MERGE_CODE_MERGE : RV
This commit is contained in:
commit
ccad927b6c
@ -12,6 +12,7 @@ use CodeIgniter\Filters\SecureHeaders;
|
||||
use App\Filters\AuthMVC;
|
||||
use App\Filters\HttpRequestLog;
|
||||
use App\Filters\CloseDbConnection;
|
||||
use App\Filters\AuthClientApi;
|
||||
|
||||
use App\Filters\AuthJWT;
|
||||
|
||||
@ -34,6 +35,7 @@ class Filters extends BaseConfig
|
||||
'authMVC' => AuthMVC::class,
|
||||
'HttpRequestLog' => HttpRequestLog::class,
|
||||
'authJWT' => AuthJWT::class,
|
||||
'AuthClientApi' => AuthClientApi::class,
|
||||
'CloseDbConnection' => CloseDbConnection::class
|
||||
];
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ $routes->get("sendextraparam", "ClientController::sendextraparam");
|
||||
$routes->get("updateRenewalData", "ClientController::updateRenewalData");
|
||||
$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient");
|
||||
$routes->get("updateRenewalInsurerData", "ClientController::updateRenewalInsurerData");
|
||||
$routes->get("sendMutipleToEmails", "MasterController::sendMutipleToEmails");
|
||||
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
|
||||
// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
|
||||
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||
@ -72,6 +73,7 @@ $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('get-notification', 'DashboardController::getDashboardNotifications');
|
||||
$routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1');
|
||||
$routes->get('get-pending-action', 'PendingActionsController::getPendingActions');
|
||||
$routes->post("prepareClaimSearchData","DashboardController::prepareClaimSearchData");
|
||||
});
|
||||
|
||||
$routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -87,6 +89,8 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('view_deposit/(:num)', 'ClientController::view_Deposit/$1');
|
||||
$routes->get('createtransaction', 'ClientController::createtransaction');
|
||||
$routes->post('save_deposit', 'ClientController::saveDeposit');
|
||||
$routes->post("saveApiData", "ClientController::saveApiData");
|
||||
$routes->get("generateToken","ClientController::sendToken");
|
||||
// $routes->get('view_Deposit/(:num)/(:num)','ClientController/view_Deposit/$1/$2');
|
||||
|
||||
$routes->group("notification", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -319,8 +323,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("test_mail", "MasterController::testGmailAPI");
|
||||
$routes->post("test_mail", "MasterController::testGmailAPI");
|
||||
$routes->get("check_policy_no/(:any)", "ClientController::check_policy_no/$1");
|
||||
$routes->get("get_client_policy_data_using_policy_no/(:any)", "ClientController::get_client_policy_data_using_policy_no/$1");
|
||||
$routes->get("get_client_policy_data_using_policy_no_and_endo_no/(:any)", "ClientController::get_client_policy_data_using_policy_no_and_endo_no/$1");
|
||||
$routes->get("get_client_policy_data_using_policy_no", "ClientController::get_client_policy_data_using_policy_no");
|
||||
$routes->get("get_client_policy_data_using_policy_no_and_endo_no", "ClientController::get_client_policy_data_using_policy_no_and_endo_no");
|
||||
$routes->get("checkInvoiceStatus/(:any)", "PolicyTransactionController::checkInvoiceStatus/$1");
|
||||
$routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1");
|
||||
$routes->get("sentTestMail/(:any)", "NotificationController::sentTestMail/$1");
|
||||
@ -353,12 +357,16 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1');
|
||||
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
|
||||
$routes->get('removeMultiFile', 'LeadsController::removeMultiFile');
|
||||
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
|
||||
});
|
||||
|
||||
$routes->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) {
|
||||
$routes->get("list", "PolicyTransactionController::viewInception");
|
||||
$routes->match(['get', 'post'], 'list', 'PolicyTransactionController::viewInception');
|
||||
$routes->post("create", "PolicyTransactionController::createInceptionPolicy");
|
||||
$routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1");
|
||||
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
|
||||
@ -373,7 +381,7 @@ $routes->group("policy_tranction", ["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-business-list", "PolicyTransactionController::reportBusinessList");
|
||||
$routes->get("report-finance-list", "PolicyTransactionController::reportFinanceList");
|
||||
@ -532,13 +540,15 @@ $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('insurer_wise_data/(:any)','BDSReportController::Insurer_wise_Data/$1');
|
||||
$routes->get('bap_wise_data/(:any)','BDSReportController::Bap_Wise_Data/$1');
|
||||
$routes->match( ['get', 'post'], 'renewal_report','BDSReportController::renewalReport');
|
||||
|
||||
$routes->get('getTATReport','BDSReportController::bdsTATReport');
|
||||
$routes->get("getMultiReport/(:any)", "BDSReportController::getMultiReport/$1");
|
||||
});
|
||||
|
||||
//New Tickets
|
||||
$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');
|
||||
@ -550,6 +560,20 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports');
|
||||
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
|
||||
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
|
||||
$routes->post("getMoreInfo","TicketController::getMoreInfo");
|
||||
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
||||
});
|
||||
|
||||
$routes->group("clientApi",["filter" => "AuthClientApi"], function ($routes){
|
||||
|
||||
$routes->post("getPolicyMaster","ClientAPIController::sendPolicyMaster");
|
||||
$routes->post("getEmployeeMaster","ClientAPIController::sendEmpMaster");
|
||||
$routes->post("getClaimMaster","ClientAPIController::sendClaimMaster");
|
||||
// $routes->post("pushData","ClientWebHooksController::sendSample");
|
||||
});
|
||||
|
||||
$routes->post("dispatchWebhookData/(:any)/(:any)",'ClientWebHooksController::pushData/$1/$2');
|
||||
|
||||
|
||||
$routes->post("retrieveWebhookDataEmp","ClientWebHooksController::pullData_emp");
|
||||
$routes->post("retrieveWebhookDataClaim","ClientWebHooksController::pullData_claim");
|
||||
|
||||
@ -33,6 +33,7 @@ class BDSReportController extends AdminController
|
||||
protected $PTCOShareDetailsModel;
|
||||
protected $coShareStmtDetailsModel;
|
||||
protected $policyTypeModel;
|
||||
protected $policyTatReportType;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -46,6 +47,13 @@ class BDSReportController extends AdminController
|
||||
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
|
||||
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
|
||||
$this->policyTypeModel = new PolicyTypeModel();
|
||||
|
||||
|
||||
$this->policyTatReportType = [
|
||||
'1' => "TAT Band Wise report",
|
||||
'2' => "Account Manger Status Wise Report",
|
||||
'3' => "Account Manger TAT Wise Report"
|
||||
];
|
||||
}
|
||||
|
||||
// public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate)
|
||||
@ -209,7 +217,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
$html = view('bds_report_bap_wise_data', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
} else if($report_type == 'bapInsurer'){
|
||||
} else if ($report_type == 'bapInsurer') {
|
||||
|
||||
//Condition for BAP Insurer wise date
|
||||
$category = $category == 'life' ? 1 : 0;
|
||||
@ -217,8 +225,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
$html = view('irda_bap_insurer_report_list', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
|
||||
}else if($report_type == 'bapClient'){
|
||||
} else if ($report_type == 'bapClient') {
|
||||
|
||||
//Condition for BAP Client wise date
|
||||
$category = $category == 'life' ? 1 : 0;
|
||||
@ -226,8 +233,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
$html = view('irda_bap_client_report_list', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
|
||||
}else if($report_type == 'client'){
|
||||
} else if ($report_type == 'client') {
|
||||
|
||||
//Condition for Client wise date
|
||||
$category = $category == 'life' ? 1 : 0;
|
||||
@ -517,7 +523,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
if (!empty($start_date) && !empty($end_date)) {
|
||||
$fromDate = change_date_format($start_date);
|
||||
$toDate = change_date_format($end_date);
|
||||
$toDate = change_date_format($end_date);
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
|
||||
@ -597,7 +603,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
// $db = db_connect();
|
||||
// $builder = $db->query("
|
||||
|
||||
|
||||
// select ins.id, ins.name as insurer_name,
|
||||
|
||||
// -- Health Policies
|
||||
@ -706,7 +712,7 @@ class BDSReportController extends AdminController
|
||||
// life_premium DESC,
|
||||
// marine_cargo_premium DESC,
|
||||
// marine_hull_premium DESC;
|
||||
|
||||
|
||||
// ");
|
||||
|
||||
// // Get the query
|
||||
@ -745,7 +751,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
// $db = db_connect();
|
||||
// $builder = $db->query("
|
||||
|
||||
|
||||
// SELECT
|
||||
// c.id AS client_id,
|
||||
// c.client_name,
|
||||
@ -808,7 +814,7 @@ class BDSReportController extends AdminController
|
||||
// life_premium DESC,
|
||||
// marine_cargo_premium DESC,
|
||||
// marine_hull_premium DESC
|
||||
|
||||
|
||||
// ");
|
||||
|
||||
// // Get the query
|
||||
@ -847,11 +853,11 @@ class BDSReportController extends AdminController
|
||||
|
||||
// $db = db_connect();
|
||||
// $builder = $db->query("
|
||||
|
||||
|
||||
// select
|
||||
// c.id as client_id,
|
||||
// c.client_name,
|
||||
|
||||
|
||||
// (
|
||||
// select
|
||||
// count(policy_transaction.id)
|
||||
@ -862,7 +868,7 @@ class BDSReportController extends AdminController
|
||||
// and policy_transaction.is_active = 1
|
||||
|
||||
// ) as policy_count,
|
||||
|
||||
|
||||
// COALESCE((
|
||||
// select
|
||||
// sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium
|
||||
@ -873,9 +879,9 @@ class BDSReportController extends AdminController
|
||||
// and stmt.is_active = 1
|
||||
// and ptco.is_active = 1
|
||||
// and pt.is_active = 1
|
||||
|
||||
|
||||
// ), 0) as premium
|
||||
|
||||
|
||||
// from clients c
|
||||
// join policy_transaction on c.id = policy_transaction.client_id AND policy_transaction.policy_issue_date >= '$fromDate' AND policy_transaction.policy_issue_date <= '$toDate'
|
||||
// join policy_type on policy_transaction.policy_type_id = policy_type.id and policy_type.policy_category = $category
|
||||
@ -910,7 +916,6 @@ class BDSReportController extends AdminController
|
||||
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$data['page_name'] = "Renewal Report";
|
||||
return $this->loadLayout('renewal_search', $data);
|
||||
|
||||
} else {
|
||||
|
||||
$fromDate = $this->request->getPost('fromDate');
|
||||
@ -927,4 +932,224 @@ class BDSReportController extends AdminController
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function bdsTATReport()
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
tc.TAT_Category,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'under_process' THEN 1 ELSE 0 END), 0) AS `Under Process`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'client_pending' THEN 1 ELSE 0 END), 0) AS `Client Pending`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'insurer_pending' THEN 1 ELSE 0 END), 0) AS `Insurer Pending`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'instalment_pending' THEN 1 ELSE 0 END), 0) AS `Instalment Pending`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'co_insurer_pending' THEN 1 ELSE 0 END), 0) AS `Co-Insurer Pending`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'tpa_pending' THEN 1 ELSE 0 END), 0) AS `TPA Pending`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'validated' THEN 1 ELSE 0 END), 0) AS `Validated`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'cancelled' THEN 1 ELSE 0 END), 0) AS `Cancelled`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'completed' THEN 1 ELSE 0 END), 0) AS `Completed`,
|
||||
COALESCE(SUM(CASE WHEN subquery.status = 'lost' THEN 1 ELSE 0 END), 0) AS `Lost` FROM
|
||||
(
|
||||
SELECT 'Above 12 Days' AS TAT_Category
|
||||
UNION ALL
|
||||
SELECT '9-12 Days'
|
||||
UNION ALL
|
||||
SELECT '5-8 Days'
|
||||
UNION ALL
|
||||
SELECT '0-4 Days'
|
||||
) AS tc
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
pt.id AS policy_id,
|
||||
ls.status,
|
||||
CASE
|
||||
WHEN DATEDIFF(CURRENT_DATE, pt.created_at) BETWEEN 0 AND 4 THEN '0-4 Days'
|
||||
WHEN DATEDIFF(CURRENT_DATE, pt.created_at) BETWEEN 5 AND 8 THEN '5-8 Days'
|
||||
WHEN DATEDIFF(CURRENT_DATE, pt.created_at) BETWEEN 9 AND 12 THEN '9-12 Days'
|
||||
ELSE 'Above 12 Days'
|
||||
END AS TAT_Category
|
||||
FROM
|
||||
policy_transaction pt
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
pts1.*
|
||||
FROM
|
||||
policy_transaction_status pts1
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
policy_tran_id,
|
||||
MAX(created_at) AS max_created_at
|
||||
FROM
|
||||
policy_transaction_status
|
||||
WHERE is_active = 1
|
||||
GROUP BY policy_tran_id
|
||||
) pts2
|
||||
ON pts1.policy_tran_id = pts2.policy_tran_id
|
||||
AND pts1.created_at = pts2.max_created_at
|
||||
WHERE pts1.is_active = 1
|
||||
) ls
|
||||
ON pt.id = ls.policy_tran_id
|
||||
WHERE pt.is_active = 1
|
||||
) AS subquery
|
||||
ON tc.TAT_Category = subquery.TAT_Category
|
||||
GROUP BY
|
||||
tc.TAT_Category
|
||||
ORDER BY
|
||||
FIELD(tc.TAT_Category, '0-4 Days', '5-8 Days' , '9-12 Days' , 'Above 12 Days' )
|
||||
";
|
||||
|
||||
// Run the query
|
||||
$db = \Config\Database::connect();
|
||||
$query = $db->query($sql);
|
||||
|
||||
// Get the result
|
||||
$result = $query->getResultArray();
|
||||
// dd(db_connect()->getLastQuery(),$result);
|
||||
$data['data'] = $result;
|
||||
// dd($data, get_role_id(), ENROLLMENT_TEAM_ID, user_team());
|
||||
// return $this->loadLayout('bds_tat_wise_report', $data);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function accountMangerStatusBDSReport()
|
||||
{
|
||||
$data['page_name'] = "Account Manager BDS Report";
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
COALESCE(ACM_Name, 'Total') AS ACM_Name,
|
||||
COALESCE(SUM(CASE WHEN status = 'instalment_pending' THEN 1 ELSE 0 END), 0) AS `Instalment Pending`,
|
||||
COALESCE(SUM(CASE WHEN status = 'under_process' THEN 1 ELSE 0 END), 0) AS `Under Process`,
|
||||
COALESCE(SUM(CASE WHEN status = 'client_pending' THEN 1 ELSE 0 END), 0) AS `Client Pending`,
|
||||
COALESCE(SUM(CASE WHEN status = 'co_insurer_pending' THEN 1 ELSE 0 END), 0) AS `Co Insurer Pending`,
|
||||
COALESCE(SUM(CASE WHEN status = 'tpa_pending' THEN 1 ELSE 0 END), 0) AS `TPA Pending`,
|
||||
COALESCE(SUM(CASE WHEN status = 'validated' THEN 1 ELSE 0 END), 0) AS `Validated`,
|
||||
COALESCE(SUM(CASE WHEN status = 'cancelled' THEN 1 ELSE 0 END), 0) AS `Cancelled`,
|
||||
COALESCE(SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END), 0) AS `Completed`,
|
||||
COALESCE(SUM(CASE WHEN status = 'lost' THEN 1 ELSE 0 END), 0) AS `Lost`,
|
||||
COALESCE(SUM(CASE WHEN status = 'insurer_pending' THEN 1 ELSE 0 END), 0) AS `Insurer Pending`
|
||||
|
||||
FROM (
|
||||
SELECT
|
||||
up.first_name AS ACM_Name,
|
||||
ls.status
|
||||
FROM policy_transaction pt
|
||||
JOIN clients c ON pt.client_id = c.id AND c.is_active = 1
|
||||
JOIN client_rm crm ON crm.client_id = c.id AND crm.is_active = 1 AND crm.level = 3
|
||||
JOIN user_profiles up ON up.id = crm.user_id AND up.is_active = 1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
pts1.policy_tran_id,
|
||||
pts1.status,
|
||||
pts1.created_at
|
||||
FROM policy_transaction_status pts1
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
policy_tran_id,
|
||||
MAX(created_at) AS max_created_at
|
||||
FROM policy_transaction_status
|
||||
WHERE is_active = 1
|
||||
GROUP BY policy_tran_id
|
||||
) pts2
|
||||
ON pts1.policy_tran_id = pts2.policy_tran_id
|
||||
AND pts1.created_at = pts2.max_created_at
|
||||
WHERE pts1.is_active = 1
|
||||
) ls ON pt.id = ls.policy_tran_id
|
||||
WHERE pt.is_active = 1
|
||||
AND DATEDIFF(CURDATE(), ls.created_at) >= 4
|
||||
) AS sub
|
||||
GROUP BY ACM_Name;
|
||||
";
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$query = $db->query($sql);
|
||||
|
||||
// Get the result
|
||||
$result = $query->getResultArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function accountManagerTatBDSReport(){
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
COALESCE(ACM_Name, 'Total') AS ACM_Name,
|
||||
COALESCE(SUM(CASE WHEN tat_bucket = '0-4 Days' THEN 1 ELSE 0 END), 0) AS `0-4 Days`,
|
||||
COALESCE(SUM(CASE WHEN tat_bucket = '5-8 Days' THEN 1 ELSE 0 END), 0) AS `5-8 Days`,
|
||||
COALESCE(SUM(CASE WHEN tat_bucket = '9-12 Days' THEN 1 ELSE 0 END), 0) AS `9-12 Days`,
|
||||
COALESCE(SUM(CASE WHEN tat_bucket = 'Above 12 Days' THEN 1 ELSE 0 END), 0) AS `Above 12 Days`
|
||||
FROM (
|
||||
SELECT
|
||||
up.first_name AS ACM_Name,
|
||||
CASE
|
||||
WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 0 AND 4 THEN '0-4 Days'
|
||||
WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 5 AND 8 THEN '5-8 Days'
|
||||
WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 9 AND 12 THEN '9-12 Days'
|
||||
WHEN DATEDIFF(CURDATE(), ls.created_at) > 12 THEN 'Above 12 Days'
|
||||
ELSE 'Unknown'
|
||||
END AS tat_bucket
|
||||
FROM policy_transaction pt
|
||||
JOIN clients c ON pt.client_id = c.id AND c.is_active = 1
|
||||
JOIN client_rm crm ON crm.client_id = c.id AND crm.is_active = 1 AND crm.level = 3
|
||||
JOIN user_profiles up ON up.id = crm.user_id AND up.is_active = 1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
pts1.policy_tran_id,
|
||||
pts1.status,
|
||||
pts1.created_at
|
||||
FROM policy_transaction_status pts1
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
policy_tran_id,
|
||||
MAX(created_at) AS max_created_at
|
||||
FROM policy_transaction_status
|
||||
WHERE is_active = 1
|
||||
GROUP BY policy_tran_id
|
||||
) pts2
|
||||
ON pts1.policy_tran_id = pts2.policy_tran_id
|
||||
AND pts1.created_at = pts2.max_created_at
|
||||
WHERE pts1.is_active = 1
|
||||
) ls ON pt.id = ls.policy_tran_id
|
||||
WHERE pt.is_active = 1
|
||||
AND ls.created_at IS NOT NULL
|
||||
) AS sub
|
||||
GROUP BY ACM_Name;
|
||||
|
||||
";
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$query = $db->query($sql);
|
||||
|
||||
// Get the result
|
||||
$result = $query->getResultArray();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function getMultiReport($report_type){
|
||||
|
||||
$data['page_name'] = "BDS Report";
|
||||
|
||||
if ($report_type == 1){
|
||||
|
||||
$data['page_title'] = "BDS TAT Report";
|
||||
$data['data'] = $this->bdsTATReport();
|
||||
}else if ($report_type == 2){
|
||||
|
||||
$data['page_title'] = "Account Manager Status Report";
|
||||
$data['data'] = $this->accountMangerStatusBDSReport();
|
||||
|
||||
}else{
|
||||
|
||||
$data['page_title'] = "Account Manager TAT Report";
|
||||
$data['data'] = $this->accountManagerTatBDSReport();
|
||||
|
||||
}
|
||||
|
||||
return $this->loadLayout('bds_multi_report', $data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
310
app/Controllers/ClientAPIController.php
Normal file
310
app/Controllers/ClientAPIController.php
Normal file
@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
use App\Helpers\ClientTokenHelper;
|
||||
use App\Helpers\ClientQueryHelper;
|
||||
|
||||
use App\Models\ClientApiModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
|
||||
use App\Controllers\TicketController;
|
||||
|
||||
class ClientAPIController extends BaseController
|
||||
{
|
||||
|
||||
use ResponseTrait;
|
||||
|
||||
protected $clientAPI;
|
||||
protected $clientPolicy;
|
||||
protected $myLogger;
|
||||
protected $clientQueryHelper;
|
||||
protected $clientTokenHelper;
|
||||
protected $ticketController;
|
||||
|
||||
protected $operators;
|
||||
protected $propertyNames;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
set_session_context('Client API Controller');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
//models
|
||||
$this->clientAPI = new ClientApiModel();
|
||||
$this->clientPolicy = new ClientPolicyModel();
|
||||
|
||||
//helper
|
||||
$this->clientQueryHelper = new ClientQueryHelper();
|
||||
|
||||
//controller
|
||||
$this->ticketController = new TicketController();
|
||||
|
||||
//variables
|
||||
$this->operators = [
|
||||
|
||||
"GT" => ">",
|
||||
"LT" => "<",
|
||||
"GTE" => ">=",
|
||||
"LTE" => "<=",
|
||||
"ET" => "=",
|
||||
"NE" => "!=",
|
||||
"LIKE" => "LIKE",
|
||||
"NL" => "NOT LIKE",
|
||||
"BTW" => "BETWEEN",
|
||||
"NB" => "NOT BETWEEN",
|
||||
"IS" => "IS NULL",
|
||||
"ISN" => "IS NOT NULL",
|
||||
|
||||
];
|
||||
$this->propertyNames = [
|
||||
'empMaster' => ['name','emp_code','relationship','client_branch_id','emp_status','mobile','email_corporate','change_event','dob','doj','band','gender'],
|
||||
'claimMaster' => ['emp_name','insured_name',"emp_code",'policy_no','emp_mobile','emp_mail','hospital_name','claim_type','claim_status','claim_no','claim_amount','claim_date','si_amt','raised_date','registration_date','denial_date','denial_reason','approved_amount','utr_details','return_remark','cancel_remark','non_id_reason','head_rejection_reason'],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function validateToken()
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$authHeader = $this->request->getHeaderLine('Authorization');
|
||||
|
||||
// Check if header exists
|
||||
if (empty($authHeader)) {
|
||||
$this->myLogger->log('error', 'Authorization header missing');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Authorization header missing', 'code' => 401]], 401);
|
||||
}
|
||||
|
||||
// Check if Bearer is present
|
||||
if (!str_contains($authHeader, 'Bearer ')) {
|
||||
$this->myLogger->log('error', 'Authorization Bearer missing');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Invalid Authorization header', 'code' => 401]], 401);
|
||||
}
|
||||
|
||||
// Extract the token
|
||||
$token = str_replace('Bearer ', '', $authHeader);
|
||||
if (empty($token)) {
|
||||
|
||||
$this->myLogger->log('error', 'Empty Token');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Invalid Token Format', 'code' => 401]], 401);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Extract client_id from the token
|
||||
$client_id = ClientTokenHelper::extractClientId($token);
|
||||
} catch (\Exception $e) {
|
||||
$this->myLogger->log('error', 'Invalid Client Token Format');
|
||||
|
||||
return $this->respond(['status' => "Failure", 'error' => 'Invalid Token Format'], 401);
|
||||
}
|
||||
|
||||
// Fetch client details from the database
|
||||
$client = $this->clientAPI->where('client_id', $client_id)->where("is_active", 1)->where("api_access", 1)->first();
|
||||
|
||||
// Client validation
|
||||
if (!$client) {
|
||||
$this->myLogger->log('error', 'Client Not Found or Unauthorized');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Client not found or unauthorized', 'code' => '403']], 403);
|
||||
}
|
||||
|
||||
// Validate the token
|
||||
if (hash_equals($client['client_token'], $token)) {
|
||||
$this->myLogger->log('error', 'Access Granted For Client : ' . $client_id);
|
||||
return true;
|
||||
} else {
|
||||
$this->myLogger->log('error', 'Invalid Token given for client : ' . $client_id);
|
||||
return $this->respond([
|
||||
'status' => "Failure",
|
||||
'error' => ['message' => 'Invalid token', 'code' => 401]
|
||||
], 401);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', 'Error in ClientAPIController:validateToken - ' . $e->getMessage());
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Internal Server Error', 'code' => 500]], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getClientIdfromToken()
|
||||
{
|
||||
$authHeader = $this->request->getHeaderLine('Authorization');
|
||||
$token = str_replace('Bearer ', '', $authHeader);
|
||||
$client_id = ClientTokenHelper::extractClientId($token);
|
||||
|
||||
$this->myLogger->log('error', 'Client ID: ' . $client_id);
|
||||
return [$client_id, $token];
|
||||
}
|
||||
|
||||
public function sendPolicyMaster()
|
||||
{
|
||||
|
||||
$data = $this->getClientIdfromToken();
|
||||
$client_id = $data[0];
|
||||
$keyString = $data[1];
|
||||
|
||||
// Extract only the actual key (after colon)
|
||||
// list($prefix, $hexKey) = explode(':', $keyString, 2);
|
||||
|
||||
// // Convert hex to binary (32 bytes)
|
||||
// $key = hex2bin($hexKey);
|
||||
|
||||
|
||||
$clientPolicy = $this->clientQueryHelper->clientPolicyMaster($client_id);
|
||||
|
||||
$this->myLogger->log('error', 'Client Policy Master: ' . json_encode($clientPolicy));
|
||||
|
||||
|
||||
// $encode_data = ClientTokenHelper::encryptData($clientPolicy, $key);
|
||||
// return $this->respond(['status' => "Success", 'data' => $encode_data], 200);
|
||||
|
||||
return $this->respond(['status' => "Success", 'data' => $clientPolicy], 200);
|
||||
}
|
||||
|
||||
|
||||
public function sendEmpMaster()
|
||||
{
|
||||
$data = $this->getClientIdfromToken();
|
||||
$client_id = $data[0];
|
||||
$keyString = $data[1];
|
||||
|
||||
$received_data = $this->request->getJSON();
|
||||
$filters = $received_data->filters ?? null;
|
||||
$limit = $received_data->limit ?? null;
|
||||
$after = $received_data->after ?? 0;
|
||||
|
||||
if ($limit > getenv('MAX_LIMIT')) {
|
||||
|
||||
$this->myLogger->log('error', "Limit exceeds maximum allowed limit");
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Limit exceeds maximum allowed limit', 'code' => 400]], 400);
|
||||
}
|
||||
|
||||
try{
|
||||
if (!empty($filters)) {
|
||||
$whereConditions = $this->prepareWhereConditions($filters,"",'empMaster');
|
||||
$employees = $this->clientQueryHelper->sendEmpMaster($client_id, $whereConditions,!empty($limit) ? $limit : 10,$after);
|
||||
}else{
|
||||
$employees = $this->clientQueryHelper->sendEmpMaster($client_id, [],!empty($limit) ? $limit : 10,$after);
|
||||
}
|
||||
}catch (\InvalidArgumentException $e) {
|
||||
return $this->respond(['status' => "Failure",'error' => ['message' => $e->getMessage(), 'code' => 400]], 400);
|
||||
}
|
||||
|
||||
foreach ($employees as &$employee){
|
||||
|
||||
$employee['policy_details'] = $this->clientQueryHelper->sendEmpPolicies($employee['ref_no']);
|
||||
}
|
||||
|
||||
$next_after = (count($employees) < $limit) ? null : ($after + $limit);
|
||||
|
||||
if (!empty($employees)){
|
||||
return $this->respond(['Status' => "Success","data" => $employees,'next_after'=>$next_after], 200);
|
||||
}else{
|
||||
return $this->respond(['Status' => "Failure","error" => ['message' => 'No Employees Found', 'code' => 404]], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendClaimMaster()
|
||||
{
|
||||
$policy_type = $this->ticketController->ticketType;
|
||||
|
||||
$data = $this->getClientIdfromToken();
|
||||
$client_id = $data[0];
|
||||
$keyString = $data[1];
|
||||
|
||||
$received_data = $this->request->getJSON();
|
||||
$filters = $received_data->filters ?? null;
|
||||
$limit = $received_data->limit ?? null;
|
||||
$after = $received_data->after ?? 0;
|
||||
|
||||
if ($limit > getenv('MAX_LIMIT')) {
|
||||
$this->myLogger->log('error', "Limit exceeds maximum allowed limit");
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Limit exceeds maximum allowed limit', 'code' => 400]], 400);
|
||||
}
|
||||
|
||||
try{
|
||||
if (!empty($filters)) {
|
||||
$whereConditions = $this->prepareWhereConditions($filters,"ticket_master",'claimMaster');
|
||||
$claimDetails = $this->clientQueryHelper->sendClaimMaster($client_id,$whereConditions,!empty($limit) ? $limit : 10);
|
||||
}else{
|
||||
$claimDetails = $this->clientQueryHelper->sendClaimMaster($client_id, [],!empty($limit) ? $limit : 10);
|
||||
}
|
||||
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return $this->respond(['status' => "Failure",'error' => ['message' => $e->getMessage(), 'code' => 400]], 400);
|
||||
}
|
||||
|
||||
foreach ($claimDetails as &$claim){
|
||||
|
||||
$claim['policy_type'] = $policy_type[$claim['policy_type']];
|
||||
}
|
||||
// dd($claimDetails);
|
||||
|
||||
$next_after = (count($claimDetails) < $limit) ? null : ($after + $limit);
|
||||
|
||||
|
||||
if (!empty($claimDetails)){
|
||||
return $this->respond(['Status' => "Success","data" => $claimDetails,'next_after'=>$next_after], 200);
|
||||
}else{
|
||||
return $this->respond(['Status' => "Failure","error" => ['message' => 'No Claims Found', 'code' => 404]], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function prepareWhereConditions($filters,$tableName = null,$model)
|
||||
{
|
||||
$whereConditions = [];
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
|
||||
$propertyName = $filter->propertyName;
|
||||
$operator = $filter->operator;
|
||||
$this->myLogger->log('error', 'Property Name: ' . $propertyName);
|
||||
if (!in_array($operator, array_keys($this->operators))) {
|
||||
$this->myLogger->log('error', 'Invalid operator: ' . $operator);
|
||||
throw new \InvalidArgumentException('Invalid operator');
|
||||
}
|
||||
if (!in_array($propertyName, $this->propertyNames[$model])) {
|
||||
$this->myLogger->log('error', 'Invalid property name: ' . $propertyName);
|
||||
throw new \InvalidArgumentException('Invalid property name '.$propertyName);
|
||||
}
|
||||
$value = isset($filter->value) ? $filter->value : null;
|
||||
$sqlOperator = $this->operators[$operator];
|
||||
|
||||
$column = !empty($tableName) ? "{$tableName}.{$propertyName}" : $propertyName;
|
||||
|
||||
if ($sqlOperator === '=') {
|
||||
$whereConditions[$column] = $value;
|
||||
} else if($sqlOperator == "LIKE" || $sqlOperator == "NOT LIKE") {
|
||||
$whereConditions["{$column} {$sqlOperator}"] = "%{$value}%";
|
||||
|
||||
} else if ($sqlOperator == 'BETWEEN') {
|
||||
if (is_array($value) && count($value) === 2) {
|
||||
// $whereConditions[] = [$column, $sqlOperator, $value[0]];
|
||||
$whereConditions["{$column} >="] = $value[0];
|
||||
$whereConditions["{$column} <="] = $value[1];
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Invalid value for BETWEEN operator', 'code' => 400]], 400);
|
||||
}
|
||||
}else if ($sqlOperator == 'NOT BETWEEN') {
|
||||
if (is_array($value) && count($value) === 2) {
|
||||
$whereConditions["{$column} <="] = $value[0];
|
||||
$whereConditions["{$column} >="] = $value[1];
|
||||
} else {
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Invalid value for NOT BETWEEN operator', 'code' => 400]], 400);
|
||||
}
|
||||
}else {
|
||||
$whereConditions["{$column} {$sqlOperator}"] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $whereConditions;
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Helpers\DepositHelper;
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Helpers\ClientTokenHelper;
|
||||
use App\helpers\JWTToken;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -39,9 +40,11 @@ use App\Models\PolicyTransactionModel;
|
||||
use App\Models\PolicyTransactionStatusModel;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\LeadsModel;
|
||||
use App\Models\ClientApiModel;
|
||||
|
||||
use App\Controllers\EmpDataServiceController;
|
||||
use App\Controllers\GoogleDriveController;
|
||||
use App\Controllers\PolicyTransactionController;
|
||||
|
||||
use App\Helpers\sendMailNotification;
|
||||
use App\Models\PTCOShareDetailsModel;
|
||||
@ -83,7 +86,7 @@ class ClientController extends AdminController
|
||||
protected $policyTransactionStatusModel;
|
||||
protected $vehicleModel;
|
||||
protected $leadsModel;
|
||||
|
||||
protected $clientApi;
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -119,6 +122,7 @@ class ClientController extends AdminController
|
||||
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
|
||||
$this->vehicleModel = new VehicleModel();
|
||||
$this->leadsModel = new LeadsModel();
|
||||
$this->clientApi = new ClientApiModel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
@ -751,7 +755,7 @@ class ClientController extends AdminController
|
||||
$editData['client_policy']['role'] = get_role_id();
|
||||
$editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll();
|
||||
$editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
|
||||
|
||||
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active",1)->first();
|
||||
// dd($editData);
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_onboarding', $editData);
|
||||
@ -3996,8 +4000,9 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function get_client_policy_data_using_policy_no($policy_no)
|
||||
{
|
||||
public function get_client_policy_data_using_policy_no()
|
||||
{
|
||||
$policy_no = $this->request->getGet('policy_no');
|
||||
$data = $this->clientPolicyModel
|
||||
->select("
|
||||
client_policy.*,
|
||||
@ -4017,8 +4022,11 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function get_client_policy_data_using_policy_no_and_endo_no($policy_no, $endorsement_no)
|
||||
{
|
||||
public function get_client_policy_data_using_policy_no_and_endo_no()
|
||||
{
|
||||
$policy_no = $this->request->getGet('policy_no');
|
||||
$endorsement_no = $this->request->getGet('endorsement_no');
|
||||
|
||||
$data = $this->clientPolicyModel
|
||||
->select('client_policy.*, endorsement.endorsement_type')
|
||||
->join('endorsement', 'client_policy.id = endorsement.client_policy_id')
|
||||
@ -4596,6 +4604,16 @@ class ClientController extends AdminController
|
||||
// $employeeRestController->employeesOnboardProcess(['file_id' => 835]);
|
||||
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]);
|
||||
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']);
|
||||
// $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);
|
||||
|
||||
|
||||
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
||||
@ -4619,8 +4637,10 @@ class ClientController extends AdminController
|
||||
// $ids = array_column($emp_data, 'id');
|
||||
// $EmpDataServiceController->sendMailForDownloadingECard($ids);
|
||||
|
||||
// $EmpDataServiceController = new EmpDataServiceController();
|
||||
$EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 1205]); //for live
|
||||
|
||||
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
// print_rr($result); die;
|
||||
@ -4665,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();
|
||||
@ -4679,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();
|
||||
@ -5692,6 +5714,40 @@ class ClientController extends AdminController
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function saveApiData(){
|
||||
|
||||
$receivedData = $this->request->getPost();
|
||||
|
||||
if (!empty($receivedData['id'])){
|
||||
$status = $this->clientApi->save($receivedData);
|
||||
|
||||
}else{
|
||||
$status = $this->clientApi->insert($receivedData);
|
||||
}
|
||||
|
||||
|
||||
if ($status){
|
||||
return $this->respond(['status'=>"Sucesss",'message'=>"Submitted Successfully"],200);
|
||||
}else{
|
||||
return $this->respond(['status'=>"Failed",'message'=>"Submission Faild"],500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function sendToken(){
|
||||
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
|
||||
$token = ClientTokenHelper::generateKey($client_id);
|
||||
|
||||
if ($token){
|
||||
return $this->respond(['status' => 'success', 'token' => $token,'message' => "Token Generated Successfully"],200);
|
||||
}else{
|
||||
return $this->respond(['status' => "Failed","message"=>"Token Generation Failed, Try Again After some time"],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
319
app/Controllers/ClientWebHooksController.php
Normal file
319
app/Controllers/ClientWebHooksController.php
Normal file
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
use App\Models\ClientApiModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
|
||||
use App\Helpers\clientWebHookHelper;
|
||||
use App\Helpers\ClientTokenHelper;
|
||||
use Exception;
|
||||
|
||||
class ClientWebHooksController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
protected $myLogger;
|
||||
protected $clientAPI;
|
||||
protected $clientPolicy;
|
||||
|
||||
protected $webHookHelper;
|
||||
protected $clientTokenHelper;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
set_session_context('Client Webhook Controller');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
//models
|
||||
$this->clientAPI = new ClientApiModel();
|
||||
$this->clientPolicy = new ClientPolicyModel();
|
||||
|
||||
// Helpers
|
||||
$this->webHookHelper = new clientWebHookHelper();
|
||||
$this->clientTokenHelper = new ClientTokenHelper();
|
||||
}
|
||||
|
||||
public function pushData($clientID, $type)
|
||||
{
|
||||
if ($type == 1) {
|
||||
|
||||
$webHookType = "emp";
|
||||
} else if ($type == 2) {
|
||||
|
||||
$webHookType = "claim";
|
||||
}
|
||||
log_message('error', 'Client ID: ' . $clientID);
|
||||
log_message('error', 'Webhook Type: ' . $webHookType);
|
||||
// Validate client ID
|
||||
if (empty($clientID)) {
|
||||
return $this->respond(["status" => "Failure", "error" => ["message" => 'Client ID is required.', "code" => 400]], 400);
|
||||
}
|
||||
$webhookData = $this->clientAPI->where('client_id', $clientID)->where('is_active', 1)->first();
|
||||
if (empty($webhookData)) {
|
||||
log_message('error', 'Client Not Found or Unauthorized');
|
||||
return $this->respond(["status" => "Failure", "error" => ["message" => 'Client Not Found or Client Does not have any Active Hooks.', "code" => 404]], 404);
|
||||
}
|
||||
$url = $webhookData[$webHookType . '_url'];
|
||||
if (empty($url)) {
|
||||
log_message('error', 'No active webhook found for the client.');
|
||||
return $this->respond(["status" => "Failure", "error" => ["message" => 'No active webhook found for the client.', "code" => 404]], 404);
|
||||
}
|
||||
|
||||
|
||||
$method = $webhookData[$webHookType . '_method'];
|
||||
$auth_method = $webhookData[$webHookType . '_tkn_type'];
|
||||
$token = $webhookData[$webHookType . '_token'];
|
||||
$objectType = json_decode($webhookData[$webHookType . '_obj']);
|
||||
|
||||
try {
|
||||
$client = \Config\Services::curlrequest();
|
||||
$data = [
|
||||
"name" => "Kavitha",
|
||||
"emp_code" => "EMP001-K4",
|
||||
"emp_status" => "active",
|
||||
"mobile" => "2233448965"
|
||||
];
|
||||
|
||||
try {
|
||||
$mapped_data = $this->webHookHelper->mapObjectType($data, $objectType);
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "Object Mapping Failed: " . $e->getMessage();
|
||||
log_message('error', $errorMessage);
|
||||
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Object Mapping Failed"]], 500);
|
||||
}
|
||||
|
||||
// Create payload
|
||||
$payload = [
|
||||
'event_type' => 'insert',
|
||||
'timestamp' => date('c'),
|
||||
'data' => $mapped_data
|
||||
];
|
||||
|
||||
log_message("error", "Payload: " . json_encode($payload));
|
||||
|
||||
// Configure request headers
|
||||
$headers = ['Content-Type' => 'application/json'];
|
||||
if ($auth_method && $token) {
|
||||
if (strtolower($auth_method) === 'bearer') {
|
||||
$headers['Authorization'] = 'Bearer ' . $token;
|
||||
} else {
|
||||
$headers[$auth_method] = $token;
|
||||
}
|
||||
}
|
||||
|
||||
// Configure request based on method
|
||||
$options = [
|
||||
'headers' => $headers,
|
||||
'timeout' => 10,
|
||||
'http_errors' => false // Don't throw exceptions for 4xx/5xx responses
|
||||
];
|
||||
|
||||
if ($method === 'GET') {
|
||||
$options['query'] = $payload;
|
||||
} else {
|
||||
$options['json'] = $payload;
|
||||
}
|
||||
|
||||
// Execute webhook request
|
||||
$response = $client->request($method, $url, $options);
|
||||
$statusCode = $response->getStatusCode();
|
||||
$responseBody = $response->getBody();
|
||||
|
||||
// Log and format response
|
||||
$logMessage = "Webhook to {$url} returned status: {$statusCode}";
|
||||
log_message('error', $logMessage);
|
||||
|
||||
return $this->respond(['status' => 'Success', "response" => $responseBody], $statusCode);
|
||||
} catch (\Throwable $e) {
|
||||
$errorMessage = "Webhook failed: " . $e->getMessage();
|
||||
log_message('error', $errorMessage);
|
||||
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => $errorMessage, 'exception' => get_class($e)]], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateToken($type)
|
||||
{
|
||||
$type = $type == 1 ? "pull_emp_token" : "pull_claim_token";
|
||||
try {
|
||||
|
||||
$authHeader = $this->request->getHeaderLine('Authorization');
|
||||
|
||||
// Check if header exists
|
||||
if (empty($authHeader)) {
|
||||
log_message('error', 'Authorization header missing');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Authorization header missing', 'code' => 401]], 401);
|
||||
}
|
||||
|
||||
// Check if Bearer is present
|
||||
if (!str_contains($authHeader, 'Bearer ')) {
|
||||
log_message('error', 'Authorization Bearer missing');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Invalid Authorization header', 'code' => 401]], 401);
|
||||
}
|
||||
|
||||
// Extract the token
|
||||
$token = str_replace('Bearer ', '', $authHeader);
|
||||
if (empty($token)) {
|
||||
|
||||
log_message('error', 'Empty Token');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Invalid Token Format', 'code' => 401]], 401);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Extract client_id from the token
|
||||
$client_id = ClientTokenHelper::extractClientId($token);
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', 'Invalid Client Token Format');
|
||||
|
||||
return $this->respond(['status' => "Failure", 'error' => 'Invalid Token Format'], 401);
|
||||
}
|
||||
|
||||
// Fetch client details from the database
|
||||
$client = $this->clientAPI->where('client_id', $client_id)->where("is_active", 1)->where("api_access", 1)->first();
|
||||
|
||||
// Client validation
|
||||
if (!$client) {
|
||||
log_message('error', 'Client Not Found or Unauthorized');
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Client not found or unauthorized', 'code' => '403']], 403);
|
||||
}
|
||||
|
||||
// Validate the token
|
||||
if (hash_equals($client[$type], $token)) {
|
||||
log_message('error', 'Access Granted For Client : ' . $client_id);
|
||||
return true;
|
||||
} else {
|
||||
log_message('error', 'Invalid Token given for client : ' . $client_id);
|
||||
return $this->respond([
|
||||
'status' => "Failure",
|
||||
'error' => ['message' => 'Invalid token', 'code' => 401]
|
||||
], 401);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', 'Error in ClientAPIController:validateToken - ' . $e->getMessage());
|
||||
return $this->respond(['status' => "Failure", 'error' => ['message' => 'Internal Server Error', 'code' => 500]], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getClientIdfromToken()
|
||||
{
|
||||
$authHeader = $this->request->getHeaderLine('Authorization');
|
||||
$token = str_replace('Bearer ', '', $authHeader);
|
||||
$client_id = ClientTokenHelper::extractClientId($token);
|
||||
|
||||
log_message('error', 'Client ID: ' . $client_id);
|
||||
return [$client_id, $token];
|
||||
}
|
||||
|
||||
public function pullData_emp()
|
||||
{
|
||||
$validationStatus = $this->validateToken(1);
|
||||
|
||||
$data = $this->getClientIdfromToken();
|
||||
$client_id = $data[0];
|
||||
|
||||
log_message('error', "Pull data emp from Client ID: ". $client_id);
|
||||
$client = $this->clientAPI->where('client_id', $client_id)->where("is_active", 1)->where("api_access", 1)->first();
|
||||
if (empty($client)) {
|
||||
log_message('error', 'Client Not Found or Unauthorized');
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 404, 'message' => 'Client Not Found or Unauthorized']], 404);
|
||||
}
|
||||
|
||||
$objectType = $client['pull_emp_obj'];
|
||||
|
||||
if ($validationStatus) {
|
||||
$responseBody = $this->request->getBody();
|
||||
$data_to_map = json_decode($responseBody, true);
|
||||
$objectType = json_decode($objectType, true);
|
||||
if (!isset($data_to_map['data']) || !is_array($data_to_map['data'])) {
|
||||
|
||||
log_message('error', "Invalid Response from Endpoint 'data' Key Missing");
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Invalid Response from Endpoint 'data' Key Missing"]], 500);
|
||||
}
|
||||
|
||||
foreach ($data_to_map['data'] as $index => $item) {
|
||||
|
||||
try {
|
||||
$mapped_data = $this->webHookHelper->mapObjectType($item, $objectType);
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "Object Mapping Failed: " . $e->getMessage();
|
||||
log_message('error', $errorMessage);
|
||||
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Object Mapping Failed"]], 500);
|
||||
}
|
||||
|
||||
try {
|
||||
$mapped_data['client_id'] = $client_id;
|
||||
$this->webHookHelper->insertData($mapped_data, 1);
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "Data Insertion Failed: " . $e->getMessage();
|
||||
log_message('error', $errorMessage);
|
||||
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Data Insertion Failed"]], 500);
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', "Data Inserted Successfully for Client ID: " . $client_id);
|
||||
// Return success response
|
||||
return $this->respond(['status' => 'Success', 'message' => "Data Inserted Successfully"], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function pullData_claim()
|
||||
{
|
||||
$validationStatus = $this->validateToken(2);
|
||||
|
||||
$data = $this->getClientIdfromToken();
|
||||
$client_id = $data[0];
|
||||
log_message('error', "Pull data claim from Client ID: ". $client_id);
|
||||
$client = $this->clientAPI->where('client_id', $client_id)->where("is_active", 1)->where("api_access", 1)->first();
|
||||
if (empty($client)) {
|
||||
log_message('error', 'Client Not Found or Unauthorized');
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 404, 'message' => 'Client Not Found or Unauthorized']], 404);
|
||||
}
|
||||
|
||||
$objectType = $client['pull_claim_obj'];
|
||||
|
||||
if ($validationStatus) {
|
||||
$responseBody = $this->request->getBody();
|
||||
$data_to_map = json_decode($responseBody, true);
|
||||
$objectType = json_decode($objectType, true);
|
||||
if (!isset($data_to_map['data']) || !is_array($data_to_map['data'])) {
|
||||
|
||||
log_message('error', "Invalid Response from Endpoint 'data' Key Missing");
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Invalid Response from Endpoint 'data' Key Missing"]], 500);
|
||||
}
|
||||
foreach ($data_to_map['data'] as $index => $item) {
|
||||
try {
|
||||
$mapped_data = $this->webHookHelper->mapObjectType($item, $objectType);
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "Object Mapping Failed: " . $e->getMessage();
|
||||
log_message('error', $errorMessage);
|
||||
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Object Mapping Failed"]], 500);
|
||||
}
|
||||
|
||||
try {
|
||||
$mapped_data['client_id'] = $client_id;
|
||||
$this->webHookHelper->insertData($mapped_data, 2);
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "Data Insertion Failed: " . $e->getMessage();
|
||||
log_message('error', $errorMessage);
|
||||
|
||||
return $this->respond(['status' => 'Failure', 'error' => ['code' => 500, 'message' => "Data Insertion Failed"]], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log_message('error', "Data Inserted Successfully for Client ID: " . $client_id);
|
||||
// Return success response
|
||||
return $this->respond(['status' => 'Success', 'message' => "Data Inserted Successfully"], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,10 @@ use App\Models\NotificationModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Controllers\PendingActionsContrller;
|
||||
use App\Controllers\EmpDataServiceController;
|
||||
use App\Models\TicketMasterModel;
|
||||
use App\Models\LeadsModel;
|
||||
use App\Models\TicketClaimStatusModel;
|
||||
|
||||
|
||||
class DashboardController extends AdminController
|
||||
{
|
||||
@ -33,8 +37,12 @@ class DashboardController extends AdminController
|
||||
protected $notificationModel;
|
||||
protected $employeePolicyModel;
|
||||
protected $policyTransactionModel;
|
||||
protected $leadModel;
|
||||
protected $ticketModel;
|
||||
protected $ticketStatusModel;
|
||||
protected $policyStatus;
|
||||
protected $colorShades;
|
||||
protected $claimDashLimit;
|
||||
|
||||
protected $myLogger;
|
||||
|
||||
@ -48,9 +56,76 @@ class DashboardController extends AdminController
|
||||
$this->employeePolicyModel = new EmployeePolicyModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->policyTransactionModel = new PolicyTransactionModel();
|
||||
$this->ticketModel = new TicketMasterModel();
|
||||
$this->leadModel = new LeadsModel();
|
||||
$this->ticketStatusModel = new TicketClaimStatusModel();
|
||||
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
$this->claimDashLimit = [
|
||||
1 => [
|
||||
'non_id' => 3,
|
||||
'id_not_generated' => 3,
|
||||
'cda' => 3,
|
||||
'information_required' => 3,
|
||||
'under_process' => 3,
|
||||
'rejected' => 3,
|
||||
'approved' => 3,
|
||||
'payment_initiated' => 3,
|
||||
'settled' => 3,
|
||||
'closed' => 3,
|
||||
'cancelled' => 3,
|
||||
'returned' => 3
|
||||
],
|
||||
|
||||
2 => [
|
||||
'claim_intimation' => 3,
|
||||
'intimation_to_insurer' => 3,
|
||||
'client_pending' => 3,
|
||||
'insurer_pending' => 3,
|
||||
'investigation' => 3,
|
||||
'approved' => 3,
|
||||
'closed' => 3,
|
||||
'not_covered' => 3,
|
||||
'settled' => 3,
|
||||
'coverage_check' => 3,
|
||||
'cancelled' => 3,
|
||||
'returned' => 3,
|
||||
'rejected' => 3,
|
||||
'dv_sent_to_insured' => 3
|
||||
],
|
||||
3 => [
|
||||
'claim_intimation' => 3,
|
||||
'intimation_to_insurer' => 3,
|
||||
'client_pending' => 3,
|
||||
'insurer_pending' => 3,
|
||||
'investigation' => 3,
|
||||
'approved' => 3,
|
||||
'closed' => 3,
|
||||
'not_covered' => 3,
|
||||
'settled' => 3,
|
||||
'coverage_check' => 3,
|
||||
'cancelled' => 3,
|
||||
'returned' => 3,
|
||||
'rejected' => 3
|
||||
],
|
||||
4 => [
|
||||
'claim_intimation' => 3,
|
||||
'intimation_to_insurer' => 3,
|
||||
'client_pending' => 3,
|
||||
'insurer_pending' => 3,
|
||||
'investigation' => 3,
|
||||
'approved' => 3,
|
||||
'closed' => 3,
|
||||
'not_covered' => 3,
|
||||
'settled' => 3,
|
||||
'coverage_check' => 3,
|
||||
'cancelled' => 3,
|
||||
'returned' => 3,
|
||||
'rejected' => 3
|
||||
]
|
||||
];
|
||||
|
||||
$this->policyStatus = [
|
||||
'under_process' => 'Under Process',
|
||||
'client_pending' => 'Client Pending',
|
||||
@ -92,7 +167,6 @@ class DashboardController extends AdminController
|
||||
'linear-gradient(45deg, #494f4f, #353d3d)' // SilverChalice shade 6
|
||||
]
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function dashboard()
|
||||
@ -100,8 +174,8 @@ class DashboardController extends AdminController
|
||||
|
||||
$data = [];
|
||||
|
||||
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()))) {
|
||||
|
||||
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()))) {
|
||||
|
||||
$db = db_connect();
|
||||
$sql = "SELECT
|
||||
clients.id AS client_id,
|
||||
@ -164,22 +238,71 @@ class DashboardController extends AdminController
|
||||
// echo "<pre>";
|
||||
$data['pendingActionsData'] = $pendingActionsData;
|
||||
$data['businessTeamCount'] = count($businessTeamData) ?? 0;
|
||||
// dd($businessTeamData);
|
||||
$data['financeTeamCount'] = count($financeTeamData) ?? 0;
|
||||
$data['businessTeamStatusData'] = $businessTeamStatusData;
|
||||
$data['financeTeamStatusData'] = $financeTeamStatusData;
|
||||
$data['policyStatus'] = $this->policyStatus;
|
||||
$data['colorShades'] = $this->colorShades;
|
||||
// print_r($data);die;
|
||||
}
|
||||
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['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());
|
||||
// dd($data);
|
||||
|
||||
$data['page_name'] = 'Dashboard';
|
||||
|
||||
echo view('layout/header', $data);
|
||||
echo view('DashBoard', $data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getClaimData()
|
||||
{
|
||||
|
||||
$results = $this->ticketStatusModel
|
||||
->select("ticket_type as ticket_type_id, claim_status")
|
||||
->where("is_active", 1)
|
||||
->findAll();
|
||||
|
||||
$claim_status = [];
|
||||
|
||||
foreach ($results as $row) {
|
||||
if (empty($row['ticket_type_id']) || empty($row['claim_status'])) {
|
||||
continue; // Skip if either value is empty
|
||||
}
|
||||
$typeId = $row['ticket_type_id'];
|
||||
$status = $row['claim_status'];
|
||||
|
||||
// Initialize if not set
|
||||
if (!isset($claim_status[$typeId])) {
|
||||
$claim_status[$typeId] = [];
|
||||
}
|
||||
|
||||
$claim_status[$typeId][$status] = true;
|
||||
}
|
||||
|
||||
// Convert set-like structure to plain array
|
||||
foreach ($claim_status as $typeId => $statuses) {
|
||||
$claim_status[$typeId] = array_keys($statuses);
|
||||
}
|
||||
$data = $this->ticketModel->getDashData($claim_status, $this->claimDashLimit);
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getDashboardNotifications()
|
||||
{
|
||||
@ -212,29 +335,29 @@ class DashboardController extends AdminController
|
||||
{
|
||||
$clientPolicyModel = new ClientPolicyModel();
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
|
||||
|
||||
$client_policy_data = $clientPolicyModel->getPolicyDetailsForEnrollment();
|
||||
$myLogger->logme('error', 'Fetched client policy data for Enrollment Status update');
|
||||
|
||||
|
||||
// dd($client_policy_data);
|
||||
|
||||
$currentDate = date('d-m-Y');
|
||||
$openEnrollment = [];
|
||||
$closeEnrollment = [];
|
||||
|
||||
|
||||
// Update policy status based on start and end dates
|
||||
foreach ($client_policy_data as $client_policy) {
|
||||
|
||||
$id = $client_policy['id'];
|
||||
$openDate = date('d-m-Y', strtotime($client_policy['open_date']));
|
||||
$closeDate = date('d-m-Y', strtotime($client_policy['close_date']));
|
||||
|
||||
|
||||
if ($currentDate == $openDate) {
|
||||
$clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
|
||||
$openEnrollment[] = $id;
|
||||
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to open for enrollment.');
|
||||
}
|
||||
|
||||
|
||||
if ($closeDate < $currentDate) {
|
||||
$clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
|
||||
$closeEnrollment[] = $id;
|
||||
@ -243,37 +366,36 @@ class DashboardController extends AdminController
|
||||
}
|
||||
|
||||
$myLogger->logme('error', 'enrollment_status function completed');
|
||||
$myLogger->logme('error', 'updated Open Enrollment Policy count : "'.count($openEnrollment).'" and Close Enrollment Policy count : "'.count($closeEnrollment).'"');
|
||||
$myLogger->logme('error', 'updated Open Enrollment Policy count : "' . count($openEnrollment) . '" and Close Enrollment Policy count : "' . count($closeEnrollment) . '"');
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'message' => 'updated Open and Close Enrollment successfully',
|
||||
'open_policy_count' => count($openEnrollment),
|
||||
'status' => true,
|
||||
'message' => 'updated Open and Close Enrollment successfully',
|
||||
'open_policy_count' => count($openEnrollment),
|
||||
'close_policy_count' => count($closeEnrollment),
|
||||
'open_policy_ids' => $openEnrollment,
|
||||
'open_policy_ids' => $openEnrollment,
|
||||
'close_policy_ids' => $closeEnrollment,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function sendCroneRemainderMail()
|
||||
{
|
||||
$clientPolicyModel = new ClientPolicyModel();
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
|
||||
|
||||
|
||||
|
||||
$client_policy_data = $clientPolicyModel->getPolicyDetailsForRemainder();
|
||||
$myLogger->logme('error', 'Fetched client policy data');
|
||||
// dd($client_policy_data);
|
||||
|
||||
|
||||
// Mail send function
|
||||
$result = $this->sendRemainderMail($client_policy_data, 'crone');
|
||||
|
||||
$myLogger->logme('error', 'sendCroneRemainderMail function completed');
|
||||
|
||||
if($result){
|
||||
|
||||
if ($result) {
|
||||
return json_encode(['status' => true, 'message' => 'Mail send successfully']);
|
||||
}else{
|
||||
} else {
|
||||
return json_encode(['status' => false, 'message' => 'There is no data to send']);
|
||||
}
|
||||
}
|
||||
@ -285,29 +407,22 @@ class DashboardController extends AdminController
|
||||
|
||||
$data = [];
|
||||
|
||||
if($type == 'insurer'){
|
||||
if ($type == 'insurer') {
|
||||
|
||||
$data = $pendingActionsData['uhid'];
|
||||
|
||||
}else if($type == 'TPA'){
|
||||
} else if ($type == 'TPA') {
|
||||
$data = $pendingActionsData['tpa'];
|
||||
|
||||
}else if($type == 'I'){
|
||||
} else if ($type == 'I') {
|
||||
$data = $pendingActionsData['inception'];
|
||||
|
||||
}else if($type == 'D'){
|
||||
} else if ($type == 'D') {
|
||||
$data = $pendingActionsData['deletion'];
|
||||
|
||||
}else if($type == 'C'){
|
||||
} else if ($type == 'C') {
|
||||
$data = $pendingActionsData['correction'];
|
||||
|
||||
}else if($type == 'SI'){
|
||||
} else if ($type == 'SI') {
|
||||
$data = $pendingActionsData['si_enhancement'];
|
||||
|
||||
}else if($type == 'policy'){
|
||||
} else if ($type == 'policy') {
|
||||
$data = $pendingActionsData['policy'];
|
||||
|
||||
}else if($type == 'ticket'){
|
||||
} else if ($type == 'ticket') {
|
||||
$data = $pendingActionsData['uhid'];
|
||||
}
|
||||
|
||||
@ -421,7 +536,6 @@ class DashboardController extends AdminController
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
}
|
||||
}
|
||||
|
||||
} else { // crone
|
||||
|
||||
if (!empty($client_policy['reminder_date'])) {
|
||||
@ -511,15 +625,12 @@ class DashboardController extends AdminController
|
||||
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme('error', "SEND REMAINDER CRONE --- Remainder date is empty()");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', 'Notification setup not found or not enabled');
|
||||
@ -549,29 +660,28 @@ class DashboardController extends AdminController
|
||||
|
||||
public function sendManualReminder($client_id, $client_branch_id, $client_policy_id = null)
|
||||
{
|
||||
$this->myLogger->logme('error','Log Works');
|
||||
$this->myLogger->logme('error', 'Log Works');
|
||||
|
||||
$this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}");
|
||||
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id, $client_policy_id);
|
||||
// print_r($client_policy_data); die;
|
||||
// print_r($this->clientPolicyModel->getLastQuery()); die;
|
||||
// $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data));
|
||||
|
||||
|
||||
if ($client_policy_data) {
|
||||
$result = $this->sendRemainderMail($client_policy_data);
|
||||
log_message('error',json_encode($result));
|
||||
$this->myLogger->logme('error',$result);
|
||||
log_message('error', json_encode($result));
|
||||
$this->myLogger->logme('error', $result);
|
||||
$this->myLogger->logme('error', "Manual Remainder Mail sending result: " . ($result ? 'success' : 'failure'));
|
||||
|
||||
|
||||
if ($result) {
|
||||
$this->myLogger->logme('error', 'Manual Remainder Mail sent successfully');
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail sent successfully'], 200);
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'Failed to send manual remainder mail, no data to send');
|
||||
return $this->respond(['status' => false, 'code' => 200, 'message' => 'There is no data to send','message2' => 'Failed' ], 200);
|
||||
return $this->respond(['status' => false, 'code' => 200, 'message' => 'There is no data to send', 'message2' => 'Failed'], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'No policy data found to send');
|
||||
return $this->respond(['status' => false, 'code' => 200, 'message' => 'There is no data to send', 'message2' => 'No policy data found to send'], 200);
|
||||
@ -581,19 +691,17 @@ class DashboardController extends AdminController
|
||||
public function sendManualEcard($client_id, $client_branch_id, $policy_id)
|
||||
{
|
||||
$this->myLogger->logme('error', "sendManualEcard called with client_id: {$client_id}, client_branch_id: {$client_branch_id}, policy id : {$policy_id}");
|
||||
|
||||
$notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', 'member_ecard_mail')->first();
|
||||
// print_r(($notification)); die;
|
||||
if($notification && $notification['enabled'] == 0 && $notification['mail_content'] == '')
|
||||
{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200);
|
||||
}
|
||||
|
||||
|
||||
$notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', 'member_ecard_mail')->first();
|
||||
// print_r(($notification)); die;
|
||||
if ($notification && $notification['enabled'] == 0 && $notification['mail_content'] == '') {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found', 'message2' => 'Failed'], 200);
|
||||
}
|
||||
|
||||
|
||||
$emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id);
|
||||
if(count($emp_data) == 0)
|
||||
{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No employees found','message2' => 'Failed' ], 200);
|
||||
if (count($emp_data) == 0) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No employees found', 'message2' => 'Failed'], 200);
|
||||
}
|
||||
$ids = array_column($emp_data, 'id');
|
||||
// print_r(($ids)); die;
|
||||
@ -603,9 +711,8 @@ class DashboardController extends AdminController
|
||||
// $empEmpDataServiceController = new EmpDataServiceController();
|
||||
// $empEmpDataServiceController->sendMailForDownloadingECard($ids);
|
||||
|
||||
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail Queued'], 200);
|
||||
|
||||
}
|
||||
|
||||
public function data_construct_for_bds($data)
|
||||
@ -620,9 +727,8 @@ class DashboardController extends AdminController
|
||||
'validated' => [],
|
||||
'cancelled' => [],
|
||||
'instalment_pending' => [],
|
||||
'completed' => [],
|
||||
];
|
||||
|
||||
|
||||
// Loop through results and group them by their status
|
||||
foreach ($data as $row) {
|
||||
switch ($row['status']) {
|
||||
@ -650,13 +756,32 @@ class DashboardController extends AdminController
|
||||
case 'instalment_pending':
|
||||
$groupedData['instalment_pending'][] = $row;
|
||||
break;
|
||||
default:
|
||||
case 'under_process':
|
||||
$groupedData['under_process'][] = $row;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $groupedData;
|
||||
}
|
||||
|
||||
public function prepareClaimSearchData()
|
||||
{
|
||||
|
||||
$received_data = $this->request->getPost();
|
||||
$ticketTypeId = $received_data['ticketTypeId'];
|
||||
$status = $received_data['status'];
|
||||
|
||||
$status = strtoupper($status);
|
||||
$status = str_replace('_', ' ', $status);
|
||||
|
||||
$data = $this->ticketModel
|
||||
->select("tcs.id as claim_status_id")
|
||||
->join("ticket_claim_status tcs", "tcs.ticket_type = " . (int)$ticketTypeId)
|
||||
->where("tcs.claim_status", $status)
|
||||
->first();
|
||||
$data['ticket_type_id'] = $ticketTypeId;
|
||||
return $this->respond(['status' => "success", "data" => $data], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,6 +529,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true; // Excel file successfully generated and exported
|
||||
|
||||
@ -633,6 +634,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -784,6 +786,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -897,6 +900,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -945,6 +949,9 @@ class EmpDataServiceController extends BaseController
|
||||
$export_data['event_type'] = 'correction';
|
||||
$correctionData = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($export_data);
|
||||
|
||||
}else if($value == "missed_inception"){
|
||||
$export_data['event_type'] = 'missed_inception';
|
||||
$additionData = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1196,6 +1203,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true; // Excel file successfully generated and exported
|
||||
|
||||
@ -2415,8 +2423,17 @@ class EmpDataServiceController extends BaseController
|
||||
$client_policy_id = $file['client_policy_id'];
|
||||
$client_branch_id = $file['client_branch_id'];
|
||||
$batch_code = $file['batch_code'];
|
||||
$insurer_or_tpa = $file['insurer_or_tpa'];
|
||||
$user_id = $file['created_by'];
|
||||
|
||||
$ref_data = [
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'insurer_or_tpa' => $insurer_or_tpa,
|
||||
'event_type' => $file['event_type'],
|
||||
];
|
||||
|
||||
|
||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||
|
||||
@ -2448,92 +2465,92 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$endorsement_data = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($ref_data, 1);
|
||||
// $db = \Config\Database::connect();
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
// // Raw SQL query
|
||||
// $sql = "
|
||||
// SELECT
|
||||
// a.id as endorsement_primarykey,
|
||||
// a.group_key,
|
||||
// employee_polices.id AS primaryKey,
|
||||
// employees.id AS emp_primary,
|
||||
// employees.name AS emp_name,
|
||||
// employees.emp_code AS emp_code,
|
||||
// employees.dob AS emp_dob,
|
||||
// employees.gender AS emp_gender,
|
||||
// employees.relationship_code AS emp_relationship_code,
|
||||
// 'Has Define' AS emp_type,
|
||||
// employee_polices.uhid AS risk_id,
|
||||
// employee_polices.pre_existing_alignments,
|
||||
// employee_polices.policy_end_date,
|
||||
// employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
// employee_polices.rata_premimum as old_si_premium,
|
||||
// sidata.new_basic_cover_si,
|
||||
// sidata.new_si_premium,
|
||||
// sidata.date_of_coverage,
|
||||
// DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
// sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium,
|
||||
// ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum,
|
||||
// ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
// ((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total
|
||||
// FROM
|
||||
// emp_endorsement a
|
||||
// LEFT JOIN
|
||||
// employees ON employees.emp_code = a.emp_code
|
||||
// LEFT JOIN
|
||||
// employee_polices ON employees.id = employee_polices.employee_id
|
||||
// LEFT JOIN (
|
||||
// SELECT
|
||||
// aa.emp_code,
|
||||
// aa.new_value as new_basic_cover_si,
|
||||
// bb.new_value as new_si_premium,
|
||||
// cc.new_value as date_of_coverage
|
||||
// FROM (
|
||||
// SELECT
|
||||
// a1.emp_code,
|
||||
// a1.field_name,
|
||||
// a1.new_value
|
||||
// FROM
|
||||
// emp_endorsement as a1
|
||||
// WHERE
|
||||
// a1.field_name = 'basic_cover_si'
|
||||
// ) aa
|
||||
// LEFT JOIN (
|
||||
// SELECT
|
||||
// b1.emp_code,
|
||||
// b1.field_name,
|
||||
// b1.new_value
|
||||
// FROM
|
||||
// emp_endorsement as b1
|
||||
// WHERE
|
||||
// b1.field_name = 'premium'
|
||||
// ) bb ON aa.emp_code = bb.emp_code
|
||||
// LEFT JOIN (
|
||||
// SELECT
|
||||
// c1.emp_code,
|
||||
// c1.field_name,
|
||||
// c1.new_value
|
||||
// FROM
|
||||
// emp_endorsement as c1
|
||||
// WHERE
|
||||
// c1.field_name = 'si_enhancement_date'
|
||||
// ) cc ON aa.emp_code = cc.emp_code
|
||||
// ) as sidata ON a.emp_code = sidata.emp_code
|
||||
// WHERE
|
||||
// employee_polices.client_policy_id = '$client_policy_id'
|
||||
// AND employees.client_branch_id = '$client_branch_id'
|
||||
// AND employee_polices.is_active = '1'
|
||||
// AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
// AND a.actions = 'si'
|
||||
// GROUP BY group_key
|
||||
// ";
|
||||
|
||||
// Raw SQL query
|
||||
$sql = "
|
||||
SELECT
|
||||
a.id as endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id AS primaryKey,
|
||||
employees.id AS emp_primary,
|
||||
employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
'Has Define' AS emp_type,
|
||||
employee_polices.uhid AS risk_id,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
employee_polices.rata_premimum as old_si_premium,
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_si_premium,
|
||||
sidata.date_of_coverage,
|
||||
DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium,
|
||||
ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum,
|
||||
ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total
|
||||
FROM
|
||||
emp_endorsement a
|
||||
LEFT JOIN
|
||||
employees ON employees.emp_code = a.emp_code
|
||||
LEFT JOIN
|
||||
employee_polices ON employees.id = employee_polices.employee_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
aa.emp_code,
|
||||
aa.new_value as new_basic_cover_si,
|
||||
bb.new_value as new_si_premium,
|
||||
cc.new_value as date_of_coverage
|
||||
FROM (
|
||||
SELECT
|
||||
a1.emp_code,
|
||||
a1.field_name,
|
||||
a1.new_value
|
||||
FROM
|
||||
emp_endorsement as a1
|
||||
WHERE
|
||||
a1.field_name = 'basic_cover_si'
|
||||
) aa
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
b1.emp_code,
|
||||
b1.field_name,
|
||||
b1.new_value
|
||||
FROM
|
||||
emp_endorsement as b1
|
||||
WHERE
|
||||
b1.field_name = 'premium'
|
||||
) bb ON aa.emp_code = bb.emp_code
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
c1.emp_code,
|
||||
c1.field_name,
|
||||
c1.new_value
|
||||
FROM
|
||||
emp_endorsement as c1
|
||||
WHERE
|
||||
c1.field_name = 'si_enhancement_date'
|
||||
) cc ON aa.emp_code = cc.emp_code
|
||||
) as sidata ON a.emp_code = sidata.emp_code
|
||||
WHERE
|
||||
employee_polices.client_policy_id = '$client_policy_id'
|
||||
AND employees.client_branch_id = '$client_branch_id'
|
||||
AND employee_polices.is_active = '1'
|
||||
AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
AND a.actions = 'si'
|
||||
GROUP BY group_key
|
||||
";
|
||||
// // Execute the query
|
||||
// $query = $db->query($sql);
|
||||
|
||||
// Execute the query
|
||||
$query = $db->query($sql);
|
||||
|
||||
// Fetch the results
|
||||
$endorsement_data = $query->getResultArray();
|
||||
// // Fetch the results
|
||||
// $endorsement_data = $query->getResultArray();
|
||||
|
||||
|
||||
|
||||
@ -2740,11 +2757,11 @@ class EmpDataServiceController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
if ($endorsement_value['pro_rata_premimum'] != $excel_data[$key][16]) {
|
||||
if ($endorsement_value['pro_rata_premium'] != $excel_data[$key][16]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 16,
|
||||
'db_data' => $endorsement_value['pro_rata_premimum'],
|
||||
'db_data' => $endorsement_value['pro_rata_premium'],
|
||||
'excel_data' => $excel_data[$key][16]
|
||||
];
|
||||
}
|
||||
@ -2945,7 +2962,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$empData['basic_cover_si'] = $value[8];
|
||||
$empData['premium'] = $value[14];
|
||||
$empData['si_enhancement_date'] = $value[10];
|
||||
$empData['si_enhancement_date'] = date('Y-m-d', strtotime($value[10])) ?? null;
|
||||
$empData['rata_premimum'] = $value[16];
|
||||
$empData['gst'] = $value[17];
|
||||
$empData['created_by'] = $user_id;
|
||||
@ -2959,26 +2976,20 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$this->employeePolicyModel->updateBatch($emp_policy_ids, 'id');
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
|
||||
$this->employeePolicyModel->insertBatch($emp_details);
|
||||
// $this->employeePolicyModel->insertBatch($emp_details);
|
||||
// $insertedIds = [];
|
||||
// $startId = $db->insertID(); // Get the first inserted ID
|
||||
|
||||
// for ($i = 0; $i < count($emp_details); $i++) {
|
||||
// $insertedIds[] = $startId + $i;
|
||||
// }
|
||||
|
||||
$insertedIds = [];
|
||||
$startId = $db->insertID(); // Get the first inserted ID
|
||||
|
||||
for ($i = 0; $i < count($emp_details); $i++) {
|
||||
$insertedIds[] = $startId + $i;
|
||||
foreach ($emp_details as $emp) {
|
||||
$insertedIds[] = $this->employeePolicyModel->insert($emp);
|
||||
}
|
||||
|
||||
$db->transComplete();
|
||||
|
||||
// if ($db->transStatus() === FALSE) {
|
||||
// // Handle the error, rollback, etc.
|
||||
// } else {
|
||||
// // Transaction successful
|
||||
// print_r($insertedIds); // This will print the array of inserted IDs
|
||||
// }
|
||||
// dd($insertedIds);
|
||||
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
|
||||
@ -190,7 +190,7 @@ class EmployeeController extends AdminController
|
||||
// print_r($this->request->getPost('upload-action-type'));
|
||||
// die();
|
||||
// $empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '42']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '933']);
|
||||
// dd($res);
|
||||
|
||||
// $empServiceController = new EmployeeServiceController();
|
||||
@ -434,7 +434,7 @@ class EmployeeController extends AdminController
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls';
|
||||
} else if ($actionType == 'si_enhancement') {
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls';
|
||||
} else if ($actionType == 'dependent_addtion') {
|
||||
} else if ($actionType == 'dependent_addition') {
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls';
|
||||
} else if ($actionType == 'addition') {
|
||||
$filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls';
|
||||
@ -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
|
||||
|
||||
@ -3226,18 +3226,12 @@ class EmployeeRestController extends AdminController
|
||||
$message = 'Claim Iniated Successfully';
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
|
||||
} else {
|
||||
$mail_sent_status = json_decode($mail_sent_status);
|
||||
$mail_sent_status_object = json_decode($mail_sent_status);
|
||||
}
|
||||
// dd(gettype($mail_sent_status));
|
||||
|
||||
if ($mail_sent_status->status == 'success') {
|
||||
$sent_message_data['ticket_id'] = $ticket_id;
|
||||
$sent_message_data['sender'] = 'staff';
|
||||
$sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
|
||||
$sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
|
||||
$sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
|
||||
if ($mail_sent_status_object->status == 'success') {
|
||||
|
||||
$message_insert_status = $this->ticketMessage->insert($sent_message_data);
|
||||
$message_insert_status = $this->ticketController->autoMessageInsertBasedOnMailResponse($mail_sent_status, $ticket_id);
|
||||
|
||||
if ($message_insert_status) {
|
||||
$message = 'Claim Initiated Successfully';
|
||||
@ -3248,11 +3242,11 @@ class EmployeeRestController extends AdminController
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
|
||||
}
|
||||
} else {
|
||||
|
||||
$message = 'Claim Initiated, Failed to send Mail ';
|
||||
$this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
$message = 'Something Went Wrong';
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
|
||||
|
||||
@ -28,6 +28,9 @@ use App\Controllers\JobWorker ;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Kint\Kint;
|
||||
|
||||
use App\Helpers\ExcelSanitizeHelper;
|
||||
|
||||
|
||||
class EmployeeServiceController extends AdminController
|
||||
{
|
||||
|
||||
@ -468,7 +471,7 @@ class EmployeeServiceController extends AdminController
|
||||
'format' => null,
|
||||
'allowed_values' => null,
|
||||
'custom' => 'check_si',
|
||||
'params' => ['row', 'policy_terms', 'slab_details']
|
||||
'params' => ['row', 'policy_details', 'slab_details']
|
||||
],
|
||||
'date_of_enhancement' => [
|
||||
'col_idx' => 4,
|
||||
@ -725,6 +728,7 @@ class EmployeeServiceController extends AdminController
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
// dd($allowedHighestColumn);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
|
||||
// !dd(array_chunk($excel_data,20)[0]);
|
||||
|
||||
//check no of columns in excel
|
||||
@ -994,7 +998,7 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
$excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data);
|
||||
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
@ -1032,6 +1036,14 @@ class EmployeeServiceController extends AdminController
|
||||
// kint::dump($family);
|
||||
$family = data_group_by_family($family)[ $emp_id ];// reason to call this again bring self to first index of the array
|
||||
}
|
||||
$firstNonTemp = null;
|
||||
|
||||
foreach ($family as $fam) {
|
||||
if (!isset($fam['temp'])) {
|
||||
$firstNonTemp = $fam;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// kint::dump($family);//die();
|
||||
|
||||
//check name dup within a family
|
||||
@ -1067,7 +1079,7 @@ class EmployeeServiceController extends AdminController
|
||||
if(!count($self_details))
|
||||
{
|
||||
array_push($result['error_summary'],14); // Self not found
|
||||
$result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database";
|
||||
$result['error_data'][ $firstNonTemp[0] ]['sno']['error'][] = "Self not found in Database";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1075,7 +1087,7 @@ class EmployeeServiceController extends AdminController
|
||||
if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception'|| $file['action'] == 'missed_inception' || $file['action'] == 'enrollment')
|
||||
{
|
||||
$res = check_dependent_conflict($family,$policy_terms,$file['action'],$is_lgbtq);
|
||||
// dd($res);
|
||||
// Kint::dump($res);
|
||||
if(!$res['status'])
|
||||
{
|
||||
foreach($res['error_data'] as $key => $value)
|
||||
@ -1088,7 +1100,7 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
//check dup with empid and name with db
|
||||
$res = name_and_empid_check_in_db($family,$file);
|
||||
// dd($res);
|
||||
// Kint::dump($res['del']);
|
||||
// echo '<br/>';
|
||||
// print_r($res);
|
||||
if(count($res['del']))
|
||||
@ -1110,7 +1122,7 @@ class EmployeeServiceController extends AdminController
|
||||
}// end of foreach
|
||||
}// end of if current action I,DA,A
|
||||
|
||||
// return $result;
|
||||
// return $result;
|
||||
// die();
|
||||
if(isset($result['error_summary']) && count($result['error_summary']))
|
||||
{
|
||||
@ -1356,19 +1368,28 @@ class EmployeeServiceController extends AdminController
|
||||
break;
|
||||
}
|
||||
// echo '<br>START- ' . $row[2];
|
||||
$employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->where('client_branch_id',$file['client_branch_id'])->first();
|
||||
|
||||
$employee = $this->employeeModel
|
||||
->where('emp_code', $row[1])
|
||||
->where('name',$row[2])
|
||||
->where('client_id',$file['client_id'])
|
||||
->where('client_branch_id',$file['client_branch_id'])
|
||||
->where('emp_status !=','truncated')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
// $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->first();
|
||||
// dd($employee);
|
||||
if(is_array($employee) && count($employee))
|
||||
{
|
||||
// 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();
|
||||
|
||||
// dd($existing_endorsements);
|
||||
@ -1527,8 +1548,21 @@ class EmployeeServiceController extends AdminController
|
||||
break;
|
||||
}
|
||||
// echo '<br>START- ' . $row[2];
|
||||
$employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->where('client_branch_id',$file['client_branch_id'])->first();
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
|
||||
$employee = $this->employeeModel
|
||||
->where('emp_code', $row[1])
|
||||
->where('name',$row[2])
|
||||
->where('client_id',$file['client_id'])
|
||||
->where('client_branch_id',$file['client_branch_id'])
|
||||
->where('emp_status', 'active')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
$employee_policy = $this->employeePolicyModel
|
||||
->where('employee_id',$employee['id'])
|
||||
->where('client_policy_id',$file['policy_id'])
|
||||
->where('status', 'active')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
// dd($employee, $employee_policy);
|
||||
|
||||
$existing_endorsements = $this->empEndorsementModel->where('actions','si')
|
||||
->where('table_name','employee_polices')
|
||||
@ -1552,9 +1586,11 @@ class EmployeeServiceController extends AdminController
|
||||
if($pre_rack_rate_name != $slab_value['rack_rate_name'])
|
||||
{
|
||||
$pre_rack_rate_name = $slab_value['rack_rate_name'];
|
||||
$rack_rate_json = json_decode($slab_value['additional_relationship']);
|
||||
if(in_array(strtolower($employee['relationship']), $rack_rate_json) && $rack_rate_json[ strtolower($employee['relationship']) ] != 0 && $rack_rate_json[ strtolower($employee['relationship']) ] != 'NA')
|
||||
{
|
||||
$rack_rate_json = json_decode($slab_value['additional_relationship'], true);
|
||||
$relationship_array_key = strtolower($employee['relationship']);
|
||||
|
||||
if(array_key_exists($relationship_array_key, $rack_rate_json) && $rack_rate_json[ strtolower($employee['relationship']) ] != 0 && $rack_rate_json[ strtolower($employee['relationship']) ] != 'NA')
|
||||
{
|
||||
$applicable_rack_rate_name = $slab_value['rack_rate_name'];
|
||||
$applicable_rack_rate_master = $slab_value['grid_master'];
|
||||
break;
|
||||
@ -1563,11 +1599,13 @@ class EmployeeServiceController extends AdminController
|
||||
}
|
||||
|
||||
//get max age,max count of the familiy
|
||||
$max_age_and_max_count_of_current_member = $this->employeeModel->getFamiliyCountAndMaxage($employee['emp_code']);
|
||||
$max_age_and_max_count_of_current_member = $this->employeeModel->getFamiliyCountAndMaxage($employee['emp_code']);
|
||||
//transform SI excel row data as inception excel OR premium calculateable fomart
|
||||
|
||||
$data = transform_si_excel_row_to_calculatable_format(employee: $employee,employee_policy: $employee_policy,maxage_and_maxcount: $max_age_and_max_count_of_current_member,slab_details: $slab_details,applicable_slab_name: $applicable_rack_rate_name,augmented_si: $row[3],grid_master: $applicable_rack_rate_master);
|
||||
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
|
||||
$policy_terms = (array) $policy_terms[0];
|
||||
// dd($policy_terms);
|
||||
//grouping slab details by rack rate name
|
||||
$temp_slab_rates = group_slab_rates_basedon_name($slab_details);
|
||||
|
||||
@ -1658,6 +1696,7 @@ class EmployeeServiceController extends AdminController
|
||||
// $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name']));
|
||||
// echo 'update emp';
|
||||
}
|
||||
$value = ExcelSanitizeHelper::sanitizeArrayData($value);
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id'])) {
|
||||
$emp_id = $value['id'];
|
||||
@ -2048,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;
|
||||
|
||||
@ -2081,7 +2122,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
|
||||
}
|
||||
|
||||
|
||||
$value = ExcelSanitizeHelper::sanitizeArrayData($value);
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id']))
|
||||
{ $emp_id = $value['id']; }
|
||||
|
||||
@ -30,6 +30,7 @@ use App\Models\RFQModel;
|
||||
use App\Models\InsurerModel;
|
||||
use App\Models\OccupancyMasterModel;
|
||||
use App\Models\LeadFilesModel;
|
||||
use App\Models\LeadInstallmentPaymentDetails;
|
||||
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Helpers\ExcelMergeHelper;
|
||||
@ -65,6 +66,7 @@ class LeadsController extends BaseController
|
||||
protected $insurerModel;
|
||||
protected $occupancyModel;
|
||||
protected $leadFilesModel;
|
||||
protected $leadInstallmentPaymentDetails;
|
||||
|
||||
//variables for storing array
|
||||
protected $issuer;
|
||||
@ -96,20 +98,27 @@ class LeadsController extends BaseController
|
||||
$this->insurerModel = new InsurerModel();
|
||||
$this->occupancyModel = new OccupancyMasterModel();
|
||||
$this->leadFilesModel = new LeadFilesModel();
|
||||
$this->leadInstallmentPaymentDetails = new LeadInstallmentPaymentDetails();
|
||||
|
||||
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$this->clientType = [1 => 'Group', 2 => 'Individual'];
|
||||
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
|
||||
$data = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$this->buisnessType = array_column($data, 'name', 'id');
|
||||
// $this->buisnessType = [1 => 'Public Sector', 2 => 'Private Sector',3=> 'Trust',4 => 'Proprietorship',5 => 'Partnership',6 => 'Private',7 => 'Individual'];
|
||||
$this->leadsStatus = [
|
||||
'queued' => 'In-Queued',
|
||||
'qcr_sent' => 'QCR sent',
|
||||
'lost' => 'Lost',
|
||||
'co_insurer_pending' => 'Co-Insurer Pending',
|
||||
'won' => 'Won',
|
||||
'completed_with_corrections' => 'Completed with Corrections',
|
||||
'completed_without_corrections' => 'Completed w/o Corrections',
|
||||
'queued' => 'In-Queued',
|
||||
'rfq_created' => 'RFQ Created',
|
||||
'rfq_sent' => 'RFQ Sent',
|
||||
'qcr_created' => 'QCR Created',
|
||||
'qcr_sent' => 'QCR Sent',
|
||||
'lost' => 'Lost',
|
||||
'co_insurer_pending' => 'Co-Insurer Pending',
|
||||
'won' => 'Won',
|
||||
'completed_with_corrections' => 'Completed with Corrections',
|
||||
'completed_without_corrections' => 'Completed without Corrections',
|
||||
];
|
||||
|
||||
$this->claim_type_for_gpa = [
|
||||
'accident_death' => 'Accident Death',
|
||||
'permanent_total_disablement' => 'Permanent Total Disablement',
|
||||
@ -146,19 +155,36 @@ class LeadsController extends BaseController
|
||||
$this->loadLayout('lead_filter', $data);
|
||||
} else {
|
||||
|
||||
$search_data = $this->request->getPost();
|
||||
// print_r($search_data);
|
||||
$isFromDashboard = $this->request->getPost("is_dashboard");
|
||||
|
||||
$where = [];
|
||||
foreach ($search_data as $search_objects => $key) {
|
||||
if ($key != null && $key != '' && $key != 0) {
|
||||
$where[$search_objects] = $key;
|
||||
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();
|
||||
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
|
||||
$html = view('leads_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
$where = [];
|
||||
foreach ($search_data as $search_objects => $key) {
|
||||
if ($key != null && $key != '' && $key != 0 && $search_objects != 'is_dashboard') {
|
||||
$where[$search_objects] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
|
||||
|
||||
$html = view('leads_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,12 +601,14 @@ class LeadsController extends BaseController
|
||||
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
|
||||
} else {
|
||||
|
||||
$lead_file_data = [
|
||||
'lead_id' => $lead_id,
|
||||
'docs_name' => $value['docs_name'],
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
$this->leadFilesModel->insert($lead_file_data);
|
||||
if (!empty($value['file_name'])) {
|
||||
$lead_file_data = [
|
||||
'lead_id' => $lead_id,
|
||||
'docs_name' => $value['docs_name'],
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
$this->leadFilesModel->insert($lead_file_data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 0 && !empty($value['file_name'])) {
|
||||
@ -659,7 +687,7 @@ class LeadsController extends BaseController
|
||||
$data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ();
|
||||
$data['lead_data'] = $lead_data;
|
||||
|
||||
$mail_content = "
|
||||
$mail_content = '
|
||||
<p>Dear Sir,</p>
|
||||
<p>Greetings From Nhance India!</p>
|
||||
<p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
|
||||
@ -670,27 +698,32 @@ class LeadsController extends BaseController
|
||||
|
||||
<div style=\"margin: 0; padding: 0; line-height: 1.2;\">
|
||||
<div>{{LOGGED_USER_NAME}}</div>
|
||||
<div>Email: {{LOGGED_USER_EMAIL}}</div>
|
||||
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
|
||||
';
|
||||
|
||||
";
|
||||
|
||||
if ($data['lead_data']['policy_end_date'] != null){
|
||||
if ($data['lead_data']['policy_end_date'] != null) {
|
||||
$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}}";
|
||||
}
|
||||
|
||||
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']);
|
||||
|
||||
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
$installment_data['installments'] = $this->leadInstallmentPaymentDetails->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
$data['lead_data']['installment_data'] = view('rfq/installment_fields', $installment_data) ?? null;
|
||||
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
|
||||
$data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut","ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active",1)->first()['team_id'];
|
||||
$data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active", 1)->first()['team_id'];
|
||||
// dd($data);
|
||||
|
||||
if ($data['lead_data']['lead_form_type'] == 1) {
|
||||
@ -711,11 +744,14 @@ class LeadsController extends BaseController
|
||||
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
}
|
||||
|
||||
$data['product'] = $this->leadsModel->select("policy_type.policy_type")->join('policy_type', 'leads.policy_type_id = policy_type.id')->where('leads.id', $id)->first()['policy_type'];
|
||||
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
// dd($data['lead_register_data']);
|
||||
// $data['entity_type'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$data['buisness_type'] = $this->buisnessType;
|
||||
|
||||
// dd($data);
|
||||
$data['client_type'] = $this->clientType;
|
||||
$data['buisness_type'] = $this->buisnessType;
|
||||
$this->loadLayout('view_rfq_non_eb', $data);
|
||||
}
|
||||
}
|
||||
@ -760,12 +796,27 @@ class LeadsController extends BaseController
|
||||
return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400);
|
||||
}
|
||||
|
||||
$rfq_created = $this->RFQModel->where('lead_id', $lead_id)->where('is_active', 1)->countAllResults();
|
||||
$qcr_created = false;
|
||||
$inputJson = json_decode($data['json'], true);
|
||||
if (isset($inputJson['premium_data']) && !empty($inputJson['premium_data'])) {
|
||||
$sortedJson = $this->reorderProposalsByInsurerTotal($inputJson);
|
||||
$data['json'] = json_encode($sortedJson);
|
||||
$qcr_created = true;
|
||||
}
|
||||
|
||||
if(($data['submit_type'] ?? "") == 'QCR'){
|
||||
$inputJson = json_decode($data['json'], true);
|
||||
$proposal_data = array_pop($inputJson);
|
||||
if(isset($proposal_data['proposal_data']['over_all_column_data'])){
|
||||
$proposel_count = $proposal_data['proposal_data']['over_all_column_data'];
|
||||
foreach ($proposel_count as $key => $value) {
|
||||
if(!empty($value['insurers'])){
|
||||
$qcr_created = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['type'] = 1;
|
||||
|
||||
@ -805,6 +856,19 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
if ($insertId) {
|
||||
|
||||
if(empty($rfq_created)){
|
||||
$this->leadsModel->update($lead_id, ['status' => "rfq_created"]);
|
||||
}
|
||||
|
||||
if($qcr_created == true){
|
||||
$this->leadsModel
|
||||
->where('id', $lead_id)
|
||||
->whereNotIn('status', ['qcr_sent', 'lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections'])
|
||||
->set(['status' => "qcr_created"])
|
||||
->update();
|
||||
}
|
||||
|
||||
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR saved successfully' : 'RFQ saved successfully';
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
@ -866,7 +930,7 @@ class LeadsController extends BaseController
|
||||
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
|
||||
$proposals[$key] = $value;
|
||||
break;
|
||||
}else{
|
||||
} else {
|
||||
$proposals[$key] = $value;
|
||||
}
|
||||
}
|
||||
@ -1047,6 +1111,17 @@ class LeadsController extends BaseController
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function removeInstallments()
|
||||
{
|
||||
$id = $this->request->getGet('id');
|
||||
// print_r($id); die;
|
||||
if (!empty($id)) {
|
||||
$this->leadInstallmentPaymentDetails->whereIn('id', $id)->set(['is_active' => 0])->update();
|
||||
return $this->respond(['status' => true, 'message' => 'Removed successfully'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'Could not be removed.'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
//-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -1123,36 +1198,32 @@ class LeadsController extends BaseController
|
||||
|
||||
if ($rfq_data['policy_type_id'] == 2) {
|
||||
$lead_data = [
|
||||
'policy_end_date' => $rfq_data['policy_end_date'],
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Status' => $rfq_data['status'],
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
|
||||
'No of Employees' => $rfq_data['incept_emp_count'],
|
||||
'No of Dependents' => $rfq_data['incept_dept_count'],
|
||||
'Total Lives' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
];
|
||||
} else if ($rfq_data['policy_type_id'] == 1) {
|
||||
$lead_data = [
|
||||
'policy_end_date' => $rfq_data['policy_end_date'],
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
|
||||
'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
|
||||
'Policy Status' => $rfq_data['status'],
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
'TPA ' => $rfq_data['tpa_name'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($rfq_data['policy_type_id'] == 2) {
|
||||
$lead_data = [
|
||||
'policy_end_date' => $rfq_data['policy_end_date'],
|
||||
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Status' => $rfq_data['status'],
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
|
||||
@ -1166,7 +1237,7 @@ class LeadsController extends BaseController
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
'Inception Premium' => $rfq_data['premium_at_inception'],
|
||||
'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'],
|
||||
@ -1178,12 +1249,11 @@ class LeadsController extends BaseController
|
||||
];
|
||||
} else if ($rfq_data['policy_type_id'] == 1) {
|
||||
$lead_data = [
|
||||
'policy_end_date' => $rfq_data['policy_end_date'],
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
|
||||
'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
|
||||
'Policy Status' => $rfq_data['status'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
'TPA ' => $rfq_data['tpa_name'],
|
||||
];
|
||||
@ -1193,13 +1263,16 @@ class LeadsController extends BaseController
|
||||
$data = json_decode($rfq_data['json'], true);
|
||||
// dd($data);
|
||||
|
||||
$sheetName = 'Worksheet';
|
||||
if ($type == 2) {
|
||||
$sheetName = 'QCR';
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
if ($propsal_and_insurer !== null) {
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
|
||||
}
|
||||
} else if ($type == 1) {
|
||||
$sheetName = 'RFQ';
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
// dd($data);
|
||||
}
|
||||
@ -1207,6 +1280,7 @@ class LeadsController extends BaseController
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setTitle($sheetName);
|
||||
|
||||
|
||||
// Start with lead_data at the top
|
||||
@ -1226,22 +1300,6 @@ class LeadsController extends BaseController
|
||||
],
|
||||
]);
|
||||
|
||||
// Set column width to fit the image properly
|
||||
$sheet->getColumnDimension('C')->setWidth(20); // Adjust as needed
|
||||
$sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed
|
||||
|
||||
$drawing = new Drawing();
|
||||
$path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path
|
||||
$drawing->setPath($path);
|
||||
$drawing->setCoordinates("C{$rowNumber}"); // Set position in column B
|
||||
$drawing->setHeight(35); // Adjust image height
|
||||
|
||||
// Center align the image in the cell
|
||||
$drawing->setOffsetX(30); // Adjust horizontal offset
|
||||
$drawing->setOffsetY(5); // Adjust vertical offset
|
||||
|
||||
$drawing->setWorksheet($sheet);
|
||||
|
||||
// Apply center alignment to the cell
|
||||
$sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
$sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
@ -1288,11 +1346,10 @@ class LeadsController extends BaseController
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
// Set column width based on max content length (adjusted for padding)
|
||||
// // Set column width based on max content length (adjusted for padding)
|
||||
$sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2);
|
||||
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 5);
|
||||
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2);
|
||||
// $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2);
|
||||
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.6);
|
||||
|
||||
// $rowNumber += 2;
|
||||
|
||||
@ -1334,9 +1391,13 @@ class LeadsController extends BaseController
|
||||
]);
|
||||
|
||||
$sheet->mergeCells($mergeRange);
|
||||
$rowNumber_for_remove_quote_asked = $rowNumber;
|
||||
$rowNumber = $rowNumber + 1;
|
||||
|
||||
$subHeaderRow = $rowNumber + 1;
|
||||
if($type == 2){
|
||||
$subHeaderRow = $rowNumber + 1;
|
||||
}else{
|
||||
$subHeaderRow = $rowNumber_for_remove_quote_asked;
|
||||
}
|
||||
$columnLetter = 'A';
|
||||
|
||||
foreach ($headers as $header) {
|
||||
@ -1377,9 +1438,12 @@ class LeadsController extends BaseController
|
||||
|
||||
// Add subheaders
|
||||
foreach ($header['subHeaders'] as $subHeader) {
|
||||
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
|
||||
|
||||
if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C" && $columnLetter != "D") {
|
||||
if($type == 2){
|
||||
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
|
||||
}
|
||||
|
||||
if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C") {
|
||||
$sheet->getColumnDimension($columnLetter)->setWidth(35);
|
||||
} else {
|
||||
$sheet->getColumnDimension('A')->setWidth(10);
|
||||
@ -1498,6 +1562,51 @@ class LeadsController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//set imgage and align the row and column
|
||||
// Kint::dump($columnLetter);
|
||||
if($type == 2){
|
||||
$columnLetter_img = $this->getPreviousColumn($columnLetter, 2);
|
||||
}else{
|
||||
$columnLetter_img = $this->getPreviousColumn($columnLetter);
|
||||
}
|
||||
// dd($columnLetter_img);
|
||||
|
||||
$company_name = $this->getPreviousColumn($columnLetter_img);
|
||||
$mergeRange1 = "A1:{$company_name}1";
|
||||
$sheet->mergeCells($mergeRange1);
|
||||
|
||||
$rowCount = count($lead_data);
|
||||
for ($i = 2; $i <= $rowCount + 1; $i++) {
|
||||
$mergeRange1 = "C{$i}:{$columnLetter_img}{$i}";
|
||||
$sheet->mergeCells($mergeRange1);
|
||||
$sheet->getStyle($mergeRange1)->applyFromArray([
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'color' => ['argb' => 'FF000000'], // Black color
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$sheet->getColumnDimension($columnLetter_img)->setWidth(40);
|
||||
$sheet->getRowDimension(1)->setRowHeight(40); // Adjust as needed
|
||||
|
||||
$drawing = new Drawing();
|
||||
$path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path
|
||||
$drawing->setPath($path);
|
||||
$drawing->setCoordinates("{$columnLetter_img}1"); // Set position in column B
|
||||
$drawing->setHeight(35); // Adjust image height
|
||||
|
||||
// Center align the image in the cell
|
||||
$drawing->setOffsetX(110); // Adjust horizontal offset
|
||||
$drawing->setOffsetY(10); // Adjust vertical offset
|
||||
$drawing->setWorksheet($sheet);
|
||||
|
||||
//end
|
||||
|
||||
|
||||
// Auto-size columns
|
||||
// foreach ($sheet->getColumnIterator() as $column) {
|
||||
// $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true);
|
||||
@ -1535,7 +1644,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
$lastRow = count($lead_data) + 1;
|
||||
$leadRange = "A1:C{$lastRow}";
|
||||
$leadRange = "A1:{$columnLetter_img}{$lastRow}";
|
||||
|
||||
$sheet->getStyle($leadRange)->applyFromArray([
|
||||
'borders' => [
|
||||
@ -1546,7 +1655,7 @@ class LeadsController extends BaseController
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
// Set filename
|
||||
$string = ($type == 2) ? 'QCR' : 'RFQ';
|
||||
@ -1554,15 +1663,14 @@ class LeadsController extends BaseController
|
||||
$next_year = $current_year + 1;
|
||||
$policy_year = "$current_year-$next_year";
|
||||
|
||||
if (!empty($rfq_data['policy_end_date'])){
|
||||
$policy_expiry = strtotime($lead_data['policy_end_date']);
|
||||
if (!empty($rfq_data['policy_end_date'])) {
|
||||
|
||||
$formatted_policy = date("d-m-Y",$policy_expiry);
|
||||
$policy_expiry = strtotime($rfq_data['policy_end_date']);
|
||||
$formatted_policy = date("d-m-Y", $policy_expiry);
|
||||
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '(Due On ' . $formatted_policy . ')' . '.xlsx';
|
||||
} else {
|
||||
|
||||
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" .$policy_year.'(Due On '.$formatted_policy . ')' .'.xlsx';
|
||||
|
||||
}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';
|
||||
}
|
||||
|
||||
|
||||
@ -1658,7 +1766,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
|
||||
@ -2060,17 +2168,19 @@ class LeadsController extends BaseController
|
||||
->where('leads.id', $lead_id)
|
||||
->first();
|
||||
|
||||
// log_message('error', 'Lead Data' . json_encode($lead_data));
|
||||
// print_r($lead_data ); die;
|
||||
|
||||
$cc_mails = [];
|
||||
$bcc_mails = [];
|
||||
|
||||
//get CC Mails
|
||||
if ($recipient_type == 'internal' || $recipient_type == 'placement' || $recipient_type == 'insurer' || $recipient_type == 'client') {
|
||||
if ($recipient_type == 'internal' || $recipient_type == 'insurer' || $recipient_type == 'client') {
|
||||
|
||||
$cc_data = isset($params['cc']) ? $params['cc'] : "";
|
||||
$param_cc_mail = json_decode($cc_data, true);
|
||||
|
||||
|
||||
if (isset($param_cc_mail) && is_array($param_cc_mail) && count($param_cc_mail) > 0) {
|
||||
// Fetch user data where ID is in the param_cc_mail array
|
||||
$userData = $this->userModel
|
||||
@ -2094,6 +2204,8 @@ class LeadsController extends BaseController
|
||||
// Handle case where param_cc_mail is not valid
|
||||
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
|
||||
}
|
||||
}else if($recipient_type == 'placement'){
|
||||
$cc_mails = isset($params['cc']) ? json_decode($params['cc'], true) : "";
|
||||
}
|
||||
|
||||
//get BCC Mails
|
||||
@ -2161,6 +2273,7 @@ class LeadsController extends BaseController
|
||||
$result = $file_info['filePath'];
|
||||
// return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200);
|
||||
}
|
||||
|
||||
// print_rr($result); die;
|
||||
// print_rr($file_info);
|
||||
// $file_path = WRITEPATH."uploads/excel/sample/correction.xls";
|
||||
@ -2179,23 +2292,18 @@ class LeadsController extends BaseController
|
||||
//get recipient address
|
||||
if ($recipient_type == 'insurer' || $recipient_type == 'placement') {
|
||||
|
||||
// print_r($recipient_mail); die;
|
||||
|
||||
$recipient_data = $this->levelContactModel
|
||||
->where(['contact_type' => 'insurer', 'is_active' => 1])
|
||||
->whereIn('id', $recipient_mail)
|
||||
->findAll();
|
||||
|
||||
// print_r($recipient_data); die;
|
||||
|
||||
} else if ($recipient_type == 'client') {
|
||||
|
||||
$mailIDS = explode(',',$params['contact_mail']);
|
||||
$mailIDS = explode(',', $params['contact_mail']);
|
||||
$recipient_data = [];
|
||||
foreach ($mailIDS as $mail){
|
||||
foreach ($mailIDS as $mail) {
|
||||
$recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail];
|
||||
}
|
||||
|
||||
} else {
|
||||
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
|
||||
}
|
||||
@ -2221,9 +2329,9 @@ class LeadsController extends BaseController
|
||||
foreach ($recipient_data as $recipient) {
|
||||
|
||||
$message = $original_message;
|
||||
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message);
|
||||
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message);
|
||||
$message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message);
|
||||
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'] != "" ? $recipient['name'] :" ", $message);
|
||||
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'] != "" ? $lead_data['client_name'] : "", $message);
|
||||
$message = str_replace("{{POLICY_LONG_NAME}}",$lead_data['long_name'] != ""? $lead_data['long_name'] : "", $message);
|
||||
$message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message);
|
||||
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--';
|
||||
|
||||
@ -2250,16 +2358,54 @@ class LeadsController extends BaseController
|
||||
$data = [
|
||||
'proposel_data' => json_encode($lead_update_data),
|
||||
'status' => 'won',
|
||||
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'),
|
||||
'payment_date' => change_date_format($params['payment_date'], 'd/m/Y', 'Y-m-d'),
|
||||
'utr_no' => $params['utr_no'],
|
||||
'is_cd' => $params['is_cd'],
|
||||
'premium_amount' => $params['premium_amount'],
|
||||
'total_amount' => $params['total_amount'],
|
||||
'cd_amount' => $params['cd_amount'],
|
||||
'placement_date' => date('Y-m-d', strtotime($params['placement_date']) ?? "") ?? null,
|
||||
'payment_date' => date('Y-m-d', strtotime($params['payment_date'] ?? "")) ?? null,
|
||||
'utr_no' => $params['utr_no'] ?? null,
|
||||
'is_cd' => $params['is_cd'] ?? null ,
|
||||
'premium_amount' => $params['premium_amount'] ?? null,
|
||||
'total_amount' => $params['total_amount'] ?? null,
|
||||
'cd_amount' => $params['cd_amount'] ?? null,
|
||||
'no_of_installment' => $params['no_of_installment'] ?? null,
|
||||
'is_installment' => $params['is_installment'] ?? null,
|
||||
];
|
||||
|
||||
$this->leadsModel->where('id', $lead_id)->set($data)->update();
|
||||
|
||||
if(isset($params['installments']) && !empty($params['installments'])){
|
||||
|
||||
$installment_data = json_decode($params['installments'], true);
|
||||
if(!empty($installment_data)){
|
||||
foreach ($installment_data as $key => $value) {
|
||||
$value['payment_date'] = !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{
|
||||
$this->leadInstallmentPaymentDetails->insert($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($recipient_type == 'client') {
|
||||
|
||||
$this->leadsModel
|
||||
->where('id', $lead_id)
|
||||
->whereNotIn('status', ['lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections'])
|
||||
->set(['status' => "qcr_sent"])
|
||||
->update();
|
||||
}
|
||||
|
||||
if ($recipient_type == 'insurer') {
|
||||
|
||||
$this->leadsModel
|
||||
->where('id', $lead_id)
|
||||
->whereNotIn('status', ['qcr_created', 'qcr_sent', 'lost', 'co_insurer_pending', 'won', 'completed_with_corrections', 'completed_without_corrections'])
|
||||
->set(['status' => "rfq_sent"])
|
||||
->update();
|
||||
}
|
||||
|
||||
//delete attachment file
|
||||
@ -2849,7 +2995,7 @@ class LeadsController extends BaseController
|
||||
$value = $cellData['display_content'] ?? '';
|
||||
|
||||
// Skip unwanted keys
|
||||
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Quote Asked') {
|
||||
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Sum Insured' || $subth === 'Fidelity Limit') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2934,13 +3080,17 @@ class LeadsController extends BaseController
|
||||
$current_year = date('Y');
|
||||
$next_year = $current_year + 1;
|
||||
$policy_year = "$current_year-$next_year";
|
||||
$page_name = $page_name == "QCR" ? "Quote Comparison Report" : $page_name;
|
||||
$log_path = base_url() . '/public/assets/images/Nhance-Logo-Final.png';
|
||||
// $log_path ='https://venbait.in/nhance/dev/public/assets/images/Nhance-Logo-Final.png';
|
||||
// dd($log_path);
|
||||
|
||||
$policy_expiry = strtotime($lead_data['policy_end_date']);
|
||||
|
||||
$formatted_policy = date("d-m-Y",$policy_expiry);
|
||||
$formatted_policy = date("d-m-Y", $policy_expiry);
|
||||
$logged_user_id = get_session_userid();
|
||||
|
||||
$logged_user_data = $this->userModel->where("id",$logged_user_id)->where("is_active",1)->first();
|
||||
$logged_user_data = $this->userModel->where("id", $logged_user_id)->where("is_active", 1)->first();
|
||||
|
||||
if ($lead_data) {
|
||||
|
||||
@ -2951,11 +3101,12 @@ class LeadsController extends BaseController
|
||||
$message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message);
|
||||
$message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message);
|
||||
$message = str_replace("{{POLICY_YEAR}}", $policy_year, $message);
|
||||
$message = str_replace("{{POLICY_END_DATE}}"," (Due On ".$formatted_policy.")",$message);
|
||||
$message = str_replace("{{POLICY_END_DATE}}", " (Due On " . $formatted_policy . ")", $message);
|
||||
|
||||
$message = str_replace("{{LOGGED_USER_NAME}}",ucfirst($logged_user_data['first_name'])." ".ucfirst($logged_user_data['last_name']),$message);
|
||||
$message = str_replace("{{LOGGED_USER_EMAIL}}",$logged_user_data['email'],$message);
|
||||
$message = str_replace("{{LOGGED_USER_MOBILE}}",$logged_user_data['mobile'],$message);
|
||||
$message = str_replace("{{LOGGED_USER_NAME}}", ucfirst($logged_user_data['first_name']) . " " . ucfirst($logged_user_data['last_name']), $message);
|
||||
$message = str_replace("{{LOGGED_USER_EMAIL}}", $logged_user_data['email'], $message);
|
||||
$message = str_replace("{{LOGGED_USER_MOBILE}}", $logged_user_data['mobile'], $message);
|
||||
$message = str_replace("{{LOGO_PATH}}", $log_path, $message);
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
@ -3065,7 +3216,6 @@ class LeadsController extends BaseController
|
||||
$data['lead_edit_data']['claims_details_html'] = "";
|
||||
}
|
||||
}
|
||||
|
||||
// dd($data);
|
||||
|
||||
return $this->loadLayout('leads_form_handler', $data);
|
||||
@ -3098,6 +3248,7 @@ class LeadsController extends BaseController
|
||||
3 => 'rfq/gmc',
|
||||
4 => 'rfq/gmc',
|
||||
5 => 'rfq/gmc',
|
||||
17=> 'rfq/burglary',
|
||||
22 => 'rfq/car',
|
||||
23 => 'rfq/cpm',
|
||||
24 => 'rfq/cyber_crime',
|
||||
@ -3237,11 +3388,11 @@ class LeadsController extends BaseController
|
||||
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2);
|
||||
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2);
|
||||
|
||||
$rowNumber += 2;
|
||||
$rowNumber += 1;
|
||||
//Policy Registration
|
||||
if (!empty($policy_registration_data)) {
|
||||
foreach ($policy_registration_data as $key => $value) {
|
||||
|
||||
// kint::dump($value);
|
||||
$startRow = $rowNumber; // Track where the block starts
|
||||
|
||||
// Title Row
|
||||
@ -3328,6 +3479,24 @@ class LeadsController extends BaseController
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
if (isset($value['policyDetails']) && !empty($value['policyDetails'])) {
|
||||
// Type of Business
|
||||
$sheet->mergeCells("A{$rowNumber}:B{$rowNumber}");
|
||||
$sheet->setCellValue("A{$rowNumber}", "Terrorism");
|
||||
$sheet->setCellValue("C{$rowNumber}", ucfirst($value['policyDetails']['terrorism'] ?? 'No'));
|
||||
|
||||
$sheet->getStyle("A{$rowNumber}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => [
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
$rowNumber++;
|
||||
|
||||
}
|
||||
|
||||
$endRow = $rowNumber - 1; // Block ends at previous row
|
||||
|
||||
// Apply border to the whole block
|
||||
@ -3340,8 +3509,9 @@ class LeadsController extends BaseController
|
||||
],
|
||||
]);
|
||||
|
||||
$rowNumber += 2; // Add space before the next block
|
||||
$rowNumber += 1; // Add space before the next block
|
||||
}
|
||||
// die();
|
||||
}
|
||||
|
||||
//Table Data
|
||||
@ -3445,6 +3615,18 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// For the subheader row, merge B and C and set the value
|
||||
$sheet->setCellValue("B{$subHeaderRow}", "Sum Insured");
|
||||
$sheet->mergeCells("B{$subHeaderRow}:C{$subHeaderRow}");
|
||||
$sheet->getStyle("B{$subHeaderRow}:C{$subHeaderRow}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => [
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
// Apply border to the header range
|
||||
$prevColumn4 = $this->getPreviousColumn($columnLetter);
|
||||
$headerRange = "A{$rowNumber}:" . "{$prevColumn4}" . "{$subHeaderRow}";
|
||||
@ -3461,7 +3643,9 @@ class LeadsController extends BaseController
|
||||
$sheet->getRowDimension($rowNumber)->setRowHeight(25); // Header row height
|
||||
$sheet->getRowDimension($subHeaderRow)->setRowHeight(20); // Subheader row height
|
||||
|
||||
$rowNumber = $subHeaderRow + 2;
|
||||
// $rowNumber = $subHeaderRow + 2;
|
||||
$rowNumber = $subHeaderRow + 1;
|
||||
|
||||
$column_data = $data['table_data']['data'];
|
||||
// dd($column_data);
|
||||
$serial_no = 1;
|
||||
@ -3749,7 +3933,7 @@ class LeadsController extends BaseController
|
||||
$row['data'] = array_filter(
|
||||
$row['data'],
|
||||
function ($item) {
|
||||
return in_array($item['subth'], ['Quote asked', '-']);
|
||||
return in_array($item['subth'], ['Sum Insured', '-',"Liability Limit"]);
|
||||
}
|
||||
);
|
||||
|
||||
@ -3838,7 +4022,7 @@ class LeadsController extends BaseController
|
||||
if ($subHeader === $insurer) {
|
||||
$headerData[] = [
|
||||
'parentHeader' => $header['parentHeader'],
|
||||
'subHeaders' => ['Quote asked', $subHeader]
|
||||
'subHeaders' => ['Sum Insured', $subHeader]
|
||||
];
|
||||
break 2; // Exit both loops after match is found
|
||||
}
|
||||
@ -3871,8 +4055,8 @@ class LeadsController extends BaseController
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
// Include Proposal with Quote Asked
|
||||
if ($item['parentth'] === $proposal && $item['subth'] === "Quote asked") {
|
||||
// Include Proposal with Sum Insured
|
||||
if ($item['parentth'] === $proposal && ($item['subth'] === "Sum Insured" || $item['subth'] === "Liability Limit")) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
@ -3919,14 +4103,86 @@ class LeadsController extends BaseController
|
||||
$lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first();
|
||||
|
||||
if ($lead_file) {
|
||||
$attachments[] = [
|
||||
'fileName' => $lead_file['file_name'],
|
||||
'filePath' => $lead_file_path . $lead_file['file_name']
|
||||
];
|
||||
|
||||
$fullPath = $lead_file_path . $lead_file['file_name'];
|
||||
|
||||
if (file_exists($fullPath) && !empty($fileName)) {
|
||||
$attachments[] = [
|
||||
'fileName' => $lead_file['file_name'],
|
||||
'filePath' => $fullPath
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -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";
|
||||
@ -1829,4 +1829,22 @@ class MasterController extends AdminController
|
||||
echo "################################################################\n\n";
|
||||
}
|
||||
|
||||
public function sendMutipleToEmails()
|
||||
{
|
||||
|
||||
$message = '<style>body{font-family:Arial,sans-serif;color:#333;line-height:1.6;margin:0;padding:0}.email-container{width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9}.header{background-color:#4a90e2;color:#fff;padding:15px;text-align:center}.header h1{margin:0;font-size:24px}.content{padding:20px;background-color:#fff}.content h2{color:#4a90e2;font-size:20px;margin-top:0}.content p{margin:10px 0}.details-table{width:100%;border-collapse:collapse;margin-top:20px}.details-table td,.details-table th{border:1px solid #ddd;padding:10px;text-align:left}.details-table th{background-color:#f2f2f2}.footer{margin-top:20px;font-size:12px;color:#777;text-align:center}.attachment-note{margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic}</style><div class=email-container><div class=header><h1>Request for Quotation (RFQ)</h1></div><div class=content><h2>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2>RFQ Details</h2><table class=details-table><tr><th>Client name<td>{{CLIENT_NAME}}<tr><th>Coverage Type<td>{{POLICY_LONG_NAME}}<tr><th>Policy Start Date<td>{{POLICY_START_DATE}}<tr><th>Policy Duration<td>{{DURATION}}</table><div class=attachment-note>Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div class=footer><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
||||
$attachments = [
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
|
||||
["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 = 'venkateshraman786@gmail.com';
|
||||
$params = ['mail'=>$email_id];
|
||||
$multi_mails = ['venkateshraman786@gmail.com', 'gowtham.manavalan.la@gmail.com', 'venkatesh.r@venbainfotech.com'];
|
||||
$common = ['mail_type'=>'test_mail_cli'];
|
||||
$bcc = "vitvelz@gmail.com,velmurugan.s@venbainfotech.com,srinivas.saravanan@venbainfotech.com";
|
||||
$result = MailHelper::send_email(['mail' => $multi_mails, 'bcc'=>$bcc, 'params'=>$params,'subject' => 'Send Multiple " To " emails','message' => $message,'attachments' => $attachments,'common'=>$common]);
|
||||
dd($result);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -54,6 +54,8 @@ class TicketController extends BaseController
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
set_session_context('Ticket Master Controller');
|
||||
|
||||
|
||||
$this->ticketMasterModel = new TicketMasterModel();
|
||||
|
||||
@ -123,6 +125,7 @@ class TicketController extends BaseController
|
||||
'((CLAIM_FEEDBACK_FORM))' => 'claim_feedback_form',
|
||||
'((SETTLED_LETTER))' => 'settle_letter',
|
||||
'((APPROVED_LETTER))' => 'approved_letter',
|
||||
'((APPROVED_DESCRIBTION))' => 'approved_description',
|
||||
];
|
||||
$this->extraFields = [
|
||||
1 => ['non_id_reason'],
|
||||
@ -132,13 +135,13 @@ class TicketController extends BaseController
|
||||
5 => ['claim_number', 'registration_date'],
|
||||
7 => ['query_received_date'],
|
||||
8 => ['denial_reason','denial_date'],
|
||||
9 => ['approved_amount','approved_date', 'approved_letter'],
|
||||
9 => ['approved_amount','approved_date', 'approved_letter', "approved_description"],
|
||||
11 => ['utr_details', 'settled_date', 'settle_letter'],
|
||||
40 => ['approved_amount','approved_date', 'approved_letter'],
|
||||
40 => ['approved_amount','approved_date', 'approved_letter', "approved_description"],
|
||||
44 => ['utr_details', 'settled_date', 'settle_letter'],
|
||||
30 => ['approved_amount','approved_date', 'approved_letter'],
|
||||
30 => ['approved_amount','approved_date', 'approved_letter', "approved_description"],
|
||||
34 => ['utr_details', 'settled_date', 'settle_letter'],
|
||||
20 => ['approved_amount','approved_date', 'approved_letter'],
|
||||
20 => ['approved_amount','approved_date', 'approved_letter', "approved_description"],
|
||||
24 => ['utr_details', 'settled_date', 'settle_letter'],
|
||||
14 => ['return_remark', 'awb_no_courier_name'],
|
||||
48 => ['return_remark', 'awb_no_courier_name'],
|
||||
@ -173,6 +176,9 @@ class TicketController extends BaseController
|
||||
public function ticketList()
|
||||
{
|
||||
$data['ticket_type'] = $this->ticketType;
|
||||
$data['modeOFIntimate'] = $this->modeOFIntimate;
|
||||
$data['priorityType'] = $this->priorityType;
|
||||
$data['claimType'] = $this->claimType;
|
||||
if ($this->request->is('get')) {
|
||||
$data['page_name'] = "Claims";
|
||||
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
|
||||
@ -181,49 +187,75 @@ class TicketController extends BaseController
|
||||
return $this->loadLayout('ticket_search', $data);
|
||||
} else {
|
||||
|
||||
$data['ticket_data'] = $this->ticketSearch();
|
||||
$html = view('ticket_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
$isFromDashboard = $this->request->getPost("is_dashboard");
|
||||
|
||||
if (isset($isFromDashboard) && !empty($isFromDashboard)){
|
||||
$data['page_name'] = "Claims";
|
||||
if ($isFromDashboard == 1) {
|
||||
|
||||
$data['ticket_data'] = $this->ticketSearch(3);
|
||||
|
||||
}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();
|
||||
// dd($data);
|
||||
return $this->loadLayout('ticket_search', $data);
|
||||
|
||||
}
|
||||
else{
|
||||
$data['ticket_data'] = $this->ticketSearch();
|
||||
$html = view('ticket_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function ticketSearch($action = null)
|
||||
{
|
||||
{
|
||||
$db = db_connect();
|
||||
|
||||
$subquery = $db->table('ticket_history th')
|
||||
$subquery = $db->table('ticket_master tm')
|
||||
->select([
|
||||
'th.ticket_id',
|
||||
'tm.id AS ticket_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"
|
||||
WHEN DATEDIFF(
|
||||
CURDATE(),
|
||||
COALESCE(latest_history.created_at, tm.created_at)
|
||||
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||
WHEN DATEDIFF(
|
||||
CURDATE(),
|
||||
COALESCE(latest_history.created_at, tm.created_at)
|
||||
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||
WHEN DATEDIFF(
|
||||
CURDATE(),
|
||||
COALESCE(latest_history.created_at, tm.created_at)
|
||||
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||
ELSE 'Above 20 Days'
|
||||
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)
|
||||
->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, action 3 gets according to dashboard, action 4 gets according to ACM, action 5 tat
|
||||
if ($action == 1) {
|
||||
|
||||
$query = $db->table('ticket_master tm')
|
||||
@ -238,12 +270,63 @@ class TicketController extends BaseController
|
||||
'tm.tpa_no',
|
||||
'tm.emp_name',
|
||||
'tm.emp_code',
|
||||
'tm.relationship',
|
||||
'i.name AS insurer_name',
|
||||
'c.client_name',
|
||||
'tm.insured_name',
|
||||
'c.short_name',
|
||||
'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date',
|
||||
'COALESCE(tat_category.tat, "0-6 Days") AS tat'
|
||||
'COALESCE(tat_category.tat, "0-6 Days") AS tat',
|
||||
|
||||
'tm.claim_status_id',
|
||||
|
||||
'(SELECT first_name FROM user_profiles WHERE user_profiles.id = tm.acm_id) AS acm_name',
|
||||
'(SELECT name FROM insurers WHERE insurers.id = tm.insurer_id) AS insurer_name',
|
||||
'(SELECT name FROM tpa WHERE tpa.id = tm.tpa_id) AS tpa_name',
|
||||
|
||||
'tm.acm_id',
|
||||
'tm.insurer_id',
|
||||
'tm.tpa_id',
|
||||
'tm.client_policy_id',
|
||||
|
||||
'tm.policy_no',
|
||||
'tm.priority',
|
||||
'tm.relationship',
|
||||
'tm.emp_mobile',
|
||||
'tm.emp_mail',
|
||||
'tm.emp_personal_mail',
|
||||
'tm.mode_of_intimation',
|
||||
'tm.claim_type',
|
||||
'tm.hospital_name',
|
||||
'tm.doa',
|
||||
'tm.dod',
|
||||
'tm.claim_amount',
|
||||
'tm.pod_no',
|
||||
'tm.date_of_join',
|
||||
'tm.date_of_incep',
|
||||
'tm.dob',
|
||||
'tm.date_of_accident',
|
||||
'tm.date_of_death',
|
||||
'tm.date_of_intimat',
|
||||
'tm.si_amt',
|
||||
'tm.raised_date',
|
||||
'tm.registration_date',
|
||||
'tm.query_received_date',
|
||||
'tm.denial_date',
|
||||
'tm.approved_date',
|
||||
'tm.settled_date',
|
||||
'tm.denial_reason',
|
||||
'tm.approved_letter',
|
||||
'tm.approved_amount',
|
||||
'tm.utr_details',
|
||||
'tm.settle_letter',
|
||||
'tm.return_remark',
|
||||
'tm.cancel_remark',
|
||||
'tm.awb_no_courier_name',
|
||||
'tm.non_id_reason',
|
||||
'tm.pay_initiate_date',
|
||||
'tm.approved_description'
|
||||
|
||||
])
|
||||
->join('insurers i', 'i.id = tm.insurer_id AND i.is_active = 1', 'left')
|
||||
->join('clients c', 'c.id = tm.client_id AND c.is_active = 1', 'left')
|
||||
@ -252,56 +335,142 @@ class TicketController extends BaseController
|
||||
->where('tm.is_active', 1)
|
||||
->orderBy('tm.id', 'DESC');
|
||||
|
||||
$data = $query->get()->getResultArray();
|
||||
$data = $query->get()->getResultArray();
|
||||
|
||||
// dd(db_connect()->getLastQuery());
|
||||
|
||||
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 if ($action == 4){
|
||||
$acm_id = $this->request->getPost('ids');
|
||||
|
||||
// dd($acm_id);
|
||||
if (!empty($acm_id)) {
|
||||
$where = "tm.acm_id = $acm_id";
|
||||
} else {
|
||||
$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);
|
||||
// print_r($search_data); die()
|
||||
$where = [];
|
||||
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;
|
||||
}
|
||||
}
|
||||
// print_rr($where);
|
||||
$query = $db->table('ticket_master tm')
|
||||
->select([
|
||||
'tm.id',
|
||||
'tm.ticket_type_id',
|
||||
'tcs.claim_status AS status',
|
||||
'tm.claim_number AS claim_no',
|
||||
'tm.claim_status_id',
|
||||
'tm.is_head_approved',
|
||||
'tm.tpa_id',
|
||||
'tm.tpa_no',
|
||||
'tm.emp_name',
|
||||
'tm.emp_code',
|
||||
'i.name AS insurer_name',
|
||||
'c.client_name',
|
||||
'tm.insured_name',
|
||||
'c.short_name',
|
||||
'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date',
|
||||
'COALESCE(tat_category.tat, "0-6 Days") AS tat'
|
||||
])
|
||||
->join('insurers i', 'i.id = tm.insurer_id AND i.is_active = 1', 'left')
|
||||
->join('clients c', 'c.id = tm.client_id AND c.is_active = 1', 'left')
|
||||
->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1', 'left')
|
||||
->join("({$subquery->getCompiledSelect()}) tat_category", 'tm.id = tat_category.ticket_id', 'left')
|
||||
->where('tm.is_active', 1)
|
||||
->where($where)
|
||||
->orderBy('tm.id', 'DESC');
|
||||
|
||||
$data = $query->get()->getResultArray();
|
||||
// print_rr($data);
|
||||
// log_message('error',' Claims Master Data '.json_encode($data));die();
|
||||
// print_rr($data);die();
|
||||
|
||||
return $data;
|
||||
}
|
||||
$query = $db->table('ticket_master tm')
|
||||
->select([
|
||||
'tm.id',
|
||||
'tm.ticket_type_id',
|
||||
'tcs.claim_status AS status',
|
||||
'tm.claim_number AS claim_no',
|
||||
'tm.claim_status_id',
|
||||
'tm.is_head_approved',
|
||||
'tm.tpa_id',
|
||||
'tm.tpa_no',
|
||||
'tm.emp_name',
|
||||
'tm.emp_code',
|
||||
'tm.relationship',
|
||||
'i.name AS insurer_name',
|
||||
'c.client_name',
|
||||
'tm.insured_name',
|
||||
'c.short_name',
|
||||
'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date',
|
||||
'COALESCE(tat_category.tat, "0-6 Days") AS tat',
|
||||
|
||||
'(SELECT first_name FROM user_profiles WHERE user_profiles.id = tm.acm_id) AS acm_name',
|
||||
'(SELECT name FROM insurers WHERE insurers.id = tm.insurer_id) AS insurer_name',
|
||||
'(SELECT name FROM tpa WHERE tpa.id = tm.tpa_id) AS tpa_name',
|
||||
|
||||
'tm.claim_status_id',
|
||||
'tm.acm_id',
|
||||
'tm.insurer_id',
|
||||
'tm.tpa_id',
|
||||
'tm.client_policy_id',
|
||||
'tm.policy_no',
|
||||
'tm.priority',
|
||||
'tm.relationship',
|
||||
'tm.emp_mobile',
|
||||
'tm.emp_mail',
|
||||
'tm.emp_personal_mail',
|
||||
'tm.mode_of_intimation',
|
||||
'tm.claim_type',
|
||||
'tm.hospital_name',
|
||||
'tm.doa',
|
||||
'tm.dod',
|
||||
'tm.claim_amount',
|
||||
'tm.pod_no',
|
||||
'tm.date_of_join',
|
||||
'tm.date_of_incep',
|
||||
'tm.dob',
|
||||
'tm.date_of_accident',
|
||||
'tm.date_of_death',
|
||||
'tm.date_of_intimat',
|
||||
'tm.si_amt',
|
||||
'tm.raised_date',
|
||||
'tm.registration_date',
|
||||
'tm.query_received_date',
|
||||
'tm.denial_date',
|
||||
'tm.approved_date',
|
||||
'tm.settled_date',
|
||||
'tm.denial_reason',
|
||||
'tm.approved_letter',
|
||||
'tm.approved_amount',
|
||||
'tm.utr_details',
|
||||
'tm.settle_letter',
|
||||
'tm.return_remark',
|
||||
'tm.cancel_remark',
|
||||
'tm.awb_no_courier_name',
|
||||
'tm.non_id_reason',
|
||||
'tm.pay_initiate_date',
|
||||
'tm.approved_description'
|
||||
|
||||
])
|
||||
->join('insurers i', 'i.id = tm.insurer_id AND i.is_active = 1', 'left')
|
||||
->join('clients c', 'c.id = tm.client_id AND c.is_active = 1', 'left')
|
||||
->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1', 'left')
|
||||
->join("({$subquery->getCompiledSelect()}) tat_category", 'tm.id = tat_category.ticket_id', 'left')
|
||||
->where('tm.is_active', 1)
|
||||
->where($where)
|
||||
->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();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function ticket_form($ticket_type)
|
||||
@ -806,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----------------------------------------------------------------------------------------------
|
||||
@ -868,24 +1054,24 @@ class TicketController extends BaseController
|
||||
}
|
||||
|
||||
// Construct Mail Data
|
||||
$mailData[] = [
|
||||
'mail' => $ticket_data['emp_mail'],
|
||||
$mailData = [
|
||||
'mail' => [$ticket_data['emp_mail'], $ticket_data['emp_personal_mail'] ?? ""],
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'cc' => $ticket_data['common_mails'] ?? '',
|
||||
'attachments' => []
|
||||
];
|
||||
|
||||
// if the employee personal mail is not empty then send the mail to the employee personal mail
|
||||
if(!empty($ticket_data['emp_personal_mail'])){
|
||||
$mailData[] = [
|
||||
'mail' => $ticket_data['emp_personal_mail'],
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'cc' => $ticket_data['common_mails'] ?? '',
|
||||
'attachments' => []
|
||||
];
|
||||
}
|
||||
// // if the employee personal mail is not empty then send the mail to the employee personal mail
|
||||
// if(!empty($ticket_data['emp_personal_mail'])){
|
||||
// $mailData[] = [
|
||||
// 'mail' => [$ticket_data['emp_mail'], $ticket_data['emp_personal_mail'] ?? ""],
|
||||
// 'subject' => $subject,
|
||||
// 'message' => $message,
|
||||
// 'cc' => $ticket_data['common_mails'] ?? '',
|
||||
// 'attachments' => []
|
||||
// ];
|
||||
// }
|
||||
|
||||
// print_r($mailData); die;
|
||||
|
||||
@ -903,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") {
|
||||
@ -976,28 +1166,28 @@ class TicketController extends BaseController
|
||||
$this->myLogger->logme('error', "Fetched ACM emails");
|
||||
|
||||
|
||||
if(!empty($ticket_data['emp_personal_mail'])){
|
||||
// if(!empty($ticket_data['emp_personal_mail'])){
|
||||
|
||||
$this->myLogger->logme('error', "Send employee personal mail start");
|
||||
// $this->myLogger->logme('error', "Send employee personal mail start");
|
||||
|
||||
$emailPersonalData = [
|
||||
'mail' => $ticket_data['emp_personal_mail'],
|
||||
'subject' => $mail_data['mail_subject'],
|
||||
'message' => $mail_data['mail_content'],
|
||||
'common' => [],
|
||||
'cc' => $acm_mails['common_mails'],
|
||||
'attachments' => []
|
||||
];
|
||||
// $emailPersonalData = [
|
||||
// 'mail' => $ticket_data['emp_personal_mail'],
|
||||
// 'subject' => $mail_data['mail_subject'],
|
||||
// 'message' => $mail_data['mail_content'],
|
||||
// 'common' => [],
|
||||
// 'cc' => $acm_mails['common_mails'],
|
||||
// 'attachments' => []
|
||||
// ];
|
||||
|
||||
$this->sendTrigger($emailPersonalData);
|
||||
// $this->sendTrigger($emailPersonalData);
|
||||
|
||||
$this->myLogger->logme('error', "Send employee personal mail successfully");
|
||||
}else{
|
||||
$this->myLogger->logme('error', "Send employee personal mail is empty");
|
||||
}
|
||||
// $this->myLogger->logme('error', "Send employee personal mail successfully");
|
||||
// }else{
|
||||
// $this->myLogger->logme('error', "Send employee personal mail is empty");
|
||||
// }
|
||||
|
||||
$emailData = [
|
||||
'mail' => $mail_data['emp_mail'],
|
||||
'mail' => [$mail_data['emp_mail'], $ticket_data['emp_personal_mail'] ?? ""],
|
||||
'subject' => $mail_data['mail_subject'],
|
||||
'message' => $mail_data['mail_content'],
|
||||
'common' => [],
|
||||
@ -1019,10 +1209,11 @@ class TicketController extends BaseController
|
||||
if (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 1) {
|
||||
$mail_content = $this->constructMailContent($ticket_id);
|
||||
// print_r($mail_content); die;
|
||||
foreach ($mail_content as $key => $value) {
|
||||
$mail_responce = $this->sendTrigger($value);
|
||||
$this->myLogger->logme('error', '{data} - Auto Mail Sent, Successfully', ['data' => $key + 1]);
|
||||
}
|
||||
// foreach ($mail_content as $key => $value) {
|
||||
$mail_responce = $this->sendTrigger($mail_content);
|
||||
// $this->myLogger->logme('error', '{data} - Auto Mail Sent, Successfully', ['data' => $key + 1]);
|
||||
$this->myLogger->logme('error', 'Auto Mail Sent, Successfully');
|
||||
// }
|
||||
} elseif (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 0) {
|
||||
$this->myLogger->logme('error', 'Auto Mail Not Sent, Reason: Automail Not Enabled');
|
||||
} else {
|
||||
@ -1235,7 +1426,8 @@ class TicketController extends BaseController
|
||||
if ($received_data['report_type'] == "acc_manager_wise_status"){
|
||||
$viewData['policy_type'] = $received_data['policy_type'];
|
||||
$viewData['account_manager_wise_data'] = $this->ticketMasterModel->accountManagerWiseReport($policy_type,$fromDate,$toDate);
|
||||
// print_rr($viewData);
|
||||
|
||||
// print_rr($viewData);die();
|
||||
if ($policy_type == 1){
|
||||
$viewData['column_order'] = [
|
||||
'ACM_NAME', 'ID NOT GENERATED', 'NON ID', 'CDA', 'INFORMATION REQUIRED',
|
||||
@ -1253,6 +1445,7 @@ class TicketController extends BaseController
|
||||
$ordered_data[] = $temp;
|
||||
}
|
||||
$viewData['tpa_wise_data'] = $ordered_data;
|
||||
// print_rr($viewData);die();
|
||||
$html = view('claims_report_acc_manager_wise', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}else{
|
||||
@ -1271,6 +1464,7 @@ class TicketController extends BaseController
|
||||
$ordered_data[] = $temp;
|
||||
}
|
||||
$viewData['tpa_wise_data'] = $ordered_data;
|
||||
// print_rr($viewData);die();
|
||||
$html = view('claims_report_acc_manager_wise', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
@ -1282,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
|
||||
@ -1296,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);
|
||||
@ -1303,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);
|
||||
}
|
||||
@ -1533,7 +1731,7 @@ class TicketController extends BaseController
|
||||
|
||||
$sent_message_data['ticket_id'] = $ticket_id;
|
||||
$sent_message_data['sender'] = 'staff';
|
||||
$sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
|
||||
$sent_message_data['emp_mail'] = isset($mail_sent_status->data->params->mail[0]) ? $mail_sent_status->data->params->mail[0] ?? null : $mail_sent_status->data->params->mail ?? null;
|
||||
$sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
|
||||
$sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
|
||||
|
||||
@ -1549,7 +1747,7 @@ class TicketController extends BaseController
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', "Failed to send Mail :$ticket_id ");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1634,4 +1832,85 @@ class TicketController extends BaseController
|
||||
$this->loadLayout("ticket_feedback_list",$data);
|
||||
}
|
||||
|
||||
public function getMoreInfo() {
|
||||
$ticket_id = $this->request->getPost('ticket_id');
|
||||
$this->myLogger->logme("error", "Ticket ID : " . $ticket_id);
|
||||
|
||||
$fields = $this->extraFields;
|
||||
$data_to_send = [];
|
||||
|
||||
// Get ticket data
|
||||
$ticket_data = $this->ticketMasterModel->where("id", $ticket_id)->where("is_active", 1)->first();
|
||||
|
||||
// Query previous status
|
||||
$ticket_previous_status = $this->ticketMasterModel
|
||||
->select("th.old_value, tcs.claim_status")
|
||||
->join("ticket_history th", "th.ticket_id = ticket_master.id AND th.field_name = 'claim_status_id' AND th.is_active = 1")
|
||||
->join("ticket_claim_status tcs", "tcs.id = th.old_value AND tcs.is_active = 1")
|
||||
->where("ticket_master.is_active", 1)
|
||||
->where("ticket_master.id", $ticket_id)
|
||||
->groupBy("th.old_value, tcs.claim_status")
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
// Loop through previous status and gather the required data
|
||||
foreach ($ticket_previous_status as $status) {
|
||||
$this->myLogger->logme("error", "Status : " . json_encode($status));
|
||||
|
||||
if (isset($fields[$status['old_value']])) {
|
||||
$field = $fields[$status['old_value']];
|
||||
|
||||
// Ensure claim_status is a scalar value (string or int)
|
||||
$claim_status = (string)$status['claim_status']; // Cast to string to avoid issues
|
||||
|
||||
// Initialize claim_status if it doesn't exist in the array
|
||||
if (!isset($data_to_send[$claim_status])) {
|
||||
$data_to_send[$claim_status] = [];
|
||||
}
|
||||
|
||||
// Handle case where $field is an array
|
||||
if (is_array($field)) {
|
||||
foreach ($field as $f) {
|
||||
// Check if the field exists in the ticket data
|
||||
$data_to_send[$claim_status][$f] = isset($ticket_data[$f]) ? $ticket_data[$f] : null;
|
||||
|
||||
// Check if the field contains a date and format it
|
||||
if ($this->isDate($data_to_send[$claim_status][$f])) {
|
||||
$data_to_send[$claim_status][$f] = date('d-m-Y', strtotime($data_to_send[$claim_status][$f]));
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Data for field {$f}: " . json_encode($data_to_send[$claim_status][$f]));
|
||||
}
|
||||
} else {
|
||||
// If field is not an array, handle it as a single field
|
||||
$data_to_send[$claim_status][$field] = isset($ticket_data[$field]) ? $ticket_data[$field] : null;
|
||||
|
||||
// Check if the field contains a date and format it
|
||||
if ($this->isDate($data_to_send[$claim_status][$field])) {
|
||||
$data_to_send[$claim_status][$field] = date('d-m-Y', strtotime($data_to_send[$claim_status][$field]));
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', "Total data: " . json_encode($data_to_send));
|
||||
|
||||
// Send response based on data availability
|
||||
if (!empty($data_to_send)) {
|
||||
return $this->respond(['status' => true, 'data' => $data_to_send], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
}
|
||||
|
||||
private function isDate($value, $format = 'Y-m-d') {
|
||||
// Check if the value is a valid date string (basic validation)
|
||||
$date = \DateTime::createFromFormat($format, $value);
|
||||
return $date && $date->format($format) === $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
87
app/Filters/AuthClientApi.php
Normal file
87
app/Filters/AuthClientApi.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
use App\Helpers\ClientTokenHelper;
|
||||
use App\Models\ClientApiModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
class AuthClientApi implements FilterInterface
|
||||
{
|
||||
use ResponseTrait;
|
||||
protected $clientAPI;
|
||||
protected $myLogger;
|
||||
public function __construct()
|
||||
{
|
||||
set_session_context('External API Filter');
|
||||
$this->clientAPI = new ClientApiModel();
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
}
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$response = service('response');
|
||||
try {
|
||||
|
||||
$authHeader = $request->getHeaderLine('Authorization');
|
||||
|
||||
// Check if header exists
|
||||
if (empty($authHeader)) {
|
||||
$this->myLogger->log('error', 'Authorization header missing');
|
||||
return $response->setJson(['status' => "Failure", 'error' => ['message'=>'Authorization header missing','code'=> 401]], 401);
|
||||
}
|
||||
|
||||
if(!str_contains($authHeader, 'Bearer ')){
|
||||
$this->myLogger->log('error', 'Authorization Bearer missing');
|
||||
return $response->setJson(['status' => "Failure", 'error' => ['message'=>'Invalid Authorization header','code'=>401]], 401);
|
||||
}
|
||||
|
||||
$token = str_replace('Bearer ', '', $authHeader);
|
||||
if (empty($token)) {
|
||||
|
||||
$this->myLogger->log('error', 'Empty Token');
|
||||
return $response->setJson(['status' => "Failure", 'error' => ['message'=>'Invalid Token Format','code'=> 401]], 401);
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
$client_id = ClientTokenHelper::extractClientId($token);
|
||||
|
||||
}catch(\Exception $e){
|
||||
|
||||
$this->myLogger->log('error', 'Invalid Client Token Format');
|
||||
|
||||
return $response->setJson(['status' => "Failure", 'error' => 'Invalid Token Format'], 401);
|
||||
}
|
||||
$client = $this->clientAPI->where('client_id', $client_id)->where("is_active", 1)->where("api_access", 1)->first();
|
||||
|
||||
// Client validation
|
||||
if (!$client) {
|
||||
$this->myLogger->log('error', 'Client Not Found or Unauthorized');
|
||||
return $response->setJson(['status' => "Failure", 'error' => ['message' => 'Client not found or unauthorized','code'=>'403']], 403);
|
||||
}
|
||||
|
||||
if (hash_equals($client['client_token'], $token)) {
|
||||
$this->myLogger->log('error', 'Access Granted For Client : '.$client_id);
|
||||
return true;
|
||||
} else {
|
||||
$this->myLogger->log('error', 'Invalid Token given for client : '.$client_id);
|
||||
return $response->setJson(['status' => "Failure", 'error' => ['message' => 'Invalid token','code'=>401]
|
||||
], 401);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', 'Error in ClientAPIController:validateToken - ' . $e->getMessage());
|
||||
return $response->setJson(['status' => "Failure", 'error' => ['message'=>'Internal Server Error','code'=> 500]], 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// Do something here
|
||||
}
|
||||
}
|
||||
|
||||
100
app/Helpers/ClientQueryHelper.php
Normal file
100
app/Helpers/ClientQueryHelper.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\ClientPolicyModel;
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\TicketMasterModel;
|
||||
|
||||
|
||||
class ClientQueryHelper{
|
||||
|
||||
protected $clientPolicy;
|
||||
protected $empModel;
|
||||
protected $empPolicyModel;
|
||||
protected $claimModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->clientPolicy = new ClientPolicyModel();
|
||||
$this->empModel = new EmployeeModel();
|
||||
$this->empPolicyModel = new EmployeePolicyModel();
|
||||
$this->claimModel = new TicketMasterModel();
|
||||
}
|
||||
|
||||
public function clientPolicyMaster($client_id){
|
||||
|
||||
return $this->clientPolicy->select("client_policy.id as policy_ref_no,client_policy.client_branch_id as branch_ref_no,client_branch.branch_code,
|
||||
client_policy.insurer_id as insurer_ref_no,insurers.name as insurer,client_policy.policy_type_id,policy_type.policy_type,
|
||||
client_policy.tpa_id as tpa_ref_no,client_policy.policy_start_date,client_policy.policy_end_date,client_policy.policy_no,client_policy.policy_status")
|
||||
->join('insurers', 'client_policy.insurer_id = insurers.id and insurers.is_active = 1')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id and policy_type.is_active = 1')
|
||||
->join('client_branch', 'client_policy.client_branch_id = client_branch.id and client_branch.is_active = 1')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function sendEmpMaster($client_id,$where,$limit,$offset = 0)
|
||||
{
|
||||
|
||||
return $this->empModel->select("id as ref_no,name,emp_code,
|
||||
relationship,emp_status,mobile,email_corporate,
|
||||
change_event,dob,doj,band,gender")
|
||||
->where("is_active",1)
|
||||
->where("client_id", $client_id)
|
||||
->where($where)
|
||||
->whereNotIn('emp_status', ['truncated'],)
|
||||
->orderBy("id")
|
||||
->limit($limit,$offset)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
}
|
||||
|
||||
public function sendEmpPolicies($emp_id)
|
||||
{
|
||||
return $this->empPolicyModel->select("id as ref_no,client_policy_id as policy_ref_no,
|
||||
tpa_id as tpa_ref_no,uhid as policy_no,pre_existing_alignments,age_band,basic_cover_si,date_coverage,
|
||||
policy_end_date,days,premium,rata_premimum,date_of_exit,reason_for_exit,payable_employee")
|
||||
->where("employee_id", $emp_id)
|
||||
->where("is_active", 1)
|
||||
->whereNotIn("status", ['truncated'])
|
||||
->orderBy("id")
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function sendClaimMaster($client_id,$where,$limit,$offset = 0)
|
||||
{
|
||||
|
||||
return $this->claimModel->select("i.name as insurer,tpa.name as tpa,concat(up.first_name,' ',up.last_name) as acm_name,
|
||||
cs.claim_status,ticket_master.emp_name,ticket_master.insured_name,
|
||||
ticket_master.emp_code,ticket_master.policy_no,ticket_master.ticket_type_id as policy_type,
|
||||
ticket_master.emp_mobile,ticket_master.emp_mail,ticket_master.hospital_name,ticket_master.doa,
|
||||
ticket_master.dod,ticket_master.claim_amount,ticket_master.date_of_join,ticket_master.date_of_incep,
|
||||
ticket_master.date_of_accident,ticket_master.date_of_death,
|
||||
ticket_master.date_of_intimat,ticket_master.claim_number,ticket_master.si_amt,
|
||||
ticket_master.raised_date,ticket_master.registration_date,ticket_master.denial_date,
|
||||
ticket_master.settled_date,ticket_master.denial_reason,ticket_master.approved_amount,
|
||||
ticket_master.utr_details,ticket_master.return_remark,ticket_master.cancel_remark,
|
||||
ticket_master.non_id_reason,ticket_master.head_rejection_reason")
|
||||
->join("tpa","tpa.id = ticket_master.tpa_id and tpa.is_active = 1")
|
||||
->join("user_profiles up", "ticket_master.acm_id = up.id and up.is_active = 1")
|
||||
->join('insurers i', 'ticket_master.insurer_id = i.id and i.is_active = 1')
|
||||
->join('ticket_claim_status cs', 'ticket_master.claim_status_id = cs.id and cs.is_active = 1')
|
||||
->where("ticket_master.client_id", $client_id)
|
||||
->where("ticket_master.is_active", 1)
|
||||
->where($where)
|
||||
->orderBy("ticket_master.id")
|
||||
->limit($limit,$offset)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
54
app/Helpers/ClientTokenHelper.php
Normal file
54
app/Helpers/ClientTokenHelper.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
|
||||
class ClientTokenHelper{
|
||||
|
||||
|
||||
|
||||
public static function generateKey($clientId,$length = 32)
|
||||
{
|
||||
$clientIdPart = bin2hex($clientId); // Convert client ID to hex
|
||||
$randomPart = bin2hex(random_bytes($length)); // Random part
|
||||
return $clientIdPart . ':' . $randomPart; // Combine with a delimiter
|
||||
}
|
||||
|
||||
public static function extractClientId($token)
|
||||
{
|
||||
$parts = explode(':', $token);
|
||||
return hex2bin($parts[0]); // Decode the hex client ID
|
||||
}
|
||||
|
||||
public static function encryptData($data, $key)
|
||||
{
|
||||
|
||||
$cipher = "AES-256-CBC";
|
||||
$ivlen = openssl_cipher_iv_length($cipher);
|
||||
$iv = openssl_random_pseudo_bytes($ivlen);
|
||||
|
||||
// Convert array to JSON string before encrypting
|
||||
$jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$encrypted = openssl_encrypt($jsonData, $cipher, $key, OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
// Combine IV + encrypted, then base64 encode it to make it JSON-safe
|
||||
return base64_encode($iv . $encrypted);
|
||||
}
|
||||
|
||||
public static function decryptData($encryptedData, $key)
|
||||
{
|
||||
$cipher = "AES-256-CBC";
|
||||
$data = base64_decode($encryptedData);
|
||||
|
||||
$ivlen = openssl_cipher_iv_length($cipher);
|
||||
$iv = substr($data, 0, $ivlen); // Extract IV
|
||||
$ciphertext = substr($data, $ivlen); // Extract Encrypted Payload
|
||||
|
||||
$decryptedJson = openssl_decrypt($ciphertext, $cipher, $key, OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
return json_decode($decryptedJson, true); // return as array
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -74,7 +74,11 @@ class GmailResponseHandler{
|
||||
if(in_array($key,$arr)){
|
||||
$data[$key] = isset($value)?json_encode($value):null;
|
||||
}else{
|
||||
$data[$key] = isset($value)?$value:null;
|
||||
if($key == "mail" && is_array($value)){
|
||||
$data[$key] = isset($value)?json_encode($value):null;
|
||||
}else{
|
||||
$data[$key] = isset($value)?$value:null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,154 +292,164 @@ class MailHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static function send_email($params)
|
||||
{
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
|
||||
$emaill = $params['mail'];
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
|
||||
$common = isset($params['common']) ? $params['common'] : '';
|
||||
$bcc = isset($params['bcc']) ? $params['bcc'] : '';
|
||||
$cc = isset($params['cc']) ? $params['cc'] : '';
|
||||
|
||||
$from_address = isset($params['from_mail']) && !empty($params['from_mail']) ? $params['from_mail'] : getenv('email.fromEmail');
|
||||
// $from_address = "claims@nhanceindia.in";
|
||||
try {
|
||||
$curl = curl_init();
|
||||
|
||||
$postData = [
|
||||
'from' => [
|
||||
'address' => $from_address
|
||||
],
|
||||
'to' => [
|
||||
[
|
||||
public static function send_email($params)
|
||||
{
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
if (is_array($params['mail'])) {
|
||||
$emails = [];
|
||||
|
||||
foreach ($params['mail'] as $key => $emaill) {
|
||||
$emails[] = [
|
||||
'email_address' => [
|
||||
'address' => $emaill
|
||||
]
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$emails[] = [
|
||||
'email_address' => [
|
||||
'address' => $params['mail']
|
||||
]
|
||||
],
|
||||
'subject' => $subject,
|
||||
'htmlbody' => $message
|
||||
];
|
||||
|
||||
// Add CC recipients if provided
|
||||
if (!empty($cc)) {
|
||||
$ccList = explode(',', $cc);
|
||||
$ccList = array_map('trim', $ccList);
|
||||
$postData['cc'] = array_map(function($email) {
|
||||
return [
|
||||
'email_address' => [
|
||||
'address' => $email
|
||||
]
|
||||
];
|
||||
}, $ccList);
|
||||
}
|
||||
// Add BCC if present
|
||||
if (!empty($bcc)) {
|
||||
$bccList = explode(',', $bcc);
|
||||
$bccList = array_map('trim', $bccList);
|
||||
$postData['bcc'] = array_map(function($email) {
|
||||
return [
|
||||
'email_address' => [
|
||||
'address' => $email
|
||||
]
|
||||
];
|
||||
}, $bccList);
|
||||
];
|
||||
}
|
||||
|
||||
// Add BCC recipients if provided
|
||||
// if (!empty($bcc)) {
|
||||
// $postData['bcc'] = [];
|
||||
// // Handle both string and array inputs for BCC
|
||||
// $bccEmails = is_array($bcc) ? $bcc : [$bcc];
|
||||
// foreach ($bccEmails as $bccEmail) {
|
||||
// $postData['bcc'][] = [
|
||||
// 'email_address' => [
|
||||
// 'address' => $bccEmail
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
|
||||
$common = isset($params['common']) ? $params['common'] : '';
|
||||
$bcc = isset($params['bcc']) ? $params['bcc'] : '';
|
||||
$cc = isset($params['cc']) ? $params['cc'] : '';
|
||||
|
||||
// Handle attachments
|
||||
if (!empty($attachments)) {
|
||||
$postData['attachments'] = [];
|
||||
foreach ($attachments as $attachment) {
|
||||
if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) {
|
||||
// Determine MIME type dynamically
|
||||
$fileMimeType = mime_content_type($attachment['filePath']);
|
||||
|
||||
$postData['attachments'][] = [
|
||||
'content' => base64_encode(file_get_contents($attachment['filePath'])),
|
||||
'name' => $attachment['fileName'],
|
||||
'mime_type' => $fileMimeType,
|
||||
$from_address = isset($params['from_mail']) && !empty($params['from_mail']) ? $params['from_mail'] : getenv('email.fromEmail');
|
||||
// $from_address = "claims@nhanceindia.in";
|
||||
try {
|
||||
$curl = curl_init();
|
||||
|
||||
$postData = [
|
||||
'from' => [
|
||||
'address' => $from_address
|
||||
],
|
||||
'to' => $emails,
|
||||
'subject' => $subject,
|
||||
'htmlbody' => $message
|
||||
];
|
||||
|
||||
// Add CC recipients if provided
|
||||
if (!empty($cc)) {
|
||||
$ccList = explode(',', $cc);
|
||||
$ccList = array_map('trim', $ccList);
|
||||
$postData['cc'] = array_map(function ($email) {
|
||||
return [
|
||||
'email_address' => [
|
||||
'address' => $email
|
||||
]
|
||||
];
|
||||
}, $ccList);
|
||||
}
|
||||
// Add BCC if present
|
||||
if (!empty($bcc)) {
|
||||
$bccList = explode(',', $bcc);
|
||||
$bccList = array_map('trim', $bccList);
|
||||
$postData['bcc'] = array_map(function ($email) {
|
||||
return [
|
||||
'email_address' => [
|
||||
'address' => $email
|
||||
]
|
||||
];
|
||||
}, $bccList);
|
||||
}
|
||||
|
||||
// Add BCC recipients if provided
|
||||
// if (!empty($bcc)) {
|
||||
// $postData['bcc'] = [];
|
||||
// // Handle both string and array inputs for BCC
|
||||
// $bccEmails = is_array($bcc) ? $bcc : [$bcc];
|
||||
// foreach ($bccEmails as $bccEmail) {
|
||||
// $postData['bcc'][] = [
|
||||
// 'email_address' => [
|
||||
// 'address' => $bccEmail
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// Handle attachments
|
||||
if (!empty($attachments)) {
|
||||
$postData['attachments'] = [];
|
||||
foreach ($attachments as $attachment) {
|
||||
if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) {
|
||||
// Determine MIME type dynamically
|
||||
$fileMimeType = mime_content_type($attachment['filePath']);
|
||||
|
||||
$postData['attachments'][] = [
|
||||
'content' => base64_encode(file_get_contents($attachment['filePath'])),
|
||||
'name' => $attachment['fileName'],
|
||||
'mime_type' => $fileMimeType,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($postData),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"accept: application/json",
|
||||
"authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'),
|
||||
"cache-control: no-cache",
|
||||
"content-type: application/json",
|
||||
],
|
||||
]);
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($postData),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"accept: application/json",
|
||||
"authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'),
|
||||
"cache-control: no-cache",
|
||||
"content-type: application/json",
|
||||
],
|
||||
]);
|
||||
|
||||
$mail_result = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
$mail_result = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$res['params'] = $params;
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
$apiResponse = json_decode($mail_result, true);
|
||||
$res['zepto_api'] = $apiResponse;
|
||||
|
||||
if (isset($apiResponse['error'])) {
|
||||
$res['params'] = $params;
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
$apiResponse = json_decode($mail_result, true);
|
||||
$res['zepto_api'] = $apiResponse;
|
||||
|
||||
if (isset($apiResponse['error'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'failed',
|
||||
'code' => 404,
|
||||
'message' => 'Email Sent Failed...' . json_encode($params['mail']),
|
||||
'data' => $res
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (isset($apiResponse['data'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'message' => 'Email Sent Successfully...' . json_encode($params['mail']),
|
||||
'data' => $res
|
||||
], 200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$msg['error'] = $e->getMessage();
|
||||
$msg['params'] = $params;
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'failed',
|
||||
'code' => 404,
|
||||
'message' => 'Email Sent Failed...' . $emaill,
|
||||
'data' => $res
|
||||
], 404);
|
||||
'code' => 500,
|
||||
'data' => $msg
|
||||
], 500);
|
||||
}
|
||||
|
||||
if (isset($apiResponse['data'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'message' => 'Email Sent Successfully...' . $emaill,
|
||||
'data' => $res
|
||||
], 200);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$msg['error'] = $e->getMessage();
|
||||
$msg['params'] = $params;
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'data' => $msg
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public static function bulk_mail(array $mails = [])
|
||||
{
|
||||
$model = new JobModel();
|
||||
|
||||
39
app/Helpers/clientWebHookHelper.php
Normal file
39
app/Helpers/clientWebHookHelper.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\TicketMasterModel;
|
||||
|
||||
class clientWebHookHelper
|
||||
{
|
||||
protected $empModel;
|
||||
protected $empPolicyModel;
|
||||
protected $claimModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Models
|
||||
$this->empModel = new EmployeeModel();
|
||||
$this->empPolicyModel = new EmployeePolicyModel();
|
||||
$this->claimModel = new TicketMasterModel();
|
||||
|
||||
}
|
||||
|
||||
public function mapObjectType($data_to_map, $objectType)
|
||||
{
|
||||
$mapped_data = [];
|
||||
foreach ($objectType as $key => $value){
|
||||
$mapped_data[$key] = $data_to_map[$value];
|
||||
}
|
||||
|
||||
return $mapped_data;
|
||||
}
|
||||
|
||||
public function insertData($mapped_data, $type){
|
||||
|
||||
$model = $type == 1 ? "empModel" : "claimModel";
|
||||
$this->$model->insert($mapped_data);
|
||||
}
|
||||
}
|
||||
@ -407,7 +407,7 @@ if (!function_exists('data_group_by_family'))
|
||||
$row = transform_enrollment_row_to_inception_row($row);
|
||||
}
|
||||
|
||||
if(strtolower($row[5]) == 'self' && isset($result[$row[1]]))
|
||||
if(isset($row[5]) && strtolower($row[5]) == 'self' && isset($result[$row[1]]))
|
||||
{
|
||||
array_unshift($result[$row[1]],$row);
|
||||
}else
|
||||
@ -440,8 +440,20 @@ if (!function_exists('name_dup_check_within_family'))
|
||||
foreach ($family_data as $rkey => $row)
|
||||
{
|
||||
if(in_array($row[2],$temp))
|
||||
{
|
||||
array_push($result,$row[0]);
|
||||
{
|
||||
// Kint::dump($row);
|
||||
$emp_code = $row[1];
|
||||
$tempFam = null;
|
||||
foreach ($family_data as $family) {
|
||||
if ($family[1] == $emp_code &&!isset($family['temp'])) {
|
||||
$tempFam = $family;
|
||||
break; // Stop at the first match
|
||||
}
|
||||
}
|
||||
// Kint::dump($tempFam);
|
||||
// die();
|
||||
|
||||
array_push($result,$tempFam[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -449,7 +461,7 @@ if (!function_exists('name_dup_check_within_family'))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// dd($result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -519,7 +531,15 @@ if (!function_exists('name_and_empid_check_in_db'))
|
||||
}
|
||||
if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition' || $current_action == 'enrollment') && count($res))
|
||||
{
|
||||
array_push($result['i'],$row[0]);
|
||||
$emp_code = $row[1];
|
||||
$tempFam = null;
|
||||
foreach ($family_data as $family) {
|
||||
if ($family[1] == $emp_code &&!isset($family['temp'])) {
|
||||
$tempFam = $family;
|
||||
break; // Stop at the first match
|
||||
}
|
||||
}
|
||||
array_push($result['i'],$tempFam[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,6 +586,15 @@ if (!function_exists('check_dependent_conflict'))
|
||||
$allowed_parents_count = $temp['either-parents-pil'] == 0 ? $temp['parents'] : 0;
|
||||
$allowed_parent_in_laws_count = $temp['either-parents-pil'] == 0 ? $temp['parents-in-law'] : 0;
|
||||
// dd($allowed_adults == 0);
|
||||
$firstNonTemp = null;
|
||||
|
||||
foreach ($family_data as $family) {
|
||||
if (!isset($family['temp'])) {
|
||||
$firstNonTemp = $family;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Kint::dump($firstNonTemp);
|
||||
foreach ($family_data as $key => $row)
|
||||
{
|
||||
// dd($family_data[0][0]);
|
||||
@ -580,7 +609,7 @@ if (!function_exists('check_dependent_conflict'))
|
||||
if($relationship == 'self')
|
||||
{
|
||||
$self_gender = $row[4];
|
||||
$self_emp_row_id = $row[0];
|
||||
$self_emp_row_id = isset($row['temp']) ? null : $row[0];
|
||||
}
|
||||
if($relationship == 'spouse')
|
||||
{
|
||||
@ -612,8 +641,9 @@ if (!function_exists('check_dependent_conflict'))
|
||||
$repeated_count = array_intersect($repeated_relationships_count,$temp_counts);
|
||||
if(is_array($repeated_count) && count($repeated_count))
|
||||
{
|
||||
// Kint::dump($firstNonTemp);die();
|
||||
$result['status'] = false;
|
||||
$result['error_data'][] = ['code' => 13,'col_name' => 'relationship','msg' => 'Rule conflict: Twofold relationship found within family','row_id' => $family_data[0][0]];
|
||||
$result['error_data'][] = ['code' => 13,'col_name' => 'relationship','msg' => 'Rule conflict: Twofold relationship found within family','row_id' => $firstNonTemp[0]];
|
||||
}
|
||||
}
|
||||
// print_r($repeated_count);
|
||||
@ -630,26 +660,26 @@ if (!function_exists('check_dependent_conflict'))
|
||||
if($self_gender && $spouse_gender && $self_gender == $spouse_gender)
|
||||
{
|
||||
$result['status'] = false;
|
||||
$result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];
|
||||
$result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];
|
||||
}
|
||||
}
|
||||
|
||||
if(($allowed_spouse_count < $received_spouse_count) || ($allowed_child_count < $received_child_count) )
|
||||
{
|
||||
$result['status'] = false;
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch
|
||||
}
|
||||
|
||||
// || ($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count)
|
||||
if($allowed_adults == 1 && $received_parents_count && $received_parent_in_laws_count )
|
||||
{
|
||||
$result['status'] = false;
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Parents and Parents in law both not allowed','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Parents and Parents in law both not allowed','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];
|
||||
|
||||
if((2 < $received_parents_count) || (2 < $received_parent_in_laws_count))
|
||||
{
|
||||
$result['status'] = false;
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch
|
||||
}
|
||||
}
|
||||
//check for any cross parents but not more than two
|
||||
@ -657,7 +687,7 @@ if (!function_exists('check_dependent_conflict'))
|
||||
{
|
||||
// dd($allowed_adults);
|
||||
$result['status'] = false;
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
|
||||
$result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $firstNonTemp[0])];//dependent count mismatch
|
||||
}
|
||||
|
||||
|
||||
@ -1132,7 +1162,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
{
|
||||
$insurer = new InsurerModel();
|
||||
$insurer = ($insurer->find($policy_terms['insurer_id']));
|
||||
if($insurer['addition_add_day'] == true)
|
||||
if(isset($insurer['addition_add_day']) && $insurer['addition_add_day'] == true)
|
||||
{
|
||||
// $emp_data['policy_details']['date_coverage'] = (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d');
|
||||
|
||||
@ -2119,15 +2149,15 @@ if(!function_exists('check_unit'))
|
||||
|
||||
if(!function_exists('transform_si_excel_row_to_calculatable_format'))
|
||||
{
|
||||
function transform_si_excel_row_to_calculatable_format(array $employee,array$employee_policy,array $maxage_and_maxcount,array $slab_details,string $applicable_slab_name,string $augmented_si,array $grid_master)
|
||||
{
|
||||
function transform_si_excel_row_to_calculatable_format(array $employee, array $employee_policy,array $maxage_and_maxcount,array $slab_details,string $applicable_slab_name,string $augmented_si,array $grid_master)
|
||||
{
|
||||
$employee['temp'] = [];
|
||||
$employee['temp']['max_age'] = $maxage_and_maxcount[0]['max_age'];
|
||||
$employee['temp']['max_count'] = $maxage_and_maxcount[0]['family_member_count'];
|
||||
$employee['temp']['grid_name'] = $applicable_slab_name;
|
||||
$employee['temp']['grid_master'] = $grid_master;
|
||||
$employee['temp']['acting_self'] = true;
|
||||
$employee['temp']['premium_type'] = $grid_master['premium_type'];
|
||||
$employee['temp']['premium_type'] = $slab_details['slab_rates'][0]['premium_type'];
|
||||
$employee['temp']['grid_type'] = $applicable_slab_name;
|
||||
$employee['temp']['grid_id'] = $grid_master['ui_type'];
|
||||
$employee['temp']['action'] = 'SI';
|
||||
@ -2137,7 +2167,7 @@ if(!function_exists('transform_si_excel_row_to_calculatable_format'))
|
||||
$employee['temp']['policy_status'] = null;
|
||||
$employee['temp']['emp_status'] = null;
|
||||
$employee['temp']['rata_premimum'] = null;
|
||||
|
||||
$employee['policy_details'] = $employee_policy;
|
||||
return $employee;
|
||||
|
||||
|
||||
@ -2180,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;
|
||||
|
||||
@ -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 "";
|
||||
|
||||
93
app/Models/BdsPlacementModel.php
Normal file
93
app/Models/BdsPlacementModel.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class BdsPlacementModel extends Model
|
||||
{
|
||||
protected $table = 'bds_installment_payment_details';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'pt_id',
|
||||
'lead_id',
|
||||
'installment_amount',
|
||||
'payment_date',
|
||||
'utr_no',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
public function getClientInstallmentDetails()
|
||||
{
|
||||
|
||||
$builder = $this->db->table("bds_installment_payment_details bipd")
|
||||
->select("bipd.*, ct.client_name,ct.short_name, cb.branch_name, leads.salse_person_id,cp.policy_no")
|
||||
->join("policy_transaction pt", "pt.id = bipd.pt_id")
|
||||
->join("clients ct", "ct.id = pt.client_id")
|
||||
->join("client_branch cb", "cb.id = pt.client_branch_id")
|
||||
->join("leads", "leads.id = bipd.lead_id")
|
||||
->join("client_policy cp","cp.id = pt.client_policy_id")
|
||||
->where("bipd.is_active", 1)
|
||||
->where("bipd.payment_date", date('Y-m-d', strtotime('+15 days')));
|
||||
|
||||
$data = $builder->get()->getResultArray();
|
||||
|
||||
// Loop through to extract sales person details
|
||||
foreach ($data as &$row) {
|
||||
$sales_person_ids = json_decode($row['salse_person_id'], true);
|
||||
$sales_person_id = $sales_person_ids[0] ?? null;
|
||||
|
||||
if ($sales_person_id) {
|
||||
$user = $this->db->table('user_profiles')
|
||||
->select('email') // or whatever field
|
||||
->where('id', $sales_person_id)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
$row['sales_person'] = $user['email'] ?? 'N/A';
|
||||
} else {
|
||||
$row['sales_person'] = 'Not Assigned';
|
||||
}
|
||||
|
||||
$head = $this->db->table('user_profiles')
|
||||
->select('email') // or whatever field
|
||||
->where('role', 5)
|
||||
->where('is_active',1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
$row['heads'] = $head;
|
||||
|
||||
$admin = $this->db->table('user_profiles')
|
||||
->select('email')
|
||||
->where("is_active",1)
|
||||
->where("role",1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$row['admins'] = $admin;
|
||||
|
||||
$buisenessTeam = $this->db->table("user_teams ut")
|
||||
->select("up.email")
|
||||
->join('user_profiles up','up.id = ut.user_id and up.is_active = 1')
|
||||
->where("ut.team_id",7)
|
||||
->where("ut.is_active",1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$row['buisness_team'] = $buisenessTeam;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
45
app/Models/ClientApiModel.php
Normal file
45
app/Models/ClientApiModel.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ClientApiModel extends Model
|
||||
{
|
||||
protected $table = 'client_api';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'id','client_id','api_access','created_by','updated_by','created_at','updated_at',
|
||||
'emp_method',"emp_url","emp_tkn_type","emp_token","emp_obj","claim_method",
|
||||
"claim_url","claim_tkn_type","claim_token","claim_obj",'is_active',"client_token",
|
||||
"pull_emp_token","pull_emp_obj","pull_claim_token","pull_claim_obj"
|
||||
];
|
||||
|
||||
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ class ClientPolicyModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -82,7 +82,7 @@ class ClientPolicyModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -90,100 +90,100 @@ class ClientPolicyModel extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getClientPolicyById($id){
|
||||
public function getClientPolicyById($id)
|
||||
{
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getClientPolicyByClientId($client_id){
|
||||
|
||||
public function getClientPolicyByClientId($client_id)
|
||||
{
|
||||
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('client_branch.branch_name as branch_name')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.is_active', 1)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('client_branch.branch_name as branch_name')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.is_active', 1)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getPolicyPremium($policy_id){
|
||||
public function getPolicyPremium($policy_id)
|
||||
{
|
||||
|
||||
return $this->db->table('policies')
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getPolicyPremiumPolicyTypeId($policy_type_id){
|
||||
public function getPolicyPremiumPolicyTypeId($policy_type_id)
|
||||
{
|
||||
|
||||
return $this->db->table('policies')
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_type_id)
|
||||
->get()
|
||||
->getResult();
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_type_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getPolicyDetails($client_id,$policy_id)
|
||||
public function getPolicyDetails($client_id, $policy_id)
|
||||
{
|
||||
return $this->select('*')
|
||||
->where('client_id',$client_id)
|
||||
->where('id',$policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
->where('client_id', $client_id)
|
||||
->where('id', $policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getinsurerswithclientid($id){
|
||||
public function getinsurerswithclientid($id)
|
||||
{
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as client_name')
|
||||
->join('clients','clients.id=client_policy.client_id')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
|
||||
->where('client_policy.client_id', $id)
|
||||
->where('cd_master.id = client_policy.cd_ac_pk')
|
||||
->groupBy('client_policy.insurer_id')
|
||||
->groupBy('client_policy.client_id', $id) // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as client_name')
|
||||
->join('clients', 'clients.id=client_policy.client_id')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
|
||||
->where('client_policy.client_id', $id)
|
||||
->where('cd_master.id = client_policy.cd_ac_pk')
|
||||
->groupBy('client_policy.insurer_id')
|
||||
->groupBy('client_policy.client_id', $id) // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
// return $this->db->table('client_policy')
|
||||
// ->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
@ -198,26 +198,28 @@ class ClientPolicyModel extends Model
|
||||
// ->getResult();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getinsurerswithinsurenceid($insurerId){
|
||||
|
||||
public function getinsurerswithinsurenceid($insurerId)
|
||||
{
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as clientname, clients.short_name as clientshort')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->where('client_policy.insurer_id', $insurerId)
|
||||
->groupBy('client_policy.client_id') // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as clientname, clients.short_name as clientshort')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->where('client_policy.insurer_id', $insurerId)
|
||||
->groupBy('client_policy.client_id') // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getClientById($id) {
|
||||
public function getClientById($id)
|
||||
{
|
||||
$query = $this->db->table('clients')->getWhere(['id' => $id]);
|
||||
// Debug statement
|
||||
// Debug statement
|
||||
return $query->getRow();
|
||||
}
|
||||
|
||||
@ -248,112 +250,113 @@ class ClientPolicyModel extends Model
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getDepositSummary($clientId, $insurerId)
|
||||
{
|
||||
// Fetch the sum of credit and debit transactions and calculate the balance
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
|
||||
->where('client_id', $clientId)
|
||||
->where('insurer_id', $insurerId)
|
||||
->where('cash_deposit.is_active', 1)
|
||||
->get()
|
||||
->getRow();
|
||||
}
|
||||
// Inside your clientPolicyModel
|
||||
// Inside your clientPolicyModel
|
||||
// public function getDepositDataWithBalance($clientId, $insurerId)
|
||||
// {
|
||||
// // Fetch deposit data with balance information
|
||||
// $builder = $this->db->table('cash_deposit');
|
||||
// $builder->select('id, created_at, description, sub_type, amount, transaction_type');
|
||||
{
|
||||
// Fetch the sum of credit and debit transactions and calculate the balance
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
|
||||
->where('client_id', $clientId)
|
||||
->where('insurer_id', $insurerId)
|
||||
->where('cash_deposit.is_active', 1)
|
||||
->get()
|
||||
->getRow();
|
||||
}
|
||||
// Inside your clientPolicyModel
|
||||
// Inside your clientPolicyModel
|
||||
// public function getDepositDataWithBalance($clientId, $insurerId)
|
||||
// {
|
||||
// // Fetch deposit data with balance information
|
||||
// $builder = $this->db->table('cash_deposit');
|
||||
// $builder->select('id, created_at, description, sub_type, amount, transaction_type');
|
||||
|
||||
// $builder->where('client_id', $clientId);
|
||||
// $builder->where('insurer_id', $insurerId);
|
||||
// $builder->orderBy('created_at', 'asc');
|
||||
// $builder->where('client_id', $clientId);
|
||||
// $builder->where('insurer_id', $insurerId);
|
||||
// $builder->orderBy('created_at', 'asc');
|
||||
|
||||
// $depositData = $builder->get()->getResult();
|
||||
// $depositData = $builder->get()->getResult();
|
||||
|
||||
// $currentBalance = 0;
|
||||
// $currentBalance = 0;
|
||||
|
||||
// foreach ($depositData as $transaction) {
|
||||
// if ($transaction->transaction_type == 'Credit') {
|
||||
// $currentBalance += $transaction->amount;
|
||||
// } elseif ($transaction->transaction_type == 'Debit') {
|
||||
// $currentBalance -= $transaction->amount;
|
||||
// }
|
||||
// foreach ($depositData as $transaction) {
|
||||
// if ($transaction->transaction_type == 'Credit') {
|
||||
// $currentBalance += $transaction->amount;
|
||||
// } elseif ($transaction->transaction_type == 'Debit') {
|
||||
// $currentBalance -= $transaction->amount;
|
||||
// }
|
||||
|
||||
// $transaction->balance = $currentBalance;
|
||||
// }
|
||||
// $transaction->balance = $currentBalance;
|
||||
// }
|
||||
|
||||
// return $depositData;
|
||||
// }
|
||||
// return $depositData;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function getBalances($clientId)
|
||||
{
|
||||
$depositsummary = $this->getDepositlistsummary($clientId);
|
||||
$balances = [];
|
||||
public function getBalances($clientId)
|
||||
{
|
||||
$depositsummary = $this->getDepositlistsummary($clientId);
|
||||
$balances = [];
|
||||
|
||||
foreach ($depositsummary as $summary) {
|
||||
$insurerId = $summary->insurer_id;
|
||||
$balances[$insurerId] = $summary;
|
||||
foreach ($depositsummary as $summary) {
|
||||
$insurerId = $summary->insurer_id;
|
||||
$balances[$insurerId] = $summary;
|
||||
}
|
||||
|
||||
return $balances;
|
||||
}
|
||||
|
||||
return $balances;
|
||||
}
|
||||
|
||||
public function getDepositlistsummary($id)
|
||||
{
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('insurer_id')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->where('client_id', $id)
|
||||
->groupBy('insurer_id')
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
public function getDepositlistsummary($id)
|
||||
{
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('insurer_id')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->where('client_id', $id)
|
||||
->groupBy('insurer_id')
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function updateStatus(){
|
||||
public function updateStatus()
|
||||
{
|
||||
|
||||
// Update client_policy table
|
||||
$client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
|
||||
$client_count = $this->db->affectedRows();
|
||||
// Update employee_polices table
|
||||
$employee = $this->db->query("UPDATE employee_polices SET status = 'expired' WHERE policy_end_date < CURDATE()");
|
||||
$emp_count = $this->db->affectedRows();
|
||||
// Update client_policy table
|
||||
$client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
|
||||
$client_count = $this->db->affectedRows();
|
||||
// Update employee_polices table
|
||||
$employee = $this->db->query("UPDATE employee_polices SET status = 'expired' WHERE policy_end_date < CURDATE()");
|
||||
$emp_count = $this->db->affectedRows();
|
||||
|
||||
return ['client'=>$client_count, 'emp' => $emp_count];
|
||||
return ['client' => $client_count, 'emp' => $emp_count];
|
||||
}
|
||||
|
||||
public function getpolicyWithPattern($client_id)
|
||||
{
|
||||
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, policies.name, policies.policy_type_id, policy_type.policy_type')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
// ->where('policy_type.policy_type', 'GMC')
|
||||
->whereIn('policy_type.id', [2, 3])
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getpolicyWithPattern($client_id){
|
||||
public function getTopUpPolicy($client_id, $type)
|
||||
{
|
||||
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, policies.name, policies.policy_type_id, policy_type.policy_type')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
// ->where('policy_type.policy_type', 'GMC')
|
||||
->whereIn('policy_type.id', [2, 3])
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getTopUpPolicy($client_id, $type){
|
||||
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT client_policy.*, policies.name, policies.policy_type_id
|
||||
FROM client_policy
|
||||
JOIN policies ON policies.id = client_policy.policy_id
|
||||
@ -361,65 +364,63 @@ public function getTopUpPolicy($client_id, $type){
|
||||
WHERE policy_type.policy_type = '{$type}'
|
||||
AND client_policy.client_id = {$client_id}";
|
||||
|
||||
$result = $this->db->query($query)->getResult();
|
||||
$result = $this->db->query($query)->getResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getClientPolicyByPolicyType($client_id, $type){
|
||||
|
||||
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name, policies.policy_type_id')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1);
|
||||
|
||||
if ($type == 2) {
|
||||
$query->where('policy_type.policy_type', 'GMC - Top-up');
|
||||
} else if ($type == 3) {
|
||||
$query->whereIn('policy_type.policy_type', ['GMC - Parents', 'GMC - Top-up(Parents)']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = $query->get()->getResult();
|
||||
|
||||
return $result;
|
||||
public function getClientPolicyByPolicyType($client_id, $type)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name, policies.policy_type_id')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1);
|
||||
|
||||
if ($type == 2) {
|
||||
$query->where('policy_type.policy_type', 'GMC - Top-up');
|
||||
} else if ($type == 3) {
|
||||
$query->whereIn('policy_type.policy_type', ['GMC - Parents', 'GMC - Top-up(Parents)']);
|
||||
}
|
||||
|
||||
$result = $query->get()->getResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getPolicyTypeForPolicyBinding($client_id){
|
||||
public function getPolicyTypeForPolicyBinding($client_id)
|
||||
{
|
||||
|
||||
$result = $this->table('client_policy')
|
||||
->select('policy_type.*, client_policy.id as client_policy_id, client_policy.policy_no')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->whereIn('policy_type.id', [2,3])
|
||||
->findAll();
|
||||
$result = $this->table('client_policy')
|
||||
->select('policy_type.*, client_policy.id as client_policy_id, client_policy.policy_no')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->whereIn('policy_type.id', [2, 3])
|
||||
->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')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
@ -427,49 +428,48 @@ public function getCliendDataForExcelFileName($client_policy_id){
|
||||
->where('client_policy.id', $client_policy_id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
// ->where('client_policy.is_addon', 1)
|
||||
// ->where('client_policy.inception_type', 2)
|
||||
->where('client_policy.open_for_enrollment', 1);
|
||||
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
}
|
||||
|
||||
if(empty($policy_id)){
|
||||
$builder->whereIn('client_policy.policy_type_id', [2, 3, 4, 5]);
|
||||
}else{
|
||||
$builder->where('client_policy.id', $policy_id);
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
// ->where('client_policy.is_addon', 1)
|
||||
// ->where('client_policy.inception_type', 2)
|
||||
->where('client_policy.open_for_enrollment', 1);
|
||||
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
}
|
||||
|
||||
if (empty($policy_id)) {
|
||||
$builder->whereIn('client_policy.policy_type_id', [2, 3, 4, 5]);
|
||||
} else {
|
||||
$builder->where('client_policy.id', $policy_id);
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForEnrollment($client_id = null, $branch_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.open_date IS NOT NULL')
|
||||
->where('client_policy.close_date IS NOT NULL');
|
||||
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForEnrollment($client_id = null, $branch_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.open_date IS NOT NULL')
|
||||
->where('client_policy.close_date IS NOT NULL');
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
}
|
||||
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -222,7 +222,7 @@ class EmployeeModel extends Model
|
||||
) AS family_stats
|
||||
ORDER BY family_member_count DESC, max_age DESC
|
||||
LIMIT 1;";
|
||||
$results = $this->db->query($query)->getResult();
|
||||
$results = $this->db->query($query)->getResultArray();
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
@ -594,7 +594,7 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data)
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0)
|
||||
{
|
||||
|
||||
$client_id = $ref_data['client_id'];
|
||||
@ -732,7 +732,14 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
// Get the result set
|
||||
$results = $query->getResult();
|
||||
// dd($this->db->getLastQuery(), $results);
|
||||
|
||||
if($return_type == 1){
|
||||
$results = $query->getResultArray();
|
||||
}else{
|
||||
$results = $query->getResult();
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
return $results;
|
||||
|
||||
}
|
||||
@ -1528,73 +1535,120 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function bulkUpdateForEndorsement($endorsement_details)
|
||||
// public function bulkUpdateForEndorsement($endorsement_details)
|
||||
// {
|
||||
// // dd($endorsement_details, '---');
|
||||
// // Extract IDs, endorsement_ids, and statuses
|
||||
// $ids = array_column($endorsement_details, 'group_key');
|
||||
// $endorsement_ids = array_column($endorsement_details, 'endorsement_id');
|
||||
// $statuses = array_column($endorsement_details, 'status');
|
||||
|
||||
// // Escape values for SQL
|
||||
// $escapedIds = array_map([$this->db, 'escape'], $ids);
|
||||
// $escapedEndorsementIds = array_map([$this->db, 'escape'], $endorsement_ids);
|
||||
// $escapedStatuses = array_map([$this->db, 'escape'], $statuses);
|
||||
|
||||
// // Construct the CASE statements
|
||||
// $caseEndorsementId = array_map(function ($id, $endorsement_id) {
|
||||
// return "WHEN group_key = $id THEN $endorsement_id";
|
||||
// }, $escapedIds, $escapedEndorsementIds);
|
||||
|
||||
// // $caseStatus = array_map(function ($id, $status) {
|
||||
// // return "WHEN status = $id THEN $status";
|
||||
// // }, $escapedIds, $escapedStatuses);
|
||||
|
||||
// // Convert cases to a string
|
||||
// $caseEndorsementIdString = implode(' ', $caseEndorsementId);
|
||||
// // $caseStatusString = implode(' ', $caseStatus);
|
||||
|
||||
// // Convert ids to a string
|
||||
// $idsString = implode(', ', $escapedIds);
|
||||
|
||||
// // Construct the SQL query
|
||||
// $sql = "
|
||||
// UPDATE emp_endorsement
|
||||
// SET
|
||||
// endorsement_id = CASE {$caseEndorsementIdString} END,
|
||||
// status = 'complete'
|
||||
// WHERE group_key IN ({$idsString})
|
||||
// ";
|
||||
|
||||
|
||||
// // dd($sql);
|
||||
// // Begin a transaction
|
||||
// $this->db->transBegin();
|
||||
|
||||
// try {
|
||||
// // Start the transaction
|
||||
// $this->db->transBegin();
|
||||
|
||||
// // Execute the query
|
||||
// $this->db->query($sql);
|
||||
|
||||
// // Check transaction status
|
||||
// if ($this->db->transStatus() === false) {
|
||||
// $error = $this->db->error(); // Get the last database error
|
||||
// $this->db->transRollback();
|
||||
|
||||
// // Optionally log the error
|
||||
// log_message('error', 'Bulk update failed. Error: ' . json_encode($error));
|
||||
|
||||
// throw new \Exception('Bulk update failed. Error: ' . $error['message']);
|
||||
// }
|
||||
|
||||
// // Commit if everything is fine
|
||||
// $this->db->transCommit();
|
||||
|
||||
// return $this->db->getLastQuery(); // Optional: return last executed query for debugging
|
||||
// } catch (\Exception $e) {
|
||||
// $this->db->transRollback();
|
||||
|
||||
// // Optionally log the exception
|
||||
// log_message('error', 'Exception during bulk update: ' . $e->getMessage());
|
||||
|
||||
// // Re-throw with detailed context
|
||||
// throw new \RuntimeException('Exception during bulk update: ' . $e->getMessage(), $e->getCode(), $e);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
public function bulkUpdateForEndorsement(array $endorsement_details)
|
||||
{
|
||||
|
||||
// Extract IDs, endorsement_ids, and statuses
|
||||
$ids = array_column($endorsement_details, 'group_key');
|
||||
$endorsement_ids = array_column($endorsement_details, 'endorsement_id');
|
||||
$statuses = array_column($endorsement_details, 'status');
|
||||
|
||||
// Escape values for SQL
|
||||
$escapedIds = array_map([$this->db, 'escape'], $ids);
|
||||
$escapedEndorsementIds = array_map([$this->db, 'escape'], $endorsement_ids);
|
||||
$escapedStatuses = array_map([$this->db, 'escape'], $statuses);
|
||||
|
||||
// Construct the CASE statements
|
||||
$caseEndorsementId = array_map(function ($id, $endorsement_id) {
|
||||
return "WHEN group_key = $id THEN $endorsement_id";
|
||||
}, $escapedIds, $escapedEndorsementIds);
|
||||
|
||||
// $caseStatus = array_map(function ($id, $status) {
|
||||
// return "WHEN status = $id THEN $status";
|
||||
// }, $escapedIds, $escapedStatuses);
|
||||
|
||||
// Convert cases to a string
|
||||
$caseEndorsementIdString = implode(' ', $caseEndorsementId);
|
||||
// $caseStatusString = implode(' ', $caseStatus);
|
||||
|
||||
// Convert ids to a string
|
||||
$idsString = implode(', ', $escapedIds);
|
||||
|
||||
// Construct the SQL query
|
||||
if (empty($endorsement_details)) {
|
||||
throw new \InvalidArgumentException("No endorsement details provided.");
|
||||
}
|
||||
|
||||
$caseParts = [];
|
||||
$groupKeys = [];
|
||||
|
||||
foreach ($endorsement_details as $row) {
|
||||
$groupKey = $this->db->escape($row['group_key']);
|
||||
$endorsementId = $this->db->escape($row['endorsement_id']);
|
||||
$caseParts[] = "WHEN group_key = {$groupKey} THEN {$endorsementId}";
|
||||
$groupKeys[] = $groupKey;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
UPDATE emp_endorsement
|
||||
SET
|
||||
endorsement_id = CASE {$caseEndorsementIdString} END,
|
||||
endorsement_id = CASE " . implode(' ', $caseParts) . " END,
|
||||
status = 'complete'
|
||||
WHERE group_key IN ({$idsString})
|
||||
WHERE group_key IN (" . implode(', ', $groupKeys) . ")
|
||||
";
|
||||
|
||||
|
||||
// dd($sql);
|
||||
// Begin a transaction
|
||||
$this->db->transBegin();
|
||||
|
||||
try {
|
||||
// Execute the query
|
||||
$this->db->query($sql);
|
||||
|
||||
// Commit the transaction
|
||||
if ($this->db->transStatus() === FALSE) {
|
||||
// If something went wrong, rollback
|
||||
$this->db->transRollback();
|
||||
throw new \Exception('Bulk update failed.');
|
||||
} else {
|
||||
// Otherwise, commit
|
||||
$this->db->transCommit();
|
||||
}
|
||||
// $this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
|
||||
return $this->db->getLastQuery();
|
||||
} catch (\Exception $e) {
|
||||
// Rollback the transaction on error
|
||||
$this->db->transRollback();
|
||||
throw $e;
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
// Check if query was successful
|
||||
if ($this->db->affectedRows() === 0) {
|
||||
throw new \RuntimeException('No rows were updated.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function bulkUpdateForCorrection($emp_details){
|
||||
|
||||
foreach ($emp_details as $employee) {
|
||||
|
||||
54
app/Models/LeadInstallmentPaymentDetails.php
Normal file
54
app/Models/LeadInstallmentPaymentDetails.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class LeadInstallmentPaymentDetails extends Model
|
||||
{
|
||||
protected $table = 'lead_installment_payment_details';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'lead_id',
|
||||
'installment_amount',
|
||||
'payment_date',
|
||||
'utr_no',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@ -30,17 +30,17 @@ class LeadsModel extends Model
|
||||
'source_policy_id',
|
||||
'policy_type_id',
|
||||
'salse_person_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'tpa_id',
|
||||
'tpa_branch_id',
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'no_of_lives',
|
||||
'incurred_claims',
|
||||
'location',
|
||||
'proposed_insurer_id',
|
||||
'proposed_insurer_branch_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'tpa_id',
|
||||
'tpa_branch_id',
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'no_of_lives',
|
||||
'incurred_claims',
|
||||
'location',
|
||||
'proposed_insurer_id',
|
||||
'proposed_insurer_branch_id',
|
||||
'proposed_tpa_id',
|
||||
'proposed_tpa_branch_id',
|
||||
'proposel_data',
|
||||
@ -90,9 +90,12 @@ class LeadsModel extends Model
|
||||
|
||||
'source_policy_start_date',
|
||||
'source_policy_end_date',
|
||||
|
||||
|
||||
'payment_date',
|
||||
'is_cd'
|
||||
'is_cd',
|
||||
|
||||
'is_installment',
|
||||
'no_of_installment',
|
||||
];
|
||||
|
||||
|
||||
@ -110,7 +113,7 @@ class LeadsModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -121,7 +124,7 @@ class LeadsModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -153,10 +156,10 @@ class LeadsModel extends Model
|
||||
|
||||
) AS rfq_count
|
||||
')
|
||||
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
|
||||
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
||||
->where('leads.is_active', 1);
|
||||
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
|
||||
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
||||
->where('leads.is_active', 1);
|
||||
|
||||
if (!empty($where)) {
|
||||
$data->where($where);
|
||||
@ -168,12 +171,12 @@ class LeadsModel extends Model
|
||||
public function getLeadForInsertClientList($type = null, $client_id = null)
|
||||
{
|
||||
$query = $this->db->table('leads')
|
||||
->select('leads.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.status', 'won')
|
||||
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''")
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)");
|
||||
->select('leads.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.status', 'won')
|
||||
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''")
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)");
|
||||
|
||||
|
||||
|
||||
@ -183,11 +186,83 @@ class LeadsModel extends Model
|
||||
if ($client_id) {
|
||||
$query->where('leads.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
$result = $query->get()->getResultArray();
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class PolicyTransactionModel extends Model
|
||||
'policy_with_corr',
|
||||
'is_cd_reduce_from_bds',
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
// Callbacks
|
||||
@ -98,7 +98,7 @@ class PolicyTransactionModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -109,7 +109,7 @@ class PolicyTransactionModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -267,21 +267,21 @@ class PolicyTransactionModel extends Model
|
||||
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
// Check if the start date and end date are provided
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
}else{
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
} else {
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
@ -289,31 +289,30 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
@ -446,7 +445,7 @@ class PolicyTransactionModel extends Model
|
||||
// AND insurer_statements.is_active = 1
|
||||
// AND insurer_statements.invoice_status IS NOT NULL
|
||||
// $date_condition
|
||||
|
||||
|
||||
// ),
|
||||
// 2
|
||||
// ) AS billed_amt,
|
||||
@ -511,7 +510,7 @@ class PolicyTransactionModel extends Model
|
||||
// ->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
// ->where('policy_transaction.is_active', 1)
|
||||
// ->where('pt_co_share_details.is_active', 1);
|
||||
|
||||
|
||||
// // Check if the start date and end date are provided
|
||||
// if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
|
||||
|
||||
@ -547,7 +546,7 @@ class PolicyTransactionModel extends Model
|
||||
// if ($client_id != 0) {
|
||||
// $builder->where('policy_transaction.client_id', $client_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($insurer_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
// }
|
||||
@ -555,7 +554,7 @@ class PolicyTransactionModel extends Model
|
||||
// if ($client_branch_id != 0) {
|
||||
// $builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($insurer_branch_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
// }
|
||||
@ -565,11 +564,11 @@ class PolicyTransactionModel extends Model
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// if ($policy_type_id != 0) {
|
||||
// $builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($issuer != 0) {
|
||||
// $builder->where('policy_transaction.issuer', $issuer);
|
||||
// }
|
||||
@ -578,7 +577,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
@ -589,18 +588,18 @@ class PolicyTransactionModel extends Model
|
||||
// $result = $builder->get()->getResultArray();
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
|
||||
|
||||
// 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 = '';
|
||||
if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||
if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||
$date_condition = "
|
||||
AND insurer_statements.month >= '".$start_date ."'
|
||||
AND insurer_statements.month <= '".$end_date ."'
|
||||
AND insurer_statements.month >= '" . $start_date . "'
|
||||
AND insurer_statements.month <= '" . $end_date . "'
|
||||
";
|
||||
}
|
||||
|
||||
@ -782,7 +781,7 @@ class PolicyTransactionModel extends Model
|
||||
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('pt_co_share_details.is_active', 1);
|
||||
|
||||
if (
|
||||
@ -797,16 +796,18 @@ class PolicyTransactionModel extends Model
|
||||
$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
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
}
|
||||
|
||||
// if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
|
||||
@ -823,17 +824,17 @@ class PolicyTransactionModel extends Model
|
||||
$endDate = date('Y-m-d', strtotime($end_date));
|
||||
|
||||
$builder->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id', 'left')
|
||||
->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id','left')
|
||||
->where('insurer_statements.is_active', 1)
|
||||
->where('insurer_statements.month >=', $startDate)
|
||||
->where('insurer_statements.month <=', $endDate)
|
||||
->groupBy('co_share_stmt_details.co_share_id');
|
||||
->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id', 'left')
|
||||
->where('insurer_statements.is_active', 1)
|
||||
->where('insurer_statements.month >=', $startDate)
|
||||
->where('insurer_statements.month <=', $endDate)
|
||||
->groupBy('co_share_stmt_details.co_share_id');
|
||||
}
|
||||
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
@ -841,7 +842,7 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_branch_id != 0) {
|
||||
$builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
}
|
||||
@ -851,23 +852,24 @@ class PolicyTransactionModel extends Model
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$fromDate = date('Y-m-d', strtotime('-60 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
if (empty($where)) {
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
@ -875,10 +877,10 @@ class PolicyTransactionModel extends Model
|
||||
$result = $builder->get()->getResultArray();
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
// {
|
||||
// // dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
@ -917,7 +919,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// // $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// // $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// // $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// // ->where('policy_transaction.created_at <=', $toDate);
|
||||
// }
|
||||
@ -925,15 +927,15 @@ class PolicyTransactionModel extends Model
|
||||
// if ($client_id != 0) {
|
||||
// $builder->where('policy_transaction.client_id', $client_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($insurer_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($policy_type_id != 0) {
|
||||
// $builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($issuer != 0) {
|
||||
// $builder->where('policy_transaction.issuer', $issuer);
|
||||
// }
|
||||
@ -945,12 +947,12 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// $builder->orderBy('policy_transaction.id', 'desc')->limit(10);
|
||||
|
||||
// $result = $builder->get()->getResultArray();
|
||||
@ -960,7 +962,7 @@ class PolicyTransactionModel extends Model
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
public function getInceptionTranctionListData($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 getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0, $where = null)
|
||||
{
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select('
|
||||
@ -1003,7 +1005,7 @@ class PolicyTransactionModel extends Model
|
||||
// Optimize Date Filtering
|
||||
if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
|
||||
$builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
|
||||
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
|
||||
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
|
||||
}
|
||||
|
||||
// Apply Filters Only When Necessary
|
||||
@ -1024,12 +1026,16 @@ class PolicyTransactionModel extends Model
|
||||
}
|
||||
|
||||
// Default to Last 30 Days if No Filters Are Applied
|
||||
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer)) {
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer) && empty($where)) {
|
||||
$fromDate = date('Y-m-d', strtotime('-60 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
if (!empty($where)) {
|
||||
$builder->whereIn('policy_transaction.id', $where);
|
||||
}
|
||||
|
||||
// Optimize Query Execution
|
||||
@ -1038,7 +1044,7 @@ class PolicyTransactionModel extends Model
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getEndorsementTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
// dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
@ -1055,7 +1061,7 @@ class PolicyTransactionModel extends Model
|
||||
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
|
||||
->join('clients', 'policy_transaction.client_id = clients.id', 'left')
|
||||
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||
->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('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
@ -1073,20 +1079,20 @@ class PolicyTransactionModel extends Model
|
||||
$builder->where('policy_transaction.created_by', get_session_userid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
}else{
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
} else {
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
@ -1094,15 +1100,15 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
@ -1110,16 +1116,15 @@ class PolicyTransactionModel extends Model
|
||||
$builder->where('policy_transaction.status', $status);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
@ -1235,14 +1240,14 @@ class PolicyTransactionModel extends Model
|
||||
// ->having('premium_variance_amt !=',0);
|
||||
|
||||
// ->group_start()
|
||||
->having('variance_amt IS NOT NULL')
|
||||
->orHaving('variance_amt !=', 0)
|
||||
->having('premium_variance_amt IS NOT NULL')
|
||||
->orHaving('premium_variance_amt !=', 0);
|
||||
// ->group_end();
|
||||
// ->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0');
|
||||
// ->where('pt_co_share_details.variance IS NOT NULL')
|
||||
// ->where('pt_co_share_details.variance !=', 0);
|
||||
->having('variance_amt IS NOT NULL')
|
||||
->orHaving('variance_amt !=', 0)
|
||||
->having('premium_variance_amt IS NOT NULL')
|
||||
->orHaving('premium_variance_amt !=', 0);
|
||||
// ->group_end();
|
||||
// ->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0');
|
||||
// ->where('pt_co_share_details.variance IS NOT NULL')
|
||||
// ->where('pt_co_share_details.variance !=', 0);
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
@ -1279,7 +1284,7 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_branch_id != 0) {
|
||||
$builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
}
|
||||
@ -1296,6 +1301,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)
|
||||
{
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days"));
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select([
|
||||
'policy_transaction.id AS policy_trns_id',
|
||||
@ -1319,9 +1325,21 @@ class PolicyTransactionModel extends Model
|
||||
->join('insurers', 'pt_co_share_details.insurer_id = insurers.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(
|
||||
'(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.status is not null", null, false)
|
||||
->whereNotIn("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) {
|
||||
|
||||
@ -1360,12 +1378,21 @@ class PolicyTransactionModel extends Model
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
// echo $builder->getCompiledSelect();
|
||||
// exit;
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
$returnData = $builder->get()->getResultArray();
|
||||
|
||||
|
||||
|
||||
// dd($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)
|
||||
{
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days"));
|
||||
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select("
|
||||
policy_transaction.id,
|
||||
@ -1388,12 +1415,22 @@ class PolicyTransactionModel extends Model
|
||||
->join('insurers', 'pt_co_share_details.insurer_id = insurers.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(
|
||||
'(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.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.actual_bp_amt, 0) + COALESCE(pt_co_share_details.actual_tp_amt, 0) + COALESCE(pt_co_share_details.actual_tep_amt, 0) = 0')
|
||||
->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0');
|
||||
|
||||
->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0')
|
||||
->where("policy_transaction.status is not null", null, false)
|
||||
->whereNotIn("policy_transaction.status", ['completed']);
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
@ -1489,55 +1526,55 @@ class PolicyTransactionModel extends Model
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
|
||||
// Date range filtering
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
} else {
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
|
||||
// Additional filters
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
|
||||
if ($status != 0) {
|
||||
$builder->where('policy_transaction.status', $status);
|
||||
}
|
||||
|
||||
|
||||
// Filter where outstanding_amount is not null
|
||||
$builder->having('outstanding_amount IS NOT NULL');
|
||||
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0, $insurer_branch_id = 0)
|
||||
{
|
||||
$builder = $this->db->table('insurer_statements s')
|
||||
->select('
|
||||
->select('
|
||||
s.id,
|
||||
s.insurer_id,
|
||||
s.branch_id,
|
||||
@ -1553,32 +1590,32 @@ class PolicyTransactionModel extends Model
|
||||
COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid,
|
||||
(s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount
|
||||
')
|
||||
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||
->join('insurers ins', 's.insurer_id = ins.id')
|
||||
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||
->where('s.is_active', 1)
|
||||
->where('p.is_active', 1)
|
||||
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||
->having('outstanding_amount >', 0);
|
||||
// ->get();
|
||||
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||
->join('insurers ins', 's.insurer_id = ins.id')
|
||||
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||
->where('s.is_active', 1)
|
||||
->where('p.is_active', 1)
|
||||
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||
->having('outstanding_amount >', 0);
|
||||
// ->get();
|
||||
|
||||
|
||||
|
||||
// Date range filtering
|
||||
if ($start_date != 0 && $end_date != 0) {
|
||||
|
||||
|
||||
$builder->where('s.month >=', $start_date)
|
||||
->where('s.month <=', $end_date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('s.insurer_id', $insurer_id);
|
||||
}
|
||||
if ($insurer_branch_id != 0) {
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('s.branch_id', $insurer_branch_id);
|
||||
}
|
||||
|
||||
$builder->orderBy('s.id', 'desc');
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
@ -1588,12 +1625,12 @@ class PolicyTransactionModel extends Model
|
||||
{
|
||||
$fromDate = date('Y-m-d', strtotime('-60 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);
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->table('policy_transaction pt')
|
||||
->select('
|
||||
pt.*,
|
||||
@ -1618,7 +1655,7 @@ class PolicyTransactionModel extends Model
|
||||
->where('pt.is_active', 1)
|
||||
->where('pt_co.is_active', 1)
|
||||
->where('pt.action_type', "inception");
|
||||
|
||||
|
||||
// Apply filters if parameters are provided
|
||||
if (!empty($client_type)) {
|
||||
$query->where('c.client_type', $client_type);
|
||||
@ -1629,7 +1666,7 @@ class PolicyTransactionModel extends Model
|
||||
if (!empty($issuer)) { // Corrected condition to check $issuer
|
||||
$query->where('pt.issuer', $issuer);
|
||||
}
|
||||
|
||||
|
||||
$query->groupBy('pt.id');
|
||||
$query->orderBy('pt.id', 'DESC');
|
||||
// Fetch and return results
|
||||
@ -1637,6 +1674,47 @@ class PolicyTransactionModel extends Model
|
||||
// print($this->db->getLastQuery()); die;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,11 +74,13 @@ class TicketMasterModel extends Model
|
||||
'head_rejection_reason',
|
||||
'pay_initiate_date',
|
||||
'emp_personal_mail',
|
||||
'client_policy_id'
|
||||
|
||||
];
|
||||
|
||||
|
||||
'client_policy_id',
|
||||
|
||||
'approved_description'
|
||||
|
||||
];
|
||||
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
@ -93,7 +95,7 @@ class TicketMasterModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -104,7 +106,7 @@ class TicketMasterModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -130,21 +132,21 @@ class TicketMasterModel extends Model
|
||||
public function getTemplateDataByTicketID($ticket_id)
|
||||
{
|
||||
$template_data = $this
|
||||
->select("ticket_mail_template.*, CASE
|
||||
->select("ticket_mail_template.*, CASE
|
||||
WHEN employees.email_corporate IS NULL OR employees.email_corporate = ''
|
||||
THEN ticket_master.emp_mail
|
||||
ELSE employees.email_corporate
|
||||
END as emp_mail, ,ticket_master.claim_status_id")
|
||||
->join('ticket_claim_status', 'ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1')
|
||||
->join('ticket_mail_template', '
|
||||
->join('ticket_claim_status', 'ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1')
|
||||
->join('ticket_mail_template', '
|
||||
ticket_claim_status.trigger_type = ticket_mail_template.trigger_type
|
||||
and ticket_claim_status.ticket_type = ticket_mail_template.ticket_type
|
||||
and ticket_mail_template.is_active = 1')
|
||||
->join('employees','employees.id = ticket_master.emp_id','left')
|
||||
->where('ticket_master.id', $ticket_id)
|
||||
->where('ticket_master.is_active', 1)
|
||||
->where('ticket_claim_status.is_active', 1)
|
||||
->first();
|
||||
->join('employees', 'employees.id = ticket_master.emp_id', 'left')
|
||||
->where('ticket_master.id', $ticket_id)
|
||||
->where('ticket_master.is_active', 1)
|
||||
->where('ticket_claim_status.is_active', 1)
|
||||
->first();
|
||||
|
||||
return $template_data;
|
||||
}
|
||||
@ -173,16 +175,16 @@ class TicketMasterModel extends Model
|
||||
->join('clients', 'ticket_master.client_id = clients.id', 'left')
|
||||
->join('insurers', 'ticket_master.insurer_id = insurers.id', 'left')
|
||||
->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left')
|
||||
->join('ticket_notes', 'ticket_master.id = ticket_notes.ticket_id and ticket_notes.is_active = 1 and ticket_notes.is_auto_query = 1','left')
|
||||
->join('ticket_notes', 'ticket_master.id = ticket_notes.ticket_id and ticket_notes.is_active = 1 and ticket_notes.is_auto_query = 1', 'left')
|
||||
->join('user_profiles', 'ticket_master.acm_id = user_profiles.id', 'left')
|
||||
->join('employees','employees.id = ticket_master.emp_id','left')
|
||||
->join('employees', 'employees.id = ticket_master.emp_id', 'left')
|
||||
->where('ticket_master.id', $ticket_id)
|
||||
->where('ticket_master.is_active', 1)
|
||||
->first();
|
||||
|
||||
return $ticket_data;
|
||||
}
|
||||
|
||||
|
||||
//get TAT report BAND wise Data
|
||||
// public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
|
||||
// {
|
||||
@ -210,7 +212,7 @@ class TicketMasterModel extends Model
|
||||
// ";
|
||||
// $statusResult = $this->db->query($statusQuery)->getResultArray();
|
||||
// // dd($statusResult);
|
||||
|
||||
|
||||
// // Initialize dynamic query parts
|
||||
// $dynamicSelect = '';
|
||||
|
||||
@ -248,12 +250,12 @@ class TicketMasterModel extends Model
|
||||
// 0
|
||||
// ) AS `$columnName`, ";
|
||||
// }
|
||||
|
||||
|
||||
// // Remove the trailing comma from the SELECT part
|
||||
// $dynamicSelect = rtrim($dynamicSelect, ', ');
|
||||
// // dd($dynamicSelect);
|
||||
|
||||
|
||||
|
||||
// // Construct the full SQL query
|
||||
// $sql = "
|
||||
// SELECT
|
||||
@ -317,7 +319,7 @@ class TicketMasterModel extends Model
|
||||
// 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;
|
||||
@ -329,167 +331,249 @@ class TicketMasterModel extends Model
|
||||
// // $tableData['headers'] = $headers;
|
||||
// // $tableData['body'] = $data;
|
||||
// // }
|
||||
|
||||
|
||||
// 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 = "";
|
||||
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;
|
||||
// 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)) {
|
||||
$statusQuery->where('ticket_type', $ticket_type);
|
||||
}
|
||||
|
||||
$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){
|
||||
$ticket_type_data_1 = "";
|
||||
public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
|
||||
{
|
||||
$ticket_type_data_1 = "";
|
||||
$ticket_type_data_2 = "";
|
||||
|
||||
if (!empty($policy_type)) {
|
||||
@ -511,8 +595,17 @@ class TicketMasterModel extends Model
|
||||
$dynamicSelect .= "
|
||||
COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) AS `{$status['claim_status']}`, ";
|
||||
|
||||
if (in_array($status['claim_status'], ['ID NOT GENERATED', 'NON ID', 'CDA', 'INFORMATION REQUIRED','UNDER PROCESS - CLAIM NO. UPDATION',
|
||||
'UNDER PROCESS - INVESTIGATION STATUS','UNDER PROCESS - QUERY DOCUMENT RECEIVED','APPROVED','PAYMENT INITIATED'])) {
|
||||
if (in_array($status['claim_status'], [
|
||||
'ID NOT GENERATED',
|
||||
'NON ID',
|
||||
'CDA',
|
||||
'INFORMATION REQUIRED',
|
||||
'UNDER PROCESS - CLAIM NO. UPDATION',
|
||||
'UNDER PROCESS - INVESTIGATION STATUS',
|
||||
'UNDER PROCESS - QUERY DOCUMENT RECEIVED',
|
||||
'APPROVED',
|
||||
'PAYMENT INITIATED'
|
||||
])) {
|
||||
$dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + ";
|
||||
}
|
||||
// Include in total count
|
||||
@ -532,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,
|
||||
@ -553,48 +647,49 @@ class TicketMasterModel extends Model
|
||||
|
||||
// print_rr($result);die();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){
|
||||
public function accountManagerWiseReport($policy_type = null, $start_date = null, $end_date = null)
|
||||
{
|
||||
|
||||
if ($policy_type == 1) {
|
||||
$ticket_type_data_1 = "";
|
||||
$ticket_type_data_2 = "";
|
||||
$ticket_type_data_2 = "";
|
||||
|
||||
if (!empty($policy_type)) {
|
||||
$ticket_type_data_1 = "AND ticket_type = $policy_type";
|
||||
$ticket_type_data_2 = "AND master.ticket_type_id = $policy_type";
|
||||
}
|
||||
if (!empty($policy_type)) {
|
||||
$ticket_type_data_1 = "AND ticket_type = $policy_type";
|
||||
$ticket_type_data_2 = "AND master.ticket_type_id = $policy_type";
|
||||
}
|
||||
|
||||
// Fetch claim statuses dynamically
|
||||
$statusQuery = "SELECT id, claim_status FROM ticket_claim_status WHERE is_active = 1 $ticket_type_data_1";
|
||||
$statusResult = $this->db->query($statusQuery)->getResultArray();
|
||||
// Fetch claim statuses dynamically
|
||||
$statusQuery = "SELECT id, claim_status FROM ticket_claim_status WHERE is_active = 1 $ticket_type_data_1";
|
||||
$statusResult = $this->db->query($statusQuery)->getResultArray();
|
||||
|
||||
// Initialize dynamic query parts
|
||||
$dynamicSelect = '';
|
||||
$dynamicTotal = '';
|
||||
// Initialize dynamic query parts
|
||||
$dynamicSelect = '';
|
||||
$dynamicTotal = '';
|
||||
|
||||
// Loop through each claim status and generate the CASE statements
|
||||
foreach ($statusResult as $status) {
|
||||
$dynamicSelect .= "
|
||||
// Loop through each claim status and generate the CASE statements
|
||||
foreach ($statusResult as $status) {
|
||||
$dynamicSelect .= "
|
||||
COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) AS `{$status['claim_status']}`, ";
|
||||
|
||||
|
||||
// Include in total count
|
||||
$dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + ";
|
||||
// Include in total count
|
||||
$dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + ";
|
||||
|
||||
// Include only closed-related statuses in total2 count
|
||||
// Include only closed-related statuses in total2 count
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the trailing commas and `+` signs
|
||||
$dynamicSelect = rtrim($dynamicSelect, ', ');
|
||||
$dynamicTotal = rtrim($dynamicTotal, ' +');
|
||||
// print_rr($dynamicSelect);
|
||||
// Construct the final SQL query
|
||||
$sql = "
|
||||
// Remove the trailing commas and `+` signs
|
||||
$dynamicSelect = rtrim($dynamicSelect, ', ');
|
||||
$dynamicTotal = rtrim($dynamicTotal, ' +');
|
||||
// print_rr($dynamicSelect);
|
||||
// Construct the final SQL query
|
||||
$sql = "
|
||||
SELECT
|
||||
user_profiles.id as ACM_ID,
|
||||
user_profiles.first_name AS ACM_NAME,
|
||||
$dynamicSelect,
|
||||
($dynamicTotal) AS TOTAL
|
||||
@ -611,47 +706,51 @@ class TicketMasterModel extends Model
|
||||
";
|
||||
|
||||
$result = $this->db->query($sql)->getResultArray();
|
||||
// dd($result);
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$ticket_type_data_1 = "";
|
||||
$ticket_type_data_2 = "";
|
||||
|
||||
|
||||
if (!empty($policy_type)) {
|
||||
$ticket_type_data_1 = "AND ticket_type = $policy_type";
|
||||
$ticket_type_data_2 = "AND master.ticket_type_id = $policy_type";
|
||||
}
|
||||
|
||||
|
||||
// Fetch claim statuses dynamically
|
||||
$statusQuery = "SELECT id, claim_status FROM ticket_claim_status WHERE is_active = 1 $ticket_type_data_1";
|
||||
$statusResult = $this->db->query($statusQuery)->getResultArray();
|
||||
|
||||
|
||||
// Initialize dynamic query parts
|
||||
$dynamicSelect = '';
|
||||
$dynamicTotal = '';
|
||||
$dynamicClosedTotal = '';
|
||||
|
||||
|
||||
// Loop through each claim status and generate the CASE statements
|
||||
foreach ($statusResult as $status) {
|
||||
$dynamicSelect .= "
|
||||
COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) AS `{$status['claim_status']}`, ";
|
||||
|
||||
if (in_array($status['claim_status'], ['CLAIM INTIMATION', 'INTIMATION TO INSURER', 'CLIENT PENDING', 'INSURER PENDING','INVESTIGATION',
|
||||
'APPROVED','ON HOLD'])) {
|
||||
|
||||
if (in_array($status['claim_status'], [
|
||||
'CLAIM INTIMATION',
|
||||
'INTIMATION TO INSURER',
|
||||
'CLIENT PENDING',
|
||||
'INSURER PENDING',
|
||||
'INVESTIGATION',
|
||||
'APPROVED',
|
||||
'ON HOLD'
|
||||
])) {
|
||||
$dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + ";
|
||||
}
|
||||
// Include in total count
|
||||
// $dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + ";
|
||||
|
||||
|
||||
// Include only closed-related statuses in total2 count
|
||||
if (in_array($status['claim_status'], ['CLOSED', 'SETTLED', 'NOT COVERED'])) {
|
||||
$dynamicClosedTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove the trailing commas and `+` signs
|
||||
$dynamicSelect = rtrim($dynamicSelect, ', ');
|
||||
$dynamicTotal = rtrim($dynamicTotal, ' +');
|
||||
@ -660,6 +759,7 @@ class TicketMasterModel extends Model
|
||||
// Construct the final SQL query
|
||||
$sql = "
|
||||
SELECT
|
||||
user_profiles.id as ACM_ID,
|
||||
user_profiles.first_name AS ACM_NAME,
|
||||
$dynamicSelect,
|
||||
($dynamicTotal) AS TOTAL,
|
||||
@ -675,12 +775,13 @@ class TicketMasterModel extends Model
|
||||
GROUP BY
|
||||
user_profiles.id;
|
||||
";
|
||||
|
||||
|
||||
// Execute the query
|
||||
$result = $this->db->query($sql)->getResultArray();
|
||||
|
||||
// print_rr($result);die();
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -705,6 +806,151 @@ class TicketMasterModel extends Model
|
||||
// dd($data, db_connect()->getLastQuery());
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDashData($claim_statuses, $limit)
|
||||
{
|
||||
$finalResults = [];
|
||||
|
||||
foreach ($claim_statuses as $typeId => $statuses) {
|
||||
// Get all active, non-null claim status tickets for this type
|
||||
$builder = $this->db->table('ticket_master tm')
|
||||
->select('tm.id, tm.ticket_type_id, tcs.claim_status, th.last_claim_status_change')
|
||||
->join('ticket_claim_status tcs', 'tm.claim_status_id = tcs.id', 'left')
|
||||
->join(
|
||||
'(SELECT ticket_id, MAX(created_at) AS last_claim_status_change
|
||||
FROM ticket_history
|
||||
WHERE field_name = \'claim_status_id\'
|
||||
GROUP BY ticket_id) th',
|
||||
'tm.id = th.ticket_id',
|
||||
'left'
|
||||
)
|
||||
->where('tm.ticket_type_id', $typeId)
|
||||
->where('tm.is_active', 1)
|
||||
->where('tm.claim_status_id IS NOT NULL');
|
||||
|
||||
$results = $builder->get()->getResultArray();
|
||||
|
||||
$summary = [
|
||||
'ticket_type_id' => $typeId,
|
||||
];
|
||||
|
||||
$total = 0;
|
||||
foreach ($statuses as $status) {
|
||||
$alias = strtolower(str_replace(' ', '_', $status));
|
||||
$summary[$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++;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Convert ticket IDs array to a comma-separated string
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@
|
||||
|
||||
</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="col-12">
|
||||
@ -217,18 +217,53 @@
|
||||
</li>
|
||||
|
||||
<?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">
|
||||
<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="d-none d-sm-inline-block">Claims</span>
|
||||
</a>
|
||||
</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">
|
||||
<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="d-none d-sm-inline-block">Leads and BDS Renewals</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</ul>
|
||||
<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 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 include('bds_dash.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 endif; ?>
|
||||
|
||||
<?php if(in_array(get_role_id(), [1,2,3,5])) { ?>
|
||||
<?php include('endorsement_dash.php'); ?>
|
||||
<?php include('enrollment_dash.php'); ?>
|
||||
<?php } ?>
|
||||
<!--
|
||||
<?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 // } ?> -->
|
||||
|
||||
<?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 } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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="StatusTileHide" style="display: none; position: relative; bottom: 15px;">
|
||||
<a href="#" onclick="hide_status_show_pending_tile()" >show all pending Tile</a>
|
||||
<div class="row">
|
||||
<div class="StatusTileHide" style="display: none; padding-bottom: 10px;padding-left: 17px">
|
||||
<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 class="row">
|
||||
|
||||
<?php if (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
@ -224,6 +227,10 @@ body{
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".StatusTileHide").hide();
|
||||
})
|
||||
|
||||
function linkRedirectForBDS(input, team)
|
||||
{
|
||||
var link = "";
|
||||
@ -244,6 +251,7 @@ function show_business_status_tile(){
|
||||
|
||||
$('.businessStatusTile').show()
|
||||
$('.StatusTileHide').show()
|
||||
$("#mainMenuTiles").text("Viewing Details of Business Team Pending");
|
||||
|
||||
$('.businessPendingTile').hide()
|
||||
$('.financePendingTile').hide()
|
||||
@ -257,6 +265,8 @@ function show_finance_status_tile(){
|
||||
|
||||
$('.financePendingTile').hide()
|
||||
$('.businessPendingTile').hide()
|
||||
$("#mainMenuTiles").text("Viewing Details of Finance Team Pending");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -267,6 +277,6 @@ function hide_status_show_pending_tile(){
|
||||
$('.businessStatusTile').hide()
|
||||
$('.financePendingTile').show()
|
||||
$('.businessPendingTile').show()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
122
app/Views/bds_multi_report.php
Normal file
122
app/Views/bds_multi_report.php
Normal file
@ -0,0 +1,122 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12" id="second_page">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;"><?= $page_title ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
// Get headers dynamically
|
||||
$headers = array_keys($data[0]);
|
||||
foreach ($headers as $header): ?>
|
||||
<th><?= esc($header) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th>TOTAL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
// Initialize column-wise totals
|
||||
$columnTotals = array_fill_keys($headers, 0);
|
||||
foreach ($data as $row):
|
||||
$rowTotal = 0; // Initialize row total
|
||||
?>
|
||||
<tr>
|
||||
<?php foreach ($row as $key => $value):
|
||||
$numValue = is_numeric($value) ? (int) $value : 0;
|
||||
if ($key != 'TAT_Category') {
|
||||
$columnTotals[$key] += $numValue;
|
||||
$rowTotal += $numValue;
|
||||
}
|
||||
?>
|
||||
<td><?= esc($value) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Row Total -->
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php foreach ($columnTotals as $key => $total): ?>
|
||||
<th><?= ($key == "TAT_Category" || $key == 'ACM_Name') ? "TOTAL" : esc($total) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th><strong><?= array_sum(array_filter($columnTotals, 'is_numeric')) ?></strong></th> <!-- Grand Total -->
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col-12 -->
|
||||
</div> <!-- end row -->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'BDS TAT BAND WISE DATA',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'BDS TAT BAND WISE DATA',
|
||||
},
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true,
|
||||
pageLength: 10,
|
||||
ordering: false
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
122
app/Views/bds_tat_wise_report.php
Normal file
122
app/Views/bds_tat_wise_report.php
Normal file
@ -0,0 +1,122 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12" id="second_page">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">BDS TAT Band Wise Report</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
// Get headers dynamically
|
||||
$headers = array_keys($data[0]);
|
||||
foreach ($headers as $header): ?>
|
||||
<th><?= esc($header) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th>TOTAL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
// Initialize column-wise totals
|
||||
$columnTotals = array_fill_keys($headers, 0);
|
||||
foreach ($data as $row):
|
||||
$rowTotal = 0; // Initialize row total
|
||||
?>
|
||||
<tr>
|
||||
<?php foreach ($row as $key => $value):
|
||||
$numValue = is_numeric($value) ? (int) $value : 0;
|
||||
if ($key != 'TAT_Category') {
|
||||
$columnTotals[$key] += $numValue;
|
||||
$rowTotal += $numValue;
|
||||
}
|
||||
?>
|
||||
<td><?= esc($value) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Row Total -->
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php foreach ($columnTotals as $key => $total): ?>
|
||||
<th><?= ($key == "TAT_Category") ? "TOTAL" : esc($total) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th><strong><?= array_sum(array_filter($columnTotals, 'is_numeric')) ?></strong></th> <!-- Grand Total -->
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col-12 -->
|
||||
</div> <!-- end row -->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'BDS TAT BAND WISE DATA',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'BDS TAT BAND WISE DATA',
|
||||
},
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true,
|
||||
pageLength: 10,
|
||||
ordering: false
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
329
app/Views/claims_dash.php
Normal file
329
app/Views/claims_dash.php
Normal file
@ -0,0 +1,329 @@
|
||||
<style>
|
||||
body {
|
||||
margin-top: 20px;
|
||||
background: #FAFAFA;
|
||||
}
|
||||
|
||||
.order-card {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.bg-c-blue {
|
||||
background: linear-gradient(45deg, #4099ff, #73b4ff);
|
||||
}
|
||||
|
||||
.bg-c-green {
|
||||
background: linear-gradient(45deg, #2ed8b6, #59e0c5);
|
||||
}
|
||||
|
||||
.bg-c-yellow {
|
||||
background: linear-gradient(45deg, #FFB64D, #ffcb80);
|
||||
}
|
||||
|
||||
.bg-c-pink {
|
||||
background: linear-gradient(45deg, #FF5370, #ff869a);
|
||||
}
|
||||
|
||||
.bg-c-red {
|
||||
background: linear-gradient(45deg, #FF4E50, #F9D423);
|
||||
}
|
||||
|
||||
.bg-c-purple {
|
||||
background: linear-gradient(45deg, #9D50BB, #6E48AA);
|
||||
}
|
||||
|
||||
.bg-c-orange {
|
||||
background: linear-gradient(45deg, #F2994A, #F2C94C);
|
||||
}
|
||||
|
||||
.bg-c-teal {
|
||||
background: linear-gradient(45deg, #1ABC9C, #16A085);
|
||||
}
|
||||
|
||||
.bg-c-cyan {
|
||||
background: linear-gradient(45deg, #00C9FF, #92FE9D);
|
||||
}
|
||||
|
||||
.bg-c-lime {
|
||||
background: linear-gradient(45deg, #A8E063, #56AB2F);
|
||||
}
|
||||
|
||||
.bg-c-indigo {
|
||||
background: linear-gradient(45deg, #3F51B5, #5A55AE);
|
||||
}
|
||||
|
||||
.bg-c-Pelorous {
|
||||
background: linear-gradient(45deg, #00d6db, #00a8b5);
|
||||
}
|
||||
|
||||
.bg-c-Pelorous2 {
|
||||
background: linear-gradient(45deg, #02a8b5, #017f8b);
|
||||
}
|
||||
|
||||
.bg-c-Pelorous3 {
|
||||
background: linear-gradient(45deg, #098895, #046063);
|
||||
}
|
||||
|
||||
.bg-c-Grenadier {
|
||||
background: linear-gradient(45deg, #ff9d37, #ff7a10);
|
||||
}
|
||||
|
||||
.bg-c-Grenadier2 {
|
||||
background: linear-gradient(45deg, #ff8010, #ff4c00);
|
||||
}
|
||||
|
||||
.bg-c-Grenadier3 {
|
||||
background: linear-gradient(45deg, #f06306, #cc4b05);
|
||||
}
|
||||
|
||||
.bg-c-SilverChalice {
|
||||
background: linear-gradient(45deg, #a3a8a8, #8f9494);
|
||||
}
|
||||
|
||||
.bg-c-SilverChalice2 {
|
||||
background: linear-gradient(45deg, #7e8484, #686e6e);
|
||||
}
|
||||
|
||||
.bg-c-SilverChalice3 {
|
||||
background: linear-gradient(45deg, #5c6363, #434949);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.card {
|
||||
border-radius: 5px;
|
||||
-webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16);
|
||||
box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16);
|
||||
border: none;
|
||||
margin-bottom: 30px;
|
||||
-webkit-transition: all 0.3s ease-in-out;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.card .card-block {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 25px;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
.order-card i {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.f-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.f-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.m-b-1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
$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="col-md-4 col-xl-3 claimTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,1)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">GMC</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($claim_data[1]['total']) ? $claim_data[1]['total'] : '0' ?></span></h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-4 col-xl-3 claimTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,2)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">GPA</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($claim_data[2]['total']) ? $claim_data[2]['total'] : '0' ?></span></h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-xl-3 claimTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,3)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">EDLI</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($claim_data[3]['total']) ? $claim_data[3]['total'] : '0' ?></span></h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-xl-3 claimTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,4)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">GTLI</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($claim_data[4]['total']) ? $claim_data[4]['total'] : '0' ?></span></h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="goBack" style="padding-bottom: 10px;padding-left: 17px;">
|
||||
<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 class="row">
|
||||
<?php
|
||||
$colorSetCount = count($colorShades); // Number of color sets
|
||||
$shadeCount = count($colorShades[0]); // Number of shades per set
|
||||
$index = 0;
|
||||
?>
|
||||
|
||||
<?php foreach ($claim_data as $ticketTypeId => $statuses) : ?>
|
||||
<?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 foreach ($statuses as $status => $count) : ?>
|
||||
<?php
|
||||
// Skip metadata fields
|
||||
if ($status === 'ticket_type_id'|| $status == "approved"|| $status == "settled"|| $status == "closed" || $status === 'total' || substr($status, -4) === "_ids") {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
$formattedStatus = strlen($status) < 5 ? strtoupper($status): ucwords(str_replace('_', ' ', $status));
|
||||
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
|
||||
$showTooltip = strlen($formattedStatus) > 20;
|
||||
?>
|
||||
<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 ?>','<?= $statuses[$status . '_ids'] ?? '' ?>')">
|
||||
<h2 class="text-center"><span><?= $count ?></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; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.goBack').hide();
|
||||
$('[class*="claimStatusTitle_"]').hide();
|
||||
});
|
||||
|
||||
function hideAndShowTile(type, claimType = null) {
|
||||
|
||||
if (type == 1) {
|
||||
|
||||
$('.claimTypeTile').hide();
|
||||
$(".goBack").show();
|
||||
} else {
|
||||
|
||||
$('.claimTypeTile').show();
|
||||
$('.goBack').hide();
|
||||
$('[class*="claimStatusTitle_"]').hide();
|
||||
}
|
||||
|
||||
if (type == 1 && claimType != null) {
|
||||
|
||||
$('.claimTypeTile').hide();
|
||||
$('.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,ids) {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
// $.ajax({
|
||||
// url: "<?= base_url("/dashboard/prepareClaimSearchData") ?>",
|
||||
// type: "POST",
|
||||
// data: {
|
||||
// ticketTypeId: ticketTypeId,
|
||||
// status: status
|
||||
// },
|
||||
// success: function(response) {
|
||||
// // Handle the response from the server
|
||||
// if (response.status === 'success') {
|
||||
// // Redirect to the claims list page with the selected filters
|
||||
// console.log("response", response);
|
||||
// // alert(JSON.stringify(response));
|
||||
// data = response.data;
|
||||
// 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);
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = url;
|
||||
|
||||
for (const key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;
|
||||
input.value = data[key];
|
||||
form.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
@ -18,6 +18,10 @@
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#scroll-horizontal-datatable tbody tr:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-12">
|
||||
@ -47,7 +51,7 @@
|
||||
<?php foreach ($account_manager_wise_data as $row): ?>
|
||||
<tr>
|
||||
<?php foreach ($column_order as $col_name): ?>
|
||||
<td><?= $row[$col_name] ?></td>
|
||||
<td onclick = "redirectToClaimList(<?=$row['ACM_ID'] ?>)"><?= $row[$col_name] ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@ -101,3 +105,37 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function redirectToClaimList(id) {
|
||||
// alert("Redirecting to claim list..."+id);
|
||||
|
||||
data = {
|
||||
is_dashboard: 2,
|
||||
ids : id
|
||||
}
|
||||
|
||||
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = url;
|
||||
|
||||
for (const key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;
|
||||
input.value = data[key];
|
||||
form.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
@ -37,16 +37,18 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($column_order as $col_name): ?>
|
||||
<th><?= str_replace('_', ' ', $col_name) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($col_name != "TPA_ID") { ?>
|
||||
<th><?= str_replace('_', ' ', $col_name) ?></th>
|
||||
<?php } endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tpa_wise_data as $row): ?>
|
||||
<tr>
|
||||
<?php foreach ($column_order as $col_name): ?>
|
||||
<td><?= $row[$col_name] ?></td>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($col_name != "TPA_ID") { ?>
|
||||
<td onclick="redirectTPAToClaimList(<?= $row['TPA_ID'] ?>)"><?= $row[$col_name] ?></td>
|
||||
<?php } endforeach;?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
@ -62,7 +64,7 @@
|
||||
}
|
||||
|
||||
foreach ($column_order as $col_name) {
|
||||
if ($col_name !== 'TPA_NAME') {
|
||||
if ($col_name !== 'TPA_NAME' && $col_name != "TPA_ID") {
|
||||
echo "<th>{$totals[$col_name]}</th>";
|
||||
}
|
||||
}
|
||||
@ -98,4 +100,35 @@
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
function redirectTPAToClaimList(tpa_id){
|
||||
|
||||
// alert(tpa_id);
|
||||
data = {
|
||||
'tpa_id' : tpa_id,
|
||||
'is_dashboard':3
|
||||
}
|
||||
|
||||
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = url;
|
||||
|
||||
for (const key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;
|
||||
input.value = data[key];
|
||||
form.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
453
app/Views/client_api.php
Normal file
453
app/Views/client_api.php
Normal file
@ -0,0 +1,453 @@
|
||||
<style>
|
||||
.card {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
<div class="tab-pane fade" id="api-tab">
|
||||
<div class="card">
|
||||
<!-- <div class="card-header">
|
||||
<h5>API Token Management</h5>
|
||||
</div> -->
|
||||
<div class="card-body">
|
||||
<div class="col-md-6">
|
||||
<label for="is_api">Enable API Access</label>
|
||||
<label class="switch">
|
||||
<input <?= isset($api_data) ? "Checked" : "" ?> id="is_api" type="checkbox" name="is_api">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="api-token-section">
|
||||
<!-- Generate Token Section -->
|
||||
<form id="api-form" data-parsley-validate>
|
||||
<input type="hidden" id="apiPK" name="id" value="<?= isset($api_data) ? $api_data['id'] : "" ?>">
|
||||
<div class="mb-4">
|
||||
<h5 class="mb-3">Generate New Token</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="client_token" value="<?= isset($api_data) ? $api_data['client_token'] : "" ?>" class="form-control" id="client_token" placeholder="Click generate to create token" readonly required>
|
||||
</div>
|
||||
<div class="form-group col-md-6 d-flex">
|
||||
<button class="btn btn-primary me-2" type="button" onclick="generateToken('client_token')">
|
||||
<i class="mdi mdi-key-chain-variant me-1"></i> Generate Token
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" onclick="copyToken('client_token')">
|
||||
<i class="mdi mdi-content-copy me-1"></i> Copy
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- <div class="row" style="padding-top:10px">
|
||||
<div class="col-md-5">
|
||||
<label for="auth_type">Authorization Type</label>
|
||||
<input type="text" class="form-control" id="auth_type" value="Authorization - Bearer" readonly>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<!-- <div class="table-responsive">
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr>
|
||||
<td>Get Individual Employee Data</td>
|
||||
<td><?= base_url("getEmpData") ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Get All Employee Data</td>
|
||||
<td><?= base_url("getAllEmpData") ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Get Branch Wise Employee Data</td>
|
||||
<td><?= base_url("getClientBranchEmpData") ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- Enter Token Section -->
|
||||
<hr>
|
||||
<div class="mt-5">
|
||||
<h5 class="mb-3">Webhooks (PUSH)</h5>
|
||||
<div class="form-row">
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Action</label>
|
||||
<input type="text" class="form-control" id="webhook_action" value="Employee" readonly>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Method Type</label>
|
||||
<select class="form-control" name="emp_method">
|
||||
<option value="post" <?= isset($api_data['emp_method']) && $api_data['emp_method'] == "post" ? "selected" : "" ?>>POST</option>
|
||||
<option value="get" <?= isset($api_data['emp_method']) && $api_data['emp_method'] == "get" ? "selected" : "" ?>>GET</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>Webhook URL</label>
|
||||
<input type="text" name="emp_url" value="<?= isset($api_data) ? $api_data['emp_url'] : "" ?>" class="form-control emp_webhook" onchange="validateWebhookUrlById(this.id)" id="webhook_url" placeholder="Enter Webhook URL">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Token Type</label>
|
||||
<select class="form-control" name="emp_tkn_type">
|
||||
<option value="bearer" <?= (isset($api_data) && $api_data['emp_tkn_type'] == 'bearer') ? 'selected' : '' ?>>Bearer Token</option>
|
||||
<option value="X-API-KEY" <?= (isset($api_data) && $api_data['emp_tkn_type'] == 'X-API-KEY') ? 'selected' : '' ?>>API Key</option>
|
||||
<option value="token" <?= (isset($api_data) && $api_data['emp_tkn_type'] == 'token') ? 'selected' : '' ?>>Token</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<label>Authorization Token</label>
|
||||
<input type="text" id="client_api_token" name="emp_token" value="<?= isset($api_data) ? $api_data['emp_token'] : "" ?>" class="form-control emp_webhook" placeholder="Enter Client API token" />
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="client_object_type">Client Object Type</label>
|
||||
<textarea class="form-control emp_webhook" name="emp_obj" onchange="checkValidJson(this)" id="client_object_type" rows="3" placeholder="Enter the object type"><?= isset($api_data) ? htmlspecialchars($api_data['emp_obj']) : "" ?></textarea>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-row">
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Action</label>
|
||||
<input type="text" class="form-control" id="webhook_action" value="Claims" readonly>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Method Type</label>
|
||||
<select class="form-control" name="claim_method">
|
||||
<option value="post" <?= isset($api_data['claim_method']) && $api_data['claim_method'] == "post" ? "selected" : "" ?>>POST</option>
|
||||
<option value="get" <?= isset($api_data['claim_method']) && $api_data['claim_method'] == "get" ? "selected" : "" ?>>GET</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>Webhook URL</label>
|
||||
<input type="text" name="claim_url" value="<?= isset($api_data) ? $api_data['claim_url'] : "" ?>" class="form-control claim_webhook" onchange="validateWebhookUrlById(this.id)" id="webhook_url_claims" placeholder="Enter Webhook URL">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Token Type</label>
|
||||
<select class="form-control" name="claim_tkn_type">
|
||||
<option value="bearer" <?= (isset($api_data) && $api_data['claim_tkn_type'] == 'bearer') ? 'selected' : '' ?>>Bearer Token</option>
|
||||
<option value="X-API-KEY" <?= (isset($api_data) && $api_data['claim_tkn_type'] == 'X-API-KEY') ? 'selected' : '' ?>>API Key</option>
|
||||
<option value="token" <?= (isset($api_data) && $api_data['claim_tkn_type'] == 'token') ? 'selected' : '' ?>>Token</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<label>Authorization Token</label>
|
||||
<input type="text" id="client_api_token" name="claim_token" value="<?= isset($api_data) ? $api_data['claim_token'] : "" ?>" class="form-control claim_webhook" placeholder="Enter Client API token">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="client_object_type">Client Object Type</label>
|
||||
<textarea class="form-control claim_webhook" name="claim_obj" onchange="checkValidJson(this)" id="client_object_type_claims" rows="3" placeholder="Enter the object type"><?= isset($api_data) ? htmlspecialchars($api_data['claim_obj']) : "" ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h5 class="mt-5">Webhooks (PULL)</h5>
|
||||
<div class="form-row">
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Action</label>
|
||||
<input type="text" class="form-control" id="webhook_action2" value="Employee" readonly>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Method Type</label>
|
||||
<select class="form-control" disabled>
|
||||
<option value="post" selected>POST</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>Webhook URL</label>
|
||||
<input type="text" value="<?= base_url("retrieveWebhookDataEmp") ?>" class="form-control" onchange="validateWebhookUrlById(this.id)" id="webhook_url2" readonly placeholder="Enter Webhook URL">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Token Type</label>
|
||||
<select class="form-control" disabled>
|
||||
<option value="bearer" selected>Bearer Token</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row mt-3">
|
||||
<div class="col-md-6">
|
||||
<label>Authorization Token</label>
|
||||
<input type="text" name="pull_emp_token" value="<?= isset($api_data) ? $api_data['pull_emp_token'] : "" ?>" class="form-control" id="pull_emp_token" placeholder="Click generate to create token" readonly required>
|
||||
</div>
|
||||
<div class="col-md-6 d-flex align-items-end">
|
||||
<button class="btn btn-primary me-2" type="button" onclick="generateToken('pull_emp_token')">
|
||||
<i class="mdi mdi-key-chain-variant me-1"></i> Generate Token
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" onclick="copyToken('pull_emp_token')">
|
||||
<i class="mdi mdi-content-copy me-1"></i> Copy
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-3">
|
||||
<label for="pull_emp_obj">Emp Object Type</label>
|
||||
<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>
|
||||
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Action</label>
|
||||
<input type="text" class="form-control" id="webhook_action2" value="Claim" readonly>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Method Type</label>
|
||||
<select class="form-control">
|
||||
<option value="post" selected>POST</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>Webhook URL</label>
|
||||
<input type="text" value="<?= base_url("retrieveWebhookDataClaim") ?>" class="form-control" onchange="validateWebhookUrlById(this.id)" id="webhook_url2" readonly placeholder="Enter Webhook URL">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>Token Type</label>
|
||||
<select class="form-control">
|
||||
<option value="bearer" selected>Bearer Token</option>
|
||||
</select>
|
||||
</div>
|
||||
<br>
|
||||
<div class="col-md-6">
|
||||
<label>Authorization Token</label>
|
||||
<input type="text" name="pull_claim_token" value="<?= isset($api_data) ? $api_data['pull_claim_token'] : "" ?>" class="form-control" id="pull_claim_token" placeholder="Click generate to create token" readonly required>
|
||||
</div>
|
||||
<div class="col-md-6 d-flex align-items-end">
|
||||
<button class="btn btn-primary me-2" type="button" onclick="generateToken('pull_claim_token')">
|
||||
<i class="mdi mdi-key-chain-variant me-1"></i> Generate Token
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" onclick="copyToken('pull_claim_token')">
|
||||
<i class="mdi mdi-content-copy me-1"></i> Copy
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="pull_claim_obj">Claim Object Type</label>
|
||||
<textarea class="form-control" name="pull_claim_obj" onchange="checkValidJson(this)" id="pull_claim_obj" rows="3" placeholder="Enter the object type"><?= isset($api_data) ? htmlspecialchars($api_data['pull_claim_obj']) : "" ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-primary waves-effect waves-light mr-1" type="submit" id="formSubmit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function generateToken(element_id) {
|
||||
|
||||
// alert($("#general_PrimaryKey").val());
|
||||
// console.log('element_id:', element_id);
|
||||
$.ajax({
|
||||
url: "<?= base_url('client/generateToken') ?>",
|
||||
type: "GET",
|
||||
data: {
|
||||
client_id: $("#general_PrimaryKey").val()
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
toastr.success(response.message);
|
||||
$(`#${element_id}`).val(response.token);
|
||||
} else {
|
||||
toastr.error(response.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
toastr.error("An error occurred while processing your request.");
|
||||
},
|
||||
complete: function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').fadeOut();
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function copyToken(element_id) {
|
||||
const tokenField = document.getElementById(`${element_id}`);
|
||||
if (tokenField.value) {
|
||||
tokenField.select();
|
||||
navigator.clipboard.writeText(tokenField.value);
|
||||
toastr.success('Token copied to clipboard!');
|
||||
} else {
|
||||
toastr.warning('Generate a token first!');
|
||||
}
|
||||
}
|
||||
|
||||
async function pasteToken() {
|
||||
try {
|
||||
// Get the target input field
|
||||
const tokenInput = document.getElementById('client_api_token');
|
||||
|
||||
// Request clipboard read permission
|
||||
const permission = await navigator.permissions.query({
|
||||
name: 'clipboard-read'
|
||||
});
|
||||
if (permission.state === 'denied') {
|
||||
toastr.error('Clipboard access denied by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Read clipboard contents
|
||||
const text = await navigator.clipboard.readText();
|
||||
|
||||
// Security checks
|
||||
if (text.length > 256) {
|
||||
toastr.warning('Invalid token length');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z0-9\-_]+$/.test(text)) {
|
||||
toastr.warning('Invalid token format');
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert into input field
|
||||
tokenInput.value = text;
|
||||
|
||||
// Visual feedback
|
||||
tokenInput.focus();
|
||||
toastr.success('Token pasted securely');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Paste failed:', error);
|
||||
toastr.error('Failed to read clipboard');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$("#is_api").change(function() {
|
||||
checkAndShowApiElements();
|
||||
});
|
||||
$(document).ready(function() {
|
||||
checkAndShowApiElements();
|
||||
});
|
||||
|
||||
|
||||
function checkAndShowApiElements() {
|
||||
if ($("#is_api").is(":checked")) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$("#api-token-section").show();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').fadeOut();
|
||||
} else {
|
||||
$("#api-token-section").hide();
|
||||
}
|
||||
}
|
||||
|
||||
function checkValidJson(el) {
|
||||
|
||||
const element = document.getElementById(el.id);
|
||||
if (!element) {
|
||||
console.error('Element with ID "${id}" not found.');
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
JSON.parse(element.value);
|
||||
} catch (e) {
|
||||
el.value = '';
|
||||
toastr.error('Invalid JSON format');
|
||||
}
|
||||
}
|
||||
|
||||
function validateWebhookUrlById(id) {
|
||||
console.log("function called");
|
||||
const element = document.getElementById(id);
|
||||
if (!element) {
|
||||
console.error(`Element with ID "${id}" not found.`);
|
||||
return false;
|
||||
}
|
||||
const url = element.value.trim(); // Trim whitespace
|
||||
try {
|
||||
// Use the URL constructor to validate structure
|
||||
const parsedUrl = new URL(url);
|
||||
if (parsedUrl.pathname !== "/" && parsedUrl.pathname.endsWith("/")) {
|
||||
element.value = "";
|
||||
toastr.error("Webhook URL should not end with a trailing slash.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parsedUrl.pathname.endsWith(".")) {
|
||||
element.value = "";
|
||||
toastr.error("Webhook URL should not end with a trailing dot.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// const strictDomainRegex = /^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/;
|
||||
// if (!strictDomainRegex.test(parsedUrl.hostname)) {
|
||||
// toastr.error("Invalid domain format in webhook URL.");
|
||||
// element.value = "";
|
||||
// return false;
|
||||
// }
|
||||
// Check if protocol is HTTP/HTTPS
|
||||
return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:";
|
||||
} catch (e) {
|
||||
toastr.error("Invalid Webhook URL format");
|
||||
element.value = "";
|
||||
return false; // Invalid URL structure
|
||||
}
|
||||
}
|
||||
|
||||
$("#api-form").submit(function(event) {
|
||||
event.preventDefault();
|
||||
const form = $(this);
|
||||
// form.parsley().validate(); // Activate Parsley validation
|
||||
|
||||
if (!$(this).parsley().isValid()) {
|
||||
return;
|
||||
}
|
||||
const formData = $(this).serializeArray();
|
||||
formData.push({
|
||||
name: "client_id",
|
||||
value: $("#general_PrimaryKey").val()
|
||||
});
|
||||
formData.push({
|
||||
name: "api_access",
|
||||
value: $("#is_api").is(":checked") ? 1 : 0
|
||||
});
|
||||
console.log(formData);
|
||||
|
||||
$.ajax({
|
||||
url: "<?= base_url('client/saveApiData') ?>",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
beforeSend: function() {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
toastr.success(response.message);
|
||||
} else {
|
||||
toastr.error(response.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
toastr.error("An error occurred while processing your request.");
|
||||
},
|
||||
complete: function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').fadeOut();
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
$(".claim_webhook").on("input", function() {
|
||||
|
||||
let anyNotEmpty = $(".claim_webhook").toArray().some(input => $(input).val() !== "");
|
||||
|
||||
$(".claim_webhook").prop("required", anyNotEmpty);
|
||||
});
|
||||
|
||||
$(".emp_webhook").on("input", function() {
|
||||
let anyNotEmpty = $(".emp_webhook").toArray().some(input => $(input).val() !== "");
|
||||
|
||||
$(".emp_webhook").prop("required", anyNotEmpty);
|
||||
});
|
||||
</script>
|
||||
@ -88,6 +88,12 @@ body {
|
||||
<span class="d-none d-sm-inline-block">Policies</span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- <li class="nav-item">
|
||||
<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="d-none d-sm-inline-block">API</span>
|
||||
</a>
|
||||
</li> -->
|
||||
<li class="nav-item">
|
||||
<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>
|
||||
@ -96,6 +102,7 @@ body {
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<?php include("client_api.php"); ?>
|
||||
<?php include('client_others_tab.php'); ?>
|
||||
<?php include('notification.php'); ?>
|
||||
<?php include('client_basic_info.php'); ?>
|
||||
@ -246,7 +253,7 @@ body {
|
||||
event.preventDefault();
|
||||
client_notification();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -758,11 +758,34 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/renewal_report') ?>">Renewal Reports</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getTATReport') ?>">TAT Band Reports</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<a href="#policy_tat_report_type" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-file-chart-fill"></i>
|
||||
<span> Policy TAT Reports </span>
|
||||
</a>
|
||||
<div class="collapse" id="policy_tat_report_type">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/1') ?>">TAT Band Wise</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/2') ?>">ACM Status Wise</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/3') ?>">ACM TAT Wise</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) )) { ?>
|
||||
<li>
|
||||
|
||||
328
app/Views/leads_dash.php
Normal file
328
app/Views/leads_dash.php
Normal file
@ -0,0 +1,328 @@
|
||||
<style>
|
||||
body {
|
||||
margin-top: 20px;
|
||||
background: #FAFAFA;
|
||||
}
|
||||
|
||||
.order-card {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.bg-c-blue {
|
||||
background: linear-gradient(45deg, #4099ff, #73b4ff);
|
||||
}
|
||||
|
||||
.bg-c-green {
|
||||
background: linear-gradient(45deg, #2ed8b6, #59e0c5);
|
||||
}
|
||||
|
||||
.bg-c-yellow {
|
||||
background: linear-gradient(45deg, #FFB64D, #ffcb80);
|
||||
}
|
||||
|
||||
.bg-c-pink {
|
||||
background: linear-gradient(45deg, #FF5370, #ff869a);
|
||||
}
|
||||
|
||||
.bg-c-red {
|
||||
background: linear-gradient(45deg, #FF4E50, #F9D423);
|
||||
}
|
||||
|
||||
.bg-c-purple {
|
||||
background: linear-gradient(45deg, #9D50BB, #6E48AA);
|
||||
}
|
||||
|
||||
.bg-c-orange {
|
||||
background: linear-gradient(45deg, #F2994A, #F2C94C);
|
||||
}
|
||||
|
||||
.bg-c-teal {
|
||||
background: linear-gradient(45deg, #1ABC9C, #16A085);
|
||||
}
|
||||
|
||||
.bg-c-cyan {
|
||||
background: linear-gradient(45deg, #00C9FF, #92FE9D);
|
||||
}
|
||||
|
||||
.bg-c-lime {
|
||||
background: linear-gradient(45deg, #A8E063, #56AB2F);
|
||||
}
|
||||
|
||||
.bg-c-indigo {
|
||||
background: linear-gradient(45deg, #3F51B5, #5A55AE);
|
||||
}
|
||||
|
||||
.bg-c-Pelorous {
|
||||
background: linear-gradient(45deg, #00d6db, #00a8b5);
|
||||
}
|
||||
|
||||
.bg-c-Pelorous2 {
|
||||
background: linear-gradient(45deg, #02a8b5, #017f8b);
|
||||
}
|
||||
|
||||
.bg-c-Pelorous3 {
|
||||
background: linear-gradient(45deg, #098895, #046063);
|
||||
}
|
||||
|
||||
.bg-c-Grenadier {
|
||||
background: linear-gradient(45deg, #ff9d37, #ff7a10);
|
||||
}
|
||||
|
||||
.bg-c-Grenadier2 {
|
||||
background: linear-gradient(45deg, #ff8010, #ff4c00);
|
||||
}
|
||||
|
||||
.bg-c-Grenadier3 {
|
||||
background: linear-gradient(45deg, #f06306, #cc4b05);
|
||||
}
|
||||
|
||||
.bg-c-SilverChalice {
|
||||
background: linear-gradient(45deg, #a3a8a8, #8f9494);
|
||||
}
|
||||
|
||||
.bg-c-SilverChalice2 {
|
||||
background: linear-gradient(45deg, #7e8484, #686e6e);
|
||||
}
|
||||
|
||||
.bg-c-SilverChalice3 {
|
||||
background: linear-gradient(45deg, #5c6363, #434949);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.card {
|
||||
border-radius: 5px;
|
||||
-webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16);
|
||||
box-shadow: 0 1px 2.94px 0.06px rgba(4, 26, 55, 0.16);
|
||||
border: none;
|
||||
margin-bottom: 30px;
|
||||
-webkit-transition: all 0.3s ease-in-out;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.card .card-block {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 25px;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
.order-card i {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.f-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.f-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.m-b-1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID, user_team()) ? 'show active' : '';
|
||||
?>
|
||||
<div class="tab-pane fade <?= $isActive ?>" id="leads-dash-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-xl-3 leadTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,1)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">Leads</h6>
|
||||
<h2 class="text-right"><i
|
||||
class="mdi mdi-playlist-check f-left"></i><span><?= isset($lead_data) ? $lead_data['total'] : 0 ?></span>
|
||||
</h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-xl-3 leadTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,2)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">BDS Renewals</h6>
|
||||
<h2 class="text-right"><i
|
||||
class="mdi mdi-playlist-check f-left"></i><span><?= isset($bds_renewal) ? $bds_renewal['total'] : 0 ?></span>
|
||||
</h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</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
|
||||
|
||||
$colorSetCount = count($colorShades); // Number of color sets
|
||||
$shadeCount = count($colorShades[0]); // Number of shades per set
|
||||
$index = 0;
|
||||
foreach ($lead_data as $key => $value) : ?>
|
||||
<?php
|
||||
if ($key == "total" || $key == "won" || substr($key, -4) === "_ids") {
|
||||
continue;
|
||||
} // Skip the total key
|
||||
?>
|
||||
<?php
|
||||
// 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 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;">
|
||||
<?php
|
||||
$policyIds = isset($bds_renewal[$key . '_ids'])
|
||||
? (is_array($bds_renewal[$key . '_ids'])
|
||||
? implode('_', $bds_renewal[$key . '_ids'])
|
||||
: str_replace(' ', '_', $bds_renewal[$key . '_ids']))
|
||||
: '';
|
||||
?>
|
||||
<div class="card order-card" style="background: <?= $bgColor ?>;"
|
||||
onclick="linkRedirectForPolicy('<?= $policyIds ?>')">
|
||||
<h2 class="text-center"><span><?= $value ?></span></h2>
|
||||
<h6 class="m-b-20 font-15 text-center"
|
||||
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
|
||||
<?= $truncatedStatus ?>
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$(".status_tile").hide();
|
||||
});
|
||||
|
||||
function hide_and_show_tile(type, leadType = null) {
|
||||
|
||||
if (type == 1) {
|
||||
|
||||
$('.leadTypeTile').hide();
|
||||
$('.status_tile').show();
|
||||
|
||||
} else {
|
||||
|
||||
$('.leadTypeTile').show();
|
||||
$('.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/inception/list") ?>";
|
||||
var data = {
|
||||
ids: ids,
|
||||
is_dashboard: 1
|
||||
}
|
||||
|
||||
redirectWithPost(url, data, "POST");
|
||||
}
|
||||
|
||||
function linkRedirectForLeads(status, ids) {
|
||||
|
||||
var url = "<?= base_url("leads/list") ?>";
|
||||
var data = {
|
||||
ids: ids,
|
||||
is_dashboard: 1
|
||||
}
|
||||
|
||||
redirectWithPost(url, data, "POST");
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}, method = "GET") {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
const form = document.createElement('form');
|
||||
form.method = method;
|
||||
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>
|
||||
@ -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;
|
||||
@ -884,7 +885,7 @@
|
||||
<?php
|
||||
if (isset($policy_type) && count($policy_type)) {
|
||||
foreach ($policy_type as $value) {
|
||||
if ($value['allocg'] != "Non-EB") {
|
||||
if ($value['allocg'] != "Non-EB" && $value['allocg'] != "Marine") {
|
||||
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 = ' [ <a href="<?= base_url("util/download-excel/member_data"); ?>" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ]';
|
||||
}
|
||||
|
||||
|
||||
div.innerHTML = `
|
||||
<div class="form-group col-md-5">
|
||||
<label>Document Name<span class="text-danger"></span></label>
|
||||
<label>Document Name ${sample_dwn_link}<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="docs_name_${increment}[]" placeholder="${placeholder}">
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
@ -458,9 +465,19 @@ if (isset($selected_lead_type)) {
|
||||
<script>
|
||||
|
||||
$(document).ready(async function () {
|
||||
handleEbAndNonEbEdit(
|
||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
|
||||
);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
handleEbAndNonEbEdit(
|
||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
|
||||
);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
function handleEbAndNonEbEdit(data){
|
||||
@ -709,6 +726,11 @@ if (isset($selected_lead_type)) {
|
||||
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$(".loss_date").each(function () {
|
||||
flatpickr(this, {
|
||||
dateFormat: "d-m-Y",
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@
|
||||
margin: 1.75rem auto;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
<div class="tab-pane fade" id="notification-tab">
|
||||
<input type="hidden" id="client_id_for_client_branch" value="<?= isset($notification['id']) ? $notification['id'] : '' ?>" />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<div class="modal fade" id="policyRegisterModel" tabindex="-1" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||||
<div class="modal fade" id="policyRegisterModel" tabindex="-1" aria-labelledby="fullWidthModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">REGISTER POLICY INFORMATION</h4>
|
||||
<button type="button" onclick="resetAllform()" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@ -150,10 +150,10 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="terrorismSwitch">
|
||||
<label class="form-check-label" for="terrorismSwitch">Is Terrorism Required?</label>
|
||||
<div class="col-md-4 dt-switch-wrapper">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="terrorismSwitch">
|
||||
<label class="custom-control-label" for="terrorismSwitch">Is Terrorism Required?</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
@ -166,7 +166,21 @@
|
||||
<option value="4_month">4 Months</option>
|
||||
<option value="5_month">5 Months</option>
|
||||
<option value="6_month">6 Months</option>
|
||||
<option value="7_month">7 Months</option>
|
||||
<option value="8_month">8 Months</option>
|
||||
<option value="9_month">9 Months</option>
|
||||
<option value="10_month">10 Months</option>
|
||||
<option value="11_month">11 Months</option>
|
||||
<option value="12_month">12 Months</option>
|
||||
<option value="2_year">2 Year</option>
|
||||
<option value="3_year">3 Year</option>
|
||||
<option value="4_year">4 Year</option>
|
||||
<option value="5_year">5 Year</option>
|
||||
<option value="6_year">6 Year</option>
|
||||
<option value="7_year">7 Year</option>
|
||||
<option value="8_year">8 Year</option>
|
||||
<option value="9_year">9 Year</option>
|
||||
<option value="10_year">10 Year</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="locationNoDIV" class="form-group col-md-4">
|
||||
@ -203,11 +217,11 @@
|
||||
<div class="text-right">
|
||||
<button type="submit" id="riskSplitup" class="btn btn-primary">Validate and Add Risk Split up</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" id="submitPolicyRisk" class="btn btn-primary">Submit For Validation</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -244,6 +258,20 @@
|
||||
// console.log("Occupancy : ", occupancyMaster);
|
||||
var storedPolicyData = {};
|
||||
storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
|
||||
|
||||
|
||||
var isFormDirty = false;
|
||||
$(document).ready(function() {
|
||||
// Listen for changes in all inputs, selects, and textareas within your modal
|
||||
$('#policyRegisterModel').on('change input', 'input, select, textarea', function() {
|
||||
// alert("function called");
|
||||
isFormDirty = true;
|
||||
// console.log("Form is dirty",isFormDirty);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
// resetAllform();
|
||||
// console.log("Stored date Found : ", typeof(storedPolicyData));
|
||||
@ -306,6 +334,7 @@
|
||||
});
|
||||
|
||||
$('#productSelectionForm').submit(function(event) {
|
||||
|
||||
// console.log("Submit function called");
|
||||
event.preventDefault();
|
||||
var isValid = $('#productSelectionForm').parsley().validate();
|
||||
@ -358,7 +387,8 @@
|
||||
$("#policyRiskSplitUpForm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
isFormDirty = false;
|
||||
|
||||
|
||||
var isValid = $('#policyRiskSplitUpForm').parsley().validate();
|
||||
// console.log('isValid', isValid);
|
||||
@ -395,35 +425,47 @@
|
||||
}
|
||||
// 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);
|
||||
let building = [...document.querySelectorAll('[id^="building_"]')].map(el => Number(el.value) || 0);
|
||||
let content = [...document.querySelectorAll('[id^="content_"]')].map(el => Number(el.value) || 0);
|
||||
let furniture = [...document.querySelectorAll('[id^="furniture_"]')].map(el => Number(el.value) || 0);
|
||||
let plantAndMachinery = [...document.querySelectorAll('[id^="plantAndMachinery_"]')].map(el => Number(el.value) || 0);
|
||||
let electricalFittings = [...document.querySelectorAll('[id^="electricalFittings_"]')].map(el => Number(el.value) || 0);
|
||||
|
||||
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
|
||||
rawMaterial.reduce((acc, val) => acc + val, 0) +
|
||||
findMaterial.reduce((acc, val) => acc + val, 0);
|
||||
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
|
||||
rawMaterial.reduce((acc, val) => acc + val, 0) +
|
||||
findMaterial.reduce((acc, val) => acc + val, 0) +
|
||||
building.reduce((acc, val) => acc + val, 0) +
|
||||
content.reduce((acc, val) => acc + val, 0) +
|
||||
furniture.reduce((acc, val) => acc + val, 0) +
|
||||
plantAndMachinery.reduce((acc, val) => acc + val, 0) +
|
||||
electricalFittings.reduce((acc, val) => acc + val, 0);
|
||||
|
||||
let allowedSI = Number($("#policySI").val()) || 0;
|
||||
// alert(allowedSI);
|
||||
|
||||
if (totalSI > allowedSI) {
|
||||
toastr.error("Sum Insured Exceeds Allowed Limit", "ERROR");
|
||||
return false;
|
||||
if (totalSI != allowedSI) {
|
||||
console.log("allowedSI : ", allowedSI, " totalSI : ", totalSI);
|
||||
toastr.error("Sum Insured Does not Match Allowed Limit", "ERROR");
|
||||
return false;
|
||||
}
|
||||
// console.log("Total SI: ", totalSI);
|
||||
}else{
|
||||
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);
|
||||
|
||||
@ -432,6 +474,10 @@
|
||||
// Determine the number of dynamic rows based on a field that appears per row
|
||||
const totalRows = formDataSplitUp.filter(field => field.name === "building[]").length;
|
||||
|
||||
if (totalRows != policyDetailsData.location_no) {
|
||||
toastr.error("Please Enter All Risk Address", "ERROR");
|
||||
return;
|
||||
}
|
||||
// Initialize empty objects for each row
|
||||
for (let i = 0; i < totalRows; i++) {
|
||||
groupData.push({});
|
||||
@ -465,6 +511,7 @@
|
||||
// console.log("Grouped Data as Objects: ", policyRiskSplitUpData);
|
||||
|
||||
savePolicyDataLocal();
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -484,11 +531,28 @@
|
||||
return;
|
||||
}
|
||||
const formData = $("#policyRiskAddressForm").serializeArray();
|
||||
console.log("formdata 1 : ", formData);
|
||||
$("[id^='isBasement_']").each(function() {
|
||||
let checkbox = $(this);
|
||||
let isChecked = checkbox.is(":checked");
|
||||
let increment = checkbox.attr("id").split("_")[1];
|
||||
|
||||
formData.push({
|
||||
name: `is_basement[]`,
|
||||
value: isChecked ? "yes" : "no"
|
||||
});
|
||||
});
|
||||
console.log("formdata 2 : ", formData);
|
||||
|
||||
const groupedData = [];
|
||||
|
||||
// Determine the number of dynamic rows
|
||||
const totalRows = formData.filter(field => field.name === "pin_code[]").length;
|
||||
|
||||
if (totalRows != policyDetailsData.location_no) {
|
||||
toastr.error("Please Enter All Risk Address", "ERROR");
|
||||
return;
|
||||
}
|
||||
// Initialize empty objects for each row
|
||||
for (let i = 0; i < totalRows; i++) {
|
||||
groupedData.push({});
|
||||
@ -513,13 +577,14 @@
|
||||
});
|
||||
|
||||
policyRiskAddress = groupedData;
|
||||
// console.log("Grouped Data as Objects: ", policyRiskAddress);
|
||||
console.log("Grouped Data as Objects: ", policyRiskAddress);
|
||||
|
||||
if (productSelectionData.singleProduct == 'on') {
|
||||
savePolicyDataLocal();
|
||||
} else {
|
||||
// if (productSelectionData.singleProduct == 'on') {
|
||||
// savePolicyDataLocal();
|
||||
// } else {
|
||||
riskSplitup();
|
||||
}
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
$("#policyDetailsForm").submit(function(event) {
|
||||
@ -538,14 +603,17 @@
|
||||
return;
|
||||
}
|
||||
var formData = $("#policyDetailsForm").serializeArray();
|
||||
formData.push({
|
||||
name: "terrorism",
|
||||
value: $('#terrorismSwitch').is(':checked') ? 'yes' : 'no'
|
||||
})
|
||||
$.each(formData, function(i, field) {
|
||||
policyDetailsData[field.name] = field.value;
|
||||
});
|
||||
// // console.log("form data", policyDetailsData.location_no);
|
||||
console.log("form data", formData);
|
||||
|
||||
if (formData !== null && formData !== '') {
|
||||
// console.log("form submitted trying to open the ris info tab");
|
||||
// riskInfoTabOpened();
|
||||
|
||||
const riskTab = new bootstrap.Tab(document.getElementById('risk-info-tab'));
|
||||
riskTab.show();
|
||||
|
||||
@ -585,7 +653,36 @@
|
||||
hideAndShowBurglary();
|
||||
})
|
||||
|
||||
}
|
||||
}else{
|
||||
// alert("you got ir");
|
||||
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();
|
||||
@ -638,31 +735,32 @@
|
||||
const newRowRisk = document.createElement("div");
|
||||
// // console.log("Risk Split Up for address : ", policyRiskAddress.length)
|
||||
// policyRiskAddress
|
||||
|
||||
console.log(increment2);
|
||||
console.log(policyRiskAddress[increment2-1])
|
||||
newRowRisk.innerHTML += `
|
||||
<h5 class = "fire">Fire (Sookshma/Laghu) Details</h5>
|
||||
<h5 class = "fire">Fire <?= isset($product) ? $product : "" ?> Details</h5>
|
||||
<h5>Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}</h5>
|
||||
<input type = "hidden" name = "location_selected[]" value = "${policyRiskAddress[increment2-1].select_location}" id = "location_selected_${increment2}" />
|
||||
<div class = "row">
|
||||
<div class="form-group col-md-4 multi_location_company">
|
||||
<label for="building_${increment2}">Building</label>
|
||||
<input type="text" id="building_${increment2}" name="building[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="building_${increment2}" name="building[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<label for="content_${increment2}">Content</label>
|
||||
<input type="text" id="content_${increment2}" name="content[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="content_${increment2}" name="content[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<label for="furniture_${increment2}">Furniture/Office Equipment</label>
|
||||
<input type="text" id="furniture_${increment2}" name="furniture[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="furniture_${increment2}" name="furniture[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<label for="plantAndMachinery_${increment2}">Plant and Machinery</label>
|
||||
<input type="text" id="plantAndMachinery_${increment2}" name="plant_and_machinery[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="plantAndMachinery_${increment2}" name="plant_and_machinery[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company">
|
||||
<label for="electricalFittings_${increment2}">Electrical Fittings</label>
|
||||
<input type="text" id="electricalFittings_${increment2}" name="electrical_fittings[]" class="form-control multi_location_company "/>
|
||||
<input type="number" id="electricalFittings_${increment2}" name="electrical_fittings[]" class="form-control multi_location_company "/>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
@ -678,7 +776,7 @@
|
||||
<input type="number" id="rawMaterial_${increment2}" name="raw_material[]" class="form-control multi_location_company" />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company">
|
||||
<label for="finishedStock_${increment2}">Finished Stock</label>
|
||||
<label for="finishedStock_${increment2}">Stock</label>
|
||||
<input type="number" id="finishedStock_${increment2}" name="finished_stock[]" class="form-control multi_location_company"/>
|
||||
</div>
|
||||
</div>
|
||||
@ -782,20 +880,9 @@
|
||||
<label for="address3_${increment}">Address 3</label>
|
||||
<input type="text" id="address3_${increment}" name="address3[]" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="constructionType_${increment}">Construction Type<span class="text-danger">*</span></label>
|
||||
<select id="constructionType_${increment}" name="construction_type[]" class="form-control">
|
||||
<option value="kutcha" selected>Kutcha</option>
|
||||
<option value="pucca">Pucca</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="basementSI_${increment}">Basement Sum Insured</label>
|
||||
<input type="text" id="basementSI_${increment}" name="basement_si[]" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="occupancy_${increment}">Occupancy<span class="text-danger">*</span></label>
|
||||
<select id="occupancy_${increment}" name="occupancy[]" class="form-control" onchange="showRequiredFieldsBasedOnLocation('occupancy_${increment}')" required>
|
||||
<div class="form-group col-md-4" style = "width: 10px !important;">
|
||||
<label for="occupancy_${increment}">Occupancy Risk<span class="text-danger">*</span></label>
|
||||
<select id="occupancy_${increment}" name="occupancy[]" class="form-control" onchange="showRequiredFieldsBasedOnLocation(this)" required>
|
||||
<option value="">Select</option>
|
||||
${occupancyMaster.map(occupancy =>
|
||||
`<option value="${occupancy.id}">${occupancy.description}</option>`
|
||||
@ -803,16 +890,30 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4 common_location_occupancy">
|
||||
<label for="isBasement_${increment}">Basement<span class="text-danger">*</span></label>
|
||||
<select id="isBasement_${increment}" name="is_basement[]" class="form-control common_location_occupancy" required>
|
||||
<option value="yes" selected>Yes</option>
|
||||
<option value="no">No</option>
|
||||
<label for="iibCode_${increment}">IIB Code<span class="text-danger">*</span></label>
|
||||
<input type="text" onchange = "updateOccupancyRisk(this)" id="iibCode_${increment}" name="iib_code[]" class="form-control common_location_occupancy" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="constructionType_${increment}">Construction Type<span class="text-danger">*</span></label>
|
||||
<select id="constructionType_${increment}" name="construction_type[]" class="form-control">
|
||||
<option value="kutcha" selected>Kutcha</option>
|
||||
<option value="pucca">Pucca</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4 common_location_occupancy">
|
||||
<label for="iibCode_${increment}">IIB Code<span class="text-danger">*</span></label>
|
||||
<input type="text" id="iibCode_${increment}" name="iib_code[]" class="form-control common_location_occupancy" required>
|
||||
|
||||
<div class="dt-switch-wrapper col-md-4 common_location_occupancy d-flex align-items-center">
|
||||
<div class="custom-control custom-switch d-flex justify-content-center">
|
||||
<input type="checkbox" class="custom-control-input" id="isBasement_${increment}" onchange="hideShowBasement(this)">
|
||||
<label class="custom-control-label" for="isBasement_${increment}">Basement</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4" style="display:none" >
|
||||
<label for="basementSI_${increment}">Basement Utilisation</label>
|
||||
<input type="text" id="basementSI_${increment}" name="basement_si[]" class="form-control"/>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-4 multiLocationOccupancy">
|
||||
<label for="select_location_${increment}">Location <span class="text-danger">*</span></label>
|
||||
<select required id="select_location_${increment}" name="select_location[]" class="form-control multiLocationOccupancy">
|
||||
@ -850,26 +951,13 @@
|
||||
|
||||
`;
|
||||
|
||||
// newRow2.innerHTML += `
|
||||
// <div class = "row">
|
||||
// <div class="col-md-12 text-right">
|
||||
// <button type ="submit" id="riskSplitup" class="btn btn-primary">Validate and Add Risk Split up</button>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div class = "row">
|
||||
// <div class="col-md-12 text-right">
|
||||
// <button type ="submit" id="submitPolicyRisk" class="btn btn-primary">Submit For Validation</button>
|
||||
// </div>
|
||||
// </div>
|
||||
|
||||
// `;
|
||||
|
||||
container.appendChild(newRow);
|
||||
// container.appendChild(newRow2);
|
||||
|
||||
const selectElement = document.getElementById(`select_location_${increment}`);
|
||||
selectElement.innerHTML = "";
|
||||
for (let i = 1; i <= policyDetailsData.location_no; i++) {
|
||||
console.log("location no : ", policyDetailsData.location_no);
|
||||
const option = document.createElement('option');
|
||||
option.value = `Location ${i}`;
|
||||
option.textContent = `Location ${i}`;
|
||||
@ -887,37 +975,33 @@
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.duplicate-btn', function() {
|
||||
|
||||
|
||||
// console.log("button is clicked");
|
||||
// console.log("increment cout ", increment);
|
||||
|
||||
$(document).on('click', '.duplicate-btn', function () {
|
||||
|
||||
if (policyDetailsData.location_no >= increment) {
|
||||
const $rowToClone = $(this).closest('.form-row');
|
||||
|
||||
// Destroy Select2 for the current and previous occupancy fields
|
||||
$(`#occupancy_${increment}`).select2('destroy');
|
||||
$(`#occupancy_${increment - 1}`).select2('destroy');
|
||||
|
||||
// Clone the row
|
||||
const $clone = $rowToClone.clone();
|
||||
|
||||
$clone.find('.select2-hidden-accessible').each(function() {
|
||||
// Clean up select2 artifacts from the clone
|
||||
$clone.find('.select2-hidden-accessible').each(function () {
|
||||
$(this).select2('destroy');
|
||||
});
|
||||
|
||||
$clone.find('.select2-container').remove();
|
||||
|
||||
// Increment the counter
|
||||
|
||||
|
||||
// Update all IDs and reset values in the clone
|
||||
$clone.find('[id]').each(function() {
|
||||
// Update all IDs in the clone
|
||||
$clone.find('[id]').each(function () {
|
||||
const oldId = $(this).attr('id');
|
||||
const newId = oldId.replace(/_(\d+)$/, `_${increment}`);
|
||||
$(this).attr('id', newId);
|
||||
});
|
||||
|
||||
// Update labels to match new IDs
|
||||
$clone.find('label').each(function() {
|
||||
// Update all labels
|
||||
$clone.find('label').each(function () {
|
||||
const oldFor = $(this).attr('for');
|
||||
if (oldFor) {
|
||||
const newFor = oldFor.replace(/_(\d+)$/, `_${increment}`);
|
||||
@ -928,18 +1012,35 @@
|
||||
// Insert the cloned row after the original
|
||||
$clone.insertAfter($rowToClone);
|
||||
|
||||
let selectedLocation = $(`#select_location_${increment}`).val();
|
||||
$(`#select_location_${increment} option[value="${selectedLocation}"]`).remove();
|
||||
$(`#occupancy_${increment}`).select2();
|
||||
// Refill and update the select_location dropdown
|
||||
const selectElement = document.getElementById(`select_location_${increment}`);
|
||||
selectElement.innerHTML = "";
|
||||
for (let i = 1; i <= policyDetailsData.location_no; i++) {
|
||||
const option = document.createElement('option');
|
||||
option.value = `Location ${i}`;
|
||||
option.textContent = `Location ${i}`;
|
||||
selectElement.appendChild(option);
|
||||
}
|
||||
|
||||
for (let i = 1;i<increment;i++){
|
||||
|
||||
let selectedLocation = $(`#select_location_${i}`).val();
|
||||
$(`#select_location_${increment} option[value="${selectedLocation}"]`).remove();
|
||||
|
||||
}
|
||||
|
||||
// Re-initialize Select2 for both fields
|
||||
$(`#occupancy_${increment - 1}`).select2(); // previous
|
||||
$(`#occupancy_${increment}`).select2(); // current
|
||||
$(`#iibCode_${increment}`).val(""); // current
|
||||
increment++;
|
||||
|
||||
} else {
|
||||
toastr.error("Maximum no of allowed locations reached", "Error")
|
||||
toastr.error("Maximum number of allowed locations reached", "Error");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
||||
function addOrRemoveAdd() {
|
||||
// console.log("chceck box clicked");
|
||||
if ($("#sameAsCommunicationAddress").is(":checked")) {
|
||||
@ -964,15 +1065,15 @@
|
||||
$('[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);
|
||||
// $('[class*="single_location_occupancy"]').hide().removeAttr("required", false);
|
||||
$('[class*="multi_location_company"]').hide().removeAttr('required');
|
||||
$("#riskSplitup").hide();
|
||||
// $('[class*="multi_location_company"]').hide().removeAttr('required');
|
||||
// $("#riskSplitup").hide();
|
||||
$("#submitPolicyRisk").show();
|
||||
$("#risksplitupTab").hide();
|
||||
// $("#risksplitupTab").hide();
|
||||
// $('[class*="multiLocationOccupancy"]').hide().removeAttr('required', false);
|
||||
// $('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false);
|
||||
|
||||
@ -1005,79 +1106,62 @@
|
||||
}
|
||||
|
||||
function showRequiredFieldsBasedOnLocation(element) {
|
||||
|
||||
if (element) {
|
||||
// alert(element);
|
||||
var selectedOccupancy = $(`#${element}`).val();
|
||||
var selectedOccupancy = $(element).val(); // FIXED
|
||||
var selectedOccupancyMasterRow = occupancyMaster.find(iib => iib.id == selectedOccupancy);
|
||||
// console.log("selected occupancy masater ", selectedOccupancyMasterRow)
|
||||
// console.log("selected occupancy masater ", occupancyMaster)
|
||||
|
||||
if (!selectedOccupancyMasterRow) return;
|
||||
|
||||
var iibCODE = selectedOccupancyMasterRow.iib_code;
|
||||
// console.log("selected occupancy masater ", iibCODE)
|
||||
var elementID = element;
|
||||
var elementID = element.id; // FIXED
|
||||
let increment = elementID.split("_").pop();
|
||||
// console.log("selected occupancy masater increment ", increment)
|
||||
// console.log("selected occupancy masater element ", $(`#iibCode_${increment}`))
|
||||
|
||||
setTimeout(function() {
|
||||
$(`#iibCode_${increment}`).val(iibCODE); // Set the value
|
||||
// console.log("Selected --------------------", $(`#iibCode_${increment}`).val()); // Log the value
|
||||
}, 1000);
|
||||
|
||||
|
||||
$(`#iibCode_${increment}`).val(iibCODE);
|
||||
}, 500);
|
||||
}
|
||||
// console.log("onchange occupancy function called ");
|
||||
|
||||
// // console.log("onchange occupancy function called ", selectedOccupancy);
|
||||
// // console.log("onchange occupancy function called ", selectedOccupancyMasterRow);
|
||||
// // console.log("onchange occupancy function called ", iibCODE);
|
||||
// // console.log("onchange occupancy function called ", increment);
|
||||
|
||||
|
||||
$('[class*="common_location_occupancy"]').show().prop("required", "required");
|
||||
$('[class*="common_location_occupancy"]').show().prop("required", true);
|
||||
var selectedProduct = productSelectionData;
|
||||
if (selectedProduct.singleProduct == 'on') {
|
||||
$('[class*="single_location_occupancy"]').show().prop("required", "required");
|
||||
|
||||
} else if (selectedProduct.multipleProduct == 'on') {
|
||||
// // console.log("Muliple location");f
|
||||
$('[class*="multiLocationOccupancy"]').show().prop('required', 'required');
|
||||
if (selectedProduct.singleProduct === 'on') {
|
||||
$('[class*="single_location_occupancy"]').show().prop("required", true);
|
||||
} else if (selectedProduct.multipleProduct === 'on') {
|
||||
$('[class*="multiLocationOccupancy"]').show().prop('required', true);
|
||||
|
||||
if (selectedProduct.multilocation_type == "multiLocation") {
|
||||
|
||||
// // console.log("multiple location without Floater");
|
||||
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required');
|
||||
|
||||
} else if (selectedProduct.multilocation_type == "multiFloater") {
|
||||
|
||||
// // console.log("Muliple location With Floater");
|
||||
$('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false);
|
||||
|
||||
} else if (selectedProduct.multilocation_type == "stockFloater") {
|
||||
|
||||
// // console.log("multiple location with stock floater");
|
||||
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required');
|
||||
$('[class*="stockSI"]').hide().removeAttr('required', false);
|
||||
if (selectedProduct.multilocation_type === "multiLocation") {
|
||||
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', true);
|
||||
} else if (selectedProduct.multilocation_type === "multiFloater") {
|
||||
$('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required');
|
||||
} else if (selectedProduct.multilocation_type === "stockFloater") {
|
||||
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', true);
|
||||
$('[class*="stockSI"]').hide().removeAttr('required');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function registerPolicyData() {
|
||||
|
||||
var policyType;
|
||||
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)"
|
||||
}else if (totalSI >500000000 ){
|
||||
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,
|
||||
policyType: policyType,
|
||||
productSelection: productSelectionData,
|
||||
policyDetails: policyDetailsData,
|
||||
locations: []
|
||||
@ -1108,6 +1192,8 @@
|
||||
}
|
||||
|
||||
function savePolicyDataLocal() {
|
||||
|
||||
isSaved = false;
|
||||
// Generate the JSON structure using the registerPolicyData function
|
||||
var policyData = registerPolicyData();
|
||||
|
||||
@ -1127,18 +1213,20 @@
|
||||
// Save the updated data back to localStorage
|
||||
localStorage.setItem('policyData', JSON.stringify(existingData));
|
||||
if (!$.isEmptyObject(existingData)) {
|
||||
|
||||
|
||||
// console.log("DATA FROM DB : ", (existingData));
|
||||
let data = (existingData);
|
||||
Object.keys(data).forEach(key => {
|
||||
|
||||
policySummary[key] = addPolicySummaryTable(data[key], key);
|
||||
prependTable(policySummary[key],key);
|
||||
prependTable(policySummary[key], key);
|
||||
});
|
||||
}
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
toastr.success("Policy Information Collected ","SUCCESS");
|
||||
toastr.success("Policy Information Collected ", "SUCCESS");
|
||||
closeModal();
|
||||
changeTerrorism(Number($("#policySI").val()));
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// console.log("Updated policy data in localStorage:", existingData);
|
||||
@ -1220,7 +1308,7 @@
|
||||
loadPolicyDataBack(data);
|
||||
assignDataToFields(data);
|
||||
// alert("inside else");
|
||||
}else{
|
||||
} else {
|
||||
// alert("nothing");
|
||||
}
|
||||
// console.log("policy data : ", data);
|
||||
@ -1255,9 +1343,9 @@
|
||||
const policyDetails = data.policyDetails;
|
||||
Object.keys(policyDetails).forEach(key => {
|
||||
$(`#${key}`).val(policyDetails[key]);
|
||||
// // console.log("Key ",key," set value : ",policyDetails[key]);
|
||||
// console.log("Key ", key, " set value : ", policyDetails[key]);
|
||||
});
|
||||
|
||||
$('#terrorismSwitch').prop('checked', policyDetails.terrorism === "yes")
|
||||
// Populate Risk Addresses
|
||||
data.locations.forEach((location, index) => {
|
||||
addHTMLInputForRiskAddress();
|
||||
@ -1277,12 +1365,13 @@
|
||||
$(`#constructionType${prefix}`).val(risk.construction_type);
|
||||
$(`#occupancy${prefix}`).select2();
|
||||
$(`#occupancy${prefix}`).val(risk.occupancy).trigger("change");
|
||||
$(`#isBasement${prefix}`).val(risk.is_basement);
|
||||
// $(`#isBasement${prefix}`).val(risk.is_basement);
|
||||
$(`#iibCode${prefix}`).val(risk.iib_code);
|
||||
$(`#buisness_desc${prefix}`).val(risk.buisness_desc);
|
||||
$(`#select_location${prefix}`).val(risk.select_location);
|
||||
$(`#basementSI${prefix}`).val(risk.basement_si);
|
||||
|
||||
$(`#isBasement${prefix}`).prop('checked', risk.is_basement === "yes").trigger("change");
|
||||
|
||||
|
||||
|
||||
@ -1318,7 +1407,7 @@
|
||||
});
|
||||
|
||||
|
||||
|
||||
isFormDirty = false; // Reset the form dirty flag
|
||||
}
|
||||
|
||||
function checkandassignLeadData() {
|
||||
@ -1332,11 +1421,12 @@
|
||||
|
||||
function assignLeadData() {
|
||||
const lead_data = <?= json_encode(json_decode($lead_data['custom_fields'])) ?>;
|
||||
var clientName = <?= isset($lead_data['client_name']) ? json_encode($lead_data['client_name']) : ""?>;
|
||||
var clientName = <?= isset($lead_data['client_name']) ? json_encode($lead_data['client_name']) : "" ?>;
|
||||
var client_type = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
|
||||
var mobile = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
|
||||
var email = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
|
||||
var mobile = <?= isset($lead_data['contact_person_mobile']) ? $lead_data['contact_person_mobile'] : "" ?>;
|
||||
var contact_email = "<?= isset($lead_data['contact_person_email']) ? $lead_data['contact_person_email'] : "" ?>";
|
||||
var panNo = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
|
||||
var buisnessType = <?= isset($lead_data['entity_type_id']) ? $lead_data['entity_type_id'] : "" ?>;
|
||||
// console.log("client_type : ".client_type);
|
||||
if (lead_data) {
|
||||
// lead_data = JSON.parse(lead_data);
|
||||
@ -1358,9 +1448,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$("#client_type").val(client_type).trigger("change");
|
||||
$("#insured_name").val(clientName);
|
||||
$("#address1").val(lead_data.address);
|
||||
$("#pin_code").val(lead_data.pincode);
|
||||
$("#mobile").val(mobile);
|
||||
$("#email").val(contact_email);
|
||||
console.log("buisness type : ", buisnessType);
|
||||
$("#type_of_buisness").val(buisnessType);
|
||||
// var policy_type = lead_data.policy_type_id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1378,6 +1475,8 @@
|
||||
}
|
||||
|
||||
function resetAllform() {
|
||||
|
||||
// isFormDirty = false;
|
||||
// console.log("FORM RESETED SUCCESSFULLY");
|
||||
$("#productSelectionForm")[0].reset();
|
||||
$("#policyDetailsForm")[0].reset();
|
||||
@ -1403,12 +1502,39 @@
|
||||
hideAndShowBurglary()
|
||||
}
|
||||
|
||||
$('.close').on('click', function() {
|
||||
$('.tab-pane').removeClass('active show');
|
||||
$('.close').on('click', function(e) {
|
||||
console.log("is form dirty : ", isFormDirty);
|
||||
if (isFormDirty) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
Swal.fire({
|
||||
title: 'You have unsaved changes!',
|
||||
text: 'Do you want to close without saving your data?',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Yes, close it',
|
||||
cancelButtonText: 'No, stay here',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
isFormDirty = false; // Reset flag
|
||||
closeModal();
|
||||
resetAllform();
|
||||
// $('#policyRegisterModel').modal('hide');
|
||||
$('.tab-pane').removeClass('active show');
|
||||
$("#addRiskInfo, #addRiskSplitUp").empty();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
} else {
|
||||
resetAllform();
|
||||
$('.tab-pane').removeClass('active show');
|
||||
$("#addRiskInfo, #addRiskSplitUp").empty();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#addRiskInfo, #addRiskSplitUp").empty();
|
||||
})
|
||||
|
||||
function copyFirePolicy() {
|
||||
// console.log("Copying Fire Policy Data...");
|
||||
@ -1429,4 +1555,108 @@
|
||||
hideAndShowBurglary();
|
||||
|
||||
}
|
||||
|
||||
$(document).on('input', 'input[id^="pin_code"]', function() {
|
||||
// alert("inside");
|
||||
|
||||
let value = $(this).val().replace(/\D/g, '').slice(0, 6);
|
||||
$(this).val(value);
|
||||
});
|
||||
|
||||
|
||||
function closeModal() {
|
||||
|
||||
document.querySelector('#policyRegisterModel [data-dismiss="modal"]').click();
|
||||
}
|
||||
|
||||
function updateOccupancyRisk(element) {
|
||||
let iibCode = $(element).val();
|
||||
|
||||
// Find matching occupancy row
|
||||
let matchedOccupancy = occupancyMaster.find(iib => iib.iib_code == iibCode);
|
||||
let matchedId = matchedOccupancy ? matchedOccupancy.id : null;
|
||||
|
||||
// Get increment from the element ID, like "iibCode_3"
|
||||
let elementID = element.id;
|
||||
let increment = elementID.split("_").pop(); // Extract "3" from "iibCode_3"
|
||||
|
||||
if (matchedId) {
|
||||
$(`#occupancy_${increment}`).val(matchedId).trigger("change");
|
||||
$(`#occupancy_${increment}`).select2();
|
||||
} else {
|
||||
toastr.error("Invalid IIB Code", "Error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function hideShowBasement(element) {
|
||||
let elementID = element.id;
|
||||
let increment = elementID.split("_").pop();
|
||||
|
||||
let isBasement = $(`#isBasement_${increment}`).is(":checked");
|
||||
|
||||
// Get the label associated with the input
|
||||
let label = $(`label[for='basementSI_${increment}']`);
|
||||
|
||||
if (isBasement) {
|
||||
$(`#basementSI_${increment}`).parent().show();
|
||||
$(`#basementSI_${increment}`).prop("required", "required");
|
||||
|
||||
// Add * if not already there
|
||||
if (label.find(".text-danger").length === 0) {
|
||||
label.append('<span class="text-danger">*</span>');
|
||||
}
|
||||
} else {
|
||||
$(`#basementSI_${increment}`).parent().hide();
|
||||
$(`#basementSI_${increment}`).removeAttr("required");
|
||||
|
||||
// Remove * if exists
|
||||
label.find(".text-danger").remove();
|
||||
}
|
||||
}
|
||||
|
||||
// function saveDataAsDraft() {
|
||||
// return new Promise((resolve) => {
|
||||
// const forms = [
|
||||
// document.getElementById('productSelectionForm'),
|
||||
// document.getElementById('policyDetailsForm'),
|
||||
// document.getElementById('policyRiskAddressForm'),
|
||||
// document.getElementById('policyRiskSplitUpForm')
|
||||
// ];
|
||||
|
||||
// let isDirty = false;
|
||||
|
||||
// forms.forEach(form => {
|
||||
// if (form) {
|
||||
// const formInputs = form.querySelectorAll('input, select, textarea');
|
||||
// formInputs.forEach(input => {
|
||||
// if (input.defaultValue !== input.value && input.value !== '') {
|
||||
// isDirty = true;
|
||||
// }
|
||||
|
||||
// if (input.type === 'checkbox' || input.type === 'radio') {
|
||||
// if (input.checked !== input.defaultChecked) {
|
||||
// isDirty = true;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
// if (isDirty) {
|
||||
// Swal.fire({
|
||||
// title: 'You have unsaved changes!',
|
||||
// text: 'Do you want to close without saving your data?',
|
||||
// icon: 'warning',
|
||||
// showCancelButton: true,
|
||||
// confirmButtonText: 'Yes, close it',
|
||||
// cancelButtonText: 'No, stay here',
|
||||
// }).then((result) => {
|
||||
// resolve(result.isConfirmed);
|
||||
// });
|
||||
// } else {
|
||||
// resolve(true); // No unsaved changes, allow closing
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
@ -848,8 +848,9 @@ $('#endorsement_no').on('change', function(){
|
||||
|
||||
if(policy_no && endorsement_no){
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no_and_endo_no/');?>'+ policy_no + '/' + endorsement_no,
|
||||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no_and_endo_no/');?>',
|
||||
type: "GET",
|
||||
data : {policy_no : policy_no, endorsement_no : endorsement_no},
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
|
||||
@ -3721,8 +3721,9 @@ $('#policy_no').change(function(){
|
||||
|
||||
if($pt_id == "" && policy_no != ""){
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>'+policy_no,
|
||||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>',
|
||||
type: "GET",
|
||||
data : { policy_no : policy_no },
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<?php foreach ($multi_file_data as $file) : ?>
|
||||
<div class="form-check">
|
||||
|
||||
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>" checked>
|
||||
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>">
|
||||
<label class="form-check-label" for="file_<?= $file['id'] ?>">
|
||||
<?= htmlspecialchars($file['docs_name']) ?> - <?= htmlspecialchars($file['file_name']) ?>
|
||||
</label>
|
||||
|
||||
@ -20,7 +20,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -20,7 +20,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
32
app/Views/rfq/burglary.php
Normal file
32
app/Views/rfq/burglary.php
Normal file
@ -0,0 +1,32 @@
|
||||
<hr>
|
||||
|
||||
<div class="form-row custom_fields">
|
||||
|
||||
<!-- Risk Location -->
|
||||
<div class="form-group col-md-6">
|
||||
<label>Risk Location</label><br>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="risk_location" value="single" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'single' ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label">Single</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="risk_location" value="multi_with_floter" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_with_floter' ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label">Multi with Floter</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="risk_location" value="multi_without_floter" <?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_without_floter' ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label">Multi without Floter</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -68,7 +68,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address:</label>
|
||||
<textarea class="form-control" id="address" name="address"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" id="multi_floater" name="risk_location" value="multi_with_floter"
|
||||
<?= isset($lead_edit_data['risk_location']) && $lead_edit_data['risk_location'] == 'multi_with_floter' ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="multi_floater">multi_with_floter</label>
|
||||
<label class="form-check-label" for="multi_floater">Multi With Floater</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" id="multi_no_floater" name="risk_location" value="multi_without_floter"
|
||||
@ -81,7 +81,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -13,6 +13,21 @@
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_policy_type_${increment}" name="first_policy_type_[]"
|
||||
value="<?= htmlspecialchars($value['policy_type']) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control loss_date" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]"
|
||||
value="<?= htmlspecialchars($value['date_of_loss']) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"
|
||||
value="<?= htmlspecialchars($value['cause_of_loss']) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]"
|
||||
@ -23,11 +38,6 @@
|
||||
<input type="text" class="form-control" id="first_settled_amount_${increment}" name="first_settled_amount[]"
|
||||
value="<?= htmlspecialchars($value['settled_amount']) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"
|
||||
value="<?= htmlspecialchars($value['cause_of_loss']) ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]"
|
||||
|
||||
@ -68,7 +68,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -14,7 +14,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address of the Insured -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address of the Insured</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address of the Insured -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address of the Insured</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address of the Insured -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address of the Insured</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"></textarea>
|
||||
</div>
|
||||
|
||||
35
app/Views/rfq/installment_fields.php
Normal file
35
app/Views/rfq/installment_fields.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// Example: Loop through $installments array if available
|
||||
if (!empty($installments)) {
|
||||
foreach ($installments as $index => $installment) {
|
||||
?>
|
||||
<div class="form-row align-items-end">
|
||||
|
||||
<input type="hidden" name="installment_primary_key[]" value="<?= isset($installment['id']) ? $installment['id'] : '' ?>">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="installment_amount">Installment Amount</label>
|
||||
<input type="text" class="form-control" name="installment_amount[]" placeholder="Enter Amount"
|
||||
value="<?= isset($installment['installment_amount']) ? $installment['installment_amount'] : '' ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="payment_date">Payment Date</label>
|
||||
<input type="text" class="form-control payment_date" name="payment_date[]" placeholder="DD/MM/YYYY"
|
||||
value="<?= isset($installment['payment_date']) && $installment['payment_date'] != '0000-00-00' ? date('d/m/Y', strtotime($installment['payment_date'])) : '' ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="utr_no">UTR No.</label>
|
||||
<input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No."
|
||||
value="<?= isset($installment['utr_no']) ? $installment['utr_no'] : '' ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<button type="button" class="btn btn-danger remove-installment">X</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -178,7 +178,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1">value="<?= isset($lead_edit_data['address']) ? $lead_edit_data['address'] : '' ?>"</textarea>
|
||||
</div>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
<div class="form-row custom_fields">
|
||||
<!-- Risk Location -->
|
||||
<div class="form-group col-md-6">
|
||||
<!-- <div class="form-group col-md-6">
|
||||
<label>Risk Location</label>
|
||||
<div>
|
||||
<?php
|
||||
@ -21,7 +21,7 @@
|
||||
<label class="form-check-label" for="multi_no_floater">Multi without Floater</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- Policy Period -->
|
||||
<div class="form-group col-md-3">
|
||||
@ -67,7 +67,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -27,6 +27,10 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -33,7 +33,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
$rowTotal += $numValue; // Add to row total
|
||||
}
|
||||
?>
|
||||
<td><?= esc($value) ?></td>
|
||||
<td onclick="redirectTATtoClaims(`<?= $row['TAT_Category'] ?>`,`<?= $policyType ?>`)"><?= esc($value) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
|
||||
</tr>
|
||||
@ -129,4 +129,41 @@
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
</script>
|
||||
<script>
|
||||
function redirectTATtoClaims(tat_category, policyType) {
|
||||
// Safely render PHP dates inside JavaScript strings
|
||||
var fromDate = "<?= isset($fromDate) && $fromDate != null ? change_date_format($fromDate) : date('Y-m-d', strtotime('-90 days')) ?>";
|
||||
var toDate = "<?= isset($toDate) && $toDate != null ? change_date_format($toDate) : date('Y-m-d 23:59:59') ?>";
|
||||
|
||||
var data = {
|
||||
'tat_category': tat_category,
|
||||
'is_dashboard': 4,
|
||||
'ticket_type_id': policyType,
|
||||
'from_date': fromDate,
|
||||
'to_date': toDate
|
||||
};
|
||||
|
||||
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||
}
|
||||
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = url;
|
||||
|
||||
for (const key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;
|
||||
input.value = data[key];
|
||||
form.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
1
app/Views/testWebhook.php
Normal file
1
app/Views/testWebhook.php
Normal file
@ -0,0 +1 @@
|
||||
Hello
|
||||
@ -11,6 +11,18 @@
|
||||
background-color: #f0f0f0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
color: #007bff;
|
||||
font-size: 15px;
|
||||
transition: 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
color: #0056b3;
|
||||
font-size: 24px;
|
||||
}
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -168,7 +180,15 @@
|
||||
<!-- end first_data_points -->
|
||||
|
||||
<br><br>
|
||||
<h5>Claim Details</h5>
|
||||
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<h5 style="margin: 0;">
|
||||
Claim Details
|
||||
<i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for more details" style="margin-left: 5px;"></i>
|
||||
<?= isset($ticket_data['claim_number']) && !empty($ticket_data['claim_number']) ? '( Claim No : ' . $ticket_data['claim_number'] . ' )' : '' ?>
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- second_data_points -->
|
||||
@ -336,6 +356,12 @@
|
||||
value="<?= isset($ticket_data['approved_letter']) ? $ticket_data['approved_letter'] : '' ?>" name="approved_letter">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6 approved" style="display: none;">
|
||||
<label for="approved_description">Approved Description</label>
|
||||
<input type="text" class="form-control" id="approved_description" placeholder="Enter Approved Description"
|
||||
value="<?= isset($ticket_data['approved_description']) ? $ticket_data['approved_description'] : '' ?>" name="approved_description">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 settled" style="display: none;">
|
||||
<label for="utr_details">UTR Details</label>
|
||||
<input type="text" class="form-control" id="utr_details" placeholder="Enter UTR Details"
|
||||
@ -409,6 +435,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Modal -->
|
||||
<div class="modal fade" id="moreInfoModal" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">More Information</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="dynamicDivFillInfo"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
// $(document).ready(function() {
|
||||
// var calim_status = $('#claim_status_id').val();
|
||||
@ -558,11 +602,37 @@
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$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() {
|
||||
updateClaimStatusDisplay($(this).val());
|
||||
// claimStatusFieldChanges()
|
||||
const selectedVal = $(this).val();
|
||||
const elementId = $(this).attr('id');
|
||||
|
||||
console.log('Selected Value:', selectedVal);
|
||||
console.log('Element ID:', elementId);
|
||||
|
||||
if(selectedVal == 2 || selectedVal == 14){
|
||||
$field = $('#non_id_reason')
|
||||
$field.prop('required', false);
|
||||
}else if(selectedVal == 1){
|
||||
|
||||
if($('#tpa_no').val() != ""){
|
||||
$field = $('#non_id_reason')
|
||||
$field.prop('required', false);
|
||||
var $parentDiv = $field.closest("div");
|
||||
$parentDiv.find("label[for='non_id_reason'] .text-danger").remove();
|
||||
}else{
|
||||
$field = $('#non_id_reason')
|
||||
$field.prop('required', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function claimStatusFieldChanges(fields) {
|
||||
@ -690,6 +760,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$field = $('#approved_description')
|
||||
$field.prop('required', false);
|
||||
var $parentDiv = $field.closest("div");
|
||||
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
||||
|
||||
});
|
||||
|
||||
// function addRequiredFieldSymbol(field_name) {
|
||||
@ -931,7 +1007,7 @@
|
||||
value: '',
|
||||
text: 'Select Client Policy'
|
||||
}));
|
||||
console.log("got data from backend ",data);
|
||||
console.log("got data from backend ", data);
|
||||
let policyCount = 1;
|
||||
var policyAppendCount = 0;
|
||||
$.each(data, function(index, item) {
|
||||
@ -939,19 +1015,19 @@
|
||||
|
||||
if (ticket_type == 1 && item.policy_type_id != 1) {
|
||||
$('#emp_client_policy').append($('<option>', {
|
||||
value: item.client_policy_value,
|
||||
text: item.client_policy_name
|
||||
}));
|
||||
$("#policy_no").val("");
|
||||
if (policyCount == 1){
|
||||
console.log("policy count from if",item.policy_no);
|
||||
value: item.client_policy_value,
|
||||
text: item.client_policy_name
|
||||
}));
|
||||
$("#policy_no").val("");
|
||||
if (policyCount == 1) {
|
||||
console.log("policy count from if", item.policy_no);
|
||||
$("#policy_no").val(item.policy_no);
|
||||
}else{
|
||||
console.log("policy count from greter if ","");
|
||||
} else {
|
||||
console.log("policy count from greter if ", "");
|
||||
$("#policy_no").val("");
|
||||
}
|
||||
policyCount++;
|
||||
policyAppendCount++;
|
||||
policyAppendCount++;
|
||||
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
|
||||
// $('#emp_client_policy').select2();
|
||||
$("#emp_client_policy").select2();
|
||||
@ -965,9 +1041,9 @@
|
||||
}
|
||||
|
||||
})
|
||||
console.log('policy append count ',policyAppendCount);
|
||||
if (policyAppendCount == 0){
|
||||
toastr.warning("No Policies found for the Employee","Warning");
|
||||
console.log('policy append count ', policyAppendCount);
|
||||
if (policyAppendCount == 0) {
|
||||
toastr.warning("No Policies found for the Employee", "Warning");
|
||||
}
|
||||
}
|
||||
// $('#emp_client_policy').select2();
|
||||
@ -986,14 +1062,14 @@
|
||||
$("#policy_no").val(policy_no);
|
||||
console.log("Function set min date called ");
|
||||
console.log("Existing DOA instance: ", doa);
|
||||
console.log('sent data ',policy_id);
|
||||
console.log('sent data ', policy_id);
|
||||
$.ajax({
|
||||
url: '<?= base_url("ticket/getPolicyStartDate") ?>',
|
||||
method: "POST",
|
||||
data: {
|
||||
policy_id: policy_id
|
||||
},
|
||||
|
||||
|
||||
success: function(response) {
|
||||
console.log("mindate response ", response);
|
||||
|
||||
@ -1029,4 +1105,107 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$("#infoIcon").click(function() {
|
||||
var ticket_id = $('#ticket_master_id').val();
|
||||
getDataForInfo(ticket_id, function(data) {
|
||||
console.log("data: ", data);
|
||||
if (data && Object.keys(data).length) {
|
||||
// openModal();
|
||||
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
|
||||
myModal.show();
|
||||
|
||||
appendHtmlToModal(data);
|
||||
} else {
|
||||
// toastr.warning("Data not Found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function getDataForInfo(ticketId, callback) {
|
||||
$.ajax({
|
||||
url: "<?= base_url('ticket/getMoreInfo') ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
ticket_id: ticketId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
console.log("Info Response: ", response);
|
||||
callback(response.data); // pass data to the callback
|
||||
} else {
|
||||
toastr.warning("No Data Found");
|
||||
callback(null);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendHtmlToModal(data) {
|
||||
var container = document.getElementById('dynamicDivFillInfo');
|
||||
|
||||
// Clear any previous content inside the container
|
||||
container.innerHTML = '';
|
||||
|
||||
// Iterate over each status in the data
|
||||
for (let status in data) {
|
||||
if (data.hasOwnProperty(status)) {
|
||||
// Create the status subheading
|
||||
var statusHeading = document.createElement('h5');
|
||||
statusHeading.textContent = status;
|
||||
container.appendChild(statusHeading);
|
||||
|
||||
// Create a row container to group the fields in a row
|
||||
var rowContainer = document.createElement('div');
|
||||
rowContainer.classList.add('row'); // Add Bootstrap row class to group fields
|
||||
|
||||
// Iterate over each field within the current status
|
||||
for (let field in data[status]) {
|
||||
if (data[status].hasOwnProperty(field)) {
|
||||
// Create a container for each field with col-md-4 class
|
||||
var fieldContainer = document.createElement('div');
|
||||
fieldContainer.classList.add('form-group', 'col-md-4'); // Apply col-md-4 to each field
|
||||
|
||||
// Create a label for the field
|
||||
var fieldLabel = document.createElement('label');
|
||||
fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
|
||||
fieldContainer.appendChild(fieldLabel);
|
||||
|
||||
// Create either an input field or a textarea based on the field name
|
||||
var fieldInput;
|
||||
if (field === 'approved_letter' || field == "settle_letter") {
|
||||
// Create a textarea for 'approved_letter'
|
||||
fieldInput = document.createElement('textarea');
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.textContent = data[status][field]; // Set the value to the field content
|
||||
} else {
|
||||
// Create an input field for other fields
|
||||
fieldInput = document.createElement('input');
|
||||
fieldInput.type = 'text';
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.value = data[status][field];
|
||||
}
|
||||
|
||||
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly
|
||||
|
||||
// Append the input (or textarea) to the container
|
||||
fieldContainer.appendChild(fieldInput);
|
||||
|
||||
// Append the field container to the row container
|
||||
rowContainer.appendChild(fieldContainer);
|
||||
}
|
||||
}
|
||||
|
||||
// Append the row container to the main container
|
||||
container.appendChild(rowContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -4,6 +4,18 @@
|
||||
background-color: #e0e0e0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
color: #007bff;
|
||||
font-size: 15px;
|
||||
transition: 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
color: #0056b3;
|
||||
font-size: 24px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
@ -130,7 +142,7 @@
|
||||
<!-- end first_data_points -->
|
||||
|
||||
<br><br>
|
||||
<h5>Claim Details</h5>
|
||||
<h5>Claim Details <span><i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for more details"></i></span></h5>
|
||||
<hr>
|
||||
|
||||
<!-- second_data_points -->
|
||||
@ -262,6 +274,12 @@
|
||||
value="<?= isset($ticket_data['approved_letter']) ? $ticket_data['approved_letter'] : '' ?>" name="approved_letter">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6 approved" style="display: none;">
|
||||
<label for="approved_description">Approved Description</label>
|
||||
<input type="text" class="form-control" id="approved_description" placeholder="Enter Approved Description"
|
||||
value="<?= isset($ticket_data['approved_description']) ? $ticket_data['approved_description'] : '' ?>" name="approved_description">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 settled" style="display: none;">
|
||||
<label for="utr_details">UTR Details</label>
|
||||
<input type="text" class="form-control" id="utr_details" placeholder="Enter UTR Details"
|
||||
@ -314,6 +332,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Modal -->
|
||||
<div class="modal fade" id="moreInfoModal" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">More Information</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="dynamicDivFillInfo"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let GlobelExtraFields = [];
|
||||
|
||||
@ -397,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() {
|
||||
@ -526,6 +567,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$field = $('#approved_description')
|
||||
$field.prop('required', false);
|
||||
var $parentDiv = $field.closest("div");
|
||||
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
||||
|
||||
});
|
||||
// function addRequiredFieldSymbol(field_name) {
|
||||
// // Find the field with the given name
|
||||
@ -803,4 +850,107 @@
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
<script>
|
||||
$("#infoIcon").click(function() {
|
||||
var ticket_id = $('#ticket_master_id').val();
|
||||
getDataForInfo(ticket_id, function(data) {
|
||||
console.log("data: ", data);
|
||||
if (data && Object.keys(data).length) {
|
||||
// openModal();
|
||||
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
|
||||
myModal.show();
|
||||
|
||||
appendHtmlToModal(data);
|
||||
} else {
|
||||
// toastr.warning("No Data Found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function getDataForInfo(ticketId, callback) {
|
||||
$.ajax({
|
||||
url: "<?= base_url('ticket/getMoreInfo') ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
ticket_id: ticketId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
console.log("Info Response: ", response);
|
||||
callback(response.data); // pass data to the callback
|
||||
} else {
|
||||
toastr.warning("No Data Found");
|
||||
callback(null);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendHtmlToModal(data) {
|
||||
var container = document.getElementById('dynamicDivFillInfo');
|
||||
|
||||
// Clear any previous content inside the container
|
||||
container.innerHTML = '';
|
||||
|
||||
// Iterate over each status in the data
|
||||
for (let status in data) {
|
||||
if (data.hasOwnProperty(status)) {
|
||||
// Create the status subheading
|
||||
var statusHeading = document.createElement('h5');
|
||||
statusHeading.textContent = status;
|
||||
container.appendChild(statusHeading);
|
||||
|
||||
// Create a row container to group the fields in a row
|
||||
var rowContainer = document.createElement('div');
|
||||
rowContainer.classList.add('row'); // Add Bootstrap row class to group fields
|
||||
|
||||
// Iterate over each field within the current status
|
||||
for (let field in data[status]) {
|
||||
if (data[status].hasOwnProperty(field)) {
|
||||
// Create a container for each field with col-md-4 class
|
||||
var fieldContainer = document.createElement('div');
|
||||
fieldContainer.classList.add('form-group', 'col-md-4'); // Apply col-md-4 to each field
|
||||
|
||||
// Create a label for the field
|
||||
var fieldLabel = document.createElement('label');
|
||||
fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
|
||||
fieldContainer.appendChild(fieldLabel);
|
||||
|
||||
// Create either an input field or a textarea based on the field name
|
||||
var fieldInput;
|
||||
if (field === 'approved_letter' || field == "settle_letter") {
|
||||
// Create a textarea for 'approved_letter'
|
||||
fieldInput = document.createElement('textarea');
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.textContent = data[status][field]; // Set the value to the field content
|
||||
} else {
|
||||
// Create an input field for other fields
|
||||
fieldInput = document.createElement('input');
|
||||
fieldInput.type = 'text';
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.value = data[status][field];
|
||||
}
|
||||
|
||||
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly
|
||||
|
||||
// Append the input (or textarea) to the container
|
||||
fieldContainer.appendChild(fieldInput);
|
||||
|
||||
// Append the field container to the row container
|
||||
rowContainer.appendChild(fieldContainer);
|
||||
}
|
||||
}
|
||||
|
||||
// Append the row container to the main container
|
||||
container.appendChild(rowContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -65,13 +65,57 @@ table.dataTable tbody td {
|
||||
<th>Emp name</th>
|
||||
<th>Insured Name</th>
|
||||
<th>Corporate name</th>
|
||||
|
||||
<th style="display: none;">ACM</th>
|
||||
<th style="display: none;">Insurer</th>
|
||||
<th style="display: none;">TPA</th>
|
||||
<th style="display: none;">Policy No</th>
|
||||
<th style="display: none;">Priority</th>
|
||||
<th style="display: none;">Relationship</th>
|
||||
<th style="display: none;">Emp Mobile</th>
|
||||
<th style="display: none;">Emp Email</th>
|
||||
<th style="display: none;">Emp Personal Email</th>
|
||||
<th style="display: none;">Mode of Intimation</th>
|
||||
<th style="display: none;">Claim Type</th>
|
||||
<th style="display: none;">Hospital Name</th>
|
||||
<th style="display: none;">DOA</th>
|
||||
<th style="display: none;">DOD</th>
|
||||
<th style="display: none;">Claim Amount</th>
|
||||
<th style="display: none;">POD No.</th>
|
||||
<th style="display: none;">Date of Join</th>
|
||||
<th style="display: none;">Date of Inception</th>
|
||||
<th style="display: none;">DOB</th>
|
||||
<th style="display: none;">Date of Accident</th>
|
||||
<th style="display: none;">Date of Death</th>
|
||||
<th style="display: none;">Date of Intimate</th>
|
||||
<th style="display: none;">Sum Insured</th>
|
||||
<th style="display: none;">Raised Date</th>
|
||||
<th style="display: none;">Registration Date</th>
|
||||
<th style="display: none;">Query Received Date</th>
|
||||
<th style="display: none;">Denial Date</th>
|
||||
<th style="display: none;">Approved Date</th>
|
||||
<th style="display: none;">Settled Date</th>
|
||||
<th style="display: none;">Denial Reason</th>
|
||||
<th style="display: none;">Approved Letter</th>
|
||||
<th style="display: none;">Approved Amount</th>
|
||||
<th style="display: none;">UTR Details</th>
|
||||
<th style="display: none;">Settle Letter</th>
|
||||
<th style="display: none;">Return Remark</th>
|
||||
<th style="display: none;">Cancel Remark</th>
|
||||
<th style="display: none;">AWB No. and Courier Name</th>
|
||||
<th style="display: none;">Non ID Reason</th>
|
||||
<th style="display: none;">Payment Initiate Date</th>
|
||||
<th style="display: none;">Approved Description</th>
|
||||
|
||||
|
||||
<th>TAT</th>
|
||||
<th>ACTION</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($ticket_data)) { ?>
|
||||
<?php foreach($ticket_data as $index => $row){ ?>
|
||||
<tr onclick="viewTicket(<?php echo $row['id']; ?>)" style="cursor: pointer;">
|
||||
<tr data-id="<?= $row['id']; ?>" style="cursor: pointer;">
|
||||
|
||||
<td data-toggle="tooltip" data-placement="top"
|
||||
|
||||
@ -119,7 +163,70 @@ table.dataTable tbody td {
|
||||
<td><?php echo $row['emp_name']; ?></td>
|
||||
<td><?php echo $row['insured_name']; ?></td>
|
||||
<td><?php echo $row['short_name']; ?></td>
|
||||
|
||||
<td style="display: none;"><?php echo $row['acm_name']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['insurer_name']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['tpa_name']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['policy_no']; ?></td>
|
||||
<td style="display: none;"><?php echo isset($priorityType[$row['priority'] ?? 0]) ? $priorityType[$row['priority'] ?? 0] : ''; ?></td>
|
||||
<td style="display: none;"><?php echo $row['relationship']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['emp_mobile']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['emp_mail']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['emp_personal_mail']; ?></td>
|
||||
<td style="display: none;"><?php echo isset($modeOFIntimate[$row['mode_of_intimation'] ?? '']) ? $modeOFIntimate[$row['mode_of_intimation']] : ''; ?></td>
|
||||
<td style="display: none;">
|
||||
<?php
|
||||
$typeId = $row['ticket_type_id'] ?? 0;
|
||||
$claimKey = $row['claim_type'] ?? '';
|
||||
if ($typeId == 1) {
|
||||
echo isset($claimType[1][$claimKey]) ? $claimType[1][$claimKey] : '';
|
||||
} else {
|
||||
echo isset($claimType[2][$claimKey]) ? $claimType[2][$claimKey] : '';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td style="display: none;"><?php echo $row['hospital_name']; ?></td>
|
||||
<td style="display: none;"><?php echo change_date_format($row['doa'], null, 'd-m-Y'); ?></td>
|
||||
<td style="display: none;"><?php echo $row['dod']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['claim_amount']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['pod_no']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['date_of_join']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['date_of_incep']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['dob']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['date_of_accident']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['date_of_death']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['date_of_intimat']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['si_amt']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['raised_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['registration_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['query_received_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['denial_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['approved_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['settled_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['denial_reason']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['approved_letter']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['approved_amount']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['utr_details']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['settle_letter']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['return_remark']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['cancel_remark']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['awb_no_courier_name']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['non_id_reason']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['pay_initiate_date']; ?></td>
|
||||
<td style="display: none;"><?php echo $row['approved_description']; ?></td>
|
||||
|
||||
|
||||
<td><?php echo $row['tat']; ?></td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removeClaim(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -198,4 +305,41 @@ function viewTicket(ticket_id){
|
||||
|
||||
}
|
||||
|
||||
function removeClaim(input, ticket_id) {
|
||||
|
||||
confirmActionSweertAlert("Do you want to delete this Claim?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
|
||||
if (confirmed) {
|
||||
let url = '<?= base_url('ticket/remove') ?>';
|
||||
|
||||
// Include `pt_id` in the AJAX request if necessary
|
||||
let requestData = { ticket_id: ticket_id };
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
window.location.reload();
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).on('click', 'tbody tr', function (e) {
|
||||
// Exclude clicks on any elements inside the last column (actions)
|
||||
if ($(e.target).closest('td').index() !== $(this).children('td').length - 1) {
|
||||
const id = $(this).data('id');
|
||||
console.log('Ticket ID', id)
|
||||
viewTicket(id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
@ -344,6 +344,7 @@
|
||||
$('#primaryKey').val('');
|
||||
$('#policy_type').val('').change();
|
||||
$('#trigger_type').val('').change();
|
||||
$("#claim_status_for_template").val("").change;
|
||||
editor.setEditorValue('');
|
||||
$('#primaryKey').val(null);
|
||||
$('#statusSwitch').prop('checked', false);
|
||||
|
||||
@ -255,153 +255,162 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('input[name="transactionMode"]').change(function() {
|
||||
if ($(this).val() === 'adjustment') {
|
||||
$('#transactionTypeRow').show();
|
||||
} else {
|
||||
$('#transactionTypeRow').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
var record_date = flatpickr("#record_date",{
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
|
||||
});
|
||||
$('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'CD TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
text: 'PDF',
|
||||
title: 'TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: ''
|
||||
}
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
ordering: false,
|
||||
paging: true ,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
// // Event listener for radio buttons
|
||||
// $('input[name="transactionMode"]').change(function() {
|
||||
// if ($(this).val() === 'add') {
|
||||
// // Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
|
||||
// $('#subType').val('Deposit');
|
||||
// } else if ($(this).val() === 'adjustment') {
|
||||
// // Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
|
||||
// $('#subType').val('Adjustment');
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#saveTransactionBtn').on('click', function() {
|
||||
|
||||
var amount = $('#amount').val();
|
||||
var description = $('#description').val();
|
||||
var clientId = '<?php echo $clientData->id; ?>';
|
||||
var insurerId = '<?php echo $insurerName->id; ?>';
|
||||
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
|
||||
var subType = "";
|
||||
var record_date = $('#record_date').val();
|
||||
|
||||
if(amount == ""){
|
||||
toastr.warning('Amount field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
if(description == ""){
|
||||
toastr.warning('Description field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//tranction type
|
||||
if(transactionTypeValue == 1){
|
||||
transactionType = 'Credit';
|
||||
subType = '1'; // Replenishment or Deposite
|
||||
}else if(transactionTypeValue == 2){
|
||||
transactionType = 'Credit'
|
||||
subType = '2'; // Adjustment add
|
||||
}else if(transactionTypeValue == 3){
|
||||
transactionType = 'Debit'
|
||||
subType = '2'; // Adjustment reduce
|
||||
}else if(transactionTypeValue == 4){
|
||||
transactionType = 'Credit'
|
||||
subType = '5'; // Asset Policy add
|
||||
}else if(transactionTypeValue == 5){
|
||||
transactionType = 'Debit'
|
||||
subType = '5'; // Asset Policy reduce
|
||||
}else if(transactionTypeValue == 6){
|
||||
transactionType = 'Debit'
|
||||
subType = '6'; // Refund by indurer
|
||||
}
|
||||
|
||||
console.log('transactionTypeValue', transactionTypeValue)
|
||||
console.log('transactionType', transactionType)
|
||||
console.log('description ', description)
|
||||
console.log('amount ', amount)
|
||||
console.log('clientId ', clientId)
|
||||
console.log('insurerId ', insurerId)
|
||||
console.log('subType ', subType)
|
||||
|
||||
|
||||
// Send data to the server using Ajax
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?= base_url()."client/save_deposit" ?>',
|
||||
data: {
|
||||
amount: amount,
|
||||
description: description,
|
||||
transaction_type: transactionType,
|
||||
sub_type_id: subType, // Include sub_type_id
|
||||
client_id: clientId,
|
||||
insurer_id: insurerId,
|
||||
record_date : record_date
|
||||
},
|
||||
success: function(response) {
|
||||
// Handle success response
|
||||
toastr.success("Transaction saved successfully", "Success");
|
||||
// Reload the page or perform other actions as needed
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
toastr.error("Transaction save failed", "Error");
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
location.reload(); // Uncomment if you need to reload the page on error
|
||||
$(document).ready(function() {
|
||||
$('input[name="transactionMode"]').change(function() {
|
||||
if ($(this).val() === 'adjustment') {
|
||||
$('#transactionTypeRow').show();
|
||||
} else {
|
||||
$('#transactionTypeRow').hide();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
var record_date = flatpickr("#record_date", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
|
||||
});
|
||||
$('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'CD TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
text: 'PDF',
|
||||
title: 'TransactionDetails',
|
||||
exportOptions: {
|
||||
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: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
ordering: false,
|
||||
paging: true,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
// // Event listener for radio buttons
|
||||
// $('input[name="transactionMode"]').change(function() {
|
||||
// if ($(this).val() === 'add') {
|
||||
// // Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
|
||||
// $('#subType').val('Deposit');
|
||||
// } else if ($(this).val() === 'adjustment') {
|
||||
// // Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
|
||||
// $('#subType').val('Adjustment');
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#saveTransactionBtn').on('click', function() {
|
||||
|
||||
var amount = $('#amount').val();
|
||||
var description = $('#description').val();
|
||||
var clientId = '<?php echo $clientData->id; ?>';
|
||||
var insurerId = '<?php echo $insurerName->id; ?>';
|
||||
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
|
||||
var subType = "";
|
||||
var record_date = $('#record_date').val();
|
||||
|
||||
if (amount == "") {
|
||||
toastr.warning('Amount field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
if (description == "") {
|
||||
toastr.warning('Description field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//tranction type
|
||||
if (transactionTypeValue == 1) {
|
||||
transactionType = 'Credit';
|
||||
subType = '1'; // Replenishment or Deposite
|
||||
} else if (transactionTypeValue == 2) {
|
||||
transactionType = 'Credit'
|
||||
subType = '2'; // Adjustment add
|
||||
} else if (transactionTypeValue == 3) {
|
||||
transactionType = 'Debit'
|
||||
subType = '2'; // Adjustment reduce
|
||||
} else if (transactionTypeValue == 4) {
|
||||
transactionType = 'Credit'
|
||||
subType = '5'; // Asset Policy add
|
||||
} else if (transactionTypeValue == 5) {
|
||||
transactionType = 'Debit'
|
||||
subType = '5'; // Asset Policy reduce
|
||||
} else if (transactionTypeValue == 6) {
|
||||
transactionType = 'Debit'
|
||||
subType = '6'; // Refund by indurer
|
||||
}
|
||||
|
||||
console.log('transactionTypeValue', transactionTypeValue)
|
||||
console.log('transactionType', transactionType)
|
||||
console.log('description ', description)
|
||||
console.log('amount ', amount)
|
||||
console.log('clientId ', clientId)
|
||||
console.log('insurerId ', insurerId)
|
||||
console.log('subType ', subType)
|
||||
|
||||
|
||||
// Send data to the server using Ajax
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?= base_url() . "client/save_deposit" ?>',
|
||||
data: {
|
||||
amount: amount,
|
||||
description: description,
|
||||
transaction_type: transactionType,
|
||||
sub_type_id: subType, // Include sub_type_id
|
||||
client_id: clientId,
|
||||
insurer_id: insurerId,
|
||||
record_date: record_date
|
||||
},
|
||||
success: function(response) {
|
||||
// Handle success response
|
||||
toastr.success("Transaction saved successfully", "Success");
|
||||
// Reload the page or perform other actions as needed
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
toastr.error("Transaction save failed", "Error");
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
location.reload(); // Uncomment if you need to reload the page on error
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -491,25 +491,14 @@
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="payment_date">Payment Date</label>
|
||||
<input type="text" class="form-control" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="utr_no">UTR No.</label>
|
||||
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="placement_date">Placement Date</label>
|
||||
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['placement_date']) ? date('d/m/Y', strtotime($lead_data['placement_date'])) : "" ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label style = "padding-left: 15px;padding-top: 33px;" for="is_cd_switch">CD </label>
|
||||
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="150" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>
|
||||
>
|
||||
<label for="is_cd_switch">CD Entry</label>
|
||||
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="218" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -519,20 +508,52 @@
|
||||
|
||||
<?php if (isset($lead_data['is_cd']) && $lead_data['is_cd'] == 1 || !isset($lead_data['is_cd'])) { ?>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="cd_amount">CD Amount</label>
|
||||
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="cd_amount">CD Amount</label>
|
||||
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="total_amount">Total Amount</label>
|
||||
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="total_amount">Total Amount</label>
|
||||
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="is_installment_switch">Installemnt </label>
|
||||
<input id="is_installment_switch" type="checkbox" name = "is_installment" value = "1" data-toggle="toggle" data-on="With Installments" data-off="Without Installments" data-onstyle="info" data-offstyle="dark" data-style="border" data-width="218" <?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 ? 'checked' : '' ?>>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" style="<?= (!empty($lead_data['is_installment']) && $lead_data['is_installment'] == 1) ? 'display: block;' : 'display: none;' ?>">
|
||||
<label for="no_of_installment">No of Installments</label>
|
||||
<input type="text" class="form-control" id="no_of_installment" name="no_of_installment"
|
||||
value="<?= isset($lead_data['no_of_installment']) ? $lead_data['no_of_installment'] : 1 ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<?php if (isset($lead_data['is_installment']) && $lead_data['is_installment'] == 0 || !isset($lead_data['is_installment'])) { ?>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="payment_date">Payment Date</label>
|
||||
<input type="text" class="form-control" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="utr_no">UTR No.</label>
|
||||
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div id="installment_form_row">
|
||||
<?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 && isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
@ -557,7 +578,7 @@
|
||||
>
|
||||
<?php foreach ($exclusiveUserList as $user) { ?>
|
||||
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<option value="<?= $user['email'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
</option>
|
||||
<?php } }?>
|
||||
@ -614,6 +635,7 @@
|
||||
var user_role_id = <?= get_role_id(); ?>;
|
||||
var jsonDataForHide = null;
|
||||
var multi_file_data = [];
|
||||
var totalSumAssuredData = [];
|
||||
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
@ -687,6 +709,9 @@
|
||||
let qcr_count = <?= isset($qcr_count) ? $qcr_count : 0 ?>;
|
||||
let question_json = <?= isset($question_json) ? json_encode($question_json) : 'null' ?>;
|
||||
let policy_terms_json = <?= isset($policy_terms) ? json_encode($policy_terms) : 'null' ?>;
|
||||
totalSumAssuredData = <?= isset($totalSumAssured) ? json_encode($totalSumAssured) : '[]' ?>;
|
||||
console.log('totalSumAssuredData', totalSumAssuredData);
|
||||
console.log('totalSumAssuredData.type', typeof totalSumAssuredData);
|
||||
// console.log('policy_terms_json', policy_terms_json);
|
||||
|
||||
data = JSON.parse(data);
|
||||
@ -694,6 +719,7 @@
|
||||
policy_terms = JSON.parse(policy_terms_json);
|
||||
|
||||
jsonDataForHide = data?.premium_data ?? null;
|
||||
console.log("data", data);
|
||||
if(data){
|
||||
proposalDataForDropDown = data.proposal_data;
|
||||
if(!data.premium_data){
|
||||
@ -837,7 +863,7 @@
|
||||
$(document).ready(function () {
|
||||
setInterval(function () {
|
||||
submitData(1);
|
||||
}, 15000);
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
|
||||
@ -1214,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++) {
|
||||
|
||||
@ -1311,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() {
|
||||
|
||||
@ -3194,7 +3255,7 @@ function insurerAndClientMailPopUp(){
|
||||
|
||||
function placementMailPopUp() {
|
||||
|
||||
console.log(proposalDataForDropDown);
|
||||
console.log("proposalDataForDropDown", proposalDataForDropDown);
|
||||
|
||||
const selectElement = document.getElementById('proposals');
|
||||
|
||||
@ -3451,137 +3512,6 @@ function constructURL(url_type) {
|
||||
}
|
||||
}
|
||||
|
||||
// function constructURL_ForInsurerAndClientMailSend() {
|
||||
|
||||
// var lead_id = $('#lead_id').val();
|
||||
// var mail_content = $('#insurer_and_client_mail_content').val();
|
||||
// var subject = $('#mail_subject').val();
|
||||
// var apiURL;
|
||||
|
||||
// if (RFQ_or_QCR == 2) {
|
||||
// apiURL = '<?= base_url('leads/sendMail') ?>?lead_id=' + encodeURIComponent(lead_id) +
|
||||
// '&file_type=qcr' +
|
||||
// '&recipient_type=client' +
|
||||
// '&recipient_mail='+
|
||||
// '&mail_content=' + String(mail_content) +
|
||||
// '&subject=' + String(subject);
|
||||
|
||||
// } else {
|
||||
// var insurerContact = $('#insurerContact').val();
|
||||
// insurerContact = insurerContact.map(Number);
|
||||
// console.log(insurerContact);
|
||||
|
||||
// apiURL = '<?= base_url('leads/sendMail') ?>?lead_id=' + encodeURIComponent(lead_id) +
|
||||
// '&file_type=rfq' +
|
||||
// '&recipient_type=insurer' +
|
||||
// '&recipient_mail=' + JSON.stringify(insurerContact)+
|
||||
// '&mail_content=' + String(mail_content) +
|
||||
// '&subject=' + String(subject);
|
||||
// }
|
||||
|
||||
// console.log(apiURL);
|
||||
// ajaxRequest(apiURL);
|
||||
// }
|
||||
|
||||
// function constructURL_ForInternalMailSend() {
|
||||
|
||||
// var lead_id = $('#lead_id').val();
|
||||
// let to = $('#to').val();
|
||||
// let mail_content = $('#internal_mail_content').val();
|
||||
// let subject = $('#subject').val();
|
||||
|
||||
|
||||
// let cc = $('#cc').val();
|
||||
// cc = cc.map(Number);
|
||||
// cc = JSON.stringify(cc)
|
||||
|
||||
// var file_type = 'rfq';
|
||||
// if (RFQ_or_QCR == 2) {
|
||||
// file_type = 'qcr'
|
||||
// }
|
||||
|
||||
// var queryParams = {
|
||||
// lead_id: lead_id,
|
||||
// file_type: file_type,
|
||||
// recipient_type: 'internal',
|
||||
// to: to,
|
||||
// cc: cc,
|
||||
// subject: subject,
|
||||
// // mail_content: mail_content,
|
||||
// recipient_mail: '',
|
||||
// mail_content: mail_content,
|
||||
// subject: subject,
|
||||
// };
|
||||
|
||||
// const queryString = objectToQueryString(queryParams);
|
||||
// console.log(queryString);
|
||||
|
||||
// var apiURL = '<?= base_url('leads/sendMail') ?>?'+queryString
|
||||
|
||||
// console.log(apiURL);
|
||||
// ajaxRequest(apiURL);
|
||||
// }
|
||||
|
||||
// function constructURL_ForPlacementMailSend() {
|
||||
|
||||
// var lead_id = $('#lead_id').val();
|
||||
// let to = $('#placement_to').val();
|
||||
// console.log('to mail', to);
|
||||
|
||||
// let placement_date = $('#placement_date').val();
|
||||
// let utr_no = $('#utr_no').val();
|
||||
// let premium_amount = $('#premium_amount').val();
|
||||
// let total_amount = $('#total_amount').val();
|
||||
// let cd_amount = $('#cd_amount').val();
|
||||
|
||||
// let subject = $('#placement_subject').val();
|
||||
// // let = mail_content = $('#placement_mail_content').val();
|
||||
// let proposal_insurer = $('#proposals option:selected').data('id');
|
||||
// let insurer_and_branch = $('#proposals').val();
|
||||
|
||||
// let cc = $('#placement_cc').val();
|
||||
// cc = cc.map(Number);
|
||||
// // cc = cc.split(',').map(email => email.trim());
|
||||
// cc = JSON.stringify(cc);
|
||||
|
||||
// // to = to.map(String);
|
||||
// // to = JSON.stringify(to)
|
||||
// to = to.split(',').map(email => email.trim());
|
||||
// to = JSON.stringify(to)
|
||||
// console.log('to (array):', to);
|
||||
|
||||
// var file_type = 'rfq';
|
||||
// if (RFQ_or_QCR == 2) {
|
||||
// file_type = 'qcr'
|
||||
// }
|
||||
|
||||
// var queryParams = {
|
||||
// lead_id: lead_id,
|
||||
// file_type: file_type,
|
||||
// recipient_type: 'placement',
|
||||
// to: to,
|
||||
// cc: cc,
|
||||
// subject: subject,
|
||||
// proposal_insurer: proposal_insurer,
|
||||
// insurer_and_branch: insurer_and_branch,
|
||||
// recipient_mail: to,
|
||||
|
||||
// placement_date: placement_date,
|
||||
// utr_no: utr_no,
|
||||
// premium_amount: premium_amount,
|
||||
// total_amount: total_amount,
|
||||
// cd_amount: cd_amount,
|
||||
// };
|
||||
|
||||
// const queryString = objectToQueryString(queryParams);
|
||||
// console.log(queryString);
|
||||
|
||||
// var apiURL = '<?= base_url('leads/sendMail') ?>?'+queryString
|
||||
|
||||
// console.log(apiURL);
|
||||
// ajaxRequest(apiURL);
|
||||
// }
|
||||
|
||||
|
||||
// Insurer and Client Mail
|
||||
function constructURL_ForInsurerAndClientMailSend() {
|
||||
@ -3694,16 +3624,44 @@ function constructURL_ForPlacementMailSend() {
|
||||
let proposal_insurer = $('#proposals option:selected').data('id');
|
||||
let insurer_and_branch = $('#proposals').val();
|
||||
let cc = $('#placement_cc').val();
|
||||
let no_of_installment = $('#no_of_installment').val();
|
||||
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
|
||||
console.log("cc1", cc);
|
||||
|
||||
// Process `to` field
|
||||
to = to.split(',').map(email => email.trim());
|
||||
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
||||
// cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
||||
|
||||
|
||||
var selectedFiles = [];
|
||||
$('#placement_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||
selectedFiles.push($(this).val());
|
||||
});
|
||||
|
||||
let data = [];
|
||||
|
||||
$('#installment_form_row .form-row').each(function () {
|
||||
let installment_amount = $(this).find('input[name="installment_amount[]"]').val();
|
||||
let payment_date = $(this).find('input[name="payment_date[]"]').val();
|
||||
let utr_no = $(this).find('input[name="utr_no[]"]').val();
|
||||
let id = $(this).find('input[name="installment_primary_key[]"]').val();
|
||||
console.log('installment_primary_key', id);
|
||||
|
||||
let obj = {
|
||||
lead_id: lead_id,
|
||||
installment_amount: installment_amount,
|
||||
payment_date: payment_date,
|
||||
utr_no: utr_no
|
||||
};
|
||||
|
||||
if (id != undefined && id != null && id != '') {
|
||||
obj.id = id;
|
||||
}
|
||||
|
||||
data.push(obj);
|
||||
});
|
||||
|
||||
|
||||
// Prepare FormData
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -3723,14 +3681,15 @@ function constructURL_ForPlacementMailSend() {
|
||||
formData.append('cd_amount', cd_amount);
|
||||
formData.append('mail_content', mail_content);
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
formData.append('installments', JSON.stringify(data));
|
||||
formData.append('no_of_installment', no_of_installment);
|
||||
formData.append('is_installment', is_installment);
|
||||
|
||||
|
||||
ajaxRequest(formData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ajaxRequest(formData) {
|
||||
|
||||
var apiURL = '<?= base_url('leads/sendMail') ?>';
|
||||
@ -3831,23 +3790,40 @@ function getInsurerBranchContacts(input){
|
||||
|
||||
function appendInsurerContact(data) {
|
||||
|
||||
console.log(data)
|
||||
console.log(data);
|
||||
|
||||
$('#placement_to').empty();
|
||||
$('#placement_to').append($('<option>', {
|
||||
// Clear existing options and CC entries
|
||||
$('#placement_to').empty().append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select'
|
||||
}));
|
||||
$('.ccInsurerMail').remove();
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
$('#placement_to').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.contact_person_email
|
||||
});
|
||||
$('#placement_to').append(option);
|
||||
text: item.contact_person_email
|
||||
}));
|
||||
|
||||
$('#placement_cc').append($('<option>', {
|
||||
value: item.contact_person_email ?? "",
|
||||
text: (item.contact_person_name || '') + (item.contact_person_email ? ' - ' + item.contact_person_email : '') + ' (Insurer)',
|
||||
class: 'ccInsurerMail'
|
||||
}));
|
||||
});
|
||||
|
||||
// Re-initialize Select2
|
||||
$('#placement_cc').val(null).select2({
|
||||
placeholder: 'Select CC Mail'
|
||||
});
|
||||
|
||||
// Style Select2 textarea input
|
||||
setTimeout(function () {
|
||||
$('textarea.select2-search__field').attr('rows', '1').css('resize', 'none');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
$('.close').click(function(){
|
||||
|
||||
$('#to').select2({
|
||||
@ -5760,7 +5736,6 @@ function appendMultiFileData(data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function convertRFQJsonToQCRJson(json) {
|
||||
|
||||
if (json) {
|
||||
@ -5889,6 +5864,93 @@ 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();
|
||||
let $installmentContainer = $('#installment_form_row');
|
||||
let row_count = $installmentContainer.find('.form-row').length;
|
||||
|
||||
if (row_count == 0 ) { addInstallmentHTML()}
|
||||
// addInstallmentHTML()
|
||||
}else{
|
||||
console.log("inside else")
|
||||
|
||||
let $installmentContainer = $('#installment_form_row');
|
||||
let row_count = $installmentContainer.find('.form-row').length;
|
||||
let remove_count = $("#no_of_installment").val();
|
||||
console.log("row count",row_count);
|
||||
if (row_count > 0 ) {
|
||||
let ids = $installmentContainer.find('.form-row').slice(-remove_count).find('input[name="installment_primary_key[]"]').map(function() {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
Swal.fire({
|
||||
title: "Do you want to remove all the entries?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, Proceed!"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
let url = '<?= base_url('util/removeInstallments') ?>';
|
||||
let requestData = { id: ids };
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
$("#no_of_installment").hide();
|
||||
$("#payment_date").show();
|
||||
$("#utr_no").show();
|
||||
$("#no_of_installment").closest('.form-group').hide();
|
||||
$("#payment_date").closest('.form-group').show();
|
||||
$("#utr_no").closest('.form-group').show();
|
||||
$('#installment_form_row').empty();
|
||||
$('#no_of_installment').val("");
|
||||
} else {
|
||||
toastr.error(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while removing the installment.', 'ERROR');
|
||||
});
|
||||
}else{
|
||||
// alert("Inside else");
|
||||
$('#no_of_installment').val(row_count);
|
||||
// $("#is_installment_switch").bootstrapToggle('on');
|
||||
// $('#is_installment_switch').val('1').change();
|
||||
// $('#is_installment_switch').bootstrapToggle('on');
|
||||
// $('#is_installment_switch').prop('checked', true).trigger('change');
|
||||
$('#is_installment_switch').trigger('click'); // in some cases, this forces the CSS to update
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$(document).on("input", "#cd_amount, #premium_amount", function() {
|
||||
|
||||
// alert("Function called");
|
||||
@ -5928,6 +5990,194 @@ function appendMultiFileData(data) {
|
||||
return emails.every(email => getDomain(email) === firstDomain);
|
||||
}
|
||||
|
||||
|
||||
function addInstallmentHTML() {
|
||||
let html = `
|
||||
<div class="form-row align-items-end">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="installment_amount">Installment Amount</label>
|
||||
<input type="text" class="form-control" name="installment_amount[]" placeholder="Enter Amount">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="payment_date">Payment Date</label>
|
||||
<input type="text" class="form-control payment_date" name="payment_date[]" placeholder="DD/MM/YYYY">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="utr_no">UTR No.</label>
|
||||
<input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No.">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<button type="button" class="btn btn-danger remove-installment">X</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#installment_form_row').append(html);
|
||||
|
||||
$('.payment_date').flatpickr({
|
||||
dateFormat: 'd/m/Y',
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click', '.remove-installment', function () {
|
||||
let $this = $(this); // Store reference to the clicked element
|
||||
let row_count = $('#installment_form_row .form-row').length;
|
||||
console.log("row_count", row_count);
|
||||
|
||||
let id = $this.closest('.form-row').find('input[name="installment_primary_key[]"]').val() ?? null;
|
||||
console.log("id", id);
|
||||
let ids = id ? [id] : [];
|
||||
console.log("ids", ids);
|
||||
|
||||
if (id != null && row_count > 1) {
|
||||
Swal.fire({
|
||||
title: "Do you want to remove this?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, Proceed!"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
let url = '<?= base_url('util/removeInstallments') ?>';
|
||||
let requestData = { id: ids };
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
|
||||
$this.closest('.form-row').remove();
|
||||
let updated_row_count = $('#installment_form_row .form-row').length;
|
||||
$('#no_of_installment').val(updated_row_count);
|
||||
console.log("after remove row_count", updated_row_count);
|
||||
} else {
|
||||
toastr.error(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while removing the installment.', 'ERROR');
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (row_count > 1) {
|
||||
$this.closest('.form-row').remove();
|
||||
let updated_row_count = $('#installment_form_row .form-row').length;
|
||||
$('#no_of_installment').val(updated_row_count);
|
||||
console.log("after remove row_count", updated_row_count);
|
||||
} else {
|
||||
console.log("Only one row left. Not removing.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#no_of_installment').on('change', function () {
|
||||
let no_of_installments = parseInt($(this).val());
|
||||
let $installmentContainer = $('#installment_form_row');
|
||||
let row_count = $installmentContainer.find('.form-row').length;
|
||||
|
||||
console.log("Form row count:", row_count);
|
||||
|
||||
if (row_count === 1) {
|
||||
// $installmentContainer.empty();
|
||||
for (let index = 0; index < no_of_installments - 1; index++) {
|
||||
addInstallmentHTML();
|
||||
}
|
||||
} else if (no_of_installments === row_count) {
|
||||
console.log('Same row count, no change needed.');
|
||||
} else if (no_of_installments < row_count) {
|
||||
|
||||
// Remove extra rows from the end
|
||||
let remove_count = row_count - no_of_installments;
|
||||
let ids = $installmentContainer.find('.form-row')
|
||||
.slice(-remove_count)
|
||||
.find('input[name="installment_primary_key[]"]')
|
||||
.map(function() {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
|
||||
console.log('ids', ids);
|
||||
|
||||
if (Object.keys(ids).length > 0) {
|
||||
Swal.fire({
|
||||
title: "Do you want to remove the last " + (remove_count ?? "") + " entries?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, Proceed!"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
let url = '<?= base_url('util/removeInstallments') ?>';
|
||||
let requestData = { id: ids };
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
$installmentContainer.find('.form-row').slice(-remove_count).remove();
|
||||
} else {
|
||||
toastr.error(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while removing the installment.', 'ERROR');
|
||||
});
|
||||
}else{
|
||||
$('#no_of_installment').val(row_count);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$installmentContainer.find('.form-row').slice(-remove_count).remove();
|
||||
}
|
||||
|
||||
} else if (no_of_installments > row_count) {
|
||||
// Add extra rows from the end
|
||||
let add_count = no_of_installments - row_count;
|
||||
for (let index = 0; index < add_count; index++) {
|
||||
addInstallmentHTML();
|
||||
}
|
||||
} else {
|
||||
// Add missing rows
|
||||
let add_count = no_of_installments - row_count;
|
||||
for (let index = 0; index < add_count; index++) {
|
||||
addInstallmentHTML();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
setTimeout(function(){
|
||||
$('.payment_date').flatpickr({
|
||||
dateFormat: 'd/m/Y',
|
||||
});
|
||||
}, 2000)
|
||||
})
|
||||
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
while true; do
|
||||
echo "Running job at $(date)"
|
||||
/usr/bin/php /var/www/nhance/zenith/public/index.php cli/processjob
|
||||
sleep 1 # Optional: Add a sleep to avoid CPU overload
|
||||
done
|
||||
BIN
public/sample_excel/Sample_Member_Data.xlsx
Normal file
BIN
public/sample_excel/Sample_Member_Data.xlsx
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user