1
0

product_form.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use App\Helpers\HtmlHelper;
  4. /**
  5. * @var string $title
  6. * @var Product $product
  7. */
  8. $core = Core::getInstance();
  9. $user = $core->getUser();
  10. $request = Request::fromRequest();
  11. if($product->isNew()) {
  12. $supplier_id = $request->int("supplier_id");
  13. $new = 1;
  14. }
  15. else {
  16. $supplier_id = $product->supplier_id;
  17. $new = 0;
  18. }
  19. ?>
  20. <h3><?=htmlspecialchars($title)?></h3>
  21. <form method="post" enctype="multipart/form-data">
  22. <?php
  23. $user->insertCsrfToken();
  24. ?>
  25. <input type="hidden" id="new" value="<?=$new?>" />
  26. <div class="row">
  27. <div class="col-sm-6">
  28. <div class="mb-3">
  29. <label class="form-label" for="supplier-id"><?=htmlspecialchars(__("Supplier"))?></label>
  30. <select class="form-select" name="supplier_id" id="supplier-id" required>
  31. <option value=""><?=htmlspecialchars(__("Select Supplier"))?></option>
  32. <?php
  33. HtmlHelper::renderOptions(Supplier::getOptions(), $supplier_id);
  34. ?>
  35. </select>
  36. </div>
  37. </div>
  38. <div class="col-sm-6">
  39. <div class="mb-3">
  40. <label class="form-label" for="type"><?=htmlspecialchars(__("Type"))?></label>
  41. <select class="form-select" name="type" id="type" required>
  42. <?php
  43. foreach(Product::getTypeOptions() as $value => $display) {
  44. ?>
  45. <option value="<?=$value?>" <?=Html::selected($value, $product->type)?>>
  46. <?=htmlspecialchars($display)?>
  47. </option>
  48. <?php
  49. }
  50. ?>
  51. </select>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="mb-3">
  56. <label class="form-label" for="name"><?=htmlspecialchars(__("Name"))?></label>
  57. <input class="form-control" type="text" id="name" name="name" placeholder="<?=htmlspecialchars(__("Type name"))?>" value="<?=htmlspecialchars($product->name)?>" maxlength="255" required />
  58. </div>
  59. <div class="row">
  60. <div class="col-6">
  61. <div class="mb-3">
  62. <label class="form-label" for="sku"><?=htmlspecialchars(__("SKU"))?></label>
  63. <input class="form-control" type="text" id="sku" name="sku" placeholder="<?=htmlspecialchars(__("Type SKU"))?>" value="<?=htmlspecialchars($product->sku)?>" maxlength="255" required />
  64. </div>
  65. </div>
  66. <div class="col-6">
  67. <div class="mb-3">
  68. <label class="form-label" for="price"><?=htmlspecialchars(__("Price"))?></label>
  69. <input class="form-control" type="number" id="price" name="price" placeholder="<?=htmlspecialchars(__("Type price"))?>" value="<?=htmlspecialchars($product->price)?>" min="0" max="999999.99" step="any" required />
  70. </div>
  71. </div>
  72. </div>
  73. <div class="mb-3">
  74. <label class="form-label" for="url"><?=htmlspecialchars(__("URL"))?></label>
  75. <input class="form-control" type="url" name="url" id="url" placeholder="<?=htmlspecialchars(__("Type URL"))?>" value="<?=htmlspecialchars($product->url)?>" />
  76. </div>
  77. <div class="mb-3">
  78. <label class="form-label" for="brochure">
  79. <?=htmlspecialchars(__("Upload Brochure (PDF)"))?>
  80. </label>
  81. <input class="form-control" type="file" name="brochure" id="brochure" accept="application/pdf" />
  82. <?php
  83. if($product->hasBrochure()) {
  84. ?>
  85. <div class="form-check">
  86. <input class="form-check-input" type="checkbox" name="delete_brochure" id="delete-brochure" value="1" />
  87. <label class="form-check-label" for="delete-brochure"><?=htmlspecialchars(__("Delete Brochure"))?></label>
  88. </div>
  89. <?php
  90. }
  91. ?>
  92. </div>
  93. <div class="mb-3">
  94. <button class="btn btn-primary" type="submit" name="submit" value="1">
  95. <?=htmlspecialchars(__("Submit"))?>
  96. </button>
  97. </div>
  98. </form>