locations.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Customer $customer
  4. * @var int $include_archived
  5. * @var int $include_closed
  6. * @var int $filter_count
  7. * @var string[] $sorts
  8. * @var string $sort
  9. * @var Location[] $locations
  10. */
  11. $query = $_GET;
  12. unset($query["path"]);
  13. $query["sort"] = "SORT";
  14. $include_archived_checked = $include_archived ? "checked" : "";
  15. $include_closed_checked = $include_closed ? "checked" : "";
  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" <?=$include_archived_checked?> />
  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" <?=$include_closed_checked?> />
  133. <label class="custom-control-label"
  134. for="include-closed"><?= htmlspecialchars(__("Include Closed")) ?></label>
  135. </div>
  136. </div>
  137. <button class="btn btn-primary" type="submit">Submit</button>
  138. <a class="btn btn-secondary" href="/account/locations?customer_id=<?=$customer->id?>">Clear Filters</a>
  139. </div>
  140. </div>
  141. </div>
  142. <div class="col-lg">
  143. </div>
  144. </div>
  145. </form>
  146. </div>
  147. </div>
  148. <?php
  149. if(!empty($locations)) {
  150. ?>
  151. <div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 480px;" data-callback="initialiseLocations">
  152. </div>
  153. <?php
  154. }
  155. ?>
  156. <div class="row mb-3 align-items-center">
  157. <div class="col-sm">
  158. <strong><?=htmlspecialchars(__("Year Cycle:"))?></strong>
  159. <?=htmlspecialchars($customer->getDisplayYearCycle())?>
  160. </div>
  161. <div class="col-sm-auto">
  162. <div class="input-group">
  163. <div class="input-group-prepend">
  164. <label for="sort-dropdown" class="input-group-text">
  165. Sort
  166. </label>
  167. </div>
  168. <select class="form-control" id="sort-dropdown" data-url-template="/account/locations?<?=htmlspecialchars(http_build_query($query))?>">
  169. <?php
  170. foreach($sorts as $value => $display) {
  171. $selected = ($value == $sort) ? "selected" : "";
  172. ?>
  173. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  174. <?php
  175. }
  176. ?>
  177. </select>
  178. </div>
  179. </div>
  180. </div>
  181. <?php
  182. View::include("location_list", compact("customer", "locations"));
  183. ?>
  184. </div>
  185. <form method="post" id="locations-export-form">
  186. <input type="hidden" name="action" value="" />
  187. </form>
  188. <form method="post" id="locations-create-project-form" action="/account/projects/add?customer_id=<?=htmlspecialchars($customer->id)?>">
  189. </form>