customer.php 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. $location_ids = array_column($customer->getLocations(), "id");
  19. $sales = Sale::query([
  20. "location_id" => $location_ids,
  21. "dts_deleted" => null
  22. ]);
  23. $tickets = Ticket::query([
  24. "location_id" => $location_ids,
  25. "dts_deleted" => null
  26. ]);
  27. View::include("header");
  28. View::include("customer", compact("customer", "sales", "tickets"));
  29. View::include("modals/new_sale", compact("customer"));
  30. View::include("modals/ticket", compact("customer"));
  31. View::include("footer");