project_form.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <?php
  2. $date_start = explode(" ", $project->dts_start)[0];
  3. $date_start_parts = explode("-", $date_start);
  4. $date_deadline = explode(" ", $project->dts_deadline)[0];
  5. $date_deadline_parts = explode("-", $date_deadline);
  6. ?>
  7. <div class="container mt-3 py-4">
  8. <h2>
  9. <?=($project->id ? "Edit" : "Add")?>
  10. Project
  11. </h2>
  12. <form method="post">
  13. <h3>Project Details</h3>
  14. <div class="row">
  15. <div class="col-lg">
  16. <div class="row mb-1">
  17. <label class="col-sm-4 col-form-label" for="name">Name</label>
  18. <div class="col-sm">
  19. <input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars($project->name)?>" required />
  20. </div>
  21. </div>
  22. <div class="row mb-1">
  23. <label class="col-sm-4 col-form-label" for="template-id">Template</label>
  24. <div class="col-sm">
  25. <select class="form-control" name="template_id" id="template-id" required>
  26. <?php
  27. foreach($templates as $template) {
  28. $selected = ($template->id == $project->template_id) ? "selected" : "";
  29. ?>
  30. <option value="<?=$template->id?>"><?=htmlspecialchars($template->name)?></option>
  31. <?php
  32. }
  33. ?>
  34. </select>
  35. </div>
  36. </div>
  37. <div class="row mb-1">
  38. <label class="col-sm-4 col-form-label" for="test-count">Test Count</label>
  39. <div class="col-sm">
  40. <input class="form-control" type="number" name="test_count" id="test-count" placeholder="Enter test count" value="<?=htmlspecialchars($project->test_count)?>" required />
  41. </div>
  42. </div>
  43. <div class="row mb-1">
  44. <label class="col-sm-4 col-form-label" for="default-tester-fee">Default Tester Fee</label>
  45. <div class="col-sm">
  46. <input class="form-control" type="number" name="default_tester_fee" id="default-tester-fee" placeholder="Enter default tester fee" value="<?=htmlspecialchars($project->default_tester_fee)?>" required />
  47. </div>
  48. </div>
  49. </div>
  50. <div class="col-lg">
  51. <div class="row mb-1">
  52. <label class="col-sm-4 col-form-label" for="min-age">Min. Age</label>
  53. <div class="col-sm">
  54. <input class="form-control" type="number" name="min_age" id="min-age" placeholder="Enter minimum age" value="<?=htmlspecialchars($project->min_age)?>" required />
  55. </div>
  56. </div>
  57. <div class="row mb-1">
  58. <label class="col-sm-4 col-form-label" for="max-age">Max. Age</label>
  59. <div class="col-sm">
  60. <input class="form-control" type="number" name="max_age" id="max-age" placeholder="Enter maximum age" value="<?=htmlspecialchars($project->max_age)?>" required />
  61. </div>
  62. </div>
  63. <div class="row mb-1">
  64. <label class="col-sm-4 col-form-label" for="date-start-day">Start Date</label>
  65. <div class="col-sm">
  66. <select class="form-control w-auto d-inline-block" name="date_start_day" id="date-start-day">
  67. <option value="">Day</option>
  68. <?php
  69. Form::renderDayOptions($date_start_parts[2]);
  70. ?>
  71. </select>
  72. <select class="form-control w-auto d-inline-block" name="date_start_month" id="date-start-month">
  73. <option value="">Month</option>
  74. <?php
  75. Form::renderMonthOptions($date_start_parts[1]);
  76. ?>
  77. </select>
  78. <select class="form-control w-auto d-inline-block" name="date_start_year" id="date-start-year">
  79. <option value="">Year</option>
  80. <?php
  81. Form::renderYearOptions(2017, date("Y") + 1, $date_start_parts[0]);
  82. ?>
  83. </select>
  84. </div>
  85. </div>
  86. <div class="row mb-1">
  87. <label class="col-sm-4 col-form-label" for="date-deadline">Deadline</label>
  88. <div class="col-sm">
  89. <select class="form-control w-auto d-inline-block" name="date_deadline_day" id="date-deadline-day">
  90. <option value="">Day</option>
  91. <?php
  92. Form::renderDayOptions($date_deadline_parts[2]);
  93. ?>
  94. </select>
  95. <select class="form-control w-auto d-inline-block" name="date_deadline_month" id="date-deadline-month">
  96. <option value="">Month</option>
  97. <?php
  98. Form::renderMonthOptions($date_deadline_parts[1]);
  99. ?>
  100. </select>
  101. <select class="form-control w-auto d-inline-block" name="date_deadline_year" id="date-deadline-year">
  102. <option value="">Year</option>
  103. <?php
  104. Form::renderYearOptions(2017, date("Y") + 1, $date_deadline_parts[0]);
  105. ?>
  106. </select>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <hr />
  112. <input type="hidden" name="location_ids" id="location-ids" value="<?=implode(", ", $location_ids)?>" />
  113. <h3>Project Locations</h3>
  114. <?php
  115. if($project->id) {
  116. ?>
  117. <div class="alert alert-warning">
  118. <div class="row">
  119. <div class="col-auto">
  120. <i class="fal fa-exclamation-triangle"></i>
  121. </div>
  122. <div class="col pl-0">
  123. Please be aware that deselecting a location will cancel the test for the project no matter its current status.<br />
  124. <strong>This action cannot be undone, you have been warned!</strong>
  125. </div>
  126. </div>
  127. </div>
  128. <?php
  129. }
  130. ?>
  131. <div class="row">
  132. <div class="col-md mb-3">
  133. <h4>Selected</h4>
  134. <div class="card">
  135. <div class="card-body">
  136. <div class="input-group">
  137. <div class="input-group-prepend">
  138. <span class="input-group-text">
  139. Filter
  140. </span>
  141. </div>
  142. <input class="form-control" type="text" placeholder="Enter name, address, ID or internal ID" data-filter-target="#selected-locations-list-group" />
  143. </div>
  144. <div class="alert alert-info mt-3 mb-0" id="selected-locations-alert">
  145. No locations selected for testing.
  146. </div>
  147. </div>
  148. <div class="list-group list-group-flush limit-height-2" id="selected-locations-list-group">
  149. <?php
  150. foreach($locations as $index => $location) {
  151. if(!in_array($location->id, $location_ids)) continue;
  152. $address = $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]);
  153. $filter_parts = array_filter([
  154. $address, $location->name
  155. ]);
  156. $filter = strtolower(implode("", $filter_parts));
  157. ?>
  158. <div class="list-group-item" data-location-id="<?=$location->id?>" data-internal-id="<?=htmlspecialchars($location->internal_id)?>" data-name="<?=htmlspecialchars($location->name)?>" data-filter-value="<?=htmlspecialchars($filter)?>">
  159. <div class="row no-gutters">
  160. <div class="col-2 text-right pr-3">
  161. <?=$location->id?>
  162. </div>
  163. <div class="col">
  164. <?=htmlspecialchars($location->name)?>
  165. <?php
  166. if($location->internal_id) {
  167. ?>
  168. <br />
  169. <small class="text-primary">Customer Internal ID: <?=htmlspecialchars($location->internal_id)?></small>
  170. <?php
  171. }
  172. ?><br />
  173. <small><?=htmlspecialchars($address)?></small>
  174. </div>
  175. <div class="col-auto align-self-center text-right">
  176. <button class="btn btn-outline-danger" type="button">
  177. <i class="fas fa-times"></i>
  178. <span class="sr-only">Deselect</span>
  179. </button>
  180. </div>
  181. </div>
  182. </div>
  183. <?php
  184. }
  185. ?>
  186. </div>
  187. </div>
  188. </div>
  189. <div class="col-md mb-3">
  190. <h4>Not Selected</h4>
  191. <div class="card">
  192. <div class="card-body">
  193. <div class="input-group">
  194. <div class="input-group-prepend">
  195. <span class="input-group-text">
  196. Filter
  197. </span>
  198. </div>
  199. <input class="form-control" type="text" placeholder="Enter name, address, ID or internal ID" data-filter-target="#not-selected-locations-list-group" />
  200. </div>
  201. <div class="alert alert-info mt-3 mb-0" id="not-selected-locations-alert">
  202. No additional locations are available for testing.
  203. </div>
  204. </div>
  205. <div class="list-group list-group-flush limit-height-2" id="not-selected-locations-list-group">
  206. <?php
  207. foreach($locations as $index => $location) {
  208. if(in_array($location->id, $location_ids)) continue;
  209. $address = $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]);
  210. $filter_parts = array_filter([
  211. $address, $location->name
  212. ]);
  213. $filter = strtolower(implode("", $filter_parts));
  214. ?>
  215. <div class="list-group-item" data-location-id="<?=$location->id?>" data-internal-id="<?=htmlspecialchars($location->internal_id)?>" data-name="<?=htmlspecialchars($location->name)?>" data-filter-value="<?=htmlspecialchars($filter)?>">
  216. <div class="row no-gutters">
  217. <div class="col-2 text-right pr-3">
  218. <?=$location->id?>
  219. </div>
  220. <div class="col">
  221. <?=htmlspecialchars($location->name)?>
  222. <?php
  223. if($location->internal_id) {
  224. ?>
  225. <br />
  226. <small class="text-primary">Customer Internal ID: <?=htmlspecialchars($location->internal_id)?></small>
  227. <?php
  228. }
  229. ?>
  230. <br />
  231. <small><?=htmlspecialchars($address)?></small>
  232. </div>
  233. <div class="col-auto align-self-center text-right">
  234. <button class="btn btn-outline-success" type="button">
  235. <i class="fas fa-check"></i>
  236. <span class="sr-only">Select</span>
  237. </button>
  238. </div>
  239. </div>
  240. </div>
  241. <?php
  242. }
  243. ?>
  244. </div>
  245. </div>
  246. </div>
  247. </div>
  248. <hr />
  249. <button class="btn btn-primary" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Submit</button>
  250. </form>
  251. </div>