product_form.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App;
  3. /**
  4. * @var string $title
  5. * @var Product $product
  6. */
  7. $core = Core::getInstance();
  8. $user = $core->getUser();
  9. $suppliers = Supplier::getAll();
  10. ?>
  11. <h3><?=htmlspecialchars($title)?></h3>
  12. <form method="post">
  13. <?php
  14. $user->insertCsrfToken();
  15. ?>
  16. <div class="mb-3">
  17. <label for="supplier-id"><?=htmlspecialchars(__("Supplier"))?></label>
  18. <select class="form-select" name="supplier_id" id="supplier-id" required>
  19. <option value=""><?=htmlspecialchars(__("Select Supplier"))?></option>
  20. <?php
  21. foreach($suppliers as $supplier) {
  22. ?>
  23. <option value="<?=$supplier->id?>" <?=Html::selected($supplier->id, $product->supplier_id)?>>
  24. <?=htmlspecialchars($supplier->name)?>
  25. </option>
  26. <?php
  27. }
  28. ?>
  29. </select>
  30. </div>
  31. <div class="mb-3">
  32. <label for="name"><?=htmlspecialchars(__("Name"))?></label>
  33. <input class="form-control" type="text" id="name" name="name" placeholder="<?=htmlspecialchars(__("Type name"))?>" value="<?=htmlspecialchars($product->name)?>" maxlength="255" required />
  34. </div>
  35. <div class="mb-3">
  36. <label for="sku"><?=htmlspecialchars(__("SKU"))?></label>
  37. <input class="form-control" type="text" id="sku" name="sku" placeholder="<?=htmlspecialchars(__("Type SKU"))?>" value="<?=htmlspecialchars($product->sku)?>" maxlength="255" required />
  38. </div>
  39. <div class="row">
  40. <div class="col-6">
  41. <div class="mb-3">
  42. <label for="type"><?=htmlspecialchars(__("Type"))?></label>
  43. <select class="form-select" name="type" id="type" required>
  44. <?php
  45. foreach(Product::getTypeOptions() as $value => $display) {
  46. ?>
  47. <option value="<?=$value?>" <?=Html::selected($value, $product->type)?>>
  48. <?=htmlspecialchars($display)?>
  49. </option>
  50. <?php
  51. }
  52. ?>
  53. </select>
  54. </div>
  55. </div>
  56. <div class="col-6">
  57. <div class="mb-3">
  58. <label for="price"><?=htmlspecialchars(__("Price"))?></label>
  59. <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 />
  60. </div>
  61. </div>
  62. </div>
  63. <div class="mb-3">
  64. <button class="btn btn-primary" type="submit" name="submit" value="1">
  65. <?=htmlspecialchars(__("Submit"))?>
  66. </button>
  67. </div>
  68. </form>