locations.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. */
  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>
  117. <div class="row">
  118. <div class="col-lg">
  119. <div class="row">
  120. <div class="col-sm offset-sm-4">
  121. <div class="form-group">
  122. <div class="custom-control custom-switch">
  123. <input class="custom-control-input" id="include-archived" name="include_archived"
  124. type="checkbox" value="1" <?=HtmlHelper::checked($include_archived)?> />
  125. <label class="custom-control-label"
  126. for="include-archived"><?= htmlspecialchars(__("Include Archived")) ?></label>
  127. </div>
  128. <div class="custom-control custom-switch">
  129. <input class="custom-control-input" id="include-closed" name="include_closed"
  130. type="checkbox"
  131. value="1" <?=HtmlHelper::checked($include_closed)?> />
  132. <label class="custom-control-label"
  133. for="include-closed"><?= htmlspecialchars(__("Include Closed")) ?></label>
  134. </div>
  135. <div class="custom-control custom-switch">
  136. <input class="custom-control-input" id="hide-tested" name="hide_tested"
  137. type="checkbox"
  138. value="1" <?=HtmlHelper::checked($hide_tested)?>/>
  139. <label class="custom-control-label"
  140. for="hide-tested"><?= htmlspecialchars(__("Hide Tested On Map")) ?></label>
  141. </div>
  142. </div>
  143. <button class="btn btn-primary" type="submit">Submit</button>
  144. <a class="btn btn-secondary" href="/account/locations?customer_id=<?=$customer->id?>">Clear Filters</a>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="col-lg">
  149. </div>
  150. </div>
  151. </form>
  152. </div>
  153. </div>
  154. <?php
  155. if(!empty($locations)) {
  156. ?>
  157. <h3>
  158. <?=htmlspecialchars(__("Map"))?>
  159. <span id="map-marker-count" class="badge badge-pill badge-primary"></span>
  160. </h3>
  161. <div class="form-row">
  162. <div class="col-md">
  163. <div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 480px;" data-callback="initialiseLocations">
  164. </div>
  165. </div>
  166. <div class="col-md-auto small">
  167. <h5>Legend</h5>
  168. <?php
  169. View::include("legend_locations");
  170. ?>
  171. </div>
  172. </div>
  173. <?php
  174. }
  175. ?>
  176. <div class="row mb-3 align-items-center">
  177. <div class="col-sm">
  178. <strong><?=htmlspecialchars(__("Year Cycle:"))?></strong>
  179. <?=htmlspecialchars($customer->getDisplayYearCycle())?>
  180. </div>
  181. <div class="col-sm-auto">
  182. <div class="input-group">
  183. <div class="input-group-prepend">
  184. <label for="sort-dropdown" class="input-group-text">
  185. Sort
  186. </label>
  187. </div>
  188. <select class="form-control" id="sort-dropdown" data-url-template="/account/locations?<?=htmlspecialchars(http_build_query($query))?>">
  189. <?php
  190. foreach($sorts as $value => $display) {
  191. $selected = ($value == $sort) ? "selected" : "";
  192. ?>
  193. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  194. <?php
  195. }
  196. ?>
  197. </select>
  198. </div>
  199. </div>
  200. </div>
  201. <?php
  202. View::include("location_list", compact("customer", "locations"));
  203. ?>
  204. </div>
  205. <form method="post" id="locations-export-form">
  206. <input type="hidden" name="action" value="" />
  207. </form>
  208. <form method="post" id="locations-create-project-form" action="/account/projects/add?customer_id=<?=htmlspecialchars($customer->id)?>">
  209. </form>