addUser.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. require "connectionDb.php";
  3. if (isset($_POST['add']) && $_POST['role']!='super' && $_POST['username']!='super' && $_POST['email']!='super' ) {
  4. $role = $_POST['role'];
  5. $id = $_POST['user_id'];
  6. $username = $_POST['username'];
  7. $email = $_POST['email'];
  8. $password = $_POST['password'];
  9. $passcode = generate_password();
  10. $pumplist = $_POST['pumplist'];
  11. $pumpliststr = implode(",", $pumplist);
  12. $sql ="INSERT INTO user SET created_at=strftime('%Y-%m-%d %H:%M:%f000000+06:30', 'now', 'localtime'),updated_at=strftime('%Y-%m-%d %H:%M:%f000000+06:30', 'now', 'localtime'), name='$username', email='$email', password='$password',role='$role',pump_list='$pumpliststr',pass_code='$passcode' WHERE id='$id'";
  13. $db->exec($sql);
  14. echo '<script>window.location.href="index.php"</script>';
  15. }
  16. ?>
  17. <style type="text/css">
  18. .editUserForm {
  19. display: none;
  20. }
  21. input[type=checkbox] {
  22. position: relative;
  23. cursor: pointer;
  24. margin: .4rem;
  25. }
  26. input[type=checkbox]:before {
  27. content: "";
  28. display: block;
  29. position: absolute;
  30. width: 16px;
  31. height: 16px;
  32. top: 0;
  33. left: 0;
  34. border: 2px solid #555555;
  35. border-radius: 3px;
  36. background-color: white;
  37. }
  38. input[type=checkbox]:checked:after {
  39. content: "";
  40. display: block;
  41. width: 5px;
  42. height: 10px;
  43. border: solid black;
  44. border-width: 0 2px 2px 0;
  45. -webkit-transform: rotate(45deg);
  46. -ms-transform: rotate(45deg);
  47. transform: rotate(45deg);
  48. position: absolute;
  49. top: 2px;
  50. left: 6px;
  51. }
  52. </style>
  53. <div class="container editUserForm" id="editUserForm">
  54. <form class="form-horizontal" action="" method="post">
  55. <input type="number" name="user_id" id="id" hidden="true">
  56. <div class="form-group">
  57. <label class="control-label col-sm-2"> Name </label>
  58. <div class="col-sm-10">
  59. <input id="username" type="text" name="username">
  60. </div>
  61. </div>
  62. <div class="form-group">
  63. <label class="control-label col-sm-2"> Role </label>
  64. <div class="col-sm-4">
  65. <select class="col-sm-6" id="role" name="role">
  66. <option value="cashier">cashier</option>
  67. <option value="user">user</option>
  68. <option value="supervisor">supervisor</option>
  69. <option value="super">super</option>
  70. </select>
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. <label class="control-label col-sm-2"> Email </label>
  75. <div class="col-sm-10">
  76. <input id="email" type="text" name="email" disabled="true">
  77. </div>
  78. </div>
  79. <div class="form-group">
  80. <label class="control-label col-sm-2"> Password </label>
  81. <div class="col-sm-10">
  82. <input id="password" type="text" name="password" disabled="true">
  83. </div>
  84. </div>
  85. <div class="form-group">
  86. <label class="control-label col-sm-2"> POS passcode </label>
  87. <div class="col-sm-10">
  88. <input id="passcode" type="text" name="passcode" disabled="true">
  89. </div>
  90. </div>
  91. <div class="form-group">
  92. <label class="control-label col-sm-2"> Pump List </label>
  93. <div class="col-sm-10">
  94. <!-- <input id="pumplist1" type="checkbox" name="pumplist" value="1"> 1
  95. <input id="pumplist" type="checkbox" name="pumplist" value="2"> 2 -->
  96. <?php
  97. for($i=1;$i<=24;$i++){
  98. echo ' <input id="pumplist'.$i.'" type="checkbox" name="pumplist[]" value="'.$i.'"> '.$i;
  99. if ($i==12) {
  100. echo "<br>";
  101. }
  102. }
  103. ?>
  104. </div>
  105. </div>
  106. <div class="form-group">
  107. <div class="col-sm-offset-2 col-sm-10">
  108. <input type="submit" name="add" value="Submit" class="btn btn-success">
  109. <input type="button" value="Cancel" class="btn btn-danger" onclick="document.getElementById('editVForm').style.display = 'none';">
  110. </div>
  111. </div>
  112. </form>
  113. </div>