| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- namespace App;
- use App\Helpers\HtmlHelper;
- use NumberFormatter;
- /**
- * @var Sale $sale
- */
- ?>
- <section id="sale-items-section" class="mb-4">
- <div class="row mb-3">
- <div class="col">
- <h3><?=htmlspecialchars("Lead Items")?></h3>
- </div>
- <div class="col-auto">
- <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#sale-item-modal" data-sale-number="<?=$sale->getNumber()?>">
- <i class="fa fa-fw fa-plus"></i>
- <?=htmlspecialchars(__("Add Item"))?>
- </button>
- </div>
- </div>
- <?php
- $items = $sale->getItems();
- if(empty($items)) {
- HtmlHelper::renderInfoAlert(__("No items to display."));
- }
- else {
- $subtotal = "0.00";
- $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
- $currency = $sale->getCurrency();
- ?>
- <form action="<?=$sale->getUrl()?>/items-batch-action" method="post">
- <table id="sale-items-table" class="table table-bordered table-hover mb-2">
- <colgroup>
- <col style="width: 1%"/>
- <col style="width: 40%"/>
- <col style="width: 20%"/>
- <col style="width: 20%"/>
- <col style="width: 20%"/>
- <col style="width: 1%"/>
- </colgroup>
- <thead>
- <tr>
- <th>
- <!--suppress HtmlFormInputWithoutLabel -->
- <input class="form-check-input" id="sale-items-all-checkbox" type="checkbox" />
- </th>
- <th><?=htmlspecialchars(__("Product"))?></th>
- <th><?=htmlspecialchars(__("Quantity"))?></th>
- <th><?=htmlspecialchars(__("Unit Price"))?></th>
- <th><?=htmlspecialchars(__("Amount"))?></th>
- <th><?=htmlspecialchars(__("Actions"))?></th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($items as $item) {
- $product = $item->getProduct();
- $supplier = $product->getSupplier();
- ?>
- <tr>
- <td>
- <!--suppress HtmlFormInputWithoutLabel -->
- <input class="form-check-input" type="checkbox" value="<?=$item->id?>" name="sale_item_ids[]" />
- </td>
- <td>
- <small class="text-uppercase text-muted"><?=htmlspecialchars($supplier->name)?></small><br />
- <?=htmlspecialchars($product->name)?>
- </td>
- <td class="text-end">
- <?=$item->quantity?>
- </td>
- <td class="text-end">
- <?=htmlspecialchars($formatter->formatCurrency($item->unit_price, $currency))?>
- </td>
- <td class="text-end">
- <?=htmlspecialchars($formatter->formatCurrency($item->getAmount(), $currency))?>
- </td>
- <td class="p-1 text-nowrap">
- <button class="btn btn-sm btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#sale-item-modal" data-sale-number="<?=$sale->getNumber()?>" data-supplier-id="<?=$supplier->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-sale-item" type="button" data-sale-item-id="<?=$item->id?>">
- <i class="fa fa-fw fa-trash"></i>
- </button>
- </td>
- </tr>
- <?php
- $subtotal = bcadd($subtotal, $item->getAmount());
- }
- $tax = bcmul($subtotal, $sale->tax_rate / 100, 2);
- $total = bcadd($subtotal, $tax, 2);
- ?>
- </tbody>
- <tfoot>
- <tr>
- <th colspan="4" class="text-end"><?=htmlspecialchars(__("Subtotal"))?></th>
- <td class="text-end"><?=htmlspecialchars($formatter->formatCurrency($subtotal, $currency))?></td>
- <td></td>
- </tr>
- <tr>
- <th colspan="4" class="text-end"><?=htmlspecialchars(__("Tax Rate"))?></th>
- <td class="text-end">
- <?=$sale->tax_rate?>%
- </td>
- <td></td>
- </tr>
- <tr>
- <th colspan="4" class="text-end"><?=htmlspecialchars(__("Tax"))?></th>
- <td class="text-end">
- <?=htmlspecialchars($formatter->formatCurrency($tax, $currency))?>
- </td>
- <td></td>
- </tr>
- <tr>
- <th colspan="4" class="text-end"><?=htmlspecialchars(__("Total"))?></th>
- <td class="text-end">
- <?=htmlspecialchars($formatter->formatCurrency($total, $currency))?>
- </td>
- <td></td>
- </tr>
- </tfoot>
- </table>
- <div class="mb-1">
- <?=htmlspecialchars(__("With selected items:"))?>
- </div>
- <button type="submit" class="btn btn-primary batch-action" name="batch_action" value="create-invoice" disabled>
- <i class="fa fa-fw fa-file-invoice"></i>
- <?=htmlspecialchars(__("Create Invoice"))?>
- </button>
- <button type="submit" class="btn btn-danger batch-action" name="batch_action" value="delete" disabled>
- <i class="fa fa-fw fa-trash"></i>
- <?=htmlspecialchars(__("Delete"))?>
- </button>
- </form>
- <?php
- }
- ?>
- </section>
|