locations.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Customer $customer
  4. * @var int $filter_count
  5. * @var array $sorts
  6. * @var string $sort
  7. * @var Location[] $locations
  8. */
  9. $query = $_GET;
  10. unset($query["path"]);
  11. $query["sort"] = "SORT";
  12. ?>
  13. <script>
  14. var customerId = <?=$customer->id?>;
  15. </script>
  16. <div class="container mt-3 py-4">
  17. <div class="row">
  18. <div class="col-lg">
  19. <h2>
  20. <?=htmlspecialchars($customer->name)?> Locations
  21. <span class="badge badge-pill badge-primary"><?=number_format(count($locations))?></span>
  22. </h2>
  23. </div>
  24. <div class="col-lg-auto">
  25. <div class="form-group">
  26. <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#project-filters">
  27. Toggle Filters
  28. <?php
  29. if($filter_count > 0) {
  30. ?>
  31. <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  32. <?php
  33. }
  34. ?>
  35. </button>
  36. <div class="dropdown d-inline-block">
  37. <button class="btn btn-primary dropdown-toggle" type="button" id="location-actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  38. Actions
  39. </button>
  40. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="location-actions-button">
  41. <button id="create-project-button" class="dropdown-item" disabled>Create Project...</button>
  42. <div class="dropdown-divider"></div>
  43. <a id="export-csv-button" class="dropdown-item" href="/account/locations?customer_id=<?=$customer->id?>&amp;action=export" data-action="export">Export CSV</a>
  44. <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>
  45. </div>
  46. </div>
  47. <a class="btn btn-success" href="/account/locations/add?customer_id=<?=$customer->id?>">Add Location</a>
  48. </div>
  49. </div>
  50. </div>
  51. <?php
  52. $filters_show = $filter_count > 0 ? "show" : "";
  53. ?>
  54. <div class="collapse <?=$filters_show?>" id="project-filters">
  55. <div class="card card-body bg-light text-dark mb-3">
  56. <h3>Filters</h3>
  57. <form method="get">
  58. <input type="hidden" name="customer_id" value="<?=http::value("customer_id", "int")?>" />
  59. <div class="row">
  60. <div class="col-lg-6">
  61. <div class="row mb-1">
  62. <label class="col-sm-4 col-form-label" for="id">ID</label>
  63. <div class="col-sm">
  64. <input class="form-control" type="number" name="id" id="id" placeholder="Enter ID" value="<?=htmlspecialchars(http::value("id", "int"))?>" />
  65. </div>
  66. </div>
  67. </div>
  68. <div class="col-lg-6">
  69. <div class="row mb-1">
  70. <label class="col-sm-4 col-form-label" for="internal-id">Internal ID</label>
  71. <div class="col-sm">
  72. <input class="form-control" type="text" name="internal_id" id="internal-id" placeholder="Enter internal ID" value="<?=htmlspecialchars(http::value("internal_id", "trim"))?>" />
  73. </div>
  74. </div>
  75. </div>
  76. <div class="col-lg-6">
  77. <div class="row mb-1">
  78. <label class="col-sm-4 col-form-label" for="name">Name</label>
  79. <div class="col-sm">
  80. <input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars(http::value("name"))?>" />
  81. </div>
  82. </div>
  83. </div>
  84. <div class="col-lg-6">
  85. <div class="row mb-1">
  86. <label class="col-sm-4 col-form-label" for="legal-entity-name">Legal Entity Name</label>
  87. <div class="col-sm">
  88. <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"))?>" />
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="row">
  94. <div class="col-lg">
  95. <div class="row">
  96. <div class="col-sm offset-sm-4">
  97. <button class="btn btn-primary" type="submit">Submit</button>
  98. <a class="btn btn-secondary" href="/account/locations?customer_id=<?=$customer->id?>">Clear Filters</a>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="col-lg">
  103. </div>
  104. </div>
  105. </form>
  106. </div>
  107. </div>
  108. <?php
  109. if(!empty($locations)) {
  110. ?>
  111. <div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 320px;" data-callback="initialiseLocations">
  112. </div>
  113. <?php
  114. }
  115. ?>
  116. <div class="row mb-3">
  117. <div class="col-sm">
  118. </div>
  119. <div class="col-sm-auto">
  120. <div class="input-group">
  121. <div class="input-group-prepend">
  122. <label for="sort-dropdown" class="input-group-text">
  123. Sort
  124. </label>
  125. </div>
  126. <select class="form-control" id="sort-dropdown" data-url-template="/account/locations?<?=htmlspecialchars(http_build_query($query))?>">
  127. <?php
  128. foreach($sorts as $value => $display) {
  129. $selected = ($value == $sort) ? "selected" : "";
  130. ?>
  131. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  132. <?php
  133. }
  134. ?>
  135. </select>
  136. </div>
  137. </div>
  138. </div>
  139. <?php
  140. View::include("location_list", compact("locations"));
  141. ?>
  142. </div>
  143. <form method="post" id="locations-export-form">
  144. <input type="hidden" name="action" value="" />
  145. </form>
  146. <form method="post" id="locations-create-project-form" action="/account/projects/add?customer_id=<?=htmlspecialchars($customer->id)?>">
  147. </form>