customer.php 929 B

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