project_form.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. $date_start = explode(" ", $project->dts_start)[0];
  3. $date_deadline = explode(" ", $project->dts_deadline)[0];
  4. ?>
  5. <div class="container mt-3 py-4">
  6. <h2>
  7. <?=($project->id ? "Edit" : "Add")?>
  8. Project
  9. </h2>
  10. <form method="post">
  11. <h3>Project Details</h3>
  12. <div class="form-group">
  13. <label for="name">Name</label>
  14. <input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars($project->name)?>" required />
  15. </div>
  16. <div class="form-group">
  17. <label for="template-id">Template</label>
  18. <select class="form-control" name="template_id" id="template-id" required>
  19. <?php
  20. foreach($templates as $template) {
  21. $selected = ($template->id == $project->template_id) ? "selected" : "";
  22. ?>
  23. <option value="<?=$template->id?>"><?=htmlspecialchars($template->name)?></option>
  24. <?php
  25. }
  26. ?>
  27. </select>
  28. </div>
  29. <div class="form-group">
  30. <label for="test-count">Test Count</label>
  31. <input class="form-control" type="number" name="test_count" id="test-count" placeholder="Enter test count" value="<?=htmlspecialchars($project->test_count)?>" required />
  32. </div>
  33. <div class="row">
  34. <div class="col">
  35. <div class="form-group">
  36. <label for="min-age">Min. Age</label>
  37. <input class="form-control" type="number" name="min_age" id="min-age" placeholder="Enter minimum age" value="<?=htmlspecialchars($project->min_age)?>" required />
  38. </div>
  39. </div>
  40. <div class="col">
  41. <div class="form-group">
  42. <label for="max-age">Max. Age</label>
  43. <input class="form-control" type="number" name="max_age" id="max-age" placeholder="Enter maximum age" value="<?=htmlspecialchars($project->max_age)?>" required />
  44. </div>
  45. </div>
  46. </div>
  47. <div class="form-group">
  48. <label for="default-tester-fee">Default Tester Fee</label>
  49. <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 />
  50. </div>
  51. <div class="row">
  52. <div class="col">
  53. <div class="form-group">
  54. <label for="date-start">Start Date</label>
  55. <input class="form-control" type="date" name="date_start" id="date-start" placeholder="Enter start date" value="<?=htmlspecialchars($date_start)?>" required />
  56. </div>
  57. </div>
  58. <div class="col">
  59. <div class="form-group">
  60. <label for="date-deadline">Deadline</label>
  61. <input class="form-control" type="date" name="date_deadline" id="date-deadline" placeholder="Enter deadline" value="<?=htmlspecialchars($date_deadline)?>" required />
  62. </div>
  63. </div>
  64. </div>
  65. <hr />
  66. <input type="hidden" name="location_ids" id="location-ids" value="<?=implode(", ", $location_ids)?>" />
  67. <h3>Project Locations</h3>
  68. <?php
  69. if($project->id) {
  70. ?>
  71. <div class="alert alert-warning">
  72. <div class="row">
  73. <div class="col-auto">
  74. <i class="fal fa-exclamation-triangle"></i>
  75. </div>
  76. <div class="col pl-0">
  77. Please be aware that deselecting a location will cancel the test for the project no matter its current status.<br />
  78. <strong>This action cannot be undone, you have been warned!</strong>
  79. </div>
  80. </div>
  81. </div>
  82. <?php
  83. }
  84. ?>
  85. <div class="row">
  86. <div class="col-md mb-3">
  87. <h4>Selected</h4>
  88. <div class="list-group" id="selected-locations-list-group">
  89. <?php
  90. foreach($locations as $index => $location) {
  91. if(!in_array($location->id, $location_ids)) continue;
  92. ?>
  93. <div class="list-group-item" data-location-id="<?=$location->id?>" data-name="<?=htmlspecialchars($location->name)?>">
  94. <div class="row">
  95. <div class="col-auto">
  96. <?=htmlspecialchars($location->name)?><br />
  97. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]))?></small>
  98. </div>
  99. <div class="col align-self-center text-right">
  100. <button class="btn btn-outline-danger" type="button">Deselect</button>
  101. </div>
  102. </div>
  103. </div>
  104. <?php
  105. }
  106. ?>
  107. </div>
  108. <div class="alert alert-info" id="selected-locations-alert">
  109. No locations selected for testing.
  110. </div>
  111. </div>
  112. <div class="col-md mb-3">
  113. <h4>Not Selected</h4>
  114. <div class="list-group" id="not-selected-locations-list-group">
  115. <?php
  116. foreach($locations as $index => $location) {
  117. if(in_array($location->id, $location_ids)) continue;
  118. ?>
  119. <div class="list-group-item" data-location-id="<?=$location->id?>" data-name="<?=htmlspecialchars($location->name)?>">
  120. <div class="row">
  121. <div class="col-auto">
  122. <?=htmlspecialchars($location->name)?><br />
  123. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]))?></small>
  124. </div>
  125. <div class="col align-self-center text-right">
  126. <button class="btn btn-outline-success" type="button">Select</button>
  127. </div>
  128. </div>
  129. </div>
  130. <?php
  131. }
  132. ?>
  133. </div>
  134. <div class="alert alert-info" id="not-selected-locations-alert">
  135. No additional locations are available for testing.
  136. </div>
  137. </div>
  138. </div>
  139. <hr />
  140. <button class="btn btn-primary" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Submit</button>
  141. </form>
  142. </div>