diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c91d90a3..fe1899f6 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -48,6 +48,7 @@ $routes->get("frontend_content", "AppContentManagementController::frontend_conte $routes->get('/test', 'Home::index'); $routes->get('/check_gemini', 'Home::check_Gemini'); $routes->get('/check_gemini2', 'Home::check_gemini_2'); +$routes->get('/checkPolicyDoc', 'Home::checkPolicyDoc'); $routes->get('/login', 'LoginController::index'); ///auth/google $routes->get('/loginPos', 'LoginController::loginPos'); //login POS team $routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no @@ -398,8 +399,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster'); $routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster'); $routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster'); - - + $routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount'); }); $routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 3bf6a341..00d81e59 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1193,7 +1193,7 @@ class EmployeeController extends AdminController // --------------- For E-Card Download ----------------------------------------------------------------------------------------------------- - //E-CARD DOWNLOAD FUNCTION USING HTML PRINT + //E-CARD DOWNLOAD FUNCTION USING HTML PRINT ( Not in use ) do not delete public function generateIDCardForEmployeeUsingHtml($rand_string, $people = 0) { // dd($rand_string, $people); @@ -1418,7 +1418,7 @@ class EmployeeController extends AdminController echo $htmlContent; } - //E-CARD DOWNLOAD FUNCTION USING DOM PDF ( CURRENTLY USING THIS ) + //E-CARD DOWNLOAD FUNCTION USING DOM PDF ( CURRENTLY USING THIS ) Dompdf public function generateIDCardForEmployee($rand_string, $people = 0, $mode = 0) { // dd($rand_string, $people); @@ -1470,8 +1470,8 @@ class EmployeeController extends AdminController // Step 3: Prepare template path $template_data_path = WRITEPATH . 'e_card_template/'; // $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html'; - $tpa_short_name = 'common.html'; - // $tpa_short_name = 'new_ecard.html'; + // $tpa_short_name = 'common.html'; + $tpa_short_name = 'new_ecard.html'; $final_path = $template_data_path . $tpa_short_name; $this->myLogger->logme('error', 'Checking if template file exists at: ' . $final_path); @@ -1495,6 +1495,7 @@ class EmployeeController extends AdminController $value['back_card'] = "Nhance_Ecard_working_1_Back.png"; $placeholders = [ + '{CLIENT_NAME}' => $value['client_name'], '{TPA_ID}' => $value['tpa_id'], '{NAME}' => $value['name'], @@ -1506,9 +1507,6 @@ class EmployeeController extends AdminController '{POLICY_START_DATE}' => date('d-M-Y', strtotime($value['policy_start_date'])), '{POLICY_NO}' => $value['policy_no'], '{INSURER_NAME}' => strtoupper($value['insurer_name']), - '{INSURER_LOGO}' => base_url() . 'public/uploads/logo/' . $value['insurer_logo'], - '{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'], - '{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['back_card'], '{EMP_ID}' => $value['emp_code'], '{SI_AMT}' => $value['basic_cover_si'], '{CORPORATE_NAME}' => $value['client_name'], @@ -1516,15 +1514,33 @@ class EmployeeController extends AdminController '{TPA_NAME}' => $value['tpa_name'], '{INSURER_BRANCH}' => $value['insurer_branch_city'], '{RELATION}' => $value['relationship'], - '{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $value['tpa_logo'], - '{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg', - '{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png', - '{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg', - '{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png', - '{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png', - '{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png', - '{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png', - '{NHANCE_N_LOGO}' => base_url() . 'public/assets/images/Nhance_Favi.png', + + '{TPA_LOGO}' => getFileIfExists('uploads/logo/' . $value['tpa_logo']), + '{MEDI_USER}' => getFileIfExists('e_card_imgs/medi_uesr.jpg'), + '{MEDI_INSURER}' => getFileIfExists('e_card_imgs/Magma.png'), + '{MEDI_BARCODE}' => getFileIfExists('e_card_imgs/borcode.jpeg'), + '{QR_ANDROID}' => getFileIfExists('e_card_imgs/android.png'), + '{QR_IOS}' => getFileIfExists('e_card_imgs/ios.png'), + '{QR_ANDROID_2}' => getFileIfExists('e_card_imgs/play_store.png'), + '{QR_IOS_2}' => getFileIfExists('e_card_imgs/appstore.png'), + '{NHANCE_N_LOGO}' => getFileIfExists('assets/images/Nhance_Favi.png'), + '{INSURER_LOGO}' => getFileIfExists('uploads/logo/' . $value['insurer_logo']), + '{FRONT_CARD}' => getFileIfExists('uploads/template_bg/' . $value['front_card']), + '{BACK_CARD}' => getFileIfExists('uploads/template_bg/' . $value['back_card']), + + // '{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $value['tpa_logo'], + // '{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg', + // '{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png', + // '{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg', + // '{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png', + // '{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png', + // '{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png', + // '{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png', + // '{NHANCE_N_LOGO}' => base_url() . 'public/assets/images/Nhance_Favi.png', + // '{INSURER_LOGO}' => base_url() . 'public/uploads/logo/' . $value['insurer_logo'], + // '{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'], + // '{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['back_card'], + ]; $placeholders['{LEVELS}'] = $this->generateAcmAndMForEcard($client_id); diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 68eb0402..84d0d8c9 100755 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -60,6 +60,8 @@ class Home extends PublicController //print_rr($data); } + + //for insurer statement upload public function check_gemini_2() { @@ -158,6 +160,143 @@ class Home extends PublicController + // The final JSON payload + $data = [ + "contents" => [ + $content_parts + ] + ]; + + // Encode the data to a JSON string + $json_data = json_encode($data); + + // Initialize cURL + $ch = curl_init($url); + + // Set cURL options + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); // Set the Content-Type header + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); // Set the JSON payload + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Optional: to bypass SSL verification if needed (not recommended for production) + + // Execute the cURL request and get the response + $response = curl_exec($ch); + + // Check for cURL errors + if (curl_errno($ch)) { + echo 'cURL Error: ' . curl_error($ch); + } + + // Close the cURL handle + curl_close($ch); + + // Decode the JSON response + $responseData = json_decode($response, true); + echo '
';
+ print_r($responseData);
+ echo '';
+ // Check if the response contains generated text
+ if (isset($responseData['candidates'][0]['content']['parts'][0]['text'])) {
+ $generatedText = $responseData['candidates'][0]['content']['parts'][0]['text'];
+ echo "Generated Text: " . $generatedText;
+ } else {
+ echo "Error or no text generated. Response: " . $response;
+ }
+
+ }
+
+
+ //for insurer policy doc upload
+ public function checkPolicyDoc()
+ {
+
+ // $this->convertToPdf();die();
+ // Replace with your actual Gemini API key
+ $apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8';
+
+ // The model to use and the API endpoint
+ $model = "gemini-pro";
+ $model = "gemini-2.5-flash";
+ // $model = "gemini-1.5-pro";
+ // $model = "gemini-1.5-pro";
+ $url = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key={$apiKey}";
+
+ $filePath = 'C:\Users\Venba\AppData\Local\Programs\Python\pyenv\pdfreader\bike-0904023124P114268957.pdf';
+ $filePath = 'C:\Users\Venba\AppData\Local\Programs\Python\pyenv\pdfreader\car-insurance-0904023124P114213011.pdf';
+
+ // Check if the file exists
+ if (!file_exists($filePath)) {
+ die("Error: File not found at {$filePath}");
+ }
+
+ // Get the file's MIME type using the finfo extension
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $mimeType = finfo_file($finfo, $filePath);
+ finfo_close($finfo);
+ // print_r($mimeType);die();
+ // Define supported inline MIME types
+ $supportedInlineMimeTypes = ['application/pdf','text/csv'];
+
+ // Read the file content and encode it to Base64
+ $fileContent = file_get_contents($filePath);
+ $base64Content = base64_encode($fileContent);
+ // The prompt you want to send to the model
+ // $prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations";
+ $prompt = "Read the following motor policy pdf document and convert into JSON format as sample specified. Give me only JSON,not any explanations.";
+ $prompt .= '"{\"policy\":{\"policy_number\":\"\",\"issue_date\":\"\",\"period\":{\"start\":\"\",\"end\":\"\"},\"insurer\":\"\",\"previous_policy_number\":\"\"},\"insured\":{\"name\":\"\",\"father_name\":\"\",\"address\":[\"\"],\"mobile\":\"\",\"id_proofs\":{\"aadhaar\":\"\",\"pan\":\"\"}},\"vehicle\":{\"reg_no\":\"\",\"engine_no\":\"\",\"chassis_no\":\"\",\"make\":\"\",\"model\":\"\",\"year\":\"\",\"cubic_capacity\":\"\",\"vehicle_type\":\"\"},\"rto\":\"\",\"premium\":{\"tp\":0,\"od\":0,\"pa_od\":0,\"taxes\":{},\"total\":0,\"in_words\":\"\"},\"endorsements\":[{\"code\":\"\",\"desc\":\"\"}]}"';
+
+ $payloadPart = null;
+
+ // The text part of the prompt
+ $text_part = [
+ "text" => $prompt
+ ];
+ // Conditionally handle the file upload based on MIME type
+ if (in_array($mimeType, $supportedInlineMimeTypes)) {
+ echo "Detected supported format inline MIME type ({$mimeType})";
+ // Handle PDF as inline data
+ $fileContent = file_get_contents($filePath);
+ $base64Content = base64_encode($fileContent);
+ $payloadPart = [
+ "inlineData" => [
+ "mimeType" => $mimeType,
+ "data" => $base64Content
+ ]
+ ];
+
+ $content_parts = [
+ "parts" => [
+ $text_part,
+ $payloadPart
+ ]
+ ];
+ } else {
+ // Handle Excel/CSV using the Files API
+ echo "Detected unsupported inline MIME type ({$mimeType}). Uploading via Files API...\n";
+ $fileInfo = $this->uploadFileToGemini($filePath, $apiKey); // Pass apiKey
+
+ print_r($fileInfo);
+ // The file part, using the URI from the Files API upload
+ $file_part = [
+ "fileData" => [
+ "fileUri" => $fileInfo['uri'],
+ "mimeType" => $fileInfo['mimeType']
+ ]
+ ];
+
+ // The full content array, containing both parts
+ $content_parts = [
+ "parts" => [
+ $text_part,
+ $file_part
+ ]
+ ];
+ }
+
+
+
+
+
// The final JSON payload
$data = [
"contents" => [
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 59608e7e..6aeb4b73 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -1024,14 +1024,7 @@ class LeadsController extends BaseController
// 3. Optimize lead data query with specific field selection
$lead_data = $this->leadsModel
->select('
- leads.id,
- leads.policy_type_id,
- leads.lead_type,
- leads.source_policy_id,
- leads.policy_end_date,
- leads.lead_form_type,
- leads.created_by,
- leads.client_name,
+ leads.*,
lead_files.status as demography_file_status,
policy_type.question_json,
policy_type.policy_type,
@@ -1776,6 +1769,24 @@ class LeadsController extends BaseController
// dd($rfq_data, $lead_id, $type, $propsal_and_insurer);
// print_r($propsal_and_insurer); die;
+ // print_r($is_placement); die;
+
+ $data = json_decode($rfq_data['json'], true);
+ $sheetName = 'Worksheet';
+ if ($type == 2) {
+ $sheetName = 'QCR';
+ // $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001";
+ $data = $this->convertJsonForQCR($data, $type);
+ if ($propsal_and_insurer !== null) {
+ list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
+ $data = $this->transformProposelData($data, $proposal_key, $insurer_key);
+ $is_placement = true;
+ $sheetName = 'Placement';
+ }
+ } else if ($type == 1) {
+ $sheetName = 'RFQ';
+ $data = $this->convertJsonForQCR($data, $type);
+ } // dd($data);
if ($rfq_data['lead_type'] == 1) {
@@ -1808,36 +1819,71 @@ class LeadsController extends BaseController
} else {
if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) {
- $lead_data = [
+ if($is_placement == true){
+ $lead_data = [
- 'Insured' => $rfq_data['client_name'],
- 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
+ 'Insured' => $rfq_data['client_name'],
+ 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
- // 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
- // 'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
- // 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
+ // 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
+ // 'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
+ // 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
- // 'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
- // 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
- // 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
+ // 'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
+ // 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
+ // 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
- 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
- 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
- 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
+ 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
+ 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
+ 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
- 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
- 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
- 'TPA' => $rfq_data['tpa_name'] ?? " - ",
+ 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
+ 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
+ 'TPA' => $rfq_data['tpa_name'] ?? " - ",
- // 'Policy Run Days' => $rfq_data['policy_run_days'],
- // 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
- // 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
- // 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
- // 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
- // 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
- // 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
- // 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
- ];
+ // 'Policy Run Days' => $rfq_data['policy_run_days'],
+ // 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
+ // 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
+ // 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
+ // 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
+ // 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
+ // 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
+ // 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
+ ];
+ }else{
+ $lead_data = [
+ 'Insured' => $rfq_data['client_name'],
+ 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
+
+ 'No of Employees at Inception' => $is_placement ? '-' : $rfq_data['incept_emp_count'],
+ 'No of Dependents at Inception' => $is_placement ? '-' : $rfq_data['incept_dept_count'],
+ 'Total Lives at Inception ' => $is_placement ? '-' : $rfq_data['incept_no_of_lives'],
+
+ 'No of Employees at Expiry' => $is_placement ? '-' : $rfq_data['exp_emp_count'],
+ 'No of Dependents at Expiry' => $is_placement ? '-' : $rfq_data['exp_dept_count'],
+ 'Total Lives at Expiry ' => $is_placement ? '-' : $rfq_data['exp_no_of_lives'],
+
+ 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
+ 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
+ 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
+
+ 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date'])
+ ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date']))
+ : "To be decided",
+
+ 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
+ 'TPA' => $rfq_data['tpa_name'] ?? " - ",
+
+ 'Policy Run Days' => $is_placement ? '-' : $rfq_data['policy_run_days'],
+ 'Inception Premium' => $is_placement ? '-' : formatIndianCurrency($rfq_data['premium_at_inception']),
+ 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => $is_placement ? '-' : formatIndianCurrency($rfq_data['premium_date']),
+ 'Earned Premium' => $is_placement ? '-' : formatIndianCurrency(intval($rfq_data['earned_premium'])),
+ 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => $is_placement ? '-' : formatIndianCurrency($rfq_data['incurred_claims']),
+ 'Annualised Claims' => $is_placement ? '-' : formatIndianCurrency(intval($rfq_data['annualised_claims'])),
+ 'Incurred Claims Ratio' => $is_placement ? '-' : $rfq_data['incurred_claims_ratio'] . " %",
+ 'Earned Claims Ratio' => $is_placement ? '-' : $rfq_data['earned_claims_ratio'] . " %",
+ ];
+ }
} else if (in_array($rfq_data['policy_type_id'], [1, 6, 7])) {
$lead_data = [
@@ -1857,27 +1903,8 @@ class LeadsController extends BaseController
];
}
}
+ // print_r($lead_data); die;
- $data = json_decode($rfq_data['json'], true);
- // dd($data);
-
- $sheetName = 'Worksheet';
- if ($type == 2) {
- $sheetName = 'QCR';
- // $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001";
- $data = $this->convertJsonForQCR($data, $type);
- if ($propsal_and_insurer !== null) {
- list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
- $data = $this->transformProposelData($data, $proposal_key, $insurer_key);
- $is_placement = true;
- $sheetName = 'Placement';
- }
- } else if ($type == 1) {
- $sheetName = 'RFQ';
- $data = $this->convertJsonForQCR($data, $type);
- // dd($data);
- }
- // dd($data);
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 9e4a5a08..58618abf 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1350,6 +1350,16 @@ class MasterController extends AdminController
// === INSERT ===
if (empty($id)) {
+ $cd_acc_count = $this->CDMasterModel->where('is_active', 1)
+ ->where('client_id', $data['client_id'])
+ ->where('insurer_id', $data['insurer_id'])
+ ->where('insurer_branch_id', $data['insurer_branch_id'])
+ ->countAllResults();
+
+ if($cd_acc_count > 0){
+ return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
+ }
+
$this->myLogger->logme("error", 'Performing INSERT operation.');
$insert = $this->CDMasterModel->insert($data);
$this->myLogger->logme("error", 'Insert result: ' . json_encode($insert));
@@ -1574,6 +1584,15 @@ class MasterController extends AdminController
$data['insurer_branch_id'] = $insurer_branch_id;
+ $cd_acc_count = $this->CDMasterModel->where('is_active', 1)
+ ->where('client_id', $data['client_id'])
+ ->where('insurer_id', $data['insurer_id'])
+ ->where('insurer_branch_id', $data['insurer_branch_id'])
+ ->countAllResults();
+
+ if($cd_acc_count > 0){
+ return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
+ }
// array with data for CD Traction table
$cd_tranction_data = [
@@ -1617,6 +1636,24 @@ class MasterController extends AdminController
}
}
+ public function checkDuplicateCdAccount()
+ {
+ $data = $this->request->getGet();
+
+ $cd_acc_count = $this->CDMasterModel
+ ->where('is_active', 1)
+ ->where('client_id', $data['client_id'])
+ ->where('insurer_id', $data['insurer_id'])
+ ->where('insurer_branch_id', $data['insurer_branch_id'])
+ ->countAllResults();
+
+ if($cd_acc_count > 0){
+ return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
+ }else{
+ return $this->respond(['status' => true], 200);
+ }
+ }
+
//Vehicle Master data Function
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 739a163f..bf508a48 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -1271,9 +1271,10 @@ class PolicyTransactionController extends BaseController
$data['tsi'] = generate_tsi_code($issue_type['issue_type'] ?? 1);
- $client_branch_id = $data['client_branch_id'];
- if ($data['client_branch_id'] == "") {
+ if (!isset($data['client_branch_id']) || $data['client_branch_id'] == "") {
$client_branch_id = $issue_type['client_branch_id'];
+ }else{
+ $client_branch_id = $data['client_branch_id'];
}
$data['is_cd_reduce_from_bds'] = (isset($issue_type['policy_type_id']) && $issue_type['policy_type_id'] > 7 && $data['client_type'] == 1) ? 1 : 0;
@@ -1431,7 +1432,11 @@ class PolicyTransactionController extends BaseController
$pt_id = null;
if(!empty($data)){
- $inception_data = $this->policyTransactionModel->where('policy_no', $data['policy_no'])->where('client_id', $data['client_id'])->first();
+ $inception_data = $this->policyTransactionModel
+ ->where('policy_no', $data['policy_no'])
+ ->where('client_id', $data['client_id'])
+ ->where('action_type', 'inception')
+ ->first();
$pt_id = $inception_data['id'];
}
@@ -2682,6 +2687,10 @@ class PolicyTransactionController extends BaseController
$gst = $gstTotal[$index];
$paymentDate = $paymentDates[$index];
+ if($utrNo == "" && $tds == "" && $gst == "" && $receivedAmount == "")
+ {
+ continue;
+ }
// Prepare data for insert/update
$childData = [
'inv_amt' => $receivedAmount,
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index f66229f5..86229e9d 100755
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -859,3 +859,10 @@ if (!function_exists('expected_amount_calc')) {
return round($expectedAmount, 2); // Optional: round to 2 decimal places
}
}
+
+if (!function_exists('getFileIfExists')) {
+ function getFileIfExists($path)
+ {
+ return file_exists(FCPATH . $path) ? base_url($path) : '';
+ }
+}
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index bea76e50..394de340 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -1532,8 +1532,15 @@ class EmployeePolicyModel extends Model
e.doj,
e.band,
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
- (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.' LIMIT 1) AS self,
-
+ (
+ SELECT name FROM employees
+ WHERE relationship = "Self"
+ and emp_code = ' . $this->db->escape($emp_code) . '
+ and client_id = '.$client_id.'
+ and is_active = 1
+ and emp_status = "active"
+ LIMIT 1
+ ) AS self,
ep.tpa_id,
ep.uhid,
diff --git a/app/Views/cd_master_add_modal.php b/app/Views/cd_master_add_modal.php
index c57936c5..9089d35f 100644
--- a/app/Views/cd_master_add_modal.php
+++ b/app/Views/cd_master_add_modal.php
@@ -46,7 +46,7 @@
-