<div class="row">
    <div class="col-sm-12">
        <div class="page-title-box"><h2 class="page-title"><?= ucfirst($note["Credit_debit_note"]["type"]) ?> Note - <?= h($note["Credit_debit_note"]["note_id"]) ?></h2></div>
    </div>
</div>
<div class="row">
    <div class="col-sm-12">
        <div class="card">
            <div class="card-body">
                <div class="row mb-3">
                    <div class="col-md-3"><strong>Vendor:</strong> <?= h($note["Credit_debit_note"]["vendor_name"]) ?></div>
                    <div class="col-md-3"><strong>Location:</strong> <?= h($note["Credit_debit_note"]["location_name"]) ?></div>
                    <div class="col-md-2"><strong>Total:</strong> <?= number_format($note["Credit_debit_note"]["total_amount"],2) ?></div>
                    <div class="col-md-2"><strong>Status:</strong>
                        <?php $s=$note["Credit_debit_note"]["status"]; echo $s==1?"<span class=\"badge badge-warning\">Pending</span>":($s==2?"<span class=\"badge badge-success\">Approved</span>":"$s"); ?>
                    </div>
                    <div class="col-md-2"><strong>Date:</strong> <?= date("d-m-Y", strtotime($note["Credit_debit_note"]["created"])) ?></div>
                </div>
                <?php if(!empty($note["Credit_debit_note"]["reason"])): ?>
                <p><strong>Reason:</strong> <?= h($note["Credit_debit_note"]["reason"]) ?></p>
                <?php endif; ?>
                <table class="table table-bordered mt-3">
                    <thead><tr><th>#</th><th>SKU</th><th>Unit</th><th>Price</th><th>Qty</th><th>Amount</th><th>Reason</th></tr></thead>
                    <tbody>
                    <?php $x=1; foreach($items as $i): $d=$i["Credit_debit_note_item"]; ?>
                        <tr>
                            <td><?= $x++ ?></td><td><?= h($d["sku_name"]) ?></td><td><?= h($d["sku_unit_name"]) ?></td>
                            <td><?= number_format($d["sku_price"],2) ?></td><td><?= $d["sku_quantity"] ?></td>
                            <td><?= number_format($d["sku_amount"],2) ?></td><td><?= h($d["reason"]) ?></td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
                <a href="<?= $this->base ?>/dashboard/credit_debit_notes" class="btn btn-secondary mt-2">Back</a>
            </div>
        </div>
    </div>
</div>
