Custom field in client table

Hey Guys,

How can i place a custom field in the customers table?
i tried the code of line 19 but gave the following error :

Message: Undefined variable: custom_fields

Filename: views/partial_client_table.php

Line Number: 19

Thanks for the help

This is the code i have so far :

Aswel as my custom field settings in the app :

I believe it is because you are not specifying what group the Custom Field belongs to but I could be wrong - I had a similar issue and Kovah replied…

https://community2.invoiceplane.com/t/topic/4569/2?u=nmay1990

Hi ,

Thanks!
But i get the same error i added on line 19 in the picture.

<?php echo $custom_fields['client']['Passagier']; ?>

still gives me error :
Message: Undefined variable: custom_fields

Filename: views/partial_client_table.php

Line Number: 19

Hi mate,

You are getting this error because there is no $custom_fields passed into this view.

A very quick and dirty solution would be like this just to see whats going under the hood.You may want to improve it:slight_smile:

in Mdl_clients.php modify default_select method like this;

   public function default_select()
    {
        $this->db->select(
            'SQL_CALC_FOUND_ROWS ' . $this->table . '.*, ip_client_custom.client_custom_fieldvalue,ip_custom_fields.custom_field_label,' .
            'CONCAT(' . $this->table . '.client_name, " ", ' . $this->table . '.client_surname) as client_fullname'
            , false)->join('ip_client_custom','ip_clients.client_id=ip_client_custom.client_id','left')
            ->join('ip_custom_fields','ip_client_custom.client_custom_fieldid=custom_field_id','left');
    }

now $records array will contain the fields you need.
you may call it like in your partial_client_table.php

   <?php echo $client->custom_field_label;?>
   <?php echo client_custom_fieldvalue;?>

Again, this is not the best way to it but when you try it you’ll see how to fetch the needed elements.

Hi ,

Any better way of doing this?
i tried it i placed the code in Mdl_clients
but then it only shows the title of the custom field in the table instead of the value itself.
My custom field Label is “Passagier”

This is my mdl code:

My client screen :

Custom fields are not supported in client tables.

Edit:
Use the custom field block from

in the corresponding client controller method status()

You would have to loop trough all clients and get the fields for each client separately.

Hi Kovah,

Thanks for the info.
Can you help me do this? Just for one custom field.
If possible offcource.

Thanks

Sorry but I have no time to work with any custom coding tasks.

Okay no problem.
I understand.

If anyone else could help.
All help would be welcome.

@Contributors @Developers

Webtica,

Can you also share you partial_client_table.php file screenshot. I think you are almost there:) let me see it

1 Like

Hey Aarion,

Here is my partial client table:

Thanks for the help already.
Kind regards
Dieter

Ok so on line 19 what does it print out if you use $client->client_custom_fieldvalue instead of $custom_fields->Passagier ?

1 Like

Hey Aarion,

This is my partial client table view after i applied your code :

And the error:

Ok one last request then,
under application/modules/clients/controllers/Clients.php

you’ll see this line;
$this->load->model('mdl_clients');

after that line please add these two;

$this->load->model('custom_fields/mdl_custom_fields');
$this->load->model('custom_fields/mdl_client_custom');

and refresh the page. See if you get the values in the table. If not please backup your partials table and paste this code;

<div class="table-responsive">
<table class="table table-striped">
    <thead>
    <tr>
        <th><?php _trans('active'); ?></th>
        <th><?php _trans('client_name'); ?></th>
        <th><?php _trans('email_address'); ?></th>
        <th><?php _trans('phone_number'); ?></th>
        <th class="amount"><?php _trans('balance'); ?></th>
        <th><?php _trans('options'); ?></th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($records as $client) : ?>
		<?php var_dump($client);?>
    <?php endforeach; ?>
    </tbody>
</table>

This will show us whats inside $clients array :slight_smile:

Hi Aarion,

Im going to test this now :slight_smile:
One min.

Hi Aarion,

So this is what i did :

I pasted the first two codes here:

Then i refreshed the page everything still the same.
So i pasted the next code here:

and i got as result this ( the custom field passagier is not in the array it seems.) :

Thanks
Dieter

Btw, Mdl_clients.php still has the joins right? That’s strange. From your screenshot of Custom Fields, I understand you added a custom field called Passenger and it belongs to the customer. If that’s the case that should show up. Can you make sure Mdl_clients.php has the joins.

Sorry, What do you mean with joins? ( im not great in this PHP code stuff :slight_smile: )

Yes i made a custom field called Passenger this is a screenshot of the custom field settings:

Sorry My bad.
The Mdl code did it :slight_smile:
it works!
But now so for example if i would make another custom field for example in invoices.
How can i show that custom field in that invoice table? do i just do the same codes for invoices or how can i add more custom fields to tables later down the line?