sale_invoices_section.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. /**
  4. * @var string $title
  5. * @var Document[] $sales_orders
  6. * @var bool $show_add_button
  7. */
  8. use App\Enums\DocumentTypes;
  9. use App\Helpers\HtmlHelper;
  10. $title ??= __("Sales Orders");
  11. $show_location_column ??= true;
  12. $show_add_button ??= false;
  13. ?>
  14. <section class="mb-4">
  15. <div class="row">
  16. <div class="col">
  17. <h3><?=htmlspecialchars($title)?></h3>
  18. </div>
  19. <?php
  20. if($show_add_button) {
  21. ?>
  22. <div class="col-auto">
  23. <button type="button" id="new-document-button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#new-document-modal" data-type="<?=DocumentTypes::SALES_ORDER?>">
  24. <i class="fa fa-fw fa-plus"></i>
  25. <?=htmlspecialchars(__("Add"))?>
  26. </button>
  27. </div>
  28. <?php
  29. }
  30. ?>
  31. </div>
  32. <?php
  33. if(empty($sales_orders)) {
  34. HtmlHelper::renderInfoAlert(__("No sales orders to display."));
  35. }
  36. else {
  37. ?>
  38. <table class="table table-bordered">
  39. <thead>
  40. <tr>
  41. <th><?=htmlspecialchars(__("No."))?></th>
  42. <th><?=htmlspecialchars(__("Date"))?></th>
  43. <?php
  44. if($show_location_column) {
  45. ?>
  46. <th><?=htmlspecialchars(__("Location"))?></th>
  47. <?php
  48. }
  49. ?>
  50. <th><?=htmlspecialchars(__("Status"))?></th>
  51. <th><?=htmlspecialchars(__("Item"))?></th>
  52. <th><?=htmlspecialchars(__("S/N"))?></th>
  53. <th><?=htmlspecialchars(__("Qty"))?></th>
  54. <th><?=htmlspecialchars(__("Subtotal"))?></th>
  55. <th><?=htmlspecialchars(__("Tax"))?></th>
  56. <th><?=htmlspecialchars(__("Total"))?></th>
  57. <th><?=htmlspecialchars(__("Actions"))?></th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <?php
  62. foreach($sales_orders as $index => $sales_order) {
  63. $location = $sales_order->getLocation();
  64. $items = $sales_order->getItems();
  65. $rowspan = count($items) ?: 1;
  66. $item = array_shift($items);
  67. $row_class = ($index % 2) ? "table-light" : "";
  68. ?>
  69. <tr class="<?=$row_class?>">
  70. <td class="text-end" rowspan="<?=$rowspan?>">
  71. <a href="<?=htmlspecialchars($sales_order->getUrl())?>"><?=$sales_order->number?></a>
  72. </td>
  73. <td rowspan="<?=$rowspan?>">
  74. <?=htmlspecialchars($sales_order->getDisplayDate())?>
  75. </td>
  76. <?php
  77. if($show_location_column) {
  78. ?>
  79. <td rowspan="<?=$rowspan?>">
  80. <a href="<?=htmlspecialchars($location->getUrl())?>">
  81. <?=htmlspecialchars($location->name)?>
  82. </a>
  83. </td>
  84. <?php
  85. }
  86. ?>
  87. <td rowspan="<?=$rowspan?>">
  88. <?=htmlspecialchars($sales_order->getDisplaySalesOrderStatus())?>
  89. </td>
  90. <td>
  91. <?php
  92. if($item) {
  93. ?>
  94. <?=htmlspecialchars($item->description)?>
  95. <?php
  96. }
  97. ?>
  98. </td>
  99. <td>
  100. <?php
  101. if($item) {
  102. ?>
  103. <?=$item->getSerialNumberHtml()?>
  104. <?php
  105. }
  106. ?>
  107. </td>
  108. <td class="text-end">
  109. <?=htmlspecialchars($item->quantity ?? "")?>
  110. </td>
  111. <td class="text-end" rowspan="<?=$rowspan?>">
  112. <?=htmlspecialchars($sales_order->getDisplaySubtotal())?>
  113. </td>
  114. <td class="text-end" rowspan="<?=$rowspan?>">
  115. <?=htmlspecialchars($sales_order->getDisplayTax())?>
  116. </td>
  117. <td class="text-end" rowspan="<?=$rowspan?>">
  118. <?=htmlspecialchars($sales_order->getDisplayTotal())?>
  119. </td>
  120. <td class="p-1" rowspan="<?=$rowspan?>">
  121. <a href="<?=htmlspecialchars($sales_order->getUrl())?>" class="btn btn-sm btn-primary">
  122. <?=htmlspecialchars(__("View"))?>
  123. </a>
  124. </td>
  125. </tr>
  126. <?php
  127. foreach($items as $item) {
  128. ?>
  129. <tr class="<?=$row_class?>">
  130. <td>
  131. <?=htmlspecialchars($item->description)?>
  132. </td>
  133. <td>
  134. <?=$item->getSerialNumberHtml()?>
  135. </td>
  136. <td class="text-end">
  137. <?=htmlspecialchars($item->quantity)?>
  138. </td>
  139. </tr>
  140. <?php
  141. }
  142. }
  143. ?>
  144. </tbody>
  145. </table>
  146. <?php
  147. }
  148. ?>
  149. </section>