<?php
session_start();
$activePage = 'User';
$activeSubPage = 'Createuser';

if(isset($_SESSION['token'] ))
{
include("../elements/master.php");
include("create_user_api.php");

}  


?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Create User</title>
    <link rel="stylesheet" href="../css/style.css" type="text/css">
    <link rel="stylesheet" href="../css/create_user.css" type="text/css">
</head>
<body>
<div class="user_container">
<maincontent>
<div class="usertable">

<!-----------------FORM FOR BULK USERS------------------>
<!-- The Form -->
<form id="uploadForm" action="bulk_upload.php" method="POST" enctype="multipart/form-data">
  <div class="upload">
    <div class="upload_file">
      <button type="button" id="createButton">Create Bulk Users</button>
    </div>
  </div>
<!--- The Modal ---->
<div id="uploadModal" class="modal">
  <div class="modal-content">
    <span class="close">&times;</span>
    <h3>Upload Bulk Users</h3>
    <div class="upload_area">
    <input type="file" name="upload" accept=".csv" />
    <p>Only .csv files are allowed.</p>
    <span class="circle"><img src="../images/info.png" alt="image"></span> 
      <button class="upload_btn" type="submit" id="submitBtn">Submit</button>
      <div id="message"></div> 
    </div>
  </div>

  <!-----------------NEW POP UP SHOWING THE INFO------------------>
<div id="infoModal" class="info-modal">
    <div class="info-modal-content">
      <span class="info-close">&times;</span>
      <h3 class="info">Follow This To Upload Bulk Users</h3>
      <div class="sec">
      <p> <span>Required fields:</span> Pid,Firstname,Email,Role,Password.</p> 
      <p> <span>All other fields will be given a default value</span></p>
      <p> <span>Reference file:</span> <a href="../files//users.csv" download="sample.csv">sample.csv</a></p>
      </div>
    </div>
  </div>
</div>
<!--------------------NEW POP UP ENDS------------------------->
</form>  
<!-----------------FORM FOR BULK USERS ENDS------------------>


  <h3>Create User</h3>
  <div class="userdetails">
  <form action="user.php" class="form" id="createUserForm" method="POST">
    <div>
      <div class="col-10">
        <label>PID</label>
      </div>
      <div class="col-40">
        <input type="text" name="pid" placeholder="Enter Your Pid" required />
      </div>
     
      <div class="col-10">
        <label>E-MAIL</label>
      </div>
      <div class="col-40">
        <input type="text" name="email" placeholder="Enter your Email" />
      </div>
      
    </div>

    <div>
    <div class="col-10">
        <label>FIRST NAME</label>
      </div>
      <div class="col-40">
        <input type="text" name="firstname" placeholder="Enter Your First Name" required />
      </div>

      <!----------ACESS LEVEL-------------->
      <div>
        <div class="col-10">
          <label for="access">ACESS LEVEL</label>
        </div>
        <div class="col-40">
          <select name="access" id="access">
            <option>Select Access Level</option>
            <option value="ALL">ALL</option>
            <option value="NONE">NONE</option>
            <option value="User Manager">User Manager</option>
            <option value="Node Manager">Node Manager</option>
            <option value="Security Event Manager">Security Event Manager</option>
          </select>
        </div>
      </div>
    </div>

    <div>

    <div class="col-10">
        <label>LAST NAME</label>
      </div>
      <div class="col-40">
        <input type="text" name="lastname" placeholder="Enter Your Last Name" required />
      </div>
      <div class="col-10">
        <label>DESIGNATION</label>
      </div>
      <div class="col-40">
        <input type="text" name="designation" placeholder="Enter Designation" />
      </div>
    </div>

    <div>
    <div class="col-10">
        <label>VALID FROM</label>
      </div>
      <div class="col-40">
        <input type="datetime-local" id="validFrom" name="valid_from" required />
      </div>
      <!------------------------------------CALENDAR FUNCTION----------------------------------------->
      <div class="col-10 hidden">
        <label>cust_field4</label>
      </div>
      <div class="col-40 hidden">
        <input type="text" name="cust_field4" placeholder="Enter cust_field4" />
      </div>
    </div>

      <div>
      <div class="col-10">
        <label>EXPIRATION</label>
      </div>
      <div class="col-40">
        <input type="datetime-local" name="expire" required />
      </div>
    </div>

      <!------------------------------------CALENDAR FUNCTION ENDS----------------------------------------->

    <!------------- HIDDEN FIELDS------------------------>
    <div>
      <div class="col-10 hidden">
        <label>cust_field3</label>
      </div>
      <div class="col-40 hidden">
        <input type="text" name="cust_field3" placeholder="Enter cust_field3" />
      </div>


      
      <div class="col-10">
          <label for="role">ROLE</label>
        </div>
        <div class="col-40">
          <select name="role" id="role">
            <option>-----------</option>
            <?php foreach ($user_list as $role): ?>
            <option value= <?php echo $role['category_id']; ?> >    <?php echo htmlspecialchars($role['name']); ?>  </option>
            <?php endforeach; ?>
          </select>
        </div>
      </div>
      



    <div>
      <div class="col-10 hidden">
        <label>cust_field7</label>
      </div>
      <div class="col-40 hidden">
        <input type="text" name="cust_field7" placeholder="Enter cust_field7" />
      </div>

      <div class="col-10">
              <label for="access">ACTIONS</label>
          </div>
          <div class="col-40">
              <select name="actions" id="actions">
                  <option>-----------</option>
                  <option value="access_duration">ACCESS DURATION</option>
                  <option value="unregdate">UNREGISTERED USER</option>
              </select>
          </div>
    </div>

    <div>
      <div class="col-10 hidden">
        <label>cust_field9</label>
      </div>
      <div class="col-40 hidden">
        <input type="text" name="cust_field9" placeholder="Enter cust_field9" />
      </div>
      
    </div>

    <div>
      <div class="col-10 hidden">
        <label>cust_field11</label>
      </div>
      <div class="col-40 hidden">
        <input type="text" name="cust_field11" placeholder="Enter cust_field11" />
      </div>


<!-------------------                  DYNAMIC DROPDOWN                 --------------------->
      <div class="col-10">
              <label for="access">VALUE</label>
          </div>
      <div class="col-40" id="valueContainer">
              <input type="text" id="valueInput" name="value" placeholder="Select an action first" readonly />
          </div>
    </div>


<!---------------------------      DYNAMIC DROPDOWN ENDS                 -------------------->
    <?php echo  $_SESSION['message']?>

    <div class="submit">
      <div class="col-10-submit">
        <input type="submit" name="submit" id="submit2" value="submit" />
      </div>
    </div>
 </form>
</div>
</div>
    </maincontent>
</div>

<?php
if(!isset($_SESSION['token'])) {
    include('token_exp.php');
}
?>
<script src="../js/user.js"></script>
</body>
</html>
