new_document.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. /**
  4. * @var Customer $customer
  5. */
  6. use App\Helpers\HtmlHelper;
  7. $core = Core::getInstance();
  8. $settings = $core->getSettings();
  9. $products = Product::query([], ["sort" => "name"]);
  10. $request = Request::fromRequest();
  11. $default_location_id = $request->int("add_location_id");
  12. $location_options = [];
  13. if(!isset($customer)) {
  14. foreach(Customer::getAll() as $customer) {
  15. foreach($customer->getLocations() as $location) {
  16. $location_options[$location->id] = $location->getDisplayName();
  17. }
  18. }
  19. }
  20. else {
  21. foreach($customer->getLocations() as $location) {
  22. $location_options[$location->id] = $location->getDisplayName();
  23. }
  24. }
  25. ?>
  26. <div class="modal fade" role="dialog" tabindex="-1" data-backdrop="static" id="new-document-modal">
  27. <div class="modal-dialog modal-lg">
  28. <form class="modal-content" method="post" action="/documents/submit">
  29. <?php
  30. View::include("modals/header", ["title" => __("New Document")]);
  31. ?>
  32. <input type="hidden" name="ticket_id" value="" />
  33. <div class="modal-body">
  34. <div class="mb-3">
  35. <label class="form-label" for="new-document-company-id"><?= htmlspecialchars(__("Company")) ?></label>
  36. <select class="form-select" name="company_id" id="new-document-company-id" required>
  37. <option value=""><?=htmlspecialchars(__("Select Company"))?></option>
  38. <?php
  39. HtmlHelper::renderOptions(Company::getOptions(), $settings->defaultCompanyId ?? null);
  40. ?>
  41. </select>
  42. </div>
  43. <div class="mb-3">
  44. <label class="form-label" for="new-document-supplier-id"><?= htmlspecialchars(__("Supplier")) ?></label>
  45. <select class="form-select" name="supplier_id" id="new-document-supplier-id">
  46. <option value=""><?=htmlspecialchars(__("Select Supplier"))?></option>
  47. <?php
  48. foreach(Supplier::getAll() as $supplier) {
  49. ?>
  50. <option value="<?=$supplier->id?>">
  51. <?=htmlspecialchars($supplier->name)?>
  52. </option>
  53. <?php
  54. }
  55. ?>
  56. </select>
  57. </div>
  58. <div class="mb-3">
  59. <label class="form-label" for="new-document-location-id"><?= htmlspecialchars(__("Location")) ?></label>
  60. <select class="form-select" name="location_id" id="new-document-location-id">
  61. <option value=""><?=htmlspecialchars(__("Select Location"))?></option>
  62. <?php
  63. HtmlHelper::renderOptions($location_options, $default_location_id);
  64. ?>
  65. </select>
  66. </div>
  67. <section id="new-document-aru-section">
  68. <h5><?=htmlspecialchars(__("ARU Item"))?></h5>
  69. <p><?=htmlspecialchars(__("Enter details of the part that is being returned if known."))?></p>
  70. <div class="mb-3">
  71. <label class="form-label" for="new-document-product-lookup">
  72. <?=htmlspecialchars(__("Product Lookup"))?>
  73. </label>
  74. <select class="form-control" id="new-document-product-lookup" data-placeholder="<?=htmlspecialchars(__("Select Product"))?>">
  75. <option value=""></option>
  76. <?php
  77. foreach($products as $product) {
  78. ?>
  79. <option value="<?=$product->id?>" data-name="<?=htmlspecialchars($product->name)?>">
  80. <?=htmlspecialchars($product->name)?> / <?=htmlspecialchars($product->sku)?>
  81. </option>
  82. <?php
  83. }
  84. ?>
  85. </select>
  86. </div>
  87. <div class="mb-3">
  88. <label class="form-label" for="new-document-item-description">
  89. <?=htmlspecialchars(__("Description"))?>
  90. </label>
  91. <input class="form-control" type="text" name="item_description" id="new-document-item-description" maxlength="255" placeholder="<?=htmlspecialchars(__("Type description"))?>" />
  92. </div>
  93. <div class="mb-3">
  94. <label class="form-label" for="new-document-item-serial-number">
  95. <?=htmlspecialchars(__("Serial Numbers"))?>
  96. </label>
  97. <textarea class="form-control" type="text" name="item_serial_number" id="new-document-item-serial-number" maxlength="64000" placeholder="<?=htmlspecialchars(__("Type serial numbers"))?>"></textarea>
  98. </div>
  99. </section>
  100. </div>
  101. <div class="modal-footer">
  102. <button type="submit" class="btn btn-success">
  103. <?= htmlspecialchars(__("Submit")) ?>
  104. </button>
  105. </div>
  106. </form>
  107. </div>
  108. </div>