diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index d25b93a9..7c5eef43 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1056,6 +1056,7 @@ class LeadsController extends BaseController if ($client_id) { $this->createClientBranchAndContactWithLeadData($data, $client_id); + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); } return $client_id; @@ -1079,7 +1080,7 @@ class LeadsController extends BaseController $branch_id = $this->clientBranchModel->insert($branch_data); if ($branch_id) { - + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); $contact_data = $this->prepareContactData($data, $branch_id); $this->levelContactModel->insert($contact_data); @@ -1116,7 +1117,14 @@ class LeadsController extends BaseController public function createClientPolicyWithLeadData($data, $client_id, $branch_id) { $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); - return $this->clientPolicyModel->insert($client_policy_data); + $client_policy_id = $this->clientPolicyModel->insert($client_policy_data); + + + if($client_policy_id){ + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + } + + return $client_policy_id; } private function prepareClientPolicyData($data, $client_id, $branch_id) diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 594a4c65..cae506f2 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -51,6 +51,7 @@ class LeadsModel extends Model 'updated_at', 'updated_by', 'is_active', + 'is_client_created', ]; @@ -127,7 +128,10 @@ class LeadsModel extends Model ->join('user_profiles', 'leads.created_by = user_profiles.id') ->where('leads.is_active', 1) ->where('leads.status', 'won') - ->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''"); + ->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''") + ->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)"); + + if ($type) { $query->where('leads.lead_type', $type); diff --git a/app/Views/client_list.php b/app/Views/client_list.php index f5c2a547..3cfcdece 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -107,7 +107,7 @@ table.dataTable thead th {