MERGE_TEST_RFQ_CHNAGES

This commit is contained in:
Ubuntu 2025-05-08 18:08:59 +05:30
commit 419afb0d55
31 changed files with 1778 additions and 688 deletions

View File

@ -357,6 +357,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1');
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
$routes->get('removeMultiFile', 'LeadsController::removeMultiFile');
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
});
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {

View File

@ -4604,9 +4604,10 @@ class ClientController extends AdminController
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]);
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
$empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '873']);
// $res = $empServiceController->excelFileDataValidation(['file_id' => '874']);
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']);
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '829']);
// $res = $empServiceController->employeeDisembark(['file_id' => '858']);
// dd('-----', $res);

View File

@ -949,6 +949,9 @@ class EmpDataServiceController extends BaseController
$export_data['event_type'] = 'correction';
$correctionData = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($export_data);
}else if($value == "missed_inception"){
$export_data['event_type'] = 'missed_inception';
$additionData = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data);
}
}

View File

@ -190,7 +190,7 @@ class EmployeeController extends AdminController
// print_r($this->request->getPost('upload-action-type'));
// die();
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '42']);
// $res = $empServiceController->excelFileDataValidation(['file_id' => '933']);
// dd($res);
// $empServiceController = new EmployeeServiceController();

View File

@ -728,6 +728,7 @@ class EmployeeServiceController extends AdminController
$allowedHighestColumn = end($columns_to_check);
// dd($allowedHighestColumn);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
// !dd(array_chunk($excel_data,20)[0]);
//check no of columns in excel
@ -997,7 +998,7 @@ class EmployeeServiceController extends AdminController
$allowedHighestColumn = end($columns_to_check);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// print_r($keys);die();
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
//remove header
unset($excel_data[0]);
@ -1035,6 +1036,14 @@ class EmployeeServiceController extends AdminController
// kint::dump($family);
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again bring self to first index of the array
}
$firstNonTemp = null;
foreach ($family as $fam) {
if (!isset($fam['temp'])) {
$firstNonTemp = $fam;
break;
}
}
// kint::dump($family);//die();
//check name dup within a family
@ -1070,7 +1079,7 @@ class EmployeeServiceController extends AdminController
if(!count($self_details))
{
array_push($result['error_summary'],14); // Self not found
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database";
$result['error_data'][ $firstNonTemp[0] ]['sno']['error'][] = "Self not found in Database";
}
}
@ -1078,7 +1087,7 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception'|| $file['action'] == 'missed_inception' || $file['action'] == 'enrollment')
{
$res = check_dependent_conflict($family,$policy_terms,$file['action'],$is_lgbtq);
// dd($res);
// Kint::dump($res);
if(!$res['status'])
{
foreach($res['error_data'] as $key => $value)
@ -1091,7 +1100,7 @@ class EmployeeServiceController extends AdminController
//check dup with empid and name with db
$res = name_and_empid_check_in_db($family,$file);
// dd($res);
// Kint::dump($res['del']);
// echo '<br/>';
// print_r($res);
if(count($res['del']))
@ -1113,7 +1122,7 @@ class EmployeeServiceController extends AdminController
}// end of foreach
}// end of if current action I,DA,A
// return $result;
// return $result;
// die();
if(isset($result['error_summary']) && count($result['error_summary']))
{
@ -1359,7 +1368,15 @@ class EmployeeServiceController extends AdminController
break;
}
// echo '<br>START- ' . $row[2];
$employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->where('client_branch_id',$file['client_branch_id'])->first();
$employee = $this->employeeModel
->where('emp_code', $row[1])
->where('name',$row[2])
->where('client_id',$file['client_id'])
->where('client_branch_id',$file['client_branch_id'])
->where('emp_status !=','truncated')
->where('is_active', 1)
->first();
// $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->first();
// dd($employee);
if(is_array($employee) && count($employee))
@ -1372,6 +1389,7 @@ class EmployeeServiceController extends AdminController
->where('name',$employee['name'])
->where('field_name','emp_status')
->where('status !=','truncated')
->where('is_active', 1)
->findAll();
// dd($existing_endorsements);

View File

@ -30,6 +30,7 @@ use App\Models\RFQModel;
use App\Models\InsurerModel;
use App\Models\OccupancyMasterModel;
use App\Models\LeadFilesModel;
use App\Models\LeadInstallmentPaymentDetails;
use App\Helpers\MailHelper;
use App\Helpers\ExcelMergeHelper;
@ -65,6 +66,7 @@ class LeadsController extends BaseController
protected $insurerModel;
protected $occupancyModel;
protected $leadFilesModel;
protected $leadInstallmentPaymentDetails;
//variables for storing array
protected $issuer;
@ -96,20 +98,27 @@ class LeadsController extends BaseController
$this->insurerModel = new InsurerModel();
$this->occupancyModel = new OccupancyMasterModel();
$this->leadFilesModel = new LeadFilesModel();
$this->leadInstallmentPaymentDetails = new LeadInstallmentPaymentDetails();
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
$this->clientType = [1 => 'Group', 2 => 'Individual'];
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
$data = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
$this->buisnessType = array_column($data, 'name', 'id');
// $this->buisnessType = [1 => 'Public Sector', 2 => 'Private Sector',3=> 'Trust',4 => 'Proprietorship',5 => 'Partnership',6 => 'Private',7 => 'Individual'];
$this->leadsStatus = [
'queued' => 'In-Queued',
'qcr_sent' => 'QCR sent',
'lost' => 'Lost',
'co_insurer_pending' => 'Co-Insurer Pending',
'won' => 'Won',
'completed_with_corrections' => 'Completed with Corrections',
'completed_without_corrections' => 'Completed w/o Corrections',
'queued' => 'In-Queued',
'rfq_created' => 'RFQ Created',
'rfq_sent' => 'RFQ Sent',
'qcr_created' => 'QCR Created',
'qcr_sent' => 'QCR Sent',
'lost' => 'Lost',
'co_insurer_pending' => 'Co-Insurer Pending',
'won' => 'Won',
'completed_with_corrections' => 'Completed with Corrections',
'completed_without_corrections' => 'Completed without Corrections',
];
$this->claim_type_for_gpa = [
'accident_death' => 'Accident Death',
'permanent_total_disablement' => 'Permanent Total Disablement',
@ -592,12 +601,14 @@ class LeadsController extends BaseController
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
} else {
$lead_file_data = [
'lead_id' => $lead_id,
'docs_name' => $value['docs_name'],
'file_name' => $value['file_name'],
];
$this->leadFilesModel->insert($lead_file_data);
if (!empty($value['file_name'])) {
$lead_file_data = [
'lead_id' => $lead_id,
'docs_name' => $value['docs_name'],
'file_name' => $value['file_name'],
];
$this->leadFilesModel->insert($lead_file_data);
}
}
if ($key == 0 && !empty($value['file_name'])) {
@ -619,6 +630,8 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200);
}
}
//--------RFQ-----------------------------------------------------------------------------------------------
@ -676,7 +689,7 @@ class LeadsController extends BaseController
$data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ();
$data['lead_data'] = $lead_data;
$mail_content = "
$mail_content = '
<p>Dear Sir,</p>
<p>Greetings From Nhance India!</p>
<p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
@ -687,13 +700,11 @@ class LeadsController extends BaseController
<div style=\"margin: 0; padding: 0; line-height: 1.2;\">
<div>{{LOGGED_USER_NAME}}</div>
<div>Email: {{LOGGED_USER_EMAIL}}</div>
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
</div>
";
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
';
if ($data['lead_data']['policy_end_date'] != null) {
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}";
@ -705,6 +716,8 @@ class LeadsController extends BaseController
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
$installment_data['installments'] = $this->leadInstallmentPaymentDetails->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
$data['lead_data']['installment_data'] = view('rfq/installment_fields', $installment_data) ?? null;
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
$data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active", 1)->first()['team_id'];
// dd($data);
@ -727,11 +740,14 @@ class LeadsController extends BaseController
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
}
$data['product'] = $this->leadsModel->select("policy_type.policy_type")->join('policy_type', 'leads.policy_type_id = policy_type.id')->where('leads.id', $id)->first()['policy_type'];
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
// dd($data['lead_register_data']);
// $data['entity_type'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
$data['buisness_type'] = $this->buisnessType;
// dd($data);
$data['client_type'] = $this->clientType;
$data['buisness_type'] = $this->buisnessType;
$this->loadLayout('view_rfq_non_eb', $data);
}
}
@ -776,12 +792,27 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400);
}
$rfq_created = $this->RFQModel->where('lead_id', $lead_id)->where('is_active', 1)->countAllResults();
$qcr_created = false;
$inputJson = json_decode($data['json'], true);
if (isset($inputJson['premium_data']) && !empty($inputJson['premium_data'])) {
$sortedJson = $this->reorderProposalsByInsurerTotal($inputJson);
$data['json'] = json_encode($sortedJson);
$qcr_created = true;
}
if(($data['submit_type'] ?? "") == 'QCR'){
$inputJson = json_decode($data['json'], true);
$proposal_data = array_pop($inputJson);
if(isset($proposal_data['proposal_data']['over_all_column_data'])){
$proposel_count = $proposal_data['proposal_data']['over_all_column_data'];
foreach ($proposel_count as $key => $value) {
if(!empty($value['insurers'])){
$qcr_created = true;
}
}
}
}
$data['type'] = 1;
@ -821,6 +852,19 @@ class LeadsController extends BaseController
}
if ($insertId) {
if(empty($rfq_created)){
$this->leadsModel->update($lead_id, ['status' => "rfq_created"]);
}
if($qcr_created == true){
$this->leadsModel
->where('id', $lead_id)
->whereNotIn('status', ['qcr_sent', 'lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections'])
->set(['status' => "qcr_created"])
->update();
}
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR saved successfully' : 'RFQ saved successfully';
return $this->respond([
'status' => true,
@ -1063,6 +1107,17 @@ class LeadsController extends BaseController
return $result;
}
public function removeInstallments()
{
$id = $this->request->getGet('id');
// print_r($id); die;
if (!empty($id)) {
$this->leadInstallmentPaymentDetails->whereIn('id', $id)->set(['is_active' => 0])->update();
return $this->respond(['status' => true, 'message' => 'Removed successfully'], 200);
} else {
return $this->respond(['status' => false, 'message' => 'Could not be removed.'], 200);
}
}
//-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------
@ -1139,36 +1194,32 @@ class LeadsController extends BaseController
if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
'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'])),
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Run Days' => $rfq_data['policy_run_days'],
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
'Policy Status' => $rfq_data['status'],
'Existing Insurer' => $rfq_data['insurer_name'],
'TPA ' => $rfq_data['tpa_name'],
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
];
}
} else {
if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
@ -1182,7 +1233,7 @@ class LeadsController extends BaseController
'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'])),
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'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'],
@ -1194,12 +1245,11 @@ class LeadsController extends BaseController
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
'Policy Status' => $rfq_data['status'],
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
'Existing Insurer' => $rfq_data['insurer_name'],
'TPA ' => $rfq_data['tpa_name'],
];
@ -1209,13 +1259,16 @@ class LeadsController extends BaseController
$data = json_decode($rfq_data['json'], true);
// dd($data);
$sheetName = 'Worksheet';
if ($type == 2) {
$sheetName = 'QCR';
$data = $this->convertJsonForQCR($data, $type);
if ($propsal_and_insurer !== null) {
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
}
} else if ($type == 1) {
$sheetName = 'RFQ';
$data = $this->convertJsonForQCR($data, $type);
// dd($data);
}
@ -1223,6 +1276,7 @@ class LeadsController extends BaseController
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle($sheetName);
// Start with lead_data at the top
@ -1242,22 +1296,6 @@ class LeadsController extends BaseController
],
]);
// Set column width to fit the image properly
$sheet->getColumnDimension('C')->setWidth(20); // Adjust as needed
$sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed
$drawing = new Drawing();
$path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path
$drawing->setPath($path);
$drawing->setCoordinates("C{$rowNumber}"); // Set position in column B
$drawing->setHeight(35); // Adjust image height
// Center align the image in the cell
$drawing->setOffsetX(30); // Adjust horizontal offset
$drawing->setOffsetY(5); // Adjust vertical offset
$drawing->setWorksheet($sheet);
// Apply center alignment to the cell
$sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
$sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
@ -1304,11 +1342,10 @@ class LeadsController extends BaseController
$rowNumber++;
}
// Set column width based on max content length (adjusted for padding)
// // Set column width based on max content length (adjusted for padding)
$sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2);
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 5);
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2);
// $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2);
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.6);
// $rowNumber += 2;
@ -1350,9 +1387,13 @@ class LeadsController extends BaseController
]);
$sheet->mergeCells($mergeRange);
$rowNumber_for_remove_quote_asked = $rowNumber;
$rowNumber = $rowNumber + 1;
$subHeaderRow = $rowNumber + 1;
if($type == 2){
$subHeaderRow = $rowNumber + 1;
}else{
$subHeaderRow = $rowNumber_for_remove_quote_asked;
}
$columnLetter = 'A';
foreach ($headers as $header) {
@ -1393,9 +1434,12 @@ class LeadsController extends BaseController
// Add subheaders
foreach ($header['subHeaders'] as $subHeader) {
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C" && $columnLetter != "D") {
if($type == 2){
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
}
if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C") {
$sheet->getColumnDimension($columnLetter)->setWidth(35);
} else {
$sheet->getColumnDimension('A')->setWidth(10);
@ -1514,6 +1558,51 @@ class LeadsController extends BaseController
]);
}
//set imgage and align the row and column
// Kint::dump($columnLetter);
if($type == 2){
$columnLetter_img = $this->getPreviousColumn($columnLetter, 2);
}else{
$columnLetter_img = $this->getPreviousColumn($columnLetter);
}
// dd($columnLetter_img);
$company_name = $this->getPreviousColumn($columnLetter_img);
$mergeRange1 = "A1:{$company_name}1";
$sheet->mergeCells($mergeRange1);
$rowCount = count($lead_data);
for ($i = 2; $i <= $rowCount + 1; $i++) {
$mergeRange1 = "C{$i}:{$columnLetter_img}{$i}";
$sheet->mergeCells($mergeRange1);
$sheet->getStyle($mergeRange1)->applyFromArray([
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'], // Black color
],
],
]);
}
$sheet->getColumnDimension($columnLetter_img)->setWidth(40);
$sheet->getRowDimension(1)->setRowHeight(40); // Adjust as needed
$drawing = new Drawing();
$path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path
$drawing->setPath($path);
$drawing->setCoordinates("{$columnLetter_img}1"); // Set position in column B
$drawing->setHeight(35); // Adjust image height
// Center align the image in the cell
$drawing->setOffsetX(110); // Adjust horizontal offset
$drawing->setOffsetY(10); // Adjust vertical offset
$drawing->setWorksheet($sheet);
//end
// Auto-size columns
// foreach ($sheet->getColumnIterator() as $column) {
// $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true);
@ -1551,7 +1640,7 @@ class LeadsController extends BaseController
}
$lastRow = count($lead_data) + 1;
$leadRange = "A1:C{$lastRow}";
$leadRange = "A1:{$columnLetter_img}{$lastRow}";
$sheet->getStyle($leadRange)->applyFromArray([
'borders' => [
@ -1571,12 +1660,12 @@ class LeadsController extends BaseController
$policy_year = "$current_year-$next_year";
if (!empty($rfq_data['policy_end_date'])) {
$policy_expiry = strtotime($lead_data['policy_end_date']);
$policy_expiry = strtotime($rfq_data['policy_end_date']);
$formatted_policy = date("d-m-Y", $policy_expiry);
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '(Due On ' . $formatted_policy . ')' . '.xlsx';
} else {
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx';
}
@ -2075,17 +2164,19 @@ class LeadsController extends BaseController
->where('leads.id', $lead_id)
->first();
// log_message('error', 'Lead Data' . json_encode($lead_data));
// print_r($lead_data ); die;
$cc_mails = [];
$bcc_mails = [];
//get CC Mails
if ($recipient_type == 'internal' || $recipient_type == 'placement' || $recipient_type == 'insurer' || $recipient_type == 'client') {
if ($recipient_type == 'internal' || $recipient_type == 'insurer' || $recipient_type == 'client') {
$cc_data = isset($params['cc']) ? $params['cc'] : "";
$param_cc_mail = json_decode($cc_data, true);
if (isset($param_cc_mail) && is_array($param_cc_mail) && count($param_cc_mail) > 0) {
// Fetch user data where ID is in the param_cc_mail array
$userData = $this->userModel
@ -2109,6 +2200,8 @@ class LeadsController extends BaseController
// Handle case where param_cc_mail is not valid
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
}
}else if($recipient_type == 'placement'){
$cc_mails = isset($params['cc']) ? json_decode($params['cc'], true) : "";
}
//get BCC Mails
@ -2176,6 +2269,7 @@ class LeadsController extends BaseController
$result = $file_info['filePath'];
// return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200);
}
// print_rr($result); die;
// print_rr($file_info);
// $file_path = WRITEPATH."uploads/excel/sample/correction.xls";
@ -2194,15 +2288,11 @@ class LeadsController extends BaseController
//get recipient address
if ($recipient_type == 'insurer' || $recipient_type == 'placement') {
// print_r($recipient_mail); die;
$recipient_data = $this->levelContactModel
->where(['contact_type' => 'insurer', 'is_active' => 1])
->whereIn('id', $recipient_mail)
->findAll();
// print_r($recipient_data); die;
} else if ($recipient_type == 'client') {
$mailIDS = explode(',', $params['contact_mail']);
@ -2235,9 +2325,9 @@ class LeadsController extends BaseController
foreach ($recipient_data as $recipient) {
$message = $original_message;
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message);
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message);
$message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message);
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'] != "" ? $recipient['name'] :" ", $message);
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'] != "" ? $lead_data['client_name'] : "", $message);
$message = str_replace("{{POLICY_LONG_NAME}}",$lead_data['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) ?? '--';
@ -2264,16 +2354,52 @@ class LeadsController extends BaseController
$data = [
'proposel_data' => json_encode($lead_update_data),
'status' => 'won',
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'),
'payment_date' => change_date_format($params['payment_date'], 'd/m/Y', 'Y-m-d'),
'utr_no' => $params['utr_no'],
'is_cd' => $params['is_cd'],
'premium_amount' => $params['premium_amount'],
'total_amount' => $params['total_amount'],
'cd_amount' => $params['cd_amount'],
'placement_date' => date('Y-m-d', strtotime($params['placement_date']) ?? "") ?? null,
'payment_date' => date('Y-m-d', strtotime($params['payment_date'] ?? "")) ?? null,
'utr_no' => $params['utr_no'] ?? null,
'is_cd' => $params['is_cd'] ?? null ,
'premium_amount' => $params['premium_amount'] ?? null,
'total_amount' => $params['total_amount'] ?? null,
'cd_amount' => $params['cd_amount'] ?? null,
'no_of_installment' => $params['no_of_installment'] ?? null,
'is_installment' => $params['is_installment'] ?? null,
];
$this->leadsModel->where('id', $lead_id)->set($data)->update();
if(isset($params['installments']) && !empty($params['installments'])){
$installment_data = json_decode($params['installments'], true);
if(!empty($installment_data)){
foreach ($installment_data as $key => $value) {
$value['payment_date'] = date('Y/m/d', strtotime($value['payment_date'])) ?? null;
if(isset($value['id']) && !empty($value['id'])){
$this->leadInstallmentPaymentDetails->where('id', $value['id'])->set($value)->update();
}else{
$this->leadInstallmentPaymentDetails->insert($value);
}
}
}
}
}
if ($recipient_type == 'client') {
$this->leadsModel
->where('id', $lead_id)
->whereNotIn('status', ['lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections'])
->set(['status' => "qcr_sent"])
->update();
}
if ($recipient_type == 'insurer') {
$this->leadsModel
->where('id', $lead_id)
->whereNotIn('status', ['qcr_created', 'qcr_sent', 'lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections'])
->set(['status' => "rfq_sent"])
->update();
}
//delete attachment file
@ -2808,7 +2934,7 @@ class LeadsController extends BaseController
$value = $cellData['display_content'] ?? '';
// Skip unwanted keys
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Quote Asked') {
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Sum Insured' || $subth === 'Fidelity Limit') {
continue;
}
@ -2913,6 +3039,10 @@ class LeadsController extends BaseController
$current_year = date('Y');
$next_year = $current_year + 1;
$policy_year = "$current_year-$next_year";
$page_name = $page_name == "QCR" ? "Quote Comparison Report" : $page_name;
$log_path = base_url() . '/public/assets/images/Nhance-Logo-Final.png';
// $log_path ='https://venbait.in/nhance/dev/public/assets/images/Nhance-Logo-Final.png';
// dd($log_path);
$policy_expiry = strtotime($lead_data['policy_end_date']);
@ -2935,6 +3065,7 @@ class LeadsController extends BaseController
$message = str_replace("{{LOGGED_USER_NAME}}", ucfirst($logged_user_data['first_name']) . " " . ucfirst($logged_user_data['last_name']), $message);
$message = str_replace("{{LOGGED_USER_EMAIL}}", $logged_user_data['email'], $message);
$message = str_replace("{{LOGGED_USER_MOBILE}}", $logged_user_data['mobile'], $message);
$message = str_replace("{{LOGO_PATH}}", $log_path, $message);
return $message;
} else {
@ -3044,7 +3175,6 @@ class LeadsController extends BaseController
$data['lead_edit_data']['claims_details_html'] = "";
}
}
// dd($data);
return $this->loadLayout('leads_form_handler', $data);
@ -3077,6 +3207,7 @@ class LeadsController extends BaseController
3 => 'rfq/gmc',
4 => 'rfq/gmc',
5 => 'rfq/gmc',
17=> 'rfq/burglary',
22 => 'rfq/car',
23 => 'rfq/cpm',
24 => 'rfq/cyber_crime',
@ -3216,11 +3347,11 @@ class LeadsController extends BaseController
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2);
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2);
$rowNumber += 2;
$rowNumber += 1;
//Policy Registration
if (!empty($policy_registration_data)) {
foreach ($policy_registration_data as $key => $value) {
// kint::dump($value);
$startRow = $rowNumber; // Track where the block starts
// Title Row
@ -3307,6 +3438,24 @@ class LeadsController extends BaseController
$rowNumber++;
}
if (isset($value['policyDetails']) && !empty($value['policyDetails'])) {
// Type of Business
$sheet->mergeCells("A{$rowNumber}:B{$rowNumber}");
$sheet->setCellValue("A{$rowNumber}", "Terrorism");
$sheet->setCellValue("C{$rowNumber}", ucfirst($value['policyDetails']['terrorism'] ?? 'No'));
$sheet->getStyle("A{$rowNumber}")->applyFromArray([
'font' => ['bold' => true],
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
],
]);
$rowNumber++;
}
$endRow = $rowNumber - 1; // Block ends at previous row
// Apply border to the whole block
@ -3319,8 +3468,9 @@ class LeadsController extends BaseController
],
]);
$rowNumber += 2; // Add space before the next block
$rowNumber += 1; // Add space before the next block
}
// die();
}
//Table Data
@ -3424,6 +3574,18 @@ class LeadsController extends BaseController
}
}
// For the subheader row, merge B and C and set the value
$sheet->setCellValue("B{$subHeaderRow}", "Sum Insured");
$sheet->mergeCells("B{$subHeaderRow}:C{$subHeaderRow}");
$sheet->getStyle("B{$subHeaderRow}:C{$subHeaderRow}")->applyFromArray([
'font' => ['bold' => true],
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
],
]);
// Apply border to the header range
$prevColumn4 = $this->getPreviousColumn($columnLetter);
$headerRange = "A{$rowNumber}:" . "{$prevColumn4}" . "{$subHeaderRow}";
@ -3440,7 +3602,9 @@ class LeadsController extends BaseController
$sheet->getRowDimension($rowNumber)->setRowHeight(25); // Header row height
$sheet->getRowDimension($subHeaderRow)->setRowHeight(20); // Subheader row height
$rowNumber = $subHeaderRow + 2;
// $rowNumber = $subHeaderRow + 2;
$rowNumber = $subHeaderRow + 1;
$column_data = $data['table_data']['data'];
// dd($column_data);
$serial_no = 1;
@ -3728,7 +3892,7 @@ class LeadsController extends BaseController
$row['data'] = array_filter(
$row['data'],
function ($item) {
return in_array($item['subth'], ['Quote asked', '-']);
return in_array($item['subth'], ['Sum Insured', '-',"Liability Limit"]);
}
);
@ -3817,7 +3981,7 @@ class LeadsController extends BaseController
if ($subHeader === $insurer) {
$headerData[] = [
'parentHeader' => $header['parentHeader'],
'subHeaders' => ['Quote asked', $subHeader]
'subHeaders' => ['Sum Insured', $subHeader]
];
break 2; // Exit both loops after match is found
}
@ -3850,8 +4014,8 @@ class LeadsController extends BaseController
$filteredData[] = $item;
}
// Include Proposal with Quote Asked
if ($item['parentth'] === $proposal && $item['subth'] === "Quote asked") {
// Include Proposal with Sum Insured
if ($item['parentth'] === $proposal && ($item['subth'] === "Sum Insured" || $item['subth'] === "Liability Limit")) {
$filteredData[] = $item;
}
@ -3898,10 +4062,15 @@ class LeadsController extends BaseController
$lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first();
if ($lead_file) {
$attachments[] = [
'fileName' => $lead_file['file_name'],
'filePath' => $lead_file_path . $lead_file['file_name']
];
$fullPath = $lead_file_path . $lead_file['file_name'];
if (file_exists($fullPath) && !empty($fileName)) {
$attachments[] = [
'fileName' => $lead_file['file_name'],
'filePath' => $fullPath
];
}
}
}
}

View File

@ -440,8 +440,20 @@ if (!function_exists('name_dup_check_within_family'))
foreach ($family_data as $rkey => $row)
{
if(in_array($row[2],$temp))
{
array_push($result,$row[0]);
{
// Kint::dump($row);
$emp_code = $row[1];
$tempFam = null;
foreach ($family_data as $family) {
if ($family[1] == $emp_code &&!isset($family['temp'])) {
$tempFam = $family;
break; // Stop at the first match
}
}
// Kint::dump($tempFam);
// die();
array_push($result,$tempFam[0]);
}
else
{
@ -449,7 +461,7 @@ if (!function_exists('name_dup_check_within_family'))
}
}
// dd($result);
return $result;
}
}
@ -519,7 +531,15 @@ if (!function_exists('name_and_empid_check_in_db'))
}
if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition' || $current_action == 'enrollment') && count($res))
{
array_push($result['i'],$row[0]);
$emp_code = $row[1];
$tempFam = null;
foreach ($family_data as $family) {
if ($family[1] == $emp_code &&!isset($family['temp'])) {
$tempFam = $family;
break; // Stop at the first match
}
}
array_push($result['i'],$tempFam[0]);
}
}
@ -566,6 +586,15 @@ if (!function_exists('check_dependent_conflict'))
$allowed_parents_count = $temp['either-parents-pil'] == 0 ? $temp['parents'] : 0;
$allowed_parent_in_laws_count = $temp['either-parents-pil'] == 0 ? $temp['parents-in-law'] : 0;
// dd($allowed_adults == 0);
$firstNonTemp = null;
foreach ($family_data as $family) {
if (!isset($family['temp'])) {
$firstNonTemp = $family;
break;
}
}
// Kint::dump($firstNonTemp);
foreach ($family_data as $key => $row)
{
// dd($family_data[0][0]);
@ -580,7 +609,7 @@ if (!function_exists('check_dependent_conflict'))
if($relationship == 'self')
{
$self_gender = $row[4];
$self_emp_row_id = $row[0];
$self_emp_row_id = isset($row['temp']) ? null : $row[0];
}
if($relationship == 'spouse')
{
@ -612,8 +641,9 @@ if (!function_exists('check_dependent_conflict'))
$repeated_count = array_intersect($repeated_relationships_count,$temp_counts);
if(is_array($repeated_count) && count($repeated_count))
{
// Kint::dump($firstNonTemp);die();
$result['status'] = false;
$result['error_data'][] = ['code' => 13,'col_name' => 'relationship','msg' => 'Rule conflict: Twofold relationship found within family','row_id' => $family_data[0][0]];
$result['error_data'][] = ['code' => 13,'col_name' => 'relationship','msg' => 'Rule conflict: Twofold relationship found within family','row_id' => $firstNonTemp[0]];
}
}
// print_r($repeated_count);
@ -630,26 +660,26 @@ if (!function_exists('check_dependent_conflict'))
if($self_gender && $spouse_gender && $self_gender == $spouse_gender)
{
$result['status'] = false;
$result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];
$result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];
}
}
if(($allowed_spouse_count < $received_spouse_count) || ($allowed_child_count < $received_child_count) )
{
$result['status'] = false;
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch
}
// || ($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count)
if($allowed_adults == 1 && $received_parents_count && $received_parent_in_laws_count )
{
$result['status'] = false;
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Parents and Parents in law both not allowed','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Parents and Parents in law both not allowed','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];
if((2 < $received_parents_count) || (2 < $received_parent_in_laws_count))
{
$result['status'] = false;
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch
}
}
//check for any cross parents but not more than two
@ -657,7 +687,7 @@ if (!function_exists('check_dependent_conflict'))
{
// dd($allowed_adults);
$result['status'] = false;
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch
}

View File

@ -0,0 +1,54 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class LeadInstallmentPaymentDetails extends Model
{
protected $table = 'lead_installment_payment_details';
protected $primaryKey = 'id';
protected $allowedFields = [
'lead_id',
'installment_amount',
'payment_date',
'utr_no',
'created_by',
'updated_by',
'is_active'
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}
}

View File

@ -92,7 +92,10 @@ class LeadsModel extends Model
'source_policy_end_date',
'payment_date',
'is_cd'
'is_cd',
'is_installment',
'no_of_installment',
];

View File

@ -1,131 +1,131 @@
<style>
body {
margin-top: 20px;
background: #FAFAFA;
}
body{
margin-top:20px;
background:#FAFAFA;
}
.order-card {
color: #fff;
}
.order-card {
color: #fff;
}
.bg-c-blue {
background: linear-gradient(45deg,#4099ff,#73b4ff);
}
.bg-c-blue {
background: linear-gradient(45deg, #4099ff, #73b4ff);
}
.bg-c-green {
background: linear-gradient(45deg,#2ed8b6,#59e0c5);
}
.bg-c-green {
background: linear-gradient(45deg, #2ed8b6, #59e0c5);
}
.bg-c-yellow {
background: linear-gradient(45deg,#FFB64D,#ffcb80);
}
.bg-c-yellow {
background: linear-gradient(45deg, #FFB64D, #ffcb80);
}
.bg-c-pink {
background: linear-gradient(45deg,#FF5370,#ff869a);
}
.bg-c-pink {
background: linear-gradient(45deg, #FF5370, #ff869a);
}
.bg-c-red {
background: linear-gradient(45deg,#FF4E50,#F9D423);
}
.bg-c-red {
background: linear-gradient(45deg, #FF4E50, #F9D423);
}
.bg-c-purple {
background: linear-gradient(45deg,#9D50BB,#6E48AA);
}
.bg-c-purple {
background: linear-gradient(45deg, #9D50BB, #6E48AA);
}
.bg-c-orange {
background: linear-gradient(45deg,#F2994A,#F2C94C);
}
.bg-c-orange {
background: linear-gradient(45deg, #F2994A, #F2C94C);
}
.bg-c-teal {
background: linear-gradient(45deg,#1ABC9C,#16A085);
}
.bg-c-teal {
background: linear-gradient(45deg, #1ABC9C, #16A085);
}
.bg-c-cyan {
background: linear-gradient(45deg,#00C9FF,#92FE9D);
}
.bg-c-cyan {
background: linear-gradient(45deg, #00C9FF, #92FE9D);
}
.bg-c-lime {
background: linear-gradient(45deg,#A8E063,#56AB2F);
}
.bg-c-lime {
background: linear-gradient(45deg, #A8E063, #56AB2F);
}
.bg-c-indigo {
background: linear-gradient(45deg,#3F51B5,#5A55AE);
}
.bg-c-indigo {
background: linear-gradient(45deg, #3F51B5, #5A55AE);
}
.bg-c-Pelorous {
background: linear-gradient(45deg, #00d6db, #00a8b5);
}
.bg-c-Pelorous {
background: linear-gradient(45deg, #00d6db, #00a8b5);
}
.bg-c-Pelorous2 {
background: linear-gradient(45deg, #02a8b5, #017f8b);
}
.bg-c-Pelorous2 {
background: linear-gradient(45deg, #02a8b5, #017f8b);
}
.bg-c-Pelorous3 {
background: linear-gradient(45deg, #098895, #046063);
}
.bg-c-Pelorous3 {
background: linear-gradient(45deg, #098895, #046063);
}
.bg-c-Grenadier {
background: linear-gradient(45deg, #ff9d37, #ff7a10);
}
.bg-c-Grenadier {
background: linear-gradient(45deg, #ff9d37, #ff7a10);
}
.bg-c-Grenadier2 {
background: linear-gradient(45deg, #ff8010, #ff4c00);
}
.bg-c-Grenadier2 {
background: linear-gradient(45deg, #ff8010, #ff4c00);
}
.bg-c-Grenadier3 {
background: linear-gradient(45deg, #f06306, #cc4b05);
}
.bg-c-Grenadier3 {
background: linear-gradient(45deg, #f06306, #cc4b05);
}
.bg-c-SilverChalice {
background: linear-gradient(45deg, #a3a8a8, #8f9494);
}
.bg-c-SilverChalice {
background: linear-gradient(45deg, #a3a8a8, #8f9494);
}
.bg-c-SilverChalice2 {
background: linear-gradient(45deg, #7e8484, #686e6e);
}
.bg-c-SilverChalice2 {
background: linear-gradient(45deg, #7e8484, #686e6e);
}
.bg-c-SilverChalice3 {
background: linear-gradient(45deg, #5c6363, #434949);
}
.bg-c-SilverChalice3 {
background: linear-gradient(45deg, #5c6363, #434949);
}
.card {
border-radius: 5px;
-webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4,26,55,0.16);
box-shadow: 0 1px 2.94px 0.06px rgba(4,26,55,0.16);
border: none;
margin-bottom: 30px;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.card {
border-radius: 5px;
-webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16);
box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16);
border: none;
margin-bottom: 30px;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.card .card-block {
padding-top: 10px;
padding-bottom: 10px;
padding-left: 25px;
padding-right: 25px;
}
.card .card-block {
padding-top: 10px;
padding-bottom: 10px;
padding-left: 25px;
padding-right: 25px;
}
.order-card i {
font-size: 26px;
}
.order-card i {
font-size: 26px;
}
.f-left {
float: left;
}
.f-left {
float: left;
}
.f-right {
float: right;
}
.f-right {
float: right;
}
.m-b-1{
margin-top: 0;
margin-bottom: 5px;
}
.m-b-1 {
margin-top: 0;
margin-bottom: 5px;
}
</style>
<?php
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team()) ? 'show active' : '';
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID, user_team()) ? 'show active' : '';
?>
<div class="tab-pane fade <?= $isActive ?>" id="leads-dash-tab">
<div class="row">
@ -133,7 +133,9 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,1)">
<div class="card-block">
<h6 class="m-b-20 font-15">Leads</h6>
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($lead_data)? $lead_data['total'] : 0 ?></span></h2>
<h2 class="text-right"><i
class="mdi mdi-playlist-check f-left"></i><span><?= isset($lead_data) ? $lead_data['total'] : 0 ?></span>
</h2>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p>
</div>
@ -143,7 +145,9 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,2)">
<div class="card-block">
<h6 class="m-b-20 font-15">BDS Renewals</h6>
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($bds_renewal) ? $bds_renewal['total'] : 0?></span></h2>
<h2 class="text-right"><i
class="mdi mdi-playlist-check f-left"></i><span><?= isset($bds_renewal) ? $bds_renewal['total'] : 0 ?></span>
</h2>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p>
</div>
@ -151,39 +155,42 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
</div>
</div>
<div class="row">
<div class="status_tile" style="padding-bottom: 10px;padding-left: 17px; ">
<a href="#" onclick="hide_and_show_tile(2)" ><i class="fas fa-arrow-left"></i> Back to Overview</a>
</div>
<div class="status_tile" style="padding-left: 30px;">
<a href="#" id="main_tile" >Current Tile : </a>
</div>
</div>
<div class="row">
<?php
<div class="status_tile" style="padding-bottom: 10px;padding-left: 17px; ">
<a href="#" onclick="hide_and_show_tile(2)"><i class="fas fa-arrow-left"></i> Back to Overview</a>
</div>
<div class="status_tile" style="padding-left: 30px;">
<a href="#" id="main_tile">Current Tile : </a>
</div>
</div>
<div class="row">
<?php
$colorSetCount = count($colorShades); // Number of color sets
$shadeCount = count($colorShades[0]); // Number of shades per set
$index = 0;
foreach ($lead_data as $key => $value) : ?>
<?php
if ($key == "total"|| $key == "won" || substr($key, -4) === "_ids") { continue; } // Skip the total key
<?php
if ($key == "total" || $key == "won" || substr($key, -4) === "_ids") {
continue;
} // Skip the total key
?>
<?php
// Initialize color set and shade indexes
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
// Initialize color set and shade indexes
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
// Get the background color for the current tile
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
// Get the background color for the current tile
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
?>
<?php
$formattedStatus = strlen($key) < 5 ? strtoupper($key): ucwords(str_replace('_', ' ', $key));
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
$showTooltip = strlen($formattedStatus) > 20;
$formattedStatus = strlen($key) < 5 ? strtoupper($key) : ucwords(str_replace('_', ' ', $key));
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
$showTooltip = strlen($formattedStatus) > 20;
?>
<div class="col-md-2 col-xl-1 leadStatusTitle_1" style="display: none;">
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForLeads('<?= esc(strtolower(str_replace(' ', '_', $key)), 'js') ?>','<?= $lead_data[$key . '_ids'] ?? '' ?>')">
<div class="card order-card" style="background: <?= $bgColor ?>;"
onclick="linkRedirectForLeads('<?= esc(strtolower(str_replace(' ', '_', $key)), 'js') ?>','<?= $lead_data[$key . '_ids'] ?? '' ?>')">
<h2 class="text-center"><span><?= $value ?></span></h2>
<h6 class="m-b-20 font-15 text-center"
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
@ -191,35 +198,45 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
</h6>
</div>
</div>
<?php endforeach ?>
</div>
<div class="row">
<?php
<?php
$colorSetCount = count($colorShades); // Number of color sets
$shadeCount = count($colorShades[0]); // Number of shades per set
$index = 0;
foreach ($bds_renewal as $key => $value) : ?>
<?php
if ($key == "total" || substr($key, -4) === "_ids"){ continue; } // Skip the total key
?>
<?php
// Initialize color set and shade indexes
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
$index = 0;
// Get the background color for the current tile
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
foreach ($bds_renewal as $key => $value) : ?>
<?php
if ($key == "total" || substr($key, -4) === "_ids") {
continue;
} // Skip the total key
?>
<?php
$formattedStatus = strlen($key) < 5 ? strtoupper($key): ucwords(str_replace('_', ' ', $key));
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
$showTooltip = strlen($formattedStatus) > 20;
// Initialize color set and shade indexes
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
// Get the background color for the current tile
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
?>
<?php
$formattedStatus = strlen($key) < 5 ? strtoupper($key) : ucwords(str_replace('_', ' ', $key));
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
$showTooltip = strlen($formattedStatus) > 20;
?>
<div class="col-md-2 col-xl-1 leadStatusTitle_2" style="display: none;">
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForPolicy('<?= isset($bds_renewal[$key . '_ids']) ? str_replace(' ', '_', $bds_renewal[$key . '_ids']) : '' ?>')">
<?php
$policyIds = isset($bds_renewal[$key . '_ids'])
? (is_array($bds_renewal[$key . '_ids'])
? implode('_', $bds_renewal[$key . '_ids'])
: str_replace(' ', '_', $bds_renewal[$key . '_ids']))
: '';
?>
<div class="card order-card" style="background: <?= $bgColor ?>;"
onclick="linkRedirectForPolicy('<?= $policyIds ?>')">
<h2 class="text-center"><span><?= $value ?></span></h2>
<h6 class="m-b-20 font-15 text-center"
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
@ -227,23 +244,23 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
</h6>
</div>
</div>
<?php endforeach ?>
</div>
</div>
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
$(".status_tile").hide();
});
function hide_and_show_tile(type,leadType = null) {
function hide_and_show_tile(type, leadType = null) {
if (type == 1) {
$('.leadTypeTile').hide();
$('.status_tile').show();
} else {
$('.leadTypeTile').show();
@ -254,12 +271,12 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
}
if (type == 1 && leadType != null && leadType == 1){
if (type == 1 && leadType != null && leadType == 1) {
$('.leadStatusTitle_1').show();
$('#main_tile').text("Viewing Details For : Leads");
}
if (type == 1 && leadType != null && leadType == 2){
if (type == 1 && leadType != null && leadType == 2) {
$('.leadStatusTitle_2').show();
$("#main_tile").text("Viewing Details For : BDS Renewals");
@ -267,25 +284,25 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
}
function linkRedirectForPolicy(ids){
function linkRedirectForPolicy(ids) {
var url = "<?= base_url("policy_tranction/inception/list") ?>";
var data = {
ids : ids,
is_dashboard : 1
ids: ids,
is_dashboard: 1
}
redirectWithPost(url,data, "POST");
redirectWithPost(url, data, "POST");
}
function linkRedirectForLeads(status,ids){
function linkRedirectForLeads(status, ids) {
var url = "<?= base_url("leads/list") ?>";
var data = {
ids : ids,
is_dashboard : 1
ids: ids,
is_dashboard: 1
}
redirectWithPost(url,data, "POST");
redirectWithPost(url, data, "POST");
}
function redirectWithPost(url, data = {}, method = "GET") {
@ -308,5 +325,4 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
document.body.appendChild(form);
form.submit();
}
</script>

View File

@ -884,7 +884,7 @@
<?php
if (isset($policy_type) && count($policy_type)) {
foreach ($policy_type as $value) {
if ($value['allocg'] != "Non-EB") {
if ($value['allocg'] != "Non-EB" && $value['allocg'] != "Marine") {
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
}
}

View File

@ -256,19 +256,19 @@ hr.solid {
</select>
</div>
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label for="tpa">TPA <span class="text-danger"></span></label>
<select class="form-control" id="tpa" name="tpa">
<option value="">Select TPA</option>
<?php if (isset($tpa)) { ?>
<?php foreach ($tpa as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
<?php //if (isset($tpa)) { ?>
<?php //foreach ($tpa as $value) { ?>
<option value="<?php // echo $value['id'] . '-' . $value['tpa_id'] ?>">
<?php // echo $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
<?php } ?>
<?php //} ?>
<?php //} ?>
</select>
</div>
</div> -->
<div class="form-group col-md-3">
<label for="">Date of Commencement <span class="text-danger">*</span></label>

View File

@ -1,9 +1,9 @@
<div class="modal fade" id="policyRegisterModel" tabindex="-1" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
<div class="modal fade" id="policyRegisterModel" tabindex="-1" aria-labelledby="fullWidthModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="fullWidthModalLabel">REGISTER POLICY INFORMATION</h4>
<button type="button" onclick="resetAllform()" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
@ -150,10 +150,10 @@
</div>
<div class="row">
<div class="col-md-4">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="terrorismSwitch">
<label class="form-check-label" for="terrorismSwitch">Is Terrorism Required?</label>
<div class="col-md-4 dt-switch-wrapper">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="terrorismSwitch">
<label class="custom-control-label" for="terrorismSwitch">Is Terrorism Required?</label>
</div>
</div>
<div class="form-group col-md-4">
@ -166,7 +166,21 @@
<option value="4_month">4 Months</option>
<option value="5_month">5 Months</option>
<option value="6_month">6 Months</option>
<option value="7_month">7 Months</option>
<option value="8_month">8 Months</option>
<option value="9_month">9 Months</option>
<option value="10_month">10 Months</option>
<option value="11_month">11 Months</option>
<option value="12_month">12 Months</option>
<option value="2_year">2 Year</option>
<option value="3_year">3 Year</option>
<option value="4_year">4 Year</option>
<option value="5_year">5 Year</option>
<option value="6_year">6 Year</option>
<option value="7_year">7 Year</option>
<option value="8_year">8 Year</option>
<option value="9_year">9 Year</option>
<option value="10_year">10 Year</option>
</select>
</div>
<div id="locationNoDIV" class="form-group col-md-4">
@ -203,11 +217,11 @@
<div class="text-right">
<button type="submit" id="riskSplitup" class="btn btn-primary">Validate and Add Risk Split up</button>
</div>
<div class="row">
<!-- <div class="row">
<div class="col-md-12 text-right">
<button type="submit" id="submitPolicyRisk" class="btn btn-primary">Submit For Validation</button>
</div>
</div>
</div> -->
</form>
</div>
@ -244,6 +258,20 @@
// console.log("Occupancy : ", occupancyMaster);
var storedPolicyData = {};
storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
var isFormDirty = false;
$(document).ready(function() {
// Listen for changes in all inputs, selects, and textareas within your modal
$('#policyRegisterModel').on('change input', 'input, select, textarea', function() {
// alert("function called");
isFormDirty = true;
// console.log("Form is dirty",isFormDirty);
});
});
$(document).ready(function() {
// resetAllform();
// console.log("Stored date Found : ", typeof(storedPolicyData));
@ -306,6 +334,7 @@
});
$('#productSelectionForm').submit(function(event) {
// console.log("Submit function called");
event.preventDefault();
var isValid = $('#productSelectionForm').parsley().validate();
@ -358,7 +387,8 @@
$("#policyRiskSplitUpForm").submit(function(event) {
event.preventDefault();
isFormDirty = false;
var isValid = $('#policyRiskSplitUpForm').parsley().validate();
// console.log('isValid', isValid);
@ -402,26 +432,38 @@
let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0);
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
let building = [...document.querySelectorAll('[id^="building_"]')].map(el => Number(el.value) || 0);
let content = [...document.querySelectorAll('[id^="content_"]')].map(el => Number(el.value) || 0);
let furniture = [...document.querySelectorAll('[id^="furniture_"]')].map(el => Number(el.value) || 0);
let plantAndMachinery = [...document.querySelectorAll('[id^="plantAndMachinery_"]')].map(el => Number(el.value) || 0);
let electricalFittings = [...document.querySelectorAll('[id^="electricalFittings_"]')].map(el => Number(el.value) || 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0) +
building.reduce((acc, val) => acc + val, 0) +
content.reduce((acc, val) => acc + val, 0) +
furniture.reduce((acc, val) => acc + val, 0) +
plantAndMachinery.reduce((acc, val) => acc + val, 0) +
electricalFittings.reduce((acc, val) => acc + val, 0);
let allowedSI = Number($("#policySI").val()) || 0;
// alert(allowedSI);
if (totalSI > allowedSI) {
toastr.error("Sum Insured Exceeds Allowed Limit", "ERROR");
return false;
if (totalSI != allowedSI) {
console.log("allowedSI : ", allowedSI, " totalSI : ", totalSI);
toastr.error("Sum Insured Does not Match Allowed Limit", "ERROR");
return false;
}
// console.log("Total SI: ", totalSI);
}else{
} else {
let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0);
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
}
}
@ -432,6 +474,10 @@
// Determine the number of dynamic rows based on a field that appears per row
const totalRows = formDataSplitUp.filter(field => field.name === "building[]").length;
if (totalRows != policyDetailsData.location_no) {
toastr.error("Please Enter All Risk Address", "ERROR");
return;
}
// Initialize empty objects for each row
for (let i = 0; i < totalRows; i++) {
groupData.push({});
@ -465,6 +511,7 @@
// console.log("Grouped Data as Objects: ", policyRiskSplitUpData);
savePolicyDataLocal();
});
@ -484,11 +531,28 @@
return;
}
const formData = $("#policyRiskAddressForm").serializeArray();
console.log("formdata 1 : ", formData);
$("[id^='isBasement_']").each(function() {
let checkbox = $(this);
let isChecked = checkbox.is(":checked");
let increment = checkbox.attr("id").split("_")[1];
formData.push({
name: `is_basement[]`,
value: isChecked ? "yes" : "no"
});
});
console.log("formdata 2 : ", formData);
const groupedData = [];
// Determine the number of dynamic rows
const totalRows = formData.filter(field => field.name === "pin_code[]").length;
if (totalRows != policyDetailsData.location_no) {
toastr.error("Please Enter All Risk Address", "ERROR");
return;
}
// Initialize empty objects for each row
for (let i = 0; i < totalRows; i++) {
groupedData.push({});
@ -513,13 +577,14 @@
});
policyRiskAddress = groupedData;
// console.log("Grouped Data as Objects: ", policyRiskAddress);
console.log("Grouped Data as Objects: ", policyRiskAddress);
if (productSelectionData.singleProduct == 'on') {
savePolicyDataLocal();
} else {
// if (productSelectionData.singleProduct == 'on') {
// savePolicyDataLocal();
// } else {
riskSplitup();
}
// }
});
$("#policyDetailsForm").submit(function(event) {
@ -538,14 +603,17 @@
return;
}
var formData = $("#policyDetailsForm").serializeArray();
formData.push({
name: "terrorism",
value: $('#terrorismSwitch').is(':checked') ? 'yes' : 'no'
})
$.each(formData, function(i, field) {
policyDetailsData[field.name] = field.value;
});
// // console.log("form data", policyDetailsData.location_no);
console.log("form data", formData);
if (formData !== null && formData !== '') {
// console.log("form submitted trying to open the ris info tab");
// riskInfoTabOpened();
const riskTab = new bootstrap.Tab(document.getElementById('risk-info-tab'));
riskTab.show();
@ -585,6 +653,14 @@
hideAndShowBurglary();
})
}else{
// alert("you got ir");
policyRiskAddress.forEach(function() {
// console.log("increment count is ", increment2)
addHTMLInputForRiskSplitUP();
validatePolicyBasedOnProductSelection();
hideAndShowBurglary();
})
}
} else {
if (contianertoCheck.innerHTML == "") {
@ -640,29 +716,29 @@
// policyRiskAddress
newRowRisk.innerHTML += `
<h5 class = "fire">Fire (Sookshma/Laghu) Details</h5>
<h5 class = "fire">Fire <?= isset($product) ? $product : "" ?> Details</h5>
<h5>Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}</h5>
<input type = "hidden" name = "location_selected[]" value = "${policyRiskAddress[increment2-1].select_location}" id = "location_selected_${increment2}" />
<div class = "row">
<div class="form-group col-md-4 multi_location_company">
<label for="building_${increment2}">Building</label>
<input type="text" id="building_${increment2}" name="building[]" class="form-control multi_location_company " />
<input type="number" id="building_${increment2}" name="building[]" class="form-control multi_location_company " />
</div>
<div class="form-group col-md-4 multi_location_company ">
<div class="form-group col-md-4 multi_location_company ">
<label for="content_${increment2}">Content</label>
<input type="text" id="content_${increment2}" name="content[]" class="form-control multi_location_company " />
<input type="number" id="content_${increment2}" name="content[]" class="form-control multi_location_company " />
</div>
<div class="form-group col-md-4 multi_location_company ">
<label for="furniture_${increment2}">Furniture/Office Equipment</label>
<input type="text" id="furniture_${increment2}" name="furniture[]" class="form-control multi_location_company " />
<input type="number" id="furniture_${increment2}" name="furniture[]" class="form-control multi_location_company " />
</div>
<div class="form-group col-md-4 multi_location_company ">
<label for="plantAndMachinery_${increment2}">Plant and Machinery</label>
<input type="text" id="plantAndMachinery_${increment2}" name="plant_and_machinery[]" class="form-control multi_location_company " />
<input type="number" id="plantAndMachinery_${increment2}" name="plant_and_machinery[]" class="form-control multi_location_company " />
</div>
<div class="form-group col-md-4 multi_location_company">
<label for="electricalFittings_${increment2}">Electrical Fittings</label>
<input type="text" id="electricalFittings_${increment2}" name="electrical_fittings[]" class="form-control multi_location_company "/>
<input type="number" id="electricalFittings_${increment2}" name="electrical_fittings[]" class="form-control multi_location_company "/>
</div>
</div>
<br>
@ -678,7 +754,7 @@
<input type="number" id="rawMaterial_${increment2}" name="raw_material[]" class="form-control multi_location_company" />
</div>
<div class="form-group col-md-4 multi_location_company">
<label for="finishedStock_${increment2}">Finished Stock</label>
<label for="finishedStock_${increment2}">Stock</label>
<input type="number" id="finishedStock_${increment2}" name="finished_stock[]" class="form-control multi_location_company"/>
</div>
</div>
@ -782,20 +858,9 @@
<label for="address3_${increment}">Address 3</label>
<input type="text" id="address3_${increment}" name="address3[]" class="form-control" />
</div>
<div class="form-group col-md-4">
<label for="constructionType_${increment}">Construction Type<span class="text-danger">*</span></label>
<select id="constructionType_${increment}" name="construction_type[]" class="form-control">
<option value="kutcha" selected>Kutcha</option>
<option value="pucca">Pucca</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="basementSI_${increment}">Basement Sum Insured</label>
<input type="text" id="basementSI_${increment}" name="basement_si[]" class="form-control"/>
</div>
<div class="form-group col-md-4">
<label for="occupancy_${increment}">Occupancy<span class="text-danger">*</span></label>
<select id="occupancy_${increment}" name="occupancy[]" class="form-control" onchange="showRequiredFieldsBasedOnLocation('occupancy_${increment}')" required>
<div class="form-group col-md-4" style = "width: 10px !important;">
<label for="occupancy_${increment}">Occupancy Risk<span class="text-danger">*</span></label>
<select id="occupancy_${increment}" name="occupancy[]" class="form-control" onchange="showRequiredFieldsBasedOnLocation(this)" required>
<option value="">Select</option>
${occupancyMaster.map(occupancy =>
`<option value="${occupancy.id}">${occupancy.description}</option>`
@ -803,16 +868,30 @@
</select>
</div>
<div class="form-group col-md-4 common_location_occupancy">
<label for="isBasement_${increment}">Basement<span class="text-danger">*</span></label>
<select id="isBasement_${increment}" name="is_basement[]" class="form-control common_location_occupancy" required>
<option value="yes" selected>Yes</option>
<option value="no">No</option>
<label for="iibCode_${increment}">IIB Code<span class="text-danger">*</span></label>
<input type="text" onchange = "updateOccupancyRisk(this)" id="iibCode_${increment}" name="iib_code[]" class="form-control common_location_occupancy" required>
</div>
<div class="form-group col-md-4">
<label for="constructionType_${increment}">Construction Type<span class="text-danger">*</span></label>
<select id="constructionType_${increment}" name="construction_type[]" class="form-control">
<option value="kutcha" selected>Kutcha</option>
<option value="pucca">Pucca</option>
</select>
</div>
<div class="form-group col-md-4 common_location_occupancy">
<label for="iibCode_${increment}">IIB Code<span class="text-danger">*</span></label>
<input type="text" id="iibCode_${increment}" name="iib_code[]" class="form-control common_location_occupancy" required>
<div class="dt-switch-wrapper col-md-4 common_location_occupancy d-flex align-items-center">
<div class="custom-control custom-switch d-flex justify-content-center">
<input type="checkbox" class="custom-control-input" id="isBasement_${increment}" onchange="hideShowBasement(this)">
<label class="custom-control-label" for="isBasement_${increment}">Basement</label>
</div>
</div>
<div class="form-group col-md-4" style="display:none" >
<label for="basementSI_${increment}">Basement Utilisation</label>
<input type="text" id="basementSI_${increment}" name="basement_si[]" class="form-control"/>
</div>
<div class="form-group col-md-4 multiLocationOccupancy">
<label for="select_location_${increment}">Location <span class="text-danger">*</span></label>
<select required id="select_location_${increment}" name="select_location[]" class="form-control multiLocationOccupancy">
@ -850,26 +929,13 @@
`;
// newRow2.innerHTML += `
// <div class = "row">
// <div class="col-md-12 text-right">
// <button type ="submit" id="riskSplitup" class="btn btn-primary">Validate and Add Risk Split up</button>
// </div>
// </div>
// <div class = "row">
// <div class="col-md-12 text-right">
// <button type ="submit" id="submitPolicyRisk" class="btn btn-primary">Submit For Validation</button>
// </div>
// </div>
// `;
container.appendChild(newRow);
// container.appendChild(newRow2);
const selectElement = document.getElementById(`select_location_${increment}`);
selectElement.innerHTML = "";
for (let i = 1; i <= policyDetailsData.location_no; i++) {
console.log("location no : ", policyDetailsData.location_no);
const option = document.createElement('option');
option.value = `Location ${i}`;
option.textContent = `Location ${i}`;
@ -887,37 +953,33 @@
});
$(document).on('click', '.duplicate-btn', function() {
// console.log("button is clicked");
// console.log("increment cout ", increment);
$(document).on('click', '.duplicate-btn', function () {
if (policyDetailsData.location_no >= increment) {
const $rowToClone = $(this).closest('.form-row');
// Destroy Select2 for the current and previous occupancy fields
$(`#occupancy_${increment}`).select2('destroy');
$(`#occupancy_${increment - 1}`).select2('destroy');
// Clone the row
const $clone = $rowToClone.clone();
$clone.find('.select2-hidden-accessible').each(function() {
// Clean up select2 artifacts from the clone
$clone.find('.select2-hidden-accessible').each(function () {
$(this).select2('destroy');
});
$clone.find('.select2-container').remove();
// Increment the counter
// Update all IDs and reset values in the clone
$clone.find('[id]').each(function() {
// Update all IDs in the clone
$clone.find('[id]').each(function () {
const oldId = $(this).attr('id');
const newId = oldId.replace(/_(\d+)$/, `_${increment}`);
$(this).attr('id', newId);
});
// Update labels to match new IDs
$clone.find('label').each(function() {
// Update all labels
$clone.find('label').each(function () {
const oldFor = $(this).attr('for');
if (oldFor) {
const newFor = oldFor.replace(/_(\d+)$/, `_${increment}`);
@ -928,18 +990,35 @@
// Insert the cloned row after the original
$clone.insertAfter($rowToClone);
let selectedLocation = $(`#select_location_${increment}`).val();
$(`#select_location_${increment} option[value="${selectedLocation}"]`).remove();
$(`#occupancy_${increment}`).select2();
// Refill and update the select_location dropdown
const selectElement = document.getElementById(`select_location_${increment}`);
selectElement.innerHTML = "";
for (let i = 1; i <= policyDetailsData.location_no; i++) {
const option = document.createElement('option');
option.value = `Location ${i}`;
option.textContent = `Location ${i}`;
selectElement.appendChild(option);
}
for (let i = 1;i<increment;i++){
let selectedLocation = $(`#select_location_${i}`).val();
$(`#select_location_${increment} option[value="${selectedLocation}"]`).remove();
}
// Re-initialize Select2 for both fields
$(`#occupancy_${increment - 1}`).select2(); // previous
$(`#occupancy_${increment}`).select2(); // current
$(`#iibCode_${increment}`).val(""); // current
increment++;
} else {
toastr.error("Maximum no of allowed locations reached", "Error")
toastr.error("Maximum number of allowed locations reached", "Error");
}
});
})
function addOrRemoveAdd() {
// console.log("chceck box clicked");
if ($("#sameAsCommunicationAddress").is(":checked")) {
@ -969,10 +1048,10 @@
$('[id^="select_location"]').hide().prev('label').hide();
$("[id^='select_location']").removeAttr('required', false);
// $('[class*="single_location_occupancy"]').hide().removeAttr("required", false);
$('[class*="multi_location_company"]').hide().removeAttr('required');
$("#riskSplitup").hide();
// $('[class*="multi_location_company"]').hide().removeAttr('required');
// $("#riskSplitup").hide();
$("#submitPolicyRisk").show();
$("#risksplitupTab").hide();
// $("#risksplitupTab").hide();
// $('[class*="multiLocationOccupancy"]').hide().removeAttr('required', false);
// $('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false);
@ -1005,79 +1084,56 @@
}
function showRequiredFieldsBasedOnLocation(element) {
if (element) {
// alert(element);
var selectedOccupancy = $(`#${element}`).val();
var selectedOccupancy = $(element).val(); // FIXED
var selectedOccupancyMasterRow = occupancyMaster.find(iib => iib.id == selectedOccupancy);
// console.log("selected occupancy masater ", selectedOccupancyMasterRow)
// console.log("selected occupancy masater ", occupancyMaster)
if (!selectedOccupancyMasterRow) return;
var iibCODE = selectedOccupancyMasterRow.iib_code;
// console.log("selected occupancy masater ", iibCODE)
var elementID = element;
var elementID = element.id; // FIXED
let increment = elementID.split("_").pop();
// console.log("selected occupancy masater increment ", increment)
// console.log("selected occupancy masater element ", $(`#iibCode_${increment}`))
setTimeout(function() {
$(`#iibCode_${increment}`).val(iibCODE); // Set the value
// console.log("Selected --------------------", $(`#iibCode_${increment}`).val()); // Log the value
}, 1000);
$(`#iibCode_${increment}`).val(iibCODE);
}, 500);
}
// console.log("onchange occupancy function called ");
// // console.log("onchange occupancy function called ", selectedOccupancy);
// // console.log("onchange occupancy function called ", selectedOccupancyMasterRow);
// // console.log("onchange occupancy function called ", iibCODE);
// // console.log("onchange occupancy function called ", increment);
$('[class*="common_location_occupancy"]').show().prop("required", "required");
$('[class*="common_location_occupancy"]').show().prop("required", true);
var selectedProduct = productSelectionData;
if (selectedProduct.singleProduct == 'on') {
$('[class*="single_location_occupancy"]').show().prop("required", "required");
} else if (selectedProduct.multipleProduct == 'on') {
// // console.log("Muliple location");f
$('[class*="multiLocationOccupancy"]').show().prop('required', 'required');
if (selectedProduct.singleProduct === 'on') {
$('[class*="single_location_occupancy"]').show().prop("required", true);
} else if (selectedProduct.multipleProduct === 'on') {
$('[class*="multiLocationOccupancy"]').show().prop('required', true);
if (selectedProduct.multilocation_type == "multiLocation") {
// // console.log("multiple location without Floater");
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required');
} else if (selectedProduct.multilocation_type == "multiFloater") {
// // console.log("Muliple location With Floater");
$('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false);
} else if (selectedProduct.multilocation_type == "stockFloater") {
// // console.log("multiple location with stock floater");
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required');
$('[class*="stockSI"]').hide().removeAttr('required', false);
if (selectedProduct.multilocation_type === "multiLocation") {
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', true);
} else if (selectedProduct.multilocation_type === "multiFloater") {
$('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required');
} else if (selectedProduct.multilocation_type === "stockFloater") {
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', true);
$('[class*="stockSI"]').hide().removeAttr('required');
}
}
}
function registerPolicyData() {
var policyType;
if (totalSI<50000000){
if (totalSI < 50000000) {
policyType = "Bharat Sookshma Udyam Suraksha (BSUS)"
} else if (totalSI > 50000000 && totalSI < 500000000){
} else if (totalSI > 50000000 && totalSI < 500000000) {
policyType = "Bharat Laghu Udyam Suraksha (BLUS)"
}else if (totalSI >500000000 ){
} else if (totalSI > 500000000) {
policyType = "Standard Fire and Special Perils (SFSP)";
}
}
// Build the initial JSON object with productSelection and policyDetails
var outputData = {
policyType:policyType,
policyType: policyType,
productSelection: productSelectionData,
policyDetails: policyDetailsData,
locations: []
@ -1108,6 +1164,8 @@
}
function savePolicyDataLocal() {
isSaved = false;
// Generate the JSON structure using the registerPolicyData function
var policyData = registerPolicyData();
@ -1127,18 +1185,20 @@
// Save the updated data back to localStorage
localStorage.setItem('policyData', JSON.stringify(existingData));
if (!$.isEmptyObject(existingData)) {
// console.log("DATA FROM DB : ", (existingData));
let data = (existingData);
Object.keys(data).forEach(key => {
policySummary[key] = addPolicySummaryTable(data[key], key);
prependTable(policySummary[key],key);
prependTable(policySummary[key], key);
});
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
toastr.success("Policy Information Collected ","SUCCESS");
toastr.success("Policy Information Collected ", "SUCCESS");
closeModal();
changeTerrorism(Number($("#policySI").val()));
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
// console.log("Updated policy data in localStorage:", existingData);
@ -1220,7 +1280,7 @@
loadPolicyDataBack(data);
assignDataToFields(data);
// alert("inside else");
}else{
} else {
// alert("nothing");
}
// console.log("policy data : ", data);
@ -1255,9 +1315,9 @@
const policyDetails = data.policyDetails;
Object.keys(policyDetails).forEach(key => {
$(`#${key}`).val(policyDetails[key]);
// // console.log("Key ",key," set value : ",policyDetails[key]);
// console.log("Key ", key, " set value : ", policyDetails[key]);
});
$('#terrorismSwitch').prop('checked', policyDetails.terrorism === "yes")
// Populate Risk Addresses
data.locations.forEach((location, index) => {
addHTMLInputForRiskAddress();
@ -1277,12 +1337,13 @@
$(`#constructionType${prefix}`).val(risk.construction_type);
$(`#occupancy${prefix}`).select2();
$(`#occupancy${prefix}`).val(risk.occupancy).trigger("change");
$(`#isBasement${prefix}`).val(risk.is_basement);
// $(`#isBasement${prefix}`).val(risk.is_basement);
$(`#iibCode${prefix}`).val(risk.iib_code);
$(`#buisness_desc${prefix}`).val(risk.buisness_desc);
$(`#select_location${prefix}`).val(risk.select_location);
$(`#basementSI${prefix}`).val(risk.basement_si);
$(`#isBasement${prefix}`).prop('checked', risk.is_basement === "yes").trigger("change");
@ -1318,7 +1379,7 @@
});
isFormDirty = false; // Reset the form dirty flag
}
function checkandassignLeadData() {
@ -1332,11 +1393,12 @@
function assignLeadData() {
const lead_data = <?= json_encode(json_decode($lead_data['custom_fields'])) ?>;
var clientName = <?= isset($lead_data['client_name']) ? json_encode($lead_data['client_name']) : ""?>;
var clientName = <?= isset($lead_data['client_name']) ? json_encode($lead_data['client_name']) : "" ?>;
var client_type = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var mobile = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var email = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var mobile = <?= isset($lead_data['contact_person_mobile']) ? $lead_data['contact_person_mobile'] : "" ?>;
var contact_email = "<?= isset($lead_data['contact_person_email']) ? $lead_data['contact_person_email'] : "" ?>";
var panNo = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var buisnessType = <?= isset($lead_data['entity_type_id']) ? $lead_data['entity_type_id'] : "" ?>;
// console.log("client_type : ".client_type);
if (lead_data) {
// lead_data = JSON.parse(lead_data);
@ -1358,9 +1420,16 @@
}
}
$("#client_type").val(client_type).trigger("change");
$("#insured_name").val(clientName);
$("#address1").val(lead_data.address);
$("#pin_code").val(lead_data.pincode);
$("#mobile").val(mobile);
$("#email").val(contact_email);
console.log("buisness type : ", buisnessType);
$("#type_of_buisness").val(buisnessType);
// var policy_type = lead_data.policy_type_id;
}
}
@ -1378,6 +1447,8 @@
}
function resetAllform() {
// isFormDirty = false;
// console.log("FORM RESETED SUCCESSFULLY");
$("#productSelectionForm")[0].reset();
$("#policyDetailsForm")[0].reset();
@ -1403,12 +1474,39 @@
hideAndShowBurglary()
}
$('.close').on('click', function() {
$('.tab-pane').removeClass('active show');
$('.close').on('click', function(e) {
console.log("is form dirty : ", isFormDirty);
if (isFormDirty) {
e.preventDefault();
e.stopPropagation();
Swal.fire({
title: 'You have unsaved changes!',
text: 'Do you want to close without saving your data?',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, close it',
cancelButtonText: 'No, stay here',
}).then((result) => {
if (result.isConfirmed) {
isFormDirty = false; // Reset flag
closeModal();
resetAllform();
// $('#policyRegisterModel').modal('hide');
$('.tab-pane').removeClass('active show');
$("#addRiskInfo, #addRiskSplitUp").empty();
}
});
return false;
} else {
resetAllform();
$('.tab-pane').removeClass('active show');
$("#addRiskInfo, #addRiskSplitUp").empty();
}
});
$("#addRiskInfo, #addRiskSplitUp").empty();
})
function copyFirePolicy() {
// console.log("Copying Fire Policy Data...");
@ -1429,4 +1527,108 @@
hideAndShowBurglary();
}
$(document).on('input', 'input[id^="pin_code"]', function() {
// alert("inside");
let value = $(this).val().replace(/\D/g, '').slice(0, 6);
$(this).val(value);
});
function closeModal() {
document.querySelector('#policyRegisterModel [data-dismiss="modal"]').click();
}
function updateOccupancyRisk(element) {
let iibCode = $(element).val();
// Find matching occupancy row
let matchedOccupancy = occupancyMaster.find(iib => iib.iib_code == iibCode);
let matchedId = matchedOccupancy ? matchedOccupancy.id : null;
// Get increment from the element ID, like "iibCode_3"
let elementID = element.id;
let increment = elementID.split("_").pop(); // Extract "3" from "iibCode_3"
if (matchedId) {
$(`#occupancy_${increment}`).val(matchedId).trigger("change");
$(`#occupancy_${increment}`).select2();
} else {
toastr.error("Invalid IIB Code", "Error");
}
}
function hideShowBasement(element) {
let elementID = element.id;
let increment = elementID.split("_").pop();
let isBasement = $(`#isBasement_${increment}`).is(":checked");
// Get the label associated with the input
let label = $(`label[for='basementSI_${increment}']`);
if (isBasement) {
$(`#basementSI_${increment}`).parent().show();
$(`#basementSI_${increment}`).prop("required", "required");
// Add * if not already there
if (label.find(".text-danger").length === 0) {
label.append('<span class="text-danger">*</span>');
}
} else {
$(`#basementSI_${increment}`).parent().hide();
$(`#basementSI_${increment}`).removeAttr("required");
// Remove * if exists
label.find(".text-danger").remove();
}
}
// function saveDataAsDraft() {
// return new Promise((resolve) => {
// const forms = [
// document.getElementById('productSelectionForm'),
// document.getElementById('policyDetailsForm'),
// document.getElementById('policyRiskAddressForm'),
// document.getElementById('policyRiskSplitUpForm')
// ];
// let isDirty = false;
// forms.forEach(form => {
// if (form) {
// const formInputs = form.querySelectorAll('input, select, textarea');
// formInputs.forEach(input => {
// if (input.defaultValue !== input.value && input.value !== '') {
// isDirty = true;
// }
// if (input.type === 'checkbox' || input.type === 'radio') {
// if (input.checked !== input.defaultChecked) {
// isDirty = true;
// }
// }
// });
// }
// });
// if (isDirty) {
// Swal.fire({
// title: 'You have unsaved changes!',
// text: 'Do you want to close without saving your data?',
// icon: 'warning',
// showCancelButton: true,
// confirmButtonText: 'Yes, close it',
// cancelButtonText: 'No, stay here',
// }).then((result) => {
// resolve(result.isConfirmed);
// });
// } else {
// resolve(true); // No unsaved changes, allow closing
// }
// });
// }
</script>

View File

@ -4,7 +4,7 @@
<?php foreach ($multi_file_data as $file) : ?>
<div class="form-check">
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>" checked>
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>">
<label class="form-check-label" for="file_<?= $file['id'] ?>">
<?= htmlspecialchars($file['docs_name']) ?> - <?= htmlspecialchars($file['file_name']) ?>
</label>

View File

@ -20,7 +20,11 @@
</div>
<!-- Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -20,7 +20,11 @@
</div>
<!-- Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -0,0 +1,32 @@
<hr>
<div class="form-row custom_fields">
<!-- Risk Location -->
<div class="form-group col-md-6">
<label>Risk Location</label><br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="risk_location" value="single" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'single' ? 'checked' : ''; ?>>
<label class="form-check-label">Single</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="risk_location" value="multi_with_floter" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_with_floter' ? 'checked' : ''; ?>>
<label class="form-check-label">Multi with Floter</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="risk_location" value="multi_without_floter" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_without_floter' ? 'checked' : ''; ?>>
<label class="form-check-label">Multi without Floter</label>
</div>
</div>
<!-- Address -->
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>
</div>

View File

@ -68,7 +68,11 @@
</div>
<!-- Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address:</label>
<textarea class="form-control" id="address" name="address"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -14,7 +14,7 @@
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="multi_floater" name="risk_location" value="multi_with_floter"
<?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_with_floter' ? 'checked' : ''; ?>>
<label class="form-check-label" for="multi_floater">multi_with_floter</label>
<label class="form-check-label" for="multi_floater">Multi With Floater</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="multi_no_floater" name="risk_location" value="multi_without_floter"
@ -81,7 +81,11 @@
</div>
<!-- Communication Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Communication Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -68,7 +68,11 @@
</div>
<!-- Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -14,7 +14,11 @@
</div>
<!-- Address of the Insured -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address of the Insured</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -35,7 +35,11 @@
</div>
<!-- Address of the Insured -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address of the Insured</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -35,7 +35,11 @@
</div>
<!-- Address of the Insured -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address of the Insured</label>
<textarea class="form-control" id="address" name="address" rows="1"></textarea>
</div>

View File

@ -0,0 +1,35 @@
<?php
// Example: Loop through $installments array if available
if (!empty($installments)) {
foreach ($installments as $index => $installment) {
?>
<div class="form-row align-items-end">
<input type="hidden" name="installment_primary_key[]" value="<?= isset($installment['id']) ? $installment['id'] : '' ?>">
<div class="form-group col-md-3">
<label for="installment_amount">Installment Amount</label>
<input type="text" class="form-control" name="installment_amount[]" placeholder="Enter Amount"
value="<?= isset($installment['installment_amount']) ? $installment['installment_amount'] : '' ?>">
</div>
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control payment_date" name="payment_date[]" placeholder="DD/MM/YYYY"
value="<?= isset($installment['payment_date']) && $installment['payment_date'] != '0000-00-00' ? date('d/m/Y', strtotime($installment['payment_date'])) : '' ?>">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No."
value="<?= isset($installment['utr_no']) ? $installment['utr_no'] : '' ?>">
</div>
<div class="form-group col-md-2">
<button type="button" class="btn btn-danger remove-installment">X</button>
</div>
</div>
<?php
}
}
?>

View File

@ -178,7 +178,11 @@
</div>
<!-- Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1">value="<?= isset($lead_edit_data['address']) ? $lead_edit_data['address'] : '' ?>"</textarea>
</div>

View File

@ -2,7 +2,7 @@
<div class="form-row custom_fields">
<!-- Risk Location -->
<div class="form-group col-md-6">
<!-- <div class="form-group col-md-6">
<label>Risk Location</label>
<div>
<?php
@ -21,7 +21,7 @@
<label class="form-check-label" for="multi_no_floater">Multi without Floater</label>
</div>
</div>
</div>
</div> -->
<!-- Policy Period -->
<div class="form-group col-md-3">
@ -67,7 +67,11 @@
</div>
<!-- Communication Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Communication Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -27,6 +27,10 @@
</div>
<!-- Address -->
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-4">
<label for="address">Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>

View File

@ -35,7 +35,11 @@
</div>
<!-- Communication Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Communication Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -33,7 +33,11 @@
</div>
<!-- Communication Address -->
<div class="form-group col-md-6">
<div class="form-group col-md-3">
<label for="pinCode">Pin Code</label>
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
</div>
<div class="form-group col-md-3">
<label for="address">Communication Address</label>
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
</div>

View File

@ -491,25 +491,14 @@
<div class="form-row">
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="placement_date">Placement Date</label>
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['placement_date']) ? date('d/m/Y', strtotime($lead_data['placement_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label style = "padding-left: 15px;padding-top: 33px;" for="is_cd_switch">CD </label>
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="150" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>
>
<label for="is_cd_switch">CD Entry</label>
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="218" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>>
</div>
<div class="form-group col-md-3">
@ -519,20 +508,54 @@
<?php if (isset($lead_data['is_cd']) && $lead_data['is_cd'] == 1 || !isset($lead_data['is_cd'])) { ?>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="total_amount">Total Amount</label>
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="total_amount">Total Amount</label>
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<?php } ?>
<div class="form-group col-md-3">
<label for="is_installment_switch">Installemnt </label>
<input id="is_installment_switch" type="checkbox" name = "is_installment" value = "1" data-toggle="toggle" data-on="With Installments" data-off="Without Installments" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="218" <?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 ? 'checked' : '' ?>>
</div>
<?php if (isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1) { ?>
<div class="form-group col-md-3">
<label for="no_of_installment">No of installments</label>
<input type="text" class="form-control" id="no_of_installment" name="no_of_installment" placeholder="" value="<?= isset($lead_data['no_of_installment']) ? $lead_data['no_of_installment'] : "1" ?>">
</div>
<?php } ?>
<?php if (isset($lead_data['is_installment']) && $lead_data['is_installment'] == 0 || !isset($lead_data['is_installment'])) { ?>
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
</div>
<?php } ?>
</div>
<hr>
<div id="installment_form_row">
<?= isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
</div>
<hr>
<div class="form-row">
<div class="form-group col-md-6">
@ -557,7 +580,7 @@
>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<option value="<?= $user['id'];?>">
<option value="<?= $user['email'];?>">
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } }?>
@ -694,6 +717,7 @@
policy_terms = JSON.parse(policy_terms_json);
jsonDataForHide = data?.premium_data ?? null;
console.log("data", data);
if(data){
proposalDataForDropDown = data.proposal_data;
if(!data.premium_data){
@ -837,7 +861,7 @@
$(document).ready(function () {
setInterval(function () {
submitData(1);
}, 15000);
}, 20000);
});
@ -3194,7 +3218,7 @@ function insurerAndClientMailPopUp(){
function placementMailPopUp() {
console.log(proposalDataForDropDown);
console.log("proposalDataForDropDown", proposalDataForDropDown);
const selectElement = document.getElementById('proposals');
@ -3451,137 +3475,6 @@ function constructURL(url_type) {
}
}
// function constructURL_ForInsurerAndClientMailSend() {
// var lead_id = $('#lead_id').val();
// var mail_content = $('#insurer_and_client_mail_content').val();
// var subject = $('#mail_subject').val();
// var apiURL;
// if (RFQ_or_QCR == 2) {
// apiURL = '<?= base_url('leads/sendMail') ?>?lead_id=' + encodeURIComponent(lead_id) +
// '&file_type=qcr' +
// '&recipient_type=client' +
// '&recipient_mail='+
// '&mail_content=' + String(mail_content) +
// '&subject=' + String(subject);
// } else {
// var insurerContact = $('#insurerContact').val();
// insurerContact = insurerContact.map(Number);
// console.log(insurerContact);
// apiURL = '<?= base_url('leads/sendMail') ?>?lead_id=' + encodeURIComponent(lead_id) +
// '&file_type=rfq' +
// '&recipient_type=insurer' +
// '&recipient_mail=' + JSON.stringify(insurerContact)+
// '&mail_content=' + String(mail_content) +
// '&subject=' + String(subject);
// }
// console.log(apiURL);
// ajaxRequest(apiURL);
// }
// function constructURL_ForInternalMailSend() {
// var lead_id = $('#lead_id').val();
// let to = $('#to').val();
// let mail_content = $('#internal_mail_content').val();
// let subject = $('#subject').val();
// let cc = $('#cc').val();
// cc = cc.map(Number);
// cc = JSON.stringify(cc)
// var file_type = 'rfq';
// if (RFQ_or_QCR == 2) {
// file_type = 'qcr'
// }
// var queryParams = {
// lead_id: lead_id,
// file_type: file_type,
// recipient_type: 'internal',
// to: to,
// cc: cc,
// subject: subject,
// // mail_content: mail_content,
// recipient_mail: '',
// mail_content: mail_content,
// subject: subject,
// };
// const queryString = objectToQueryString(queryParams);
// console.log(queryString);
// var apiURL = '<?= base_url('leads/sendMail') ?>?'+queryString
// console.log(apiURL);
// ajaxRequest(apiURL);
// }
// function constructURL_ForPlacementMailSend() {
// var lead_id = $('#lead_id').val();
// let to = $('#placement_to').val();
// console.log('to mail', to);
// let placement_date = $('#placement_date').val();
// let utr_no = $('#utr_no').val();
// let premium_amount = $('#premium_amount').val();
// let total_amount = $('#total_amount').val();
// let cd_amount = $('#cd_amount').val();
// let subject = $('#placement_subject').val();
// // let = mail_content = $('#placement_mail_content').val();
// let proposal_insurer = $('#proposals option:selected').data('id');
// let insurer_and_branch = $('#proposals').val();
// let cc = $('#placement_cc').val();
// cc = cc.map(Number);
// // cc = cc.split(',').map(email => email.trim());
// cc = JSON.stringify(cc);
// // to = to.map(String);
// // to = JSON.stringify(to)
// to = to.split(',').map(email => email.trim());
// to = JSON.stringify(to)
// console.log('to (array):', to);
// var file_type = 'rfq';
// if (RFQ_or_QCR == 2) {
// file_type = 'qcr'
// }
// var queryParams = {
// lead_id: lead_id,
// file_type: file_type,
// recipient_type: 'placement',
// to: to,
// cc: cc,
// subject: subject,
// proposal_insurer: proposal_insurer,
// insurer_and_branch: insurer_and_branch,
// recipient_mail: to,
// placement_date: placement_date,
// utr_no: utr_no,
// premium_amount: premium_amount,
// total_amount: total_amount,
// cd_amount: cd_amount,
// };
// const queryString = objectToQueryString(queryParams);
// console.log(queryString);
// var apiURL = '<?= base_url('leads/sendMail') ?>?'+queryString
// console.log(apiURL);
// ajaxRequest(apiURL);
// }
// Insurer and Client Mail
function constructURL_ForInsurerAndClientMailSend() {
@ -3694,16 +3587,44 @@ function constructURL_ForPlacementMailSend() {
let proposal_insurer = $('#proposals option:selected').data('id');
let insurer_and_branch = $('#proposals').val();
let cc = $('#placement_cc').val();
let no_of_installment = $('#no_of_installment').val();
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
console.log("cc1", cc);
// Process `to` field
to = to.split(',').map(email => email.trim());
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
// cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
var selectedFiles = [];
$('#placement_mail_attachment .multi_file_attachment:checked').each(function () {
selectedFiles.push($(this).val());
});
let data = [];
$('#installment_form_row .form-row').each(function () {
let installment_amount = $(this).find('input[name="installment_amount[]"]').val();
let payment_date = $(this).find('input[name="payment_date[]"]').val();
let utr_no = $(this).find('input[name="utr_no[]"]').val();
let id = $(this).find('input[name="installment_primary_key[]"]').val();
console.log('installment_primary_key', id);
let obj = {
lead_id: lead_id,
installment_amount: installment_amount,
payment_date: payment_date,
utr_no: utr_no
};
if (id != undefined && id != null && id != '') {
obj.id = id;
}
data.push(obj);
});
// Prepare FormData
var formData = new FormData();
formData.append('lead_id', lead_id);
@ -3723,14 +3644,15 @@ function constructURL_ForPlacementMailSend() {
formData.append('cd_amount', cd_amount);
formData.append('mail_content', mail_content);
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
formData.append('installments', JSON.stringify(data));
formData.append('no_of_installment', no_of_installment);
formData.append('is_installment', is_installment);
ajaxRequest(formData);
}
function ajaxRequest(formData) {
var apiURL = '<?= base_url('leads/sendMail') ?>';
@ -3831,23 +3753,40 @@ function getInsurerBranchContacts(input){
function appendInsurerContact(data) {
console.log(data)
console.log(data);
$('#placement_to').empty();
$('#placement_to').append($('<option>', {
// Clear existing options and CC entries
$('#placement_to').empty().append($('<option>', {
value: '',
text: 'Select'
}));
$('.ccInsurerMail').remove();
$.each(data, function(index, item) {
var option = $('<option>', {
$('#placement_to').append($('<option>', {
value: item.id,
text: item.contact_person_email
});
$('#placement_to').append(option);
text: item.contact_person_email
}));
$('#placement_cc').append($('<option>', {
value: item.contact_person_email ?? "",
text: (item.contact_person_name || '') + (item.contact_person_email ? ' - ' + item.contact_person_email : '') + ' (Insurer)',
class: 'ccInsurerMail'
}));
});
// Re-initialize Select2
$('#placement_cc').val(null).select2({
placeholder: 'Select CC Mail'
});
// Style Select2 textarea input
setTimeout(function () {
$('textarea.select2-search__field').attr('rows', '1').css('resize', 'none');
}, 0);
}
$('.close').click(function(){
$('#to').select2({
@ -5760,7 +5699,6 @@ function appendMultiFileData(data) {
}
function convertRFQJsonToQCRJson(json) {
if (json) {
@ -5889,6 +5827,28 @@ function appendMultiFileData(data) {
}
})
$("#is_installment_switch").change(function (){
var switch_status = ($(this).is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#no_of_installment").show();
$("#payment_date").hide();
$("#utr_no").hide();
$("#no_of_installment").closest('.form-group').show();
$("#payment_date").closest('.form-group').hide();
$("#utr_no").closest('.form-group').hide();
addInstallmentHTML()
}else{
$("#no_of_installment").hide();
$("#payment_date").show();
$("#utr_no").show();
$("#no_of_installment").closest('.form-group').hide();
$("#payment_date").closest('.form-group').show();
$("#utr_no").closest('.form-group').show();
$('#installment_form_row').empty();
}
})
$(document).on("input", "#cd_amount, #premium_amount", function() {
// alert("Function called");
@ -5928,6 +5888,193 @@ function appendMultiFileData(data) {
return emails.every(email => getDomain(email) === firstDomain);
}
function addInstallmentHTML() {
let html = `
<div class="form-row align-items-end">
<div class="form-group col-md-3">
<label for="installment_amount">Installment Amount</label>
<input type="text" class="form-control" name="installment_amount[]" placeholder="Enter Amount">
</div>
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control payment_date" name="payment_date[]" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No.">
</div>
<div class="form-group col-md-2">
<button type="button" class="btn btn-danger remove-installment">X</button>
</div>
</div>
`;
$('#installment_form_row').append(html);
$('.payment_date').flatpickr({
dateFormat: 'd/m/Y',
});
}
$(document).on('click', '.remove-installment', function () {
let $this = $(this); // Store reference to the clicked element
let row_count = $('#installment_form_row .form-row').length;
console.log("row_count", row_count);
let id = $this.closest('.form-row').find('input[name="installment_primary_key[]"]').val() ?? null;
console.log("id", id);
let ids = id ? [id] : [];
console.log("ids", ids);
if (id != null && row_count > 1) {
Swal.fire({
title: "Do you want to remove this?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Proceed!"
}).then((result) => {
if (result.isConfirmed) {
let url = '<?= base_url('util/removeInstallments') ?>';
let requestData = { id: ids };
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
$this.closest('.form-row').remove();
let updated_row_count = $('#installment_form_row .form-row').length;
$('#no_of_installment').val(updated_row_count);
console.log("after remove row_count", updated_row_count);
} else {
toastr.error(response.message, 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while removing the installment.', 'ERROR');
});
}
});
} else {
if (row_count > 1) {
$this.closest('.form-row').remove();
let updated_row_count = $('#installment_form_row .form-row').length;
$('#no_of_installment').val(updated_row_count);
console.log("after remove row_count", updated_row_count);
} else {
console.log("Only one row left. Not removing.");
}
}
});
$('#no_of_installment').on('change', function () {
let no_of_installments = parseInt($(this).val());
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
console.log("Form row count:", row_count);
if (row_count === 1) {
$installmentContainer.empty();
for (let index = 0; index < no_of_installments; index++) {
addInstallmentHTML();
}
} else if (no_of_installments === row_count) {
console.log('Same row count, no change needed.');
} else if (no_of_installments < row_count) {
// Remove extra rows from the end
let remove_count = row_count - no_of_installments;
let ids = $installmentContainer.find('.form-row')
.slice(-remove_count)
.find('input[name="installment_primary_key[]"]')
.map(function() {
return $(this).val();
}).get();
console.log('ids', ids);
if (ids != null) {
Swal.fire({
title: "Do you want to remove the last " + (remove_count ?? "") + " entries?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Proceed!"
}).then((result) => {
if (result.isConfirmed) {
let url = '<?= base_url('util/removeInstallments') ?>';
let requestData = { id: ids };
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
$installmentContainer.find('.form-row').slice(-remove_count).remove();
} else {
toastr.error(response.message, 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while removing the installment.', 'ERROR');
});
}else{
$('#no_of_installment').val(row_count);
}
});
} else {
$installmentContainer.find('.form-row').slice(-remove_count).remove();
}
} else if (no_of_installments > row_count) {
// Add extra rows from the end
let add_count = no_of_installments - row_count;
for (let index = 0; index < add_count; index++) {
addInstallmentHTML();
}
} else {
// Add missing rows
let add_count = no_of_installments - row_count;
for (let index = 0; index < add_count; index++) {
addInstallmentHTML();
}
}
});
$(document).ready(function(){
setTimeout(function(){
$('.payment_date').flatpickr({
dateFormat: 'd/m/Y',
});
}, 2000)
})
</script>

View File

@ -426,27 +426,27 @@
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No.">
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="placement_date">Placement Date</label>
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY">
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['placement_date']) ? date('d/m/Y', strtotime($lead_data['placement_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="premium_amount">Premium Amount</label>
<input type="text" class="form-control" id="premium_amount" name="premium_amount" placeholder="Enter Premium Amount">
<input type="text" class="form-control" id="premium_amount" name="premium_amount" placeholder="Enter Premium Amount" value="<?= isset($lead_data['premium_amount']) ? $lead_data['premium_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="total_amount">Total Amount</label>
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount">
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['total_amount']) ? $lead_data['total_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount">
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
</div>
@ -472,7 +472,7 @@
<select class="form-control" id="placement_cc" name="placement_cc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<option value="<?= $user['id']; ?>">
<option value="<?= $user['email']; ?>">
<?= $user['first_name'] . ' - ' . $user['email']; ?>
</option>
<?php } ?>
@ -516,10 +516,13 @@
</div><!-- /.modal -->
<script>
var isSaved = true;
// var randomColor = 'hsl(' + Math.random() * 360 + ', 100%, 93%)';
var rfq_data = <?= isset($rfq_data['json']) ? json_encode($rfq_data['json'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : '""' ?>;
rfq_data = rfq_data ? JSON.parse(rfq_data) : {}; // Convert to object if not already
var policySI = "";
var rfq_or_qcr = 1;
var proposalDataForDropDown = {};
var lead_type = "<?= $lead_data['lead_type'] ?>";
@ -536,7 +539,7 @@
// alert(rollover_or_renewal);
var policyConfig = {
1: ['Quote asked']
1: ['Sum Insured']
};
let myModal;
@ -547,6 +550,9 @@
'insurers': []
}
};
var tdChanged = false;
var changedNewSI = "";
var suggestions = {};
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 storedData = {};
@ -564,6 +570,7 @@
// // console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes")
$(document).ready(function() {
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
// monitorTableChanges();
});
var tableCount = 0;
const policies = <?= json_encode($policies) ?>;
@ -634,7 +641,7 @@
let proposalCount = 1;
// // console.log("Proposal count changed", proposalCount);
let quotesConfig = {
1: ['Quote asked']
1: ['Sum Insured']
}; // Stores quote columns for each proposal
@ -688,6 +695,7 @@
// Remove a proposal column
function removeProposal(proposalNumber) {
isSaved = false;
// alert(proposalNumber);
var rowIdCount = {};
@ -801,6 +809,7 @@
function addRow(event, element) {
// // console.log(' event ', element);
isSaved = false;
const button = event.target;
const row = button.closest('tr');
const table = row.closest('table');
@ -826,6 +835,7 @@
// Remove a row
function removeRow(event) {
isSaved = false;
const button = event.target;
const row = button.closest('tr');
const table = row.closest('table');
@ -1000,10 +1010,11 @@
document.getElementById('addProposal').addEventListener('click', () => {
// // console.log("proposal count before ", proposalCount);
proposalCount++;
isSaved = false;
// // console.log("proposal count after ", proposalCount);
quotesConfig[proposalCount] = ['Quote asked'];
policyConfig[proposalCount] = ['Quote asked'];
quotesConfig[proposalCount] = ['Sum Insured'];
policyConfig[proposalCount] = ['Sum Insured'];
const tables = document.querySelectorAll('table');
let increaseBy = 150;
increaseTableWidth(increaseBy);
@ -1037,7 +1048,13 @@
// Add new quote sub-header
const newQuoteHeader = document.createElement('th');
newQuoteHeader.textContent = 'Quote asked';
if (table.id != "public_liability_addOnCoverage"){
newQuoteHeader.textContent = 'Sum Insured';
}else{
newQuoteHeader.textContent = "Liability Limit";
}
newQuoteHeader.style.backgroundColor = randomColor;
headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child'));
@ -1586,19 +1603,26 @@
</th>
`).join('')}
<th>Action</th>`;
console.log("quotesConfig",quotesConfig);
const headerRow2 = document.createElement('tr');
headerRow2.innerHTML = `
<th>-</th>
<th>-</th>
${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
// codes.map(code => `
// <th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Sum Insured' && code !== "Liability Limit" ? 'insurer_proposal' : ''}">
// ${table.id == "public_liability_addOnCoverage" ? "Liability Limit" : code}
// <span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span>
// <div class="dropdown-content">
// <button onclick="removeQuote(event, ${proposal}, '${code}')">Remove Quote</button>
// </div>
// </th>
// `)
// ).join('')}
codes.map(code => `
<th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Quote asked' ? 'insurer_proposal' : ''}">
${code}
<span class="three-dot-menu" onclick="showDropdown(event)">&#8942;</span>
<div class="dropdown-content">
<button onclick="removeQuote(event, ${proposal}, '${code}')">Remove Quote</button>
</div>
<th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Sum Insured' && code !== "Liability Limit" ? 'insurer_proposal' : ''}">
${table.id == "public_liability_addOnCoverage" ? "Liability Limit" : code}
</th>
`)
).join('')}
@ -1723,8 +1747,8 @@
// }
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
// // console.log("Subheader th: below code",subHeaderText);
// Check if subheader is NOT "Quote asked"
let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ?
// Check if subheader is NOT "Sum Insured"
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
"insurer_proposal" : "";
// console.log("className", className);
// alert(subHeaderText);
@ -1776,6 +1800,17 @@
tableContainer.appendChild(collapsibleBar);
tableContainer.appendChild(tableContent);
container.appendChild(tableContainer);
monitorTableChanges();
if (changedNewSI != null && changedNewSI != ""){
console.log("Changed new SI",changedNewSI);
setTimeout(function() {
updateAddON(changedNewSI)
}, 500);
}
}
@ -1826,8 +1861,8 @@
let subHeaderTh = validSubHeaders.find(th => th.textContent.trim());
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
// Check if subheader is NOT "Quote asked"
let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ?
// Check if subheader is NOT "Sum Insured"
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
"insurer_proposal" : ""; // alert(subHeaderText);
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
@ -1863,10 +1898,12 @@
});
moveExcessTableLast();
styleTableColumns();
monitorTableChanges()
return false;
} else {
return true;
}
}
// Initialize the parent table
document.addEventListener('DOMContentLoaded', () => {
@ -1883,6 +1920,7 @@
localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data));
jsonToTables();
styleTableColumns();
monitorTableChanges();
proposalDataForDropDown = rfq_data[rfq_data.length - 1].proposal_data;
// // console.log("proposalDataForDropDown", proposalDataForDropDown);
if (!$.isEmptyObject(storedData)) {
@ -2190,6 +2228,7 @@
}
function addOrRemoveIcon(element, event) {
isSaved = false;
event.stopPropagation();
// Get the parent dropdown to access both buttons reliably
@ -2257,16 +2296,20 @@
// // console.log("anchor link clicked ", policyName);
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'),{
backdrop: 'static',
keyboard: false
});
// // console.log("inside if condition");
var leadID = $("#lead_id").val();
let policy = policies.find(p => p.name === policyName);
// alert(policy.quote_asked[0]);
// var policySI = policies[]
policySI = rfq_count == 0 && !tdChanged ? policy.quote_asked[0] : (changedNewSI) != "" && changedNewSI != 0? changedNewSI : policy.quote_asked[0];
console.log("policy si",policySI,"rfq ount ",rfq_count,"tdchanged ",tdChanged,"changedNewSI",changedNewSI);
$("#policyName").val(policyName);
$("#policySI").val(policy.quote_asked[0]);
$("#policySI").val(policySI);
$("#leadID").val(leadID);
$("#multilocation_type_div").hide();
$('.loader').fadeIn();
@ -2296,7 +2339,68 @@
// Loop through each location and generate the summary rows dynamically
for (let i = 0; i < locationCount; i++) {
let locationIndex = i + 1; // To make it 1-based instead of 0-based
let locationIndex = i + 1;
let rowContents = [
{
[`fire_plantMachineries_${locationIndex}`]: {
"display_value": "Plant & Machineries and Accessories",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.plant_and_machinery || ""
}
},
{
[`fire_electricalFittings_${locationIndex}`]: {
"display_value": "Electronic Equipments and Accessories",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.electrical_fittings || ""
}
},
{
[`fire_furnitureFittings_${locationIndex}`]: {
"display_value": "FFF (Furniture, Fixtures & Fittings)",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.furniture || ""
}
},
{
[`fire_content_${locationIndex}`]: {
"display_value": "Other Contents Related to Insured",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.content || ""
}
},
{
[`fire_content_${locationIndex}`]: {
"display_value": "Stock",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.finished_stock || ""
}
}
];
// ✅ Keep the structure, add extra only if value is present
const riskSplit = storedData.locations[i].policyRiskSplitUp || {};
if (riskSplit.stock_in_process) {
rowContents.push({
[`fire_content_${locationIndex}`]: {
"display_value": "Stock In Process",
"answer_type": "free-text",
"default_answer": riskSplit.stock_in_process
}
});
}
if (riskSplit.raw_material) {
rowContents.push({
[`fire_content_${locationIndex}`]: {
"display_value": "Raw Materials",
"answer_type": "free-text",
"default_answer": riskSplit.raw_material
}
});
}
tableRowContent.push({
table_type: "new",
@ -2306,40 +2410,12 @@
storedData.locations[i].policyRisk['occupancy'] + "- " +
storedData.locations[i].policyRisk['address1'] + " " +
storedData.locations[i].policyRisk['address2'],
table_row_contents: [{
[`fire_plantMachineries_${locationIndex}`]: {
"display_value": "Plant & Machineries and Accessories",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.plantAndMachinery || ""
}
},
{
[`fire_electricalFittings_${locationIndex}`]: {
"display_value": "Electronic Equipments and Accessories",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.electricalFittings || ""
}
},
{
[`fire_furnitureFittings_${locationIndex}`]: {
"display_value": "FFF (Furniture, Fixtures & Fittings)",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.furniture || ""
}
},
{
[`fire_content_${locationIndex}`]: {
"display_value": "Other Contents Related to Insured",
"answer_type": "free-text",
"default_answer": storedData.locations[i].policyRiskSplitUp?.content || ""
}
}
]
table_row_contents: rowContents
});
}
var policySummary = tableRowContent;
// // console.log("policy summary ", policySummary);
console.log("policy summary ", policySummary);
return policySummary;
}
@ -2406,6 +2482,8 @@
}
function saveRFQ() {
// alert("Function Called");
isSaved = true;
// // console.log("save button clicked");
leadJson = tablesToJson();
// // console.log("json from function ", leadJson);
@ -2434,6 +2512,9 @@
data: formData,
method: "POST",
success: function(response) {
console.log('RFQ NON EB FORM SUBMIT RESPONSE : ', response);
if (response.status == true) {
localStorage.removeItem('policyData');
@ -2775,8 +2856,13 @@
return allTablesData;
}
function openQCR() {
async function openQCR() {
if (!isSaved){
const proceed = await confirmUnsavedChanges();
// if (!proceed) {}
// return;
}
const url = window.location.pathname; // Get the path (e.g., "/nhance/rfq/list/75/1")
const segments = url.split("/"); // Split by "/"
segments[segments.length - 1] = "2"; // Change the last segment
@ -2820,8 +2906,8 @@
// if (!proposalNumber) return; // Skip if extraction fails
// Initialize with "Quote asked"
result[proposalNumber] = ["Quote asked"];
// Initialize with "Sum Insured"
result[proposalNumber] = ["Sum Insured"];
// Check if insurers exist and filter those with qcr = 1
if (Array.isArray(proposalData.insurers)) {
@ -2862,8 +2948,8 @@
let proposal = overallColumnData[proposalKey];
let insurersList = proposal.insurers.map(ins => ins.ins_name); // Extract insurer names
// Create output format: index { "Quote asked", ...insurers }
quotesConfiguration[index] = ["Quote asked", ...insurersList];
// Create output format: index { "Sum Insured", ...insurers }
quotesConfiguration[index] = ["Sum Insured", ...insurersList];
});
@ -2987,13 +3073,14 @@
// Create body
const tbody = document.createElement('tbody');
var cellCount = 0;
tableEntry.table_data.data.forEach((rowData, rowDataIndex) => {
const tr = document.createElement('tr');
tr.id = rowData.row_id;
if (tableEntry.tableId === "excess" && rowData.parentPolicy) {
tr.setAttribute('data-excess-row-parent', rowData.parentPolicy);
}
// Process each cell
rowData.data.forEach((cellData, cellIndex) => {
const td = document.createElement(cellIndex === 0 ? 'td' : 'td');
@ -3032,19 +3119,28 @@
if (lead_type == 1){
td.onclick = () => getAnswer(table.id, tr.id);
if (cellData.subth != "Quote asked") {
if (cellData.subth != "Sum Insured" && cellData.subth != "Liability Limit") {
td.onclick = () => getAnswer(table.id, tr.id);
td.classList.add("insurer_proposal");
}
}else{
td.onclick = () => getAnswer(table.id, tr.id);
if (cellData.subth != "Quote asked") {
if (cellData.subth != "Sum Insured" && cellData.subth != "Liability Limit") {
td.onclick = () => getAnswer(table.id, tr.id);
td.classList.add("insurer_proposal");
}
}
if (cellData.subth == "Sum Insured" && cellData.parentth == "Proposal 1" && table.id == "" && cellCount === 0){
console.log("cell count : ",cellCount)
changedNewSI = cellData.input_value;
console.log("changed new si from jsontotables",changedNewSI);
$("#policySI").val(changedNewSI);
cellCount = cellCount + 1;
}
}
td.contentEditable = true;
@ -3246,8 +3342,8 @@
const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader);
if (subHeader != "Quote asked") {
// // console.log("trying to find something : matchedInsurer", matchedInsurer);
if (subHeader != "Sum Insured" && subHeader != "Liability Limit") {
console.log("trying to find something : matchedInsurer", subHeader);
// // console.log("trying to find something :matchedInsurer stc ", matchedInsurer.stc);
// // console.log("trying to find something : ", matchedInsurer.stc);
@ -3642,7 +3738,7 @@
}
function makeQuoteAskedColumnNonEditableorEditable() {
// alert("Quote asked");
// alert("Sum Insured");
$("table").each(function() {
var table = $(this);
var subHeaderRow = table.find("tr:nth-child(2)"); // Assuming second row is the sub-header
@ -3652,18 +3748,18 @@
var colIndexTracker = []; // Maps visual column index to actual index
var visualIndex = 0; // Tracks the visual column position considering rowspan/colspan
// Step 1: Find the "Quote asked" column index
// Step 1: Find the "Sum Insured" column index
subHeaderRow.children("th, td").each(function(actualIndex) {
colIndexTracker[visualIndex] = actualIndex;
if ($(this).text().trim() === "Quote asked") {
if ($(this).text().trim() === "Sum Insured" || $(this).text().trim() === "Liability Limit") {
targetColumnIndexes.push(visualIndex);
}
visualIndex += parseInt($(this).attr("colspan") || 1, 10);
});
if (targetColumnIndexes === 0) return; // If "Quote asked" column is not found, exit
if (targetColumnIndexes === 0) return; // If "Sum Insured" column is not found, exit
// Step 2: Make all cells in the found column non-editable, considering rowspan
var rowSpans = {}; // Keeps track of rowspans per column
@ -4238,8 +4334,13 @@
})
function checkTheTableDataChanged(redirect_type) {
async function checkTheTableDataChanged(redirect_type) {
if (!isSaved){
const proceed = await confirmUnsavedChanges();
// if (!proceed) {}
// return;
}
if (redirect_type == 1) {
//BACK BUTTON
@ -4675,7 +4776,7 @@
// Process `to` field
to = to.split(',').map(email => email.trim());
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
// cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
var selectedFiles = [];
@ -4725,6 +4826,8 @@
dataType: 'json',
success: function(res) {
console.log('MAIL SEND API RESPONSE : ', res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -4745,9 +4848,8 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
// console.error(xhr.responseText);
// console.error(status, error);
console.error(xhr.responseText);
console.error(status, error);
}
});
@ -4868,4 +4970,229 @@
createIcon(stcButton);
}
}
function monitorTableChanges() {
console.log("monitoring table changes");
var proposalValue = "";
// Get the first table
const table = document.querySelector("table");
if (!table) return;
// Get the first row in the tbody
const firstRow = table.querySelector("tbody tr");
if (!firstRow) return;
// console.log("firstRow : ",firstRow);
// Get all cells in the first row
const cells = firstRow.querySelectorAll("td");
// Get header rows to identify which columns are "Sum Insured"
const headerRow1 = table.querySelector("thead tr:nth-child(1)");
const headerRow2 = table.querySelector("thead tr:nth-child(2)");
if (!headerRow1 || !headerRow2) return;
// console.log("headerRow1 : ",headerRow1);
// console.log("headerRow2 : ",headerRow2);
// Find which column is the "Sum Insured" column
let sumInsuredColumnIndex = -1;
const subHeaders = headerRow2.querySelectorAll("th");
subHeaders.forEach((th, index) => {
if (th.textContent.trim() === "Sum Insured") {
proposalValue = th.getAttribute("data-proposal");
sumInsuredColumnIndex = index;
}
});
// console.log("sumInsuredColumnIndex : ",sumInsuredColumnIndex);
if (sumInsuredColumnIndex === -1) return;
// Check if we have a cell at that index
if (cells.length > sumInsuredColumnIndex) {
console.log("It is there");
const sumInsuredCell = cells[sumInsuredColumnIndex];
let previousValue = "";
// Add event listener for changes
sumInsuredCell.addEventListener("focus", function () {
previousValue = this.textContent.trim();
});
sumInsuredCell.addEventListener("blur", function () {
const newValue = this.textContent.trim();
if (newValue !== previousValue) {
tdChanged = true;
changedNewSI = newValue;
$("#policySI").val(newValue);
console.log("new Value",changedNewSI);
// alert(newValue);
updateAddON(newValue,proposalValue);
console.log("Sum Insured value changed to:", newValue);
}
});
}else{
console.log("Sum Insured column not found");
}
}
function updateAddON(newValue,proposalValue = null) {
console.log("Function called");
var table = document.getElementById("fire_addOnCoverage");
console.log("table : ",table);
if (!table) return;
const thead = table.querySelector("thead");
const tbody = table.querySelector("tbody");
if (!thead || !tbody) return;
const topHeaderCells = thead.rows[0].cells;
const subHeaderCells = thead.rows[1].cells;
let targetIndexes = [];
// Find indexes of columns with the required headers
for (let i = 0; i < topHeaderCells.length; i++) {
const topHeaderText = topHeaderCells[i].textContent.trim();
const subHeaderText = subHeaderCells[i] ? subHeaderCells[i].textContent.trim() : "";
const subheaderProposalValue = subHeaderCells[i]?.getAttribute("data-proposal");
console.log("subheaderProposalValue : ",subheaderProposalValue);
console.log("proposalValue : ",proposalValue);
if (proposalValue != "" && proposalValue != null){
if (subheaderProposalValue !== proposalValue) {
continue;
}
}
if ((topHeaderText.startsWith("Pro") || topHeaderText.startsWith("Exis")) && subHeaderText === "Sum Insured") {
targetIndexes.push(i);
}
}
// Loop through the first 3 rows of tbody and update the matching cells
for (let rowIndex = 0; rowIndex < Math.min(3, tbody.rows.length); rowIndex++) {
const row = tbody.rows[rowIndex];
targetIndexes.forEach(colIndex => {
if (row.cells[colIndex]) {
console.log("Found row to update")
if (['fire_stfi', 'fire_eq'].includes(row.id)) {
row.cells[colIndex].textContent = newValue;
}
if (row.id == "fire_terrorism"){
if (storedPolicyData){
console.log("storedPolicyData : ",storedPolicyData);
var is_terrorism = storedPolicyData.fire.policyDetails.terrorism;
console.log("is terrorism",is_terrorism);
if (is_terrorism == "yes"){
row.cells[colIndex].textContent = `Yes, ${newValue}`;
}else{
row.cells[colIndex].textContent = "No"
}
}else{
row.cells[colIndex].textContent = "No"
}
}
}
});
}
}
function changeTerrorism(newValue){
storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
console.log("Stroredpolicy data : ",storedPolicyData);
console.log("Change terrorism Function Called");
var table = document.getElementById("fire_addOnCoverage");
if (!table) return;
const thead = table.querySelector("thead");
const tbody = table.querySelector("tbody");
if (!thead || !tbody) return;
const topHeaderCells = thead.rows[0].cells;
const subHeaderCells = thead.rows[1].cells;
let targetIndexes = [];
// Find indexes of columns with the required headers
for (let i = 0; i < topHeaderCells.length; i++) {
const topHeaderText = topHeaderCells[i].textContent.trim();
const subHeaderText = subHeaderCells[i] ? subHeaderCells[i].textContent.trim() : "";
if ((topHeaderText.startsWith("Pro") || topHeaderText.startsWith("Exis")) && subHeaderText === "Sum Insured") {
targetIndexes.push(i);
}
}
// Loop through the first 3 rows of tbody and update the matching cells
for (let rowIndex = 0; rowIndex < Math.min(3, tbody.rows.length); rowIndex++) {
const row = tbody.rows[rowIndex];
targetIndexes.forEach(colIndex => {
if (row.cells[colIndex]) {
if (row.id == "fire_terrorism"){
console.log("Found the row");
if (storedPolicyData){
console.log("storedPolicyData : ",storedPolicyData);
var is_terrorism = storedPolicyData.fire.policyDetails.terrorism;
updateAddON(newValue);
if (is_terrorism == "yes"){
row.cells[colIndex].textContent = `Yes, ${newValue}`;
}else{
row.cells[colIndex].textContent = "No"
}
}else{
row.cells[colIndex].textContent = "No"
}
}
}
});
}
}
document.addEventListener('input', function (e) {
if (e.target.matches('td[contenteditable]')) {
isSaved = false;
// alert("status changed");
}
});
async function confirmUnsavedChanges() {
const result = await Swal.fire({
title: 'Unsaved changes',
text: 'Please save your changes before continuing.',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Save Now',
cancelButtonText: 'Cancel'
});
if (result.isConfirmed) {
saveRFQ();
return true;
}
return false;
}
</script>