I can't add clients with same name


#1

Hi, I’m using InvoicePlane 1.5.9 and I’m not able to add clients with the same name, in Italy is common that people have the same name and surname, for example “Mario Rossi”.
What can I do to solve this problem? I want some clients to have the same name (they will differ in email obviously). At the moment I add a progressive number to the name whenever I have a duplicate, but it doesn’t look good and it creates problems when i create Invoices and quotes…


#2

Are you able to change the code? If you are, I can show you how to disable the check for the name and surname in the code, although this should be a temporary measure.

How can you distinguish one from another, For example, if you receive a phone call, and someone says "Hi, this is Mario Rossi calling ", how do you know which one. He may say “Mario Rossi from Rome”, or “Mario Rossi from Microsoft”. You could use this information as part of your naming.


#3

@crafter is right. IP uses the client name to identify clients when listing quotes, invoices, payments, as in,

and if you use the same name you will not be able to differentiate them. So I agree, the best solution would be to add some extra information (VAT number, town, an alias) to the client name to make it unique.


#4

Yes I can change the code, i have access to all the files and i know a little of php and mysql.
Adding the address as part of the key in the database to make it unique is enough for me, can you help me with the modifications i have to do to disable the check? thanks!


#5

The file to change is application/modules/clients/controllers/Clients.php

This is the snippet of code where the check is done.

   public function form($id = null)
   {
       if ($this->input->post('btn_cancel')) {
           redirect('clients');
       }
      $new_client = false;        
        // Set validation rule based on is_update
        if ($this->input->post('is_update') == 0 && $this->input->post('client_name') != '') {
            $check = $this->db->get_where('ip_clients', array(
                'client_name' => $this->input->post('client_name'),
                'client_surname' => $this->input->post('client_surname')
            ))->result();

if (!empty($check)) {
                $this->session->set_flashdata('alert_error', trans('client_already_exists'));
                redirect('clients/form');
            } else {
                $new_client = true;
            }
        }

My suggestion is to add the email address as part of the check.
The lines

$check = $this->db->get_where('ip_clients', array(
    'client_name' => $this->input->post('client_name'),
    'client_surname' => $this->input->post('client_surname')
))->result();

should then read

            $check = $this->db->get_where('ip_clients', array(
                'client_name' => $this->input->post('client_name'),
                'client_surname' => $this->input->post('client_surname'),
                'client_email' => $this->input->post('client_email')
            ))->result();