Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
e1220f7283
@ -508,6 +508,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("saveInvoicePaymentDetails", "PolicyTransactionController::saveInvoicePaymentDetails");
|
||||
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
|
||||
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
|
||||
$routes->get("downloadInsurerStatement/(:num)", "PolicyTransactionController::downloadInsurerStatement/$1");
|
||||
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
|
||||
$routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth");
|
||||
$routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1");
|
||||
|
||||
@ -1068,7 +1068,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
'is_active' => 1,
|
||||
'created_by' => $file_info[0]['created_by'] ?? null,
|
||||
'action_flag_status' => $row['IsActive'] == 1 ? 'A' : 'D'
|
||||
'action_flag_status' => $row['IsActive'] == 1 ? 'A' : 'D',
|
||||
'si' => $row['BASE_SUMINSURED'],
|
||||
'doj' => change_date_format($row['DATE_OF_JOINING'],'Y-m-d\TH:i:s'),
|
||||
'endorsement_no' => $row['ENDORSEMENT_NO']
|
||||
|
||||
@ -571,6 +571,70 @@ class LeadsController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
// $leadFormType = (int) ($postData['lead_form_type'] ?? 1);
|
||||
// $postedPolicyTypeIds = array_map('intval', (array) ($postData['policy_type_id'] ?? []));
|
||||
// $isEbRenewalGpaClaimHistory = $leadFormType === 1
|
||||
// && (int) ($postData['lead_type'] ?? 0) === 2
|
||||
// && in_array(1, $postedPolicyTypeIds, true)
|
||||
// && (int) ($postData['claim_history'] ?? 0) === 1;
|
||||
|
||||
// if ($isEbRenewalGpaClaimHistory) {
|
||||
// $rules['first_year.*'] = [
|
||||
// 'rules' => 'required|regex_match[/^\d{4}-\d{4}$/]',
|
||||
// 'errors' => [
|
||||
// 'required' => 'Claim Year is required for all entries.',
|
||||
// 'regex_match' => 'Year must be in format YYYY-YYYY.',
|
||||
// ],
|
||||
// ];
|
||||
// $rules['emp_id.*'] = [
|
||||
// 'rules' => 'required',
|
||||
// 'errors' => ['required' => 'Employee ID is required in Claim History.'],
|
||||
// ];
|
||||
// $rules['emp_name.*'] = [
|
||||
// 'rules' => 'required',
|
||||
// 'errors' => ['required' => 'Employee Name is required in Claim History.'],
|
||||
// ];
|
||||
// $rules['gender.*'] = [
|
||||
// 'rules' => 'required|in_list[Female,Male]',
|
||||
// 'errors' => [
|
||||
// 'required' => 'Gender is required in Claim History.',
|
||||
// 'in_list' => 'Gender must be Female or Male.',
|
||||
// ],
|
||||
// ];
|
||||
// $rules['designation.*'] = [
|
||||
// 'rules' => 'required',
|
||||
// 'errors' => ['required' => 'Designation is required in Claim History.'],
|
||||
// ];
|
||||
// $rules['sum_insured.*'] = [
|
||||
// 'rules' => 'required|numeric',
|
||||
// 'errors' => [
|
||||
// 'required' => 'Sum Insured is required in Claim History.',
|
||||
// 'numeric' => 'Sum Insured must be a number.',
|
||||
// ],
|
||||
// ];
|
||||
// $rules['first_death_date.*'] = [
|
||||
// 'rules' => 'required|regex_match[/^[0-9]{2}-([0-9]{2}|[A-Za-z]{3})-[0-9]{4}$/]',
|
||||
// 'errors' => [
|
||||
// 'required' => 'Date of Death is required.',
|
||||
// 'regex_match' => 'Date of Death must be in DD-MM-YYYY or DD-MMM-YYYY format.',
|
||||
// ],
|
||||
// ];
|
||||
// $rules['first_cause_of_death.*'] = [
|
||||
// 'rules' => 'required|in_list[natural_death,suicide,accident,cardiac_arrest,septic_shock,heart_attack]',
|
||||
// 'errors' => [
|
||||
// 'required' => 'Nature/Cause Of Death is required.',
|
||||
// 'in_list' => 'Nature/Cause Of Death is invalid.',
|
||||
// ],
|
||||
// ];
|
||||
// $rules['first_claim_amount.*'] = [
|
||||
// 'rules' => 'required|numeric',
|
||||
// 'errors' => [
|
||||
// 'required' => 'Claim/Settled Amount is required.',
|
||||
// 'numeric' => 'Claim/Settled Amount must be a number.',
|
||||
// ],
|
||||
// ];
|
||||
// }
|
||||
|
||||
// 1. MANUALLY VALIDATE FILES BEFORE PROCESSING
|
||||
// $allFiles = $this->request->getFiles();
|
||||
// foreach ($allFiles as $inputName => $files) {
|
||||
@ -2140,6 +2204,8 @@ class LeadsController extends BaseController
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
||||
$claim_history = $rfq_data['claim_history'] ?? 0;
|
||||
|
||||
$is_placement = false;
|
||||
$length = 0;
|
||||
|
||||
@ -2176,7 +2242,7 @@ class LeadsController extends BaseController
|
||||
'No of Dependents' => $rfq_data['incept_dept_count'],
|
||||
'Total Lives' => $rfq_data['incept_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",
|
||||
// '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'],
|
||||
@ -2186,7 +2252,7 @@ class LeadsController extends BaseController
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
// 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
|
||||
'Policy Period' => ! 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",
|
||||
// 'Policy Period' => ! 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 Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
@ -2279,7 +2345,7 @@ class LeadsController extends BaseController
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal' => $rfq_data['total_si_at_renewal'],
|
||||
'Claims Experience for last 3 years' => "Mentioned in Claims sheet",
|
||||
'Claims Experience for last 3 years' => $claim_history == "1" ? "Mentioned in Claims sheet" : "Nil",
|
||||
// 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Total Lives at Inception' => $rfq_data['total_lives_at_incept'],
|
||||
@ -2796,7 +2862,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
//claim history new sheet;
|
||||
if (! empty($rfq_data['fin_years_claims'])) {
|
||||
if ($claim_history == 1 && !empty($rfq_data['fin_years_claims'])) {
|
||||
|
||||
$claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? [];
|
||||
|
||||
|
||||
@ -4236,7 +4236,7 @@ class PolicyTransactionController extends BaseController
|
||||
return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']);
|
||||
}
|
||||
|
||||
public function validateInsurerStatement($params)
|
||||
public function validateInsurerStatementOLD1($params)
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
|
||||
@ -4392,8 +4392,7 @@ class PolicyTransactionController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateInsurerStatement($params)
|
||||
public function updateInsurerStatementOLD($params)
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
//get file info
|
||||
@ -4559,6 +4558,375 @@ class PolicyTransactionController extends BaseController
|
||||
return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']);
|
||||
}
|
||||
|
||||
public function validateInsurerStatement($params)
|
||||
{
|
||||
/*
|
||||
* Changes made: 12-06-2024
|
||||
* - Added safe file_id handling and DB file record validation before using file details.
|
||||
* - Fixed physical file missing response and error message.
|
||||
* - Skips empty Excel rows and collects unique policy numbers from the uploaded statement.
|
||||
* - Fetches NHance source records only for those uploaded policy numbers.
|
||||
* - Sanitizes policy and endorsement numbers before comparison to avoid hidden-space mismatch.
|
||||
* - Validates each row by policy number + endorsement number combination.
|
||||
* - Detects duplicate policy + endorsement rows and returns row-wise validation errors.
|
||||
*/
|
||||
helper('excel_util_helper');
|
||||
|
||||
$file_id = $params['file_id'] ?? 0;
|
||||
|
||||
try {
|
||||
|
||||
$error_data = ['error_code' => '', 'error_data' => []];
|
||||
$status = 'success';
|
||||
$ret_status = true;
|
||||
|
||||
//get file info
|
||||
$file = $this->insurerStatements->find((int)$file_id);
|
||||
// dd($file);
|
||||
|
||||
if (empty($file)) {
|
||||
//file not found in DB
|
||||
$this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => 'statement file not found in DB'])])->update();
|
||||
return array('status' => false, 'error_code' => 0, 'error_data' => 'statement file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error', ($message . ' for statement file id ' . $file_id));
|
||||
$this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => $message])])->update();
|
||||
return array('status' => false, 'error_code' => 0, 'error_data' => $message); //0 - Physcial file not found
|
||||
}
|
||||
|
||||
//get excel data to php array
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRow = $sheet->getHighestRow();
|
||||
$highestColumn = $sheet->getHighestColumn();
|
||||
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestColumn . $highestRow);
|
||||
unset($excel_data[0]);
|
||||
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
|
||||
// dd($excel_data);
|
||||
|
||||
//get no of line items and update in DB
|
||||
$line_items = 0;
|
||||
|
||||
$policyNos = [];
|
||||
|
||||
foreach ($excel_data as $row) {
|
||||
if (check_row_is_empty_or_null($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// row[1] => second column (B column)
|
||||
$policyNo = $this->sanitizeStatementLookupValue($row[1] ?? '');
|
||||
|
||||
if ($policyNo !== '') {
|
||||
$policyNos[] = $policyNo;
|
||||
}
|
||||
}
|
||||
$policyNos = array_values(array_unique($policyNos));
|
||||
|
||||
// get uploaded month transactions data
|
||||
// $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id'], month: $file['month']);
|
||||
$source_data = !empty($policyNos) ? $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactionByPolicyAndEndorsement(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id'], policy_no: $policyNos) : [];
|
||||
// dd($source_data);
|
||||
|
||||
$source_lookup = [];
|
||||
$source_policy_lookup = [];
|
||||
$source_endorsement_lookup = [];
|
||||
|
||||
foreach ($source_data as $source_row) {
|
||||
$source_policy_no = $this->sanitizeStatementLookupValue($source_row['policy_no'] ?? '');
|
||||
$source_endorsement_no = $this->sanitizeStatementLookupValue($source_row['endorsement_no'] ?? '');
|
||||
$source_entry_key = $source_policy_no . '|' . $source_endorsement_no;
|
||||
|
||||
$source_lookup[$source_entry_key] = true;
|
||||
$source_policy_lookup[$source_policy_no] = true;
|
||||
$source_endorsement_lookup[$source_policy_no][$source_endorsement_no] = true;
|
||||
}
|
||||
|
||||
// check policy no,insurer and etc in DB for this month
|
||||
// if all good return true, otherwise return false with messssage
|
||||
$matched_entry = [];
|
||||
$error_messages = []; // row-wise error storage
|
||||
|
||||
foreach ($excel_data as $excel_key => $excel_row) {
|
||||
|
||||
$row_number = $excel_key;
|
||||
$is_row_empty = check_row_is_empty_or_null($excel_row);
|
||||
$policy_source_found = 0;
|
||||
$endorsement_source_found = 0;
|
||||
$duplicate_found = 0;
|
||||
|
||||
if (!$is_row_empty) {
|
||||
|
||||
$policy_no = $this->sanitizeStatementLookupValue($excel_row[1] ?? ''); //policy_number from excel
|
||||
$endorsement_no = $this->sanitizeStatementLookupValue($excel_row[2] ?? ''); //endorsement number from excel
|
||||
$entry_key = $policy_no . '|' . $endorsement_no;
|
||||
|
||||
if (isset($matched_entry[$entry_key])) {
|
||||
$duplicate_found = 1;
|
||||
} elseif (isset($source_lookup[$entry_key])) {
|
||||
$line_items = $line_items + 1;
|
||||
$matched_entry[$entry_key] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$policy_source_found = isset($source_policy_lookup[$policy_no]) ? 1 : 0;
|
||||
$endorsement_source_found = isset($source_endorsement_lookup[$policy_no][$endorsement_no]) ? 1 : 0;
|
||||
|
||||
// Policy number mismatch
|
||||
if ($policy_source_found == 0) {
|
||||
$error_messages[$row_number]['policy_no_mismatch'] =
|
||||
"Policy number <strong>({$policy_no}) </strong> not in NHance.";
|
||||
}
|
||||
|
||||
// Endorsement number mismatch
|
||||
if ($policy_source_found == 1 && $endorsement_source_found == 0) {
|
||||
$error_messages[$row_number]['endorsement_no_mismatch'] =
|
||||
"Endorsement number <strong>({$endorsement_no})</strong> not in NHance for policy <strong>({$policy_no})</strong>.";
|
||||
}
|
||||
|
||||
// Duplicate check
|
||||
if ($duplicate_found == 1) {
|
||||
$error_messages[$row_number]['duplicate'] =
|
||||
"Duplicate entry found. This policy and endorsement <strong>({$policy_no} | {$endorsement_no})</strong> combination has already been matched.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// print_rr($error_messages);die;
|
||||
|
||||
if (!empty($error_messages)) {
|
||||
$error_data['error_code'] = 2;
|
||||
$error_data['error_data'] = $error_messages;
|
||||
$status = 'failed';
|
||||
$ret_status = false;
|
||||
}
|
||||
|
||||
//update in DB
|
||||
$this->insurerStatements->where('id', $file_id)->set(['line_items' => $line_items, 'file_status' => $status, 'reason' => json_encode($error_data)])->update();
|
||||
return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']);
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
$errorData = [
|
||||
'message' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' => $th->getLine(),
|
||||
'code' => $th->getCode(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||
];
|
||||
|
||||
$this->myLogger->logme("error", "POLICY-TRANSACTION-CONTROLLER - validateInsurerStatement: Exception: " . json_encode($errorData ?? []));
|
||||
$this->insurerStatements->where('id', $file_id)->set(['line_items' => 0, 'file_status' => 'failed', 'reason' => json_encode($errorData)])->update();
|
||||
return array('status' => false, 'error_code' => [], 'error_data' => $errorData);
|
||||
}
|
||||
}
|
||||
|
||||
private function sanitizeStatementLookupValue($value): string
|
||||
{
|
||||
$value = trim((string)($value ?? ''));
|
||||
$value = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $value);
|
||||
return preg_replace('/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $value);
|
||||
}
|
||||
|
||||
public function updateInsurerStatement($params)
|
||||
{
|
||||
/*
|
||||
* Changes made: 12-06-2024
|
||||
* - Added safe file_id handling and DB file record validation before using file details.
|
||||
* - Fixed physical file missing response and error message.
|
||||
* - Skips empty Excel rows and collects unique policy numbers from the uploaded statement.
|
||||
* - Fetches NHance source records only for those uploaded policy numbers.
|
||||
* - Uses the same sanitized policy number + endorsement number matching as validation.
|
||||
* - Inserts statement details only for matched rows and skips empty or unmatched Excel rows.
|
||||
* - Added safe default handling for amount and reward columns before calculation/insert.
|
||||
*/
|
||||
helper('excel_util_helper');
|
||||
$file_id = $params['file_id'] ?? 0;
|
||||
|
||||
$error_data = ['error_code' => '', 'error_data' => []];
|
||||
$status = 'success';
|
||||
$ret_status = true;
|
||||
|
||||
//get file info
|
||||
$file = $this->insurerStatements->find((int)$file_id);
|
||||
// dd($file);
|
||||
|
||||
if (empty($file)) {
|
||||
//file not found in DB
|
||||
return array('status' => false, 'error_code' => 0, 'error_data' => 'statement file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error', ($message . ' for statement file id ' . $file_id));
|
||||
$this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => $message])])->update();
|
||||
return array('status' => false, 'error_code' => 0, 'error_data' => $message); //0 - Physcial file not found
|
||||
}
|
||||
|
||||
//get excel data to php array
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
// dd($highestRowAndColumn);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
unset($excel_data[0]);
|
||||
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
|
||||
// dd($excel_data);
|
||||
|
||||
$policyNos = [];
|
||||
|
||||
foreach ($excel_data as $row) {
|
||||
if (check_row_is_empty_or_null($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$policyNo = $this->sanitizeStatementLookupValue($row[1] ?? '');
|
||||
|
||||
if ($policyNo !== '') {
|
||||
$policyNos[] = $policyNo;
|
||||
}
|
||||
}
|
||||
$policyNos = array_values(array_unique($policyNos));
|
||||
|
||||
// get uploaded month transactions data
|
||||
// $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id'], month: $file['month']);
|
||||
$source_data = !empty($policyNos) ? $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactionByPolicyAndEndorsement(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id'], policy_no: $policyNos) : [];
|
||||
// Kint::dump($source_data);//die;
|
||||
// Kint::dump($excel_data);
|
||||
// die;
|
||||
$source_lookup = [];
|
||||
|
||||
foreach ($source_data as $source_row) {
|
||||
$source_policy_no = $this->sanitizeStatementLookupValue($source_row['policy_no'] ?? '');
|
||||
$source_endorsement_no = $this->sanitizeStatementLookupValue($source_row['endorsement_no'] ?? '');
|
||||
$source_lookup[$source_policy_no . '|' . $source_endorsement_no][] = $source_row;
|
||||
}
|
||||
|
||||
// check policy no,insurer and etc in DB for this month
|
||||
// if all good return true, otherwise return false with messssage
|
||||
$data_to_update = [];
|
||||
try {
|
||||
foreach ($excel_data as $excel_row) {
|
||||
if (check_row_is_empty_or_null($excel_row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||
// $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||
$policy_no = $this->sanitizeStatementLookupValue($excel_row[1] ?? ''); //policy_number from excel
|
||||
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||
$endorsement_no = $this->sanitizeStatementLookupValue($excel_row[2] ?? ''); //endorsement number from excel
|
||||
$entry_key = $policy_no . '|' . $endorsement_no;
|
||||
|
||||
if (empty($source_lookup[$entry_key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$source_row = array_shift($source_lookup[$entry_key]);
|
||||
|
||||
//calculate percentage first
|
||||
$total_amt = 0;
|
||||
|
||||
// $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file
|
||||
$actual_bp_per = 0; //set default value 0 for maintaining existing code flow
|
||||
$actual_bp_brokerage = (int) trim((string)($excel_row[5] ?? 0));
|
||||
$actual_bp_amt = (int) trim((string)($excel_row[3] ?? 0));
|
||||
|
||||
if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
|
||||
$total_amt += $actual_bp_brokerage;
|
||||
//percentage reverse calculation
|
||||
if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) {
|
||||
$actual_bp_per = (int) round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2);
|
||||
}
|
||||
} else {
|
||||
$actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
|
||||
$total_amt += $actual_bp_brokerage;
|
||||
}
|
||||
|
||||
// $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file
|
||||
$actual_tp_per = 0;//set default value 0 for maintaining existing code flow
|
||||
$actual_tp_brokerage = (int) trim((string)($excel_row[6] ?? 0));
|
||||
$actual_tp_amt = (int) trim((string)($excel_row[4] ?? 0));
|
||||
|
||||
if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
|
||||
$total_amt += $actual_tp_brokerage;
|
||||
//percentage reverse calculation
|
||||
if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) {
|
||||
$actual_tp_per = (int) round(($actual_tp_brokerage / $actual_tp_amt) * 100, 2);
|
||||
}
|
||||
} else {
|
||||
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
|
||||
$total_amt += $actual_tp_brokerage;
|
||||
}
|
||||
|
||||
// $actual_tep_per = trim($excel_row[11]);
|
||||
// $actual_tep_brokerage = trim($excel_row[14]);
|
||||
// $actual_tep_amt = trim($excel_row[8]);
|
||||
|
||||
$actual_tep_per = 0;
|
||||
$actual_tep_brokerage = 0;
|
||||
$actual_tep_amt = 0;
|
||||
|
||||
if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
|
||||
$total_amt += $actual_tep_brokerage;
|
||||
//percentage reverse calculation
|
||||
if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) {
|
||||
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
|
||||
}
|
||||
} else {
|
||||
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
|
||||
$total_amt += $actual_tep_brokerage;
|
||||
}
|
||||
|
||||
//find variance
|
||||
$variance_amt = $source_row['exp_amt'] - $total_amt;
|
||||
|
||||
$data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim((string)($excel_row[7] ?? '')), 'statement_id' => $file_id];
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString());
|
||||
$errorData = [
|
||||
'message' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' => $th->getLine(),
|
||||
'code' => $th->getCode(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||
];
|
||||
return ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData];
|
||||
}
|
||||
// dd($data_to_update);
|
||||
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
|
||||
// dd($data_to_update);
|
||||
// if($error_data['error_code'])
|
||||
// {
|
||||
// $status = 'failed';
|
||||
// $ret_status = false;
|
||||
// }
|
||||
//update in DB
|
||||
$this->insurerStatements->where('id', $file_id)->set(['file_status' => $status, 'reason' => json_encode($error_data), 'invoice_status' => 'pending'])->update();
|
||||
return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']);
|
||||
}
|
||||
|
||||
public function getInvoicePaymentDetails()
|
||||
{
|
||||
$statement_id = $this->request->getUri()->getSegment(4);
|
||||
|
||||
@ -141,14 +141,8 @@ if (! function_exists('merge_ticket_pdfs')) {
|
||||
$src = $sourceFile['path'];
|
||||
try {
|
||||
if ($sourceFile['mime'] === 'application/pdf') {
|
||||
$pageCount = $mpdf->setSourceFile($src);
|
||||
for ($p = 1; $p <= $pageCount; $p++) {
|
||||
$tplId = $mpdf->importPage($p);
|
||||
$mpdf->AddPage();
|
||||
// adjustPageSize=true makes the output page match the imported page.
|
||||
$mpdf->useTemplate($tplId, 0, 0, null, null, true);
|
||||
$totalPages++;
|
||||
}
|
||||
$pageCount = merge_ticket_pdf_add_pdf_pages($mpdf, $src, $tempDir);
|
||||
$totalPages += $pageCount;
|
||||
log_message('error', "merge_ticket_pdfs | added PDF | file={$src} | pages={$pageCount}");
|
||||
} elseif (in_array($sourceFile['mime'], ['image/jpeg', 'image/png'], true)) {
|
||||
if (merge_ticket_pdf_add_image_page($mpdf, $src)) {
|
||||
@ -226,6 +220,81 @@ if (! function_exists('merge_ticket_pdfs')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('merge_ticket_pdf_add_pdf_pages')) {
|
||||
/**
|
||||
* Import PDF pages. If FPDI cannot import the source (commonly encrypted
|
||||
* PDFs), normalize through Ghostscript and retry.
|
||||
*/
|
||||
function merge_ticket_pdf_add_pdf_pages(Mpdf $mpdf, string $pdfPath, string $tempDir): int
|
||||
{
|
||||
try {
|
||||
return merge_ticket_pdf_import_pdf_pages($mpdf, $pdfPath);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', "merge_ticket_pdfs | direct PDF import failed | file={$pdfPath} | " . $e->getMessage());
|
||||
|
||||
$normalizedPath = merge_ticket_pdf_normalize_with_ghostscript($pdfPath, $tempDir);
|
||||
if ($normalizedPath === null) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try {
|
||||
$pageCount = merge_ticket_pdf_import_pdf_pages($mpdf, $normalizedPath);
|
||||
log_message('error', "merge_ticket_pdfs | Ghostscript normalized PDF imported | original={$pdfPath} | normalized={$normalizedPath} | pages={$pageCount}");
|
||||
@unlink($normalizedPath);
|
||||
return $pageCount;
|
||||
} catch (\Throwable $normalizedError) {
|
||||
@unlink($normalizedPath);
|
||||
throw $normalizedError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('merge_ticket_pdf_import_pdf_pages')) {
|
||||
function merge_ticket_pdf_import_pdf_pages(Mpdf $mpdf, string $pdfPath): int
|
||||
{
|
||||
$pageCount = $mpdf->setSourceFile($pdfPath);
|
||||
for ($p = 1; $p <= $pageCount; $p++) {
|
||||
$tplId = $mpdf->importPage($p);
|
||||
$mpdf->AddPage();
|
||||
// adjustPageSize=true makes the output page match the imported page.
|
||||
$mpdf->useTemplate($tplId, 0, 0, null, null, true);
|
||||
}
|
||||
|
||||
return $pageCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('merge_ticket_pdf_normalize_with_ghostscript')) {
|
||||
function merge_ticket_pdf_normalize_with_ghostscript(string $pdfPath, string $tempDir): ?string
|
||||
{
|
||||
$ghostscript = is_executable('/usr/bin/gs') ? '/usr/bin/gs' : trim((string) @shell_exec('command -v gs 2>/dev/null'));
|
||||
if ($ghostscript === '' || ! is_executable($ghostscript)) {
|
||||
log_message('error', "merge_ticket_pdfs | Ghostscript not available for PDF normalization | file={$pdfPath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
$normalizedPath = rtrim($tempDir, '/\\') . DIRECTORY_SEPARATOR . 'normalized_' . uniqid('', true) . '.pdf';
|
||||
$cmd = escapeshellarg($ghostscript)
|
||||
. ' -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.4'
|
||||
. ' -sOutputFile=' . escapeshellarg($normalizedPath)
|
||||
. ' ' . escapeshellarg($pdfPath)
|
||||
. ' 2>&1';
|
||||
|
||||
$output = [];
|
||||
$exitCode = 1;
|
||||
@exec($cmd, $output, $exitCode);
|
||||
|
||||
if ($exitCode !== 0 || ! is_file($normalizedPath) || filesize($normalizedPath) <= 0) {
|
||||
log_message('error', 'merge_ticket_pdfs | Ghostscript normalization failed | file=' . $pdfPath . ' | exit=' . $exitCode . ' | output=' . implode(' ', $output));
|
||||
@unlink($normalizedPath);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $normalizedPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('merge_ticket_pdf_resolve_mime')) {
|
||||
/**
|
||||
* Resolve file type from stored MIME, filesystem MIME, and extension.
|
||||
|
||||
@ -121,5 +121,41 @@ class PTCOShareDetailsModel extends Model
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function getNonReconcileredPolicyTransactionByPolicyAndEndorsement(string $insurer_id, string $insurer_branch_id, array $policy_no)
|
||||
{
|
||||
$builder = $this->db->table('pt_co_share_details pt_co')
|
||||
->select("
|
||||
pt_co.id,
|
||||
pt_co.pt_id,
|
||||
pt_co.exp_amt,
|
||||
pt.id AS policy_transaction_id,
|
||||
pt.endorsement_no,
|
||||
c.client_name,
|
||||
pt.created_at,
|
||||
pt_co.insurer_id,
|
||||
pt_co.insurer_branch_id,
|
||||
pt.policy_no,
|
||||
pt.policy_issue_date,
|
||||
pt.policy_start_date,
|
||||
pt.policy_end_date,
|
||||
pt.status,
|
||||
pt_co.bp_amt,
|
||||
pt_co.tp_amt,
|
||||
pt_co.tep_amt,
|
||||
pt_co.exp_amt,
|
||||
pt_co.statement_id
|
||||
")
|
||||
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
|
||||
->join('clients c', 'pt.client_id = c.id')
|
||||
->where('pt_co.is_active', 1)
|
||||
->where('pt.is_active', 1)
|
||||
->where('pt_co.insurer_id', $insurer_id)
|
||||
->where('pt_co.insurer_branch_id', $insurer_branch_id)
|
||||
->whereIn('pt.policy_no', $policy_no);
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -302,7 +302,15 @@ $isl_col_width_px = nhance_dt_column_widths_px($isl_header_labels, $isl_col_max_
|
||||
<td><?php echo $row['short_name'] . '-' . $row['branch_code']; ?></td>
|
||||
<td><?php echo change_date_format($row['month'], 'Y-m-d', 'M-Y'); ?></td>
|
||||
<td><?php echo $row['stmt_sno'] ?> </td>
|
||||
<td><?php echo $row['file_name'] ?> </td>
|
||||
<td>
|
||||
<?php if (!empty($row['file_name'])) { ?>
|
||||
<a href="<?php echo base_url('policy_tranction/statement/downloadInsurerStatement/' . $row['id']); ?>" class="text-primary" title="Download <?php echo esc($row['file_name']); ?>">
|
||||
<?php echo esc($row['file_name']); ?>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
-
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td><?php echo $row['line_items'] ?></td>
|
||||
<td><?php echo $row['file_status'];
|
||||
if ($row['file_status'] == 'failed') {
|
||||
|
||||
@ -220,7 +220,7 @@
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h4 class="card-title mb-0">Client Information</h4>
|
||||
<div class="form-group freshFields mb-0 d-flex align-items-center">
|
||||
<div class="form-group freshFields existing-client-toggle mb-0 d-flex align-items-center">
|
||||
<label for="exixting_client" class="mb-0 mr-2">Existing Client</label>
|
||||
<label class="switch mb-0">
|
||||
<input id="exixting_client" type="checkbox" name="exixting_client">
|
||||
@ -761,7 +761,7 @@
|
||||
|
||||
}
|
||||
|
||||
leadTypeBsedHideAndShow(lead_type)
|
||||
leadTypeBsedHideAndShow(lead_type, false, policy_type_id)
|
||||
|
||||
|
||||
if (lead_type == 1) {
|
||||
@ -868,6 +868,7 @@
|
||||
.contact_person_email);
|
||||
$('#policy_type_id_1').val(res.data.policy_type_id)
|
||||
.select2();
|
||||
togglePolicyDateFields(lead_type, res.data.policy_type_id);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000)
|
||||
@ -1110,6 +1111,7 @@
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
console.log("lead_type", lead_type);
|
||||
togglePolicyDateFields(lead_type);
|
||||
|
||||
let url = '<?= base_url('util/getPolicyTypeFields/') ?>';
|
||||
|
||||
@ -1298,7 +1300,7 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-4 policy-date-field">
|
||||
<label for="policy_start_date">Date of Commencement <span class="text-danger">*</span></label>
|
||||
<div class="input-icon">
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" onchange="calculatePolicyMetrics(this)" autocomplete="off" >
|
||||
@ -1307,7 +1309,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-4 policy-date-field">
|
||||
<label for="policy_end_date">Date of Expiry <span class="text-danger">*</span></label>
|
||||
<div class="input-icon">
|
||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE" autocomplete="off">
|
||||
@ -1793,6 +1795,8 @@
|
||||
const finyearJsonString = gatherClaimExperienceData(policy_type_ids);
|
||||
console.log('finyearJsonString', finyearJsonString);
|
||||
formData.append('finyear', finyearJsonString);
|
||||
let claimHistoryStatus = $("#claim_history").length > 0 && $("#claim_history").prop("checked") ? 1 : 0;
|
||||
formData.set('claim_history', claimHistoryStatus);
|
||||
|
||||
$.ajax({
|
||||
data: formData,
|
||||
@ -1915,6 +1919,7 @@
|
||||
$('#policy_start_date').val("");
|
||||
$('#policy_end_date').val("");
|
||||
$("#appendArea_1").empty();
|
||||
togglePolicyDateFields(value);
|
||||
|
||||
// $('#source_policy_start_date').val("");
|
||||
// $('#source_policy_end_date').val("");
|
||||
@ -2038,6 +2043,12 @@
|
||||
|
||||
let claimData = [];
|
||||
|
||||
if ($("#claim_history").length > 0 && !$("#claim_history").prop("checked")) {
|
||||
return JSON.stringify({
|
||||
"finyear": claimData
|
||||
});
|
||||
}
|
||||
|
||||
$(".claim-row").each(function() {
|
||||
|
||||
let year = $(this).find("[name='first_year[]']").val();
|
||||
@ -2175,15 +2186,23 @@
|
||||
let policy_type_id = $('#policy_type_id_' + count).val()
|
||||
console.log('policy_type_id', policy_type_id);
|
||||
|
||||
let lead_type = $('#lead_type').val();
|
||||
let showClaimHistorySwitch = lead_type == 2 && policy_type_id == 1;
|
||||
|
||||
console.log('claimIndex from parent', claimIndex);
|
||||
let increment = claimIndex;
|
||||
|
||||
let claimsFields = `
|
||||
let claimsFields = `${showClaimHistorySwitch && !document.querySelector('#claim_history') ? `<div class="custom-control custom-switch">
|
||||
<input type="checkbox" onchange="claimHistoryToggle()" class="custom-control-input" id="claim_history" name="claim_history" checked>
|
||||
<label class="custom-control-label" for="claim_history">Claims History</label>
|
||||
</div><br>` : ``}`;
|
||||
|
||||
claimsFields += `
|
||||
<div class="row claim-row">
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
|
||||
<select class="form-control first_year_" id="first_year_${increment}" name="first_year[]">
|
||||
<select class="form-control first_year_ claim-input" id="first_year_${increment}" name="first_year[]">
|
||||
<option value="">Select Year</option>
|
||||
<?php foreach ($lastFiveYears as $year) {
|
||||
echo "<option value='$year'>$year</option>";
|
||||
@ -2193,18 +2212,18 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_id_${increment}">Emp ID<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="emp_id_${increment}" name="emp_id[]">
|
||||
<input type="text" class="form-control claim-input" id="emp_id_${increment}" name="emp_id[]">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_name_${increment}">Employee Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="emp_name_${increment}" name="emp_name[]">
|
||||
<input type="text" class="form-control claim-input" id="emp_name_${increment}" name="emp_name[]">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="gender_${increment}">Gender<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="gender_${increment}" name="gender[]">
|
||||
<select class="form-control claim-input" id="gender_${increment}" name="gender[]">
|
||||
<option value="">Select Gender</option>
|
||||
<option value="Female">Female</option>
|
||||
<option value="Male">Male</option>
|
||||
@ -2213,25 +2232,25 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="designation_${increment}">Designation <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="designation_${increment}" name="designation[]">
|
||||
<input type="text" class="form-control claim-input" id="designation_${increment}" name="designation[]">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="sum_insured_${increment}">Sum Insured <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="sum_insured_${increment}" name="sum_insured[]">
|
||||
<input type="text" class="form-control claim-input" id="sum_insured_${increment}" name="sum_insured[]">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
|
||||
<div class="input-icon">
|
||||
<input type="text" class="form-control death_date flatpickr-date" id="first_death_date_${increment}" name="first_death_date[]" autocomplete="off">
|
||||
<input type="text" class="form-control death_date flatpickr-date claim-input" id="first_death_date_${increment}" name="first_death_date[]" autocomplete="off">
|
||||
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_cause_of_death_${increment}">Nature/Cause Of Death <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="first_cause_of_death_${increment}" name="first_cause_of_death[]">
|
||||
<select class="form-control claim-input" id="first_cause_of_death_${increment}" name="first_cause_of_death[]">
|
||||
<option value="">Select Cause of Death</option>
|
||||
<?php foreach ($causeOfDeath as $cause => $death_value) {
|
||||
echo "<option value='$cause'>$death_value</option>";
|
||||
@ -2241,7 +2260,7 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_amount_${increment}">Claim/Settled Amount<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
|
||||
<input type="text" class="form-control claim-input" id="first_claim_amount_${increment}" name="first_claim_amount[]">
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-2">
|
||||
@ -2302,6 +2321,10 @@
|
||||
maxDate: 'today', // Optional: disable future dates
|
||||
});
|
||||
|
||||
if (showClaimHistorySwitch) {
|
||||
claimHistoryToggle();
|
||||
}
|
||||
|
||||
toggleRequiredFields();
|
||||
restoreActualLeadGstNumber();
|
||||
restoreActualLeadContactDetails();
|
||||
@ -2318,7 +2341,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
function leadTypeBsedHideAndShow(value, resetValues = false) {
|
||||
function claimHistoryToggle() {
|
||||
let claimHistoryStatus = $("#claim_history").prop("checked") ? 1 : 0;
|
||||
|
||||
if (claimHistoryStatus == 1) {
|
||||
$(".claim-row").show();
|
||||
$(".claim-input").attr("required", true);
|
||||
} else {
|
||||
$(".claim-row").hide();
|
||||
$(".claim-input").removeAttr("required").val("");
|
||||
$(".claim-input").each(function() {
|
||||
if ($(this).hasClass('select2-hidden-accessible')) {
|
||||
$(this).val(null).trigger('change');
|
||||
}
|
||||
if ($(this).parsley) {
|
||||
$(this).parsley().reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleRequiredFields();
|
||||
}
|
||||
|
||||
function togglePolicyDateFields(value, fallbackPolicyTypeId = null) {
|
||||
const policyTypesToHide = ['1', '2', '3', '4', '5', '6', '7'];
|
||||
|
||||
$('.dynamic-form-row').each(function(index) {
|
||||
const selectedPolicyTypeId = $(this).find('[id^="policy_type_id_"]').val();
|
||||
const policyTypeId = String(selectedPolicyTypeId || (index === 0 ? fallbackPolicyTypeId || '' : ''));
|
||||
const shouldHide = value == 1 && policyTypesToHide.includes(policyTypeId);
|
||||
|
||||
$(this).find('.policy-date-field').toggle(!shouldHide);
|
||||
});
|
||||
}
|
||||
|
||||
function leadTypeBsedHideAndShow(value, resetValues = false, fallbackPolicyTypeId = null) {
|
||||
|
||||
togglePolicyDateFields(value, fallbackPolicyTypeId);
|
||||
if (value == 2) {
|
||||
$('.existing-client-toggle').removeClass('d-flex').addClass('d-none');
|
||||
} else {
|
||||
$('.existing-client-toggle').removeClass('d-none').addClass('d-flex');
|
||||
}
|
||||
|
||||
if (value == 1) {
|
||||
$('.btnDiv').show();
|
||||
|
||||
@ -837,7 +837,10 @@ if (isset($selected_lead_type)) {
|
||||
$('#appendAreaForClaim').attr('id', newId);
|
||||
}
|
||||
|
||||
leadTypeBsedHideAndShow(lead_type);
|
||||
leadTypeBsedHideAndShow(lead_type, false, policy_type_id);
|
||||
if ($('#claim_history').length && typeof claimHistoryToggle === 'function') {
|
||||
claimHistoryToggle();
|
||||
}
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
@ -935,6 +938,10 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($('#claim_history').length && typeof claimHistoryToggle === 'function') {
|
||||
claimHistoryToggle();
|
||||
}
|
||||
|
||||
if(lead_type == 3){
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
|
||||
@ -1324,6 +1331,7 @@ if (isset($selected_lead_type)) {
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
togglePolicyDateFields(lead_type, data.policy_type_id || '');
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
@ -41,10 +41,23 @@
|
||||
<hr>
|
||||
|
||||
<?php if(isset($lead_edit_data)) { ?>
|
||||
<?php
|
||||
$savedClaims = !empty($lead_edit_data['fin_years_claims_array']) ? $lead_edit_data['fin_years_claims_array'] : [];
|
||||
$isClaimHistoryChecked = (isset($lead_edit_data['claim_history']) && (int) $lead_edit_data['claim_history'] === 1) || !empty($savedClaims);
|
||||
$showClaimHistorySwitch = isset($lead_edit_data['lead_type'], $lead_edit_data['policy_type_id'])
|
||||
&& (int) $lead_edit_data['lead_type'] === 2
|
||||
&& (int) $lead_edit_data['policy_type_id'] === 1;
|
||||
?>
|
||||
<?php if ($showClaimHistorySwitch) { ?>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" onchange="claimHistoryToggle()" class="custom-control-input" id="claim_history" name="claim_history" <?= $isClaimHistoryChecked ? 'checked' : '' ?>>
|
||||
<label class="custom-control-label" for="claim_history">Claims History</label>
|
||||
</div><br>
|
||||
<?php } ?>
|
||||
<div class="form-row" id="appendAreaForClaim_1">
|
||||
<?php
|
||||
|
||||
$claims = !empty($lead_edit_data['fin_years_claims_array']) ? $lead_edit_data['fin_years_claims_array'] : [ ['year' => '', 'claim_amount' => '', 'status' => '', 'claim_type' => '', 'cause_of_death' => '', 'death_date' => ''] ];
|
||||
$claims = !empty($savedClaims) ? $savedClaims : [ ['year' => '', 'claim_amount' => '', 'status' => '', 'claim_type' => '', 'cause_of_death' => '', 'death_date' => ''] ];
|
||||
|
||||
foreach ($claims as $key => $value) { ?>
|
||||
|
||||
@ -52,7 +65,7 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_year">Year<span class="text-danger">*</span></label>
|
||||
<select class="form-control first_year_" id="first_year" name="first_year[]">
|
||||
<select class="form-control first_year_ claim-input" id="first_year" name="first_year[]">
|
||||
<option value="">Select Year</option>
|
||||
<?php foreach ($lastFiveYears as $year) {
|
||||
$selected = ($year == $value['year']) ? 'selected' : '';
|
||||
@ -63,17 +76,17 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_id">Emp ID<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="emp_id" name="emp_id[]" value="<?= htmlspecialchars(isset($value['emp_id']) ? $value['emp_id'] : '-' ) ?>">
|
||||
<input type="text" class="form-control claim-input" id="emp_id" name="emp_id[]" value="<?= htmlspecialchars(isset($value['emp_id']) ? $value['emp_id'] : '-' ) ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_name">Employee Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="emp_name" name="emp_name[]" value="<?= htmlspecialchars(isset($value['emp_name']) ? $value['emp_name'] : '-' ) ?>">
|
||||
<input type="text" class="form-control claim-input" id="emp_name" name="emp_name[]" value="<?= htmlspecialchars(isset($value['emp_name']) ? $value['emp_name'] : '-' ) ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="gender">Gender<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="gender" name="gender[]">
|
||||
<select class="form-control claim-input" id="gender" name="gender[]">
|
||||
<option value="">Select Gender</option>
|
||||
<option value="Female" <?= (isset($value['gender']) && $value['gender'] == 'Female') ? 'selected' : '' ?>>Female</option>
|
||||
<option value="Male" <?= (isset($value['gender']) && $value['gender'] == 'Male') ? 'selected' : '' ?>>Male</option>
|
||||
@ -83,22 +96,22 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="designation">Designation <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="designation" name="designation[]" value="<?= htmlspecialchars(isset($value['designation']) ? $value['designation'] : '-' ) ?>">
|
||||
<input type="text" class="form-control claim-input" id="designation" name="designation[]" value="<?= htmlspecialchars(isset($value['designation']) ? $value['designation'] : '-' ) ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="sum_insured">Sum Insured <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="sum_insured" name="sum_insured[]" value="<?= htmlspecialchars(isset($value['sum_insured']) ? $value['sum_insured'] : '-' ) ?>">
|
||||
<input type="text" class="form-control claim-input" id="sum_insured" name="sum_insured[]" value="<?= htmlspecialchars(isset($value['sum_insured']) ? $value['sum_insured'] : '-' ) ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_death_date">Date of Death<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control flatpickr-date" id="first_death_date" name="first_death_date[]" value="<?= htmlspecialchars($value['death_date']) ?>" autocomplete="off">
|
||||
<input type="text" class="form-control flatpickr-date claim-input" id="first_death_date" name="first_death_date[]" value="<?= htmlspecialchars($value['death_date']) ?>" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_cause_of_death">Nature/Cause Of Death <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="first_cause_of_death" name="first_cause_of_death[]">
|
||||
<select class="form-control claim-input" id="first_cause_of_death" name="first_cause_of_death[]">
|
||||
<option value="">Select Cause of Death</option>
|
||||
<?php foreach ($causeOfDeath as $cause => $death_value) {
|
||||
$selected = ($cause == $value['cause_of_death']) ? 'selected' : '';
|
||||
@ -109,7 +122,7 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_amount">Claim/Settled Amount<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_claim_amount" name="first_claim_amount[]" value="<?= htmlspecialchars(isset($value['claim_amount']) ? $value['claim_amount'] : ( isset($value['settled']) ? $value['settled'] : '-' )) ?>">
|
||||
<input type="text" class="form-control claim-input" id="first_claim_amount" name="first_claim_amount[]" value="<?= htmlspecialchars(isset($value['claim_amount']) ? $value['claim_amount'] : ( isset($value['settled']) ? $value['settled'] : '-' )) ?>">
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-2">
|
||||
|
||||
@ -884,13 +884,13 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_start_date">Policy Start Date</label>
|
||||
<input type="text" class="form-control" id="policy_start_date" name="policy_start_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_start_date']) ? date('d-m-Y', strtotime($lead_data['policy_start_date'])) : "" ?>">
|
||||
<label for="policy_start_date">Policy Start Date <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="policy_start_date" name="policy_start_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_start_date']) ? date('d-m-Y', strtotime($lead_data['policy_start_date'])) : "" ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_end_date">Policy End Date</label>
|
||||
<input type="text" class="form-control" id="policy_end_date" name="policy_end_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_end_date']) ? date('d-m-Y', strtotime($lead_data['policy_end_date'])) : "" ?>">
|
||||
<label for="policy_end_date">Policy End Date <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="policy_end_date" name="policy_end_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_end_date']) ? date('d-m-Y', strtotime($lead_data['policy_end_date'])) : "" ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -4429,6 +4429,18 @@ function constructURL_ForPlacementMailSend(return_type = false) {
|
||||
let acm_pk = $('#acm_id option:selected').data('id');
|
||||
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
|
||||
|
||||
if (!policy_start_date) {
|
||||
toastr.warning('Policy Start Date is required.', 'Warning');
|
||||
$('#policy_start_date').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!policy_end_date) {
|
||||
toastr.warning('Policy End Date is required.', 'Warning');
|
||||
$('#policy_end_date').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process `to` field
|
||||
to = to.split(',').map(email => email.trim());
|
||||
// cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
||||
@ -7552,6 +7564,9 @@ function appendMultiFileData(data) {
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = constructURL_ForPlacementMailSend(true);
|
||||
if (requestData === false) {
|
||||
return false;
|
||||
}
|
||||
console.log('requestData', requestData);
|
||||
|
||||
// Show loader
|
||||
|
||||
Loading…
Reference in New Issue
Block a user