Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
31820a8905
@ -309,6 +309,11 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("update_emp_data", "EmployeeController::update_emp_data");
|
||||
$routes->get("checkDeletionGetDataFunction", "EmployeeController::checkDeletionGetDataFunction");
|
||||
$routes->get("download_import_excel/(:any)", "EmployeeController::downloadSampleImportExcelFile/$1");
|
||||
$routes->get("getInsurerBranchContacts/(:any)", "LeadsController::getInsurerBranchContacts/$1");
|
||||
$routes->get("download_import_file/(:any)", "EmployeeController::download_import_file/$1");
|
||||
$routes->get('log_list', 'EmployeeController::listLogs');
|
||||
$routes->get('view_log/(:any)', 'EmployeeController::viewLog/$1');
|
||||
$routes->get('download_log/(:any)', 'EmployeeController::downloadLog/$1');
|
||||
});
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -355,6 +360,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
|
||||
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
|
||||
});
|
||||
|
||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -287,7 +287,7 @@ class ClientController extends AdminController
|
||||
$headerData['page_name'] = 'Client List';
|
||||
$data['clientList'] = $this->clientModel->getCreatedByUserName();
|
||||
$data['client_rm'] = $this->clientRMModel->getAllClientRM();
|
||||
// $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
|
||||
$data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
|
||||
|
||||
// dd($data);
|
||||
|
||||
@ -553,6 +553,7 @@ class ClientController extends AdminController
|
||||
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
||||
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
||||
$editData['client_branch']['role'] = get_role_id();
|
||||
$editData['lead_data'] = $this->leadsModel->getLeadForInsertClientList(2, $id);
|
||||
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
|
||||
|
||||
foreach ($clientPoliceData as $key => $value) {
|
||||
|
||||
@ -3976,22 +3976,75 @@ class EmpDataServiceController extends BaseController
|
||||
// print_r($arrayData);
|
||||
if (!empty($arrayData)) {
|
||||
|
||||
// dd($arrayData);
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($arrayData); die;
|
||||
|
||||
$client_branch_data = $this->clientBranchModel->where('id', $arrayData['client_branch_id'])->first();
|
||||
$units = json_decode($client_branch_data['units']);
|
||||
|
||||
// dd($client_branch_data, $units);
|
||||
|
||||
$get_insurer_id_from_client_policy = db_connect()->table('client_policy')
|
||||
->select('insurer_id')
|
||||
->where('id', $arrayData['client_policy_id'])
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
// dd($get_insurer_id_from_client_policy);
|
||||
|
||||
$add_one_day = 0;
|
||||
|
||||
if (!empty($get_insurer_id_from_client_policy)) {
|
||||
|
||||
$get_the_insurer_add_one_for_delete = db_connect()
|
||||
->table('insurers')
|
||||
->select('deletion_add_day')
|
||||
->where('id', $get_insurer_id_from_client_policy['insurer_id'])
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
// dd($get_the_insurer_add_one_for_delete, $get_the_insurer_add_one_for_delete['deletion_add_day']);
|
||||
|
||||
if (!empty($get_the_insurer_add_one_for_delete) && $get_the_insurer_add_one_for_delete['deletion_add_day'] == 1) {
|
||||
$add_one_day = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// dd($add_one_day);
|
||||
|
||||
foreach($units as $unit) {
|
||||
|
||||
// $amount = $this->employeePolicyModel->query("
|
||||
// SELECT SUM(rata_premimum + gst) AS total_sum
|
||||
// FROM employee_polices
|
||||
// JOIN employees ON employees.id = employee_polices.employee_id
|
||||
// WHERE employees.unit = '$unit'
|
||||
// AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
// ")->getRow();
|
||||
|
||||
$amount = $this->employeePolicyModel->query("
|
||||
SELECT SUM(rata_premimum + gst) AS total_sum
|
||||
FROM employee_polices
|
||||
JOIN employees ON employees.id = employee_polices.employee_id
|
||||
WHERE employees.unit = '$unit'
|
||||
AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
SELECT
|
||||
SUM(ROUND(
|
||||
((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, emp_endorsement.new_value) + '$add_one_day')) / 365) +
|
||||
(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, emp_endorsement.new_value) + '$add_one_day')) / 365) * 0.18),
|
||||
2
|
||||
)) AS total_sum
|
||||
FROM
|
||||
employee_polices
|
||||
JOIN
|
||||
employees ON employees.id = employee_polices.employee_id
|
||||
JOIN
|
||||
emp_endorsement ON emp_endorsement.pk = employee_polices.id
|
||||
WHERE
|
||||
employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
AND emp_endorsement.pk IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
AND emp_endorsement.field_name = 'date_of_exit'
|
||||
")->getRow();
|
||||
|
||||
// dd(db_connect()->getLastQuery(), $amount);
|
||||
|
||||
if($amount){
|
||||
|
||||
$insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
|
||||
@ -4016,6 +4069,7 @@ class EmpDataServiceController extends BaseController
|
||||
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
|
||||
}
|
||||
}
|
||||
|
||||
$msg = "Deletion Cash Deposite Updated Successfully -- ";
|
||||
return [$msg];
|
||||
// print_r($response);
|
||||
@ -4255,137 +4309,104 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
public function sendMailForDownloadingECard(array $ids, $single_mail = null)
|
||||
{
|
||||
$this->myLogger->logme('info', 'sendMailForDownloadingECard - Function called');
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - function called');
|
||||
if (count($ids) > 0) {
|
||||
|
||||
$temp_id = $ids[0];
|
||||
|
||||
$get_client_info_for_notification = $this->employeePolicyModel
|
||||
->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.emp_status', 'active')
|
||||
->where('employees.is_active', '1')
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.is_active', '1')
|
||||
->where('employee_polices.id', $ids[0])->first();
|
||||
|
||||
$client_data = $this->clientModel->where('id', $get_client_info_for_notification['client_id'])->first();
|
||||
$notification = $this->notificationModel->where('client_id', $get_client_info_for_notification['client_id'])->where('template_name', 'member_ecard_mail')->first();
|
||||
|
||||
if ($notification != null && !empty($notification) && $notification['enabled'] == 1) {
|
||||
|
||||
try {
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - inside try');
|
||||
$count = 0;
|
||||
$counts = 0;
|
||||
|
||||
foreach ($ids as $key => $id) {
|
||||
|
||||
$get_emp_email_and_other_details = $this->employeePolicyModel
|
||||
->select('employee_polices.client_policy_id, employees.relationship, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.emp_status', 'active')
|
||||
->where('employees.is_active', '1')
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.is_active', '1')
|
||||
->where('employee_polices.id', $id)->first();
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - emp_policy_id : {id}', ['id' => $id]);
|
||||
|
||||
if ($get_emp_email_and_other_details != null && !empty($get_emp_email_and_other_details)) {
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function inside if condition ',);
|
||||
|
||||
$rand_string = $get_emp_email_and_other_details['rand_string'];
|
||||
$tpa_id = $get_emp_email_and_other_details['tpa_id'];
|
||||
|
||||
$params['rand_string'] = $rand_string;
|
||||
$params['tpa_id'] = $tpa_id;
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_data;
|
||||
$params['notification'] = $notification;
|
||||
$params['notification'] = $notification;
|
||||
$params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
|
||||
// $this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',);
|
||||
|
||||
if (isset($get_emp_email_and_other_details['email_corporate']) && !empty($get_emp_email_and_other_details['email_corporate']) && $get_emp_email_and_other_details['relationship'] == 'Self') {
|
||||
$wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
|
||||
// print_r($wholeData);die;
|
||||
$count++;
|
||||
}
|
||||
|
||||
$counts++;
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - counts : {data}', ['data' => $counts]);
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - count : {data}', ['data' => $count]);
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - ids count : {data}', ['data' => count($ids)]);
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - whole count : {data}', ['data' => count($wholeData)]);
|
||||
|
||||
if ($count == 20 || $counts == count($ids) - 1) {
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - ids count : {data}', ['data' => count($ids)]);
|
||||
|
||||
if(count($wholeData) > 0){
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job to bulk mail',);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
|
||||
$wholeData = [];
|
||||
$count = 0;
|
||||
|
||||
}
|
||||
}else{
|
||||
|
||||
// for view member individual employee send self and self family ecard
|
||||
if($single_mail){
|
||||
|
||||
if(count($wholeData) > 0){
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job for single mail to bulk mail function',);
|
||||
|
||||
$mail_send_return = MailHelper::send_email($wholeData[0]);
|
||||
$this->myLogger->logme("info", $mail_send_return);
|
||||
return $mail_send_return;
|
||||
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
|
||||
// $wholeData = [];
|
||||
// $count = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',);
|
||||
}
|
||||
}
|
||||
return true; // Email(s) sent successfully
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
// Log the error
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard : inside catch');
|
||||
$this->myLogger->logme('error', 'Error occurred while sending email: ' . $e->getMessage());
|
||||
return false; // Email(s) sending failed
|
||||
}
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - the client notification setup not created or not enabled the E-Card Notification');
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (empty($ids)) {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - employee_policy_ids are empty');
|
||||
return false;
|
||||
}
|
||||
|
||||
$temp_id = $ids[0];
|
||||
|
||||
$get_client_info = $this->employeePolicyModel
|
||||
->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate, employees.client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.emp_status', 'active')
|
||||
->where('employees.is_active', '1')
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.is_active', '1')
|
||||
->where('employee_polices.id', $temp_id)
|
||||
->first();
|
||||
|
||||
if (!$get_client_info) {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - No client information found for the first ID');
|
||||
return false;
|
||||
}
|
||||
|
||||
$client_data = $this->clientModel->where('id', $get_client_info['client_id'])->first();
|
||||
$notification = $this->notificationModel
|
||||
->where('client_id', $get_client_info['client_id'])
|
||||
->where('template_name', 'member_ecard_mail')
|
||||
->first();
|
||||
|
||||
if (empty($notification) || $notification['enabled'] != 1) {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Notification setup not enabled or missing for E-Card Notification');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Inside try block');
|
||||
|
||||
$count = 0;
|
||||
$processedCount = 0;
|
||||
$wholeData = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$emp_details = $this->employeePolicyModel
|
||||
->select('employee_polices.client_policy_id, employees.relationship, employees.emp_code, employees.email_corporate, employees.client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.emp_status', 'active')
|
||||
->where('employees.is_active', '1')
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.is_active', '1')
|
||||
->where('employee_polices.id', $id)
|
||||
->first();
|
||||
|
||||
if ($emp_details) {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Processing employee_policy_id: {id}', ['id' => $id]);
|
||||
|
||||
if (!empty($emp_details['email_corporate']) && $emp_details['relationship'] === 'Self') {
|
||||
$params = [
|
||||
'rand_string' => $emp_details['rand_string'],
|
||||
'tpa_id' => $emp_details['tpa_id'],
|
||||
'notification' => $notification,
|
||||
'client_data' => $client_data,
|
||||
'get_emp_email_and_other_details' => $emp_details,
|
||||
];
|
||||
$wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
|
||||
$count++;
|
||||
}
|
||||
$processedCount++;
|
||||
|
||||
// Send batch emails or handle single email
|
||||
if ($count == 20 || $processedCount == count($ids)) {
|
||||
if (!empty($wholeData)) {
|
||||
if ($single_mail == 1) {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Sending single mail');
|
||||
$mail_result = MailHelper::send_email($wholeData[0]);
|
||||
$this->myLogger->logme('info', 'sendMailForDownloadingECard - Single mail result: {result}', ['result' => $mail_result]);
|
||||
return $mail_result;
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Creating a job for bulk mail');
|
||||
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
|
||||
$wholeData = [];
|
||||
$count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Email processing completed');
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Exception occurred: {message}', ['message' => $e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function readExcelFileToArray($path)
|
||||
{
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path);
|
||||
|
||||
@ -1074,6 +1074,7 @@ class EmployeeController extends AdminController
|
||||
|
||||
// Step 1: Attempt to fetch employee code and client policy ID
|
||||
$this->myLogger->logme('error', 'Fetching employee code and client policy ID.');
|
||||
|
||||
$get_emp_code_and_client_policy_id = $this->employeePolicyModel
|
||||
->select('employee_polices.client_policy_id, employees.emp_code, tpa.short_name,employees.client_id')
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||
@ -1087,6 +1088,10 @@ class EmployeeController extends AdminController
|
||||
->where('employee_polices.rand_string', $rand_string)
|
||||
->first();
|
||||
|
||||
// dd($this->employeePolicyModel->getLastQuery());
|
||||
|
||||
// dd($rand_string, $get_emp_code_and_client_policy_id);
|
||||
|
||||
if ($get_emp_code_and_client_policy_id == null || $get_emp_code_and_client_policy_id == "") {
|
||||
$this->myLogger->logme('error', 'Member not found in this rand_string: ' . $rand_string);
|
||||
$data['message'] = 'Record Not Found';
|
||||
@ -1222,7 +1227,8 @@ class EmployeeController extends AdminController
|
||||
// $file['action'] = 'si_enhancement';
|
||||
// $result = [];
|
||||
// !dd($file);
|
||||
if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment') {
|
||||
if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment' || $file['action'] == 'missed_inception') {
|
||||
|
||||
|
||||
if($file['action'] == 'enrollment'){
|
||||
$result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['draft','enrolled'], policy_status: ['draft','enrolled']);
|
||||
@ -1442,9 +1448,9 @@ class EmployeeController extends AdminController
|
||||
// array_pop($excel_data);
|
||||
// }
|
||||
|
||||
if($event_type == 'deletion'){
|
||||
array_pop($excel_data);
|
||||
}
|
||||
// if($event_type == 'deletion'){
|
||||
// array_pop($excel_data);
|
||||
// }
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($error_data as $key => $values) {
|
||||
@ -1785,20 +1791,37 @@ class EmployeeController extends AdminController
|
||||
|
||||
public function checkDeletionGetDataFunction()
|
||||
{
|
||||
$batch_data = [
|
||||
'client_id' => 77,
|
||||
'client_policy_id' => 203,
|
||||
'client_branch_id' => 53,
|
||||
'insurer_or_tpa' => 'tpa',
|
||||
];
|
||||
// $batch_data = [
|
||||
// 'client_id' => 77,
|
||||
// 'client_policy_id' => 203,
|
||||
// 'client_branch_id' => 53,
|
||||
// 'insurer_or_tpa' => 'tpa',
|
||||
// ];
|
||||
|
||||
$result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
|
||||
// print_rr($result); die;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// $ids = [
|
||||
// 'employeeIds' => [20252, 20258, 20277, 20282, 20196, 20237, 20314, 20325, 20356],
|
||||
// 'client_id' => 17,
|
||||
// 'client_policy_id' => 30,
|
||||
// 'client_branch_id' => 18,
|
||||
// 'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
// 'endorsement_no' => $endorsement_id ?? null,
|
||||
// 'count' => 9,
|
||||
// // 'event_name' => $file['event_type'],
|
||||
// // 'policy_name' => $policy_name['policy_name'],
|
||||
// // 'user_id' => $user_id,
|
||||
// ];
|
||||
// $empDataServiceController = new EmpDataServiceController();
|
||||
// $result = $empDataServiceController->cashDepositCalculationForDeletion($ids);
|
||||
|
||||
print_rr($result); die;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// ---------- DOWNLOAD IMPORT BATCH FILE AND SAMPLE FILE ------------------------------------------------------------------------------------------------
|
||||
|
||||
public function downloadSampleImportExcelFile($actionType = null)
|
||||
{
|
||||
@ -1834,4 +1857,94 @@ class EmployeeController extends AdminController
|
||||
echo view('errors/html/production');
|
||||
}
|
||||
}
|
||||
|
||||
public function download_import_file($file_id)
|
||||
{
|
||||
// $actionType = $this->request->getGet();
|
||||
$file_data = $this->batchFileModel->where('id', $file_id)->first();
|
||||
$fileName = $file_data['file_name'];
|
||||
|
||||
$filePath = WRITEPATH . '/uploads/import_excel/' . $fileName;
|
||||
|
||||
try {
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($filePath)) {
|
||||
// Set the appropriate MIME type
|
||||
$mimeType = mime_content_type($filePath);
|
||||
|
||||
// Send the file to the client for download
|
||||
return $this->response->download($filePath, null, $mimeType);
|
||||
} else {
|
||||
|
||||
$data['message'] = 'The Physical File Not Found';
|
||||
echo view('errors/404', $data);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Handle any exceptions
|
||||
$errorMessage = $e->getMessage();
|
||||
$this->myLogger->logme('error', $errorMessage);
|
||||
// You can return an error response here
|
||||
echo $errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
//--------- LOG FILE VIEW AND DOWNLOAD ---------------------------------------------------------------------------------------------
|
||||
|
||||
public function listLogs()
|
||||
{
|
||||
$logPath = WRITEPATH . 'logs/';
|
||||
$logs = [];
|
||||
|
||||
// Check if the log directory exists
|
||||
if (is_dir($logPath)) {
|
||||
$files = array_diff(scandir($logPath), ['.', '..']); // Exclude '.' and '..'
|
||||
|
||||
$files = array_reverse($files);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_file($logPath . $file)) {
|
||||
$logs[] = $file; // Add log files to the list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['logs'] = $logs;
|
||||
$data['server_details'] = get_server_details();
|
||||
|
||||
// Pass log files to the view
|
||||
return $this->loadLayout('log_view', $data);
|
||||
}
|
||||
|
||||
public function downloadLog($fileName)
|
||||
{
|
||||
$logPath = WRITEPATH . 'logs/' . $fileName;
|
||||
|
||||
// Check if the requested file exists
|
||||
if (file_exists($logPath)) {
|
||||
return $this->response->download($logPath, null)->setFileName($fileName);
|
||||
}
|
||||
|
||||
// Redirect back with an error if file doesn't exist
|
||||
return redirect()->back()->with('error', 'Log file not found.');
|
||||
}
|
||||
|
||||
public function viewLog($fileName)
|
||||
{
|
||||
$logPath = WRITEPATH . 'logs/' . $fileName;
|
||||
|
||||
if (file_exists($logPath)) {
|
||||
$content = file_get_contents($logPath);
|
||||
|
||||
$data['fileName'] = $fileName;
|
||||
$data['content'] = $content;
|
||||
$data['server_details'] = get_server_details();
|
||||
|
||||
return $this->loadLayout('log_content_view', $data);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('error', 'Log file not found.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ namespace App\Controllers;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
use App\Models\UserModel;
|
||||
@ -165,13 +167,26 @@ class LeadsController extends BaseController
|
||||
|
||||
private function prepareMultipleLeadData($data)
|
||||
{
|
||||
// print_r($data); die;
|
||||
$processedData = [];
|
||||
foreach($data['policy_type_id'] as $index => $value){
|
||||
|
||||
// Separate the insurer and insurer branch
|
||||
list($insurer_branch_id, $insurer_id) = explode('-',$data['insurer'][$index]);
|
||||
// Separate the tpa and tpa branch
|
||||
list($tpa_branch_id, $tpa_id) = explode('-',$data['tpa'][$index]);
|
||||
|
||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
|
||||
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]);
|
||||
} else {
|
||||
$insurer_branch_id = 0;
|
||||
$insurer_id = 0;
|
||||
}
|
||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||
if (isset($data['tpa'][$index]) && strpos($data['tpa'][$index], '-') !== false) {
|
||||
list($tpa_branch_id, $tpa_id) = explode('-', $data['tpa'][$index]);
|
||||
} else {
|
||||
$tpa_branch_id = 0;
|
||||
$tpa_id = 0;
|
||||
}
|
||||
|
||||
|
||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||
if (isset($data['proposed_insurer'][$index]) && strpos($data['proposed_insurer'][$index], '-') !== false) {
|
||||
@ -337,16 +352,25 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['lead_id'] = $id;
|
||||
$lead_data = $this->leadsModel
|
||||
->select('policy_type.question_json')
|
||||
->select('leads.*, policy_type.question_json')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->where('leads.id', $id)
|
||||
->where('leads.is_active', 1)
|
||||
->first();
|
||||
|
||||
// dd($lead_data);
|
||||
|
||||
if($lead_data['lead_type'] == 2){
|
||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
$data['policy_terms'] = $client_policy_data['policy_terms'];
|
||||
}
|
||||
|
||||
$data['question_json'] = $lead_data['question_json'];
|
||||
$data['page_name'] = isset($data['rfq_data']['type']) && $data['rfq_data']['type'] == 2 ? 'QCR' : 'RFQ';
|
||||
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
$data['userList'] = $this->userModel->getUserListForRFQ();
|
||||
$data['lead_data'] = $lead_data;
|
||||
|
||||
$data['lead_data'] = $this->leadsModel->where('leads.id', $id)->where('leads.is_active', 1)->first();
|
||||
// dd($data);
|
||||
$this->loadLayout('view_rfq.php', $data);
|
||||
}
|
||||
@ -366,7 +390,7 @@ class LeadsController extends BaseController
|
||||
$result = $this->RFQModel->insert($data);
|
||||
|
||||
if ($result) {
|
||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'New RFQ created successfully', 'data' =>$data], 200);
|
||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'RFQ created successfully', 'data' =>$data], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' =>$data], 200);
|
||||
@ -389,7 +413,7 @@ class LeadsController extends BaseController
|
||||
$result = $this->RFQModel->insert($data);
|
||||
|
||||
if ($result) {
|
||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'New QCR created successfully', 'data' =>$data], 200);
|
||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'QCR created successfully', 'data' =>$data], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200);
|
||||
@ -401,13 +425,8 @@ class LeadsController extends BaseController
|
||||
|
||||
//export main route function
|
||||
public function exportQCRandRFQ($lead_id, $type, $export_type){
|
||||
|
||||
if($export_type == 'mail'){
|
||||
$this-> exportMailForQCRandRFQ($lead_id, $type);
|
||||
}else{
|
||||
$this-> exportExcelForQCRandRFQ($lead_id, $type);
|
||||
}
|
||||
}
|
||||
|
||||
//FOR EXCEL
|
||||
public function exportExcelForQCRandRFQ($lead_id, $type)
|
||||
@ -435,42 +454,12 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
//FOR MAIL
|
||||
public function exportMailForQCRandRFQ($lead_id, $type){
|
||||
|
||||
$filepath = $this->constructExcelToSaveTemp($lead_id, $type);
|
||||
|
||||
if ($filepath) {
|
||||
return $this->respond(['status' => true, 'file_path' => $filepath, 'message' => 'Mail send successfully'], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'file_path' => $filepath, 'message' => "Mail send failed"], 200);
|
||||
}
|
||||
|
||||
//Construct excel file and save the file to the folder and return file path
|
||||
public function constructExcelToSaveTemp($lead_id, $type)
|
||||
public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null)
|
||||
{
|
||||
$rfq_data = $this->RFQModel
|
||||
->select('
|
||||
leads.client_name,
|
||||
leads.client_short_name,
|
||||
insurers.name as insurer_name,
|
||||
insurer_branch.branch_name as insurer_branch_name,
|
||||
tpa.name as tpa_name,
|
||||
tpa_branch.branch_name as tpa_branch_name,
|
||||
policy_type.policy_type,
|
||||
rfq.json
|
||||
')
|
||||
->join('leads', 'rfq.lead_id = leads.id')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->join('insurers', 'leads.insurer_id = insurers.id')
|
||||
->join('insurer_branch', 'leads.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'leads.tpa_id = tpa.id')
|
||||
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id')
|
||||
->where('rfq.lead_id', $lead_id)
|
||||
->where('rfq.type', $type)
|
||||
->where('rfq.is_active', 1)
|
||||
->first();
|
||||
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
||||
|
||||
// dd($rfq_data, $lead_id, $type);
|
||||
|
||||
$lead_data = [
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
@ -478,10 +467,16 @@ class LeadsController extends BaseController
|
||||
'TPA' => $rfq_data['tpa_name'] . ' - ' . $rfq_data['tpa_branch_name'],
|
||||
];
|
||||
|
||||
$jsonData = $rfq_data['json'];
|
||||
$data = json_decode($jsonData, true);
|
||||
$data = json_decode($rfq_data['json'], true);
|
||||
|
||||
if($type == 2){
|
||||
$data = $this->convertJsonForQCR($data, 'stc');
|
||||
if($propsal_and_insurer !== null){
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize PhpSpreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
@ -490,95 +485,172 @@ class LeadsController extends BaseController
|
||||
foreach ($lead_data as $key => $value) {
|
||||
$sheet->setCellValue("A{$rowNumber}", $key);
|
||||
$sheet->setCellValue("B{$rowNumber}", $value);
|
||||
|
||||
// Apply bold style to the key
|
||||
$sheet->getStyle("A{$rowNumber}")->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$sheet->getStyle("A{$rowNumber}")->applyFromArray(['font' => ['bold' => true]]);
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
// Leave two blank rows
|
||||
$leadRange = "A1:B" . (count($lead_data));
|
||||
$sheet->getStyle($leadRange)->applyFromArray([
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'color' => ['argb' => 'FF000000'], // Black color
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
$rowNumber += 2;
|
||||
|
||||
// Set headers and subheaders starting from current row
|
||||
// Add headers and subheaders
|
||||
$headers = $data['table_data']['headers'];
|
||||
$subHeaderRow = $rowNumber + 1;
|
||||
$columnLetter = 'A';
|
||||
|
||||
// Set column width and apply word wrap to headers and subheaders
|
||||
foreach ($headers as $header) {
|
||||
if ($header['parentHeader'] === 'Item Key' || $header['parentHeader'] == 'Action') {
|
||||
continue; // Skip "Item Key" and "Action" columns
|
||||
if (in_array($header['parentHeader'], ['Item Key', 'Action'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($header['parentHeader'] === 'Sno') {
|
||||
$header['parentHeader'] = 'S.No.';
|
||||
}
|
||||
|
||||
// Set the header cell value
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $header['parentHeader']);
|
||||
$startColumn = $columnLetter; // Start of the current header range
|
||||
$subHeaderCount = count($header['subHeaders']); // Number of subheaders for this parent header
|
||||
|
||||
// Set column width for header
|
||||
$sheet->getColumnDimension($columnLetter)->setWidth(20); // Adjust width as needed
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->getAlignment()->setWrapText(true);
|
||||
|
||||
// Apply bold style to the header
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
// Set parent header value
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", $header['parentHeader']);
|
||||
$sheet->getStyle("{$startColumn}{$rowNumber}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => [
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
// Add subheaders in the second row
|
||||
// Merge header cells if it spans multiple subheaders
|
||||
if ($subHeaderCount > 1) {
|
||||
$endColumn = chr(ord($startColumn) + $subHeaderCount - 1); // Calculate the end column
|
||||
$sheet->mergeCells("{$startColumn}{$rowNumber}:{$endColumn}{$rowNumber}");
|
||||
} else {
|
||||
$endColumn = $startColumn; // No merge needed if only one subheader
|
||||
}
|
||||
|
||||
// Add subheaders
|
||||
foreach ($header['subHeaders'] as $subHeader) {
|
||||
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
|
||||
|
||||
// Enable word wrap for subheaders
|
||||
$sheet->getStyle("{$columnLetter}{$subHeaderRow}")->getAlignment()->setWrapText(true);
|
||||
|
||||
// Apply bold style to the subheader
|
||||
$sheet->getStyle("{$columnLetter}{$subHeaderRow}")->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => [
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
]);
|
||||
$columnLetter++; // Move to the next column for subheaders
|
||||
}
|
||||
}
|
||||
|
||||
// Apply border to the header range
|
||||
$headerRange = "A{$rowNumber}:" . chr(ord($columnLetter) - 1) . "{$subHeaderRow}";
|
||||
$sheet->getStyle($headerRange)->applyFromArray([
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'color' => ['argb' => 'FF000000'], // Black color
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Increase row height for headers and subheaders
|
||||
$sheet->getRowDimension($rowNumber)->setRowHeight(30); // Header row height
|
||||
$sheet->getRowDimension($subHeaderRow)->setRowHeight(25); // Subheader row height
|
||||
|
||||
$rowNumber = $subHeaderRow + 2;
|
||||
$column_data = $data['table_data']['data'];
|
||||
$serial_no = 1;
|
||||
|
||||
// Add table data rows
|
||||
foreach ($column_data as $dataRow) {
|
||||
$columnLetter = 'A';
|
||||
foreach ($dataRow['data'] as $cellData) {
|
||||
if (in_array($cellData['parentth'], ['Item Key', 'Action'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($cellData['parentth'] == 'Sno') {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $serial_no);
|
||||
} else {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['value']);
|
||||
}
|
||||
|
||||
$columnLetter++;
|
||||
}
|
||||
$rowNumber++;
|
||||
$serial_no++;
|
||||
}
|
||||
|
||||
// Move to next row for data entries
|
||||
$rowNumber = $subHeaderRow + 1;
|
||||
$dataRange = "A" . ($subHeaderRow + 1) . ":" . chr(ord($columnLetter) - 1) . ($rowNumber - 1);
|
||||
$sheet->getStyle($dataRange)->applyFromArray([
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'color' => ['argb' => 'FF000000'], // Black color
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Add data rows and enable word wrap for data cells
|
||||
foreach ($data['table_data']['data'] as $dataRow) {
|
||||
$columnLetter = 'A';
|
||||
foreach ($dataRow['data'] as $cellData) {
|
||||
if ($cellData['parentth'] === 'Item Key' || $cellData['parentth'] == 'Action') {
|
||||
continue; // Skip "Item Key" data
|
||||
|
||||
if($type == 2){
|
||||
|
||||
$rowNumber += 2;
|
||||
|
||||
// Add premium data
|
||||
$premiumData = $data['premium_data']['data'];
|
||||
$premium = ['Premium'];
|
||||
$gst = ['GST'];
|
||||
$total = ['Total'];
|
||||
|
||||
foreach ($premiumData as $proposal => $insurers) {
|
||||
foreach ($insurers as $insurer => $values) {
|
||||
$premium[] = $values['Premium'];
|
||||
$gst[] = $values['GST'];
|
||||
$total[] = $values['Total'];
|
||||
}
|
||||
}
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['value']);
|
||||
|
||||
// Enable word wrap for data cells
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->getAlignment()->setWrapText(true);
|
||||
|
||||
foreach ([$premium, $gst, $total] as $index => $rowData) {
|
||||
$columnLetter = 'B';
|
||||
foreach ($rowData as $key => $value) {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $value);
|
||||
if ($key === 0) {
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray(['font' => ['bold' => true,],]);
|
||||
}
|
||||
$columnLetter++;
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
// Auto-size all columns after data is entered
|
||||
$premiumRange = "B" . ($rowNumber - 3) . ":" . chr(ord($columnLetter) - 1) . ($rowNumber - 1);
|
||||
$sheet->getStyle($premiumRange)->applyFromArray([
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'color' => ['argb' => 'FF000000'], // Black color
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
// Auto-size columns
|
||||
foreach ($sheet->getColumnIterator() as $column) {
|
||||
$sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Set filename based on type
|
||||
// Set filename
|
||||
$string = ($type == 2) ? 'QCR' : 'RFQ';
|
||||
$filename = $string . '_' . $rfq_data['client_short_name'] . '_' . $rfq_data['policy_type'] . '_' . date('Ymdhis') . '.xlsx';
|
||||
$filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx';
|
||||
|
||||
// Save to temporary location
|
||||
$uploadFilePath = WRITEPATH . 'tmp/' . $filename;
|
||||
@ -588,7 +660,7 @@ class LeadsController extends BaseController
|
||||
return [
|
||||
'filePath' => $uploadFilePath,
|
||||
'fileName' => $filename,
|
||||
]; // Return file path and file name
|
||||
];
|
||||
}
|
||||
|
||||
//this funciton for send mail to insurer and client with either RFQ/QCR
|
||||
@ -598,88 +670,144 @@ class LeadsController extends BaseController
|
||||
helper('MailHelper');
|
||||
|
||||
$params = $this->request->getGet();
|
||||
// dd($params);
|
||||
// print_r($params); die;
|
||||
$lead_id = $params['lead_id'];
|
||||
$file_type = $params['file_type']; //rfq or qcr
|
||||
$recipient_type = $params['recipient_type'];//insurer or client
|
||||
$recipient_mail = $params['recipient_mail'];// - only primary key of contacts
|
||||
$recipient_mail = json_decode($params['recipient_mail'], true);;// - only primary key of contacts
|
||||
// $cc = 'velz1990@gmail.com,vitvelz@gmail.com';
|
||||
$cc = "";
|
||||
$recipient_type = $params['recipient_type']; //insurer or client or internal or placement
|
||||
$recipient_mail = $params['recipient_mail']; // - only primary key of contacts
|
||||
$recipient_mail = json_decode($params['recipient_mail'], true); // - only primary key of contacts
|
||||
$propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
|
||||
|
||||
$result_data = [];
|
||||
// dd($recipient_mail);
|
||||
if($recipient_type == 'insurer' && (!is_array($recipient_mail) || count($recipient_mail) == 0))
|
||||
{
|
||||
return $this->respond(['status' => 'failed','code' => 400,'data' => '','messgae' => 'Recipient mail not found ! ' ], 200);
|
||||
if ($recipient_type == 'insurer' && (!is_array($recipient_mail) || count($recipient_mail) == 0)) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200);
|
||||
}
|
||||
// dd();
|
||||
//gather lead info
|
||||
$lead_data = $this->leadsModel
|
||||
->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email')
|
||||
->join('policy_type','leads.policy_type_id = policy_type.id')
|
||||
->join('user_profiles','leads.created_by = user_profiles.id')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.id', $lead_id)
|
||||
->first();
|
||||
if( $recipient_type == 'client' && ($lead_data['contact_person_email'] == '' || $lead_data['contact_person_email'] == null))
|
||||
{
|
||||
return $this->respond(['status' => 'failed','code' => 400,'data' => '','messgae' => 'Recipient mail not found ! ' ], 200);
|
||||
|
||||
$cc_mails = [];
|
||||
|
||||
//get CC Mails
|
||||
if($recipient_type == 'internal' || $recipient_type == 'placement'){
|
||||
|
||||
$cc_data = isset($params['cc']) ? $params['cc'] : "";
|
||||
$param_cc_mail = json_decode($cc_data, true);
|
||||
if (isset($param_cc_mail) && is_array($param_cc_mail) && count($param_cc_mail) > 0) {
|
||||
// Fetch user data where ID is in the param_cc_mail array
|
||||
$userData = $this->userModel
|
||||
->where('is_active', 1)
|
||||
->whereIn('id', $param_cc_mail)
|
||||
->findAll();
|
||||
|
||||
// print_r($userData); die;
|
||||
|
||||
// Extract emails from the fetched user data
|
||||
$cc_mails = array_column($userData, 'email');
|
||||
|
||||
// print_r(json_encode($cc_mails)); die;
|
||||
|
||||
// If no emails were found, return an error response
|
||||
if (empty($cc_mails)) {
|
||||
return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'No valid CC mail addresses found!'], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Handle case where param_cc_mail is not valid
|
||||
return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
if ($recipient_type == 'client' && ($lead_data['contact_person_email'] == '' || $lead_data['contact_person_email'] == null)) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200);
|
||||
}
|
||||
|
||||
// dd($lead_data);
|
||||
$reply_to = $lead_data['created_person_email'];
|
||||
|
||||
//get file path to attach
|
||||
$file_info = $this->constructExcelToSaveTemp($lead_id, ( $file_type == 'rfq' ? 1 : 2) );
|
||||
$file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer);
|
||||
// $file_path = WRITEPATH."uploads/excel/sample/correction.xls";
|
||||
// $file_name = $file_type.'.xlsx';
|
||||
// !dd($file_info);
|
||||
|
||||
$file_path = $file_info['filePath'];
|
||||
$file_name = $file_info['fileName'];
|
||||
$attachments = [['fileName' => $file_name,'filePath' => $file_path]];
|
||||
$attachments = [['fileName' => $file_name, 'filePath' => $file_path]];
|
||||
|
||||
//get recipient address
|
||||
if($recipient_type == 'insurer')
|
||||
{
|
||||
if ($recipient_type == 'insurer' || $recipient_type == 'placement') {
|
||||
|
||||
// print_r($recipient_mail); die;
|
||||
|
||||
$recipient_data = $this->levelContactModel
|
||||
->where(['contact_type' => $recipient_type, 'is_active' => 1])
|
||||
->where(['contact_type' => 'insurer', 'is_active' => 1])
|
||||
->whereIn('id', $recipient_mail)
|
||||
->findAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
$recipient_data = [['name' => $lead_data['contact_person_name'],'email' => $lead_data['contact_person_email']] ];
|
||||
}
|
||||
// !dd($recipient_data);
|
||||
|
||||
$subject = $file_type == 'rfq' ? 'Request for Quotation from '. $lead_data['client_name'] . ' for '.$lead_data['policy_type'] : 'Quotation Comparison Report for ' .$lead_data['policy_type'];
|
||||
// print_r($recipient_data); die;
|
||||
|
||||
} else if($recipient_type == 'client') {
|
||||
$recipient_data = [['name' => $lead_data['contact_person_name'], 'email' => $lead_data['contact_person_email']]];
|
||||
}else{
|
||||
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
|
||||
}
|
||||
// print_r($recipient_data); die;
|
||||
|
||||
$subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type'];
|
||||
$original_message = '<div style="width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9;font-family:Arial,sans-serif;color:#333;line-height:1.6"><div style=background-color:#4a90e2;color:#fff;padding:15px;text-align:center><h1 style=margin:0;font-size:24px>Request for Quotation (RFQ)</h1></div><div style=padding:20px;background-color:#fff><h2 style=color:#4a90e2;font-size:20px;margin-top:0>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2 style=color:#4a90e2;font-size:20px;margin-top:20px>RFQ Details</h2><table style=width:100%;border-collapse:collapse;margin-top:20px><tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Client name<td style="border:1px solid #ddd;padding:10px;text-align:left">{{CLIENT_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Coverage Type<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_LONG_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Start Date<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_START_DATE}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Duration<td style="border:1px solid #ddd;padding:10px;text-align:left">{{DURATION}}</table><div style="margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic">Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div style=margin-top:20px;font-size:12px;color:#777;text-align:center><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
||||
|
||||
if($recipient_data){
|
||||
foreach ($recipient_data as $recipient) {
|
||||
|
||||
foreach($recipient_data as $recipient)
|
||||
{
|
||||
$message = $original_message;
|
||||
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message);
|
||||
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message);
|
||||
$message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message);
|
||||
$message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'],'Y-m-d','d-m-Y'), $message);
|
||||
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'],$lead_data['policy_start_date'])->days, $message);
|
||||
$message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message);
|
||||
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--';
|
||||
|
||||
// print_rr($message);
|
||||
// print_rr($message);calculate_days_bw_dates
|
||||
|
||||
$res = MailHelper::send_email(['mail' => $recipient['email'], 'subject' => $subject, 'message' => $message,'attachments' => $attachments,'reply_to' => $reply_to]);
|
||||
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc'=> $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to]);
|
||||
// !dd($res);
|
||||
|
||||
$result_data[] = ['mail' => $recipient['email'],'status' => $res];
|
||||
$result_data[] = ['mail' => $recipient['email'], 'status' => $res];
|
||||
}
|
||||
}
|
||||
|
||||
if($recipient_type == 'placement'){
|
||||
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
|
||||
$lead_update_data = [
|
||||
'proposel_name' => $proposal_key,
|
||||
'insurer_name' => $insurer_key,
|
||||
'insurer' => $params['insurer_and_branch'],
|
||||
] ;
|
||||
|
||||
$data = [
|
||||
'proposel_data' => json_encode($lead_update_data),
|
||||
'status' => 'won'
|
||||
];
|
||||
|
||||
$this->leadsModel->where('id', $lead_id)->set($data)->update();
|
||||
}
|
||||
|
||||
//delete attachment file
|
||||
unlink($file_path);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result_data ], 200);
|
||||
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result_data], 200);
|
||||
}
|
||||
|
||||
public function getLevelContects()
|
||||
{
|
||||
|
||||
$data = $this->levelContactModel->getContectForRFQ();
|
||||
$data = $this->levelContactModel->getContactForRFQ();
|
||||
|
||||
if($data){
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
@ -689,11 +817,219 @@ class LeadsController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function getInsurerBranchContacts($insurer_and_branch_id)
|
||||
{
|
||||
if (strpos($insurer_and_branch_id, '-') === false) {
|
||||
return $this->respond(['status' => false, 'message' => 'Invalid ID format'], 400);
|
||||
}
|
||||
|
||||
// Split the insurer_and_branch_id
|
||||
list($insurerBranchId, $insurerId) = explode('-', $insurer_and_branch_id);
|
||||
|
||||
$data = $this->levelContactModel->getContactForRFQ($insurerId, $insurerBranchId);
|
||||
|
||||
if (!empty($data)) {
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'data' => $data, 'message' => 'No contacts were found for the selected insurer.'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
function transformProposelData($data, $proposel, $insurer){
|
||||
|
||||
// print_r($data['premium_data']['data']); die;
|
||||
|
||||
$headerData = [];
|
||||
|
||||
// Default headers: S. No and Particulars
|
||||
$defaultHeaders = [
|
||||
[
|
||||
'parentHeader' => 'Sno',
|
||||
'subHeaders' => ['-']
|
||||
],
|
||||
[
|
||||
'parentHeader' => 'Particulars',
|
||||
'subHeaders' => ['-']
|
||||
]
|
||||
];
|
||||
|
||||
// Add default headers to the result
|
||||
$headerData = array_merge($headerData, $defaultHeaders);
|
||||
|
||||
foreach ($data['table_data']['headers'] as $header) {
|
||||
// Check if the parentHeader matches the target proposal
|
||||
if ($header['parentHeader'] === $proposel) {
|
||||
// Check if subHeaders contain the target insurer key
|
||||
foreach ($header['subHeaders'] as $subHeader) {
|
||||
if ($subHeader === $insurer) {
|
||||
$headerData[] = [
|
||||
'parentHeader' => $header['parentHeader'],
|
||||
'subHeaders' => [
|
||||
'Quote Asked', // Default value
|
||||
$subHeader // Matched insurer key
|
||||
]
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$columnData = [];
|
||||
|
||||
foreach ($data['table_data']['data'] as $entry) {
|
||||
|
||||
$sno = $entry['SNO'];
|
||||
$items = $entry['items'];
|
||||
$dataEntry = $entry['data'];
|
||||
|
||||
$result = [
|
||||
"SNO" => $sno,
|
||||
"items" => $items,
|
||||
"data" => []
|
||||
];
|
||||
|
||||
foreach ($dataEntry as $item) {
|
||||
|
||||
// Include Sno and Particulars by default
|
||||
if (in_array($item['parentth'], ['Sno', 'Particulars'])) {
|
||||
$result['data'][] = [
|
||||
"parentth" => $item['parentth'],
|
||||
"subth" => $item['subth'],
|
||||
"value" => $item['value'],
|
||||
"input_value" => $item['input_value']
|
||||
];
|
||||
}
|
||||
|
||||
// Include Proposal with Quote Asked by default
|
||||
if ($item['parentth'] === $proposel && $item['subth'] === "Quote Asked") {
|
||||
$result['data'][] = [
|
||||
"parentth" => $item['parentth'],
|
||||
"subth" => $item['subth'],
|
||||
"value" => $item['value'],
|
||||
"input_value" => $item['input_value']
|
||||
];
|
||||
}
|
||||
|
||||
// Example of including matching specific proposals and insurers
|
||||
if ($item['parentth'] === $proposel && $item['subth'] === $insurer) {
|
||||
$result['data'][] = [
|
||||
"parentth" => $item['parentth'],
|
||||
"subth" => $item['subth'],
|
||||
"value" => $item['value'],
|
||||
"input_value" => $item['input_value']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Add to the final result
|
||||
$columnData[] = $result;
|
||||
}
|
||||
|
||||
$premiumData = [];
|
||||
|
||||
foreach ($data['premium_data']['data'] as $key => $value) {
|
||||
if ($key === $proposel) {
|
||||
$premiumData[$key]['Quote Asked'] = $value['Quote Asked'];
|
||||
$premiumData[$key][$insurer] = $value[$insurer];
|
||||
}
|
||||
}
|
||||
|
||||
$data['table_data']['headers'] = $headerData;
|
||||
$data['table_data']['data'] = $columnData;
|
||||
$data['premium_data']['data'] = $premiumData;
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
function convertJsonForQCR($json, $type)
|
||||
{
|
||||
if ($json) {
|
||||
// Deep copy of JSON
|
||||
$first_json = json_decode(json_encode($json), true);
|
||||
|
||||
// Column-wise Check: Remove headers and relevant data if qcr == 0
|
||||
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
|
||||
if ($proposalData['stc'] == 0 || $proposalData['stc'] === false) {
|
||||
// Remove matching parentHeader in headers
|
||||
foreach ($first_json['table_data']['headers'] as $index => $header) {
|
||||
if ($header['parentHeader'] === $proposalKey) {
|
||||
unset($first_json['table_data']['headers'][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove data entries with matching parentth
|
||||
foreach ($first_json['table_data']['data'] as &$item) {
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) {
|
||||
return $entry['parentth'] !== $proposalKey;
|
||||
}));
|
||||
}
|
||||
|
||||
// Remove proposalKey from over_all_column_data
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
|
||||
|
||||
if($type == 'stc'){
|
||||
// Remove proposalKey from premium_data
|
||||
unset($first_json['premium_data']['data'][$proposalKey]);
|
||||
}
|
||||
}
|
||||
|
||||
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
|
||||
foreach ($proposalData['insurers'] as $insurerIndex => $insurer) {
|
||||
if ($insurer['stc'] === 0 || $insurer['stc'] === false) {
|
||||
foreach ($first_json['table_data']['headers'] as &$header) {
|
||||
if (isset($header['subHeaders'])) {
|
||||
$header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) {
|
||||
return $sub !== $insurer['display_name'];
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($first_json['table_data']['data'] as &$item) {
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) {
|
||||
return $entry['subth'] !== $insurer['display_name'];
|
||||
}));
|
||||
}
|
||||
|
||||
// Remove insurer from proposal's insurers array
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
|
||||
|
||||
if($type == 'stc'){
|
||||
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Row-wise Check: Remove rows if qcr == 0 for actions
|
||||
foreach ($first_json['table_data']['data'] as $rowKey => $rowData) {
|
||||
foreach ($rowData['data'] as $data) {
|
||||
if ($data['parentth'] === "Action" && isset($data['input_value']['stc']) && $data['input_value']['stc'] == 0) {
|
||||
unset($first_json['table_data']['data'][$rowKey]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reindex arrays to maintain proper structure
|
||||
$first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']);
|
||||
$first_json['table_data']['data'] = array_values($first_json['table_data']['data']);
|
||||
$first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) {
|
||||
$proposal['insurers'] = array_values($proposal['insurers']);
|
||||
return $proposal;
|
||||
}, $first_json['proposal_data']['over_all_column_data']);
|
||||
|
||||
return $first_json;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//----- Featch Lead data and insert Client -------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
public function featchLeadDataAndInsertClient($lead_id)
|
||||
{
|
||||
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
|
||||
@ -705,7 +1041,9 @@ class LeadsController extends BaseController
|
||||
$result = $this->createClientWithLeadData($data);
|
||||
|
||||
if ($result) {
|
||||
return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data], 200);
|
||||
|
||||
$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);
|
||||
@ -751,7 +1089,6 @@ class LeadsController extends BaseController
|
||||
return $branch_id;
|
||||
}
|
||||
|
||||
|
||||
private function prepareClientBranchData($data, $client_id)
|
||||
{
|
||||
$default_unit = trim(($data['client_short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-');
|
||||
@ -784,12 +1121,16 @@ class LeadsController extends BaseController
|
||||
|
||||
private function prepareClientPolicyData($data, $client_id, $branch_id)
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
// print_r($proposel_data); die;
|
||||
list($insurer_branch_id, $insurer_id) = explode('-', $proposel_data['insurer'], 2);
|
||||
|
||||
$client_policy_data = [
|
||||
'client_id' => $client_id,
|
||||
'client_branch_id' => $branch_id,
|
||||
'policy_type_id' => $data['policy_type_id'],
|
||||
'insurer_id' => $data['insurer_id'],
|
||||
'insurer_branch_id' => $data['insurer_branch_id'],
|
||||
'insurer_id' => $insurer_id,
|
||||
'insurer_branch_id' => $insurer_branch_id,
|
||||
'tpa_id' => $data['tpa_id'],
|
||||
'tpa_branch_id' => $data['tpa_branch_id'],
|
||||
'policy_start_date' => $data['policy_start_date'],
|
||||
@ -797,6 +1138,8 @@ class LeadsController extends BaseController
|
||||
'policy_status' => 1,
|
||||
];
|
||||
|
||||
$terms = $this->preparePolicyTermsFromRFQ($data);
|
||||
|
||||
$policy_type_id = $data['policy_type_id'];
|
||||
if (in_array($policy_type_id, [1, 2, 6, 7])) {
|
||||
$client_policy_data['is_addon'] = 1; // Base Policy
|
||||
@ -810,14 +1153,145 @@ class LeadsController extends BaseController
|
||||
// }
|
||||
}
|
||||
|
||||
$client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data);
|
||||
|
||||
// print_r($client_policy_data); die;
|
||||
|
||||
return $client_policy_data;
|
||||
}
|
||||
|
||||
private function preparePolicyTermsFromRFQ($data)
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
|
||||
$QCRData = $this->RFQModel->where('is_active', 1)->where('type', 2)->where('lead_id', $data['id'])->first();
|
||||
|
||||
$JSON = json_decode($QCRData['json'], true);
|
||||
|
||||
$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']);
|
||||
}
|
||||
|
||||
private function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name)
|
||||
{
|
||||
$GMC_Keys = [
|
||||
"sum_insured", "family_floater", "family_floaters", "age_ratio", "waiverofpreexistingdiseases",
|
||||
"maternitycoverage", "twindelivery", "preandpostnatal", "babyday1cover", "9monthwaitingperiodwaived",
|
||||
"coverfromthedateofjoining", "waiverof1,2,3&4thyearexclusions", "waiverof30dayswaitingperiod",
|
||||
"prehospitalizationcover", "congenitaldiseasesinternal", "copayzonewisecopay",
|
||||
"bioabsorbablestenttoriclensmultifocallens", "roomrentlimit", "proportionatedeductionclause",
|
||||
"ailmentcapping", "ambulancecharges", "airambulance", "familytransportationbenefit",
|
||||
"reasonableandcustomarycharges", "ayudhtreatmentcover", "congenitaldiseasesexternal",
|
||||
"optionalparentalcopay", "posthospitalizationcover", "corporatebuffer", "sublimitofcorporatebuffer",
|
||||
"ayushTreatmentCoverData", "armdcovered", "suminsuredenhancement", "automaticsuminsuredreinstatement",
|
||||
"additionalsicknessbenefit", "lasiksurgery", "midterminclusion", "capd", "organdonorexpenses",
|
||||
"moderntreatmentsasperirdai", "Wellness", "days_of_discharge", "days_from_dod",
|
||||
"special_condition_label", "special_condition_input", "multiple_sum_insured",
|
||||
"cataract", "cataractData"
|
||||
];
|
||||
|
||||
$GPA_Keys = [
|
||||
"sumInsured2", "totalSumInsured", "age_ratio", "accidentalDeathBenefit", "permanentTotalDisablement",
|
||||
"permanentPartialDisablement", "temporaryTotalDisablementBenefit", "accidentalHospitalizationExpenses",
|
||||
"childrenEducationWelfareFund", "compassionateVisitExpenses", "compassionateVisitExpensesData",
|
||||
"brokenBoneExpenses", "brokenBoneExpensesData", "ambulanceCharges", "ambulanceChargesData",
|
||||
"burnExpenses", "burnExpensesData", "carriageOfDeadBody", "carriageOfDeadBodyData",
|
||||
"animalSnakeInsectBite", "terrorism", "worldwideCover", "gpa_special_condition_label",
|
||||
"gpa_special_condition_input", "multiple_sum_insured"
|
||||
];
|
||||
|
||||
// Select keys based on policy type
|
||||
$termsKey = $policy_type == 1 ? $GPA_Keys : $GMC_Keys;
|
||||
|
||||
// Initialize terms_array with default empty values
|
||||
$terms_array = array_fill_keys($termsKey, "");
|
||||
$specialKeys = ['special_condition_label', 'special_condition_input', 'gpa_special_condition_label', 'gpa_special_condition_input', 'multiple_sum_insured'];
|
||||
foreach ($specialKeys as $key) {
|
||||
$terms_array[$key] = [];
|
||||
}
|
||||
|
||||
// Initialize age_ratio based on policy type
|
||||
$terms_array['age_ratio'] = $policy_type == 2 ? [
|
||||
"self" => ["min" => "18", "max" => "60"],
|
||||
"spouse" => ["min" => 0, "max" => 0],
|
||||
"child" => ["min" => 0, "max" => "25"],
|
||||
"elders" => ["min" => 0, "max" => 0],
|
||||
] : ["self" => ["min" => "18", "max" => "60"]];
|
||||
|
||||
foreach ($data['table_data']['data'] as $dataRow) {
|
||||
|
||||
$item = $dataRow['items'] ?? '';
|
||||
|
||||
foreach ($dataRow['data'] as $cellData) {
|
||||
$parentth = $cellData['parentth'] ?? '';
|
||||
$subth = $cellData['subth'] ?? '';
|
||||
$input_value = $cellData['input_value'] ?? '';
|
||||
$value = $cellData['value'] ?? '';
|
||||
|
||||
// Skip unwanted keys
|
||||
if (in_array($parentth, ['Sno', 'Item Key', 'Particulars', 'Action']) ||
|
||||
in_array($subth, ['Quote Asked'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle special conditions
|
||||
if (str_starts_with($item, "special_condition") && $parentth === $proposel_name && $subth === $insurer_name) {
|
||||
|
||||
$parts = explode("-", $input_value);
|
||||
$question = $parts[0] ?? '';
|
||||
$answer = $parts[1] ?? '';
|
||||
$labelKey = $policy_type == 1 ? 'gpa_special_condition_label' : 'special_condition_label';
|
||||
$inputKey = $policy_type == 1 ? 'gpa_special_condition_input' : 'special_condition_input';
|
||||
|
||||
$terms_array[$labelKey][] = $question;
|
||||
$terms_array[$inputKey][] = $answer;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle sum insured
|
||||
if (in_array($item, ['sum_insured', 'sumInsured2'])) {
|
||||
$si_amt = explode(",", $value);
|
||||
$terms_array[$item] = $si_amt[0] ?? "";
|
||||
$terms_array['multiple_sum_insured'] = array_slice($si_amt, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle family floaters
|
||||
if ($item === 'family_composition') {
|
||||
$terms_array['family_floaters'] = isJsonString($input_value) ? json_decode($input_value, true) : $input_value;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Decode JSON if valid
|
||||
$terms_array[$item] = isJsonString($input_value) ?
|
||||
(json_decode($input_value, true)['key'] ?? '') :
|
||||
$input_value;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($terms_array);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -173,7 +173,7 @@ class MasterController extends AdminController
|
||||
|
||||
|
||||
$editData['policy_type'] = $this->policyTypeModel->whereIn('id', [1,2,6,7])->findAll();
|
||||
$editData['events'] = ['inception' => 'Inception', 'addition' => 'Addition', 'dependent_addition' => 'Dependent Addition', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement', 'all' => 'All'];
|
||||
$editData['events'] = ['inception' => 'Inception', 'missed_inception' => 'Missed Inception', 'addition' => 'Addition', 'dependent_addition' => 'Dependent Addition', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement', 'all' => 'All'];
|
||||
$editData['action'] = ['import' => 'Import', 'export' => 'Export'];
|
||||
$editData['db_column_name'] = [
|
||||
|
||||
|
||||
@ -106,7 +106,9 @@ class MailHelper
|
||||
//check CC mail
|
||||
if (isset($params['cc'])) {
|
||||
$cc = $params['cc'];
|
||||
if(!is_array($cc)){
|
||||
$cc = explode(',', $cc);
|
||||
}
|
||||
}else{
|
||||
$cc = [];
|
||||
}
|
||||
|
||||
@ -152,6 +152,11 @@ class sendMailNotification
|
||||
$mail = $get_emp_email_and_other_details['email_corporate'];
|
||||
$subject = $notification['subject'];
|
||||
|
||||
$cleanedText = mb_convert_encoding($subject, 'UTF-8', 'UTF-8'); // Normalize encoding
|
||||
$cleanedText = preg_replace('/[^\x20-\x7E]/', '', $cleanedText);
|
||||
|
||||
$subject = $cleanedText;
|
||||
|
||||
$link = generate_download_link($rand_string);
|
||||
|
||||
$app_link = $_ENV['App_Url'];
|
||||
@ -258,6 +263,7 @@ class sendMailNotification
|
||||
$si = '';
|
||||
$premium = '';
|
||||
$gst_forself = '';
|
||||
|
||||
if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
|
||||
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
|
||||
$premium = '₹ ' .format_indian_number(round($inner_item['premium']));
|
||||
|
||||
@ -475,3 +475,29 @@ if (!function_exists('print_rr')) {
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_server_details')) {
|
||||
/**
|
||||
* Get the hostname and server name.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_server_details(): array
|
||||
{
|
||||
$hostname = gethostname(); // Get the hostname of the server
|
||||
$serverName = $_SERVER['SERVER_NAME'] ?? 'Unknown'; // Get the server name
|
||||
|
||||
return [
|
||||
'hostname' => $hostname,
|
||||
'server_name' => $serverName,
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!function_exists('isJsonString')) {
|
||||
|
||||
function isJsonString($input)
|
||||
{
|
||||
json_decode($input); // Decode the string
|
||||
return (json_last_error() === JSON_ERROR_NONE); // Check if the last JSON error is "no error"
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,8 +75,8 @@ class EmployeePolicyModel extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=[], $branch_id=0, $emp_code="", $emp_name="")
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "")
|
||||
{
|
||||
// dd($status);
|
||||
|
||||
@ -91,7 +91,7 @@ class EmployeePolicyModel extends Model
|
||||
'tpab.branch_code as tpa_branch_code',
|
||||
'cm.client_name',
|
||||
'cm.short_name as client_short_name',
|
||||
'emp.id as employee_primary_id',
|
||||
// 'emp.id as employee_primary_id',
|
||||
'emp.relationship',
|
||||
'emp.relationship_code',
|
||||
'emp.change_event',
|
||||
@ -126,13 +126,13 @@ class EmployeePolicyModel extends Model
|
||||
->orderBy('employee_polices.employee_id', 'ASC');
|
||||
|
||||
// Conditionally add where clauses
|
||||
if ($client_id !=0 && !empty($client_id)) {
|
||||
if ($client_id != 0 && !empty($client_id)) {
|
||||
$result->where('emp.client_id', $client_id);
|
||||
}
|
||||
if ($branch_id !=0 && !empty($branch_id)) {
|
||||
if ($branch_id != 0 && !empty($branch_id)) {
|
||||
$result->where('emp.client_branch_id', $branch_id);
|
||||
}
|
||||
if ($policy_id !=0 && !empty($policy_id)) {
|
||||
if ($policy_id != 0 && !empty($policy_id)) {
|
||||
$result->where('employee_polices.client_policy_id', $policy_id);
|
||||
}
|
||||
|
||||
@ -145,13 +145,11 @@ class EmployeePolicyModel extends Model
|
||||
$result->where('employee_polices.tpa_id IS NOT NULL');
|
||||
$result->where('employee_polices.uhid IS NOT NULL');
|
||||
$result->whereIn('employee_polices.status', $status);
|
||||
|
||||
} elseif (in_array("pending", $status)) {
|
||||
|
||||
$result->where('employee_polices.tpa_id IS NULL');
|
||||
$result->where('employee_polices.uhid IS NULL');
|
||||
$result->whereIn('employee_polices.status', array_merge($status, ['active']));
|
||||
|
||||
} else {
|
||||
|
||||
$result->whereIn('employee_polices.status', $status);
|
||||
@ -575,6 +573,12 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
}
|
||||
|
||||
$status_condition = "{$insurer_or_tpa}" === 'tpa'
|
||||
? "employee_polices.status = 'inactive' AND employees.emp_status = 'inactive'"
|
||||
: "employee_polices.status = 'active' AND employees.emp_status = 'active'";
|
||||
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
|
||||
$query = $this->db->query("
|
||||
SELECT DISTINCT
|
||||
a.id as endorsement_primarykey,
|
||||
@ -659,24 +663,23 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
WHERE employee_polices.client_policy_id = {$client_policy_id}
|
||||
AND employees.client_branch_id = {$client_branch_id}
|
||||
AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
$endorsement_condition
|
||||
AND a.actions = 'd'
|
||||
AND a.status != 'truncated'
|
||||
AND employee_polices.is_active = 1
|
||||
AND employee_polices.status = 'active'
|
||||
AND employees.is_active = 1
|
||||
AND employees.emp_status = 'active'
|
||||
AND $status_condition
|
||||
group by group_key
|
||||
");
|
||||
|
||||
$result = $query->getResult();
|
||||
|
||||
// dd($this->db->getLastQuery(), $result);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function fetchEmpEndorsementData($fetch_data)
|
||||
{
|
||||
// dd($fetch_data);
|
||||
|
||||
@ -43,6 +43,7 @@ class LeadsModel extends Model
|
||||
'proposed_insurer_branch_id',
|
||||
'proposed_tpa_id',
|
||||
'proposed_tpa_branch_id',
|
||||
'proposel_data',
|
||||
'status',
|
||||
'notes',
|
||||
'created_at',
|
||||
@ -119,12 +120,25 @@ class LeadsModel extends Model
|
||||
|
||||
}
|
||||
|
||||
public function getLeadForInsertClientList()
|
||||
public function getLeadForInsertClientList($type = null, $client_id = null)
|
||||
{
|
||||
return $this
|
||||
$query = $this->db->table('leads')
|
||||
->select('leads.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.status', 'won')
|
||||
->findAll();
|
||||
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''");
|
||||
|
||||
if ($type) {
|
||||
$query->where('leads.lead_type', $type);
|
||||
}
|
||||
if ($client_id) {
|
||||
$query->where('leads.client_id', $client_id);
|
||||
}
|
||||
|
||||
$result = $query->get()->getResultArray();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,27 +26,35 @@ class LevelContactModel extends Model
|
||||
];
|
||||
|
||||
|
||||
public function getContectForRFQ(){
|
||||
|
||||
$result = $this
|
||||
|
||||
public function getContactForRFQ($insurer_id = null, $insurer_branch_id = null)
|
||||
{
|
||||
$query =
|
||||
$this->db->table('level_contacts')
|
||||
->select('
|
||||
level_contacts.id,
|
||||
insurers.short_name as insurer_name,
|
||||
insurer_branch.branch_code,
|
||||
level_contacts.name as contect_person_name,
|
||||
level_contacts.email as contect_person_email,
|
||||
level_contacts.name as contact_person_name,
|
||||
level_contacts.email as contact_person_email
|
||||
')
|
||||
->join('insurer_branch', 'level_contacts.ref_id = insurer_branch.id')
|
||||
->join('insurers', 'insurer_branch.insurer_id = insurers.id')
|
||||
->where('level_contacts.contact_type', 'insurer')
|
||||
->where('level_contacts.is_active', 1)
|
||||
->where('insurer_branch.is_active', 1)
|
||||
->where('insurers.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
return $result;
|
||||
->where('insurers.is_active', 1);
|
||||
|
||||
if ($insurer_branch_id) {
|
||||
$query->where('insurer_branch.id', $insurer_branch_id);
|
||||
}
|
||||
if ($insurer_id) {
|
||||
$query->where('insurer_branch.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
$result = $query->get()->getResultArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -57,4 +57,29 @@ class RFQModel extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getRFQTableDataWithLeadIDAndType($lead_id, $type){
|
||||
|
||||
return $this->select('
|
||||
leads.client_name,
|
||||
leads.client_short_name,
|
||||
insurers.name as insurer_name,
|
||||
insurer_branch.branch_name as insurer_branch_name,
|
||||
tpa.name as tpa_name,
|
||||
tpa_branch.branch_name as tpa_branch_name,
|
||||
policy_type.policy_type,
|
||||
rfq.json
|
||||
')
|
||||
->join('leads', 'rfq.lead_id = leads.id')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->join('insurers', 'leads.insurer_id = insurers.id', 'left')
|
||||
->join('insurer_branch', 'leads.insurer_branch_id = insurer_branch.id', 'left')
|
||||
->join('tpa', 'leads.tpa_id = tpa.id', 'left')
|
||||
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->where('rfq.lead_id', $lead_id)
|
||||
->where('rfq.type', $type)
|
||||
->where('rfq.is_active', 1)
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,8 @@ class TPABranchModel extends Model
|
||||
{
|
||||
$query = $this->select('tpa_branch.*, T.short_name as tpa_short_name, T.name as tpa_name')
|
||||
->join('tpa T', 'tpa_branch.tpa_id = T.id', 'left')
|
||||
->where('T.is_active', 1)
|
||||
->where('tpa_branch.is_active', 1)
|
||||
->find();
|
||||
return $query;
|
||||
}
|
||||
|
||||
@ -124,5 +124,15 @@ class UserModel extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserListForRFQ(){
|
||||
|
||||
return $this->db->table('user_profiles')
|
||||
->select('user_profiles.*')
|
||||
->select('roles.role as user_role')
|
||||
->join('roles', 'roles.id = user_profiles.role')
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -71,36 +71,73 @@
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($file['status'] == 'failed') { ?>
|
||||
<?php echo $file['status']; ?> <a
|
||||
href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>"
|
||||
<?php echo $file['status']; ?>
|
||||
|
||||
<a href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>"
|
||||
class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to show the error"></a>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'partially success') { ?>
|
||||
<?php echo $file['status']; ?>
|
||||
<?php if ($file['error_data'] != 0) { ?>
|
||||
|
||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
|
||||
<?php } ?>
|
||||
<?php } else if ($file['status'] == 'failed-1') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the TPA ID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?> "></a>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-2') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the UHID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?>"></a>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-3') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="The Excel record count exceeds the DB record count."></a>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-4') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="Physical File Not Found."></a>
|
||||
<?php } else if ($file['status'] == 'failed-5') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="Wrong File Uploaded"></a>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
|
||||
<?php } else { ?>
|
||||
<?php echo $file['status']; ?>
|
||||
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
|
||||
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ table.dataTable thead th {
|
||||
<option value="">Select Lead</option>
|
||||
<?php if(isset($lead_data)) { ?>
|
||||
<?php foreach ($lead_data as $value) { ?>
|
||||
<option value="<?= $value['id']?>"><?= $value['client_name'] ?></option>
|
||||
<option value="<?= $value['id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
@ -275,7 +275,7 @@ function featchClient(){
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
let client_url = '<?= base_url('client/list/') ?>'+res.client_id;
|
||||
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
|
||||
toastr.success(res.message, 'SUCCESS')
|
||||
window.location.href = client_url
|
||||
}else{
|
||||
@ -294,4 +294,5 @@ function featchClient(){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
|
||||
<div class="row float-right" style="padding-bottom: 10px; position: relative;right: 13px;">
|
||||
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
|
||||
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm" style="position: relative;right: 10px;"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
|
||||
<button type="button" id="BtnAddSuccess" class="btn btn-success waves-effect waves-light BtnAddSuccess btn-sm" onclick="showModal()"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy From Lead</button>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive" id="table_list">
|
||||
@ -193,6 +194,36 @@
|
||||
<?php include('policy_gpa_terms.php'); ?>
|
||||
<?php include('other_policy_terms.php'); ?>
|
||||
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="lead_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Lead List</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="lead_id"> Lead List <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="lead_id" name="lead_id" required>
|
||||
<option value="">Select Lead</option>
|
||||
<?php if(isset($lead_data)) { ?>
|
||||
<?php foreach ($lead_data as $value) { ?>
|
||||
<option value="<?= $value['id']?>" data-clientid="<?= $value['client_id']?>", data-branchid="<?= $value['client_branch_id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary" onclick="featchClient()">Featch Client</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
$('#inception_type').change(function () {
|
||||
@ -394,6 +425,7 @@
|
||||
$('#table_list').hide();
|
||||
$('.btnBack').show();
|
||||
$('.btnAdd').hide();
|
||||
$('.BtnAddSuccess').hide();
|
||||
$('#insurer').val('').change();
|
||||
$('#tpa').val('').change();
|
||||
$('#policy_no').val('').change();
|
||||
@ -426,6 +458,7 @@
|
||||
$('#table_list').show();
|
||||
$('.btnBack').hide();
|
||||
$('.btnAdd').show();
|
||||
$('.BtnAddSuccess').show();
|
||||
$('#insurer').val('').change();
|
||||
$('#tpa').val('').change();
|
||||
$('#policy_no').val('').change();
|
||||
@ -515,6 +548,7 @@
|
||||
$('#table_list').show();
|
||||
$('.btnBack').hide();
|
||||
$('.btnAdd').show();
|
||||
$('.BtnAddSuccess').show();
|
||||
var message = (policy_PrimaryKey === '') ?
|
||||
'Policy Created successfully' : 'Policy Updated Successfully';
|
||||
toastr.success(message, 'Success');
|
||||
@ -695,7 +729,6 @@
|
||||
// get the client policy data for edit
|
||||
$('body').on('click', '.btnPolicyEdit', function() {
|
||||
|
||||
|
||||
var policy_form_action = '';
|
||||
var policy_id = $(this).attr('data-id');
|
||||
|
||||
@ -730,6 +763,7 @@
|
||||
$('#table_list').hide();
|
||||
$('.btnBack').show();
|
||||
$('.btnAdd').hide();
|
||||
$('.BtnAddSuccess').hide();
|
||||
|
||||
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
|
||||
var tpaValue = '';
|
||||
@ -1725,4 +1759,257 @@
|
||||
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
// Check if the URL contains a hash
|
||||
const hash = window.location.hash;
|
||||
|
||||
// If hash is '#police-tab', trigger a click on the tab
|
||||
if (hash === '#police-tab') {
|
||||
$(`a[href="${hash}"]`).click();
|
||||
|
||||
// Get the `client_policy_id` from the URL
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const clientPolicyId = urlParams.get('client_policy_id');
|
||||
|
||||
if (clientPolicyId) {
|
||||
// Call your function with the `client_policy_id`
|
||||
setTimeout(function() {
|
||||
getClientPolicyDataForEdit(clientPolicyId);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function getClientPolicyDataForEdit(client_policy_id){
|
||||
|
||||
var policy_form_action = '';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
fetchClientBranch()
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/policy/list/") ?>' + client_policy_id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('client_policy_res', res);
|
||||
|
||||
var gst = (res.data.gst == 0.00) ? 18 : res.data.gst;
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1100);
|
||||
|
||||
$('#policy_form_action').val('<?= base_url("client/policy/edit"); ?>');
|
||||
|
||||
if (res.status === false) {
|
||||
toastr.error(res.message);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#add_form').show();
|
||||
$('#table_list').hide();
|
||||
$('.btnBack').show();
|
||||
$('.btnAdd').hide();
|
||||
$('.BtnAddSuccess').hide();
|
||||
|
||||
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
|
||||
var tpaValue = '';
|
||||
|
||||
if (res.data.tpa_branch_id && res.data.tpa_id) {
|
||||
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
||||
}
|
||||
|
||||
$('#tpa').val(tpaValue).change();
|
||||
$('#policy_type').val(res.data.policy_type_id).change();
|
||||
$('#base_policy').val(res.data.base_policy);
|
||||
|
||||
$('#policy_type_id').val(res.data.policy_type_id);
|
||||
$('#policy_PrimaryKey').val(res.data.id);
|
||||
$('#insurer_policy_id').val(res.data.policy_id);
|
||||
$('#policy_no').val(res.data.policy_no);
|
||||
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
|
||||
$('#open_date').val(rearrangeDateFormat(res.data.open_date));
|
||||
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
|
||||
$('#close_date').val(rearrangeDateFormat(res.data.close_date));
|
||||
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date));
|
||||
$('#disclaimer').val(res.data.disclaimer);
|
||||
$('#gst_no').val(gst);
|
||||
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
|
||||
$('#policy_status_field').show();
|
||||
|
||||
|
||||
if (res.data.inception_type == 2) {
|
||||
$('#inception_type').prop('checked', true);
|
||||
$('#open_date').parent().show();
|
||||
$('#close_date').parent().show();
|
||||
$('#reminder_date').parent().show();
|
||||
$('.dateofdata').attr('required', true);
|
||||
} else {
|
||||
$('#inception_type').prop('checked', false);
|
||||
$('#open_date').parent().hide();
|
||||
$('#close_date').parent().hide();
|
||||
$('#reminder_date').parent().hide();
|
||||
$('.dateofdata').attr('required', false);
|
||||
}
|
||||
|
||||
|
||||
if (res.data.enrolment_visibility == 1) {
|
||||
$('#policy_visibility').prop('checked', true);
|
||||
} else {
|
||||
$('#policy_visibility').prop('checked', false);
|
||||
}
|
||||
|
||||
|
||||
if (res.data.policy_type_id == '4' || res.data.policy_type_id == '5') {
|
||||
|
||||
$('#base_policy_id').show();
|
||||
$('#base_policy').prop('required', true);
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
$('#third').show();
|
||||
|
||||
} else if (res.data.policy_type_id == '0') {
|
||||
|
||||
$('#first').hide();
|
||||
$('#second').hide();
|
||||
$('#third').hide();
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
|
||||
} else if (res.data.policy_type_id == '1' || res.data.policy_type_id == '2' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
$('#third').show();
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
}else if(res.data.policy_type_id == '3'){
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
$('#third').show();
|
||||
$('#base_policy_id').show();
|
||||
$('#base_policy').prop('required', false);
|
||||
$('#base_danger').hide();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
|
||||
|
||||
$("#insurer").next(".select2-container").css({
|
||||
'pointer-events': 'none',
|
||||
});
|
||||
$('#select2-insurer-container').css({
|
||||
'background-color': '#ebebe0',
|
||||
});
|
||||
|
||||
$("#tpa").next(".select2-container").css({
|
||||
'pointer-events': 'none',
|
||||
});
|
||||
$('#select2-tpa-container').css({
|
||||
'background-color': '#ebebe0',
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
$("#insurer").next(".select2-container").css({
|
||||
'pointer-events': 'auto',
|
||||
});
|
||||
$('#select2-insurer-container').css({
|
||||
'background-color': 'transparent',
|
||||
});
|
||||
|
||||
$("#tpa").next(".select2-container").css({
|
||||
'pointer-events': 'auto',
|
||||
});
|
||||
$('#select2-tpa-container').css({
|
||||
'background-color': 'transparent',
|
||||
});
|
||||
}
|
||||
|
||||
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
$('#tpa').prop('required', false);
|
||||
$('#tpa_danger').hide()
|
||||
} else {
|
||||
$('#tpa').prop('required', true);
|
||||
$('#tpa_danger').show()
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
$('#client_branch').val(res.data.client_branch_id).select2();
|
||||
}, 1000);
|
||||
|
||||
setTimeout(function(){
|
||||
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number
|
||||
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy
|
||||
}, 2000)
|
||||
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
//console.log('Something Wrong!', 'warning');
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showModal(){
|
||||
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function featchClient(){
|
||||
|
||||
let lead_id = $('#lead_id').val();
|
||||
let client_id = $('#lead_id option:selected').data('clientid');
|
||||
let branch_id = $('#lead_id option:selected').data('branchid');
|
||||
console.log('lead_id : ', lead_id)
|
||||
let url = '<?= base_url('leads/featchClientPolicyFromLead/') ?>' + client_id + '/' + branch_id + '/' + lead_id
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
console.log(res);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
|
||||
toastr.success(res.message, 'SUCCESS')
|
||||
window.location.href = client_url;
|
||||
}else{
|
||||
toastr.success(res.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.close').click()
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$('.close').click()
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -445,6 +445,16 @@
|
||||
|
||||
function send_mail_for_individual_employee_ecard(id){
|
||||
|
||||
Swal.fire({
|
||||
title: "Do you want to send Ecard Mail?",
|
||||
showDenyButton: true,
|
||||
showCancelButton: false,
|
||||
confirmButtonText: "Yes,Send",
|
||||
denyButtonText: "Don't Send"
|
||||
}).then((result) => {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
@ -476,5 +486,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -64,7 +64,7 @@ table.dataTable tbody td {
|
||||
<?php foreach($status as $key => $value) { ?>
|
||||
<option value="<?= $key ?>"
|
||||
<?php
|
||||
if ((!isset($getData) || count($getData['status']) == 0) && $key == 'active') {
|
||||
if ((!isset($getData) || count($getData['status']) > 0) && $key == 'active') {
|
||||
echo 'selected';
|
||||
}
|
||||
?>>
|
||||
@ -417,7 +417,7 @@ document.getElementById('toggleIcon').addEventListener('click', function() {
|
||||
|
||||
|
||||
function sendManualEcard(input)
|
||||
{
|
||||
{
|
||||
console.log('sendManualEcard function called');
|
||||
|
||||
var client_id = $('#clients').val()
|
||||
@ -478,6 +478,6 @@ function sendManualEcard(input)
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -554,6 +554,7 @@
|
||||
var policy_value = $('#policy').val()
|
||||
var event_type_data = $('#event_type_data').val();
|
||||
var action_type = $('#action_type').val()
|
||||
var event_type_data = $('#event_type_data').val();
|
||||
|
||||
console.log('policy_value', policy_value)
|
||||
|
||||
@ -570,6 +571,18 @@
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 1){
|
||||
|
||||
$("#event_type").attr("multiple", "multiple");
|
||||
$("#event_type").attr("name", "event_type[]");
|
||||
$("#event_type").select2();
|
||||
|
||||
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 0){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else{
|
||||
if(policy_value != 0){
|
||||
$("#event_type").attr("multiple", "multiple");
|
||||
@ -577,9 +590,10 @@
|
||||
$("#event_type").select2();
|
||||
}
|
||||
}
|
||||
}) ;
|
||||
});
|
||||
|
||||
$('#action_type').change(function(){
|
||||
|
||||
var action_type = $(this).val()
|
||||
var policy_value = $('#policy').val()
|
||||
var insurer_or_tpa = $('#insurer_or_tpa').val()
|
||||
@ -588,6 +602,7 @@
|
||||
|
||||
console.log('policy_value', policy_value)
|
||||
// if(insurer_or_tpa == 'import' || event_type_data == 0){
|
||||
|
||||
if(action_type == 'import'){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
@ -600,6 +615,18 @@
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 1){
|
||||
|
||||
$("#event_type").attr("multiple", "multiple");
|
||||
$("#event_type").attr("name", "event_type[]");
|
||||
$("#event_type").select2();
|
||||
|
||||
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 0){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else{
|
||||
if(policy_value != 0){
|
||||
$("#event_type").attr("multiple", "multiple");
|
||||
@ -607,7 +634,7 @@
|
||||
$("#event_type").select2();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
@ -624,7 +651,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -418,6 +418,7 @@ function getLeadsDataForEdit(input) {
|
||||
$('#renewalDiv').show();
|
||||
$('#freshDiv').hide();
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
$('#policy_end_date, #policy_start_date, #claim').removeAttr('required');
|
||||
} else {
|
||||
$('#renewalDiv').find('select, input').removeAttr('required');
|
||||
$('#freshDiv').find('select, input').attr('required', 'required');
|
||||
@ -495,11 +496,14 @@ function getBranchData(input) {
|
||||
}
|
||||
}
|
||||
|
||||
//Client Policy Data
|
||||
function getPolicyData(input) {
|
||||
var client_policy_id = $(input).val();
|
||||
if (client_policy_id) {
|
||||
// Client Policy Data
|
||||
function getPolicyData(client_policy_id, increment_count) {
|
||||
|
||||
console.log('client_policy_id', client_policy_id);
|
||||
console.log('increment_count', increment_count);
|
||||
|
||||
if (client_policy_id) {
|
||||
// Show loader
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
@ -508,46 +512,71 @@ function getPolicyData(input) {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
console.log('getPolicyData response:', res);
|
||||
|
||||
console.log('getPolicyData response', res);
|
||||
if (res.status === true && res.data) {
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
console.log('Updating fields for row:', i);
|
||||
|
||||
if (res.status == true) {
|
||||
|
||||
$('#gst').val(res.data.gst);
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res.contact.name);
|
||||
$('#contact_person_mobile').val(res.contact.mobile);
|
||||
$('#contact_person_email').val(res.contact.email);
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
const insurer = `${res.data.insurer_branch_id}-${res.data.insurer_id}`;
|
||||
const tpa = `${res.data.tpa_branch_id}-${res.data.tpa_id}`;
|
||||
|
||||
// Update fields with response data
|
||||
$(`#policy_type_id_${i}`).val(res.data.policy_type_id).trigger('change');
|
||||
$(`#insurer_${i}`).val(insurer).trigger('change');
|
||||
$(`#tpa_${i}`).val(tpa).trigger('change');
|
||||
$(`#proposed_insurer_${i}`).val(insurer).trigger('change');
|
||||
$(`#proposed_tpa_${i}`).val(tpa).trigger('change');
|
||||
}
|
||||
} else {
|
||||
console.warn('Invalid response:', res.message || 'Unknown error');
|
||||
|
||||
$('#gst').val('');
|
||||
$('#pan').val('');
|
||||
$('#branch_name').val('');
|
||||
$('#branch_code').val('');
|
||||
$('#contact_person_name').val('');
|
||||
$('#contact_person_mobile').val('');
|
||||
$('#contact_person_email').val('');
|
||||
|
||||
console.log(res.message, 'warning');
|
||||
// Reset fields if response is invalid
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
$(`#policy_type_id_${i}`).val('').trigger('change');
|
||||
$(`#insurer_${i}`).val('').trigger('change');
|
||||
$(`#tpa_${i}`).val('').trigger('change');
|
||||
$(`#proposed_insurer_${i}`).val('').trigger('change');
|
||||
$(`#proposed_tpa_${i}`).val('').trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
// Hide loader
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
console.error('AJAX Error:', xhr.responseText || error);
|
||||
|
||||
// Reset fields on error
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
$(`#policy_type_id_${i}`).val('').trigger('change');
|
||||
$(`#insurer_${i}`).val('').trigger('change');
|
||||
$(`#tpa_${i}`).val('').trigger('change');
|
||||
$(`#proposed_insurer_${i}`).val('').trigger('change');
|
||||
$(`#proposed_tpa_${i}`).val('').trigger('change');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn('Client policy ID is required.');
|
||||
|
||||
// Reset fields if no client policy ID is provided
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
$(`#policy_type_id_${i}`).val('').trigger('change');
|
||||
$(`#insurer_${i}`).val('').trigger('change');
|
||||
$(`#tpa_${i}`).val('').trigger('change');
|
||||
$(`#proposed_insurer_${i}`).val('').trigger('change');
|
||||
$(`#proposed_tpa_${i}`).val('').trigger('change');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Salse team user list data
|
||||
function selecSalsePerson(salse_person_ids) {
|
||||
|
||||
@ -569,7 +598,7 @@ function selecSalsePerson(salse_person_ids) {
|
||||
|
||||
var increment = 1;
|
||||
|
||||
function addHTMLInput() {
|
||||
function addHTMLInput(check) {
|
||||
|
||||
const container = document.getElementById('dynamic-form-container');
|
||||
const newRow = document.createElement('div');
|
||||
@ -598,9 +627,9 @@ function addHTMLInput() {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="insurer">Insurer <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="insurer_${increment}" name="insurer[]" onchange="insurerChange(this, ${increment})" required>
|
||||
<div class="form-group col-md-3 proposed_div">
|
||||
<label for="insurer">Insurer <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="insurer_${increment}" name="insurer[]" onchange="insurerChange(this, ${increment})">
|
||||
<option value="">Select Insurer</option>
|
||||
<?php if (isset($insurer)) { ?>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
@ -612,9 +641,9 @@ function addHTMLInput() {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="tpa">TPA <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="tpa_${increment}" name="tpa[]" onchange="tpaChange(this, ${increment})" required>
|
||||
<div class="form-group col-md-3 proposed_div">
|
||||
<label for="tpa">TPA <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="tpa_${increment}" name="tpa[]" onchange="tpaChange(this, ${increment})">
|
||||
<option value="">Select TPA</option>
|
||||
<?php if (isset($tpa)) { ?>
|
||||
<?php foreach ($tpa as $value) { ?>
|
||||
@ -631,19 +660,19 @@ function addHTMLInput() {
|
||||
<input type="text" class="form-control" id="no_of_lives" name="no_of_lives[]" placeholder="Enter Lives" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" required>
|
||||
<div class="form-group col-md-3 proposed_div">
|
||||
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div">
|
||||
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="claims">Claims <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="claims" name="claims[]" placeholder="Enter Claims" required>
|
||||
<label for="claims">Claims <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="claims" name="claims[]" placeholder="Enter Claims">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -652,8 +681,8 @@ function addHTMLInput() {
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div" style="display: none;">
|
||||
<label for="proposed_insurer">Proposed Insurer <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="proposed_insurer_${increment}" name="proposed_insurer[]" required>
|
||||
<label for="proposed_insurer">Proposed Insurer <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="proposed_insurer_${increment}" name="proposed_insurer[]">
|
||||
<option value="">Select Insurer</option>
|
||||
<?php if (isset($insurer)) { ?>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
@ -666,8 +695,8 @@ function addHTMLInput() {
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div" style="display: none;">
|
||||
<label for="proposed_tpa">Proposed TPA <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="proposed_tpa_${increment}" name="proposed_tpa[]" required>
|
||||
<label for="proposed_tpa">Proposed TPA <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="proposed_tpa_${increment}" name="proposed_tpa[]">
|
||||
<option value="">Select TPA</option>
|
||||
<?php if (isset($tpa)) { ?>
|
||||
<?php foreach ($tpa as $value) { ?>
|
||||
@ -681,7 +710,7 @@ function addHTMLInput() {
|
||||
|
||||
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput()">+</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -691,9 +720,11 @@ function addHTMLInput() {
|
||||
var lead_type = $('#lead_type').val();
|
||||
|
||||
if (lead_type == 2) {
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
$('.proposed_div').show();
|
||||
} else {
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
// $('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
$('.proposed_div').hide()
|
||||
}
|
||||
|
||||
// Scroll the newly added select into view and focus on it
|
||||
@ -724,6 +755,19 @@ function addHTMLInput() {
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
$('#source_policy_id').on('change', function(){
|
||||
let client_policy_id = $(this).val();
|
||||
console.log('client_policy_id', client_policy_id)
|
||||
getPolicyData(client_policy_id, increment)
|
||||
})
|
||||
|
||||
if(check == 1){
|
||||
let client_policy_id = $('#source_policy_id').val();
|
||||
if(client_policy_id){
|
||||
getPolicyData(client_policy_id, increment)
|
||||
}
|
||||
}
|
||||
|
||||
increment++; // Increment after adding the input
|
||||
}
|
||||
|
||||
@ -828,6 +872,9 @@ $('#lead_type').change(function() {
|
||||
$('#freshDiv').find('select, input').removeAttr('required');
|
||||
$('#renewalDiv').show();
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
$('#policy_end_date').removeAttr('required');
|
||||
$('#policy_start_date').removeAttr('required');
|
||||
$('#claims').removeAttr('required');
|
||||
$('#freshDiv').hide();
|
||||
|
||||
$('#gst').val('');
|
||||
|
||||
@ -74,7 +74,7 @@ table.dataTable tbody td {
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php if(isset($lead_data_list) && count($lead_data_list) > 0) { ?>
|
||||
<?php if(isset($lead_data_list)) { ?>
|
||||
<?php foreach($lead_data_list as $index => $row){ ?>
|
||||
<tr>
|
||||
<td><?php echo $index + 1; ?></td>
|
||||
|
||||
32
app/Views/log_content_view.php
Normal file
32
app/Views/log_content_view.php
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>View Log: <?= esc($fileName) ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="form-group col-10">
|
||||
<h3> <?= $server_details['hostname'] . '/' . $server_details['server_name'] . ' - ' ?> Log File: <?= esc($fileName) ?></h3>
|
||||
</div>
|
||||
<div class="form-group col-2">
|
||||
<a href="<?= base_url('util/log_list') ?>" class="btn btn-primary float-md-right">Back to Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<pre style="background-color: #f5f5f5; padding: 15px; border: 1px solid #ccc;">
|
||||
<?= esc($content) ?>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="<?= base_url('util/log_list') ?>">Back to Logs</a>
|
||||
</body>
|
||||
</html>
|
||||
49
app/Views/log_view.php
Normal file
49
app/Views/log_view.php
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
<title>Log Files</title>
|
||||
<style>
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<h3> <?= $server_details['hostname'] . '/' . $server_details['server_name'] . ' - ' ?> Log Files</h3>
|
||||
|
||||
<?php if (session()->getFlashdata('error')): ?>
|
||||
<p style="color: red;"><?= session()->getFlashdata('error') ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>S.No.</th>
|
||||
<th>Log File</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($logs)): ?>
|
||||
<?php foreach ($logs as $index => $log): ?>
|
||||
<tr>
|
||||
<td><?= $index + 1 . '.' ?></td>
|
||||
<td><?= esc($log) ?></td>
|
||||
<td>
|
||||
<a href="<?= base_url('util/view_log/' . urlencode($log)) ?>">View</a> |
|
||||
<a href="<?= base_url('util/download_log/' . urlencode($log)) ?>">Download</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="2">No log files found.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -765,7 +765,8 @@
|
||||
|
||||
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
|
||||
const editorConfig = {
|
||||
buttons: toolbar,
|
||||
buttons: toolbar.concat(['fontsize']),
|
||||
fontsize: [8, 10, 12, 14, 16, 18, 20, 22, 24], // Customize font sizes
|
||||
showPlaceholder: false,
|
||||
toolbarButtonSize: 'small',
|
||||
toolbarAdaptive: false,
|
||||
@ -959,6 +960,14 @@
|
||||
formData.push({ name: 'mailContent', value: mailContent });
|
||||
formData.push({ name: 'client_id', value: $('#general_PrimaryKey').val() });
|
||||
|
||||
formData.forEach(function(item) {
|
||||
if (item.name === 'subject') {
|
||||
// Clean the subject value by removing unwanted characters
|
||||
item.value = item.value.replace(/[Â]/g, "").replace(/[^\x20-\x7E]/g, '');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var form_action = '<?= base_url("client/notification/create") ?>';
|
||||
|
||||
@ -1293,7 +1293,7 @@
|
||||
var index = $('.modifyclassinput').length;
|
||||
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
|
||||
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
|
||||
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 15px;">
|
||||
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 5px;">
|
||||
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
|
||||
</label>
|
||||
<input type="text" name="special_condition_input[]" id="special_condition_input[]" class="form-control s special_condition_input[]">
|
||||
|
||||
@ -705,7 +705,7 @@
|
||||
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
|
||||
|
||||
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
|
||||
<input class="form-control" name="gpa_special_condition_label[]" id="gpa_special_condition_label[]" style="position: relative;right: 15px;">
|
||||
<input class="form-control" name="gpa_special_condition_label[]" id="gpa_special_condition_label[]" style="position: relative;right: 5px;">
|
||||
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
|
||||
</label>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user