documents.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use App\Enums\DocumentTypes;
  4. /**
  5. * @var string $title
  6. * @var int $type
  7. * @var Document[] $documents
  8. * @var Pagination $pagination
  9. */
  10. $is_invoice = ($type === DocumentTypes::INVOICE);
  11. $is_goods_in = ($type === DocumentTypes::GOODS_IN);
  12. $is_aru = ($type === DocumentTypes::ADVANCE_REPLACEMENT_UNIT);
  13. ?>
  14. <div class="row mb-3">
  15. <div class="col">
  16. <h3><?=htmlspecialchars($title)?></h3>
  17. </div>
  18. <?php
  19. if($is_goods_in || $is_aru) {
  20. ?>
  21. <div class="col-auto">
  22. <a class="btn btn-success" data-bs-toggle="modal" data-bs-target="#new-document-modal" data-type="<?=$type?>">
  23. <i class="fa fa-fw fa-plus"></i>
  24. <?=htmlspecialchars(__("Add"))?>
  25. </a>
  26. </div>
  27. <?php
  28. }
  29. ?>
  30. </div>
  31. <?php
  32. if(empty($documents)) {
  33. ?>
  34. <div class="alert alert-info">
  35. <i class="fa fa-fw fa-info-circle"></i>
  36. <?=htmlspecialchars(__("No documents to display."))?>
  37. </div>
  38. <?php
  39. }
  40. else {
  41. ?>
  42. <table class="table table-bordered table-hover mb-3">
  43. <thead>
  44. <tr>
  45. <th><?=htmlspecialchars(__("Number"))?></th>
  46. <?php
  47. if($is_goods_in) {
  48. ?>
  49. <th><?=htmlspecialchars(__("Location / Supplier"))?></th>
  50. <?php
  51. }
  52. else {
  53. ?>
  54. <th><?=htmlspecialchars(__("Location"))?></th>
  55. <th><?=htmlspecialchars(__("Status"))?></th>
  56. <?php
  57. }
  58. ?>
  59. <th><?=htmlspecialchars(__("Items"))?></th>
  60. <th><?=htmlspecialchars(__("Actions"))?></th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <?php
  65. foreach($documents as $document) {
  66. $location = $document->getLocation();
  67. $supplier = $document->getSupplier();
  68. ?>
  69. <tr>
  70. <td class="text-end">
  71. <a href="<?=htmlspecialchars($document->getUrl())?>"><?=$document->number?></a>
  72. </td>
  73. <td>
  74. <?php
  75. if($location) {
  76. ?>
  77. <a href="<?=htmlspecialchars($location->getUrl())?>">
  78. <?=htmlspecialchars($location->getDisplayName())?>
  79. </a>
  80. <?php
  81. }
  82. if($supplier) {
  83. ?>
  84. <a href="<?=htmlspecialchars($supplier->getUrl())?>">
  85. <?=htmlspecialchars($supplier->name)?>
  86. </a>
  87. <?php
  88. }
  89. ?>
  90. </td>
  91. <?php
  92. if(!$is_goods_in) {
  93. if($is_invoice) {
  94. ?>
  95. <td>
  96. <?=htmlspecialchars($document->getDisplayInvoiceStatus())?>
  97. </td>
  98. <?php
  99. }
  100. else {
  101. ?>
  102. <td>
  103. <?=htmlspecialchars($document->getDisplayAruStatus())?>
  104. </td>
  105. <?php
  106. }
  107. }
  108. ?>
  109. <td>
  110. <ul class="list-unstyled mb-0">
  111. <?php
  112. foreach($document->getItems() as $item) {
  113. ?>
  114. <li>
  115. <?=htmlspecialchars($item->description)?> &times; <?=$item->quantity?>
  116. <?php
  117. if($item->serial_number) {
  118. ?>
  119. <span class="text-muted">
  120. (S/N: <?=htmlspecialchars($item->serial_number)?>)
  121. </span>
  122. <?php
  123. }
  124. ?>
  125. </li>
  126. <?php
  127. }
  128. ?>
  129. </ul>
  130. </td>
  131. <td class="p-1">
  132. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($document->getUrl())?>">
  133. <?=htmlspecialchars(__("View"))?>
  134. </a>
  135. </td>
  136. </tr>
  137. <?php
  138. }
  139. ?>
  140. </tbody>
  141. </table>
  142. <?php
  143. $pagination->render();
  144. }