Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
25f819fd05
@ -330,6 +330,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getCoShareStatementDetails/(:any)', 'PolicyTransactionController::getCoShareStatementDetails/$1');
|
||||
$routes->get('getClientPolicyDataBasedOnClientAndInsuer', 'PolicyTransactionController::getClientPolicyDataBasedOnClientAndInsuer');
|
||||
$routes->get('checkCDAmountForBasePremium', 'PolicyTransactionController::checkCDAmountForBasePremium');
|
||||
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
|
||||
});
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -377,6 +378,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "LeadsController::createLead");
|
||||
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
|
||||
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
|
||||
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
|
||||
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
|
||||
|
||||
@ -205,9 +205,6 @@ class EmpDataServiceController extends BaseController
|
||||
// Log the export file name
|
||||
$this->myLogger->logme('error', 'Inception export file name : {data}', ['data' => $export_data['file_name']]);
|
||||
|
||||
// remove existing batch file anf batch list data every time export
|
||||
$this->removeOldExportInfoFromBatchFile($export_data);
|
||||
|
||||
// default excel header information
|
||||
$excel_header_columns = [
|
||||
[
|
||||
@ -258,7 +255,7 @@ class EmpDataServiceController extends BaseController
|
||||
[
|
||||
'column_index' => 7,
|
||||
'column_name' => 'DATE OF COVERAGE',
|
||||
'db_column_name' => 'date_coverage'
|
||||
'db_column_name' => 'date_of_coverage'
|
||||
],
|
||||
[
|
||||
'column_index' => 8,
|
||||
@ -368,7 +365,7 @@ class EmpDataServiceController extends BaseController
|
||||
[
|
||||
'column_index' => 7,
|
||||
'column_name' => 'DATE OF COVERAGE',
|
||||
'db_column_name' => 'date_coverage'
|
||||
'db_column_name' => 'date_of_coverage'
|
||||
],
|
||||
[
|
||||
'column_index' => 8,
|
||||
@ -428,14 +425,35 @@ class EmpDataServiceController extends BaseController
|
||||
];
|
||||
}else{
|
||||
// get excel export format structure array
|
||||
$template_json = $this->clientPolicyModel
|
||||
->select('insurer_excel_export_template.jsoncolumns')
|
||||
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
|
||||
->where('client_policy.id', $export_data['client_policy_id'])
|
||||
->where('insurer_excel_export_template.event_name', $export_data['event_type'])
|
||||
->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
|
||||
->where('insurer_excel_export_template.type_name', $export_data['actions'])
|
||||
->first();
|
||||
// $template_json = $this->clientPolicyModel
|
||||
// ->select('insurer_excel_export_template.jsoncolumns')
|
||||
// ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
|
||||
// ->where('client_policy.id', $export_data['client_policy_id'])
|
||||
// ->where('insurer_excel_export_template.event_name', $export_data['event_type'])
|
||||
// ->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
|
||||
// ->where('insurer_excel_export_template.type_name', $export_data['actions'])
|
||||
// ->first();
|
||||
|
||||
$sql = "
|
||||
SELECT `insurer_excel_export_template`.`jsoncolumns`
|
||||
FROM `client_policy`
|
||||
JOIN `insurer_excel_export_template`
|
||||
ON `insurer_excel_export_template`.`insurer_id` = `client_policy`.`insurer_id`
|
||||
AND `insurer_excel_export_template`.`policy_type_id` =
|
||||
CASE
|
||||
WHEN `client_policy`.`policy_type_id` IN (2, 3, 4, 5) THEN 2
|
||||
ELSE `client_policy`.`policy_type_id`
|
||||
END
|
||||
WHERE `client_policy`.`id` = '".$export_data['client_policy_id']."'
|
||||
AND `insurer_excel_export_template`.`event_name` = '".$export_data['event_type']."'
|
||||
AND `insurer_excel_export_template`.`is_active` = 1
|
||||
AND `insurer_excel_export_template`.`type_name` = '".$export_data['actions']."'
|
||||
LIMIT 1";
|
||||
|
||||
$query = db_connect()->query($sql);
|
||||
$template_json = $query->getRowArray();
|
||||
|
||||
// dd(db_connect()->getLastQuery());
|
||||
|
||||
if(!empty($template_json) && $template_json != null){
|
||||
$excel_header_columns = json_decode($template_json['jsoncolumns'], true);
|
||||
@ -444,6 +462,10 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// remove existing batch file anf batch list data every time export
|
||||
$this->removeOldExportInfoFromBatchFile($export_data);
|
||||
|
||||
//convert the excel data based on the insurer
|
||||
$excel_data_info = generate_insurer_based_excel($excel_header_columns, $objects);
|
||||
|
||||
// Generate Excel file
|
||||
@ -1343,7 +1365,7 @@ class EmpDataServiceController extends BaseController
|
||||
// employees.gender AS emp_gender,
|
||||
// employee_polices.pre_existing_alignments,
|
||||
// employee_polices.basic_cover_si,
|
||||
// employee_polices.date_coverage,
|
||||
// employee_polices.date_of_coverage,
|
||||
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
// employees.relationship AS emp_relationship,
|
||||
// employees.change_event AS change_event,
|
||||
@ -1954,12 +1976,14 @@ class EmpDataServiceController extends BaseController
|
||||
->where("employees.is_active", 1)
|
||||
->where("employees.emp_status", "active")
|
||||
->where("emp_endorsement.actions", "c")
|
||||
->where("emp_endorsement.is_active", 1)
|
||||
->where("emp_endorsement.status !=", "truncated")
|
||||
->where("(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')")
|
||||
->findAll();
|
||||
|
||||
|
||||
|
||||
// dd($endorsement_data, $excel_data);
|
||||
dd($endorsement_data, $excel_data);
|
||||
|
||||
|
||||
if ($endorsement_data == null || empty($endorsement_data)) {
|
||||
@ -2253,6 +2277,8 @@ class EmpDataServiceController extends BaseController
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.emp_status', 'active')
|
||||
->where("emp_endorsement.is_active", 1)
|
||||
->where("emp_endorsement.status !=", "truncated")
|
||||
->first();
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
|
||||
@ -32,6 +32,9 @@ use App\Helpers\ExcelMergeHelper;
|
||||
use Google\Service\CloudSearch\PushItem;
|
||||
use Kint;
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
use App\Controllers\JobWorker;
|
||||
|
||||
|
||||
class LeadsController extends BaseController
|
||||
{
|
||||
@ -98,7 +101,7 @@ class LeadsController extends BaseController
|
||||
{
|
||||
|
||||
// $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null);
|
||||
$job_details = new Jobs();
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => ['lead_id' => 24]]);
|
||||
// $d = $this->calculateMembersDemography(['lead_id' => 24]);
|
||||
//$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null);
|
||||
@ -323,6 +326,12 @@ class LeadsController extends BaseController
|
||||
$insert = $this->leadsModel->insert($value);
|
||||
$insertCount[] = $insert;
|
||||
$this->insertLeadStatus($insert, $value['status'], 3);
|
||||
|
||||
//for this push the job to the calculateMembersDemography() function
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [
|
||||
'lead_id' => $insert,
|
||||
]]);
|
||||
}
|
||||
|
||||
if (count($insertCount) > 0) {
|
||||
@ -423,11 +432,13 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
$data['question_json'] = $lead_data['question_json'];
|
||||
$data['page_name'] = isset($data['rfq_data']['type']) && $data['rfq_data']['type'] == 2 ? 'QCR' : 'RFQ';
|
||||
$data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
|
||||
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
$data['userList'] = $this->userModel->getUserListForRFQ();
|
||||
$data['lead_data'] = $lead_data;
|
||||
|
||||
$data['mail_content'] = $this->transformMailContent($id);
|
||||
|
||||
// dd($data);
|
||||
$this->loadLayout('view_rfq.php', $data);
|
||||
}
|
||||
@ -449,7 +460,10 @@ class LeadsController extends BaseController
|
||||
$result = $this->RFQModel->insert($data);
|
||||
|
||||
if ($result) {
|
||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'RFQ created successfully', 'data' => $data], 200);
|
||||
|
||||
$message = "RFQ submitted successfully";
|
||||
if($data['submit_type'] == 'QCR'){ $message = "QCR submitted successfully"; }
|
||||
return $this->respond(['status' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' => $data], 200);
|
||||
@ -492,6 +506,29 @@ class LeadsController extends BaseController
|
||||
public function exportExcelForQCRandRFQ($lead_id, $type)
|
||||
{
|
||||
$filepath = $this->constructExcelToSaveTemp($lead_id, $type);
|
||||
$lead_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
||||
// dd($filepath);
|
||||
|
||||
//Excel merging part
|
||||
if ($lead_data['file_name'] != null && $lead_data['file_name'] != '') {
|
||||
|
||||
$temp_file_path = $filepath['filePath'];
|
||||
$temp_file_name = $filepath['fileName'];
|
||||
$lead_file_path = WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'];
|
||||
|
||||
// dd($lead_data, $temp_file_path, $temp_file_name, $lead_file_path);
|
||||
|
||||
if ($lead_file_path) {
|
||||
$filePaths = [
|
||||
['file_path' => $temp_file_path, 'sheets' => []],
|
||||
['file_path' => $lead_file_path, 'sheets' => []]
|
||||
];
|
||||
// $outputPath = dirname($temp_file_path) . '/' . 'merged_' . $temp_file_name;
|
||||
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $temp_file_path);
|
||||
// print_rr($result);
|
||||
}
|
||||
}
|
||||
|
||||
$filepath = $filepath['filePath'];
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
@ -522,11 +559,51 @@ class LeadsController extends BaseController
|
||||
// dd($rfq_data, $lead_id, $type, $propsal_and_insurer);
|
||||
// print_r($propsal_and_insurer); die;
|
||||
|
||||
$lead_data = [
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Insurer' => $rfq_data['insurer_name'] . ' - ' . $rfq_data['insurer_branch_name'],
|
||||
'TPA' => $rfq_data['tpa_name'] . ' - ' . $rfq_data['tpa_branch_name'],
|
||||
];
|
||||
if($rfq_data['lead_type'] == 1){
|
||||
|
||||
$lead_data = [
|
||||
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Status' => $rfq_data['status'],
|
||||
|
||||
'No of Employees' => $rfq_data['incept_emp_count'],
|
||||
'No of Dependents' => $rfq_data['incept_dept_count'],
|
||||
'Total Lives' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
];
|
||||
|
||||
}else{
|
||||
|
||||
$lead_data = [
|
||||
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Status' => $rfq_data['status'],
|
||||
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
|
||||
'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
|
||||
'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
|
||||
'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
|
||||
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
'Inception Premium' => $rfq_data['premium_at_inception'],
|
||||
'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'],
|
||||
'Earned Premium' => $rfq_data['earned_premium'],
|
||||
'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'],
|
||||
'Annualised Claims' => $rfq_data['annualised_claims'],
|
||||
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'],
|
||||
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'],
|
||||
];
|
||||
}
|
||||
|
||||
$data = json_decode($rfq_data['json'], true);
|
||||
|
||||
@ -538,6 +615,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}else if($type == 1){
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
// dd($data);
|
||||
}
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
@ -1135,14 +1213,18 @@ class LeadsController extends BaseController
|
||||
helper('excel_util_helper');
|
||||
helper('MailHelper');
|
||||
helper('ExcelMergeHelper');
|
||||
$params = $this->request->getGet();
|
||||
$params = $this->request->getPost();
|
||||
|
||||
// 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 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;
|
||||
$mail_content = $params['mail_content'];
|
||||
$mail_subject = $params['subject'];
|
||||
|
||||
$result_data = [];
|
||||
// dd($recipient_mail);
|
||||
@ -1161,9 +1243,10 @@ class LeadsController extends BaseController
|
||||
// print_r($lead_data ); die;
|
||||
|
||||
$cc_mails = [];
|
||||
$bcc_mails = [];
|
||||
|
||||
//get CC Mails
|
||||
if ($recipient_type == 'internal' || $recipient_type == 'placement') {
|
||||
if ($recipient_type == 'internal' || $recipient_type == 'placement' || $recipient_type == 'insurer' || $recipient_type == 'client') {
|
||||
|
||||
$cc_data = isset($params['cc']) ? $params['cc'] : "";
|
||||
$param_cc_mail = json_decode($cc_data, true);
|
||||
@ -1193,6 +1276,37 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
//get BCC Mails
|
||||
if ($recipient_type == 'insurer' || $recipient_type == 'client') {
|
||||
|
||||
$bcc_data = isset($params['bcc']) ? $params['bcc'] : "";
|
||||
$param_bcc_mail = json_decode($bcc_data, true);
|
||||
|
||||
if (isset($param_bcc_mail) && is_array($param_bcc_mail) && count($param_bcc_mail) > 0) {
|
||||
// Fetch user data where ID is in the param_cc_mail array
|
||||
$userData = $this->userModel
|
||||
->where('is_active', 1)
|
||||
->whereIn('id', $param_bcc_mail)
|
||||
->findAll();
|
||||
|
||||
// print_r($userData); die;
|
||||
|
||||
// Extract emails from the fetched user data
|
||||
$bcc_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);
|
||||
}
|
||||
@ -1248,6 +1362,18 @@ class LeadsController extends BaseController
|
||||
$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>';
|
||||
|
||||
//for mail content
|
||||
if(!empty($mail_content)){
|
||||
$original_message = $mail_content;
|
||||
}
|
||||
|
||||
//for mail subject
|
||||
if(!empty($mail_subject)){
|
||||
$subject = $mail_subject;
|
||||
}
|
||||
|
||||
// print_r($subject); die;
|
||||
|
||||
if ($recipient_data) {
|
||||
foreach ($recipient_data as $recipient) {
|
||||
|
||||
@ -1260,7 +1386,7 @@ class LeadsController extends BaseController
|
||||
|
||||
// print_rr($message);calculate_days_bw_dates
|
||||
|
||||
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $cc_mails, '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, 'bcc' => $bcc_mails]);
|
||||
// !dd($res);
|
||||
$result_data[] = ['mail' => $recipient['email'], 'status' => $res];
|
||||
}
|
||||
@ -1434,83 +1560,126 @@ class LeadsController extends BaseController
|
||||
public function convertJsonForQCR($json, $type)
|
||||
{
|
||||
if ($json) {
|
||||
|
||||
// Deep copy of JSON
|
||||
$first_json = json_decode(json_encode($json), true);
|
||||
|
||||
// dd($first_json);
|
||||
|
||||
// Column-wise Check: Remove headers and relevant data if qcr == 0
|
||||
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
|
||||
if($type == 2){
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
// Column-wise Check: Remove headers and relevant data if qcr == 0
|
||||
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
|
||||
|
||||
// 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;
|
||||
}));
|
||||
}
|
||||
if (($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) {
|
||||
|
||||
// Remove proposalKey from over_all_column_data
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
|
||||
|
||||
if($type == 2){
|
||||
// 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'];
|
||||
}));
|
||||
// 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 ($insurer) {
|
||||
return $entry['subth'] !== $insurer['display_name'];
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) {
|
||||
return $entry['parentth'] !== $proposalKey;
|
||||
}));
|
||||
}
|
||||
|
||||
// Remove insurer from proposal's insurers array
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
|
||||
|
||||
// Remove proposalKey from over_all_column_data
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
|
||||
|
||||
if($type == 2){
|
||||
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
|
||||
// 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['qcr'] === 0 || $insurer['qcr'] === false) || ($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 == 2){
|
||||
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;
|
||||
// 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']['qcr']) && $data['input_value']['qcr'] == 0) || (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']);
|
||||
// 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']);
|
||||
|
||||
}else{
|
||||
|
||||
//remove insurer as Subheaders for RFQ
|
||||
foreach ($first_json['table_data']['headers'] as &$header) {
|
||||
$header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) {
|
||||
return in_array($subHeader, ['Quote Asked', '-']);
|
||||
});
|
||||
}
|
||||
|
||||
//Remove insurer Row wise data for RFQ
|
||||
foreach ($first_json['table_data']['data'] as &$row) {
|
||||
|
||||
// Filter the inner data array
|
||||
$row['data'] = array_filter(
|
||||
$row['data'],
|
||||
function ($item) {
|
||||
return in_array($item['subth'], ['Quote Asked', '-']);
|
||||
}
|
||||
);
|
||||
|
||||
$row['data'] = array_values($row['data']);
|
||||
}
|
||||
|
||||
// Ensure to unset the reference after the loop
|
||||
unset($row);
|
||||
|
||||
|
||||
// Remove insurers from Proposal Data key for RFQ
|
||||
foreach ($first_json['proposal_data']['over_all_column_data'] as $key => &$proposal) {
|
||||
if (isset($proposal['insurers'])) {
|
||||
// Set the insurers array to empty
|
||||
$proposal['insurers'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure to reset the reference
|
||||
unset($proposal);
|
||||
|
||||
}
|
||||
|
||||
return $first_json;
|
||||
}
|
||||
@ -1850,8 +2019,54 @@ class LeadsController extends BaseController
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public function transformMailContent()
|
||||
{
|
||||
public function transformMailContent($lead_id)
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
// $params = $this->request->getGet();
|
||||
|
||||
// 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 or internal or placement
|
||||
// $recipient_mail = $params['recipient_mail']; // - only primary key of contacts
|
||||
// $propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
|
||||
|
||||
// if ($recipient_type == 'insurer' && empty($recipient_mail)) {
|
||||
// return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200);
|
||||
// }
|
||||
|
||||
//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', 'left')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
|
||||
->where('leads.id', $lead_id)
|
||||
->first();
|
||||
|
||||
// dd($lead_data);
|
||||
|
||||
if($lead_data){
|
||||
|
||||
$recipient_data = ['name' => "Team"];
|
||||
$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>';
|
||||
|
||||
$message = $original_message;
|
||||
$message = str_replace("{{RECIPIENT_NAME}}", $recipient_data['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) ?? '--';
|
||||
|
||||
// return $this->respond(['status' => true, 'code' => 200, 'data' => $message], 200);
|
||||
return $message;
|
||||
|
||||
}else{
|
||||
|
||||
// return $this->respond(['status' => false, 'code' => 404, 'message' => "This lead has not data"], 200);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,9 @@ class MailHelper
|
||||
//check BCC mail
|
||||
if (isset($params['bcc'])) {
|
||||
$bcc = $params['bcc'];
|
||||
$bcc = explode(',', $bcc);
|
||||
if(!is_array($bcc)){
|
||||
$bcc = explode(',', $bcc);
|
||||
}
|
||||
}else{
|
||||
$bcc = [];
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ if (! function_exists('transform_objects_to_array_for_inception')) {
|
||||
$obj->emp_gender, // Employee Gender
|
||||
$obj->pre_existing_alignments, // Pre-existing Alignments
|
||||
$obj->basic_cover_si, // Basic Cover SI
|
||||
$obj->date_coverage, // Date Coverage
|
||||
$obj->date_of_coverage, // Date Coverage
|
||||
$obj->emp_age, // Employee Age
|
||||
$obj->emp_relationship, // Employee Relationship
|
||||
$obj->change_event, // Change Event
|
||||
@ -260,7 +260,6 @@ if (! function_exists('transform_objects_to_array_for_deletion')) {
|
||||
$obj->total,
|
||||
$claim_status,
|
||||
$endorsement_id
|
||||
|
||||
];
|
||||
|
||||
// Append the row data to the main data array
|
||||
@ -487,7 +486,7 @@ if (!function_exists('format_Excel_BasedOn_Client'))
|
||||
$rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI
|
||||
break;
|
||||
case 'dateofcoverage':
|
||||
$rowData[] = $obj->date_coverage; // DATE OF COVERAGE
|
||||
$rowData[] = $obj->date_of_coverage; // DATE OF COVERAGE
|
||||
break;
|
||||
case 'age':
|
||||
$rowData[] = $obj->emp_age; // Employee AGE
|
||||
|
||||
@ -179,7 +179,11 @@ class EmployeePolicyModel extends Model
|
||||
$result->where('employee_polices.is_active', 1)
|
||||
->where('emp.is_active', 1);
|
||||
|
||||
return $result->findAll();
|
||||
$res = $result->findAll();
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getEmployeePolicyForEcard($policy_id = 0)
|
||||
@ -275,7 +279,7 @@ class EmployeePolicyModel extends Model
|
||||
employee_polices.uhid,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.basic_cover_si,
|
||||
employee_polices.date_coverage,
|
||||
employee_polices.date_coverage as date_of_coverage,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.days as no_of_days,
|
||||
employee_polices.premium,
|
||||
@ -322,6 +326,9 @@ class EmployeePolicyModel extends Model
|
||||
}else{
|
||||
$results = $query->getResult();
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
@ -556,6 +563,175 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
}
|
||||
|
||||
// DO NOT DELETE this DELETION QUERY FUNCTION
|
||||
|
||||
// public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
|
||||
// {
|
||||
|
||||
// $client_id = $ref_data['client_id'];
|
||||
// $client_policy_id = $ref_data['client_policy_id'];
|
||||
// $client_branch_id = $ref_data['client_branch_id'];
|
||||
// $insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
// $get_insurer_id_from_client_policy = $this->db->table('client_policy')
|
||||
// ->select('insurer_id')
|
||||
// ->where('id', $client_policy_id)
|
||||
// ->get()
|
||||
// ->getRowArray();
|
||||
|
||||
// $add_one_day = 0;
|
||||
|
||||
// if (!empty($get_insurer_id_from_client_policy)) {
|
||||
|
||||
// $get_the_insurer_add_one_for_delete = $this->db->table('insurers')
|
||||
// ->select('deletion_add_day')
|
||||
// ->where('id', $get_insurer_id_from_client_policy['insurer_id'])
|
||||
// ->get()
|
||||
// ->getRowArray();
|
||||
|
||||
// if (!empty($get_the_insurer_add_one_for_delete) && $get_the_insurer_add_one_for_delete['deletion_add_day'] == 1) {
|
||||
// $add_one_day = 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $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,
|
||||
// a.group_key,
|
||||
// employee_polices.id as primaryKey,
|
||||
// employees.name AS emp_name,
|
||||
// employees.emp_code AS emp_code,
|
||||
// employees.dob AS emp_dob,
|
||||
// employees.gender AS emp_gender,
|
||||
// employees.relationship AS emp_relationship,
|
||||
// employees.relationship_code AS emp_relationship_code,
|
||||
// employees.emp_type as emp_type,
|
||||
// 'D' as event_type_data,
|
||||
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
|
||||
// employees.doj AS emp_doj,
|
||||
// employees.mobile AS emp_mobile,
|
||||
// employees.email_corporate AS emp_email_c,
|
||||
// employees.email_personal AS emp_email_p,
|
||||
// employees.band AS emp_grade,
|
||||
// employees.designation AS emp_designation,
|
||||
// employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
// employee_polices.basic_cover_si,
|
||||
// employee_polices.uhid as uhid,
|
||||
// employee_polices.policy_end_date,
|
||||
// employee_polices.rata_premimum as premium,
|
||||
// employee_polices.claim_status,
|
||||
|
||||
// batch_data.emp_policy_id AS emp_policy_id,
|
||||
// batch_data.bl AS batch_list_batch_code,
|
||||
// batch_data.bf AS batch_files_batch_code,
|
||||
|
||||
// deletiondata.empstatus,
|
||||
// deletiondata.changeevent,
|
||||
// deletiondata.dateofexit,
|
||||
// deletiondata.reasonforexit,
|
||||
// deletiondata.status,
|
||||
|
||||
// DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
|
||||
|
||||
|
||||
// CASE
|
||||
// WHEN employee_polices.claim_status = 0 THEN
|
||||
// ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
|
||||
// ELSE
|
||||
// 0
|
||||
// END AS pro_rata_premium,
|
||||
|
||||
// CASE
|
||||
// WHEN employee_polices.claim_status = 0 THEN
|
||||
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
|
||||
// ELSE
|
||||
// 0
|
||||
// END AS gst,
|
||||
|
||||
// CASE
|
||||
// WHEN employee_polices.claim_status = 0 THEN
|
||||
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
|
||||
// (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
|
||||
// ELSE
|
||||
// 0
|
||||
// END AS total,
|
||||
|
||||
// CASE
|
||||
// WHEN employee_polices.claim_status = 0 THEN
|
||||
// 'No claim'
|
||||
// ELSE
|
||||
// 'Claim'
|
||||
// END AS claim_status
|
||||
|
||||
// FROM
|
||||
// emp_endorsement a
|
||||
// LEFT JOIN
|
||||
// employees ON a.emp_code = employees.emp_code
|
||||
// LEFT JOIN
|
||||
// employee_polices ON employees.id = employee_polices.employee_id
|
||||
|
||||
// LEFT JOIN(
|
||||
|
||||
// select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
|
||||
|
||||
// ( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
|
||||
// left join
|
||||
// ( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
|
||||
// left join
|
||||
// ( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
|
||||
// left join
|
||||
// ( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
|
||||
// left JOIN
|
||||
// ( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
|
||||
|
||||
// ) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
|
||||
|
||||
// LEFT JOIN
|
||||
// (
|
||||
// SELECT
|
||||
// batch_list.emp_policy_id,
|
||||
// batch_list.batch_code AS bl,
|
||||
// batch_files.batch_code AS bf
|
||||
// FROM
|
||||
// batch_files
|
||||
// LEFT JOIN
|
||||
// batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
// WHERE
|
||||
// batch_files.event_type = 'deletion'
|
||||
// AND batch_files.actions = 'export'
|
||||
// AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
// ) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
|
||||
// WHERE employee_polices.client_policy_id = {$client_policy_id}
|
||||
// AND employees.client_branch_id = {$client_branch_id}
|
||||
// $endorsement_condition
|
||||
// AND a.actions = 'd'
|
||||
// AND a.status != 'truncated'
|
||||
// AND employee_polices.is_active = 1
|
||||
// AND employees.is_active = 1
|
||||
// AND $status_condition
|
||||
// group by group_key
|
||||
// ");
|
||||
|
||||
// if($return_type == 1){
|
||||
// $result = $query->getResultArray();
|
||||
// }else{
|
||||
// $result = $query->getResult();
|
||||
// }
|
||||
|
||||
// // dd($this->db->getLastQuery(), $result);
|
||||
|
||||
// return $result;
|
||||
|
||||
// }
|
||||
|
||||
public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
|
||||
{
|
||||
@ -666,28 +842,31 @@ class EmployeePolicyModel extends Model
|
||||
FROM
|
||||
emp_endorsement a
|
||||
LEFT JOIN
|
||||
employees ON a.emp_code = employees.emp_code and a.pk = employees.id
|
||||
employee_polices ON a.pk = employee_polices.id
|
||||
LEFT JOIN
|
||||
employee_polices ON employees.id = employee_polices.employee_id
|
||||
|
||||
LEFT JOIN(
|
||||
|
||||
select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
|
||||
|
||||
( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
|
||||
left join
|
||||
( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
|
||||
left join
|
||||
( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
|
||||
left join
|
||||
( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
|
||||
left JOIN
|
||||
( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
|
||||
|
||||
) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
|
||||
employees ON employee_polices.employee_id = employees.id
|
||||
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
emp_code,
|
||||
group_key,
|
||||
MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
|
||||
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
|
||||
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
|
||||
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
|
||||
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status
|
||||
FROM
|
||||
emp_endorsement
|
||||
WHERE
|
||||
status != 'truncated'
|
||||
GROUP BY
|
||||
group_key
|
||||
|
||||
) AS deletiondata
|
||||
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
|
||||
|
||||
LEFT JOIN
|
||||
(
|
||||
(
|
||||
SELECT
|
||||
batch_list.emp_policy_id,
|
||||
batch_list.batch_code AS bl,
|
||||
@ -700,7 +879,7 @@ class EmployeePolicyModel extends Model
|
||||
batch_files.event_type = 'deletion'
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
|
||||
WHERE employee_polices.client_policy_id = {$client_policy_id}
|
||||
AND employees.client_branch_id = {$client_branch_id}
|
||||
@ -720,6 +899,7 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery(), $result);
|
||||
// dd($result);
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
@ -60,15 +60,13 @@ class RFQModel extends Model
|
||||
public function getRFQTableDataWithLeadIDAndType($lead_id, $type){
|
||||
|
||||
return $this->select('
|
||||
leads.client_name,
|
||||
leads.client_short_name,
|
||||
leads.*,
|
||||
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,
|
||||
file_name
|
||||
')
|
||||
->join('leads', 'rfq.lead_id = leads.id')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
|
||||
@ -887,7 +887,7 @@ function addHTMLInput(check) {
|
||||
newRow7.innerHTML += `
|
||||
<div class="form-group col-md-3">
|
||||
<label for="file_upload">File Upload<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name[]" accept=".xls,.xlsx" required>
|
||||
<span class="text-danger" id="file_name_display"></span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -1649,6 +1649,13 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
$('#table_tr_3').hide();
|
||||
$('#table_tr_7').hide();
|
||||
$('#table_tr_35').hide();
|
||||
|
||||
setTimeout(function(){
|
||||
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
$(this).val(''); // Clear value
|
||||
console.log('Input cleared:', $(this).attr('name'));
|
||||
});
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
// Handle "Same Insured Name"
|
||||
@ -1820,17 +1827,32 @@ function amountCalculation(input) {
|
||||
console.log(gst_per);
|
||||
}
|
||||
|
||||
console.log('gst_per', gst_per);
|
||||
console.log('igst', igst);
|
||||
console.log('cgst', cgst);
|
||||
console.log('sgst', sgst);
|
||||
|
||||
// Calculate the total premium (Base + TP + Co-Premium)
|
||||
let tpTotal = bp + tp + tep + cop;
|
||||
|
||||
console.log('bp', bp);
|
||||
console.log('tp', tp);
|
||||
console.log('tep', tep);
|
||||
console.log('cop', cop);
|
||||
console.log('tpTotal', tpTotal);
|
||||
|
||||
|
||||
let gst_per_amt = (tpTotal * gst_per) / 100;
|
||||
console.log('gst_per_amt', gst_per_amt);
|
||||
|
||||
|
||||
// $('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
|
||||
$('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00');
|
||||
|
||||
|
||||
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
|
||||
|
||||
// console.log('Summed Amount:', finalTotal);
|
||||
console.log('Summed Amount:', finalTotal);
|
||||
// $('#total_amt_' + input).val(finalTotal.toFixed(2));
|
||||
$('#total_amt_' + input).val(!isNaN(finalTotal) && isFinite(finalTotal) ? finalTotal.toFixed(2) : '0.00');
|
||||
|
||||
@ -3274,6 +3296,12 @@ $('#cop_yes').change(function() {
|
||||
$('#table_tr_3').show()
|
||||
$('#table_tr_7').show()
|
||||
$('#table_tr_35').show()
|
||||
|
||||
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
$(this).val(''); // Clear value
|
||||
console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#add_more_row').addClass('d-none');
|
||||
$('.payby').addClass('d-none');
|
||||
@ -3282,6 +3310,11 @@ $('#cop_yes').change(function() {
|
||||
$('#table_tr_3').hide()
|
||||
$('#table_tr_7').hide()
|
||||
$('#table_tr_35').hide()
|
||||
|
||||
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||||
$(this).val(''); // Clear value
|
||||
console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -3621,6 +3654,10 @@ function addInsurerColumn() {
|
||||
|
||||
if(team_id.includes('4')){
|
||||
|
||||
console.log(
|
||||
'################ TEAM ID 4 insurerTable '+ index + '########################'
|
||||
)
|
||||
|
||||
switch(index) {
|
||||
case 0: // Insurer selection
|
||||
newCell = `<td>
|
||||
@ -3749,6 +3786,10 @@ function addInsurerColumn() {
|
||||
|
||||
}else if(team_id.includes('3')){
|
||||
|
||||
console.log(
|
||||
'################ TEAM ID 3 ########################'
|
||||
)
|
||||
|
||||
switch(index) {
|
||||
case 0: // Insurer selection
|
||||
newCell = `<td>
|
||||
@ -3841,6 +3882,10 @@ function addInsurerColumn() {
|
||||
|
||||
}else if(team_id.includes('6')){
|
||||
|
||||
console.log(
|
||||
'################ TEAM ID 6 ########################'
|
||||
)
|
||||
|
||||
switch(index) {
|
||||
case 0: // Insurer selection
|
||||
newCell = `<td>
|
||||
@ -3971,7 +4016,9 @@ function addInsurerColumn() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('#################################################################');
|
||||
console.log(newCell);
|
||||
console.log('#################################################################');
|
||||
$(this).append(newCell);
|
||||
|
||||
$('#follow_insurer_id_' + insurerCount).select2()
|
||||
@ -4065,6 +4112,10 @@ function populateTable(dataArray) {
|
||||
|
||||
if(team_id.includes('4')){
|
||||
|
||||
console.log(
|
||||
'################ TEAM ID 4 ########################'
|
||||
)
|
||||
|
||||
switch (rowIndex) {
|
||||
case 0: // Insurer selection
|
||||
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
|
||||
@ -4172,6 +4223,10 @@ function populateTable(dataArray) {
|
||||
|
||||
}else if(team_id.includes('3')){
|
||||
|
||||
console.log(
|
||||
'################ TEAM ID 3 ########################'
|
||||
)
|
||||
|
||||
switch (rowIndex) {
|
||||
case 0: // Insurer selection
|
||||
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
|
||||
@ -4236,7 +4291,6 @@ function populateTable(dataArray) {
|
||||
case 20: // Standard Ter %
|
||||
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
|
||||
break;
|
||||
|
||||
case 21: // Co-share ID (hidden field)
|
||||
cell.find('input[type="hidden"]').val(data.id);
|
||||
break;
|
||||
@ -4244,6 +4298,10 @@ function populateTable(dataArray) {
|
||||
|
||||
}else if(team_id.includes('6')){
|
||||
|
||||
console.log(
|
||||
'################ TEAM ID 6 ########################'
|
||||
)
|
||||
|
||||
switch (rowIndex) {
|
||||
case 0: // Insurer selection
|
||||
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user