Want to add custom field to report but not in invoice

Hi,

I wish to add a custom field (e.g. product cost) into the sale report by client, but not to appear in the invoice. I shall be grateful if anyone is kind to share with me how to do it.

Thank you.

Are your custom fields being printed on your inoice in any case?

Because this is about cost price, it is not supposed to print inside invoice, but to print in sales report by client. I shall be grateful if you could guide me how to do that. Thank you in advance.

Start in this file : application/modules/reports/controllers/Reports.php

public function sales_by_client()
{
         //  ....
        $this->load->model('custom_fields/mdl_client_custom');
        $client_custom_fields = $this->mdl_client_custom->where('client_id', $id)->get();
        //  ....
        $data = array(
            'results' =>  ....
            'from_date' =>...
            'to_date' =>  ...
           'custom_fields' => $client_custom_fields
        );
        //  ....
}

Then in your view : application/modules/reports/views/sales_by_client_index.php

                            <?php foreach ($custom_fields as $custom_field) : ?>
                                <?php if ($custom_field->custom_field_location != 2) {
                                    continue;
                                } ?>
                                <tr>
                                    <?php
                                    $column = $custom_field->custom_field_label;
                                    $value = $this->mdl_client_custom->form_value('cf_' . $custom_field->custom_field_id);
                                    ?>
                                    <th><?php _htmlsc($column); ?></th>
                                    <td><?php _htmlsc($value); ?></td>
                                </tr>
                            <?php endforeach; ?>
1 Like