1
0

user_edit_form.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. $date_of_birth_parts = explode("-", $user->date_of_birth);
  3. $activated_checked = ($user->activated) ? "checked" : "";
  4. $can_claim_checked = ($user->can_claim) ? "checked" : "";
  5. ?>
  6. <script>
  7. var userId = <?=$user->id?>;
  8. </script>
  9. <div class="container mt-3 py-4">
  10. <h2>Edit User</h2>
  11. <form method="post">
  12. <div class="row">
  13. <div class="col-lg-6 mb-3">
  14. <h3>Details</h3>
  15. <div class="row mb-1">
  16. <label class="col-sm-4 col-form-label" for="level">Level</label>
  17. <div class="col-sm">
  18. <select class="form-control" name="level" id="level" required />
  19. <?php
  20. foreach(User::LEVELS as $value => $display) {
  21. if($value > Core::$user->level) continue;
  22. $selected = ($user->level == $value) ? "selected" : "";
  23. ?>
  24. <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  25. <?php
  26. }
  27. ?>
  28. </select>
  29. </div>
  30. </div>
  31. <div class="row mb-1">
  32. <div class="col-sm offset-sm-4">
  33. <div class="form-check">
  34. <input class="form-check-input" type="checkbox" name="activated" id="activated" value="1" <?=$activated_checked?> />
  35. <label class="form-check-label" for="activated">Email Verified</label>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="row mb-1">
  40. <label class="col-sm-4 col-form-label" for="title">Title</label>
  41. <div class="col-sm">
  42. <select class="form-control" name="title" id="title" required>
  43. <option value="">Select title</option>
  44. <?php
  45. foreach(User::TITLES as $title) {
  46. $selected = ($user->title == $title) ? "selected" : "";
  47. ?>
  48. <option value="<?=htmlspecialchars($title)?>" <?=$selected?>><?=htmlspecialchars($title)?></option>
  49. <?php
  50. }
  51. ?>
  52. </select>
  53. </div>
  54. </div>
  55. <div class="row mb-1">
  56. <label class="col-sm-4 col-form-label" for="first-name">First Name</label>
  57. <div class="col-sm">
  58. <input class="form-control" type="text" name="first_name" id="first-name" placeholder="Enter first name" value="<?=htmlspecialchars($user->first_name)?>" required />
  59. </div>
  60. </div>
  61. <div class="row mb-1">
  62. <label class="col-sm-4 col-form-label" for="last-name">Last Name</label>
  63. <div class="col-sm">
  64. <input class="form-control" type="text" name="last_name" id="last-name" placeholder="Enter last name" value="<?=htmlspecialchars($user->last_name)?>" required />
  65. </div>
  66. </div>
  67. <div class="row mb-1">
  68. <label class="col-sm-4 col-form-label" for="gender">Gender</label>
  69. <div class="col-sm">
  70. <select class="form-control" name="gender" id="gender" required>
  71. <option value="">Select gender</option>
  72. <?php
  73. foreach(User::GENDERS as $gender) {
  74. $display = $gender;
  75. $value = substr($gender, 0, 1);
  76. $selected = ($user->gender == $value) ? "selected" : "";
  77. ?>
  78. <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  79. <?php
  80. }
  81. ?>
  82. </select>
  83. </div>
  84. </div>
  85. <div class="row mb-1">
  86. <label class="col-sm-4 col-form-label" for="email">Email Address</label>
  87. <div class="col-sm">
  88. <input class="form-control" type="email" name="email" id="email" placeholder="Enter email address" value="<?=htmlspecialchars($user->email)?>" required />
  89. </div>
  90. </div>
  91. <div class="row mb-1">
  92. <label class="col-sm-4 col-form-label" for="phone">Mobile Number</label>
  93. <div class="col-sm">
  94. <input class="form-control" type="phone" name="phone" id="phone" placeholder="Enter mobile number" value="<?=htmlspecialchars($user->phone)?>" required />
  95. </div>
  96. </div>
  97. <div class="row mb-1">
  98. <label class="col-sm-4 col-form-label" for="password">Password (if changing)</label>
  99. <div class="col-sm">
  100. <input class="form-control" type="password" name="password" id="password" placeholder="Enter password" />
  101. <small class="text-muted form-text">At least <span data-length-requirement>6 characters</span>. Must contain at least one <span data-lowercase-requirement>lowercase</span>, <span data-uppercase-requirement>uppercase</span>, <span data-number-requirement>number</span> and <span data-special-requirement>special</span> character.</small>
  102. </div>
  103. </div>
  104. <div class="row mb-1">
  105. <label class="col-sm-4 col-form-label" for="password-confirm">Confirm Password</label>
  106. <div class="col-sm">
  107. <input class="form-control" type="password" name="password_confirm" id="password-confirm" placeholder="Confirm password" />
  108. </div>
  109. </div>
  110. <div class="row mb-1">
  111. <label class="col-sm-4 col-form-label" for="date-of-birth">Date of Birth</label>
  112. <div class="col-sm">
  113. <select class="form-control w-auto d-inline-block" name="date_of_birth_day" id="date-of-birth-day">
  114. <option value="">Day</option>
  115. <?php
  116. Form::renderDayOptions($date_of_birth_parts[2]);
  117. ?>
  118. </select>
  119. <select class="form-control w-auto d-inline-block" name="date_of_birth_month" id="date-of-birth-month">
  120. <option value="">Month</option>
  121. <?php
  122. Form::renderMonthOptions($date_of_birth_parts[1]);
  123. ?>
  124. </select>
  125. <select class="form-control w-auto d-inline-block" name="date_of_birth_year" id="date-of-birth-year">
  126. <option value="">Year</option>
  127. <?php
  128. Form::renderYearOptionsDescending(null, null, $date_of_birth_parts[0]);
  129. ?>
  130. </select>
  131. </div>
  132. </div>
  133. <div class="row mb-1">
  134. <label class="col-sm-4 col-form-label" for="reported">Reported</label>
  135. <div class="col-sm">
  136. <select class="form-control" name="reported" id="reported" />
  137. <?php
  138. foreach(Form::BOOLEAN_OPTIONS as $value => $display) {
  139. $selected = ($user->reported == $value) ? "selected" : "";
  140. ?>
  141. <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  142. <?php
  143. }
  144. ?>
  145. </select>
  146. </div>
  147. </div>
  148. <div class="row mb-1">
  149. <label class="col-sm-4 col-form-label" for="reported-comment">Reported Notes</label>
  150. <div class="col-sm">
  151. <textarea class="form-control" name="reported_comment" id="reported-comment" placeholder="Enter reported notes" rows="4"><?=htmlspecialchars($user->reported_comment)?></textarea>
  152. </div>
  153. </div>
  154. <div class="row mb-1">
  155. <label class="col-sm-4 col-form-label" for="can-claim">Enable "Find Tests"</label>
  156. <div class="col-sm">
  157. <select class="form-control" name="can_claim" id="can-claim" />
  158. <?php
  159. foreach(Form::BOOLEAN_OPTIONS as $value => $display) {
  160. $selected = ($user->can_claim == $value) ? "selected" : "";
  161. ?>
  162. <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  163. <?php
  164. }
  165. ?>
  166. </select>
  167. </div>
  168. </div>
  169. </div>
  170. <div class="col-lg-6 mb-3">
  171. <h3>Addresses</h3>
  172. <?php
  173. $addresses = $user->getAddresses();
  174. if(empty($addresses)) {
  175. ?>
  176. <div class="alert alert-info">This user does not have any addresses.</div>
  177. <?php
  178. }
  179. else {
  180. ?>
  181. <div class="mb-1" id="map" style="height: 248px;" data-maps data-lat="0" data-lng="0" data-zoom="5" data-callback="initialiseAddresses">
  182. </div>
  183. <div class="list-group">
  184. <?php
  185. foreach($addresses as $address) {
  186. ?>
  187. <div class="list-group-item">
  188. <strong><?=htmlspecialchars($address->name)?></strong><br />
  189. <small><?=htmlspecialchars($address->getDisplayAddress())?></small>
  190. </div>
  191. <?php
  192. }
  193. ?>
  194. </div>
  195. <?php
  196. }
  197. ?>
  198. </div>
  199. </div>
  200. <button class="btn btn-primary" type="submit" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">Submit</button>
  201. <a class="btn btn-secondary" href="<?=htmlspecialchars($_SERVER["HTTP_REFERER"] ?? "/account/users/$user->id")?>">Cancel</a>
  202. </form>
  203. </div>