locations.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Customer $customer
  4. * @var int $include_archived
  5. * @var int $include_closed
  6. * @var int $hide_tested
  7. * @var int $filter_count
  8. * @var string[] $sorts
  9. * @var string $sort
  10. * @var Location[] $locations
  11. * @var Test[] $latest_tests
  12. */
  13. $query = $_GET;
  14. unset($query["path"]);
  15. $query["sort"] = "SORT";
  16. ?>
  17. <script>
  18. var customerId = <?=$customer->id?>;
  19. </script>
  20. <div class="container mt-3 py-4">
  21. <div class="row">
  22. <div class="col-lg">
  23. <h2>
  24. <?=htmlspecialchars($customer->name)?> Locations
  25. <span class="badge badge-pill badge-primary"><?=number_format(count($locations))?></span>
  26. </h2>
  27. </div>
  28. <div class="col-lg-auto">
  29. <div class="form-group">
  30. <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#project-filters">
  31. Toggle Filters
  32. <?php
  33. if($filter_count > 0) {
  34. ?>
  35. <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  36. <?php
  37. }
  38. ?>
  39. </button>
  40. <div class="dropdown d-inline-block">
  41. <button class="btn btn-primary dropdown-toggle" type="button" id="location-actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  42. Actions
  43. </button>
  44. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="location-actions-button">
  45. <button id="create-project-button" class="dropdown-item" disabled>
  46. <?=htmlspecialchars(__("Create Project"))?>
  47. </button>
  48. <button id="add-locations-to-project-button" class="dropdown-item" data-toggle="modal" data-target="#add-locations-to-project-modal" disabled>
  49. <?=htmlspecialchars(__("Add to Project"))?>
  50. </button>
  51. <div class="dropdown-divider"></div>
  52. <a id="export-csv-button" class="dropdown-item" href="/account/locations?customer_id=<?=$customer->id?>&amp;action=export" data-action="export">Export CSV</a>
  53. <a id="export-kml-button" class="dropdown-item" href="/account/locations?customer_id=<?=$customer->id?>&amp;action=export-kml" data-action="export-kml">Export KML</a>
  54. </div>
  55. </div>
  56. <a class="btn btn-success" href="/account/locations/add?customer_id=<?=$customer->id?>">Add Location</a>
  57. </div>
  58. </div>
  59. </div>
  60. <?php
  61. $filters_show = $filter_count > 0 ? "show" : "";
  62. ?>
  63. <div class="collapse <?=$filters_show?>" id="project-filters">
  64. <div class="card card-body bg-light text-dark mb-3">
  65. <h3>Filters</h3>
  66. <form method="get">
  67. <input type="hidden" name="customer_id" value="<?=http::value("customer_id", "int")?>" />
  68. <div class="row">
  69. <div class="col-lg-6">
  70. <div class="row form-group">
  71. <label class="col-sm-4 col-form-label" for="id">ID</label>
  72. <div class="col-sm">
  73. <input class="form-control" type="number" name="id" id="id" placeholder="Enter ID" value="<?=htmlspecialchars(http::value("id", "int"))?>" />
  74. </div>
  75. </div>
  76. </div>
  77. <div class="col-lg-6">
  78. <div class="row form-group">
  79. <label class="col-sm-4 col-form-label" for="internal-id">Internal ID</label>
  80. <div class="col-sm">
  81. <input class="form-control" type="text" name="internal_id" id="internal-id" placeholder="Enter internal ID" value="<?=htmlspecialchars(http::value("internal_id", "trim"))?>" />
  82. </div>
  83. </div>
  84. </div>
  85. <div class="col-lg-6">
  86. <div class="row form-group">
  87. <label class="col-sm-4 col-form-label" for="name">Name</label>
  88. <div class="col-sm">
  89. <input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars(http::value("name"))?>" />
  90. </div>
  91. </div>
  92. </div>
  93. <div class="col-lg-6">
  94. <div class="row form-group">
  95. <label class="col-sm-4 col-form-label" for="legal-entity-name">Legal Entity Name</label>
  96. <div class="col-sm">
  97. <input class="form-control" type="text" name="legal_entity_name" id="legal-entity-name" placeholder="Enter legal entity name" value="<?=htmlspecialchars(http::value("legal_entity_name"))?>" />
  98. </div>
  99. </div>
  100. </div>
  101. <div class="col-lg-6">
  102. <div class="row form-group">
  103. <label class="col-sm-4 col-form-label" for="min-date">Min. Test Date</label>
  104. <div class="col-sm">
  105. <input class="form-control" type="date" name="min_date" id="min-date" placeholder="Select date" value="<?=htmlspecialchars(http::value("min_date"))?>" />
  106. </div>
  107. </div>
  108. </div>
  109. <div class="col-lg-6">
  110. <div class="row form-group">
  111. <label class="col-sm-4 col-form-label" for="max-date">Max. Test Date</label>
  112. <div class="col-sm">
  113. <input class="form-control" type="date" name="max_date" id="max-date" placeholder="Select date" value="<?=htmlspecialchars(http::value("max_date"))?>" />
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div class="row">
  119. <div class="col-lg">
  120. <div class="row">
  121. <div class="col-sm offset-sm-4">
  122. <div class="form-group">
  123. <div class="custom-control custom-switch">
  124. <input class="custom-control-input" id="include-archived" name="include_archived"
  125. type="checkbox" value="1" <?=HtmlHelper::checked($include_archived)?> />
  126. <label class="custom-control-label"
  127. for="include-archived"><?= htmlspecialchars(__("Include Archived")) ?></label>
  128. </div>
  129. <div class="custom-control custom-switch">
  130. <input class="custom-control-input" id="include-closed" name="include_closed"
  131. type="checkbox"
  132. value="1" <?=HtmlHelper::checked($include_closed)?> />
  133. <label class="custom-control-label"
  134. for="include-closed"><?= htmlspecialchars(__("Include Closed")) ?></label>
  135. </div>
  136. <div class="custom-control custom-switch">
  137. <input class="custom-control-input" id="hide-tested" name="hide_tested"
  138. type="checkbox"
  139. value="1" <?=HtmlHelper::checked($hide_tested)?>/>
  140. <label class="custom-control-label"
  141. for="hide-tested"><?= htmlspecialchars(__("Only Show Untested")) ?></label>
  142. </div>
  143. </div>
  144. <button class="btn btn-primary" type="submit">Submit</button>
  145. <a class="btn btn-secondary" href="/account/locations?customer_id=<?=$customer->id?>">Clear Filters</a>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="col-lg">
  150. </div>
  151. </div>
  152. </form>
  153. </div>
  154. </div>
  155. <?php
  156. if(!empty($locations)) {
  157. ?>
  158. <h3>
  159. <?=htmlspecialchars(__("Map"))?>
  160. <span id="map-marker-count" class="badge badge-pill badge-primary"></span>
  161. </h3>
  162. <div class="form-row">
  163. <div class="col-md">
  164. <div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 480px;" data-callback="initialiseLocations">
  165. </div>
  166. </div>
  167. <div class="col-md-auto small">
  168. <h5>Legend</h5>
  169. <?php
  170. View::include("legend_locations");
  171. ?>
  172. </div>
  173. </div>
  174. <?php
  175. }
  176. ?>
  177. <div class="row mb-3 align-items-center">
  178. <div class="col-sm">
  179. <strong><?=htmlspecialchars(__("Year Cycle:"))?></strong>
  180. <?=htmlspecialchars($customer->getDisplayYearCycle())?>
  181. </div>
  182. <div class="col-sm-auto">
  183. <div class="input-group">
  184. <div class="input-group-prepend">
  185. <label for="sort-dropdown" class="input-group-text">
  186. Sort
  187. </label>
  188. </div>
  189. <select class="form-control" id="sort-dropdown" data-url-template="/account/locations?<?=htmlspecialchars(http_build_query($query))?>">
  190. <?php
  191. foreach($sorts as $value => $display) {
  192. $selected = ($value == $sort) ? "selected" : "";
  193. ?>
  194. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  195. <?php
  196. }
  197. ?>
  198. </select>
  199. </div>
  200. </div>
  201. </div>
  202. <?php
  203. View::include("location_list", compact("customer", "locations", "latest_tests"));
  204. ?>
  205. </div>
  206. <form method="post" id="locations-export-form">
  207. <input type="hidden" name="action" value="" />
  208. </form>
  209. <form method="post" id="locations-create-project-form" action="/account/projects/add?customer_id=<?=htmlspecialchars($customer->id)?>">
  210. </form>