Adding Date to each Item

Hello I’m using version 1.5.9

I managed to add a new column to the invoice and everytime I save the date disappear

I added this to the /application/modules/invoices/views/partial_item_table.php

<tbody id="new_row" style="display: none;">
<tr>
    <td class="td-date">
        <div class="input-group">
            <span class="input-group-addon"><?php _trans('date'); ?></span>
	      <input type="text" name="item_date" class="input-sm form-control datepicker" value="<?php echo format_date(@$item->item_date); ?>"
        </div>
    </td>

I also modify/added /application/views/invoice_templates/pdf/invoiceplane.php

<table class="item-table">
    <thead>
    <tr>
      <th class="item-date"><?php _trans('date'); ?></th> //Added
      <th class="item-name"><?php _trans('item'); ?></th>

and

<?php
    foreach ($items as $item) { ?>
        <tr>
	   <td><?php _htmlsc($item->item_date); ?></td> //Added

Will this give me trouble later on if I update?

At least its not the right way to do so.
Pls just edit the TEMPLATES which are located here:

/application/views/invoice_templates/*
/application/views/quote_templates/*

I would recomment copying the original ones and renaming them to custom ones.
There you can add your code (what you already did).

I just dont get why you modified “/application/modules/invoices/views/partial_item_table.php” ?
Have you tried to revert the “/application/modules/invoices/views/partial_item_table.php” File back to stock and try again? Because I think it is unnecessary to edit this file to achive what you want.

Sorry my account was on hold thus I could not answer.

I’m trying to get the invoice to have a new column with different date for each item on there.
The /application/views/invoice_templates/* only let me change the layout of the PDF output. How could I make those dates appear without changing the /application/modules/invoices/views/partial_item_table.php file?

After saving, I could not edit the date for each item.

You must add the fields in two places

application/modules/invoices/views/partial_item_table.php

    <tbody id="new_row" style="display: none;">
              ....
    `</tbody>

The code above you have done already (you should the code above).
This is a hidden form (see “display: none;” That is used when you click the “Add New Row Button”.

When the page loads, you need code in the for loop

       <?php foreach ($items as $item) { ?>
                <tbody class="item">
                                   .... <snip>
                     <!-- START OF ITEM DATE FIELDS -->
                        <td class="td-date">
                            <div class="input-group">
                                <span class="input-group-addon"><?php _trans('date'); ?></span>
                                <input type="text" name="item_date" class="input-sm form-control datepicker"
                                       value="<?php echo format_date($item->item_date); ?>"
                                    <?php if ($invoice->is_read_only == 1) {
                                        echo 'disabled="disabled"';
                                    } ?>>
                            </div>
                        </td>
                    <!-- END OF ITEM DATE FIELDS -->

                    <td class="td-amount td-quantity">
                               .... <snip>
                    </td>
                            ...    <snip>
            </tbody>
        <?php } ?

Please note the code above is NOT TESTED.

1 Like

Awesome,

The code worked!

Thank you

Create question, i managed to add item date to my invoiceplane setup. One thing that i would like to change is the date notation on the PDF, any code fix for that?

@Pietsnot can you make your own question?
You can refer to this one if you like.
Just mention what you’ve tried and what’s not working.
Thank you

This topic was automatically closed after 15 hours. New replies are no longer allowed.