FEAT_RFQ_NONEB_PRE_FINAL

This commit is contained in:
Srinivas-Saravanan 2025-03-22 07:07:11 +05:30
parent b313309e00
commit 89db5cf085
6 changed files with 1267 additions and 853 deletions

View File

@ -404,6 +404,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) { $routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "LeadsController::createRFQ"); $routes->post("create", "LeadsController::createRFQ");
$routes->post("savePolicyInfo", "LeadsController::savePolicyInfo");
$routes->post("createQCR", "LeadsController::createQCR"); $routes->post("createQCR", "LeadsController::createQCR");
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1"); $routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
$routes->get("nonEB","LeadsController::rfqNonEB"); $routes->get("nonEB","LeadsController::rfqNonEB");

View File

@ -28,6 +28,7 @@ use App\Models\InsurerBranchModel;
use App\Models\TPABranchModel; use App\Models\TPABranchModel;
use App\Models\RFQModel; use App\Models\RFQModel;
use App\Models\InsurerModel; use App\Models\InsurerModel;
use App\Models\OccupancyMasterModel;
use App\Helpers\MailHelper; use App\Helpers\MailHelper;
use App\Helpers\ExcelMergeHelper; use App\Helpers\ExcelMergeHelper;
@ -60,6 +61,7 @@ class LeadsController extends BaseController
protected $tpaBranchModel; protected $tpaBranchModel;
protected $RFQModel; protected $RFQModel;
protected $insurerModel; protected $insurerModel;
protected $occupancyModel;
//variables for storing array //variables for storing array
protected $issuer; protected $issuer;
@ -68,6 +70,7 @@ class LeadsController extends BaseController
protected $leadsStatus; protected $leadsStatus;
protected $claim_type_for_gpa; protected $claim_type_for_gpa;
protected $cause_of_death; protected $cause_of_death;
protected $buisnessType;
public function __construct() public function __construct()
@ -88,10 +91,12 @@ class LeadsController extends BaseController
$this->tpaBranchModel = new TPABranchModel(); $this->tpaBranchModel = new TPABranchModel();
$this->RFQModel = new RFQModel(); $this->RFQModel = new RFQModel();
$this->insurerModel = new InsurerModel(); $this->insurerModel = new InsurerModel();
$this->occupancyModel = new OccupancyMasterModel();
$this->issuer = [1 => 'JIBS', 2 => 'Nhance']; $this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
$this->clientType = [1 => 'Group', 2 => 'Individual']; $this->clientType = [1 => 'Group', 2 => 'Individual'];
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; $this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
$this->leadsStatus = [ $this->leadsStatus = [
'queued' => 'Queued', 'queued' => 'Queued',
'qcr_sent' => 'QCR sent', 'qcr_sent' => 'QCR sent',
@ -113,7 +118,6 @@ class LeadsController extends BaseController
'suicide' => 'Suicide', 'suicide' => 'Suicide',
'accident' => 'Accident' 'accident' => 'Accident'
]; ];
} }
public function viewLeadsList() public function viewLeadsList()
@ -133,10 +137,10 @@ class LeadsController extends BaseController
// dd($lastFiveYears); // dd($lastFiveYears);
if ($this->request->is('get')) { if ($this->request->is('get')) {
// Fetch leads data // Fetch leads data
$data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising(); $data['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
// Load layout and pass data // Load layout and pass data
$this->loadLayout('lead_filter', $data); $this->loadLayout('lead_filter', $data);
}else{ } else {
$search_data = $this->request->getPost(); $search_data = $this->request->getPost();
// print_r($search_data); // print_r($search_data);
@ -190,9 +194,9 @@ class LeadsController extends BaseController
$data['client_code'] = generate_client_code('IC'); $data['client_code'] = generate_client_code('IC');
} }
if(isset($data['lead_form_type'])){ if (isset($data['lead_form_type'])) {
$data = $this->prepareSingleLeadData($data); $data = $this->prepareSingleLeadData($data);
}else{ } else {
$data = $this->prepareMultipleLeadData($data); $data = $this->prepareMultipleLeadData($data);
} }
// print_r($data); die; // print_r($data); die;
@ -210,44 +214,43 @@ class LeadsController extends BaseController
// print_r($files); die; // print_r($files); die;
// Separate the insurer and insurer branch, handle missing or invalid data // Separate the insurer and insurer branch, handle missing or invalid data
if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) { if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) {
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer']); list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer']);
} else {
$insurer_branch_id = 0;
$insurer_id = 0;
}
}else{ $data['insurer_id'] = $insurer_id;
$insurer_branch_id = 0; $data['insurer_branch_id'] = $insurer_branch_id;
$insurer_id = 0;
}
$data['insurer_id'] = $insurer_id; // Separate the insurer and insurer branch, handle missing or invalid data
$data['insurer_branch_id'] = $insurer_branch_id; if (isset($data['tpa']) && strpos($data['tpa'], '-') !== false) {
list($tpa_branch_id, $tpa_id) = explode('-', $data['tpa']);
} else {
$tpa_branch_id = 0;
$tpa_id = 0;
}
// Separate the insurer and insurer branch, handle missing or invalid data $data['tpa_id'] = $tpa_id;
if (isset($data['tpa']) && strpos($data['tpa'], '-') !== false) { $data['tpa_branch_id'] = $tpa_branch_id;
list($tpa_branch_id, $tpa_id) = explode('-', $data['tpa']);
} else {
$tpa_branch_id = 0;
$tpa_id = 0;
}
$data['tpa_id'] = $tpa_id;
$data['tpa_branch_id'] = $tpa_branch_id;
if (!empty($data['policy_start_date'])) { if (!empty($data['policy_start_date'])) {
$data['policy_start_date'] = change_date_format($data['policy_start_date']); $data['policy_start_date'] = change_date_format($data['policy_start_date']);
} else { } else {
$data['policy_start_date'] = null; $data['policy_start_date'] = null;
} }
if (!empty($data['policy_end_date'])) { if (!empty($data['policy_end_date'])) {
$data['policy_end_date'] = change_date_format($data['policy_end_date']); $data['policy_end_date'] = change_date_format($data['policy_end_date']);
} else { } else {
$data['policy_end_date'] = null; $data['policy_end_date'] = null;
} }
$data['file_name'] = file_Upload($files, $uploadFilePath); $data['file_name'] = file_Upload($files, $uploadFilePath);
$processcedData[] = $data; $processcedData[] = $data;
// print_r($data);die(); // print_r($data);die();
return $processcedData; return $processcedData;
@ -264,13 +267,12 @@ class LeadsController extends BaseController
// print_r($files); die; // print_r($files); die;
foreach($data['policy_type_id'] as $index => $value){ foreach ($data['policy_type_id'] as $index => $value) {
// Separate the insurer and insurer branch, handle missing or invalid data // Separate the insurer and insurer branch, handle missing or invalid data
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) { if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]); list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]);
} else {
}else{
$insurer_branch_id = 0; $insurer_branch_id = 0;
$insurer_id = 0; $insurer_id = 0;
} }
@ -310,15 +312,15 @@ class LeadsController extends BaseController
$policy_end_date = null; $policy_end_date = null;
} }
if(!empty($data['incurred_claim_date'][$index])){ if (!empty($data['incurred_claim_date'][$index])) {
$incurred_claims_date = change_date_format($data['incurred_claim_date'][$index], 'd/m/Y', 'Y-m-d'); $incurred_claims_date = change_date_format($data['incurred_claim_date'][$index], 'd/m/Y', 'Y-m-d');
}else{ } else {
$incurred_claims_date = null; $incurred_claims_date = null;
} }
if(!empty($data['premium_date'][$index])){ if (!empty($data['premium_date'][$index])) {
$premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d'); $premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
}else{ } else {
$premium_date = null; $premium_date = null;
} }
@ -406,7 +408,7 @@ class LeadsController extends BaseController
$insertCount[] = $insert; $insertCount[] = $insert;
$this->insertLeadStatus($insert, $value['status'], 3); $this->insertLeadStatus($insert, $value['status'], 3);
if($value['lead_form_type'] == 1){ if ($value['lead_form_type'] == 1) {
//for this push the job to the calculateMembersDemography() function //for this push the job to the calculateMembersDemography() function
$job_details = new Jobs(); $job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [ $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [
@ -441,9 +443,9 @@ class LeadsController extends BaseController
->first(); ->first();
$data['lead_edit_data'] = $this->leadsModel $data['lead_edit_data'] = $this->leadsModel
->where('leads.id', $id) ->where('leads.id', $id)
->where('leads.is_active', 1) ->where('leads.is_active', 1)
->first(); ->first();
if (!empty($data['policy_start_date'])) { if (!empty($data['policy_start_date'])) {
@ -509,18 +511,18 @@ class LeadsController extends BaseController
{ {
$data['rfq_data'] = $this->RFQModel $data['rfq_data'] = $this->RFQModel
->where('lead_id', $id) ->where('lead_id', $id)
// ->where('type', $type) // ->where('type', $type)
->where('is_active', 1) ->where('is_active', 1)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->first(); ->first();
// dd($data); // dd($data);
$data['rfq_count'] = $this->RFQModel $data['rfq_count'] = $this->RFQModel
->where('lead_id', $id) ->where('lead_id', $id)
// ->where('type', 1) // ->where('type', 1)
->where('is_active', 1) ->where('is_active', 1)
->countAllResults(); ->countAllResults();
$data['qcr_count'] = $this->RFQModel $data['qcr_count'] = $this->RFQModel
->where('lead_id', $id) ->where('lead_id', $id)
@ -532,18 +534,18 @@ class LeadsController extends BaseController
$data['lead_id'] = $id; $data['lead_id'] = $id;
$lead_data = $this->leadsModel $lead_data = $this->leadsModel
->select(' ->select('
leads.*, leads.*,
policy_type.question_json, policy_type.question_json,
policy_type.policy_type, policy_type.policy_type,
policy_type.long_name, policy_type.long_name,
user_profiles.email as created_person_email user_profiles.email as created_person_email
') ')
->join('policy_type', 'leads.policy_type_id = policy_type.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id')
->join('user_profiles', 'leads.created_by = user_profiles.id', 'left') ->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
->where('leads.id', $id) ->where('leads.id', $id)
->where('leads.is_active', 1) ->where('leads.is_active', 1)
->first(); ->first();
// dd($lead_data); // dd($lead_data);
@ -575,21 +577,52 @@ class LeadsController extends BaseController
// dd($data); // dd($data);
if ($data['lead_data']['lead_form_type'] == 1){ if ($data['lead_data']['lead_form_type'] == 1) {
$this->loadLayout('view_rfq.php', $data); $this->loadLayout('view_rfq.php', $data);
} else if ($data['lead_data']['lead_form_type'] == 2) {
}else if ($data['lead_data']['lead_form_type'] == 2){ $data['occupancy'] = $this->occupancyModel->findAll();
// dd($data['occupancy']);
$data['policies'] = json_decode($data['question_json'], true)['policies']; $data['policies'] = json_decode($data['question_json'], true)['policies'];
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data']; $data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']); // $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
// dd($data['lead_register_data']); // dd($data['lead_register_data']);
$data['client_type'] = $this->clientType; $data['client_type'] = $this->clientType;
$data['buisness_type'] = $this->buisnessType;
$this->loadLayout('view_rfq_non_eb', $data); $this->loadLayout('view_rfq_non_eb', $data);
} }
}
public function savePolicyInfo()
{
$data = $this->request->getPost();
$lead_id = $data['lead_id'];
$json_data = $data['registration_json'];
$existingJson = $this->RFQModel->where('is_active', 1)->where("lead_id", $lead_id)->first()['registration_json'] ?? null;
if (empty($existingJson)) {
$this->RFQModel
->where('lead_id', $lead_id)
->where('type', 1)
->where('is_active', 1)
->set('is_active', 0)
->update();
$insertData['lead_id'] = $lead_id;
$insertData['registration_json'] = json_encode($json_data);
$this->RFQModel->insert($insertData);
return $this->respond(['status' => true, "message" => "Policy Inforamtion saved"]);
} else {
return $this->respond(['status' => true, "message" => "Policy Inforamtion Already saved"]);
}
} }
@ -608,12 +641,37 @@ class LeadsController extends BaseController
->set('is_active', 0) ->set('is_active', 0)
->update(); ->update();
$result = $this->RFQModel->insert($data); $registrationJson = $data['registration_json'] ?? null; // Use null coalescing operator for safety
if ($registrationJson) {
// If registration_json is provided, insert the data directly
$result = $this->RFQModel->insert($data);
} else {
// If registration_json is not provided, fetch the latest registration_json from the database
$this->RFQModel->select('registration_json')
->where("lead_id", $lead_id)
->order_by('id', 'DESC') // Assuming 'id' is an auto-increment field
->limit(1);
$query = $this->RFQModel->get();
$latestRegistrationJson = $query->row()->registration_json ?? null;
if ($latestRegistrationJson) {
// If a valid registration_json is found, update the data and insert
$data['registration_json'] = $latestRegistrationJson;
$result = $this->RFQModel->insert($data);
} else {
// If no registration_json is found, insert the data as-is
$result = $this->RFQModel->insert($data);
}
}
if ($result) { if ($result) {
$message = "RFQ submitted successfully"; $message = "RFQ submitted successfully";
if($data['submit_type'] == 'QCR'){ $message = "QCR 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' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200);
} }
@ -656,9 +714,9 @@ class LeadsController extends BaseController
//FOR EXCEL //FOR EXCEL
public function exportExcelForQCRandRFQ($lead_id, $type, $lead_form_type = 1) public function exportExcelForQCRandRFQ($lead_id, $type, $lead_form_type = 1)
{ {
if($lead_form_type == 2){ if ($lead_form_type == 2) {
$filepath = $this->constructNonEbExcelToSaveTemp($lead_id, $type); $filepath = $this->constructNonEbExcelToSaveTemp($lead_id, $type);
}else{ } else {
$filepath = $this->constructExcelToSaveTemp($lead_id, $type); $filepath = $this->constructExcelToSaveTemp($lead_id, $type);
} }
@ -1229,16 +1287,16 @@ class LeadsController extends BaseController
echo "Filename: " . $result['filename'] . "\n"; echo "Filename: " . $result['filename'] . "\n";
$filePaths = [ $filePaths = [
['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]], ['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]],
['file_path' => WRITEPATH.'/uploads/lead_files/' . $result['filename'], 'sheets' => []], ['file_path' => WRITEPATH . '/uploads/lead_files/' . $result['filename'], 'sheets' => []],
]; ];
$outputPath = WRITEPATH . 'uploads/lead_files/Member_Data.xlsx'; $outputPath = WRITEPATH . 'uploads/lead_files/Member_Data.xlsx';
$result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); $result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
if ($result_merge) { if ($result_merge) {
// Call the delete function after the file is successfully created // Call the delete function after the file is successfully created
$deleteResponse = $this->deleteGeneratedFile($result['fullpath']); $deleteResponse = $this->deleteGeneratedFile($result['fullpath']);
// Add delete message to response // Add delete message to response
$response['deleteMessage'] = $deleteResponse['message']; $response['deleteMessage'] = $deleteResponse['message'];
return ['status' => 'success', 'message' => 'Member_Data Merged Suceesfully']; return ['status' => 'success', 'message' => 'Member_Data Merged Suceesfully'];
} }
} else { } else {
@ -1530,7 +1588,6 @@ class LeadsController extends BaseController
]; ];
return $response; return $response;
} catch (Exception $e) { } catch (Exception $e) {
return [ return [
'success' => false, 'success' => false,
@ -1709,14 +1766,14 @@ class LeadsController extends BaseController
//get file path to attach //get file path to attach
if($lead_data["lead_form_type"] == 2){ if ($lead_data["lead_form_type"] == 2) {
$file_info = $this->constructNonEbExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer); $file_info = $this->constructNonEbExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer);
}else{ } else {
$file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer); $file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer);
} }
// $file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer); // $file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer);
log_message('error','File Info'.json_encode($file_info)); log_message('error', 'File Info' . json_encode($file_info));
if ($lead_data['file_name'] != null && $lead_data['file_name'] != '') { if ($lead_data['file_name'] != null && $lead_data['file_name'] != '') {
$temp_file_path = $file_info['filePath']; $temp_file_path = $file_info['filePath'];
$temp_file_name = $file_info['fileName']; $temp_file_name = $file_info['fileName'];
@ -1730,7 +1787,7 @@ class LeadsController extends BaseController
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); $result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
// print_rr($result); // print_rr($result);
} }
}else{ } else {
$result = $file_info['filePath']; $result = $file_info['filePath'];
// return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200); // return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200);
} }
@ -1767,12 +1824,12 @@ class LeadsController extends BaseController
$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>'; $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 //for mail content
if(!empty($mail_content)){ if (!empty($mail_content)) {
$original_message = $mail_content; $original_message = $mail_content;
} }
//for mail subject //for mail subject
if(!empty($mail_subject)){ if (!empty($mail_subject)) {
$subject = $mail_subject; $subject = $mail_subject;
} }
@ -1972,7 +2029,7 @@ class LeadsController extends BaseController
$first_json = json_decode(json_encode($json), true); $first_json = json_decode(json_encode($json), true);
// dd($first_json); // dd($first_json);
if($type == 2){ if ($type == 2) {
// Column-wise Check: Remove headers and relevant data if qcr == 0 // Column-wise Check: Remove headers and relevant data if qcr == 0
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) { foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
@ -1996,7 +2053,7 @@ class LeadsController extends BaseController
// Remove proposalKey from over_all_column_data // Remove proposalKey from over_all_column_data
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]); unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
if($type == 2){ if ($type == 2) {
// Remove proposalKey from premium_data // Remove proposalKey from premium_data
unset($first_json['premium_data']['data'][$proposalKey]); unset($first_json['premium_data']['data'][$proposalKey]);
} }
@ -2004,7 +2061,7 @@ class LeadsController extends BaseController
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0 // Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
foreach ($proposalData['insurers'] as $insurerIndex => $insurer) { foreach ($proposalData['insurers'] as $insurerIndex => $insurer) {
if (($insurer['qcr'] === 0 || $insurer['qcr'] === false) || ($insurer['stc'] === 0 || $insurer['stc'] === false) ) { if (($insurer['qcr'] === 0 || $insurer['qcr'] === false) || ($insurer['stc'] === 0 || $insurer['stc'] === false)) {
foreach ($first_json['table_data']['headers'] as &$header) { foreach ($first_json['table_data']['headers'] as &$header) {
if (isset($header['subHeaders'])) { if (isset($header['subHeaders'])) {
$header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) { $header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) {
@ -2023,7 +2080,7 @@ class LeadsController extends BaseController
// Remove insurer from proposal's insurers array // Remove insurer from proposal's insurers array
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]); unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
if($type == 2){ if ($type == 2) {
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]); unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
} }
} }
@ -2047,8 +2104,7 @@ class LeadsController extends BaseController
$proposal['insurers'] = array_values($proposal['insurers']); $proposal['insurers'] = array_values($proposal['insurers']);
return $proposal; return $proposal;
}, $first_json['proposal_data']['over_all_column_data']); }, $first_json['proposal_data']['over_all_column_data']);
} else {
}else{
//remove insurer as Subheaders for RFQ //remove insurer as Subheaders for RFQ
foreach ($first_json['table_data']['headers'] as &$header) { foreach ($first_json['table_data']['headers'] as &$header) {
@ -2085,7 +2141,6 @@ class LeadsController extends BaseController
// Ensure to reset the reference // Ensure to reset the reference
unset($proposal); unset($proposal);
} }
return $first_json; return $first_json;
@ -2366,7 +2421,6 @@ class LeadsController extends BaseController
$message = str_replace("{{POLICY_YEAR}}", $policy_year, $message); $message = str_replace("{{POLICY_YEAR}}", $policy_year, $message);
return $message; return $message;
} else { } else {
return ''; // Return empty if no lead data found return ''; // Return empty if no lead data found
} }
@ -2496,7 +2550,7 @@ class LeadsController extends BaseController
->where('user_teams.team_id', 5) ->where('user_teams.team_id', 5)
->where('user_teams.is_active', 1) ->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1) ->where('user_profiles.is_active', 1)
->findAll(); ->findAll();
if (!empty($id)) { if (!empty($id)) {
$data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first() ?? []; $data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first() ?? [];
@ -2525,12 +2579,11 @@ class LeadsController extends BaseController
$data['lead_edit_data']['policy_type_id'] ?? null, $data['lead_edit_data']['policy_type_id'] ?? null,
$data $data
) ?? ""; ) ?? "";
} }
if($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2){ if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) {
$data['lead_edit_data']['claims_details_html'] = view('rfq/claims_details_non_eb', $data['lead_edit_data']); $data['lead_edit_data']['claims_details_html'] = view('rfq/claims_details_non_eb', $data['lead_edit_data']);
}else{ } else {
$data['lead_edit_data']['claims_details_html'] = ""; $data['lead_edit_data']['claims_details_html'] = "";
} }
} }
@ -2547,12 +2600,11 @@ class LeadsController extends BaseController
$html = $this->generateViewPageHtml($policy_type_id) ?? ""; $html = $this->generateViewPageHtml($policy_type_id) ?? "";
if(!empty($html)){ if (!empty($html)) {
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Type FIELDS are found', 'data' => $html], 200); return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Type FIELDS are found', 'data' => $html], 200);
}else{ } else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Fields not found for this policy type'], 200); return $this->respond(['status' => false, 'code' => 400, 'message' => 'Fields not found for this policy type'], 200);
} }
} }
public function generateViewPageHtml($policy_type_id, $data = []) public function generateViewPageHtml($policy_type_id, $data = [])
@ -2561,13 +2613,28 @@ class LeadsController extends BaseController
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
$viewMap = [ $viewMap = [
1 => 'rfq/gpa', 6 => 'rfq/gpa', 7 => 'rfq/gpa', 1 => 'rfq/gpa',
2 => 'rfq/gmc', 3 => 'rfq/gmc', 4 => 'rfq/gmc', 5 => 'rfq/gmc', 6 => 'rfq/gpa',
22 => 'rfq/car', 23 => 'rfq/cpm', 24 => 'rfq/cyber_crime', 7 => 'rfq/gpa',
25 => 'rfq/do', 27 => 'rfq/eo', 49 => 'rfq/money', 2 => 'rfq/gmc',
19 => 'rfq/cgl', 59 => 'rfq/sfsp', 63 => 'rfq/wc', 3 => 'rfq/gmc',
15 => 'rfq/blu', 16 => 'rfq/bsu', 4 => 'rfq/gmc',
44 => 'rfq/marine', 45 => 'rfq/marine', 46 => 'rfq/marine', 47 => 'rfq/marine', 5 => 'rfq/gmc',
22 => 'rfq/car',
23 => 'rfq/cpm',
24 => 'rfq/cyber_crime',
25 => 'rfq/do',
27 => 'rfq/eo',
49 => 'rfq/money',
19 => 'rfq/cgl',
59 => 'rfq/sfsp',
63 => 'rfq/wc',
15 => 'rfq/blu',
16 => 'rfq/bsu',
44 => 'rfq/marine',
45 => 'rfq/marine',
46 => 'rfq/marine',
47 => 'rfq/marine',
50 => 'rfq/office' 50 => 'rfq/office'
]; ];
@ -2903,134 +2970,132 @@ class LeadsController extends BaseController
public function convertNonEbJsonForQCR($jsonArr, $type, $proposeldata) public function convertNonEbJsonForQCR($jsonArr, $type, $proposeldata)
{ {
$first_json = $jsonArr; $first_json = $jsonArr;
$first_json = array_merge($first_json, $proposeldata); $first_json = array_merge($first_json, $proposeldata);
if($type == 2){ if ($type == 2) {
// Column-wise Check: Remove headers and relevant data if qcr == 0 // Column-wise Check: Remove headers and relevant data if qcr == 0
foreach ($first_json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) { foreach ($first_json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
if (($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) { if (($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) {
// Remove matching parentHeader in headers // Remove matching parentHeader in headers
foreach ($first_json['table_data']['headers'] as $index => $header) { foreach ($first_json['table_data']['headers'] as $index => $header) {
if ($header['parentHeader'] === $proposalKey) { if ($header['parentHeader'] === $proposalKey) {
unset($first_json['table_data']['headers'][$index]); 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 == 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['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'];
}));
} }
} }
// Remove data entries with matching parentth
foreach ($first_json['table_data']['data'] as &$item) { foreach ($first_json['table_data']['data'] as &$item) {
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) { $item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) {
return $entry['parentth'] !== $proposalKey; return $entry['subth'] !== $insurer['display_name'];
})); }));
} }
// Remove proposalKey from over_all_column_data // Remove insurer from proposal's insurers array
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]); unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
if($type == 2){ if ($type == 2) {
// Remove proposalKey from premium_data unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
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 (
isset($data['parentth']) && $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; // Stop checking other columns for this row
}
}
}
// 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) {
// Ensure 'subHeaders' exists and is an array before filtering
if (isset($header['subHeaders']) && is_array($header['subHeaders'])) {
$header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) {
return in_array($subHeader, ['Quote asked', '-'], true);
});
}
}
//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 ($proposeldata['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;
// 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 (
isset($data['parentth']) && $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; // Stop checking other columns for this row
}
}
}
// 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) {
// Ensure 'subHeaders' exists and is an array before filtering
if (isset($header['subHeaders']) && is_array($header['subHeaders'])) {
$header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) {
return in_array($subHeader, ['Quote asked', '-'], true);
});
}
}
//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 ($proposeldata['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;
return null; return null;
} }

View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class OccupancyMasterModel extends Model
{
protected $table = 'occupancy_master';
protected $allowedFields = [
'id',
'iib_code',
'section',
'description',
'iib_loss_rate',
'created_by',
'created_at',
'is_active'
];
}

View File

@ -17,6 +17,7 @@ class RFQModel extends Model
'type', 'type',
'lead_id', 'lead_id',
'json', 'json',
"registration_json",
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',

File diff suppressed because it is too large Load Diff

View File

@ -243,8 +243,8 @@
<select class="form-control" id="to" name="to" required> <select class="form-control" id="to" name="to" required>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['email'];?>"> <option value="<?= $user['email']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -256,8 +256,8 @@
<select class="form-control" id="cc" name="cc" required multiple> <select class="form-control" id="cc" name="cc" required multiple>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>"> <option value="<?= $user['id']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -278,7 +278,7 @@
</div> </div>
<br> <br>
<div class="form-group text-right m-b-0" id="hide_smbt_btn"> <div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button> <button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
</div> </div>
</div> </div>
</div><!-- /.modal-content --> </div><!-- /.modal-content -->
@ -300,7 +300,7 @@
<!-- For display perpose placement alredy submited text display --> <!-- For display perpose placement alredy submited text display -->
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label><span id="alert_msg"class="text-danger"></span></label> <label><span id="alert_msg" class="text-danger"></span></label>
</div> </div>
<div class="form-row"> <div class="form-row">
@ -335,16 +335,16 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="proposals"> Proposals/Insurer <span id="base_danger"class="text-danger">*</span></label> <label for="proposals"> Proposals/Insurer <span id="base_danger" class="text-danger">*</span></label>
<select class="form-control" id="proposals"name="proposals" onchange="getInsurerBranchContacts(this)" required> <select class="form-control" id="proposals" name="proposals" onchange="getInsurerBranchContacts(this)" required>
<option value="" >Select Proposals</option> <option value="">Select Proposals</option>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="placement_to"> To <span id="base_danger"class="text-danger">*</span></label> <label for="placement_to"> To <span id="base_danger" class="text-danger">*</span></label>
<select class="form-control" id="placement_to" name="placement_to" required> <select class="form-control" id="placement_to" name="placement_to" required>
<option value="" >Select To Mail</option> <option value="">Select To Mail</option>
</select> </select>
</div> </div>
@ -353,8 +353,8 @@
<select class="form-control" id="placement_cc" name="placement_cc" required multiple> <select class="form-control" id="placement_cc" name="placement_cc" required multiple>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>"> <option value="<?= $user['id']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -403,11 +403,18 @@
} }
}; };
var suggestions = {}; var suggestions = {};
var storedData = JSON.parse(localStorage.getItem('policyData')); var policyInformationData = <?= isset($rfq_data['registration_json']) ? json_encode($rfq_data['registration_json'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : '""' ?>;
var policySummary; var storedData = {};
if (!$.isEmptyObject(storedData)) { console.log("stored data : ", typeof(policyInformationData))
policySummary = addPolicySummaryTable(storedData);
if (policyInformationData.length) {
localStorage.setItem('policyData', (policyInformationData));
storedData = policyInformationData;
} }
var policySummary = [];
console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes") console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes")
$(document).ready(function() { $(document).ready(function() {
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
@ -482,37 +489,7 @@
1: ['Quote asked'] 1: ['Quote asked']
}; // Stores quote columns for each proposal }; // Stores quote columns for each proposal
// Generate a random quote code (e.g., abc123)
function generateRandomCode() {
const chars = 'abcdefghijklmnopqrstuvwxyz';
const nums = '0123456789';
return Array.from({
length: 3
}, () => chars[Math.floor(Math.random() * 26)]).join('') +
Array.from({
length: 3
}, () => nums[Math.floor(Math.random() * 10)]).join('');
}
// Add a new quote column to a specific proposal
// function addNewQuote(proposalNumber) {
// console.log("this doesnt work");
// let increaseBy = 25;
// increaseTableWidth(increaseBy)
// console.log('ADD NEW QUOTE proposalNumber' + proposalNumber);
// console.log('ADD NEW QUOTE overall quotesConfig');
// console.log(quotesConfig);
// if (!quotesConfig[proposalNumber]) {
// quotesConfig[proposalNumber] = ['Quote asked']; // Initialize with default quote
// }
// const newQuote = generateRandomCode();
// quotesConfig[proposalNumber].push(newQuote); // Add new quote to the proposal
// // Update all tables (parent and child) with the new quote column
// updateAllTables(proposalNumber, newQuote);
// // hideProposalOptionsForChild();
// }
// Update all tables with the new quote column // Update all tables with the new quote column
function updateAllTables_old(proposalNumber, newQuote) { function updateAllTables_old(proposalNumber, newQuote) {
@ -722,6 +699,7 @@
// console.log('Row id for excess table',rowId); // console.log('Row id for excess table',rowId);
$("#excess .three-dot-menu").hide(); $("#excess .three-dot-menu").hide();
moveExcessTableLast(); moveExcessTableLast();
} }
} else { } else {
// Handle regular table // Handle regular table
@ -729,6 +707,9 @@
generateTable(childContainer, true, rowId, childTable); generateTable(childContainer, true, rowId, childTable);
// console.log('Row id for excess table', rowId); // console.log('Row id for excess table', rowId);
$(childContainer).find(".three-dot-menu").hide(); $(childContainer).find(".three-dot-menu").hide();
// alert(`${rowId.toUpperCase()}_register`);
$(`#${rowId.toUpperCase()}_register`).prop("disabled", false);
moveExcessTableLast(); moveExcessTableLast();
} }
}); });
@ -738,7 +719,10 @@
container.appendChild(childContainer); container.appendChild(childContainer);
} }
arrangeTables(); arrangeTables();
alignTableColumn();
} else { } else {
console.log('UNCHECKED:', rowId); console.log('UNCHECKED:', rowId);
selectedPolicies.delete(rowId); selectedPolicies.delete(rowId);
@ -747,6 +731,7 @@
regularContainers.forEach(container => { regularContainers.forEach(container => {
console.log(" contaitner ", container); console.log(" contaitner ", container);
$(`#${rowId.toUpperCase()}_register`).prop("disabled", true);
container.remove(); container.remove();
}); });
console.log("row id ", rowId); console.log("row id ", rowId);
@ -1134,6 +1119,10 @@
${newQuote} ${newQuote}
<span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span> <span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span>
<div class="dropdown-content"> <div class="dropdown-content">
<button id = "isInsurerSTC" class="sendInsurerClientProposal" onclick = "addOrRemoveIconInsurer(this,event)"
style="background-color: rgb(221, 221, 221);">Send to Client <i
class="fa fa-check-square"
style="color: green; margin-left: 8px; "></i></button>
<button onclick="changeInsurer(event, ${proposalNumber}, '${newQuote}')">Change Insurer</button> <button onclick="changeInsurer(event, ${proposalNumber}, '${newQuote}')">Change Insurer</button>
<button onclick="removeQuote(event, ${proposalNumber}, '${newQuote}')">Remove Quote</button> <button onclick="removeQuote(event, ${proposalNumber}, '${newQuote}')">Remove Quote</button>
</div> </div>
@ -1183,7 +1172,7 @@
const headerRow1 = document.createElement('tr'); const headerRow1 = document.createElement('tr');
headerRow1.innerHTML = headerRow1.innerHTML =
` `
${isChildTable ? '<th>S.NO</th>' : '<th><input type="checkbox"></th>'} ${isChildTable ? '<th>S.NO</th>' : '<th>Policy</th>'}
<th>${tableName}</th> <th>${tableName}</th>
${Object.keys(quotesConfig).map(proposal => ` ${Object.keys(quotesConfig).map(proposal => `
<th data-proposal="${proposal}" colspan="${quotesConfig[proposal].length}"> <th data-proposal="${proposal}" colspan="${quotesConfig[proposal].length}">
@ -1210,13 +1199,15 @@
<th>-</th> <th>-</th>
${Object.entries(quotesConfig).flatMap(([proposal, codes]) => ${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
codes.map(code => ` codes.map(code => `
<th data-proposal="${proposal}" data-quote="${code}"> <th data-proposal="${proposal}" data-quote="${code}"
${code} class="${code !== 'Quote asked' ? 'insurer_proposal' : ''}">
<span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span> ${code}
<div class="dropdown-content"> <span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span>
<button onclick="removeQuote(event, ${proposal}, '${code}')">Remove Quote</button> <div class="dropdown-content">
</div> <button onclick="removeQuote(event, ${proposal}, '${code}')">Remove Quote</button>
</th> </div>
</th>
`) `)
).join('')} ).join('')}
<th>-</th>`; <th>-</th>`;
@ -1258,7 +1249,7 @@
<input type="checkbox" class="sno-checkbox"> <input type="checkbox" class="sno-checkbox">
${policy.name} ${policy.name}
${policy.name === 'Fire' || policy.name === 'Burglary' ? ${policy.name === 'Fire' || policy.name === 'Burglary' ?
`<br><button class = "btn btn-primary btn-sm" onclick = "getPolicyInfo()" class="policy-link" data-policy-name="${policy.name}">Register</button>` : `<br><button id = '${policy.name.toUpperCase()}_register' class = "btn btn-primary btn-sm" onclick = "getPolicyInfo('${policy.name}')" class="policy-link" data-policy-name="${policy.name}" disabled>Register</button>` :
''} ''}
</td> </td>
<td contenteditable="true">${desc}</td> <td contenteditable="true">${desc}</td>
@ -1299,13 +1290,14 @@
suggestions[rowID] = row_fields[rowID].answer_type; suggestions[rowID] = row_fields[rowID].answer_type;
if (answer_type == 'dropdown') { if (answer_type == 'dropdown') {
default_answers_array = row_fields[rowID].default_answer; default_answers_array = row_fields[rowID].default_answer;
console.log("default ans array : ", typeof(default_answers_array))
// createDropdown(default_answers_array); // createDropdown(default_answers_array);
default_value = default_answers_array[0].key; default_value = default_answers_array[0].key;
default_answer = default_answers_array[0].display_value; default_answer = default_answers_array[0].display_value;
} else { } else {
default_answers_array = row_fields[rowID].default_answer ? row_fields[rowID].default_answer : "-"; default_answers_array = row_fields[rowID].default_answer ? row_fields[rowID].default_answer : "-";
console.log("default ans array else: ", default_answers_array)
// console.log("defaultansetgoa : ",default_answers_array); // console.log("defaultansetgoa : ",default_answers_array);
default_value = default_answers_array; default_value = default_answers_array;
default_answer = default_answers_array; default_answer = default_answers_array;
@ -1321,15 +1313,43 @@
${isChildTable ${isChildTable
? `<td>${SNO}</td>` ? `<td>${SNO}</td>`
: `<td rowspan = "${policy.description.length}"><input type="checkbox" class="sno-checkbox">${policy.name}${policy.name == 'Fire' || policy.name == 'Burglary' : `<td rowspan = "${policy.description.length}"><input type="checkbox" class="sno-checkbox">${policy.name}${policy.name == 'Fire' || policy.name == 'Burglary'
? `<br><button class = "btn btn-primary btn-sm" onclick = "getPolicyInfo()" class="policy-link" data-policy-name="${policy.name}">Register</a>` ? `<br><button id = '${policy.name.toUpperCase()}_register' class = "btn btn-primary btn-sm" onclick = "getPolicyInfo('${policy.name}')" class="policy-link" data-policy-name="${policy.name}" disabled>Register</a>`
: ""}</td>` : ""}</td>`
} }
<td contenteditable="true">${tableData ? policy_question : policy.description}</td> <td contenteditable="true">${tableData ? policy_question : policy.description}</td>
${Object.values(quotesConfig).flatMap(codes => ${Object.values(quotesConfig).flatMap(codes =>
codes.map(() => `<td onblur="setValueForHiddenField(this,'${answer_type}')" onclick = "getAnswer('${tableID}','${rowID}')" contenteditable="true">${tableData ? (default_value === '-' ? `${default_value} <input type="hidden" value='${default_value}' />` : `${default_answer} <input type="hidden" value='${JSON.stringify(default_answers_array[0])}' />`) codes.map((_, colIndex) => {
: policy.quote_asked}</td>`) // Get the subheader (assuming it's the second <tr> inside <thead>)
).join('')} let subHeaderTh = document.querySelector(`thead tr:nth-child(2) th:nth-child(${colIndex + 1})`);
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
// Check if subheader is NOT "Quote asked"
let className = subHeaderText !== "Quote asked" && subHeaderText != "-" ? "insurer_proposal" : "";
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
// console.log("defaultJsonString", defaultJsonString);
// console.log("defaultJsonString type", typeof defaultJsonString);
// console.log("defaultJsonString string", String(defaultJsonString));
return `<td class="${className}" onblur="setValueForHiddenField(this,'${answer_type}')"
onclick="getAnswer('${tableID}','${rowID}')"
contenteditable="true">
${tableData ?
(default_value === '-' ?
`${default_value} <input type="hidden" value="${default_value}" />`
: `${default_answer} <input type="hidden" value='${defaultJsonString}' />`
)
: policy.quote_asked
}
</td>`;
})
).join('')}
<td> <td>
${isChildTable ? ` ${isChildTable ? `
<input id = "qcrCheckbox" name = "qcr" checked type="checkbox" class="qcr-checkbox"> <label for = "qcrCheckbox">QCR</label> <input id = "qcrCheckbox" name = "qcr" checked type="checkbox" class="qcr-checkbox"> <label for = "qcrCheckbox">QCR</label>
@ -1474,6 +1494,23 @@
console.log("inside if conditoon"); console.log("inside if conditoon");
localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data)); localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data));
jsonToTables(); jsonToTables();
if (!$.isEmptyObject(storedData)) {
console.log("DATA FROM DB : ", JSON.parse(storedData));
let data = JSON.parse(storedData);
Object.keys(data).forEach(key => {
policySummary[key] = addPolicySummaryTable(data[key], key);
prependTable(policySummary[key],key);
});
// console.log("policy summary : ",child_table_data[key])
console.log("generate policy summary : ", policySummary);
}
// generateTable(document.getElementById('tablesContainer')); // generateTable(document.getElementById('tablesContainer'));
// console.log("polices Length ", policies.length); // console.log("polices Length ", policies.length);
@ -1783,18 +1820,37 @@
function getPolicyInfo(policyName) { function getPolicyInfo(policyName) {
console.log("anchor link clicked ", policyName); console.log("anchor link clicked ", policyName);
if (!myModal) {
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
console.log("inside if condition"); console.log("inside if condition");
}
var leadID = $("#lead_id").val();
$("#policyName").val(policyName);
$("#leadID").val(leadID);
$("#multilocation_type_div").hide();
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
// Add 'show active' to the 'product-selection' tab
$("#policy_register_forms .tab-pane.show.active").removeClass("active show");
// Add 'show active' to the 'product-selection' tab
$("#product-selection").addClass("active show");
hideAndShowBurglary();
storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
if (!$.isEmptyObject(storedPolicyData)) {
// alert("not empty");
prepareDataForEdit(storedPolicyData);
}
myModal.show(); myModal.show();
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
} }
function addPolicySummaryTable(storedData) { function addPolicySummaryTable(storedData, policyName) {
// alert(policyName);
var locationCount = storedData.locations.length; var locationCount = storedData.locations.length;
var tableRowContent = []; var tableRowContent = [];
@ -1804,7 +1860,7 @@
tableRowContent.push({ tableRowContent.push({
table_type: "new", table_type: "new",
table_id: "fire_summary_" + locationIndex, table_id: `${policyName}_summary_` + locationIndex,
table_editable: true, table_editable: true,
table_name: "Risk Location " + locationIndex + "- " + table_name: "Risk Location " + locationIndex + "- " +
storedData.locations[i].policyRisk['occupancy'] + "- " + storedData.locations[i].policyRisk['occupancy'] + "- " +
@ -1914,15 +1970,17 @@
console.log("save button clicked"); console.log("save button clicked");
leadJson = tablesToJson(); leadJson = tablesToJson();
console.log("json from function ", leadJson); console.log("json from function ", leadJson);
saveRFQTODB(leadJson); var policyJson = localStorage.getItem("policyData") ?? null;
saveRFQTODB(leadJson, policyJson);
} }
function saveRFQTODB(tableJSON) { function saveRFQTODB(tableJSON, policyJson) {
var formData = { var formData = {
lead_id: $("#lead_id").val(), lead_id: $("#lead_id").val(),
json: JSON.stringify(tableJSON), json: JSON.stringify(tableJSON),
submit_type: "RFQ" submit_type: "RFQ",
registration_json: policyJson
} }
var url = '<?= base_url('rfq/create') ?>'; var url = '<?= base_url('rfq/create') ?>';
@ -1935,6 +1993,8 @@
method: "POST", method: "POST",
success: function(response) { success: function(response) {
if (response.status == true) { if (response.status == true) {
localStorage.removeItem('policyData');
toastr.success(response.message, "Success"); toastr.success(response.message, "Success");
// window.location.reload(); // window.location.reload();
} else { } else {
@ -1942,7 +2002,7 @@
} }
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
// window.location.reload(); window.location.reload();
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
$('.loader').fadeOut(); $('.loader').fadeOut();
@ -1955,8 +2015,6 @@
function prepareOverallData() { function prepareOverallData() {
const overAllData = {}; const overAllData = {};
// console.log("Policy Configuration Data : ", policyConfig);
// Iterate through each proposal in quotesConfig
Object.entries(policyConfig).forEach(([proposalNumber, insurers]) => { Object.entries(policyConfig).forEach(([proposalNumber, insurers]) => {
const proposalKey = `Proposal ${proposalNumber}`; const proposalKey = `Proposal ${proposalNumber}`;
overAllData[proposalKey] = { overAllData[proposalKey] = {
@ -1965,7 +2023,6 @@
insurers: [] insurers: []
}; };
// Get QCR/STC status from proposal header
const proposalHeader = document.querySelector(`th[data-proposal="${proposalNumber}"]`); const proposalHeader = document.querySelector(`th[data-proposal="${proposalNumber}"]`);
if (proposalHeader) { if (proposalHeader) {
const qcrSelected = proposalHeader.querySelector('.qcrProposal .fa-check-square') !== null; const qcrSelected = proposalHeader.querySelector('.qcrProposal .fa-check-square') !== null;
@ -1975,13 +2032,25 @@
} }
console.log("Insurers Found", insurers); console.log("Insurers Found", insurers);
// Get unique insurers from quotesConfig (stored during addNewQuote)
const uniqueInsurers = []; const uniqueInsurers = [];
insurers.forEach(insurer => { insurers.forEach(insurer => {
if (typeof insurer === 'object' && insurer.id) { // Check if stored properly id:dataId, if (typeof insurer === 'object' && insurer.id) {
let stcInsurerSelected = false;
const insurerHeaders = document.querySelectorAll(`th[data-quote="${insurer.insurerName}"]`);
insurerHeaders.forEach(header => {
const headerProposalCount = header.getAttribute("data-proposal");
if (headerProposalCount == proposalNumber) {
console.log("Found the subheader we are searching");
if (header.querySelector('.sendInsurerClientProposal .fa-check-square') !== null) {
stcInsurerSelected = true;
}
console.log("STC selected for insurer:", stcInsurerSelected);
}
});
uniqueInsurers.push({ uniqueInsurers.push({
ins_name: insurer.insurerName, ins_name: insurer.insurerName,
qcr: 1,
stc: rfq_or_qcr == 1 ? 1 : stcInsurerSelected ? 1 : 0,
display_name: insurer.insurerName, display_name: insurer.insurerName,
id: insurer.id id: insurer.id
}); });
@ -1994,6 +2063,7 @@
return overAllData; return overAllData;
} }
function getTextExcludingButton(cell) { function getTextExcludingButton(cell) {
return Array.from(cell.childNodes) return Array.from(cell.childNodes)
.filter(node => node.nodeType === Node.TEXT_NODE) // Get only text nodes .filter(node => node.nodeType === Node.TEXT_NODE) // Get only text nodes
@ -2039,7 +2109,7 @@
const headerHTML = header.innerHTML; const headerHTML = header.innerHTML;
const headerText = headerHTML.replace(/<span class="three-dot-menu"[\s\S]*?<\/div>/g, '').trim(); const headerText = headerHTML.replace(/<span class="three-dot-menu"[\s\S]*?<\/div>/g, '').trim();
console.log("processing sub header array : ", subHeaderArray); console.log("processing sub header array : ", subHeaderArray);
console.log("HEader : ", headerText); console.log("HEader : ", header.innerText == " " ? header.innerText.trim() : headerText);
headers.push({ headers.push({
// parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(), // parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(),
parentHeader: headerText, parentHeader: headerText,
@ -2242,6 +2312,17 @@
// child_table_data[rowData.rowID] // child_table_data[rowData.rowID]
} }
function getTotalCount(proposalDataArray) {
let proposals = proposalDataArray.proposal_data.over_all_column_data;
let proposalCount = Object.keys(proposals).length; // Count proposals
let insurerCount = Object.values(proposals).reduce((sum, proposal) => {
return sum + (proposal.insurers ? proposal.insurers.length : 0);
}, 0); // Count insurers across all proposals
return proposalCount + insurerCount;
}
function jsonToTables() { function jsonToTables() {
@ -2270,7 +2351,15 @@
console.log("proposal count : ", proposalCount); console.log("proposal count : ", proposalCount);
console.log("proposal count quotes config ... : ", proposalDataArray.proposal_data.over_all_column_data); console.log("proposal count quotes config ... : ", proposalDataArray.proposal_data.over_all_column_data);
var totalCount = getTotalCount(proposalDataArray);
let increaseBy = proposalCount * 150; let increaseBy = proposalCount * 150;
if (rfq_or_qcr == 1) {
console.log("inside if ")
increaseBy = proposalCount * 150;
} else if (rfq_or_qcr == 2) {
increaseBy = totalCount * 150;
}
console.log("trying to find checkbox data : : : ", increaseBy); console.log("trying to find checkbox data : : : ", increaseBy);
@ -2400,6 +2489,7 @@
const headerRow1 = document.createElement('tr'); const headerRow1 = document.createElement('tr');
const headerRow2 = document.createElement('tr'); const headerRow2 = document.createElement('tr');
var overallColumnDataProposal = proposal_data.proposal_data.over_all_column_data; var overallColumnDataProposal = proposal_data.proposal_data.over_all_column_data;
var matchedKey = "";
headers.forEach(header => { headers.forEach(header => {
// Parent header // Parent header
const th1 = document.createElement('th'); const th1 = document.createElement('th');
@ -2408,7 +2498,7 @@
var headerName = header.parentHeader; var headerName = header.parentHeader;
console.log("header name : ", th1.textContent.trim()); console.log("header name : ", th1.textContent.trim());
console.log("over all column data : ", over_all_column_data) console.log("over all column data : ", over_all_column_data)
let matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key));
if (matchedKey) { if (matchedKey) {
console.log("something wrong : ", overallColumnDataProposal[matchedKey]); console.log("something wrong : ", overallColumnDataProposal[matchedKey]);
var headerCheckBoxProperties = overallColumnDataProposal[matchedKey]; var headerCheckBoxProperties = overallColumnDataProposal[matchedKey];
@ -2441,14 +2531,22 @@
header.subHeaders.forEach(subHeader => { header.subHeaders.forEach(subHeader => {
const th2 = document.createElement('th'); const th2 = document.createElement('th');
if (header.parentHeader.startsWith("Proposal")) { if (header.parentHeader.startsWith("Proposal")) {
var insurers = overallColumnDataProposal[matchedKey].insurers;
const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader);
if (subHeader != "Quote asked") { if (subHeader != "Quote asked") {
console.log("trying to find something : ", matchedInsurer.stc);
console.log("this is the subheader : ", subHeader); console.log("this is the subheader : ", subHeader);
th2.classList.add("insurer_proposal"); th2.classList.add("insurer_proposal");
th2.innerHTML = ` th2.innerHTML = `
${subHeader} ${subHeader}
<span class="three-dot-menu">&#8942;</span> <span class="three-dot-menu">&#8942;</span>
<div class="dropdown-content"> <div class="dropdown-content">
<button id = "isInsurerSTC" class="sendInsurerClientProposal" onclick = "addOrRemoveIconInsurer(this,event)"
style="background-color: rgb(221, 221, 221);">Send to Client ${matchedInsurer.stc == 1 ? `<i
class="fa fa-check-square"
style="color: green; margin-left: 8px; "></i>`: ""} </button>
<button onclick="changeInsurer(event, ${header.parentHeader.split(' ')[1]}, '${subHeader}')">Change Insurer</button> <button onclick="changeInsurer(event, ${header.parentHeader.split(' ')[1]}, '${subHeader}')">Change Insurer</button>
<button onclick="removeQuote(event, ${header.parentHeader.split(' ')[1]}, '${subHeader}')">Remove Quote</button> <button onclick="removeQuote(event, ${header.parentHeader.split(' ')[1]}, '${subHeader}')">Remove Quote</button>
</div> </div>
@ -2487,7 +2585,7 @@
} }
// console.log("insude the function value ", value); // console.log("insude the function value ", value);
return `<input type="checkbox" ${value == "Checked" ? "checked" :""} class = "sno-checkbox" /> ${cellData.SNO} ${cellData.SNO == 'Fire' || cellData.SNO == 'Burglary' return `<input type="checkbox" ${value == "Checked" ? "checked" :""} class = "sno-checkbox" /> ${cellData.SNO} ${cellData.SNO == 'Fire' || cellData.SNO == 'Burglary'
? `<br><button class = "btn btn-primary btn-sm" onclick = "getPolicyInfo()" class="policy-link" data-policy-name="${cellData.SNO}">Register</a>` ? `<br><button id = '${cellData.SNO.toUpperCase()}_register' class = "btn btn-primary btn-sm" onclick = "getPolicyInfo('${cellData.SNO}')" class="policy-link" data-policy-name="${cellData.SNO}" ${value == "Checked" ? "" :"disabled"} >Register</a>`
: ""}`; : ""}`;
} }
if (typeof value === 'string' && value.startsWith('{')) { if (typeof value === 'string' && value.startsWith('{')) {
@ -2913,11 +3011,53 @@
}); });
}); });
} }
function prependTable(policyJson,policyName) {
// alert("hi");
console.log("table to prepened : ", policyJson);
let parentDiv = document.querySelector(`div[data-parent-row=${policyName}]`);
// let newTable = document.createElement("table");
if (parentDiv){
let tables = Array.from(parentDiv.querySelectorAll("table"));
tables.forEach(table => {
if (table.id.includes("summary")) {
table.remove(); // Move summary table to the top
}
});
policyJson.slice().reverse().forEach(childTable => {
generateTable(parentDiv, true, policyName, childTable);
});
moveSummaryTableToTop(policyName);
}
}
function moveSummaryTableToTop(policyName) {
let parentDiv = document.querySelector(`div[data-parent-row="${policyName}"]`);
if (!parentDiv) return; // Exit if no such div exists
let tables = Array.from(parentDiv.querySelectorAll("table"));
tables.forEach(table => {
if (table.id.includes("summary")) {
parentDiv.prepend(table); // Move summary table to the top
}
});
}
</script> </script>
<!-- Export Excel and Mail Script --> <!-- Export Excel and Mail Script -->
<script> <script>
var proposalDataForDropDown = {}; var proposalDataForDropDown = {};
const editorConfig = { const editorConfig = {
@ -2946,7 +3086,7 @@
placeholder: "Start typing here...", // Optional placeholder text placeholder: "Start typing here...", // Optional placeholder text
}; };
$(document).ready(function(){ $(document).ready(function() {
const path = window.location.pathname; // Get the current URL path const path = window.location.pathname; // Get the current URL path
const segments = path.split('/'); // Split the path into segments const segments = path.split('/'); // Split the path into segments
@ -2989,10 +3129,10 @@
if (placementLeadData) { if (placementLeadData) {
placementLeadData = JSON.parse(placementLeadData); placementLeadData = JSON.parse(placementLeadData);
let txt = 'The data has already been sent to the insurer ' let txt = 'The data has already been sent to the insurer ' +
+ placementLeadData.insurer_name placementLeadData.insurer_name +
+ ' and the proposal is ' ' and the proposal is ' +
+ placementLeadData.proposel_name + '.'; placementLeadData.proposel_name + '.';
$('#alert_msg').text(txt); $('#alert_msg').text(txt);
} else { } else {
$('#alert_msg').text(''); $('#alert_msg').text('');
@ -3013,34 +3153,34 @@
}) })
function checkTheTableDataChanged(redirect_type){ function checkTheTableDataChanged(redirect_type) {
if(redirect_type == 1){ if (redirect_type == 1) {
//BACK BUTTON //BACK BUTTON
window.location.href="<?= base_url("leads/list")?>" window.location.href = "<?= base_url("leads/list") ?>"
}else if(redirect_type == 2){ } else if (redirect_type == 2) {
//EXCEL EXPORT //EXCEL EXPORT
let url = $('#submitExcel').data('url'); let url = $('#submitExcel').data('url');
window.location.href = url; window.location.href = url;
}else if(redirect_type == 3){ } else if (redirect_type == 3) {
//INSURER OR CLIENT MAIL SEND //INSURER OR CLIENT MAIL SEND
showModal(1); showModal(1);
}else if(redirect_type == 4){ } else if (redirect_type == 4) {
//INTERNAL MAIL SEND //INTERNAL MAIL SEND
showModal(2); showModal(2);
}else if(redirect_type == 5){ } else if (redirect_type == 5) {
//PROCCED TO QCR //PROCCED TO QCR
// submitQCRData(); // submitQCRData();
let lead_id = $('#lead_id').val(); let lead_id = $('#lead_id').val();
let url = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2; let url = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
window.location.href = url; window.location.href = url;
}else if(redirect_type == 6){ } else if (redirect_type == 6) {
//INTERNAL MAIL SEND //INTERNAL MAIL SEND
showModal(3); showModal(3);
@ -3049,18 +3189,18 @@
function showModal(mail_type) { function showModal(mail_type) {
if(mail_type == 1){ if (mail_type == 1) {
insurerAndClientMailPopUp() insurerAndClientMailPopUp()
}else if(mail_type == 2){ } else if (mail_type == 2) {
var myModal = new bootstrap.Modal(document.getElementById('internal_mail_modal')); var myModal = new bootstrap.Modal(document.getElementById('internal_mail_modal'));
myModal.show(); myModal.show();
// getMailContent('internal_mail_content'); // getMailContent('internal_mail_content');
}else if(mail_type == 3){ } else if (mail_type == 3) {
placementMailPopUp() placementMailPopUp()
// getMailContent('placement_mail_content'); // getMailContent('placement_mail_content');
@ -3069,7 +3209,7 @@
} }
function insurerAndClientMailPopUp(){ function insurerAndClientMailPopUp() {
var url = ''; var url = '';
var lead_id = $('#lead_id').val(); var lead_id = $('#lead_id').val();
@ -3164,7 +3304,7 @@
`; `;
} }
if(user_role_id == 1 || user_role_id == 5){ if (user_role_id == 1 || user_role_id == 5) {
html += ` html += `
@ -3173,8 +3313,8 @@
<select class="form-control" id="client_cc" name="client_cc" required multiple> <select class="form-control" id="client_cc" name="client_cc" required multiple>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>"> <option value="<?= $user['id']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -3186,8 +3326,8 @@
<select class="form-control" id="client_bcc" name="client_bcc" required multiple> <select class="form-control" id="client_bcc" name="client_bcc" required multiple>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>"> <option value="<?= $user['id']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -3235,8 +3375,8 @@
<select class="form-control" id="client_cc" name="client_cc" required multiple> <select class="form-control" id="client_cc" name="client_cc" required multiple>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>"> <option value="<?= $user['id']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -3248,8 +3388,8 @@
<select class="form-control" id="client_bcc" name="client_bcc" required multiple> <select class="form-control" id="client_bcc" name="client_bcc" required multiple>
<?php if (isset($userList)) { ?> <?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?> <?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>"> <option value="<?= $user['id']; ?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'] . ' - ' . $user['email']; ?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -3310,11 +3450,11 @@
function constructURL(url_type) { function constructURL(url_type) {
if(url_type == 1){ if (url_type == 1) {
constructURL_ForInsurerAndClientMailSend() constructURL_ForInsurerAndClientMailSend()
}else if(url_type == 2){ } else if (url_type == 2) {
constructURL_ForInternalMailSend() constructURL_ForInternalMailSend()
}else if(url_type == 3){ } else if (url_type == 3) {
Swal.fire({ Swal.fire({
title: "Do you want to place the proposal data?", title: "Do you want to place the proposal data?",
@ -3327,7 +3467,7 @@
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
constructURL_ForPlacementMailSend() constructURL_ForPlacementMailSend()
}else{ } else {
return false; return false;
} }
}); });
@ -3501,15 +3641,15 @@
placeholder: 'Select To Mail', placeholder: 'Select To Mail',
}); });
$('#cc').val('').select2({ $('#cc').val('').select2({
placeholder : 'select CC Mail' placeholder: 'select CC Mail'
}); });
// $('#subject').val(''); // $('#subject').val('');
$('#proposals').val(''); $('#proposals').val('');
$('#placement_to').val('').select2({ $('#placement_to').val('').select2({
placeholder : 'select To Mail' placeholder: 'select To Mail'
}); });
$('#placement_cc').val('').select2({ $('#placement_cc').val('').select2({
placeholder : 'select CC Mail' placeholder: 'select CC Mail'
}); });
$('#placement_subject').val(''); $('#placement_subject').val('');
@ -3521,7 +3661,7 @@
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
} }
function getInsurerBranchContacts(input){ function getInsurerBranchContacts(input) {
let insurer_and_branch = $(input).val(); let insurer_and_branch = $(input).val();
console.log('insurer_and_branch', insurer_and_branch); console.log('insurer_and_branch', insurer_and_branch);
@ -3537,9 +3677,9 @@
console.log(res) console.log(res)
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
if(res.status == false){ if (res.status == false) {
toastr.warning(res.message, 'WARNING') toastr.warning(res.message, 'WARNING')
}else{ } else {
appendInsurerContact(res.data) appendInsurerContact(res.data)
} }
}, },
@ -3569,24 +3709,24 @@
}); });
$('#placement_to').append(option); $('#placement_to').append(option);
}); });
} }
$('.close').click(function(){ $('.close').click(function() {
$('#to').select2({ $('#to').select2({
placeholder: 'Select To Mail', placeholder: 'Select To Mail',
}); });
$('#cc').val('').select2({ $('#cc').val('').select2({
placeholder : 'select CC Mail' placeholder: 'select CC Mail'
}); });
// $('#subject').val(''); // $('#subject').val('');
$('#proposals').val(''); $('#proposals').val('');
$('#placement_to').val('').select2({ $('#placement_to').val('').select2({
placeholder : 'select To Mail' placeholder: 'select To Mail'
}); });
$('#placement_cc').val('').select2({ $('#placement_cc').val('').select2({
placeholder : 'select CC Mail' placeholder: 'select CC Mail'
}); });
$('#placement_subject').val(''); $('#placement_subject').val('');
@ -3594,4 +3734,24 @@
$("textarea.select2-search__field").css('resize', 'none'); $("textarea.select2-search__field").css('resize', 'none');
}) })
function addOrRemoveIconInsurer(element, event) {
event.stopPropagation(); // Prevent event bubbling
// Find the button inside the dropdown (or use `element` directly)
const stcButton = element.closest('.dropdown-content') ?
element.closest('.dropdown-content').querySelector('.sendInsurerClientProposal') :
element;
// Check if the icon already exists
let icon = stcButton.querySelector("i.fa-check-square");
if (icon) {
// Remove the icon if it already exists
icon.remove();
} else {
// Create and append the check icon
createIcon(stcButton);
}
}
</script> </script>