sales_table.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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></th>
  22. <?php
  23. }
  24. ?>
  25. <th><?=htmlspecialchars(__("Ref."))?></th>
  26. <th><?=htmlspecialchars(__("Date"))?></th>
  27. <th><?=htmlspecialchars(__("Location"))?></th>
  28. <th><?=htmlspecialchars(__("Status"))?></th>
  29. <th><?=htmlspecialchars(__("Items"))?></th>
  30. <th><?=htmlspecialchars(__("Value"))?></th>
  31. <th><?=htmlspecialchars(__("Predicted Sold Date"))?></th>
  32. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  33. <th><?=htmlspecialchars(__("Actions"))?></th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. <?php
  38. foreach($sales as $sale) {
  39. $location = $sale->getLocation();
  40. ?>
  41. <tr>
  42. <?php
  43. if($show_batch_actions) {
  44. ?>
  45. <td>
  46. <input type="checkbox" name="sale_ids[]" value="<?=$sale->id?>" />
  47. </td>
  48. <?php
  49. }
  50. ?>
  51. <td class="text-end">
  52. <a href="<?=htmlspecialchars($sale->getUrl())?>"><?=htmlspecialchars($sale->getReference())?></a>
  53. </td>
  54. <td>
  55. <?=htmlspecialchars($user->formatDate($sale->getDateTimeCreated()))?>
  56. </td>
  57. <td>
  58. <a href="<?=htmlspecialchars($location->getUrl())?>">
  59. <?=htmlspecialchars($location->getDisplayName())?>
  60. </a>
  61. </td>
  62. <td>
  63. <?=htmlspecialchars($sale->getDisplayStatus())?>
  64. </td>
  65. <td>
  66. <?php
  67. foreach($sale->getItems() as $item) {
  68. ?>
  69. <?=htmlspecialchars($item->getProduct()->name)?> &times; <?=$item->quantity?><br />
  70. <?php
  71. }
  72. ?>
  73. </td>
  74. <td class="text-end">
  75. <?=htmlspecialchars($sale->getDisplayAmount())?>
  76. </td>
  77. <td>
  78. <?=htmlspecialchars($sale->getDisplayPredictedSoldDate())?>
  79. </td>
  80. <td>
  81. <?php
  82. $dt_updated = $sale->getDateTimeUpdated();
  83. if($dt_updated) {
  84. echo $dt_updated->diffForHumans();
  85. }
  86. ?>
  87. </td>
  88. <td class="p-1">
  89. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($sale->getUrl())?>">
  90. <?=htmlspecialchars(__("View"))?>
  91. </a>
  92. </td>
  93. </tr>
  94. <?php
  95. }
  96. ?>
  97. </tbody>
  98. </table>
  99. <?php
  100. if($show_batch_actions) {
  101. ?>
  102. <div class="card mb-3">
  103. <div class="card-header">
  104. <?=htmlspecialchars(__("Batch Actions"))?>
  105. </div>
  106. <div class="card-body">
  107. <label class="sr-only" for="batch-action"><?=htmlspecialchars(__("Batch Action"))?></label>
  108. <div class="input-group">
  109. <select class="form-control" name="batch_action" id="batch-action" required>
  110. <option value=""><?=htmlspecialchars(__("Select Batch Action"))?></option>
  111. <option value="mark-completed"><?=htmlspecialchars(__("Mark As Completed"))?></option>
  112. </select>
  113. <button type="submit" class="btn btn-primary">
  114. <?=htmlspecialchars(__("Submit"))?>
  115. </button>
  116. </div>
  117. </div>
  118. </div>
  119. <?php
  120. }
  121. ?>
  122. </form>