Adding Date to each Item


#1

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?


#2

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.


#3

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.


#4

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.


#5

Awesome,

The code worked!

Thank you