products.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace App;
  3. use App\Helpers\HtmlHelper;
  4. /**
  5. * @var Product[] $products
  6. * @var Pagination $pagination
  7. * @var array $sort_options
  8. * @var int $product_id
  9. * @var int $supplier_id
  10. * @var string $name
  11. * @var string $sku
  12. * @var int $type
  13. * @var string $sort
  14. */
  15. ?>
  16. <div class="row mb-3">
  17. <div class="col">
  18. <h3><?=htmlspecialchars(__("Products"))?></h3>
  19. </div>
  20. <div class="col-auto">
  21. <a class="btn btn-success" href="/products/add">
  22. <i class="fa fa-fw fa-plus"></i>
  23. <?=htmlspecialchars(__("Add"))?>
  24. </a>
  25. </div>
  26. </div>
  27. <div class="card mb-3">
  28. <div class="card-header">
  29. <?=htmlspecialchars(__("Filters"))?>
  30. </div>
  31. <div class="card-body">
  32. <form action="/products" method="get">
  33. <div class="row">
  34. <div class="col-sm-4">
  35. <div class="mb-3">
  36. <label class="form-label" for="product-id"><?=htmlspecialchars(__("ID"))?></label>
  37. <input class="form-control" type="number" name="product_id" id="product-id" placeholder="<?=htmlspecialchars(__("Type ID"))?>" value="<?=htmlspecialchars($product_id)?>" />
  38. </div>
  39. </div>
  40. <div class="col-sm-4">
  41. <div class="mb-3">
  42. <label class="form-label" for="supplier-id"><?= htmlspecialchars(__("Supplier")) ?></label>
  43. <select class="form-control" name="supplier_id" id="supplier-id">
  44. <option value=""><?= htmlspecialchars(__("Any Supplier")) ?></option>
  45. <?php
  46. HtmlHelper::renderOptions(Supplier::getOptions(), $supplier_id);
  47. ?>
  48. </select>
  49. </div>
  50. </div>
  51. <div class="col-sm-4">
  52. <div class="mb-3">
  53. <label class="form-label" for="name"><?= htmlspecialchars(__("Name")) ?></label>
  54. <input class="form-control" type="text" name="name" id="name" placeholder="<?= htmlspecialchars(__("Type name")) ?>" value="<?=htmlspecialchars($name)?>" />
  55. </div>
  56. </div>
  57. <div class="col-sm-4">
  58. <div class="mb-3">
  59. <label class="form-label" for="sku"><?= htmlspecialchars(__("SKU")) ?></label>
  60. <input class="form-control" type="text" name="sku" id="sku" placeholder="<?= htmlspecialchars(__("Type SKU")) ?>" value="<?=htmlspecialchars($sku)?>" />
  61. </div>
  62. </div>
  63. <div class="col-sm-4">
  64. <div class="mb-3">
  65. <label class="form-label" for="type"><?=htmlspecialchars(__("Type"))?></label>
  66. <select class="form-control" name="type" id="type">
  67. <option value=""><?=htmlspecialchars(__("Any Type"))?></option>
  68. <?php
  69. HtmlHelper::renderOptions(Product::getTypeOptions(), $type);
  70. ?>
  71. </select>
  72. </div>
  73. </div>
  74. <div class="col-sm-4">
  75. <div class="mb-3">
  76. <div class="mb-3">
  77. <label class="form-label" for="sort"><?= htmlspecialchars(__("Sort")) ?></label>
  78. <select class="form-control" name="sort" id="sort">
  79. <?php
  80. HtmlHelper::renderOptions($sort_options, $sort);
  81. ?>
  82. </select>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <button class="btn btn-primary" type="submit">
  88. <?=htmlspecialchars(__("Submit"))?>
  89. </button>
  90. </form>
  91. </div>
  92. </div>
  93. <?php
  94. if(empty($products)) {
  95. ?>
  96. <div class="alert alert-info">
  97. <i class="fa fa-fw fa-info-circle"></i>
  98. <?=htmlspecialchars(__("No products to display."))?>
  99. </div>
  100. <?php
  101. }
  102. else {
  103. View::include("products_table", compact("products"));
  104. $pagination->render();
  105. }