locations.php 8.0 KB

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