sales.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use App\Enums\SaleStatuses;
  4. use App\Helpers\HtmlHelper;
  5. /**
  6. * @var Sale[] $sales
  7. * @var Pagination $pagination
  8. * @var int $customer_id
  9. * @var int $location_id
  10. * @var int $status
  11. * @var string $custom_filter
  12. */
  13. $custom_filter_options = [
  14. "open" => __("Open Sales"),
  15. ];
  16. ?>
  17. <div class="row mb-3">
  18. <div class="col">
  19. <h3><?=htmlspecialchars(__("Sales"))?></h3>
  20. </div>
  21. <div class="col-auto">
  22. <a class="btn btn-success" data-bs-toggle="modal" data-bs-target="#new-sale-modal">
  23. <i class="fa fa-fw fa-plus"></i>
  24. <?=htmlspecialchars(__("Add"))?>
  25. </a>
  26. </div>
  27. </div>
  28. <div class="card mb-3">
  29. <div class="card-header">
  30. <?=htmlspecialchars(__("Filters"))?>
  31. </div>
  32. <div class="card-body">
  33. <form action="/sales" method="post">
  34. <div class="row">
  35. <div class="col-sm-4">
  36. <?php
  37. View::include("components/customer_id_field", compact("customer_id"));
  38. ?>
  39. </div>
  40. <div class="col-sm-4">
  41. <?php
  42. View::include("components/location_id_field", compact("location_id"));
  43. ?>
  44. </div>
  45. <div class="col-sm-4">
  46. <div class="mb-3">
  47. <label class="form-label" for="status"><?=htmlspecialchars(__("Status"))?></label>
  48. <select class="form-control" name="status" id="status">
  49. <option value=""><?=htmlspecialchars(__("Any Status"))?></option>
  50. <?php
  51. HtmlHelper::renderOptions(SaleStatuses::options(), $status);
  52. ?>
  53. </select>
  54. </div>
  55. </div>
  56. <div class="col-sm-4">
  57. <div class="mb-3">
  58. <label class="form-label" for="custom-filter"><?=htmlspecialchars(__("Custom Filter"))?></label>
  59. <select class="form-control" name="custom_filter" id="custom-filter">
  60. <option value=""><?=htmlspecialchars(__("All Sales"))?></option>
  61. <?php
  62. HtmlHelper::renderOptions($custom_filter_options, $custom_filter);
  63. ?>
  64. </select>
  65. </div>
  66. </div>
  67. </div>
  68. <button class="btn btn-primary" type="submit">
  69. <?=htmlspecialchars(__("Submit"))?>
  70. </button>
  71. </form>
  72. </div>
  73. </div>
  74. <?php
  75. if(empty($sales)) {
  76. ?>
  77. <div class="alert alert-info">
  78. <i class="fa fa-fw fa-info-circle"></i>
  79. <?=htmlspecialchars(__("No sales to display."))?>
  80. </div>
  81. <?php
  82. }
  83. else {
  84. ?>
  85. <table class="table table-bordered table-hover mb-3">
  86. <thead>
  87. <tr>
  88. <th><?=htmlspecialchars(__("Number"))?></th>
  89. <th><?=htmlspecialchars(__("Location"))?></th>
  90. <th><?=htmlspecialchars(__("Status"))?></th>
  91. <th><?=htmlspecialchars(__("Actions"))?></th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <?php
  96. foreach($sales as $sale) {
  97. $location = $sale->getLocation();
  98. ?>
  99. <tr>
  100. <td class="text-end">
  101. <a href="<?=htmlspecialchars($sale->getUrl())?>"><?=htmlspecialchars($sale->getNumber())?></a>
  102. </td>
  103. <td>
  104. <a href="<?=htmlspecialchars($location->getUrl())?>">
  105. <?=htmlspecialchars($location->getDisplayName())?>
  106. </a>
  107. </td>
  108. <td>
  109. <?=htmlspecialchars($sale->getDisplayStatus())?>
  110. </td>
  111. <td class="p-1">
  112. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($sale->getUrl())?>">
  113. <?=htmlspecialchars(__("View"))?>
  114. </a>
  115. </td>
  116. </tr>
  117. <?php
  118. }
  119. ?>
  120. </tbody>
  121. </table>
  122. <?php
  123. $pagination->render();
  124. }