customer.php 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use RuntimeException;
  4. /**
  5. * @var int $id
  6. */
  7. $customer = Customer::get($id);
  8. if(!$customer) {
  9. throw new RuntimeException(__("Customer not found."));
  10. }
  11. $core = Core::getInstance();
  12. $core->addBreadcrumb("/customers", __("Customers"));
  13. $core->addBreadcrumb($customer->getUrl(), $customer->name);
  14. $user = $core->getUser();
  15. $user->requireAdmin();
  16. $core->addScript("/js/new-sale-modal.js");
  17. $core->addScript("/js/ticket-modal.js");
  18. $core->addScript("/js/map.js");
  19. $location_ids = array_column($customer->getLocations(), "id");
  20. $sales = Sale::query([
  21. "location_id" => $location_ids,
  22. "dts_deleted" => null
  23. ]);
  24. $tickets = Ticket::query([
  25. "location_id" => $location_ids,
  26. "dts_deleted" => null
  27. ]);
  28. View::include("header");
  29. View::include("customer", compact("customer", "sales", "tickets"));
  30. View::include("modals/new_sale", compact("customer"));
  31. View::include("modals/ticket", compact("customer"));
  32. View::include("footer");