sale_invoices_section.php 3.3 KB

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