new_sale.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App;
  3. /**
  4. * @var Customer $customer
  5. */
  6. $customers = isset($customer) ? [$customer] : Customer::getAll();
  7. ?>
  8. <div class="modal fade" role="dialog" tabindex="-1" data-backdrop="static" id="new-sale-modal">
  9. <div class="modal-dialog modal-lg">
  10. <form class="modal-content" method="post" action="/sales/submit">
  11. <?php
  12. View::include("modals/header", ["title" => __("New Sale")]);
  13. ?>
  14. <div class="modal-body">
  15. <div class="mb-3">
  16. <label for="new-sale-company-id" class="form-label">
  17. <?=htmlspecialchars(__("Company"))?>
  18. </label>
  19. <select class="form-control" name="company_id" id="new-sale-company-id">
  20. <?php
  21. foreach(Company::getAll() as $company) {
  22. ?>
  23. <option value="<?=$company->id?>">
  24. <?=htmlspecialchars($company->name)?>
  25. </option>
  26. <?php
  27. }
  28. ?>
  29. </select>
  30. </div>
  31. <div class="mb-3">
  32. <label class="form-label" for="location-id"><?= htmlspecialchars(__("Location")) ?></label>
  33. <select class="form-control" name="location_id" id="location-id">
  34. <?php
  35. foreach($customers as $customer) {
  36. ?>
  37. <optgroup label="<?=htmlspecialchars($customer->name)?>">
  38. <?php
  39. foreach($customer->getLocations() as $location) {
  40. ?>
  41. <option value="<?=$location->id?>">
  42. <?=htmlspecialchars($location->name)?>
  43. </option>
  44. <?php
  45. }
  46. ?>
  47. </optgroup>
  48. <?php
  49. }
  50. ?>
  51. </select>
  52. </div>
  53. </div>
  54. <div class="modal-footer">
  55. <button type="submit" class="btn btn-success">
  56. <?= htmlspecialchars(__("Submit")) ?>
  57. </button>
  58. </div>
  59. </form>
  60. </div>
  61. </div>