All files we’re going to add and edit are in the application
directory.
Most of them are in /modules/clients
.
If they are in different directory, i’ll say full path, otherwise, i’ll just talk about Controllers, Models, Views in that clients
directory.
Migration
So … first task is to add your field to the database.
We use .sql files in /modules/setup/sql
.
copy/paste that latest file and just add 1 to the filename:
038_1.6.2.sql
, something like that.
When i add an important field, i’ll usually add it close to the client_id
.
So maybe something like:
ALTER TABLE `ip_clients` ADD client_number VARCHAR(255) NULL DEFAULT NULL AFTER `client_id`;
Second task is to alter the functions.
Index of clients is in the Clients controller: Clients.php
and then the index()
function (status()
function).
The view is in the views
directory.
When the sql is not inside status()
function, it’s inside the model.
For every place you want your field, just adjust the sql in the model and after that adjust your view: application/modules/clients/views/partial_client_table.php
I hope it makes sense.
Adding, Editing
Then the Ajax for the forms. They go through the Ajax controller.
Right now, this is the response for the frontend:
$response[] = [
'id' => $client->client_id,
'text' => (format_client($client)),
];
IF you’re adding extra stuff here, it will help you in the frontend.
If the sql says something like this: ```
$clients = $this->mdl_clients
->where(‘client_active’, 1)
it will get all fields, so your client_number will be in there.
## Saving
Saving the clients will get you by the `public function validation_rules()` in the model, so add your rule for the client_number.
I would still validate on a string, so users can add their own variations.
## Invoices
Models, Views, Controllers in the `application/modules/invoices` directory
## Reports
Models, Views, Controllers in the
`application/modules/reports` directory
## Quotes, Projects, etc
Let's say they want to search for a client or 'change_client': `site_url('quotes/ajax/modal_change_client')`
Then you'll goto the `Quotes` module, the `Ajax` controller, the `modal_change_client` function
Try to go over every place where clients are chosen and shown.
Even if you don't use tasks or something like that, try to change it there as well.
Go slow, make your preferred change first, then add the rest.
Hope it helps!