<table class="ti-items">
    <thead>
        <tr>
            <th class="w-sr">Sr</th>
            <th class="w-item">Item Description</th>
            <th class="w-hsn">HSN</th>
            <th class="w-unit">Unit</th>
            <th class="w-mrp">MRP</th>
            <th class="w-qty">Qty</th>
            <th class="w-rate">Rate</th>
            <th class="w-gst">GST%</th>
            <th class="w-disc">Disc</th>
            <th class="w-amt">Amount</th>
        </tr>
    </thead>

    <tbody>
        <?php $i=1; while($row = $items->fetch_assoc()): ?>
        <tr>
            <td class="c"><?= $i++ ?></td>
            <td>
                <?= htmlspecialchars($row['product_name']) ?>
                <?php if($row['item_description']): ?>
                    <div class="item-sub-desc">
                        <?= nl2br(htmlspecialchars($row['item_description'])) ?>
                    </div>
                <?php endif; ?>
            </td>
            <td class="c"><?= $row['hsn_code'] ?></td>
            <td class="c"><?= $row['unit'] ?></td>
            <td class="r"><?= number_format($row['mrp'],2) ?></td>
            <td class="r"><?= $row['sold_qty'] ?></td>
            <td class="r"><?= number_format($row['selling_price_incl'],2) ?></td>
            <td class="c"><?= $row['gst_percent'] ?>%</td>
            <td class="c">
                <?= $row['discount_type']=='percent'
                    ? $row['discount_value'].'%'
                    : '₹'.$row['discount_value'] ?>
            </td>
            <td class="r"><?= number_format($row['total_amount'],2) ?></td>
        </tr>
        <?php endwhile; ?>
    </tbody>
</table>