| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- /**
- * @var int $id
- * @var string $action
- */
- use Helpers\LocationHelper;
- use Searches\LocationSearch;
- JSON::header();
- $customer = Customer::get($id);
- if(!$customer) JSON::fail("Customer not found.");
- if(!Core::$user->hasPermission($customer)) throw new Exception(__("No permission."));
- switch($action) {
- case "get-locations":
- $search = new LocationSearch($customer);
- $id = http::value("id", "int");
- $internal_id = http::value("internal_id", "trim");
- $name = http::value("name", "trim");
- $legal_entity_name = http::value("legal_entity_name", "trim");
- $include_archived = http::value("include_archived", "int");
- $include_closed = http::value("include_closed", "int");
- $min_date = http::value("min_date");
- $max_date = http::value("max_date");
- $filter = http::value("filter");
- $search->setId($id);
- $search->setInternalId($internal_id);
- $search->setName($name);
- $search->setLegalEntityName($legal_entity_name);
- $search->setIncludeArchived((bool) $include_archived);
- $search->setIncludeClosed((bool) $include_closed);
- $search->setMinTestDate($min_date);
- $search->setMaxTestDate($max_date);
- $search->setFilter($filter);
- $locations = $search->run();
- $output = LocationHelper::getMarkerDataForLocations($locations, $min_date, $max_date);
- JSON::success([
- "locations" => $output
- ]);
- break;
- }
|