diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9c1b388e..ef4c655c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 39440f05..9bf373ce 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -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(); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index a11921fb..0bcc03c5 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -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 diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 31c2ff0f..5d65c4a4 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -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; diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index b001edf1..6e6c6952 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -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 []; + } } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index fa094bb8..0a3c357d 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -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"; diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 310cc939..d7270335 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -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}.
+ 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()); + } + } } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 37685b55..005bebc4 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -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; } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index d2e30828..67ffc9b1 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -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; diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 33f504c0..0d4529c3 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -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 ""; diff --git a/app/Models/BdsPlacementModel.php b/app/Models/BdsPlacementModel.php new file mode 100644 index 00000000..2cd7c6f4 --- /dev/null +++ b/app/Models/BdsPlacementModel.php @@ -0,0 +1,93 @@ +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; + } +} diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 1404190e..b85dad62 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -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, diff --git a/app/Views/claims_report_tpa_wise.php b/app/Views/claims_report_tpa_wise.php index 0a3fc65a..d473d717 100644 --- a/app/Views/claims_report_tpa_wise.php +++ b/app/Views/claims_report_tpa_wise.php @@ -37,16 +37,18 @@ - - + + + - - + + + @@ -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 "{$totals[$col_name]}"; } } @@ -98,4 +100,35 @@ console.error("Table not found."); } }); - + + function redirectTPAToClaimList(tpa_id){ + + // alert(tpa_id); + data = { + 'tpa_id' : tpa_id, + 'is_dashboard':3 + } + + redirectWithPost("", 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(); + } + \ No newline at end of file diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index be2954d7..fed5f122 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -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'); diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 265d1f32..25044797 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -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; diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index c6f463df..3096e13c 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -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 = ' [ " id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel ]'; + } + div.innerHTML = `
- +
@@ -458,9 +465,19 @@ if (isset($selected_lead_type)) { \ No newline at end of file diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index f9b1ee91..9cfadf3c 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -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 += `
Fire Details
Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}
@@ -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, diff --git a/app/Views/rfq/claims_details_non_eb.php b/app/Views/rfq/claims_details_non_eb.php index 9a7b590b..04592201 100644 --- a/app/Views/rfq/claims_details_non_eb.php +++ b/app/Views/rfq/claims_details_non_eb.php @@ -13,6 +13,21 @@ } ?>
+
+ + +
+
+ + +
+
+ + +
-
- - -
- + @@ -129,4 +129,41 @@ }); // ---------------------------------------------------------------------------------------------------- + + \ No newline at end of file diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 8eb8c494..a9779a33 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -180,7 +180,15 @@

-
Claim Details
+ +
+
+ Claim Details + + +
+
+
@@ -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() { diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index 3618d1f1..0ae537f8 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -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() { diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index 6f49c545..d3408054 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -109,12 +109,13 @@ table.dataTable tbody td { TAT + ACTION $row){ ?> - + + + + @@ -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 = ''; + + // 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); + } +}); + + \ No newline at end of file diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 1396be13..e42d2e2b 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -525,14 +525,12 @@ >
- +
+ + +
-
- - "> -
- - @@ -552,7 +550,7 @@
- +

@@ -637,6 +635,7 @@ var user_role_id = ; var jsonDataForHide = null; var multi_file_data = []; + var totalSumAssuredData = []; const editorConfig = { buttons: [ @@ -710,6 +709,9 @@ let qcr_count = ; let question_json = ; let policy_terms_json = ; + totalSumAssuredData = ; + 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 = ''; + 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({ diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 35e38f5c..183a1bb1 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -255,6 +255,12 @@ cursor: pointer; user-select: none; } + + .toggle.btn { + height: 38px !important; + line-height: 33px !important; + } + @@ -424,31 +430,66 @@
-
- - "> -
+
">
+
+ + > +
+
">
-
- - "> -
+ + +
+ + "> +
+ +
+ + "> +
+ +
- - "> + + >
+
+ + +
+ + + +
+ + "> +
+ +
+ + "> +
+ + + +
+
+
+

@@ -517,6 +558,22 @@ + + + + - \ No newline at end of file diff --git a/public/sample_excel/Sample_Member_Data.xlsx b/public/sample_excel/Sample_Member_Data.xlsx new file mode 100644 index 00000000..3adbcef7 Binary files /dev/null and b/public/sample_excel/Sample_Member_Data.xlsx differ diff --git a/public/sample_excel/enrollment.xlsx b/public/sample_excel/enrollment.xlsx index 0666a6c8..97cd3191 100755 Binary files a/public/sample_excel/enrollment.xlsx and b/public/sample_excel/enrollment.xlsx differ