/application/views/admin/pages/forms/system-users.php

https://gitlab.com/Anas7232/Layout-Changes · PHP · 177 lines · 165 code · 11 blank · 1 comment · 22 complexity · cf346e9b9319802e462d93ebf3d98c4c MD5 · raw file

  1. <div class="content-wrapper">
  2. <!-- Content Header (Page header) -->
  3. <!-- Main content -->
  4. <section class="content-header">
  5. <div class="container-fluid">
  6. <div class="row mb-2">
  7. <div class="col-sm-6">
  8. <h4>System Users</h4>
  9. </div>
  10. <div class="col-sm-6">
  11. <ol class="breadcrumb float-sm-right">
  12. <li class="breadcrumb-item"><a href="<?= base_url('admin/home') ?>">Home</a></li>
  13. <li class="breadcrumb-item active">Sytem Users</li>
  14. </ol>
  15. </div>
  16. </div>
  17. </div><!-- /.container-fluid -->
  18. </section>
  19. <section class="content">
  20. <div class="container-fluid">
  21. <div class="row">
  22. <div class="col-md-12">
  23. <div class="card card-info">
  24. <form class="form-horizontal form-submit-event" action="<?= base_url('admin/system_users/update_system_user'); ?>" method="POST" id="add_product_form" enctype="multipart/form-data">
  25. <div class="card-body row">
  26. <?php
  27. if (isset($fetched_data[0]['id'])) { ?>
  28. <input type='hidden' name='edit_system_user' value="<?= $fetched_data[0]['id'] ?>">
  29. <?php }
  30. ?>
  31. <div class="<?= (isset($fetched_data[0]['id'])) ? 'col-md-12' : 'col-md-4' ?>">
  32. <!-- form start -->
  33. <div class="form-group">
  34. <label for="username" class="control-label">Username <span class='text-danger text-sm'>*</span></label>
  35. <div class="col-md-12">
  36. <input type="text" class="form-control" name="username" id="username" value="<?= (isset($fetched_data[0]['username'])) ? $fetched_data[0]['username'] : ' ' ?>">
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label for="mobile" class="control-label">Mobile <span class='text-danger text-sm'>*</span></label>
  41. <div class="col-md-12">
  42. <input type="number" class="form-control" name="mobile" id="mobile" value="<?= (isset($fetched_data[0]['mobile'])) ? $fetched_data[0]['mobile'] : ' ' ?>">
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label for="email" class="control-label">Email <span class='text-danger text-sm'>*</span></label>
  47. <div class="col-md-12">
  48. <input type="email" class="form-control" name="email" id="email" value="<?= (isset($fetched_data[0]['email'])) ? $fetched_data[0]['email'] : ' ' ?>">
  49. </div>
  50. </div>
  51. <div class="form-group">
  52. <label for="password" class="control-label">Password <span class='text-danger text-sm'>*</span></label>
  53. <?php if (isset($fetched_data[0]['id'])) { ?>
  54. <span class='text-danger'>*Leave blank if there is no change</span>
  55. <?php } ?>
  56. <div class="col-md-12">
  57. <input type="password" class="form-control" name="password" id="password">
  58. </div>
  59. </div>
  60. <?php if (!isset($fetched_data[0]['id'])) { ?>
  61. <div class="form-group">
  62. <label for="confirm_password" class="control-label">Confirm Password <span class='text-danger text-sm'>*</span></label>
  63. <div class="col-md-12">
  64. <input type="password" class="form-control" name="confirm_password" id="confirm_password">
  65. </div>
  66. </div>
  67. <?php } ?>
  68. <div class="form-group">
  69. <label for="role" class="control-label">Role <span class='text-danger text-sm'>*</span></label>
  70. <div class="col-md-12">
  71. <select class="form-control system-user-role" name="role">
  72. <option value=" ">---Select role---</option>
  73. <option value="0" <?= (isset($fetched_data[0]['role']) && $fetched_data[0]['role'] == '0') ? 'selected' : ' ' ?>>Super Admin</option>
  74. <option value="1" <?= (isset($fetched_data[0]['role']) && $fetched_data[0]['role'] == '1') ? 'selected' : ' ' ?>>Admin</option>
  75. <option value="2" <?= (isset($fetched_data[0]['role']) && $fetched_data[0]['role'] == '2') ? 'selected' : ' ' ?>>Editor</option>
  76. </select>
  77. </div>
  78. </div>
  79. <?php if (!isset($fetched_data[0]['id'])) { ?>
  80. <div class="d-flex justify-content-center">
  81. <div class="form-group" id="error_box">
  82. </div>
  83. </div>
  84. <div class="form-group">
  85. <button type="reset" class="btn btn-warning">Reset</button>
  86. <button type="submit" class="btn btn-success" id="submit_btn">Add User</button>
  87. </div>
  88. <?php } ?>
  89. </div>
  90. <div class=" <?= (isset($fetched_data[0]['id'])) ? 'col-md-12' : 'col-md-8' ?> ">
  91. <?php
  92. if (isset($fetched_data[0]['id'])) {
  93. $user_permissions = json_decode($fetched_data[0]['permissions'], 1);
  94. }
  95. $actions = [
  96. 'create',
  97. 'read',
  98. 'update',
  99. 'delete'
  100. ];
  101. ?>
  102. <table class="table permission-table <?= ( isset($fetched_data[0]['role'] ) && $fetched_data[0]['role'] == 0 ) ? 'd-none' : '' ?>">
  103. <tr>
  104. <th>Module/Permissions</th>
  105. <?php foreach ($actions as $row) { ?>
  106. <th><?= ucfirst($row) ?></th>
  107. <?php }
  108. ?>
  109. </tr>
  110. <tbody>
  111. <?php
  112. foreach ($system_modules as $key => $value) {
  113. $flag = 0;
  114. ?>
  115. <tr>
  116. <td><?= $key ?></td>
  117. <?php for ($i = 0; $i < count($actions); $i++) {
  118. //create,update,delete
  119. $index = array_search($actions[$i], $value);
  120. if ($index !== false) {
  121. $checked = '';
  122. if (isset($user_permissions)) {
  123. if (isset($user_permissions[$key][$value[$index]])) {
  124. $checked = 'checked';
  125. } else {
  126. $checked = '';
  127. }
  128. } else {
  129. $checked = 'checked';
  130. }
  131. ?>
  132. <td> <input type="checkbox" name="<?= 'permissions[' . $key . '][' . $value[$index] . ']' ?>" data-bootstrap-switch data-off-color="danger" class='system-users-switch' data-on-color="success" <?= $checked ?>></td>
  133. <?php
  134. } else { ?>
  135. <td></td>
  136. <?php }
  137. ?>
  138. <?php } ?>
  139. </tr>
  140. <?php
  141. }
  142. ?>
  143. </tbody>
  144. </table>
  145. <?php if (isset($fetched_data[0]['id'])) { ?>
  146. <div class="d-flex justify-content-center">
  147. <div class="form-group" id="error_box">
  148. </div>
  149. </div>
  150. <div class="form-group">
  151. <button type="submit" class="btn btn-success" id="submit_btn">Update User</button>
  152. </div>
  153. <?php } ?>
  154. </div>
  155. </div>
  156. </form>
  157. </div>
  158. <!--/.card-->
  159. </div>
  160. <!--/.col-md-12-->
  161. </div>
  162. <!-- /.row -->
  163. </div><!-- /.container-fluid -->
  164. </section>
  165. <!-- /.content -->
  166. </div>