Просмотр исходного кода

Show quantity in own column for invoice items for a sale

Alan Lam 3 лет назад
Родитель
Сommit
fd091168b2
1 измененных файлов с 45 добавлено и 11 удалено
  1. 45 11
      views/sale_invoices_section.php

+ 45 - 11
views/sale_invoices_section.php

@@ -19,11 +19,12 @@ use App\Helpers\HtmlHelper;
 	}
 	else {
 		?>
-		<table class="table table-bordered table-hover">
+		<table class="table table-bordered">
 			<colgroup>
 				<col style="width: 1%"/>
 				<col style="width: 15%"/>
-				<col style="width: 55%"/>
+				<col style="width: 45%"/>
+				<col style="width: 10%"/>
 				<col style="width: 10%"/>
 				<col style="width: 10%"/>
 				<col style="width: 10%"/>
@@ -33,7 +34,8 @@ use App\Helpers\HtmlHelper;
 			<tr>
 				<th><?=htmlspecialchars(__("No."))?></th>
 				<th><?=htmlspecialchars(__("Status"))?></th>
-				<th><?=htmlspecialchars(__("Items"))?></th>
+				<th><?=htmlspecialchars(__("Item"))?></th>
+				<th><?=htmlspecialchars(__("Qty"))?></th>
 				<th><?=htmlspecialchars(__("Subtotal"))?></th>
 				<th><?=htmlspecialchars(__("Tax"))?></th>
 				<th><?=htmlspecialchars(__("Total"))?></th>
@@ -42,36 +44,68 @@ use App\Helpers\HtmlHelper;
 			</thead>
 			<tbody>
 			<?php
-			foreach($invoices as $invoice) {
+			foreach($invoices as $index => $invoice) {
+				$items = $invoice->getItems();
+				$rowspan = count($items);
+
+				$item = array_shift($items);
+				$row_class = ($index % 2) ? "table-light" : "";
 				?>
-				<tr>
-					<td class="text-end">
+				<tr class="<?=$row_class?>">
+					<td class="text-end" rowspan="<?=$rowspan?>">
 						<a href="<?=htmlspecialchars($invoice->getUrl())?>"><?=$invoice->number?></a>
 					</td>
-					<td>
+					<td rowspan="<?=$rowspan?>">
 						<?=htmlspecialchars($invoice->getDisplayInvoiceStatus())?>
 					</td>
 					<td>
+						<?=htmlspecialchars($item->description)?>
 						<?php
-						View::include("components/document_items_unstyled_list", ["items" => $invoice->getItems()]);
+						if($item->serial_number) {
+							?>
+							<span class="text-muted">(S/N: <?=htmlspecialchars($item->serial_number)?>)</span>
+							<?php
+						}
 						?>
 					</td>
 					<td class="text-end">
+						<?=htmlspecialchars($item->quantity)?>
+					</td>
+					<td class="text-end" rowspan="<?=$rowspan?>">
 						<?=htmlspecialchars($invoice->getDisplaySubtotal())?>
 					</td>
-					<td class="text-end">
+					<td class="text-end" rowspan="<?=$rowspan?>">
 						<?=htmlspecialchars($invoice->getDisplayTax())?>
 					</td>
-					<td class="text-end">
+					<td class="text-end" rowspan="<?=$rowspan?>">
 						<?=htmlspecialchars($invoice->getDisplayTotal())?>
 					</td>
-					<td class="p-1">
+					<td class="p-1" rowspan="<?=$rowspan?>">
 						<a href="<?=htmlspecialchars($invoice->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)?>
+							<?php
+							if($item->serial_number) {
+								?>
+								<span class="text-muted">(S/N: <?=htmlspecialchars($item->serial_number)?>)</span>
+								<?php
+							}
+							?>
+						</td>
+						<td class="text-end">
+							<?=htmlspecialchars($item->quantity)?>
+						</td>
+					</tr>
+					<?php
+				}
 			}
 			?>
 			</tbody>