products.php 3.6 KB

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