How to add "Item No." on the Invoice?


#1

I want to add “Item No.” in all the PDF.

Example:
Item No. | Item | Description | Qty | Price | Total
1. | Test Item | Apple Inc. | 2 | 100 | 200
2. | More Item | Samsung Inc. | 1 | 100 | 100


#2
    <?php
    foreach ($items as $item) { ?>
        <tr>
            <td>**Need help here!!!**</td>
            <td><?php echo $item->item_name; ?></td>
            <td><?php echo nl2br($item->item_description); ?></td>
            <td class="text-right">
                <?php echo format_amount($item->item_quantity); ?>
            </td>
            <td class="text-right">
                <?php echo format_currency($item->item_price); ?>
            </td>
            <?php if ($show_discounts) : ?>
                <td class="text-right">
                    <?php echo format_currency($item->item_discount); ?>
                </td>
            <?php endif; ?>
            <td class="text-right">
                <?php echo format_currency($item->item_total); ?>
            </td>
        </tr>
    <?php } ?>

How do I add a loop for Item No? Any expert?


#3
<?php
    $i = 1;
    foreach ($items as $item) { ?>
        <tr>
            <td><?php echo $i . '.'; ?></td>
            <td><?php echo $item->item_name; ?></td>
            <td><?php echo nl2br($item->item_description); ?></td>
            <td class="text-right">
                <?php echo format_amount($item->item_quantity); ?>
            </td>
            <td class="text-right">
                <?php echo format_currency($item->item_price); ?>
            </td>
            <?php if ($show_discounts) : ?>
                <td class="text-right">
                    <?php echo format_currency($item->item_discount); ?>
                </td>
            <?php endif; ?>
            <td class="text-right">
                <?php echo format_currency($item->item_total); ?>
            </td>
        </tr>
    <?php
    $i++;
    } ?>

#4

Hi Kovah!!!

Thanks for the help. It works!!!

For others that are looking for this, you can change the file in the following folder:

/application/views/*


#5

Probably Item can be changed as item no and description can change to Item. Description detail is not really necessary in quotation / invoices.


#6

Item No. is useful for packing list. The picker / packer can double check the number of items they pack according to the printed invoice before the seal the packaging for delivery.


#8

hi, i tried this on invoice and quote. no doubt the item no displayed, but some part is not properly aligned as attached picture.

anyone can help me redo the code. thank you.

my code as follow:

<?php $i = 1; foreach ($items as $item) { ?>
        <tr>
             <td><?php echo $i . '.'; ?></td>
            <td><?php _htmlsc($item->item_name); ?></td>
            <td><?php echo nl2br(htmlsc($item->item_description)); ?></td>
            <td class="text-right">
                <?php echo format_amount($item->item_quantity); ?>
                <?php if ($item->item_product_unit) : ?>
                    <br>
                    <small><?php _htmlsc($item->item_product_unit); ?></small>
                <?php endif; ?>
            </td>
            <td class="text-right">
                <?php echo format_currency($item->item_price); ?>
            </td>
            <?php if ($show_item_discounts) : ?>
                <td class="text-right">
                    <?php echo format_currency($item->item_discount); ?>
                </td>
            <?php endif; ?>
            <td class="text-right">
                <?php echo format_currency($item->item_total); ?>
            </td>
        </tr>
    <?php $i++; } ?>

#9

Hi,

I would like to share the code that I got it works as follow:

https://file.io/fakOTO


#10