sale_invoices_section.php 3.1 KB

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