FIX_CLAIMS_TAT,FEAT_DASHBOARD_USERROLE_BASED

This commit is contained in:
Srinivas-Saravanan 2025-04-22 12:07:56 +05:30
parent c40e5bbc64
commit 25e7296e85
17 changed files with 1796 additions and 1400 deletions

View File

@ -376,7 +376,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
}); });
$routes->group("report", ["filter" => "authMVC"], function ($routes) { $routes->group("report", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "PolicyTransactionController::reportBDS"); $routes->match(['get', 'post'],"list", "PolicyTransactionController::reportBDS");
$routes->get("report-varience-list", "PolicyTransactionController::reportVarience"); $routes->get("report-varience-list", "PolicyTransactionController::reportVarience");
$routes->get("report-business-list", "PolicyTransactionController::reportBusinessList"); $routes->get("report-business-list", "PolicyTransactionController::reportBusinessList");
$routes->get("report-finance-list", "PolicyTransactionController::reportFinanceList"); $routes->get("report-finance-list", "PolicyTransactionController::reportFinanceList");

View File

@ -244,9 +244,19 @@ class DashboardController extends AdminController
$data['policyStatus'] = $this->policyStatus; $data['policyStatus'] = $this->policyStatus;
$data['colorShades'] = $this->colorShades; $data['colorShades'] = $this->colorShades;
} }
if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])){
$data['claim_data'] = $this->getClaimData(); $data['claim_data'] = $this->getClaimData();
$data['lead_data'] = $this->getLeadData(); $data['colorShades'] = $this->colorShades;
}
if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])){
$data['lead_data'] = $this->leadModel->getDashData();
$data['bds_renewal'] = $this->policyTransactionModel->getBDSRenewalData();
$data['colorShades'] = $this->colorShades;
}
// dd(get_role_id(),user_team());
$data['page_name'] = 'Dashboard'; $data['page_name'] = 'Dashboard';
@ -255,9 +265,6 @@ class DashboardController extends AdminController
echo view('layout/footer'); echo view('layout/footer');
} }
public function getLeadData(){
}
public function getClaimData() public function getClaimData()
{ {
@ -281,7 +288,6 @@ class DashboardController extends AdminController
$claim_status[$typeId] = []; $claim_status[$typeId] = [];
} }
// Use associative array keys to mimic a set
$claim_status[$typeId][$status] = true; $claim_status[$typeId][$status] = true;
} }
@ -291,15 +297,8 @@ class DashboardController extends AdminController
} }
$data = $this->ticketModel->getDashData($claim_status, $this->claimDashLimit); $data = $this->ticketModel->getDashData($claim_status, $this->claimDashLimit);
// dd($data);
// foreach ($data as $dat){
// foreach ($dat as $key => $value){
// echo($key . " => ". $value);
// }
// }
// die();
return $data;
return $data;
} }
@ -765,7 +764,8 @@ class DashboardController extends AdminController
return $groupedData; return $groupedData;
} }
public function prepareClaimSearchData(){ public function prepareClaimSearchData()
{
$received_data = $this->request->getPost(); $received_data = $this->request->getPost();
$ticketTypeId = $received_data['ticketTypeId']; $ticketTypeId = $received_data['ticketTypeId'];

View File

@ -146,21 +146,38 @@ class LeadsController extends BaseController
$this->loadLayout('lead_filter', $data); $this->loadLayout('lead_filter', $data);
} else { } else {
$isFromDashboard = $this->request->getPost("is_dashboard");
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = $this->request->getPost('ids');
$ids = array_filter(explode(',', $ids));
if (!empty($ids)) {
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs to be integers
$where = "leads.id IN ($idsStr)";
} else {
$where = '1 = 0'; // No valid IDs, return empty result
}
// dd($where );
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
$this->loadLayout('lead_filter', $data);
} else {
$search_data = $this->request->getPost(); $search_data = $this->request->getPost();
// print_r($search_data);
$where = []; $where = [];
foreach ($search_data as $search_objects => $key) { foreach ($search_data as $search_objects => $key) {
if ($key != null && $key != '' && $key != 0) { if ($key != null && $key != '' && $key != 0 && $search_objects != 'is_dashboard') {
$where[$search_objects] = $key; $where[$search_objects] = $key;
} }
} }
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where); $data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
$html = view('leads_list', $data); $html = view('leads_list', $data);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} }
} }
}
public function createLead() public function createLead()
{ {
@ -682,7 +699,6 @@ class LeadsController extends BaseController
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}"; $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}";
} else { } else {
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}"; $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
} }
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']); $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
@ -1560,7 +1576,6 @@ class LeadsController extends BaseController
$formatted_policy = date("d-m-Y", $policy_expiry); $formatted_policy = date("d-m-Y", $policy_expiry);
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '(Due On ' . $formatted_policy . ')' . '.xlsx'; $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '(Due On ' . $formatted_policy . ')' . '.xlsx';
} else { } else {
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx'; $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx';
} }
@ -2195,7 +2210,6 @@ class LeadsController extends BaseController
foreach ($mailIDS as $mail) { foreach ($mailIDS as $mail) {
$recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail]; $recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail];
} }
} else { } else {
$recipient_data = [['name' => "Team", 'email' => $params['to']]]; $recipient_data = [['name' => "Team", 'email' => $params['to']]];
} }

View File

@ -320,8 +320,7 @@ class PolicyTransactionController extends BaseController
// $data['month'] = empty($data['month']) ? null : date('Y-m-d', strtotime($month)); // $data['month'] = empty($data['month']) ? null : date('Y-m-d', strtotime($month));
// Determine $is_addon value // Determine $is_addon value
$data['is_addon'] = in_array($data['policy_type_id'], [1, 2, 6, 7]) ? 1 : $data['is_addon'] = in_array($data['policy_type_id'], [1, 2, 6, 7]) ? 1 : (in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && isset($data['base_policy']) ? 3 : 1));
(in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && isset($data['base_policy']) ? 3 : 1));
// print_r($data); die; // print_r($data); die;
@ -390,7 +389,6 @@ class PolicyTransactionController extends BaseController
$this->policyTransactionModel->update($id, ['client_policy_id' => $client_policy_id]); $this->policyTransactionModel->update($id, ['client_policy_id' => $client_policy_id]);
$this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id); $this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id);
} }
} else { } else {
if (isset($data['emp_policy_id']) && !empty($data['emp_policy_id'][0])) { if (isset($data['emp_policy_id']) && !empty($data['emp_policy_id'][0])) {
$this->InsertIndividualEmpPolicyTable($emp_data, $data['client_policy_id']); $this->InsertIndividualEmpPolicyTable($emp_data, $data['client_policy_id']);
@ -515,7 +513,6 @@ class PolicyTransactionController extends BaseController
// die; // die;
return true; return true;
} }
// print_r($data); // print_r($data);
@ -638,7 +635,6 @@ class PolicyTransactionController extends BaseController
} }
return $emp_ids; return $emp_ids;
} }
} }
@ -667,7 +663,6 @@ class PolicyTransactionController extends BaseController
return true; return true;
} }
} }
@ -961,7 +956,6 @@ class PolicyTransactionController extends BaseController
} else { } else {
return $this->respond(['status' => false], 200); return $this->respond(['status' => false], 200);
} }
} }
public function removePolicyTransaction($id) public function removePolicyTransaction($id)
@ -972,7 +966,6 @@ class PolicyTransactionController extends BaseController
$this->policyTransactionModel->where('id', $id)->set($data)->update(); $this->policyTransactionModel->where('id', $id)->set($data)->update();
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update(); $this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200); return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200);
} else { } else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy transaction'], 200); return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy transaction'], 200);
@ -1136,14 +1129,12 @@ class PolicyTransactionController extends BaseController
$data['endorse_eff_date'] = null; $data['endorse_eff_date'] = null;
} else { } else {
$data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d'); $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d');
} }
if (empty($data['install_due_date'])) { if (empty($data['install_due_date'])) {
$data['install_due_date'] = null; $data['install_due_date'] = null;
} else { } else {
$data['install_due_date'] = change_date_format($data['install_due_date'], 'd/m/Y', 'Y-m-d'); $data['install_due_date'] = change_date_format($data['install_due_date'], 'd/m/Y', 'Y-m-d');
} }
if (!empty($data['month'])) { if (!empty($data['month'])) {
@ -1645,7 +1636,6 @@ class PolicyTransactionController extends BaseController
$insurer_data = $this->clientPolicyModel->where('id', $client_policy_id)->where('is_active', 1)->first(); $insurer_data = $this->clientPolicyModel->where('id', $client_policy_id)->where('is_active', 1)->first();
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to get data'], 200); return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to get data'], 200);
} }
} }
public function checkInvoiceStatus($pt_id) public function checkInvoiceStatus($pt_id)
@ -1784,6 +1774,7 @@ class PolicyTransactionController extends BaseController
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll(); $data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll(); $data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
//filter datas //filter datas
$start_date = $this->request->getGet('start_date'); $start_date = $this->request->getGet('start_date');
$end_date = $this->request->getGet('end_date'); $end_date = $this->request->getGet('end_date');
@ -1814,10 +1805,25 @@ class PolicyTransactionController extends BaseController
$client_branch_id = (!isset($client_branch_id) || $client_branch_id === '' || $client_branch_id === null) ? 0 : $client_branch_id; $client_branch_id = (!isset($client_branch_id) || $client_branch_id === '' || $client_branch_id === null) ? 0 : $client_branch_id;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id; $insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id; $client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id;
if ($this->request->is('post')) {
$isFromDashboard = $this->request->getPost("is_dashboard");
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = $this->request->getPost('ids');
$ids = array_filter(explode(',', $ids));
if (!empty($ids)) {
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs to be integers
$where = "policy_transaction.id IN ($idsStr)";
} else {
$where = []; // No valid IDs, return empty result
}
}
// dd($ids);
}
//Actual data for the list //Actual data for the list
$data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id); $data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id, isset($where) ? $where : '');
//!dd($data['report_list']); //!dd($data['report_list']);
$this->loadLayout('report_bds_filter', $data); $this->loadLayout('report_bds_filter', $data);
@ -1869,7 +1875,6 @@ class PolicyTransactionController extends BaseController
$data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id); $data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id);
// !dd($data['varience_list']); // !dd($data['varience_list']);
$this->loadLayout('variance_report_list', $data); $this->loadLayout('variance_report_list', $data);
} }
@ -1988,7 +1993,6 @@ class PolicyTransactionController extends BaseController
// dd($this->policyTransactionModel->getLastQuery()); // dd($this->policyTransactionModel->getLastQuery());
// dd($data); // dd($data);
$this->loadLayout('outstanding_report_list', $data); $this->loadLayout('outstanding_report_list', $data);
} }
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
@ -2006,7 +2010,8 @@ class PolicyTransactionController extends BaseController
// dd( $data['insurers']); // dd( $data['insurers']);
$data['insurer_statement_list'] = $this->insurerStatements $data['insurer_statement_list'] = $this->insurerStatements
->select('insurer_statements.*, ->select(
'insurer_statements.*,
insurers.name AS insurer_name, insurers.name AS insurer_name,
insurers.short_name, insurers.short_name,
user_profiles.first_name, user_profiles.first_name,
@ -2093,8 +2098,7 @@ class PolicyTransactionController extends BaseController
], ],
]); ]);
// $this->createStatementFolder(); // $this->createStatementFolder();
if ($validated) if ($validated) {
{
$avatar = $this->request->getFile('statement'); $avatar = $this->request->getFile('statement');
if (!$avatar) { if (!$avatar) {
$this->myLogger->logme("error", 'Statement File not found'); $this->myLogger->logme("error", 'Statement File not found');
@ -2106,7 +2110,6 @@ class PolicyTransactionController extends BaseController
$filename = $avatar->getName(); $filename = $avatar->getName();
// Handle successful upload, e.g., log success or further processing // Handle successful upload, e.g., log success or further processing
$this->myLogger->logme("error", 'Statement File moved successful'); $this->myLogger->logme("error", 'Statement File moved successful');
} else { } else {
$this->myLogger->logme("error", 'Statement File move failed'); $this->myLogger->logme("error", 'Statement File move failed');
return $this->respond(['dataStatus' => false, 'code' => 500, 'message' => 'File move failed'], 500); return $this->respond(['dataStatus' => false, 'code' => 500, 'message' => 'File move failed'], 500);
@ -2141,8 +2144,7 @@ class PolicyTransactionController extends BaseController
//validate file //validate file
$validation_result = $this->validateInsurerStatement(['file_id' => $file_id]); $validation_result = $this->validateInsurerStatement(['file_id' => $file_id]);
//update file content to DB //update file content to DB
if($validation_result['status'] ) if ($validation_result['status']) {
{
$this->updateInsurerStatement(['file_id' => $file_id]); $this->updateInsurerStatement(['file_id' => $file_id]);
} }
@ -2164,8 +2166,7 @@ class PolicyTransactionController extends BaseController
$folderPath = WRITEPATH . 'uploads/statements/'; $folderPath = WRITEPATH . 'uploads/statements/';
// Check if the folder doesn't exist // Check if the folder doesn't exist
if (!file_exists($folderPath)) if (!file_exists($folderPath)) {
{
// Create the folder // Create the folder
if (mkdir($folderPath, 0777, true)) { if (mkdir($folderPath, 0777, true)) {
$this->myLogger->logme('error', 'statement upload folder created successfully'); $this->myLogger->logme('error', 'statement upload folder created successfully');
@ -2177,9 +2178,7 @@ class PolicyTransactionController extends BaseController
// echo "Failed to create folder."; // echo "Failed to create folder.";
$this->myLogger->logme('error', 'Failed to create statement upload folder.'); $this->myLogger->logme('error', 'Failed to create statement upload folder.');
} }
} } else {
else
{
$this->myLogger->logme('error', 'upload folder exists.'); $this->myLogger->logme('error', 'upload folder exists.');
} }
} }
@ -2201,16 +2200,14 @@ class PolicyTransactionController extends BaseController
$ret_status = true; $ret_status = true;
// dd($month.'-'.$year); // dd($month.'-'.$year);
$return = []; $return = [];
if(!isset($file)) if (!isset($file)) {
{
//file not found in DB //file not found in DB
return array('status' => false, 'msg' => 'statement file not found in DB'); return array('status' => false, 'msg' => 'statement file not found in DB');
} }
$file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name']; $file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name'];
//check physical file //check physical file
if(!file_exists($file_name_with_path)) if (!file_exists($file_name_with_path)) {
{
//file not found update status and reason //file not found update status and reason
$message = "Physcial file not found"; $message = "Physcial file not found";
// echo $message; // echo $message;
@ -2238,11 +2235,9 @@ class PolicyTransactionController extends BaseController
// check policy no,insurer and etc in DB for this month // check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage // if all good return true, otherwise return false with messssage
foreach ($excel_data as $excel_key => $excel_row) foreach ($excel_data as $excel_key => $excel_row) {
{
$is_row_empty = check_row_is_empty_or_null($excel_row); $is_row_empty = check_row_is_empty_or_null($excel_row);
if(!$is_row_empty) if (!$is_row_empty) {
{
// $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row); // $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row);
$is_source_found = 0; $is_source_found = 0;
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
@ -2252,12 +2247,10 @@ class PolicyTransactionController extends BaseController
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
// Kint::dump($policy_no); // Kint::dump($policy_no);
foreach ($source_data as $source_key => $source_row) foreach ($source_data as $source_key => $source_row) {
{
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
// Kint::dump($source_endorsement_no); // Kint::dump($source_endorsement_no);
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) {
{
$is_source_found = 1; $is_source_found = 1;
$line_items = $line_items + 1; $line_items = $line_items + 1;
unset($source_data[$source_key]); unset($source_data[$source_key]);
@ -2265,21 +2258,18 @@ class PolicyTransactionController extends BaseController
} }
} }
if($is_source_found == 0) if ($is_source_found == 0) {
{
// echo $excel_key.'-'.$excel_row[1] . '- not found<br>'; // echo $excel_key.'-'.$excel_row[1] . '- not found<br>';
$error_data['error_code'] = 1; //match not found $error_data['error_code'] = 1; //match not found
// $error_data['error_data'] = ($error_data['error_data'] ?? []); // $error_data['error_data'] = ($error_data['error_data'] ?? []);
$error_data['error_data'] = array_merge($error_data['error_data'], [$excel_row[0]]); //match not found $error_data['error_data'] = array_merge($error_data['error_data'], [$excel_row[0]]); //match not found
} }
} }
} }
// dd($error_data); // dd($error_data);
if($error_data['error_code']) if ($error_data['error_code']) {
{
$status = 'failed'; $status = 'failed';
$ret_status = false; $ret_status = false;
} }
@ -2306,16 +2296,14 @@ class PolicyTransactionController extends BaseController
$ret_status = true; $ret_status = true;
// dd($month.'-'.$year); // dd($month.'-'.$year);
$return = []; $return = [];
if(!isset($file)) if (!isset($file)) {
{
//file not found in DB //file not found in DB
return array('status' => false, 'msg' => 'statement file not found in DB'); return array('status' => false, 'msg' => 'statement file not found in DB');
} }
$file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name']; $file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name'];
//check physical file //check physical file
if(!file_exists($file_name_with_path)) if (!file_exists($file_name_with_path)) {
{
//file not found update status and reason //file not found update status and reason
$message = "Physcial file not found"; $message = "Physcial file not found";
// echo $message; // echo $message;
@ -2343,11 +2331,9 @@ class PolicyTransactionController extends BaseController
// check policy no,insurer and etc in DB for this month // check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage // if all good return true, otherwise return false with messssage
$data_to_update = []; $data_to_update = [];
foreach ($excel_data as $excel_key => $excel_row) foreach ($excel_data as $excel_key => $excel_row) {
{
$is_row_empty = check_row_is_empty_or_null($excel_row); $is_row_empty = check_row_is_empty_or_null($excel_row);
if(!$is_row_empty) if (!$is_row_empty) {
{
$is_source_found = 0; $is_source_found = 0;
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
@ -2357,12 +2343,10 @@ class PolicyTransactionController extends BaseController
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
foreach ($source_data as $source_key => $source_row) foreach ($source_data as $source_key => $source_row) {
{
// Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) {
{
$is_source_found = 1; $is_source_found = 1;
//calculate percentage first //calculate percentage first
@ -2372,18 +2356,13 @@ class PolicyTransactionController extends BaseController
$actual_bp_brokerage = trim($excel_row[12]); $actual_bp_brokerage = trim($excel_row[12]);
$actual_bp_amt = trim($excel_row[6]); $actual_bp_amt = trim($excel_row[6]);
if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
{
$total_amt += $actual_bp_brokerage; $total_amt += $actual_bp_brokerage;
//percentage reverse calculation //percentage reverse calculation
if($actual_bp_per == 0 || $actual_bp_per == "") if ($actual_bp_per == 0 || $actual_bp_per == "") {
{
$actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2); $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2);
} }
} else {
}
else
{
$actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100); $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
$total_amt += $actual_bp_brokerage; $total_amt += $actual_bp_brokerage;
} }
@ -2392,17 +2371,13 @@ class PolicyTransactionController extends BaseController
$actual_tp_brokerage = trim($excel_row[13]); $actual_tp_brokerage = trim($excel_row[13]);
$actual_tp_amt = trim($excel_row[7]); $actual_tp_amt = trim($excel_row[7]);
if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
{
$total_amt += $actual_tp_brokerage; $total_amt += $actual_tp_brokerage;
//percentage reverse calculation //percentage reverse calculation
if($actual_tp_per == 0 || $actual_tp_per == "") if ($actual_tp_per == 0 || $actual_tp_per == "") {
{
$actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100; $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
} }
} } else {
else
{
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100); $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
$total_amt += $actual_tp_brokerage; $total_amt += $actual_tp_brokerage;
} }
@ -2411,17 +2386,13 @@ class PolicyTransactionController extends BaseController
$actual_tep_brokerage = trim($excel_row[14]); $actual_tep_brokerage = trim($excel_row[14]);
$actual_tep_amt = trim($excel_row[8]); $actual_tep_amt = trim($excel_row[8]);
if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
{
$total_amt += $actual_tep_brokerage; $total_amt += $actual_tep_brokerage;
//percentage reverse calculation //percentage reverse calculation
if($actual_tep_per == 0 || $actual_tep_per == "") if ($actual_tep_per == 0 || $actual_tep_per == "") {
{
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
} }
} } else {
else
{
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100); $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
$total_amt += $actual_tep_brokerage; $total_amt += $actual_tep_brokerage;
} }
@ -2435,7 +2406,6 @@ class PolicyTransactionController extends BaseController
continue 2; continue 2;
} }
} }
} }
} }
// dd($data_to_update); // dd($data_to_update);
@ -2461,31 +2431,29 @@ class PolicyTransactionController extends BaseController
->where('is_active', 1) ->where('is_active', 1)
->get() ->get()
->getResultArray(); ->getResultArray();
if(!$inv_details['invoice_value']) if (!$inv_details['invoice_value']) {
{
$stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value') $stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value')
->where('statement_id', $statement_id) ->where('statement_id', $statement_id)
->groupBy('statement_id') ->groupBy('statement_id')
->get() ->get()
->getResultArray(); ->getResultArray();
// print_r($stmt_level_value); // print_r($stmt_level_value);
if($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0])) if ($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0])) {
{
$inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value']; $inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value'];
} }
} }
// ~dd($inv_details); // ~dd($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'], $data = [
'invoice_status' => $inv_details['invoice_status'],
'gst_per' => isset($inv_details['gst_per']) ? $inv_details['gst_per'] : 18, 'gst_per' => isset($inv_details['gst_per']) ? $inv_details['gst_per'] : 18,
'invoice_value' => $inv_details['invoice_value'], 'invoice_value' => $inv_details['invoice_value'],
'gst_value' => $inv_details['gst_value'], 'gst_value' => $inv_details['gst_value'],
'invoice_no' => $inv_details['invoice_no'], 'invoice_no' => $inv_details['invoice_no'],
'invoice_amount' => $inv_details['invoice_amount'], 'invoice_amount' => $inv_details['invoice_amount'],
'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ]; 'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'], 'Y-m-d', 'd/m/Y') : null
];
$data['payments'] = $inv_payment_details; $data['payments'] = $inv_payment_details;
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200); return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
} }
public function saveInvoicePaymentDetails() public function saveInvoicePaymentDetails()
@ -2547,8 +2515,9 @@ class PolicyTransactionController extends BaseController
if ($pk) { if ($pk) {
$childData['updated_by'] = get_session_userid(); $childData['updated_by'] = get_session_userid();
$childData['id'] = (int)$pk; $childData['id'] = (int)$pk;
} else {
$childData['created_by'] = get_session_userid();
} }
else { $childData['created_by'] = get_session_userid(); }
// print_r($childData); // print_r($childData);
// Insert or update // Insert or update
$this->invPaymentDetailsModel->save($childData); $this->invPaymentDetailsModel->save($childData);
@ -2596,8 +2565,7 @@ class PolicyTransactionController extends BaseController
public function dmsSearch() public function dmsSearch()
{ {
// echo 'scbsc';die(); // echo 'scbsc';die();
if ($this->request->getMethod() == 'post') if ($this->request->getMethod() == 'post') {
{
// $jsonData = (array)$this->request->getJSON(); // $jsonData = (array)$this->request->getJSON();
$customer_id = $this->request->getPost('customer_id'); $customer_id = $this->request->getPost('customer_id');
$policy_id = $this->request->getPost('policy_id'); $policy_id = $this->request->getPost('policy_id');
@ -2608,8 +2576,7 @@ class PolicyTransactionController extends BaseController
$batch_files = []; $batch_files = [];
$files = []; $files = [];
// print_r($jsonData);die(); // print_r($jsonData);die();
if($policy_id != "") if ($policy_id != "") {
{
//get policy docs from policy transation related tables //get policy docs from policy transation related tables
$pt_files = $this->PTFileModel->getPolicyDriveFilesIndex($policy_id, $policy_doc_name); $pt_files = $this->PTFileModel->getPolicyDriveFilesIndex($policy_id, $policy_doc_name);
$batch_files = $this->batchFileModel->getBatchFilesDataForDocumentSearch($policy_id, $policy_doc_name); $batch_files = $this->batchFileModel->getBatchFilesDataForDocumentSearch($policy_id, $policy_doc_name);
@ -2618,8 +2585,7 @@ class PolicyTransactionController extends BaseController
// dd($this->PTFileModel->getLastQuery()); // dd($this->PTFileModel->getLastQuery());
// ~dd($pt_files); // ~dd($pt_files);
} }
if($customer_id != "") if ($customer_id != "") {
{
$kyc_files = $this->clientKYCDocsModel->getClientKYCDriveFilesIndex($customer_id, $cus_doc_name); $kyc_files = $this->clientKYCDocsModel->getClientKYCDriveFilesIndex($customer_id, $cus_doc_name);
// dd($this->clientKYCDocsModel->getLastQuery()); // dd($this->clientKYCDocsModel->getLastQuery());
// !dd($kyc_files); // !dd($kyc_files);
@ -2637,8 +2603,6 @@ class PolicyTransactionController extends BaseController
->where('client_policy.is_active', 1)->get()->getResultarray(); ->where('client_policy.is_active', 1)->get()->getResultarray();
// dd($data); // dd($data);
$this->loadLayout('dms_search', $data); $this->loadLayout('dms_search', $data);
} }
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
@ -2800,8 +2764,6 @@ class PolicyTransactionController extends BaseController
->findAll(); ->findAll();
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $res_data], 200); return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $res_data], 200);
} }
public function deleteStatement($id) public function deleteStatement($id)
@ -2818,6 +2780,4 @@ class PolicyTransactionController extends BaseController
->update(); ->update();
return $this->respond(['dataStatus' => true, 'code' => 200], 200); return $this->respond(['dataStatus' => true, 'code' => 200], 200);
} }
} }

View File

@ -181,15 +181,16 @@ class TicketController extends BaseController
return $this->loadLayout('ticket_search', $data); return $this->loadLayout('ticket_search', $data);
} else { } else {
$data['ticket_data'] = $this->ticketSearch();
$isFromDashboard = $this->request->getPost("is_dashboard"); $isFromDashboard = $this->request->getPost("is_dashboard");
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) { if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
$data['page_name'] = "Claims"; $data['page_name'] = "Claims";
$data['ticket_data'] = $this->ticketSearch(3);
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll(); $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(); $data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll();
return $this->loadLayout('ticket_search', $data); return $this->loadLayout('ticket_search', $data);
}else{ }else{
$data['ticket_data'] = $this->ticketSearch();
$html = view('ticket_list', $data); $html = view('ticket_list', $data);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} }
@ -201,39 +202,38 @@ class TicketController extends BaseController
{ {
$db = db_connect(); $db = db_connect();
$subquery = $db->table('ticket_history th') $subquery = $db->table('ticket_master tm')
->select([ ->select([
'th.ticket_id', 'tm.id AS ticket_id',
"CASE "CASE
WHEN DATEDIFF( WHEN DATEDIFF(
th.created_at, CURDATE(),
COALESCE( COALESCE(latest_history.created_at, tm.created_at)
(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' ) BETWEEN 0 AND 6 THEN '0-6 Days'
WHEN DATEDIFF( WHEN DATEDIFF(
th.created_at, CURDATE(),
COALESCE( COALESCE(latest_history.created_at, tm.created_at)
(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' ) BETWEEN 7 AND 12 THEN '7-12 Days'
WHEN DATEDIFF( WHEN DATEDIFF(
th.created_at, CURDATE(),
COALESCE( COALESCE(latest_history.created_at, tm.created_at)
(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' ) BETWEEN 13 AND 20 THEN '13-20 Days'
ELSE 'Above 20 Days' ELSE 'Above 20 Days'
END AS tat" END AS tat"
]) ])
->join('ticket_master tm', 'tm.id = th.ticket_id', 'right') ->join(
'(SELECT th.ticket_id, MAX(th.created_at) AS created_at
FROM ticket_history th
WHERE th.field_name = "claim_status_id"
GROUP BY th.ticket_id) AS latest_history',
'latest_history.ticket_id = tm.id',
'left'
)
->where('tm.is_active', 1) ->where('tm.is_active', 1)
->groupBy('th.ticket_id, tm.created_at'); ->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 1 get last 100 rows, action 2 filter and get all rows related to that and action 3 gets according to dashboard
if ($action == 1) { if ($action == 1) {
$query = $db->table('ticket_master tm') $query = $db->table('ticket_master tm')
@ -268,6 +268,18 @@ class TicketController extends BaseController
return $data; return $data;
}else if ($action == 3) {
$ids = $this->request->getPost('ids');
$ids = array_filter(explode(',', $ids));
if (!empty($ids)) {
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs to be integers
$where = "tm.id IN ($idsStr)";
} else {
$where = '1 = 0'; // No valid IDs, return empty result
}
// dd($where);
} else { } else {
$search_data = $this->request->getPost(); $search_data = $this->request->getPost();
// print_r($search_data); die() // print_r($search_data); die()
@ -278,6 +290,8 @@ class TicketController extends BaseController
} }
} }
// print_rr($where); // print_rr($where);
}
$query = $db->table('ticket_master tm') $query = $db->table('ticket_master tm')
->select([ ->select([
'tm.id', 'tm.id',
@ -312,7 +326,6 @@ class TicketController extends BaseController
return $data; return $data;
} }
}
public function ticket_form($ticket_type) public function ticket_form($ticket_type)
{ {

View File

@ -90,7 +90,8 @@ class ClientPolicyModel extends Model
return $data; return $data;
} }
public function getClientPolicyById($id){ public function getClientPolicyById($id)
{
return $this->db->table('client_policy') return $this->db->table('client_policy')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short') ->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
@ -106,10 +107,10 @@ class ClientPolicyModel extends Model
->where('client_policy.id', $id) ->where('client_policy.id', $id)
->get() ->get()
->getResult(); ->getResult();
} }
public function getClientPolicyByClientId($client_id){ public function getClientPolicyByClientId($client_id)
{
return $this->db->table('client_policy') return $this->db->table('client_policy')
@ -132,12 +133,10 @@ class ClientPolicyModel extends Model
->where('client_policy.is_active', 1) ->where('client_policy.is_active', 1)
->get() ->get()
->getResult(); ->getResult();
} }
public function getPolicyPremium($policy_id){ public function getPolicyPremium($policy_id)
{
return $this->db->table('policies') return $this->db->table('policies')
->select('policy_type.*') ->select('policy_type.*')
@ -147,7 +146,8 @@ class ClientPolicyModel extends Model
->getResult(); ->getResult();
} }
public function getPolicyPremiumPolicyTypeId($policy_type_id){ public function getPolicyPremiumPolicyTypeId($policy_type_id)
{
return $this->db->table('policies') return $this->db->table('policies')
->select('policy_type.*') ->select('policy_type.*')
@ -165,11 +165,11 @@ class ClientPolicyModel extends Model
->where('id', $policy_id) ->where('id', $policy_id)
->get() ->get()
->getResult(); ->getResult();
} }
public function getinsurerswithclientid($id){ public function getinsurerswithclientid($id)
{
return $this->db->table('client_policy') return $this->db->table('client_policy')
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no') ->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
@ -200,7 +200,8 @@ class ClientPolicyModel extends Model
} }
public function getinsurerswithinsurenceid($insurerId){ public function getinsurerswithinsurenceid($insurerId)
{
return $this->db->table('client_policy') return $this->db->table('client_policy')
->select('client_policy.*') ->select('client_policy.*')
@ -215,7 +216,8 @@ class ClientPolicyModel extends Model
} }
public function getClientById($id) { public function getClientById($id)
{
$query = $this->db->table('clients')->getWhere(['id' => $id]); $query = $this->db->table('clients')->getWhere(['id' => $id]);
// Debug statement // Debug statement
return $query->getRow(); return $query->getRow();
@ -321,7 +323,8 @@ public function getDepositlistsummary($id)
} }
public function updateStatus(){ public function updateStatus()
{
// Update client_policy table // Update client_policy table
$client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()"); $client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
@ -331,11 +334,10 @@ public function updateStatus(){
$emp_count = $this->db->affectedRows(); $emp_count = $this->db->affectedRows();
return ['client' => $client_count, 'emp' => $emp_count]; return ['client' => $client_count, 'emp' => $emp_count];
} }
public function getpolicyWithPattern($client_id){ public function getpolicyWithPattern($client_id)
{
$query = $this->db->table('client_policy') $query = $this->db->table('client_policy')
->select('client_policy.*, policies.name, policies.policy_type_id, policy_type.policy_type') ->select('client_policy.*, policies.name, policies.policy_type_id, policy_type.policy_type')
@ -351,7 +353,8 @@ public function getpolicyWithPattern($client_id){
return $query; return $query;
} }
public function getTopUpPolicy($client_id, $type){ public function getTopUpPolicy($client_id, $type)
{
$query = " $query = "
SELECT client_policy.*, policies.name, policies.policy_type_id SELECT client_policy.*, policies.name, policies.policy_type_id
@ -364,11 +367,11 @@ public function getTopUpPolicy($client_id, $type){
$result = $this->db->query($query)->getResult(); $result = $this->db->query($query)->getResult();
return $result; return $result;
} }
public function getClientPolicyByPolicyType($client_id, $type){ public function getClientPolicyByPolicyType($client_id, $type)
{
$query = $this->db->table('client_policy') $query = $this->db->table('client_policy')
@ -396,12 +399,11 @@ public function getClientPolicyByPolicyType($client_id, $type){
$result = $query->get()->getResult(); $result = $query->get()->getResult();
return $result; return $result;
} }
public function getPolicyTypeForPolicyBinding($client_id){ public function getPolicyTypeForPolicyBinding($client_id)
{
$result = $this->table('client_policy') $result = $this->table('client_policy')
->select('policy_type.*, client_policy.id as client_policy_id, client_policy.policy_no') ->select('policy_type.*, client_policy.id as client_policy_id, client_policy.policy_no')
@ -412,12 +414,11 @@ public function getPolicyTypeForPolicyBinding($client_id){
->findAll(); ->findAll();
return $result; return $result;
} }
public function getCliendDataForExcelFileName($client_policy_id){ public function getCliendDataForExcelFileName($client_policy_id)
{
return $this->table('client_policy') return $this->table('client_policy')
->select('clients.short_name, policy_type.policy_type, client_branch.branch_code') ->select('clients.short_name, policy_type.policy_type, client_branch.branch_code')
@ -427,7 +428,6 @@ public function getCliendDataForExcelFileName($client_policy_id){
->where('client_policy.id', $client_policy_id) ->where('client_policy.id', $client_policy_id)
->where('client_policy.is_active', 1) ->where('client_policy.is_active', 1)
->first(); ->first();
} }
//for this using in CRONE JOB //for this using in CRONE JOB
@ -471,5 +471,5 @@ public function getPolicyDetailsForEnrollment($client_id = null, $branch_id = nu
return $builder->get()->getResultArray(); return $builder->get()->getResultArray();
} }
}
}

View File

@ -186,8 +186,80 @@ class LeadsModel extends Model
$result = $query->get()->getResultArray(); $result = $query->get()->getResultArray();
return $result; return $result;
} }
public function getDashData()
{
$statuses = $this->db->table('leads')
->select('status')
->where("is_active", 1)
->groupBy('status')
->get()
->getResultArray();
$selectParts = [];
foreach ($statuses as $status) {
$s = $status['status'];
$alias = strtolower(str_replace(' ', '_', $s));
// Count alias
$selectParts[] = "SUM(CASE WHEN status = '{$s}' THEN 1 ELSE 0 END) AS `{$alias}`";
// IDs alias
$selectParts[] = "GROUP_CONCAT(CASE WHEN status = '{$s}' THEN leads.id ELSE NULL END) AS `{$alias}_ids`";
}
$select = implode(", ", $selectParts);
// Start query builder
$builder = $this->db->table('leads');
$builder->select($select);
// Auditing subquery
$subquery = "(SELECT pk, MAX(created_at) AS last_claim_status_change
FROM auditing_history
WHERE table_name = 'leads' AND field_name = 'status'
GROUP BY pk)";
$builder->join("{$subquery} AS th", 'leads.id = th.pk', 'left');
// Date filtering for last status change
$dateLimit = 3;
$dateThreshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
$builder->groupStart()
->where('th.last_claim_status_change <=', $dateThreshold)
->orWhere('th.last_claim_status_change IS NULL')
->groupEnd();
// Add only active
$builder->where("leads.is_active", 1);
$lead_data = $builder->get()->getResultArray();
// Fallback for empty results
if (empty($lead_data)) {
$lead_data[0] = ['total' => 0];
foreach ($statuses as $status) {
$alias = strtolower(str_replace(' ', '_', $status['status']));
$lead_data[0][$alias] = 0;
$lead_data[0]["{$alias}_ids"] = '';
}
}
// Calculate total
$total = 0;
foreach ($lead_data[0] as $key => $value) {
if (!str_ends_with($key, '_ids') && $key != "won") {
$total += (int) $value;
}
}
$lead_data[0]['total'] = $total;
// dd($lead_data[0]);
return $lead_data[0];
}
} }

View File

@ -309,7 +309,6 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
->where('policy_transaction.created_at <=', $toDate); ->where('policy_transaction.created_at <=', $toDate);
} }
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
@ -593,7 +592,7 @@ class PolicyTransactionModel extends Model
// return $result; // return $result;
// } // }
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0) public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0, $where = [])
{ {
$date_condition = ''; $date_condition = '';
@ -797,7 +796,10 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.created_by', get_session_userid()); $builder->where('policy_transaction.created_by', get_session_userid());
} }
} }
if (!empty($where)) {
log_message('info', 'Where condition: ' . json_encode($where));
$builder->where($where);
}
// Check if the start date and end date are provided // Check if the start date and end date are provided
if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') { if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
@ -806,7 +808,6 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); ->where('policy_transaction.' . $date_type . '<=', $endDate);
} }
// if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){ // if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
@ -865,9 +866,10 @@ class PolicyTransactionModel extends Model
$fromDate = date('Y-m-d', strtotime('-30 days')); $fromDate = date('Y-m-d', strtotime('-30 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
if (empty($where)) {
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
->where('policy_transaction.created_at <=', $toDate); ->where('policy_transaction.created_at <=', $toDate);
}
} }
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
@ -1117,7 +1119,6 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
->where('policy_transaction.created_at <=', $toDate); ->where('policy_transaction.created_at <=', $toDate);
} }
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
@ -1296,6 +1297,7 @@ class PolicyTransactionModel extends Model
public function getBusinessReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) public function getBusinessReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{ {
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days"));
$builder = $this->db->table('policy_transaction') $builder = $this->db->table('policy_transaction')
->select([ ->select([
'policy_transaction.id AS policy_trns_id', 'policy_transaction.id AS policy_trns_id',
@ -1319,9 +1321,19 @@ class PolicyTransactionModel extends Model
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left') ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->join(
'(SELECT policy_tran_id, MAX(created_at) AS last_policy_status_change,is_active
FROM policy_transaction_status
WHERE is_active = 1
GROUP BY policy_tran_id) th',
'policy_transaction.id = th.policy_tran_id'
)
->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false)
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
// ->where('policy_transaction.status', 'completed') // ->where('policy_transaction.status', 'completed')
->where('pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0'); ->where('(pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0)', null, false);
if ($start_date != 0 && $end_date != 0 && $date_type != 0) { if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
@ -1360,15 +1372,21 @@ class PolicyTransactionModel extends Model
} }
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
// echo $builder->getCompiledSelect();
// exit;
$returnData = $builder->get()->getResultArray(); $returnData = $builder->get()->getResultArray();
// dd($returnData);
return $returnData; return $returnData;
} }
public function getFinanceReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) public function getFinanceReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{ {
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days"));
$builder = $this->db->table('policy_transaction') $builder = $this->db->table('policy_transaction')
->select(" ->select("
policy_transaction.id, policy_transaction.id,
@ -1391,6 +1409,15 @@ class PolicyTransactionModel extends Model
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left') ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->join(
'(SELECT policy_tran_id, MAX(created_at) AS last_policy_status_change,is_active
FROM policy_transaction_status
WHERE is_active = 1
GROUP BY policy_tran_id) th',
'policy_transaction.id = th.policy_tran_id'
)
->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false)
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
// ->where('policy_transaction.status', 'completed') // ->where('policy_transaction.status', 'completed')
->where('COALESCE(pt_co_share_details.agreed_bp_per, 0) + COALESCE(pt_co_share_details.agreed_tp_per, 0) + COALESCE(pt_co_share_details.agreed_tep_per, 0) = 0') ->where('COALESCE(pt_co_share_details.agreed_bp_per, 0) + COALESCE(pt_co_share_details.agreed_tp_per, 0) + COALESCE(pt_co_share_details.agreed_tep_per, 0) = 0')
@ -1641,5 +1668,46 @@ class PolicyTransactionModel extends Model
return $results; return $results;
} }
public function getBDSRenewalData()
{
// Increase GROUP_CONCAT limit
$this->db->query("SET SESSION group_concat_max_len = 1000000;");
$builder = $this->db->table('policy_transaction pt');
$builder->select([
'SUM(CASE WHEN pt.policy_end_date < CURDATE() THEN 1 ELSE 0 END) AS Expired',
'SUM(CASE WHEN pt.policy_end_date BETWEEN CURDATE() AND (CURDATE() + INTERVAL 1 MONTH) THEN 1 ELSE 0 END) AS `Renewal Pending`',
'GROUP_CONCAT(CASE WHEN pt.policy_end_date < CURDATE() THEN pt.id ELSE NULL END) AS Expired_ids',
'GROUP_CONCAT(CASE WHEN pt.policy_end_date BETWEEN CURDATE() AND (CURDATE() + INTERVAL 1 MONTH) THEN pt.id ELSE NULL END) AS Renewal_Pending_ids'
]);
$builder->where("pt.policy_end_date IS NOT NULL", null, false);
$builder->where('pt.is_active', 1);
// Self join to check if a policy has been renewed
$builder->join('policy_transaction renewed', 'renewed.source_client_policy_id = pt.client_policy_id and renewed.client_id = pt.client_id and renewed.client_branch_id = pt.client_branch_id', 'left');
// Filter for expired or expiring policies
$builder->where("(pt.policy_end_date < CURDATE() OR pt.policy_end_date BETWEEN CURDATE() AND (CURDATE() + INTERVAL 1 MONTH))", null, false);
$builder->where('renewed.id IS NULL', null, false);
$query = $builder->get();
$result = $query->getResultArray();
$total = 0;
foreach ($result[0] as $key => $value) {
if ($key !== 'Expired_ids' && $key !== 'Renewal_Pending_ids') {
$total += $value;
}
}
// Ensure ID fields are arrays (not null)
$result[0]['Expired_ids'] = $result[0]['Expired_ids'] ? $result[0]['Expired_ids'] : [];
$result[0]['Renewal Pending_ids'] = $result[0]['Renewal_Pending_ids'] ? $result[0]['Renewal_Pending_ids'] : [];
// Add total count
$result[0]['total'] = $total;
return $result[0];
}
} }

View File

@ -726,76 +726,145 @@ class TicketMasterModel extends Model
$finalResults = []; $finalResults = [];
foreach ($claim_statuses as $typeId => $statuses) { foreach ($claim_statuses as $typeId => $statuses) {
$builder = $this->db->table('ticket_master tm'); // Get all active, non-null claim status tickets for this type
$builder = $this->db->table('ticket_master tm')
// Start with ticket_type_id in SELECT ->select('tm.id, tm.ticket_type_id, tcs.claim_status, th.last_claim_status_change')
$selects = ['tm.ticket_type_id']; ->join('ticket_claim_status tcs', 'tm.claim_status_id = tcs.id', 'left')
->join(
// Dynamically build status counts with COALESCE to handle missing values
foreach ($statuses as $status) {
$alias = strtolower($status);
$alias = str_replace(' ', '_', $alias);
$selects[] = "COALESCE(SUM(CASE WHEN tcs.claim_status = " . $this->db->escape($status) . " AND tm.ticket_type_id = {$typeId} THEN 1 ELSE 0 END), 0) AS `{$alias}`";
}
$builder->select(implode(',', $selects));
$builder->join('ticket_claim_status tcs', 'tm.claim_status_id = tcs.id', 'left');
// Subquery for latest status change, with LEFT JOIN to avoid missing ticket_type_id
$builder->join(
'(SELECT ticket_id, MAX(created_at) AS last_claim_status_change '(SELECT ticket_id, MAX(created_at) AS last_claim_status_change
FROM ticket_history FROM ticket_history
WHERE field_name = \'claim_status_id\' WHERE field_name = \'claim_status_id\'
GROUP BY ticket_id) th', GROUP BY ticket_id) th',
'tm.id = th.ticket_id', 'tm.id = th.ticket_id',
'left' 'left'
); )
->where('tm.ticket_type_id', $typeId)
->where('tm.is_active', 1)
->where('tm.claim_status_id IS NOT NULL');
// Set the date limit based on the status $results = $builder->get()->getResultArray();
foreach ($statuses as $status) {
$dateLimit = $limit[$typeId][$status] ?? 3;
$dateThreshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
$builder->groupStart() $summary = [
->where('th.last_claim_status_change <=', $dateThreshold) 'ticket_type_id' => $typeId,
->orWhere('th.last_claim_status_change IS NULL') ];
->groupEnd();
}
$builder->where('tm.ticket_type_id', $typeId);
$builder->where('tm.is_active', 1);
$builder->where('tm.claim_status_id is not null');
$builder->groupBy('tm.ticket_type_id');
$query = $builder->get();
$result = $query->getRowArray();
// Add Total count
$total = 0; $total = 0;
foreach ($result as $key => $res) {
// Ensure that ticket_type_id is excluded from the sum
if ($key !== 'ticket_type_id') {
$total += $res;
}
}
$result['total'] = $total;
// If no result, initialize an empty result for the ticket_type_id
if (!$result) {
$result = ['ticket_type_id' => $typeId, 'total' => 0];
foreach ($statuses as $status) { foreach ($statuses as $status) {
$alias = strtolower($status); $alias = strtolower(str_replace(' ', '_', $status));
$alias = str_replace(' ', '_', $alias); $summary[$alias] = 0;
$result[$alias] = 0; $summary[$alias . '_ids'] = '';
$dateLimit = $limit[$typeId][$status] ?? 3;
$threshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
$ticketIds = [];
// dd($results);
foreach ($results as $row) {
if (
$row['claim_status'] === $status &&
(
!$row['last_claim_status_change'] ||
$row['last_claim_status_change'] <= $threshold
)
) {
$summary[$alias]++;
$ticketIds[] = $row['id'];
if ($status == "APPROVED"|| $status == "SETTLED"|| $status == "CLOSED" ){
continue;
}
$total++;
} }
} }
// Add the result to the final array // Convert ticket IDs array to a comma-separated string
$finalResults[$typeId] = $result; $summary[$alias . '_ids'] = implode(',', $ticketIds);
} }
$summary['total'] = $total;
// Add approved but not settled IDs and count
$approvedNotSettled = $this->getNotSettledbutApprovedCount($typeId);
$summary['approved_not_settled'] = $approvedNotSettled['count'];
$summary['approved_not_settled_ids'] = $approvedNotSettled['ticket_ids'];
$finalResults[$typeId] = $summary;
}
// dd($finalResults);
return $finalResults; return $finalResults;
} }
public function getNotSettledbutApprovedCount($ticket_type)
{
// Fetch the approved and settled claim_status IDs
$builder = $this->db->table("ticket_claim_status approved")
->select("approved.id AS approved_id, settled.id AS settled_id")
->join("ticket_claim_status settled", "approved.ticket_type = settled.ticket_type")
->where("approved.claim_status", "APPROVED")
->where("settled.claim_status", "SETTLED")
->where("approved.ticket_type", $ticket_type)
->where("approved.is_active", 1)
->where("settled.is_active", 1);
$ids = $builder->get()->getRowArray();
// If no matching status IDs are found, return empty
if (!$ids) {
return ['count' => 0, 'ticket_ids' => ''];
}
// Extract approved and settled status IDs
$approved_id = $ids['approved_id'];
$settled_id = $ids['settled_id'];
// Subquery to get the latest approval time for each ticket
$subquery = $this->db->table('ticket_history')
->select('ticket_id, MAX(created_at) AS approved_time')
->where('field_name', 'claim_status_id')
->where('new_value', $approved_id)
->groupBy('ticket_id');
// Main query to find tickets that are approved but not settled
$builder = $this->db->table('ticket_master tm');
$builder->join("({$subquery->getCompiledSelect()}) latest_approval", 'tm.id = latest_approval.ticket_id', 'inner');
// Left join to find if there is a settled status for each ticket after approval
$builder->join(
'ticket_history th_settled',
"th_settled.ticket_id = tm.id
AND th_settled.field_name = 'claim_status_id'
AND th_settled.new_value = {$settled_id}
AND th_settled.created_at > latest_approval.approved_time",
'left',
false // Important for raw ON condition
);
// Filtering conditions: not settled and approved time older than 12 days
$builder->where('tm.claim_status_id !=', $settled_id);
$builder->where('tm.is_active', 1);
$builder->where("latest_approval.approved_time <= DATE_SUB(NOW(), INTERVAL 12 DAY)", null, false);
$builder->where('th_settled.id IS NULL', null, false);
// Final select to get ticket IDs of approved but not settled tickets
$builder->select('tm.id');
// Execute the query
$query = $builder->get();
$ticketIds = array_column($query->getResultArray(), 'id'); // Extract the IDs
// Convert ticket IDs array to a comma-separated string
$ticketIdsString = implode(',', $ticketIds);
// Return the count and comma-separated ticket IDs
return [
'count' => count($ticketIds),
'ticket_ids' => $ticketIdsString
];
}
} }

View File

@ -173,7 +173,7 @@
</style> </style>
<?php if(in_array(get_role_id(), [1,2,3,5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?> <?php if(in_array(get_role_id(), [1,2,3,4,5]) || (in_array(ENROLLMENT_TEAM_ID, user_team()) || in_array(CLAIMS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
<div class="row" id="client_add" style="margin-top: -32px;"> <div class="row" id="client_add" style="margin-top: -32px;">
<div class="col-12"> <div class="col-12">
@ -217,28 +217,43 @@
</li> </li>
<?php } ?> <?php } ?>
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
<?php
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team()) ? 'active show' : '';
?>
<li class="nav-item"> <li class="nav-item">
<a href="#claims-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="claims_tab"> <a href="#claims-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2 <?= $isActive?>" id="claims_tab">
<span class="mr-1"><i class="fa fa-file-alt"></i> </span> <span class="mr-1"><i class="fa fa-file-alt"></i> </span>
<span class="d-none d-sm-inline-block">Claims</span> <span class="d-none d-sm-inline-block">Claims</span>
</a> </a>
</li> </li>
<?php endif; ?>
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
<?php
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team()) ? 'active show' : '';
?>
<li class="nav-item"> <li class="nav-item">
<a href="#leads-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="leads_tab"> <a href="#leads-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2 <?= $isActive?>" id="leads_tab">
<span class="mr-1"><i class="fa fa-file-alt"></i> </span> <span class="mr-1"><i class="fa fa-file-alt"></i> </span>
<span class="d-none d-sm-inline-block">Leads and Renewals</span> <span class="d-none d-sm-inline-block">Leads and BDS Renewals</span>
</a> </a>
</li> </li>
<?php endif; ?>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
<?php include("claims_dash.php") ?> <?php include("claims_dash.php") ?>
<?php endif; ?>
<?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?> <?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
<?php include('bds_dash.php'); ?> <?php include('bds_dash.php'); ?>
<?php } ?> <?php } ?>
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
<?php include("leads_dash.php") ?> <?php include("leads_dash.php") ?>
<?php endif; ?>
<?php if(in_array(get_role_id(), [1,2,3,5])) { ?> <?php if(in_array(get_role_id(), [1,2,3,5])) { ?>
<?php include('endorsement_dash.php'); ?> <?php include('endorsement_dash.php'); ?>

View File

@ -131,11 +131,14 @@ body{
<div class="tab-pane <?= isset($add_active_calss) ? $add_active_calss : 'fade' ?>" id="bds-dash-tab" style="padding-right: 35px;"> <div class="tab-pane <?= isset($add_active_calss) ? $add_active_calss : 'fade' ?>" id="bds-dash-tab" style="padding-right: 35px;">
<div class="row">
<div class="StatusTileHide" style="display: none; position: relative; bottom: 15px;"> <div class="StatusTileHide" style="display: none; padding-bottom: 10px;padding-left: 17px">
<a href="#" onclick="hide_status_show_pending_tile()" >show all pending Tile</a> <a href="#" onclick="hide_status_show_pending_tile()" ><i class="fas fa-arrow-left"></i> Back to Overview</a>
</div>
<div class="StatusTileHide" style="display: none;padding-left: 30px;">
<a href="#" id="mainMenuTiles">Current Tile : </a>
</div>
</div> </div>
<div class="row"> <div class="row">
<?php if (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?> <?php if (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
@ -224,6 +227,10 @@ body{
<script> <script>
$(document).ready(function(){
$(".StatusTileHide").hide();
})
function linkRedirectForBDS(input, team) function linkRedirectForBDS(input, team)
{ {
var link = ""; var link = "";
@ -244,6 +251,7 @@ function show_business_status_tile(){
$('.businessStatusTile').show() $('.businessStatusTile').show()
$('.StatusTileHide').show() $('.StatusTileHide').show()
$("#mainMenuTiles").text("Viewing Details of Business Team Pending");
$('.businessPendingTile').hide() $('.businessPendingTile').hide()
$('.financePendingTile').hide() $('.financePendingTile').hide()
@ -257,6 +265,8 @@ function show_finance_status_tile(){
$('.financePendingTile').hide() $('.financePendingTile').hide()
$('.businessPendingTile').hide() $('.businessPendingTile').hide()
$("#mainMenuTiles").text("Viewing Details of Finance Team Pending");
} }

View File

@ -124,8 +124,10 @@
margin-bottom: 5px; margin-bottom: 5px;
} }
</style> </style>
<?php
<div class="tab-pane fade" id="claims-dash-tab"> $isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team()) ? 'active show' : '';
?>
<div class="tab-pane fade <?= $isActive ?>" id="claims-dash-tab">
<div class="row"> <div class="row">
<div class="col-md-4 col-xl-3 claimTypeTile"> <div class="col-md-4 col-xl-3 claimTypeTile">
<div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,1)"> <div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,1)">
@ -172,9 +174,13 @@
</div> </div>
</div> </div>
<div class="row">
<div class="goBack"> <div class="goBack" style="padding-bottom: 10px;padding-left: 17px;">
<a href="#" onclick="hideAndShowTile('2')">show all pending Tile<br></a> <a href="#" onclick="hideAndShowTile('2')" ><i class="fas fa-arrow-left"></i> Back to Overview<br></a>
</div>
<div class="goBack" style="display: none;padding-left: 30px;">
<a href="#" id="current_tile">Current Tile : </a>
</div>
</div> </div>
<div class="row"> <div class="row">
<?php <?php
@ -196,7 +202,7 @@
<?php foreach ($statuses as $status => $count) : ?> <?php foreach ($statuses as $status => $count) : ?>
<?php <?php
// Skip metadata fields // Skip metadata fields
if ($status === 'ticket_type_id' || $status === 'total') { if ($status === 'ticket_type_id'|| $status == "approved"|| $status == "settled"|| $status == "closed" || $status === 'total' || substr($status, -4) === "_ids") {
continue; continue;
} }
@ -208,7 +214,7 @@
$showTooltip = strlen($formattedStatus) > 20; $showTooltip = strlen($formattedStatus) > 20;
?> ?>
<div class="col-md-2 col-xl-1 claimStatusTitle_<?= $ticketTypeId ?>" style="display: none;"> <div class="col-md-2 col-xl-1 claimStatusTitle_<?= $ticketTypeId ?>" style="display: none;">
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForClaims(<?= $ticketTypeId ?>, '<?= $status ?>')"> <div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForClaims(<?= $ticketTypeId ?>, '<?= $status ?>','<?= $statuses[$status . '_ids'] ?? '' ?>')">
<h2 class="text-center"><span><?= $count ?></span></h2> <h2 class="text-center"><span><?= $count ?></span></h2>
<h6 class="m-b-20 font-15 text-center" <h6 class="m-b-20 font-15 text-center"
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>> <?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
@ -248,39 +254,58 @@
$('.claimTypeTile').hide(); $('.claimTypeTile').hide();
$('.claimStatusTitle_' + claimType).show(); $('.claimStatusTitle_' + claimType).show();
if (claimType == 1) {
$('#current_tile').text("Viewing Details For : GMC");
} else if (claimType == 2) {
$('#current_tile').text("Viewing Details For : GPA");
} else if (claimType == 3) {
$('#current_tile').text("Viewing Details For : EDLI");
} else if (claimType == 4) {
$('#current_tile').text("Viewing Details For : GTLI");
}
} }
} }
function linkRedirectForClaims(ticketTypeId, status) { function linkRedirectForClaims(ticketTypeId, status,ids) {
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
$.ajax({ // $.ajax({
url: "<?= base_url("/dashboard/prepareClaimSearchData") ?>", // url: "<?= base_url("/dashboard/prepareClaimSearchData") ?>",
type: "POST", // type: "POST",
data: { // data: {
ticketTypeId: ticketTypeId, // ticketTypeId: ticketTypeId,
status: status // status: status
}, // },
success: function(response) { // success: function(response) {
// Handle the response from the server // // Handle the response from the server
if (response.status === 'success') { // if (response.status === 'success') {
// Redirect to the claims list page with the selected filters // // Redirect to the claims list page with the selected filters
console.log("response", response); // console.log("response", response);
// alert(JSON.stringify(response)); // // alert(JSON.stringify(response));
data = response.data; // data = response.data;
data.is_dashboard = 1; // data.is_dashboard = 1;
// redirectWithPost("<?= base_url("ticket/list") ?>", data);
// } else {
// // Handle error case
// console.log('Error: ' + response.message);
// }
// },
// error: function(xhr, status, error) {
// // Handle AJAX error
// console.error('AJAX Error:', error);
// // alert('An error occurred while processing your request.');
// }
// })
data = {
is_dashboard: 1,
ids : ids
}
redirectWithPost("<?= base_url("ticket/list") ?>", data); redirectWithPost("<?= base_url("ticket/list") ?>", data);
} else {
// Handle error case
console.log('Error: ' + response.message);
}
},
error: function(xhr, status, error) {
// Handle AJAX error
console.error('AJAX Error:', error);
// alert('An error occurred while processing your request.');
}
})
} }
function redirectWithPost(url, data = {}) { function redirectWithPost(url, data = {}) {

View File

@ -179,7 +179,7 @@
<textarea class="form-control" name="pull_emp_obj" onchange="checkValidJson(this)" id="pull_emp_obj" rows="3" placeholder="Enter the object type"><?= isset($api_data) ? htmlspecialchars($api_data['pull_emp_obj']) : "" ?></textarea> <textarea class="form-control" name="pull_emp_obj" onchange="checkValidJson(this)" id="pull_emp_obj" rows="3" placeholder="Enter the object type"><?= isset($api_data) ? htmlspecialchars($api_data['pull_emp_obj']) : "" ?></textarea>
</div> </div>
</div><hr> <hr>
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">
<label>Webhook Action</label> <label>Webhook Action</label>
@ -222,6 +222,7 @@
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<button class="btn btn-primary waves-effect waves-light mr-1" type="submit" id="formSubmit">Submit</button> <button class="btn btn-primary waves-effect waves-light mr-1" type="submit" id="formSubmit">Submit</button>
</div> </div>
</div>
</form> </form>
</div> </div>
</div> </div>

View File

@ -88,12 +88,12 @@ body {
<span class="d-none d-sm-inline-block">Policies</span> <span class="d-none d-sm-inline-block">Policies</span>
</a> </a>
</li> </li>
<li class="nav-item"> <!-- <li class="nav-item">
<a href="#api-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="api_tab"> <a href="#api-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="api_tab">
<span class="mdi mdi-api"></span> <span class="mdi mdi-api"></span>
<span class="d-none d-sm-inline-block">API</span> <span class="d-none d-sm-inline-block">API</span>
</a> </a>
</li> </li> -->
<li class="nav-item"> <li class="nav-item">
<a href="#others-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="others_tab"> <a href="#others-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="others_tab">
<span class="mr-1"><i class="mdi mdi-tag-text-outline"></i></span> <span class="mr-1"><i class="mdi mdi-tag-text-outline"></i></span>

View File

@ -124,23 +124,26 @@ body{
margin-bottom: 5px; margin-bottom: 5px;
} }
</style> </style>
<div class="tab-pane fade" id="leads-dash-tab"> <?php
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team()) ? 'show active' : '';
?>
<div class="tab-pane fade <?= $isActive ?>" id="leads-dash-tab">
<div class="row"> <div class="row">
<div class="col-md-4 col-xl-3 leadTypeTile"> <div class="col-md-4 col-xl-3 leadTypeTile">
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1)"> <div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,1)">
<div class="card-block"> <div class="card-block">
<h6 class="m-b-20 font-15">Leads</h6> <h6 class="m-b-20 font-15">Leads</h6>
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span></span></h2> <h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($lead_data)? $lead_data['total'] : 0 ?></span></h2>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p> <p class="m-b-1">&nbsp;<span class="f-right"></span></p>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p> <p class="m-b-1">&nbsp;<span class="f-right"></span></p>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-4 col-xl-3 leadTypeTile"> <div class="col-md-4 col-xl-3 leadTypeTile">
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1)"> <div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,2)">
<div class="card-block"> <div class="card-block">
<h6 class="m-b-20 font-15">Renewals</h6> <h6 class="m-b-20 font-15">BDS Renewals</h6>
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span></span></h2> <h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($bds_renewal) ? $bds_renewal['total'] : 0?></span></h2>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p> <p class="m-b-1">&nbsp;<span class="f-right"></span></p>
<p class="m-b-1">&nbsp;<span class="f-right"></span></p> <p class="m-b-1">&nbsp;<span class="f-right"></span></p>
</div> </div>
@ -148,26 +151,162 @@ body{
</div> </div>
</div> </div>
<div class="row">
<div class="status_tile" style="padding-bottom: 10px;padding-left: 17px; ">
<a href="#" onclick="hide_and_show_tile(2)" ><i class="fas fa-arrow-left"></i> Back to Overview</a>
</div>
<div class="status_tile" style="padding-left: 30px;">
<a href="#" id="main_tile" >Current Tile : </a>
</div>
</div>
<div class="row">
<?php
<div class="status_tile" style="display: none; position: relative; bottom: 15px;"> $colorSetCount = count($colorShades); // Number of color sets
<a href="#" onclick="hide_and_show_tile(2)" >show all pending Tile</a> $shadeCount = count($colorShades[0]); // Number of shades per set
$index = 0;
foreach ($lead_data as $key => $value) : ?>
<?php
if ($key == "total"|| $key == "won" || substr($key, -4) === "_ids") { continue; } // Skip the total key
?>
<?php
// Initialize color set and shade indexes
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
// Get the background color for the current tile
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
?>
<?php
$formattedStatus = strlen($key) < 5 ? strtoupper($key): ucwords(str_replace('_', ' ', $key));
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
$showTooltip = strlen($formattedStatus) > 20;
?>
<div class="col-md-2 col-xl-1 leadStatusTitle_1" style="display: none;">
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForLeads('<?= esc(strtolower(str_replace(' ', '_', $key)), 'js') ?>','<?= $lead_data[$key . '_ids'] ?? '' ?>')">
<h2 class="text-center"><span><?= $value ?></span></h2>
<h6 class="m-b-20 font-15 text-center"
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
<?= $truncatedStatus ?>
</h6>
</div>
</div>
<?php endforeach ?>
</div> </div>
<div class="row"> <div class="row">
<?php
$colorSetCount = count($colorShades); // Number of color sets
$shadeCount = count($colorShades[0]); // Number of shades per set
$index = 0;
foreach ($bds_renewal as $key => $value) : ?>
<?php
if ($key == "total" || substr($key, -4) === "_ids"){ continue; } // Skip the total key
?>
<?php
// Initialize color set and shade indexes
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
// Get the background color for the current tile
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
?>
<?php
$formattedStatus = strlen($key) < 5 ? strtoupper($key): ucwords(str_replace('_', ' ', $key));
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
$showTooltip = strlen($formattedStatus) > 20;
?>
<div class="col-md-2 col-xl-1 leadStatusTitle_2" style="display: none;">
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForPolicy('<?= isset($bds_renewal[$key . '_ids']) ? str_replace(' ', '_', $bds_renewal[$key . '_ids']) : '' ?>')">
<h2 class="text-center"><span><?= $value ?></span></h2>
<h6 class="m-b-20 font-15 text-center"
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
<?= $truncatedStatus ?>
</h6>
</div>
</div>
<?php endforeach ?>
</div> </div>
</div> </div>
<script> <script>
function hide_and_show_tile(type) {
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
$(".status_tile").hide();
});
function hide_and_show_tile(type,leadType = null) {
if (type == 1) { if (type == 1) {
$('.leadTypeTile').hide(); $('.leadTypeTile').hide();
$('.status_tile').show(); $('.status_tile').show();
} else { } else {
$('.leadTypeTile').show(); $('.leadTypeTile').show();
$('.status_tile').hide(); $('.leadStatusTitle_1').hide();
$('.leadStatusTitle_2').hide();
$(".status_tile").hide();
}
if (type == 1 && leadType != null && leadType == 1){
$('.leadStatusTitle_1').show();
$('#main_tile').text("Viewing Details For : Leads");
}
if (type == 1 && leadType != null && leadType == 2){
$('.leadStatusTitle_2').show();
$("#main_tile").text("Viewing Details For : BDS Renewals");
}
}
function linkRedirectForPolicy(ids){
var url = "<?= base_url("policy_tranction/report/list") ?>";
var data = {
ids : ids,
is_dashboard : 1
}
redirectWithPost(url,data);
}
function linkRedirectForLeads(status,ids){
var url = "<?= base_url("leads/list") ?>";
var data = {
ids : ids,
is_dashboard : 1
}
redirectWithPost(url,data);
}
function redirectWithPost(url, data = {}) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
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> </script>

View File

@ -344,6 +344,7 @@
$('#primaryKey').val(''); $('#primaryKey').val('');
$('#policy_type').val('').change(); $('#policy_type').val('').change();
$('#trigger_type').val('').change(); $('#trigger_type').val('').change();
$("#claim_status_for_template").val("").change;
editor.setEditorValue(''); editor.setEditorValue('');
$('#primaryKey').val(null); $('#primaryKey').val(null);
$('#statusSwitch').prop('checked', false); $('#statusSwitch').prop('checked', false);

View File

@ -291,9 +291,21 @@ var record_date = flatpickr("#record_date",{
text: 'PDF', text: 'PDF',
title: 'TransactionDetails', title: 'TransactionDetails',
exportOptions: { exportOptions: {
columns: '' columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
format: {
body: function(data, row, column, node) {
return data.replace(/<.*?>/g, '');
} }
} }
},
customize: function(doc) {
doc.pageOrientation = 'landscape';
doc.styles.tableHeader.alignment = 'left';
doc.defaultStyle.alignment = 'left';
doc.content[1].table.widths = ['9%', '9%', '8%', '9%', '10%', '9%', '9%', '9%', '9%', '11%', '8%'];
}
}
], ],
language: { language: {
search: "_INPUT_", search: "_INPUT_",
@ -303,13 +315,10 @@ var record_date = flatpickr("#record_date",{
paging: true, paging: true,
}); });
}); });
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {