locations.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 array $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>
  102. <div class="row">
  103. <div class="col-lg">
  104. <div class="row">
  105. <div class="col-sm offset-sm-4">
  106. <div class="form-group">
  107. <div class="custom-control custom-switch">
  108. <input class="custom-control-input" id="include-archived" name="include_archived"
  109. type="checkbox" value="1" <?=$include_archived_checked?> />
  110. <label class="custom-control-label"
  111. for="include-archived"><?= htmlspecialchars(__("Include Archived")) ?></label>
  112. </div>
  113. <div class="custom-control custom-switch">
  114. <input class="custom-control-input" id="include-closed" name="include_closed"
  115. type="checkbox"
  116. value="1" <?=$include_closed_checked?> />
  117. <label class="custom-control-label"
  118. for="include-closed"><?= htmlspecialchars(__("Include Closed")) ?></label>
  119. </div>
  120. </div>
  121. <button class="btn btn-primary" type="submit">Submit</button>
  122. <a class="btn btn-secondary" href="/account/locations?customer_id=<?=$customer->id?>">Clear Filters</a>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="col-lg">
  127. </div>
  128. </div>
  129. </form>
  130. </div>
  131. </div>
  132. <?php
  133. if(!empty($locations)) {
  134. ?>
  135. <div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 480px;" data-callback="initialiseLocations">
  136. </div>
  137. <?php
  138. }
  139. ?>
  140. <div class="row mb-3">
  141. <div class="col-sm">
  142. </div>
  143. <div class="col-sm-auto">
  144. <div class="input-group">
  145. <div class="input-group-prepend">
  146. <label for="sort-dropdown" class="input-group-text">
  147. Sort
  148. </label>
  149. </div>
  150. <select class="form-control" id="sort-dropdown" data-url-template="/account/locations?<?=htmlspecialchars(http_build_query($query))?>">
  151. <?php
  152. foreach($sorts as $value => $display) {
  153. $selected = ($value == $sort) ? "selected" : "";
  154. ?>
  155. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  156. <?php
  157. }
  158. ?>
  159. </select>
  160. </div>
  161. </div>
  162. </div>
  163. <?php
  164. View::include("location_list", compact("locations"));
  165. ?>
  166. </div>
  167. <form method="post" id="locations-export-form">
  168. <input type="hidden" name="action" value="" />
  169. </form>
  170. <form method="post" id="locations-create-project-form" action="/account/projects/add?customer_id=<?=htmlspecialchars($customer->id)?>">
  171. </form>