I've been developing a CRM system and the plan was to set it up on individual hosting for each individual client. The system is already about 95% complete and now I'd like to instead have the CRM in one place and be able to have each client access it and have their version of the CRM shown to them based on their login.
I've been developing this for over 2 years so there is a lot of code. In order to have one CRM with many clients I will need to change the databases to function based on a client ID.
That should mean:
- Updating the SQL tables
- Updating almost every bit of code in the PHP which connects to the mySQL database to include the client ID so it fetches the relevant data for that client.
In regards to number 1, that would be simple and quick to do.
However in regards to number 2, since the system is almost complete, there are probably over a thousand different places in the code which will need to be modified to include the client ID in the SQL statement to fetch/update/insert the relevant data for that client.
An example of some PHP in my code which connects to the mySQL database:
try {
$sql = "INSERT INTO call_list_recommend SET candid='".$candid."',".
"listid='".$recommended_list."',".
"rowid='".$rowid."',".
"transfer_type='".$transfer_type."',".
"byuser='".$_SESSION['username']."',".
"date=date_format(curdate(), '%d/%m/%Y')";
$result = $pdo->query($sql);
}
catch(PDOException $e) {
$error = 'Error recommending candidate for call list: ' . $e->getMessage();
showerror($error);
exit();
}
I would have to add the client ID to that SQL, and there would be over a thousand different places in code in various files which would also need to be updated.
Would this be the only way to achieve this or am I overlooking another perhaps quicker and more efficient way of achieving this goal?