MERGE_TEST_LIVE_ISSUES&RFQ_REQMENTS

This commit is contained in:
Ubuntu 2025-05-14 18:02:23 +05:30
commit 69ff7bc194
27 changed files with 1966 additions and 733 deletions

View File

@ -360,6 +360,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->cli("cli/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->group("inception", ["filter" => "authMVC"], function ($routes) {
@ -545,6 +548,7 @@ $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) {
$routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->match( ['get', 'post'], 'list','TicketController::ticketList');
$routes->get('feedback-list','TicketController::feedbackList');
$routes->get('remove','TicketController::removeTicket');
$routes->get('new/(:any)','TicketController::ticket_form/$1');
$routes->post('create','TicketController::createTicket');
$routes->post('update','TicketController::updateTicket');

View File

@ -44,6 +44,7 @@ use App\Models\ClientApiModel;
use App\Controllers\EmpDataServiceController;
use App\Controllers\GoogleDriveController;
use App\Controllers\PolicyTransactionController;
use App\Helpers\sendMailNotification;
use App\Models\PTCOShareDetailsModel;
@ -4608,6 +4609,10 @@ class ClientController extends AdminController
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '829']);
// $res = $empServiceController->employeeDisembark(['file_id' => '858']);
$policyTransactionController = new PolicyTransactionController();
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']);
// $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']);
// dd('-----', $res);
@ -4680,7 +4685,7 @@ class ClientController extends AdminController
// ------------- LEADS CONTROLLER ----------------------------------------------------------
// $LeadsController = new LeadsController();
$LeadsController = new LeadsController();
// $RFQModel = new RFQModel();
// $data = $RFQModel->where('is_active', 1)->where('lead_id', 40)->first();
@ -4694,6 +4699,8 @@ class ClientController extends AdminController
// $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name);
// dd($returndata);
$LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]);
// -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------
// $BDSReportController = new BDSReportController();

View File

@ -444,6 +444,8 @@ class EmployeeController extends AdminController
$filePath = ROOTPATH . 'public/sample_excel/enrollment.xlsx';
}else if ($actionType == 'missed_inception') {
$filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls';
}else if ($actionType == 'member_data') {
$filePath = ROOTPATH . 'public/sample_excel/Sample_Member_Data.xlsx';
}
// Check if the file exists

View File

@ -1383,11 +1383,11 @@ class EmployeeServiceController extends AdminController
{
// dd($employee);
$existing_endorsements = $this->empEndorsementModel->where('actions','d')
->where('table_name','employees')
->where('table_name','employee_polices')
->where('endorsement_id is null')
->where('emp_code',$employee['emp_code'])
->where('name',$employee['name'])
->where('field_name','emp_status')
->where('field_name','status')
->where('status !=','truncated')
->where('is_active', 1)
->findAll();
@ -2087,12 +2087,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$relation = 'parent';
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$relation = 'child';
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
}else if((strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') || (strtolower(trim($value['relationship'])) === 'father-in-law' || strtolower(trim($value['relationship'])) === 'mother-in-law')){
$relation = 'parent_in_law';
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
$relation = 'spouse';
}else{
}else if(strtolower(trim($value['relationship'])) === 'self'){
$relation = 'self';
}else {
$relation = '';
}
$value['family_floater_key'] = $relation;

View File

@ -712,6 +712,12 @@ class LeadsController extends BaseController
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
}
if($lead_data['policy_type_id'] == 1){
$data['totalSumAssured'] = $this->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => $id]);
}else{
$data['totalSumAssured'] = [];
}
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
@ -1762,7 +1768,7 @@ class LeadsController extends BaseController
['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]],
['file_path' => WRITEPATH . '/uploads/lead_files/' . $result['filename'], 'sheets' => []],
];
$outputPath = WRITEPATH . 'uploads/lead_files/Member_Data.xlsx';
$outputPath = WRITEPATH . 'uploads/lead_files/' .$lead_data['file_name'];
$result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
if ($result_merge) {
// Call the delete function after the file is successfully created
@ -2372,7 +2378,9 @@ class LeadsController extends BaseController
$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;
$value['payment_date'] = !empty($value['payment_date']) && strtotime($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{
@ -4077,4 +4085,71 @@ class LeadsController extends BaseController
return $attachments;
}
public function handleMemberDataGPATotalSumInsurerFromExcel($params)
{
$lead_id = $params['lead_id'];
$lead_data = $this->leadsModel->find($lead_id);
// dd($lead_data);
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
// dd($file_name_with_path);
if (!$lead_data) {
return ['status' => 'failed', 'message' => 'Lead data not found'];
}
if ($lead_data['file_name']) {
//check physical file
if (!file_exists($file_name_with_path)) {
$message = "Lead Physcial file not found";
$this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path));
return ['status' => 'failed', 'message' => 'no physical file'];
}
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
//get members data
$members_sheet = $spreadsheet->getSheet(0);
$highestRowAndColumn = $members_sheet->getHighestRowAndColumn();
// dd($highestRowAndColumn);
$uncleaned_members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
// dd($uncleaned_members);
$members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members);
// dd($members);
// Check column headings
$members_heading = $members[0];
$available_col = [];
$lower_headers = array_map('strtolower', $members_heading);
foreach ($lower_headers as $index => $header) {
if (preg_match('/^sa\s*-\s*option\s*\d*$/i', $header)) {
$column_name = $members_heading[$index];
$sum = 0;
for ($i = 1; $i < count($members); $i++) {
$cell_raw = $members[$i][$index] ?? '';
$cell_clean = preg_replace('/[^0-9.\-]/', '', $cell_raw); // remove non-numeric chars
if ($cell_clean !== '' && is_numeric($cell_clean)) {
$sum += (float) $cell_clean;
}
}
$available_col[] = $sum;
}
}
// dd($available_col);
return $available_col;
}
return [];
}
}

View File

@ -1680,7 +1680,7 @@ class MasterController extends AdminController
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
];
$email_id = 'srinivas.saravanan@venbainfotech.com';
$email_id = ['srinivas.saravanan@venbainfotech.com','srinivassaravanan2002@gmail.com'];
$params = ['mail'=>$email_id];
$common = ['mail_type'=>'test_mail_cli'];
// $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com";

View File

@ -32,10 +32,13 @@ use App\Models\InvPaymentDetailsModel;
use App\Models\BatchFileModel;
use App\Models\FileModel;
use App\Models\COShareStmtDetailsModel;
use Kint;
use App\Models\BdsPlacementModel;
use Kint\Kint;
use App\Helpers\MailHelper;
use Exception;
class PolicyTransactionController extends BaseController
{
{
use ResponseTrait;
protected $myLogger;
@ -64,6 +67,7 @@ class PolicyTransactionController extends BaseController
protected $batchFileModel;
protected $filesModel;
protected $coShareStmtDetailsModel;
protected $BdsPlacementModel;
public function __construct()
{
@ -94,6 +98,7 @@ class PolicyTransactionController extends BaseController
$this->batchFileModel = new BatchFileModel();
$this->filesModel = new FileModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->BdsPlacementModel = new BdsPlacementModel();
$this->invoiceStatus = [
'pending' => 'Pending',
'generated' => 'Generated',
@ -182,8 +187,7 @@ class PolicyTransactionController extends BaseController
$issuer,
$status
);
}else{
} else {
$ids = $this->request->getPost('ids');
$ids = array_filter(explode(',', $ids));
@ -1831,7 +1835,7 @@ class PolicyTransactionController extends BaseController
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = $this->request->getPost('ids');
$ids = array_filter(explode(',', $ids));
if (!empty($ids)) {
@ -2380,7 +2384,7 @@ class PolicyTransactionController extends BaseController
if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
$total_amt += $actual_bp_brokerage;
//percentage reverse calculation
if ($actual_bp_per == 0 || $actual_bp_per == "") {
if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) {
$actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2);
}
} else {
@ -2395,7 +2399,7 @@ class PolicyTransactionController extends BaseController
if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
$total_amt += $actual_tp_brokerage;
//percentage reverse calculation
if ($actual_tp_per == 0 || $actual_tp_per == "") {
if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) {
$actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
}
} else {
@ -2410,7 +2414,7 @@ class PolicyTransactionController extends BaseController
if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
$total_amt += $actual_tep_brokerage;
//percentage reverse calculation
if ($actual_tep_per == 0 || $actual_tep_per == "") {
if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) {
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
}
} else {
@ -2801,4 +2805,105 @@ class PolicyTransactionController extends BaseController
->update();
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
}
public function sendInstallmentRemainderMail()
{
$this->myLogger->logme("error", "Cron Job For Send Installment Remainder Mail Started");
try {
try {
$bdsInstallmentData = $this->BdsPlacementModel->getClientInstallmentDetails();
}catch (Exception $e) {
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
}
$this->myLogger->logme("error", "Data for BDS Installment " . json_encode($bdsInstallmentData));
// dd($bdsInstallmentData);
if (empty($bdsInstallmentData)) {
$this->myLogger->logme("error", "No Client Installment is Due in the 15th Day");
return false;
}
foreach ($bdsInstallmentData as $installmentData) {
$mailData = $this->PrepareBDSMailData($installmentData);
$to_mail = $mailData['to_mail'];
$message = $mailData['message'];
$subject = $mailData['subject'];
$this->myLogger->logme("error", "Installment Pending for" . $subject);
$common = ['mail_type' => 'installment_amount_due_remainder_mail'];
$res = MailHelper::send_email(['mail' => $to_mail, 'subject' => $subject, 'message' => $message, 'common' => $common]);
$res = json_decode($res);
$this->myLogger->logme('error', 'res: ' . json_encode($res));
if ($res->status == 'success') {
return true;
} else {
return false;
}
}
} catch (Exception $e) {
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
}
}
protected function PrepareBDSMailData($data)
{
try {
$installment_amount = $data['installment_amount'];
$payment_date = date('d-m-Y', strtotime($data['payment_date']));
$client = $data['client_name'];
$branch = $data['branch_name'];
$sales_person_mail = $data['sales_person'];
$heads = $data['heads'];
$admins = $data['admins'];
$buisness_team = $data['buisness_team'];
$policy_no = $data['policy_no'];
$client_short_name = isset($data['short_name']) && $data['short_name'] != null ? $data['short_name'] : $data['client_name'];
$subject = "Installment Amount Due For Client - {$client_short_name} - Policy NO({$policy_no}) is Due On - {$payment_date}";
$message = "Policy Installment for Client - {$client}, Branch - {$branch} is Due on {$payment_date}
with amount of {$installment_amount}.<br>
Policy No : {$policy_no}";
$to_mail = array_merge(
array_column($heads, 'email'),
array_column($admins, 'email'),
array_column($buisness_team, 'email'),
[$sales_person_mail]
);
$to_mail = array_unique($to_mail);
$this->myLogger->logme("error", "Selected To Address : " . json_encode($to_mail));
// dd($to_mail);
return [
'to_mail' => $to_mail,
'message' => $message,
'subject' => $subject
];
} catch (Exception $e) {
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
}
}
}

View File

@ -198,6 +198,12 @@ class TicketController extends BaseController
}else if ($isFromDashboard == 2){
$data['ticket_data'] = $this->ticketSearch(4);
}else if ($isFromDashboard == 3){
$data['ticket_data'] = $this->ticketSearch(2);
}else if ($isFromDashboard == 4){
$data['ticket_data'] = $this->ticketSearch(5);
}
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
$data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll();
@ -249,7 +255,7 @@ class TicketController extends BaseController
->groupBy('tm.id, tm.created_at, latest_history.created_at');
//action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM
//action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM, action 5 tat
if ($action == 1) {
$query = $db->table('ticket_master tm')
@ -356,6 +362,10 @@ class TicketController extends BaseController
$where = '1 = 0'; // No valid IDs, return empty result
}
}else if ($action == 5) {
$search_data = $this->request->getPost();
$where = "tm.created_at >= '" . $search_data['from_date'] . "' AND tm.created_at <= '" . $search_data['to_date'] . "'" ."and ticket_type_id = ".$search_data['ticket_type_id'];
} else {
$search_data = $this->request->getPost();
// print_r($search_data); die()
@ -445,6 +455,17 @@ class TicketController extends BaseController
->orderBy('tm.id', 'DESC');
$data = $query->get()->getResultArray();
// dd($db->getLastQuery()->getQuery());
// dd($data);
if ($action == 5){
$tat = $this->request->getPost("tat_category");
$data = array_values(array_filter($data, function($dat) use ($tat) {
return $dat['tat'] == $tat;
}));
}
// print_rr($data);
// log_message('error',' Claims Master Data '.json_encode($data));die();
// print_rr($data);die();
@ -954,10 +975,27 @@ class TicketController extends BaseController
}
public function convertHtmlToText($html)
{
if(!empty($html)){
$dom = new DOMDocument();
@$dom->loadHTML($html);
return strip_tags($dom->saveHTML());
}else{
return '';
}
}
public function removeTicket()
{
$dom = new DOMDocument();
@$dom->loadHTML($html);
return strip_tags($dom->saveHTML());
$ticket_id = $this->request->getGet('ticket_id');
if(!empty($ticket_id)){
$data['is_active'] = 0;
$this->ticketMasterModel->where('id', $ticket_id)->set($data)->update();
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Claim removed successfully'], 200);
}else{
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove Claim'], 200);
}
}
//---- Email Trigger Part----------------------------------------------------------------------------------------------
@ -1051,6 +1089,10 @@ class TicketController extends BaseController
$this->myLogger->logme('error', "Replacing placeholders in content");
if (!empty($ticket_data) && !empty($content)) {
// print_rr($ticket_data);die();
if (!isset($ticket_data['id'])) { $ticket_data['id'] = $ticket_data['ticket_master_id'];}
if (!isset($ticket_data['ticket_master_id'])) {$ticket_data['ticket_master_id'] = $ticket_data['id'];}
foreach ($this->placeHolders as $key => $value) {
if ($value == "emp_code") {
@ -1434,7 +1476,7 @@ class TicketController extends BaseController
'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED',
'UNDER PROCESS - CLAIM NO. UPDATION',
'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED',
'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL'
'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL','TPA_ID'
];
// Reorder data based on column order
@ -1448,6 +1490,7 @@ class TicketController extends BaseController
$ordered_data[] = $temp;
}
$viewData['tpa_wise_data'] = $ordered_data;
// print_r($ordered_data);die();
// $html = view('claims_report_tpa_wise', $viewData);
$html = view('claims_report_tpa_wise',$viewData);
@ -1455,6 +1498,9 @@ class TicketController extends BaseController
} else if ($received_data['report_type'] == 'tat_band_wise') {
$viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate);
$viewData['policyType'] = $policy_type;
$viewData['fromDate'] = $fromDate;
$viewData['toDate'] = $toDate;
$html = view('tat_report_band_wise_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200);
}
@ -1859,9 +1905,10 @@ class TicketController extends BaseController
}
}
private function isDate($value) {
private function isDate($value, $format = 'Y-m-d') {
// Check if the value is a valid date string (basic validation)
return strtotime($value) !== false;
$date = \DateTime::createFromFormat($format, $value);
return $date && $date->format($format) === $value;
}

View File

@ -2210,12 +2210,14 @@ if (!function_exists('generate_family_floater_key')) {
$relation = 'parent';
} else if (strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter') {
$relation = 'child';
} else if (strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') {
}else if((strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') || (strtolower(trim($relationship)) === 'father-in-Law' || strtolower(trim($relationship)) === 'mother-in-Law')){
$relation = 'parent_in_law';
} else if (strtolower(trim($relationship)) === 'spouse') {
$relation = 'spouse';
} else {
} else if(strtolower(trim($relationship)) === 'self'){
$relation = 'self';
}else{
$relation = '';
}
return $relation;

View File

@ -55,8 +55,8 @@ if (!function_exists('file_Upload')) {
function file_Upload($fileToUpload, $filepath)
{
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
$fileToUpload->move($filepath);
$fileName = $fileToUpload->getName();
$fileToUpload->move($filepath, $fileName);
return $fileName;
} else {
return "";

View File

@ -0,0 +1,93 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BdsPlacementModel extends Model
{
protected $table = 'bds_installment_payment_details';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'pt_id',
'lead_id',
'installment_amount',
'payment_date',
'utr_no',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active'
];
public function getClientInstallmentDetails()
{
$builder = $this->db->table("bds_installment_payment_details bipd")
->select("bipd.*, ct.client_name,ct.short_name, cb.branch_name, leads.salse_person_id,cp.policy_no")
->join("policy_transaction pt", "pt.id = bipd.pt_id")
->join("clients ct", "ct.id = pt.client_id")
->join("client_branch cb", "cb.id = pt.client_branch_id")
->join("leads", "leads.id = bipd.lead_id")
->join("client_policy cp","cp.id = pt.client_policy_id")
->where("bipd.is_active", 1)
->where("bipd.payment_date", date('Y-m-d', strtotime('+15 days')));
$data = $builder->get()->getResultArray();
// Loop through to extract sales person details
foreach ($data as &$row) {
$sales_person_ids = json_decode($row['salse_person_id'], true);
$sales_person_id = $sales_person_ids[0] ?? null;
if ($sales_person_id) {
$user = $this->db->table('user_profiles')
->select('email') // or whatever field
->where('id', $sales_person_id)
->get()
->getRowArray();
$row['sales_person'] = $user['email'] ?? 'N/A';
} else {
$row['sales_person'] = 'Not Assigned';
}
$head = $this->db->table('user_profiles')
->select('email') // or whatever field
->where('role', 5)
->where('is_active',1)
->get()
->getResultArray();
$row['heads'] = $head;
$admin = $this->db->table('user_profiles')
->select('email')
->where("is_active",1)
->where("role",1)
->get()
->getResultArray();
$row['admins'] = $admin;
$buisenessTeam = $this->db->table("user_teams ut")
->select("up.email")
->join('user_profiles up','up.id = ut.user_id and up.is_active = 1')
->where("ut.team_id",7)
->where("ut.is_active",1)
->get()
->getResultArray();
$row['buisness_team'] = $buisenessTeam;
}
return $data;
}
}

View File

@ -335,159 +335,240 @@ class TicketMasterModel extends Model
// return $data;
// }
// public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
// {
// //set default last 3 months data date
// $fromDate = date('Y-m-d', strtotime('-90 days'));
// $toDate = date('Y-m-d 23:59:59');
// if (!empty($start_date) && !empty($end_date)) {
// $fromDate = change_date_format($start_date);
// $toDate = change_date_format($end_date);
// }
// $ticket_type_data_1 = "";
// $ticket_type_data_2 = "";
// if (!empty($ticket_type)) {
// $ticket_type_data_1 = "AND ticket_type = $ticket_type";
// $ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type";
// }
// // Fetch claim statuses from the `ticket_claim_status` table
// $statusQuery = " SELECT
// id, claim_status, ticket_type
// FROM ticket_claim_status
// Where is_active = 1
// $ticket_type_data_1
// ";
// $statusResult = $this->db->query($statusQuery)->getResultArray();
// // dd($statusResult);
// // Initialize dynamic query parts
// $dynamicSelect = '';
// // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
// foreach ($statusResult as $status) {
// $columnName = $status['claim_status']; // Default column name
// if (empty($ticket_type)) {
// // Append the insurance type prefix based on `ticket_type`
// switch ($status['ticket_type']) {
// case 1:
// $columnName = "GMC - {$status['claim_status']}";
// break;
// case 2:
// $columnName = "GPA - {$status['claim_status']}";
// break;
// case 3:
// $columnName = "EDLI - {$status['claim_status']}";
// break;
// case 4:
// $columnName = "GTLI - {$status['claim_status']}";
// break;
// }
// }
// $dynamicSelect .= "
// COALESCE(
// SUM(
// CASE
// WHEN subquery.status_id = {$status['id']} THEN 1
// ELSE 0
// END
// ),
// 0
// ) AS `$columnName`, ";
// }
// // Remove the trailing comma from the SELECT part
// $dynamicSelect = rtrim($dynamicSelect, ', ');
// // dd($dynamicSelect);
// // Construct the full SQL query
// $sql = "
// SELECT
// tc.TAT_Category,
// $dynamicSelect
// FROM
// (
// SELECT 'Above 20 Days' AS TAT_Category
// UNION ALL
// SELECT '13-20 Days'
// UNION ALL
// SELECT '7-12 Days'
// UNION ALL
// SELECT '0-6 Days'
// ) AS tc
// LEFT JOIN (
// SELECT
// tm.id AS ticket_id,
// latest_status.claim_status_id AS status_id,
// CASE
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 0 AND 6 THEN '0-6 Days'
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 7 AND 12 THEN '7-12 Days'
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 13 AND 20 THEN '13-20 Days'
// ELSE 'Above 20 Days'
// END AS TAT_Category
// FROM
// ticket_master tm
// LEFT JOIN (
// SELECT
// th.ticket_id,
// th.new_value AS claim_status_id,
// MAX(th.created_at) AS change_date
// FROM
// ticket_history th
// WHERE
// th.field_name = 'claim_status_id'
// AND th.is_active = 1
// GROUP BY
// th.ticket_id, th.new_value
// ) AS latest_status ON latest_status.ticket_id = tm.id
// WHERE tm.is_active = 1
// AND tm.created_at >= '$fromDate'
// AND tm.created_at <= '$toDate'
// " . (!empty($ticket_type) ? " AND tm.ticket_type_id = $ticket_type" : "") . "
// GROUP BY tm.id, latest_status.claim_status_id, latest_status.change_date, tm.created_at
// ) AS subquery ON tc.TAT_Category = subquery.TAT_Category
// GROUP BY
// tc.TAT_Category
// ORDER BY
// FIELD(
// tc.TAT_Category,
// 'Above 20 Days',
// '13-20 Days',
// '7-12 Days',
// '0-6 Days'
// );
// ";
// // Execute the query and return the result
// $data = $this->db->query($sql)->getResultArray();
// // dd($data);
// print_rr($data);die();
// // print_rr($this->db->getLastQuery()->getQuery()); die;
// return $data;
// }
public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
{
//set default last 3 months data date
// Set default date range (last 90 days)
$fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = change_date_format($start_date);
$toDate = change_date_format($end_date);
}
$ticket_type_data_1 = "";
$ticket_type_data_2 = "";
// Get all active claim statuses
$statusQuery = $this->db->table('ticket_claim_status')
->select('id, claim_status')
->where('is_active', 1)
->orderBy('id', 'ASC');
if (!empty($ticket_type)) {
$ticket_type_data_1 = "AND ticket_type = $ticket_type";
$ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type";
$statusQuery->where('ticket_type', $ticket_type);
}
// Fetch claim statuses from the `ticket_claim_status` table
$statusQuery = " SELECT
id, claim_status, ticket_type
FROM ticket_claim_status
Where is_active = 1
$ticket_type_data_1
";
$statusResult = $this->db->query($statusQuery)->getResultArray();
// dd($statusResult);
// Initialize dynamic query parts
$dynamicSelect = '';
// Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
foreach ($statusResult as $status) {
$columnName = $status['claim_status']; // Default column name
if (empty($ticket_type)) {
// Append the insurance type prefix based on `ticket_type`
switch ($status['ticket_type']) {
case 1:
$columnName = "GMC - {$status['claim_status']}";
break;
case 2:
$columnName = "GPA - {$status['claim_status']}";
break;
case 3:
$columnName = "EDLI - {$status['claim_status']}";
break;
case 4:
$columnName = "GTLI - {$status['claim_status']}";
break;
$statusResult = $statusQuery->get()->getResultArray();
// Create a list of all TAT categories we want in the output
$tatCategories = [
'Above 20 Days',
'13-20 Days',
'7-12 Days',
'0-6 Days'
];
// Initialize the result array with all TAT categories
$result = [];
foreach ($tatCategories as $category) {
$row = ['TAT_Category' => $category];
foreach ($statusResult as $status) {
$row[$status['claim_status']] = 0;
}
$result[] = $row;
}
// Get the base query for ticket counts by status and TAT category
$query = $this->db->table('ticket_master tm')
->select([
'tcs.claim_status',
'CASE
WHEN DATEDIFF(CURDATE(), COALESCE(
(SELECT MAX(th.created_at)
FROM ticket_history th
WHERE th.ticket_id = tm.id
AND th.field_name = "claim_status_id"
AND th.is_active = 1),
tm.created_at
)) BETWEEN 0 AND 6 THEN "0-6 Days"
WHEN DATEDIFF(CURDATE(), COALESCE(
(SELECT MAX(th.created_at)
FROM ticket_history th
WHERE th.ticket_id = tm.id
AND th.field_name = "claim_status_id"
AND th.is_active = 1),
tm.created_at
)) BETWEEN 7 AND 12 THEN "7-12 Days"
WHEN DATEDIFF(CURDATE(), COALESCE(
(SELECT MAX(th.created_at)
FROM ticket_history th
WHERE th.ticket_id = tm.id
AND th.field_name = "claim_status_id"
AND th.is_active = 1),
tm.created_at
)) BETWEEN 13 AND 20 THEN "13-20 Days"
ELSE "Above 20 Days"
END AS tat_category',
'COUNT(*) AS count'
])
->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1')
->where('tm.is_active', 1)
->where('tm.created_at >=', $fromDate)
->where('tm.created_at <=', $toDate)
->groupBy('tcs.claim_status, tat_category')
->orderBy('FIELD(tat_category, "Above 20 Days", "13-20 Days", "7-12 Days", "0-6 Days")');
if (!empty($ticket_type)) {
$query->where('tm.ticket_type_id', $ticket_type);
}
$countResults = $query->get()->getResultArray();
// Populate the result array with actual counts
foreach ($countResults as $row) {
foreach ($result as &$categoryRow) {
if ($categoryRow['TAT_Category'] === $row['tat_category']) {
$categoryRow[$row['claim_status']] = (int)$row['count'];
break;
}
}
$dynamicSelect .= "
COALESCE(
SUM(
CASE
WHEN subquery.status_id = {$status['id']} THEN 1
ELSE 0
END
),
0
) AS `$columnName`, ";
}
// Remove the trailing comma from the SELECT part
$dynamicSelect = rtrim($dynamicSelect, ', ');
// dd($dynamicSelect);
// Construct the full SQL query
$sql = "
SELECT
tc.TAT_Category,
$dynamicSelect
FROM
(
SELECT 'Above 20 Days' AS TAT_Category
UNION ALL
SELECT '13-20 Days'
UNION ALL
SELECT '7-12 Days'
UNION ALL
SELECT '0-6 Days'
) AS tc
LEFT JOIN (
SELECT
th.ticket_id,
tcs.claim_status,
tcs.id AS status_id,
CASE
WHEN DATEDIFF(
th.created_at,
COALESCE(
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
tm.created_at
)
) BETWEEN 0 AND 6 THEN '0-6 Days'
WHEN DATEDIFF(
th.created_at,
COALESCE(
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
tm.created_at
)
) BETWEEN 7 AND 12 THEN '7-12 Days'
WHEN DATEDIFF(
th.created_at,
COALESCE(
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
tm.created_at
)
) BETWEEN 13 AND 20 THEN '13-20 Days'
ELSE 'Above 20 Days'
END AS TAT_Category
FROM
ticket_master tm
JOIN ticket_history th ON tm.id = th.ticket_id
JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' AND th.new_value = tcs.id
$ticket_type_data_2
AND tm.created_at >= '$fromDate'
AND tm.created_at <= '$toDate'
AND tm.is_active = 1
AND th.is_active = 1
AND tcs.is_active = 1
) AS subquery ON tc.TAT_Category = subquery.TAT_Category
GROUP BY
tc.TAT_Category
ORDER BY
FIELD(
tc.TAT_Category,
'Above 20 Days',
'13-20 Days',
'7-12 Days',
'0-6 Days'
);
";
// Execute the query and return the result
$data = $this->db->query($sql)->getResultArray();
// print_rr($this->db->getLastQuery(), $data); die;
// $tableData = [];
// if (!empty($data)) {
// // Extract table headers from the first row keys
// $headers = array_keys($data[0]);
// $tableData['headers'] = $headers;
// $tableData['body'] = $data;
// }
return $data;
return $result;
}
public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
@ -544,6 +625,7 @@ class TicketMasterModel extends Model
// Construct the final SQL query
$sql = "
SELECT
tpa.id as TPA_ID,
tpa.name AS TPA_NAME,
$dynamicSelect,
($dynamicTotal) AS TOTAL,

View File

@ -37,16 +37,18 @@
</tr>
<tr>
<?php foreach ($column_order as $col_name): ?>
<th><?= str_replace('_', ' ', $col_name) ?></th>
<?php endforeach; ?>
<?php if ($col_name != "TPA_ID") { ?>
<th><?= str_replace('_', ' ', $col_name) ?></th>
<?php } endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($tpa_wise_data as $row): ?>
<tr>
<?php foreach ($column_order as $col_name): ?>
<td><?= $row[$col_name] ?></td>
<?php endforeach; ?>
<?php if ($col_name != "TPA_ID") { ?>
<td onclick="redirectTPAToClaimList(<?= $row['TPA_ID'] ?>)"><?= $row[$col_name] ?></td>
<?php } endforeach;?>
</tr>
<?php endforeach; ?>
</tbody>
@ -62,7 +64,7 @@
}
foreach ($column_order as $col_name) {
if ($col_name !== 'TPA_NAME') {
if ($col_name !== 'TPA_NAME' && $col_name != "TPA_ID") {
echo "<th>{$totals[$col_name]}</th>";
}
}
@ -98,4 +100,35 @@
console.error("Table not found.");
}
});
</script>
function redirectTPAToClaimList(tpa_id){
// alert(tpa_id);
data = {
'tpa_id' : tpa_id,
'is_dashboard':3
}
redirectWithPost("<?= base_url("ticket/list") ?>", data);
}
function redirectWithPost(url, data = {}) {
const form = document.createElement('form');
form.method = 'POST';
form.action = url;
for (const key in data) {
if (data.hasOwnProperty(key)) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = data[key];
form.appendChild(input);
}
}
document.body.appendChild(form);
form.submit();
}
</script>

View File

@ -1004,7 +1004,7 @@ maxDate.setDate(today.getDate() + 180);
// Request failed, handle error
console.error("Request failed:", status, error);
toastr.error('Something went wrong! Try later', 'Error');
$('#uploadForm')[0].reset();
// $('#uploadForm')[0].reset();
$('.close').click()
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');

View File

@ -777,6 +777,7 @@
console.log(response.message, 'SUCCESS');
$('#appendArea_' + dataIncrement).append(response.data);
console.log("Policy Type ID : ",policy_type_id);
if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) {
let newId = 'appendAreaForClaim_' + dataIncrement;

View File

@ -346,14 +346,21 @@ if (isset($selected_lead_type)) {
let placeholder = isFirstField ? 'First file must be Demography.' : '';
let accept = isFirstField ? '.xls,.xlsx' : '';
if(selected_lead_form_type != 1){
placeholder = '';
accept = '';
}
let sample_dwn_link = "";
if(selected_lead_form_type == 1 && isFirstField == 1){
sample_dwn_link = '&nbsp;[ <a href="<?= base_url("util/download-excel/member_data"); ?>" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ]';
}
div.innerHTML = `
<div class="form-group col-md-5">
<label>Document Name<span class="text-danger"></span></label>
<label>Document Name ${sample_dwn_link}<span class="text-danger"></span></label>
<input type="text" class="form-control" name="docs_name_${increment}[]" placeholder="${placeholder}">
</div>
<div class="form-group col-md-5">
@ -458,9 +465,19 @@ if (isset($selected_lead_type)) {
<script>
$(document).ready(async function () {
handleEbAndNonEbEdit(
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
setTimeout(() => {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
handleEbAndNonEbEdit(
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
);
}, 1000);
});
function handleEbAndNonEbEdit(data){
@ -709,6 +726,11 @@ if (isset($selected_lead_type)) {
$('#policy_type_id').val(data.policy_type_id || '').select2();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$(".loss_date").each(function () {
flatpickr(this, {
dateFormat: "d-m-Y",
});
});
}, 1000);
}, 1000);
}, 2000);

File diff suppressed because it is too large Load Diff

View File

@ -425,10 +425,10 @@
}
// console.log("form from : ", formDataSplitUp);
if (productSelectionData.multipleProduct == 'on') {
let selectionType = productSelectionData.multilocation_type;
// if (productSelectionData.multipleProduct == 'on') {
// let selectionType = productSelectionData.multilocation_type;
if (selectionType == 'multiFloater') {
// if (selectionType == 'multiFloater') {
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);
@ -456,16 +456,16 @@
return false;
}
// console.log("Total SI: ", totalSI);
} 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);
// } 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);
// }
// }
// console.log("Form is trying to submit : ", formDataSplitUp);
@ -655,13 +655,34 @@
}else{
// alert("you got ir");
policyRiskAddress.forEach(function() {
// console.log("increment count is ", increment2)
addHTMLInputForRiskSplitUP();
validatePolicyBasedOnProductSelection();
hideAndShowBurglary();
})
}
console.log("increment2",increment2);
console.log("policyRiskAddress.length",policyRiskAddress.length);
policyRiskAddress.forEach(function() {
if (increment2 <= policyRiskAddress.length) {
// console.log("increment count is ", increment2)
addHTMLInputForRiskSplitUP();
validatePolicyBasedOnProductSelection();
hideAndShowBurglary();
}
})
// else {
// const container = document.getElementById("addRiskSplitUp");
// container.innerHTML = "";
// increment2 = 1;
// if (increment2 <= policyRiskAddress.length) {
// policyRiskAddress.forEach(function() {
// // console.log("increment count is ", increment2)
// addHTMLInputForRiskSplitUP();
// validatePolicyBasedOnProductSelection();
// hideAndShowBurglary();
// // increment2++;
// })
// // alert("fdg");
// }
// }
}
} else {
if (contianertoCheck.innerHTML == "") {
addHTMLInputForRiskSplitUpWarninig();
@ -714,7 +735,8 @@
const newRowRisk = document.createElement("div");
// // console.log("Risk Split Up for address : ", policyRiskAddress.length)
// policyRiskAddress
console.log(increment2);
console.log(policyRiskAddress[increment2-1])
newRowRisk.innerHTML += `
<h5 class = "fire">Fire <?= isset($product) ? $product : "" ?> Details</h5>
<h5>Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}</h5>
@ -1043,7 +1065,7 @@
$('[class*="single_location"]').show();
$("#locationNoDIV").hide();
$("#location_no").removeAttr("required", false);
$('[class*="duplicate-btn"]').hide();
// $('[class*="duplicate-btn"]').hide();
$("[id^='select_location']").hide();
$('[id^="select_location"]').hide().prev('label').hide();
$("[id^='select_location']").removeAttr('required', false);
@ -1122,15 +1144,21 @@
function registerPolicyData() {
var policyType;
var policyAcronym;
if (totalSI < 50000000) {
if (totalSI <= 50000000) {
policyType = "Bharat Sookshma Udyam Suraksha (BSUS)"
} else if (totalSI > 50000000 && totalSI < 500000000) {
policyAcronym = "bsu"
} else if (totalSI > 50000000 && totalSI <= 500000000) {
policyType = "Bharat Laghu Udyam Suraksha (BLUS)"
policyAcronym = "blu"
} else if (totalSI > 500000000) {
policyType = "Standard Fire and Special Perils (SFSP)";
policyAcronym = "sfsp"
}
modifyExcessTable(policyAcronym);
// Build the initial JSON object with productSelection and policyDetails
var outputData = {
policyType: policyType,

View File

@ -13,6 +13,21 @@
} ?>
</select>
</div>
<div class="form-group col-md-2">
<label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_policy_type_${increment}" name="first_policy_type_[]"
value="<?= htmlspecialchars($value['policy_type']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label>
<input type="text" class="form-control loss_date" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]"
value="<?= htmlspecialchars($value['date_of_loss']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"
value="<?= htmlspecialchars($value['cause_of_loss']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]"
@ -23,11 +38,6 @@
<input type="text" class="form-control" id="first_settled_amount_${increment}" name="first_settled_amount[]"
value="<?= htmlspecialchars($value['settled_amount']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"
value="<?= htmlspecialchars($value['cause_of_loss']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]"

View File

@ -63,7 +63,7 @@
$rowTotal += $numValue; // Add to row total
}
?>
<td><?= esc($value) ?></td>
<td onclick="redirectTATtoClaims(`<?= $row['TAT_Category'] ?>`,`<?= $policyType ?>`)"><?= esc($value) ?></td>
<?php endforeach; ?>
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
</tr>
@ -129,4 +129,41 @@
});
// ----------------------------------------------------------------------------------------------------
</script>
<script>
function redirectTATtoClaims(tat_category, policyType) {
// Safely render PHP dates inside JavaScript strings
var fromDate = "<?= isset($fromDate) && $fromDate != null ? change_date_format($fromDate) : date('Y-m-d', strtotime('-90 days')) ?>";
var toDate = "<?= isset($toDate) && $toDate != null ? change_date_format($toDate) : date('Y-m-d 23:59:59') ?>";
var data = {
'tat_category': tat_category,
'is_dashboard': 4,
'ticket_type_id': policyType,
'from_date': fromDate,
'to_date': toDate
};
redirectWithPost("<?= base_url("ticket/list") ?>", data);
}
function redirectWithPost(url, data = {}) {
const form = document.createElement('form');
form.method = 'POST';
form.action = url;
for (const key in data) {
if (data.hasOwnProperty(key)) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = data[key];
form.appendChild(input);
}
}
document.body.appendChild(form);
form.submit();
}
</script>

View File

@ -180,7 +180,15 @@
<!-- end first_data_points -->
<br><br>
<h5>Claim Details <span><i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for more details"></i></span></h5>
<div style="display: flex; align-items: center; gap: 10px;">
<h5 style="margin: 0;">
Claim Details
<i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for more details" style="margin-left: 5px;"></i>
<?= isset($ticket_data['claim_number']) && !empty($ticket_data['claim_number']) ? '( Claim No : ' . $ticket_data['claim_number'] . ' )' : '' ?>
</h5>
</div>
<hr>
<!-- second_data_points -->
@ -594,6 +602,11 @@
});
}
$field = $('#approved_description')
$field.prop('required', false);
var $parentDiv = $field.closest("div");
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
}
$('#claim_status_id').on('change', function() {

View File

@ -432,6 +432,12 @@
} else if (value == 48 || value == 54 || value == 59) { // RETURNED
$('.returned').show();
}
$field = $('#approved_description')
$field.prop('required', false);
var $parentDiv = $field.closest("div");
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
}
$('#claim_status_id').on('change', function() {

View File

@ -109,12 +109,13 @@ table.dataTable tbody td {
<th>TAT</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php if (isset($ticket_data)) { ?>
<?php foreach($ticket_data as $index => $row){ ?>
<tr onclick="viewTicket(<?php echo $row['id']; ?>)" style="cursor: pointer;">
<tr data-id="<?= $row['id']; ?>" style="cursor: pointer;">
<td data-toggle="tooltip" data-placement="top"
@ -216,6 +217,16 @@ table.dataTable tbody td {
<td><?php echo $row['tat']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removeClaim(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
@ -294,4 +305,41 @@ function viewTicket(ticket_id){
}
function removeClaim(input, ticket_id) {
confirmActionSweertAlert("Do you want to delete this Claim?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
if (confirmed) {
let url = '<?= base_url('ticket/remove') ?>';
// Include `pt_id` in the AJAX request if necessary
let requestData = { ticket_id: ticket_id };
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
window.location.reload();
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
});
}
$(document).on('click', 'tbody tr', function (e) {
// Exclude clicks on any elements inside the last column (actions)
if ($(e.target).closest('td').index() !== $(this).children('td').length - 1) {
const id = $(this).data('id');
console.log('Ticket ID', id)
viewTicket(id);
}
});
</script>

View File

@ -525,14 +525,12 @@
<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" style="<?= (!empty($lead_data['is_installment']) && $lead_data['is_installment'] == 1) ? 'display: block;' : 'display: none;' ?>">
<label for="no_of_installment">No of Installments</label>
<input type="text" class="form-control" id="no_of_installment" name="no_of_installment"
value="<?= isset($lead_data['no_of_installment']) ? $lead_data['no_of_installment'] : 1 ?>">
</div>
<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'])) { ?>
@ -552,7 +550,7 @@
<hr>
<div id="installment_form_row">
<?= isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
<?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 && isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
</div>
<hr>
@ -637,6 +635,7 @@
var user_role_id = <?= get_role_id(); ?>;
var jsonDataForHide = null;
var multi_file_data = [];
var totalSumAssuredData = [];
const editorConfig = {
buttons: [
@ -710,6 +709,9 @@
let qcr_count = <?= isset($qcr_count) ? $qcr_count : 0 ?>;
let question_json = <?= isset($question_json) ? json_encode($question_json) : 'null' ?>;
let policy_terms_json = <?= isset($policy_terms) ? json_encode($policy_terms) : 'null' ?>;
totalSumAssuredData = <?= isset($totalSumAssured) ? json_encode($totalSumAssured) : '[]' ?>;
console.log('totalSumAssuredData', totalSumAssuredData);
console.log('totalSumAssuredData.type', typeof totalSumAssuredData);
// console.log('policy_terms_json', policy_terms_json);
data = JSON.parse(data);
@ -1238,7 +1240,7 @@ function addSuggestionsToTable() {
particularsCell.innerText = details.display_values;
const columnCount = $("#rfqTable thead tr th").length;
console.log('columnCount' + columnCount);
// console.log('columnCount' + columnCount);
for (let i = 3; i < columnCount - 6; i++) {
@ -1335,8 +1337,43 @@ function addSuggestionsToTable() {
moveAddRowButton();
hideQCR();
isFormDataModified = false;
processTotalSumInsured(totalSumAssuredData)
}
function processTotalSumInsured(data) {
let values = [];
if (Array.isArray(data)) {
data.forEach((value, index) => {
console.log('total - value', value);
if (index !== 0) {
$('#addQuote').click();
}
});
values = data
} else if (typeof data === 'object' && data !== null) {
$.each(data, function(key, value) {
console.log('total - value', value);
if (key != 0) {
$('#addQuote').click();
}
});
values = Object.values(data)
} else {
console.log("Data is not iterable.");
return;
}
// Set values in td.editablecolumns in order
$('#totalSumInsured .editablecolumns').each(function(index) {
if (values[index] !== undefined) {
$(this).text(values[index]);
}
});
}
// Function to move add row button to last row
function moveAddRowButton() {
@ -5828,27 +5865,92 @@ 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();
}
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();
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
if (row_count == 0 ) { addInstallmentHTML()}
// addInstallmentHTML()
}else{
console.log("inside else")
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
let remove_count = $("#no_of_installment").val();
console.log("row count",row_count);
if (row_count > 0 ) {
let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() {
return $(this).val();
}).get();
Swal.fire({
title: "Do you want to remove all the 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');
$("#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();
$('#no_of_installment').val("");
} 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{
// alert("Inside else");
$('#no_of_installment').val(row_count);
// $("#is_installment_switch").bootstrapToggle('on');
// $('#is_installment_switch').val('1').change();
// $('#is_installment_switch').bootstrapToggle('on');
// $('#is_installment_switch').prop('checked', true).trigger('change');
$('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update
}
});
}
}
})
$(document).on("input", "#cd_amount, #premium_amount", function() {
// alert("Function called");
@ -5991,8 +6093,8 @@ function appendMultiFileData(data) {
console.log("Form row count:", row_count);
if (row_count === 1) {
$installmentContainer.empty();
for (let index = 0; index < no_of_installments; index++) {
// $installmentContainer.empty();
for (let index = 0; index < no_of_installments - 1; index++) {
addInstallmentHTML();
}
} else if (no_of_installments === row_count) {
@ -6010,7 +6112,7 @@ function appendMultiFileData(data) {
console.log('ids', ids);
if (ids != null) {
if (Object.keys(ids).length > 0) {
Swal.fire({
title: "Do you want to remove the last " + (remove_count ?? "") + " entries?",
icon: "warning",
@ -6069,6 +6171,7 @@ function appendMultiFileData(data) {
}
});
$(document).ready(function(){
setTimeout(function(){
$('.payment_date').flatpickr({

View File

@ -255,6 +255,12 @@
cursor: pointer;
user-select: none;
}
.toggle.btn {
height: 38px !important;
line-height: 33px !important;
}
</style>
@ -424,31 +430,66 @@
<div class="form-row">
<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 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">
<label for="premium_amount">Premium Amount</label>
<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" value="<?= isset($lead_data['total_amount']) ? $lead_data['total_amount'] : "" ?>">
</div>
<?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="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="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'] : "" ?>">
<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" style="height: 37.53px;" <?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 ? 'checked' : '' ?>>
</div>
<div class="form-group col-md-3" style="<?= (!empty($lead_data['is_installment']) && $lead_data['is_installment'] == 1) ? 'display: block;' : 'display: none;' ?>">
<label for="no_of_installment">No of Installments</label>
<input type="text" class="form-control" id="no_of_installment" name="no_of_installment"
value="<?= isset($lead_data['no_of_installment']) ? $lead_data['no_of_installment'] : 1 ?>">
</div>
<?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['is_installment']) && $lead_data['is_installment'] == 1 && isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
</div>
<hr>
<div class="form-row">
@ -517,6 +558,22 @@
<script>
const dynamicExcessJson = {
"excess_fire":[
{
"blu":"5% of claim amount subject to minimum of Rs. 10000/- for each and every claim",
"bsu":"5% of claim amount subject to minimum of Rs. 5000/- for each and every claim",
"sfsp":"For location having SI upto INR 10Cr: 5% of claim amount subject to a minimum of Rs.10,000/- for each and every claim. For location having SI above INR 10Cr and upto 100 Cr: 5% of claim amount subject to a minimum of Rs.25,000/- For each and every claim .For location having SI above INR 100Cr and upto 1500 Cr: 5% of claim amount subject to a minimum of Rs.500,000/- for each and every claim"
}
],
"excess_burglary":[
{
"blu":"5% of claim amount subject to minimum of Rs.5,000/-",
"bsu": "5% of claim amount subject to minimum of Rs.2,500/- for Burglary & 5,000/- for Theft each and every claim"
}
]
}
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) : '""' ?>;
@ -1056,6 +1113,7 @@
newQuoteHeader.textContent = "Liability Limit";
}
newQuoteHeader.style.backgroundColor = randomColor;
newQuoteHeader.setAttribute('data-proposal', proposalCount);
headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child'));
// Add new cells to all rows
@ -1108,6 +1166,8 @@
hideProposalOptionsForChild();
showOrHideFieldsBasedOnRFQorQCR();
// styleTableColumns();
monitorTableChanges();
});
// #################################################################################
@ -1825,6 +1885,8 @@
// Add new rows from tableData
tableData.table_row_contents.forEach((rowData, index) => {
let rowID = Object.keys(rowData)[0];
// console.log("rowData: ",rowData);
// alert(rowID.answer_type);
var question = rowData[rowID].display_value;
const row = document.createElement('tr');
@ -1864,15 +1926,20 @@
// Check if subheader is NOT "Sum Insured"
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
"insurer_proposal" : ""; // alert(subHeaderText);
// console.log("default_answers_array",default_answers_array)
let default_answers_array = rowData[rowID].default_answer
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
let defaul_value = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
let default_answer = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
// // // console.log("defaultJsonString", defaultJsonString);
// // // console.log("defaultJsonString type", typeof defaultJsonString);
// // // console.log("defaultJsonString string", String(defaultJsonString));
// console.log("defaultJsonString", defaultJsonString);
// console.log("defaultJsonString type", typeof defaultJsonString);
// console.log("defaultJsonString string", String(defaultJsonString));
return `<td class="${className}" onblur="setValueForHiddenField(this,'${rowID.answer_type}')"
return `<td class="${className}" onblur="setValueForHiddenField(this,'${rowData[rowID].answer_type}')"
onclick="getAnswer('${'excess'}','${rowID}')"
contenteditable="true">
@ -4764,6 +4831,7 @@
var lead_id = $('#lead_id').val();
let to = $('#placement_to').val();
let placement_date = $('#placement_date').val();
let payment_date = $('#payment_date').val();
let utr_no = $('#utr_no').val();
let premium_amount = $('#premium_amount').val();
let total_amount = $('#total_amount').val();
@ -4773,6 +4841,10 @@
let proposal_insurer = $('#proposals option:selected').data('id');
let insurer_and_branch = $('#proposals').val();
let cc = $('#placement_cc').val();
let is_cd = $("#is_cd_switch").is(":checked") ? 1 : 0;
let no_of_installment = $('#no_of_installment').val();
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
// Process `to` field
to = to.split(',').map(email => email.trim());
@ -4784,6 +4856,33 @@
selectedFiles.push($(this).val());
});
let data = [];
$('#installment_form_row .form-row').each(function () {
var lead_id = $('#lead_id').val();
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();
@ -4796,12 +4895,17 @@
formData.append('proposal_insurer', proposal_insurer);
formData.append('insurer_and_branch', insurer_and_branch);
formData.append('placement_date', placement_date);
formData.append('payment_date', payment_date);
formData.append("is_cd",is_cd);
formData.append('utr_no', utr_no);
formData.append('premium_amount', premium_amount);
formData.append('total_amount', total_amount);
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);
@ -4972,71 +5076,54 @@
}
function monitorTableChanges() {
console.log("monitoring table changes");
var proposalValue = "";
// Get the first table
const table = document.querySelector("table");
if (!table) return;
console.log("monitoring table changes");
const table = document.querySelector("table");
if (!table) return;
// Get the first row in the tbody
const firstRow = table.querySelector("tbody tr");
if (!firstRow) return;
const firstRow = table.querySelector("tbody tr");
if (!firstRow) return;
// console.log("firstRow : ",firstRow);
const cells = firstRow.querySelectorAll("td");
const headerRow1 = table.querySelector("thead tr:nth-child(1)");
const headerRow2 = table.querySelector("thead tr:nth-child(2)");
if (!headerRow1 || !headerRow2) return;
// 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;
const mainHeaders = headerRow1.querySelectorAll("th");
const subHeaders = headerRow2.querySelectorAll("th");
// 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;
subHeaders.forEach((subHeader, index) => {
const subHeaderText = subHeader.textContent.trim();
const mainHeaderText = mainHeaders[index]?.textContent.trim();
// Check if subheader is "Sum Insured" and main header starts with "Proposal" or "Exis"
if (subHeaderText === "Sum Insured" && /^(Proposal|Exis)/i.test(mainHeaderText)) {
const proposalValue = subHeader.getAttribute("data-proposal");
if (index < cells.length) {
const cell = cells[index];
let previousValue = "";
cell.addEventListener("focus", function () {
previousValue = this.textContent.trim();
});
cell.addEventListener("blur", function () {
const newValue = this.textContent.trim();
if (newValue !== previousValue) {
tdChanged = true;
changedNewSI = newValue;
$("#policySI").val(newValue);
console.log("new Value proposalValue", changedNewSI);
console.log("proposalValue",proposalValue);
updateAddON(newValue, proposalValue);
console.log("Sum Insured value changed to:", newValue);
}
});
}
});
// 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");
@ -5194,5 +5281,396 @@
return false;
}
$(document).on("input", "#cd_amount, #premium_amount", function() {
// alert("Function called");
var cd_amount = parseInt($("#cd_amount").val()) || 0;
var premium_amount = parseInt($("#premium_amount").val()) || 0;
var total_amount = (cd_amount + premium_amount);
$("#total_amount").val(total_amount);
});
$("#is_cd_switch").change(function (){
var switch_status = ($("#is_cd_switch").is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#cd_amount").show();
$("#total_amount").show();
$("#cd_amount").closest('.form-group').show();
$("#total_amount").closest('.form-group').show();
}else{
$("#cd_amount").hide();
$("#total_amount").hide();
$("#cd_amount").closest('.form-group').hide();
$("#total_amount").closest('.form-group').hide();
}
})
$("#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();
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
if (row_count == 0 ) { addInstallmentHTML()}
// addInstallmentHTML()
}else{
console.log("inside else")
let $installmentContainer = $('#installment_form_row');
let row_count = $installmentContainer.find('.form-row').length;
let remove_count = $("#no_of_installment").val();
console.log("row count",row_count);
if (row_count > 0 ) {
let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() {
return $(this).val();
}).get();
Swal.fire({
title: "Do you want to remove all the 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');
$("#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();
$('#no_of_installment').val("");
} 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{
// alert("Inside else");
$('#no_of_installment').val(row_count);
// $("#is_installment_switch").bootstrapToggle('on');
// $('#is_installment_switch').val('1').change();
// $('#is_installment_switch').bootstrapToggle('on');
// $('#is_installment_switch').prop('checked', true).trigger('change');
$('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update
}
});
}
}
})
$('#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 - 1; 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 (Object.keys(ids).length > 0) {
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();
}
}
});
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).ready(function(){
setTimeout(function(){
$('.payment_date').flatpickr({
dateFormat: 'd/m/Y',
});
}, 2000)
// $('#is_installment_switch').bootstrapToggle();
})
$(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.");
}
}
});
</script>
<script>
class ExcessHandler {
change() {
throw new Error("Method 'change()' must be implemented.");
}
}
class DefaultExcessHandler extends ExcessHandler {
constructor(typeKey) {
super();
this.typeKey = typeKey;
}
change() {
getExcessData(this.typeKey);
}
}
const handlerMap = {
blu: new DefaultExcessHandler("blu"),
bsu: new DefaultExcessHandler("bsu"),
sfsp: new DefaultExcessHandler("sfsp"),
};
function modifyExcessTable(policyType) {
console.log("Policy Type from register: ", policyType);
const handler = handlerMap[policyType];
if (handler instanceof ExcessHandler) {
handler.change();
} else {
console.error(`No handler found for policyType: ${policyType}`);
}
}
function getExcessData(typeKey) {
const fire = dynamicExcessJson["excess_fire"][0][typeKey];
const burglary = dynamicExcessJson["excess_burglary"]?.[0]?.[typeKey] ?? null;
changeExcessTableDynamic(fire, burglary);
}
function changeExcessTableDynamic(fire, burglary = null) {
console.log("fire to be changed to: ", fire);
setExcessRowValues("fire", fire);
if (burglary != null) {
console.log("Burglary to be changed: ", burglary);
setExcessRowValues("burglary", burglary);
}
}
function setExcessRowValues(rowId, value) {
const table = document.getElementById("excess");
if (!table) return;
const rows = table.querySelectorAll(`tr[data-excess-row-parent="${rowId}"]`);
if (!rows.length) return;
const headerCells = table.querySelectorAll("thead tr:first-child th");
const subHeaderCells = table.querySelectorAll("thead tr:nth-child(2) th");
rows.forEach(row => {
const cells = row.querySelectorAll("td");
cells.forEach((cell, index) => {
const headerText = headerCells[index]?.textContent?.trim() || "";
const subHeaderText = subHeaderCells[index]?.textContent?.trim() || "";
if (
(headerText.startsWith("Proposal") || headerText.startsWith("Exi")) &&
subHeaderText.toLowerCase() === "sum insured"
) {
cell.textContent = value;
}
});
});
}
</script>
</script>

Binary file not shown.

Binary file not shown.