|
@@ -1,12 +1,15 @@
|
|
|
<?php
|
|
<?php
|
|
|
namespace App;
|
|
namespace App;
|
|
|
|
|
|
|
|
|
|
+use App\Helpers\HtmlHelper;
|
|
|
use NumberFormatter;
|
|
use NumberFormatter;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @var Document $document
|
|
* @var Document $document
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+$items = $document->getItems();
|
|
|
|
|
+
|
|
|
?>
|
|
?>
|
|
|
<section class="mb-4" id="document-items-section">
|
|
<section class="mb-4" id="document-items-section">
|
|
|
|
|
|
|
@@ -22,148 +25,157 @@ use NumberFormatter;
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <form action="<?=htmlspecialchars($document->getUrl())?>/items-batch-action" method="post">
|
|
|
|
|
|
|
+ <?php
|
|
|
|
|
+ if(empty($items)) {
|
|
|
|
|
+ HtmlHelper::renderInfoAlert(__("No items to display."));
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <form action="<?=htmlspecialchars($document->getUrl())?>/items-batch-action" method="post">
|
|
|
|
|
|
|
|
- <table class="table table-bordered table-hover mb-2">
|
|
|
|
|
- <colgroup>
|
|
|
|
|
- <col style="width: 1%"/>
|
|
|
|
|
- <col style="width: 35%"/>
|
|
|
|
|
- <col style="width: 20%"/>
|
|
|
|
|
- <col style="width: 15%"/>
|
|
|
|
|
- <?php
|
|
|
|
|
- if($document->isInvoice()) {
|
|
|
|
|
- ?>
|
|
|
|
|
- <col style="width: 15%"/>
|
|
|
|
|
|
|
+ <table class="table table-bordered table-hover mb-2">
|
|
|
|
|
+ <colgroup>
|
|
|
|
|
+ <col style="width: 1%"/>
|
|
|
|
|
+ <col style="width: 35%"/>
|
|
|
|
|
+ <col style="width: 20%"/>
|
|
|
<col style="width: 15%"/>
|
|
<col style="width: 15%"/>
|
|
|
<?php
|
|
<?php
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- <col style="width: 1%"/>
|
|
|
|
|
- </colgroup>
|
|
|
|
|
- <thead>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th>
|
|
|
|
|
- <!--suppress HtmlFormInputWithoutLabel -->
|
|
|
|
|
- <input class="form-check-input" id="all-items-checkbox" type="checkbox" />
|
|
|
|
|
- </th>
|
|
|
|
|
- <th><?=htmlspecialchars(__("Description"))?></th>
|
|
|
|
|
- <th><?=htmlspecialchars(__("Serial Number"))?></th>
|
|
|
|
|
- <th><?=htmlspecialchars(__("Quantity"))?></th>
|
|
|
|
|
- <?php
|
|
|
|
|
- if($document->isInvoice()) {
|
|
|
|
|
|
|
+ if($document->isInvoice()) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <col style="width: 15%"/>
|
|
|
|
|
+ <col style="width: 15%"/>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
?>
|
|
?>
|
|
|
- <th><?=htmlspecialchars(__("Unit Price"))?></th>
|
|
|
|
|
- <th><?=htmlspecialchars(__("Amount"))?></th>
|
|
|
|
|
- <?php
|
|
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- <th><?=htmlspecialchars(__("Actions"))?></th>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </thead>
|
|
|
|
|
- <tbody>
|
|
|
|
|
- <?php
|
|
|
|
|
- $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
|
|
|
|
|
- $currency = $document->currency;
|
|
|
|
|
- $subtotal = "0.00";
|
|
|
|
|
-
|
|
|
|
|
- foreach($document->getItems() as $item) {
|
|
|
|
|
- ?>
|
|
|
|
|
|
|
+ <col style="width: 1%"/>
|
|
|
|
|
+ </colgroup>
|
|
|
|
|
+ <thead>
|
|
|
<tr>
|
|
<tr>
|
|
|
- <td>
|
|
|
|
|
|
|
+ <th>
|
|
|
<!--suppress HtmlFormInputWithoutLabel -->
|
|
<!--suppress HtmlFormInputWithoutLabel -->
|
|
|
- <input class="form-check-input" type="checkbox" name="document_item_ids[]" value="<?=$item->id?>" />
|
|
|
|
|
- </td>
|
|
|
|
|
- <td>
|
|
|
|
|
- <?=htmlspecialchars($item->description)?>
|
|
|
|
|
- </td>
|
|
|
|
|
- <td>
|
|
|
|
|
- <?=htmlspecialchars($item->serial_number)?>
|
|
|
|
|
- </td>
|
|
|
|
|
- <td class="text-end">
|
|
|
|
|
- <?=$item->quantity?>
|
|
|
|
|
- </td>
|
|
|
|
|
|
|
+ <input class="form-check-input" id="all-items-checkbox" type="checkbox" />
|
|
|
|
|
+ </th>
|
|
|
|
|
+ <th><?=htmlspecialchars(__("Description"))?></th>
|
|
|
|
|
+ <th><?=htmlspecialchars(__("Serial Number"))?></th>
|
|
|
|
|
+ <th><?=htmlspecialchars(__("Quantity"))?></th>
|
|
|
<?php
|
|
<?php
|
|
|
if($document->isInvoice()) {
|
|
if($document->isInvoice()) {
|
|
|
?>
|
|
?>
|
|
|
- <td class="text-end">
|
|
|
|
|
- <?=htmlspecialchars($formatter->formatCurrency($item->unit_price, $currency))?>
|
|
|
|
|
- </td>
|
|
|
|
|
- <td class="text-end">
|
|
|
|
|
- <?=htmlspecialchars($formatter->formatCurrency($item->getAmount(), $currency))?>
|
|
|
|
|
- </td>
|
|
|
|
|
|
|
+ <th><?=htmlspecialchars(__("Unit Price"))?></th>
|
|
|
|
|
+ <th><?=htmlspecialchars(__("Amount"))?></th>
|
|
|
<?php
|
|
<?php
|
|
|
- $subtotal = bcadd($subtotal, $item->getAmount());
|
|
|
|
|
}
|
|
}
|
|
|
?>
|
|
?>
|
|
|
- <td class="p-1 text-nowrap">
|
|
|
|
|
- <button class="btn btn-sm btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#document-item-modal" data-document-id="<?=$document->id?>" data-item="<?=htmlspecialchars(json_encode($item))?>">
|
|
|
|
|
- <i class="fa fa-fw fa-pencil"></i>
|
|
|
|
|
- </button>
|
|
|
|
|
- <button class="btn btn-sm btn-danger btn-delete-document-item" type="button" data-document-item-id="<?=$item->id?>">
|
|
|
|
|
- <i class="fa fa-fw fa-trash"></i>
|
|
|
|
|
- </button>
|
|
|
|
|
- </td>
|
|
|
|
|
|
|
+ <th><?=htmlspecialchars(__("Actions"))?></th>
|
|
|
</tr>
|
|
</tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
<?php
|
|
<?php
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- </tbody>
|
|
|
|
|
|
|
+ $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
|
|
|
|
|
+ $currency = $document->currency;
|
|
|
|
|
+ $subtotal = "0.00";
|
|
|
|
|
+
|
|
|
|
|
+ foreach($document->getItems() as $item) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td>
|
|
|
|
|
+ <!--suppress HtmlFormInputWithoutLabel -->
|
|
|
|
|
+ <input class="form-check-input" type="checkbox" name="document_item_ids[]" value="<?=$item->id?>" />
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td>
|
|
|
|
|
+ <?=htmlspecialchars($item->description)?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td>
|
|
|
|
|
+ <?=htmlspecialchars($item->serial_number)?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td class="text-end">
|
|
|
|
|
+ <?=$item->quantity?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ if($document->isInvoice()) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <td class="text-end">
|
|
|
|
|
+ <?=htmlspecialchars($formatter->formatCurrency($item->unit_price, $currency))?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td class="text-end">
|
|
|
|
|
+ <?=htmlspecialchars($formatter->formatCurrency($item->getAmount(), $currency))?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ $subtotal = bcadd($subtotal, $item->getAmount());
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <td class="p-1 text-nowrap">
|
|
|
|
|
+ <button class="btn btn-sm btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#document-item-modal" data-document-id="<?=$document->id?>" data-item="<?=htmlspecialchars(json_encode($item))?>">
|
|
|
|
|
+ <i class="fa fa-fw fa-pencil"></i>
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button class="btn btn-sm btn-danger btn-delete-document-item" type="button" data-document-item-id="<?=$item->id?>">
|
|
|
|
|
+ <i class="fa fa-fw fa-trash"></i>
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ if($document->isInvoice()) {
|
|
|
|
|
+ $tax = bcmul($subtotal, $document->tax_rate / 100, 2);
|
|
|
|
|
+ $total = bcadd($subtotal, $tax, 2);
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <tfoot>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th colspan="5" class="text-end"><?=htmlspecialchars(__("Subtotal"))?></th>
|
|
|
|
|
+ <td class="text-end"><?=htmlspecialchars($formatter->formatCurrency($subtotal, $currency))?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th colspan="5" class="text-end"><?=htmlspecialchars(__("Tax Rate"))?></th>
|
|
|
|
|
+ <td class="text-end">
|
|
|
|
|
+ <?=$document->tax_rate?>%
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th colspan="5" class="text-end"><?=htmlspecialchars(__("Tax"))?></th>
|
|
|
|
|
+ <td class="text-end">
|
|
|
|
|
+ <?=htmlspecialchars($formatter->formatCurrency($tax, $currency))?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th colspan="5" class="text-end"><?=htmlspecialchars(__("Total"))?></th>
|
|
|
|
|
+ <td class="text-end">
|
|
|
|
|
+ <?=htmlspecialchars($formatter->formatCurrency($total, $currency))?>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </tfoot>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ </table>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="mb-1">
|
|
|
|
|
+ <?=htmlspecialchars(__("With selected items:"))?>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<?php
|
|
<?php
|
|
|
if($document->isInvoice()) {
|
|
if($document->isInvoice()) {
|
|
|
- $tax = bcmul($subtotal, $document->tax_rate / 100, 2);
|
|
|
|
|
- $total = bcadd($subtotal, $tax, 2);
|
|
|
|
|
?>
|
|
?>
|
|
|
- <tfoot>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th colspan="5" class="text-end"><?=htmlspecialchars(__("Subtotal"))?></th>
|
|
|
|
|
- <td class="text-end"><?=htmlspecialchars($formatter->formatCurrency($subtotal, $currency))?></td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th colspan="5" class="text-end"><?=htmlspecialchars(__("Tax Rate"))?></th>
|
|
|
|
|
- <td class="text-end">
|
|
|
|
|
- <?=$document->tax_rate?>%
|
|
|
|
|
- </td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th colspan="5" class="text-end"><?=htmlspecialchars(__("Tax"))?></th>
|
|
|
|
|
- <td class="text-end">
|
|
|
|
|
- <?=htmlspecialchars($formatter->formatCurrency($tax, $currency))?>
|
|
|
|
|
- </td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th colspan="5" class="text-end"><?=htmlspecialchars(__("Total"))?></th>
|
|
|
|
|
- <td class="text-end">
|
|
|
|
|
- <?=htmlspecialchars($formatter->formatCurrency($total, $currency))?>
|
|
|
|
|
- </td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </tfoot>
|
|
|
|
|
|
|
+ <button type="submit" class="btn btn-primary" name="batch_action" value="create-delivery-note">
|
|
|
|
|
+ <i class="fa fa-fw fa-file-invoice"></i>
|
|
|
|
|
+ <?=htmlspecialchars(__("Create Delivery Note"))?>
|
|
|
|
|
+ </button>
|
|
|
<?php
|
|
<?php
|
|
|
}
|
|
}
|
|
|
?>
|
|
?>
|
|
|
- </table>
|
|
|
|
|
|
|
|
|
|
- <div class="mb-1">
|
|
|
|
|
- <?=htmlspecialchars(__("With selected items:"))?>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <?php
|
|
|
|
|
- if($document->isInvoice()) {
|
|
|
|
|
- ?>
|
|
|
|
|
- <button type="submit" class="btn btn-primary" name="batch_action" value="create-delivery-note">
|
|
|
|
|
- <i class="fa fa-fw fa-file-invoice"></i>
|
|
|
|
|
- <?=htmlspecialchars(__("Create Delivery Note"))?>
|
|
|
|
|
|
|
+ <button type="submit" class="btn btn-danger" name="batch_action" value="delete">
|
|
|
|
|
+ <i class="fa fa-fw fa-trash"></i>
|
|
|
|
|
+ <?=htmlspecialchars(__("Delete"))?>
|
|
|
</button>
|
|
</button>
|
|
|
- <?php
|
|
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
-
|
|
|
|
|
- <button type="submit" class="btn btn-danger" name="batch_action" value="delete">
|
|
|
|
|
- <i class="fa fa-fw fa-trash"></i>
|
|
|
|
|
- <?=htmlspecialchars(__("Delete"))?>
|
|
|
|
|
- </button>
|
|
|
|
|
- </form>
|
|
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
</section>
|
|
</section>
|