| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- namespace App;
- /**
- * @var string $title
- * @var Document[] $sales_orders
- * @var bool $show_add_button
- */
- use App\Enums\DocumentTypes;
- use App\Helpers\HtmlHelper;
- $title ??= __("Sales Orders");
- $show_location_column ??= true;
- $show_add_button ??= false;
- ?>
- <section class="mb-4">
- <div class="row">
- <div class="col">
- <h3><?=htmlspecialchars($title)?></h3>
- </div>
- <?php
- if($show_add_button) {
- ?>
- <div class="col-auto">
- <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?>">
- <i class="fa fa-fw fa-plus"></i>
- <?=htmlspecialchars(__("Add"))?>
- </button>
- </div>
- <?php
- }
- ?>
- </div>
- <?php
- if(empty($sales_orders)) {
- HtmlHelper::renderInfoAlert(__("No sales orders to display."));
- }
- else {
- ?>
- <table class="table table-bordered">
- <thead>
- <tr>
- <th><?=htmlspecialchars(__("No."))?></th>
- <th><?=htmlspecialchars(__("Date"))?></th>
- <?php
- if($show_location_column) {
- ?>
- <th><?=htmlspecialchars(__("Location"))?></th>
- <?php
- }
- ?>
- <th><?=htmlspecialchars(__("Status"))?></th>
- <th><?=htmlspecialchars(__("Item"))?></th>
- <th><?=htmlspecialchars(__("S/N"))?></th>
- <th><?=htmlspecialchars(__("Qty"))?></th>
- <th><?=htmlspecialchars(__("Subtotal"))?></th>
- <th><?=htmlspecialchars(__("Tax"))?></th>
- <th><?=htmlspecialchars(__("Total"))?></th>
- <th><?=htmlspecialchars(__("Actions"))?></th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($sales_orders as $index => $sales_order) {
- $location = $sales_order->getLocation();
- $items = $sales_order->getItems();
- $rowspan = count($items) ?: 1;
- $item = array_shift($items);
- $row_class = ($index % 2) ? "table-light" : "";
- ?>
- <tr class="<?=$row_class?>">
- <td class="text-end" rowspan="<?=$rowspan?>">
- <a href="<?=htmlspecialchars($sales_order->getUrl())?>"><?=$sales_order->number?></a>
- </td>
- <td rowspan="<?=$rowspan?>">
- <?=htmlspecialchars($sales_order->getDisplayDate())?>
- </td>
- <?php
- if($show_location_column) {
- ?>
- <td rowspan="<?=$rowspan?>">
- <a href="<?=htmlspecialchars($location->getUrl())?>">
- <?=htmlspecialchars($location->name)?>
- </a>
- </td>
- <?php
- }
- ?>
- <td rowspan="<?=$rowspan?>">
- <?=htmlspecialchars($sales_order->getDisplaySalesOrderStatus())?>
- </td>
- <td>
- <?php
- if($item) {
- ?>
- <?=htmlspecialchars($item->description)?>
- <?php
- }
- ?>
- </td>
- <td>
- <?php
- if($item) {
- ?>
- <?=$item->getSerialNumberHtml()?>
- <?php
- }
- ?>
- </td>
- <td class="text-end">
- <?=htmlspecialchars($item->quantity ?? "")?>
- </td>
- <td class="text-end" rowspan="<?=$rowspan?>">
- <?=htmlspecialchars($sales_order->getDisplaySubtotal())?>
- </td>
- <td class="text-end" rowspan="<?=$rowspan?>">
- <?=htmlspecialchars($sales_order->getDisplayTax())?>
- </td>
- <td class="text-end" rowspan="<?=$rowspan?>">
- <?=htmlspecialchars($sales_order->getDisplayTotal())?>
- </td>
- <td class="p-1" rowspan="<?=$rowspan?>">
- <a href="<?=htmlspecialchars($sales_order->getUrl())?>" class="btn btn-sm btn-primary">
- <?=htmlspecialchars(__("View"))?>
- </a>
- </td>
- </tr>
- <?php
- foreach($items as $item) {
- ?>
- <tr class="<?=$row_class?>">
- <td>
- <?=htmlspecialchars($item->description)?>
- </td>
- <td>
- <?=$item->getSerialNumberHtml()?>
- </td>
- <td class="text-end">
- <?=htmlspecialchars($item->quantity)?>
- </td>
- </tr>
- <?php
- }
- }
- ?>
- </tbody>
- </table>
- <?php
- }
- ?>
- </section>
|