sales_table.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. /**
  4. * @var Sale[] $sales
  5. * @var bool $show_batch_actions
  6. */
  7. $core = Core::getInstance();
  8. $user = $core->getUser();
  9. $show_batch_actions ??= false;
  10. ?>
  11. <form method="post">
  12. <?php
  13. $user->insertCsrfToken();
  14. ?>
  15. <table class="table table-bordered table-hover mb-3">
  16. <thead>
  17. <tr>
  18. <?php
  19. if($show_batch_actions) {
  20. ?>
  21. <th class="text-center">
  22. <input type="checkbox" id="sales-table-select-all" />
  23. </th>
  24. <?php
  25. }
  26. ?>
  27. <th><?=htmlspecialchars(__("Ref."))?></th>
  28. <th><?=htmlspecialchars(__("Date"))?></th>
  29. <th><?=htmlspecialchars(__("Location"))?></th>
  30. <th><?=htmlspecialchars(__("Status"))?></th>
  31. <th><?=htmlspecialchars(__("Items"))?></th>
  32. <th><?=htmlspecialchars(__("Value"))?></th>
  33. <th><?=htmlspecialchars(__("Predicted Sold Date"))?></th>
  34. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  35. <th><?=htmlspecialchars(__("Actions"))?></th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. <?php
  40. foreach($sales as $sale) {
  41. $location = $sale->getLocation();
  42. ?>
  43. <tr>
  44. <?php
  45. if($show_batch_actions) {
  46. ?>
  47. <td class="text-center">
  48. <input type="checkbox" name="sale_ids[]" value="<?=$sale->id?>" />
  49. </td>
  50. <?php
  51. }
  52. ?>
  53. <td class="text-end">
  54. <a href="<?=htmlspecialchars($sale->getUrl())?>"><?=htmlspecialchars($sale->getReference())?></a>
  55. </td>
  56. <td>
  57. <?=htmlspecialchars($user->formatDate($sale->getDateTimeCreated()))?>
  58. </td>
  59. <td>
  60. <a href="<?=htmlspecialchars($location->getUrl())?>">
  61. <?=htmlspecialchars($location->getDisplayName())?>
  62. </a>
  63. </td>
  64. <td>
  65. <?=htmlspecialchars($sale->getDisplayStatus())?>
  66. </td>
  67. <td>
  68. <?php
  69. foreach($sale->getItems() as $item) {
  70. ?>
  71. <?=htmlspecialchars($item->getProduct()->name)?> &times; <?=$item->quantity?><br />
  72. <?php
  73. }
  74. ?>
  75. </td>
  76. <td class="text-end">
  77. <?=htmlspecialchars($sale->getDisplayAmount())?>
  78. </td>
  79. <td>
  80. <?=htmlspecialchars($sale->getDisplayPredictedSoldDate())?>
  81. </td>
  82. <td>
  83. <?php
  84. $dt_updated = $sale->getDateTimeUpdated();
  85. if($dt_updated) {
  86. echo $dt_updated->diffForHumans();
  87. }
  88. ?>
  89. </td>
  90. <td class="p-1">
  91. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($sale->getUrl())?>">
  92. <?=htmlspecialchars(__("View"))?>
  93. </a>
  94. </td>
  95. </tr>
  96. <?php
  97. }
  98. ?>
  99. </tbody>
  100. </table>
  101. <?php
  102. if($show_batch_actions) {
  103. ?>
  104. <div class="card mb-3">
  105. <div class="card-header">
  106. <?=htmlspecialchars(__("Batch Actions"))?>
  107. </div>
  108. <div class="card-body">
  109. <label class="sr-only" for="batch-action"><?=htmlspecialchars(__("Batch Action"))?></label>
  110. <div class="input-group">
  111. <select class="form-control" name="batch_action" id="batch-action" required>
  112. <option value=""><?=htmlspecialchars(__("Select Batch Action"))?></option>
  113. <option value="mark-new"><?=htmlspecialchars(__("Mark As New"))?></option>
  114. <option value="mark-confirmed"><?=htmlspecialchars(__("Mark As Confirmed"))?></option>
  115. <option value="mark-shipping"><?=htmlspecialchars(__("Mark As Shipping"))?></option>
  116. <option value="mark-completed"><?=htmlspecialchars(__("Mark As Completed"))?></option>
  117. </select>
  118. <button type="submit" class="btn btn-primary">
  119. <?=htmlspecialchars(__("Submit"))?>
  120. </button>
  121. </div>
  122. </div>
  123. </div>
  124. <?php
  125. }
  126. ?>
  127. </form>