editUser.php 3.7 KB

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