From fa6b3001ab0f3870eb1f03e71e6741748d2de6de Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 14 May 2025 17:28:53 +0530 Subject: [PATCH 1/2] FIX_FILE_UPLOAD : RV --- app/Helpers/utility_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 33f504c0..0d4529c3 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -55,8 +55,8 @@ if (!function_exists('file_Upload')) { function file_Upload($fileToUpload, $filepath) { if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { + $fileToUpload->move($filepath); $fileName = $fileToUpload->getName(); - $fileToUpload->move($filepath, $fileName); return $fileName; } else { return ""; From 3f0003224f16d94b064577dfce1dfd3ae85174e3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 16 May 2025 10:47:15 +0530 Subject: [PATCH 2/2] CHANGE_CLIENT_FROM_LEADS : RV --- app/Controllers/LeadsController.php | 199 ++++++++++-------- .../PolicyTransactionController.php | 34 +-- app/Views/client_list.php | 53 ++++- 3 files changed, 170 insertions(+), 116 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 617add8f..fdeca47e 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -602,8 +602,8 @@ class LeadsController extends BaseController return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200); } } - //--------RFQ----------------------------------------------------------------------------------------------- + //--------RFQ----------------------------------------------------------------------------------------------- public function viewRFQ($id, $type = 1) { @@ -2538,64 +2538,103 @@ class LeadsController extends BaseController public function featchLeadDataAndInsertClient($lead_id) { - $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); + try { + $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); - if (!$data) { - return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200); + if (!$data) { + $this->myLogger->logme('featchLeadDataAndInsertClient', "Lead not found or inactive", ['lead_id' => $lead_id]); + return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200); + } + + $result = $this->createClientWithLeadData($data); + + if ($result) { + $policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first(); + return $this->respond([ + 'status' => true, + 'message' => 'New Client created successfully', + 'client_id' => $result, + 'data' => $data, + 'client_policy_id' => $policy_data['id'] ?? null, + ], 200); + } + + $this->myLogger->logme('featchLeadDataAndInsertClient', "Client creation failed after processing", ['lead_id' => $lead_id]); + return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200); + } catch (\Throwable $e) { + $this->myLogger->logme('featchLeadDataAndInsertClient', $e->getMessage(), ['lead_id' => $lead_id, 'trace' => $e->getTraceAsString()]); + return $this->respond(['status' => false, 'message' => 'Internal server error', 'error' => $e->getMessage()], 500); } - - $result = $this->createClientWithLeadData($data); - - if ($result) { - - $policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first(); - return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data, 'client_policy_id' => $policy_data['id']], 200); - } - - return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200); } public function createClientWithLeadData($data) { - $client_data = $this->prepareClientData($data); - $client_id = $this->clientModel->insert($client_data); + try { + $client_data = $this->prepareClientData($data); + $client_id = $this->clientModel->insert($client_data); - if ($client_id) { - $this->createClientBranchAndContactWithLeadData($data, $client_id); - $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + if ($client_id) { + $this->createClientBranchAndContactWithLeadData($data, $client_id); + $this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update(); + } + + return $client_id; + } catch (\Throwable $e) { + $this->myLogger->logme('createClientWithLeadData', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return false; } + } - return $client_id; + public function createClientBranchAndContactWithLeadData($data, $client_id) + { + try { + $branch_data = $this->prepareClientBranchData($data, $client_id); + $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); + $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); + } + + return $branch_id; + } catch (\Throwable $e) { + $this->myLogger->logme('createClientBranchAndContactWithLeadData', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return false; + } + } + + public function createClientPolicyWithLeadData($data, $client_id, $branch_id) + { + try { + $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); + $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(); + $this->leadsModel->where('id', $data['id'])->set('is_policy_created', $client_id)->update(); + } + + return $client_policy_id; + } catch (\Throwable $e) { + $this->myLogger->logme('createClientPolicyWithLeadData', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return false; + } } private function prepareClientData($data) { return [ - 'client_type' => $data['client_type'], - 'entity_type_id' => $data['entity_type_id'], - 'client_code' => $data['client_code'], - 'client_name' => $data['client_name'], - 'short_name' => $data['client_short_name'], - 'pan' => $data['pan'], + 'client_type' => $data['client_type'] ?? null, + 'entity_type_id' => $data['entity_type_id'] ?? null, + 'client_code' => $data['client_code'] ?? null, + 'client_name' => $data['client_name'] ?? null, + 'short_name' => $data['client_short_name'] ?? null, + 'pan' => $data['pan'] ?? null, ]; } - public function createClientBranchAndContactWithLeadData($data, $client_id) - { - $branch_data = $this->prepareClientBranchData($data, $client_id); - $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); - - $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); - } - - return $branch_id; - } - private function prepareClientBranchData($data, $client_id) { $default_unit = trim(($data['client_short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-'); @@ -2620,19 +2659,6 @@ class LeadsController extends BaseController ]; } - public function createClientPolicyWithLeadData($data, $client_id, $branch_id) - { - $client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id); - $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) { $proposel_data = json_decode($data['proposel_data'], true); @@ -2682,17 +2708,46 @@ class LeadsController extends BaseController private function preparePolicyTermsFromRFQ($data) { - $proposel_data = json_decode($data['proposel_data'], true); + try { + $proposel_data = json_decode($data['proposel_data'], true); + $QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first(); - $QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first(); + if (!$QCRData) { + throw new \Exception('RFQ Data not found'); + } - $JSON = json_decode($QCRData['json'], true); + $JSON = json_decode($QCRData['json'], true); + $converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']); - $converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']); - - return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']); + return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']); + } catch (\Throwable $e) { + $this->myLogger->logme('preparePolicyTermsFromRFQ', $e->getMessage(), ['lead_id' => $data['id'], 'trace' => $e->getTraceAsString()]); + return null; + } } + public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id) + { + $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); + + if (!$data) { + return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => null], 200); + } + + $result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); + // print_r($result); die; + + if ($result) { + + $policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first(); + return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200); + } + + return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200); + } + + // --------------------------------------------------------------------------------------------------------------- + //Function for convert the RFQ and QCR Json to Policy Terms Json public function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name) { @@ -2817,26 +2872,6 @@ class LeadsController extends BaseController } } - public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id) - { - $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); - - if (!$data) { - return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => null], 200); - } - - $result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id); - // print_r($result); die; - - if ($result) { - - $policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first(); - return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200); - } - - return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200); - } - public function getPlacementJson(array $data): ?string { $proposel_data = json_decode($data['proposel_data'], true); @@ -2929,7 +2964,7 @@ class LeadsController extends BaseController } - function getLastFiveFinancialYears() + public function getLastFiveFinancialYears() { $currentYear = date('Y'); $currentMonth = date('m'); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index a4721770..7b35bc86 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -327,42 +327,37 @@ class PolicyTransactionController extends BaseController return $data; } - + private function insertInceptionPolicy($data) - { + { // print_r($data); die; $insert = $this->policyTransactionModel->insert($data); + if ($insert) { + $this->insertTransactionStatus($insert, $data, 1); $emp_data = $this->processInsertIndividualMemberInEmpTable($data); - if(isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])){ + if (isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])) { $pt_co_share_details = $this->insertOrUpdateCoShareDetails($data, $insert); if ($data['ct_type'] == 2) { - $client_policy_insert_data = $this->prepareClientPolicyInsertData($data); $client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data); $this->policyTransactionModel->update($insert, ['client_policy_id' => $client_policy_id]); $emp_policy_insert = $this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id); - - if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { - $this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']); - } } - - $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $insert)->where('is_active', 1)->findAll(); + if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { + $this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']); + } } - - $client_data = $this->clientModel->where('id', $data['client_id'])->first(); - $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll(); - $data['entity_type_id'] = $client_data['entity_type_id']; return $this->respondSuccess($insert, "Policy transaction created successfully", $data); } + return $this->respondError("Failed to create policy transaction"); } @@ -397,19 +392,12 @@ class PolicyTransactionController extends BaseController } } - if ($data['status'] == 'completed' && $data['ct_type'] == 2) { - if($data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1){ - $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']); - } + if($data['status'] == 'completed' && $data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1){ + $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']); } - $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll(); } - $client_data = $this->clientModel->where('id', $data['client_id'])->first(); - $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll(); - $data['entity_type_id'] = $client_data['entity_type_id']; - return $this->respondSuccess($id, "Policy transaction updated successfully", $data); } diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 592031dc..673c5eaf 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -17,6 +17,10 @@ table.dataTable thead th { max-width: 98% !important; } +.btn-filter{ + margin-left: 20px !important; +} + .custom-dropdown-menu { display: none; position: absolute; @@ -53,12 +57,12 @@ table.dataTable thead th {

Client List

-
+
@@ -269,18 +273,40 @@ table.dataTable thead th { $(document).ready(function() { $('#tickets-table').DataTable({ - dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" + + dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - buttons: [{ - extend: 'csv', - text: 'CSV', - title: 'ClientList', - className: 'my_class', - exportOptions: { - columns: ':not(:last-child)' + buttons: [ + { + extend: 'csv', + text: 'CSV', + title: 'ClientList', + className: 'my_class', + exportOptions: { + columns: ':not(:last-child)' + }, + }, + { + text: 'Add From Lead', + className: 'btn-filter', // custom class + action: function(e, dt, node, config) { + showModal(); + } }, - }], + { + text: 'Add', + className: 'btn-filter', // custom class + action: function(e, dt, node, config) { + addClient(); + } + } + ], + + initComplete: function() { + $('.btn-filter') + .removeClass('btn-secondary') + .addClass('btn btn-primary'); + }, language: { search: "_INPUT_", searchPlaceholder: "Search..." @@ -440,4 +466,9 @@ function featchClient(){ }); } +function addClient(){ + let url = ""; + window.location.href = url; +} + \ No newline at end of file