new_sale.php 1.8 KB

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