HR login api : GWM
This commit is contained in:
commit
ac0196991f
2
.gitignore
vendored
2
.gitignore
vendored
@ -33,3 +33,5 @@ build/
|
||||
composer.lock
|
||||
.env
|
||||
.phpunit*
|
||||
phpqueue.sh
|
||||
|
||||
|
||||
@ -9,3 +9,5 @@ From command propmt run the following cmds
|
||||
Run speeific method
|
||||
|
||||
`php vendor/bin/phpunit tests\unit\PremiumCalculationTest.php --filter testPremiumCalculationWithPrimaryRackRateAndAdditionalRackRate`
|
||||
|
||||
Test Comments
|
||||
@ -103,6 +103,8 @@ define('BUSINESS_TEAM_ID', '3');
|
||||
define('FINANCE_TEAM_ID', '4');
|
||||
define('SALES_TEAM_ID', '5');
|
||||
define('MANAGEMENT_TEAM_ID', '6');
|
||||
define('BUSINESS_SUPPORT_TEAM_ID', '7');
|
||||
define('POS_TEAM_ID', '8');
|
||||
|
||||
/**
|
||||
* @User Teams Constant
|
||||
|
||||
@ -45,6 +45,9 @@ class Database extends Config
|
||||
'numberNative' => false,
|
||||
];
|
||||
|
||||
|
||||
public array $book_stack = [];
|
||||
|
||||
/**
|
||||
* This database connection is used when
|
||||
* running PHPUnit database tests.
|
||||
@ -75,6 +78,29 @@ class Database extends Config
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Initialize book_stack configuration with environment variables
|
||||
$this->book_stack = [
|
||||
'DSN' => '',
|
||||
'hostname' => getenv('bookStack_hostname'),
|
||||
'username' => getenv('bookStack_username'),
|
||||
'password' => getenv('bookStack_password'),
|
||||
'database' => getenv('bookStack_database'),
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => 'utf8_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
];
|
||||
|
||||
// Ensure that we always set the database group to 'tests' if
|
||||
// we are currently running an automated test suite, so that
|
||||
// we don't overwrite live data on accident.
|
||||
@ -82,4 +108,5 @@ class Database extends Config
|
||||
$this->defaultGroup = 'tests';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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");
|
||||
@ -52,6 +53,10 @@ $routes->get('/update-emp-policy-status', 'ClientController::updateEmpAndPolicyS
|
||||
$routes->get('download-e-card/(:any)', 'EmployeeController::generateIDCardForEmployee/$1');
|
||||
$routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1');
|
||||
$routes->get('claim-form-download/(:any)', 'TicketController::downloadClaimForm/$1');
|
||||
$routes->match (['get','post'],"claims-feedback-form/(:any)/(:any)", "TicketController::viewClaimFeedbackForm/$1/$2");
|
||||
$routes->match (['get','post'],"claims-feedback-form/(:any)", "TicketController::viewClaimFeedbackForm/$1");
|
||||
|
||||
|
||||
|
||||
$routes->group("/user", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "UserController::create");
|
||||
@ -68,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) {
|
||||
@ -83,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) {
|
||||
@ -315,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");
|
||||
@ -348,12 +356,20 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1');
|
||||
$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->post("getMoreInfo","PolicyTransactionController::getMoreInfo");
|
||||
$routes->post("saveInstallment","PolicyTransactionController::saveInstallment");
|
||||
|
||||
$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");
|
||||
@ -368,7 +384,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");
|
||||
@ -404,6 +420,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "LeadsController::createRFQ");
|
||||
$routes->post("savePolicyInfo", "LeadsController::savePolicyInfo");
|
||||
$routes->post("createQCR", "LeadsController::createQCR");
|
||||
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
|
||||
$routes->get("nonEB","LeadsController::rfqNonEB");
|
||||
@ -431,6 +448,7 @@ $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDr
|
||||
//crone job
|
||||
$routes->cli('cli/enrollOpendAndClose', 'DashboardController::updatePolicyEnrollmentStatus');
|
||||
$routes->cli("cli/sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
|
||||
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
|
||||
|
||||
//Employee login api's
|
||||
$routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber");
|
||||
@ -439,6 +457,9 @@ $routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyM
|
||||
$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin");
|
||||
$routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId");
|
||||
$routes->post("/employeeRest/updateEmpOTP", "RestAuthenticationController::updateEmpOTP");
|
||||
$routes->post("/employeeRest/updateEmpMPIN", "RestAuthenticationController::updateEmpMPIN");
|
||||
// $routes->post("/employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
|
||||
|
||||
|
||||
//HR login api's
|
||||
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
|
||||
@ -461,6 +482,11 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
|
||||
});
|
||||
|
||||
$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
|
||||
$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin");
|
||||
|
||||
|
||||
|
||||
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
|
||||
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
@ -468,8 +494,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
|
||||
|
||||
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
|
||||
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
||||
$routes->post("updateMpin", "RestAuthenticationController::updateMpin");
|
||||
// $routes->post("updateMpin", "RestAuthenticationController::updateMpin");
|
||||
$routes->post("getChatResponse", "ChatBotController::getChatResponse");
|
||||
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
|
||||
|
||||
@ -502,6 +527,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
||||
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
||||
$routes->get("getWellnessURL", "EmployeeRestController::getWellnessURL");
|
||||
|
||||
// $routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket");
|
||||
});
|
||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||
@ -514,19 +541,22 @@ $routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrol
|
||||
|
||||
// Ticketing System End's
|
||||
|
||||
|
||||
$routes->get("autobookstackLogin", "RestAuthenticationController::bookstackLoginToken");
|
||||
//BDSReports
|
||||
$routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match( ['get', 'post'], 'irba_report','BDSReportController::irba_report');
|
||||
$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');
|
||||
@ -538,6 +568,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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,10 +17,14 @@ class EcardDownloadConversation extends Conversation
|
||||
|
||||
protected function showEcardMenu()
|
||||
{
|
||||
log_message('error', ('showEcardMenu function called'));
|
||||
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
$buttons = [];
|
||||
$question = 'Choose Policy to Download Ecard:';
|
||||
log_message('error', ('policy_list : ' . json_encode($policy_list)));
|
||||
|
||||
if(is_array($policy_list) && count($policy_list))
|
||||
{
|
||||
foreach($policy_list as $policy)
|
||||
|
||||
@ -46,9 +46,16 @@ class MainMenuConversation extends Conversation
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
log_message('error', ('user_reponse before: ' . $user_reponse));
|
||||
|
||||
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
|
||||
log_message('error', ('user_reponse is interactive: ' . $answer->isInteractiveMessageReply()));
|
||||
|
||||
|
||||
// Get just the existing path array
|
||||
$path = $this->bot->userStorage()->get('path') ?? [];
|
||||
|
||||
@ -60,25 +67,35 @@ class MainMenuConversation extends Conversation
|
||||
'path' => $path
|
||||
]);
|
||||
|
||||
log_message('error', ('user_reponse after: ' . $user_reponse));
|
||||
|
||||
|
||||
switch ($user_reponse) {
|
||||
|
||||
case "ecard_download":
|
||||
$this->bot->startConversation(new EcardDownloadConversation());
|
||||
log_message('error', 'ecard_download clicked ');
|
||||
|
||||
break;
|
||||
case "network_hospital":
|
||||
$this->bot->startConversation(new NetworkHospitalConversation());
|
||||
log_message('error', 'network_hospital clicked ');
|
||||
break;
|
||||
case "reimbursement_claim":
|
||||
$this->bot->startConversation(new ReimbursementClaimProcessConversation());
|
||||
log_message('error', 'reimbursement_claim clicked ');
|
||||
break;
|
||||
case "reimbursement_status":
|
||||
$this->bot->startConversation(new ReimbursementClaimStatusConversation());
|
||||
log_message('error', 'reimbursement_status clicked ');
|
||||
break;
|
||||
case "new_policy":
|
||||
case "renew_policy":
|
||||
$this->bot->startConversation(new policyConversation());
|
||||
log_message('error', 'renew_policy || new_policy clicked ');
|
||||
break;
|
||||
default:
|
||||
log_message('error', 'default shown ');
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
break;
|
||||
|
||||
@ -59,7 +59,10 @@ class NetworkHospitalConversation extends Conversation
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
log_message('error', ('user_reponse : ' . $answer->getValue()));
|
||||
|
||||
switch ($answer->getValue()) {
|
||||
|
||||
case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2:
|
||||
|
||||
$client_poilicy_id = explode('#',$answer->getValue())[1];
|
||||
|
||||
@ -46,6 +46,9 @@ class policyConversation extends Conversation
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
|
||||
log_message('error', ('user_reponse : ' . $answer->getValue()));
|
||||
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
|
||||
@ -84,12 +84,13 @@ class ChatbotControllerNew extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
if($this->session->get('CHATBOT_RANDOM_USER_ID') == '-' || $this->session->get('CHATBOT_RANDOM_USER_ID') == '')
|
||||
{
|
||||
|
||||
$user = $this->botman->getUser();
|
||||
$id = $user->getId();
|
||||
// $this->myLogger->logme('error', ('TEST' . $id));
|
||||
$this->myLogger->logme('error', ('TEST' . $id));
|
||||
$this->session->set('CHATBOT_RANDOM_USER_ID', $id);
|
||||
}
|
||||
|
||||
@ -100,6 +101,7 @@ class ChatbotControllerNew extends BaseController
|
||||
}
|
||||
|
||||
$this->botman->hears('.*', function ($bot) {
|
||||
log_message("error","Inside Bot Type Function");
|
||||
|
||||
$bot->types(); // Typing indicator for the first message
|
||||
sleep(0.5); // Delay
|
||||
@ -128,14 +130,14 @@ class ChatbotControllerNew extends BaseController
|
||||
$this->botman->listen();
|
||||
}
|
||||
|
||||
private function registerHandlers()
|
||||
{
|
||||
// Handling Policy and Claims
|
||||
$this->botman->hears('group:policy:{option}', [\App\Controllers\Chatbot\PolicyHandler::class, 'handle']);
|
||||
$this->botman->hears('group:claim:{option}', [\App\Libraries\Chatbot\ClaimHandler::class, 'handle']);
|
||||
// private function registerHandlers()
|
||||
// {
|
||||
// // Handling Policy and Claims
|
||||
// $this->botman->hears('group:policy:{option}', [\App\Controllers\Chatbot\PolicyHandler::class, 'handle']);
|
||||
// $this->botman->hears('group:claim:{option}', [\App\Libraries\Chatbot\ClaimHandler::class, 'handle']);
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
public function chatbot()
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
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,10 @@ class DashboardController extends AdminController
|
||||
|
||||
$data = [];
|
||||
|
||||
$db = db_connect();
|
||||
$sql = "SELECT
|
||||
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,
|
||||
clients.client_name,
|
||||
clients.short_name,
|
||||
@ -144,38 +220,89 @@ class DashboardController extends AdminController
|
||||
|
||||
GROUP BY clients.id, client_branch.id";
|
||||
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
|
||||
$pendingActionsController = new PendingActionsController;
|
||||
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
|
||||
$businessTeamData = $this->policyTransactionModel->getBusinessReportList();
|
||||
$financeTeamData = $this->policyTransactionModel->getFinanceReportList();
|
||||
$businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
|
||||
$financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
|
||||
$pendingActionsController = new PendingActionsController;
|
||||
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
|
||||
$businessTeamData = $this->policyTransactionModel->getBusinessReportList();
|
||||
$financeTeamData = $this->policyTransactionModel->getFinanceReportList();
|
||||
$businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
|
||||
$financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
|
||||
|
||||
|
||||
$data['client_branch_emp_list'] = $results;
|
||||
$session = \Config\Services::session();
|
||||
$session->set('enrollment_data', json_encode($data));
|
||||
$data['client_branch_emp_list'] = $results;
|
||||
$session = \Config\Services::session();
|
||||
$session->set('enrollment_data', json_encode($data));
|
||||
|
||||
// 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;
|
||||
}
|
||||
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);
|
||||
|
||||
// echo "<pre>";
|
||||
$data['pendingActionsData'] = $pendingActionsData;
|
||||
$data['businessTeamCount'] = count($businessTeamData) ?? 0;
|
||||
$data['financeTeamCount'] = count($financeTeamData) ?? 0;
|
||||
$data['businessTeamStatusData'] = $businessTeamStatusData;
|
||||
$data['financeTeamStatusData'] = $financeTeamStatusData;
|
||||
$data['policyStatus'] = $this->policyStatus;
|
||||
$data['colorShades'] = $this->colorShades;
|
||||
// print_r($data);die;
|
||||
|
||||
$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()
|
||||
{
|
||||
@ -208,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;
|
||||
@ -239,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']);
|
||||
}
|
||||
}
|
||||
@ -281,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'];
|
||||
}
|
||||
|
||||
@ -417,7 +536,6 @@ class DashboardController extends AdminController
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
}
|
||||
}
|
||||
|
||||
} else { // crone
|
||||
|
||||
if (!empty($client_policy['reminder_date'])) {
|
||||
@ -507,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');
|
||||
@ -545,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);
|
||||
@ -577,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;
|
||||
@ -599,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)
|
||||
@ -616,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']) {
|
||||
@ -646,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,11 @@ use App\Models\CDMasterModel;
|
||||
use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\ClientBranchModel;
|
||||
use App\Models\EndorsementModel;
|
||||
use App\Models\BdsPlacementModel;
|
||||
use App\Models\LeadsModel;
|
||||
use App\Models\LeadInstallmentPaymentDetails;
|
||||
use App\Models\PolicyTransactionModel;
|
||||
use App\Models\PTCOShareDetailsModel;
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
use App\Controllers\JobWorker;
|
||||
@ -60,6 +65,11 @@ class EmpDataServiceController extends BaseController
|
||||
protected $excelExportTemplateModel;
|
||||
protected $clientBranchModel;
|
||||
protected $endorsementModel;
|
||||
protected $BdsPlacementModel;
|
||||
protected $leadsModel;
|
||||
protected $leadInstallmentPaymentDetailesModel;
|
||||
protected $policyTransactionModel;
|
||||
protected $PTCOShareDetailsModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -83,6 +93,11 @@ class EmpDataServiceController extends BaseController
|
||||
$this->excelExportTemplateModel = new InsurerExcelExportTemplateModel();
|
||||
$this->clientBranchModel = new ClientBranchModel();
|
||||
$this->endorsementModel = new EndorsementModel();
|
||||
$this->BdsPlacementModel = new BdsPlacementModel();
|
||||
$this->leadsModel = new LeadsModel();
|
||||
$this->leadInstallmentPaymentDetailesModel = new LeadInstallmentPaymentDetails();
|
||||
$this->policyTransactionModel = new PolicyTransactionModel();
|
||||
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
|
||||
|
||||
}
|
||||
|
||||
@ -170,7 +185,7 @@ class EmpDataServiceController extends BaseController
|
||||
$balance = $this->CDMasterModel
|
||||
->where('client_id', $export_data['client_id'])
|
||||
->where('insurer_id', $policy_details['insurer_id'])
|
||||
->where('cd_ac_no', $policy_details['cd_ac_no'])
|
||||
->where('id', $policy_details['cd_ac_pk'])
|
||||
->first();
|
||||
|
||||
$cash_balance['balance'] = $balance['opening_bal'];
|
||||
@ -432,7 +447,7 @@ class EmpDataServiceController extends BaseController
|
||||
];
|
||||
|
||||
//for addition and dependent addition adding a ENDORSEMENT NO column
|
||||
if(in_array($export_data['event_type'], ['addition', 'dependent_addition'])){
|
||||
if(in_array($export_data['event_type'], ['addition', 'dependent_addition', 'missed_inception'])){
|
||||
$excel_header_columns[] = [
|
||||
'column_index' => 18,
|
||||
'column_name' => 'ENDORSEMENT NO',
|
||||
@ -529,6 +544,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true; // Excel file successfully generated and exported
|
||||
|
||||
@ -633,6 +649,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -666,7 +683,7 @@ class EmpDataServiceController extends BaseController
|
||||
$balance = $this->CDMasterModel
|
||||
->where('client_id', $export_data['client_id'])
|
||||
->where('insurer_id', $policy_details['insurer_id'])
|
||||
->where('cd_ac_no', $policy_details['cd_ac_no'])
|
||||
->where('id', $policy_details['cd_ac_pk'])
|
||||
->first();
|
||||
|
||||
$cash_balance['balance'] = $balance['opening_bal'];
|
||||
@ -784,6 +801,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -897,6 +915,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -945,6 +964,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 +1218,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// Close and remove temporary file
|
||||
fclose($tempFile);
|
||||
exit();
|
||||
|
||||
return true; // Excel file successfully generated and exported
|
||||
|
||||
@ -1381,14 +1404,15 @@ class EmpDataServiceController extends BaseController
|
||||
'TOTAL AMOUNT',
|
||||
];
|
||||
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition'])){
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition', 'missed_inception'])){
|
||||
$inceptionHeader[] = 'ENDORSEMENT NO';
|
||||
}
|
||||
|
||||
// dd($inceptionHeader);
|
||||
foreach ($inceptionHeader as $key => $value) {
|
||||
|
||||
if($excel_header[$key] != $value){
|
||||
if (!isset($excel_header[$key]) || $excel_header[$key] != $value) {
|
||||
|
||||
$data = [
|
||||
'status' => 'failed-5',
|
||||
];
|
||||
@ -1543,6 +1567,17 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($file['event_type'], ['addition', 'dependent_addition', 'missed_inception'])) {
|
||||
if ($excel_data[$key][18] === null) {
|
||||
$missing_id[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 18,
|
||||
'db_data' => "Endorsement ID is Must",
|
||||
'excel_data' => $excel_data[$key][18]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($emp_value['emp_name'] != $excel_data[$key][1]) {
|
||||
$errors[$key][] = [
|
||||
@ -1877,6 +1912,27 @@ class EmpDataServiceController extends BaseController
|
||||
$emp_details[] = array('id' => $result['id'], 'tpa_id' => $value[13], 'uhid' => $value[14]);
|
||||
}
|
||||
|
||||
if(in_array($file['event_type'], ['missed_inception']) && isset($value[18])){
|
||||
$endorsement_id = $value[18];
|
||||
|
||||
$result_for_employees_policy = $this->employeePolicyModel
|
||||
->select('employee_polices.*')
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
->join('emp_endorsement', 'emp_endorsement.employee_id = employees.id') // assuming this is the correct join
|
||||
->where('employees.emp_code', $emp_code)
|
||||
->where('employees.name', $name)
|
||||
->where('employees.client_id', $client_id)
|
||||
->where('employees.client_branch_id', $client_branch_id)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.emp_status', 'active')
|
||||
->first();
|
||||
|
||||
$enrollment_file_id = $result_for_employees_policy['file_id'] ?? null;
|
||||
}
|
||||
|
||||
//for addition and dependent_addition endorsement , endorsement_id update functionality
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition']) && isset($value[18])){
|
||||
|
||||
@ -1906,7 +1962,9 @@ class EmpDataServiceController extends BaseController
|
||||
->first();
|
||||
|
||||
if (!empty($result_for_endorsement) && count($result_for_endorsement)) {
|
||||
$enrollment_file_id = $result_for_endorsement['file_id']; //files table primary key
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result_for_endorsement['file_id']; //files table primary key
|
||||
}
|
||||
$emp_endorsement_table_data[] = array('id' => $result_for_endorsement['id'], 'group_key' => $result_for_endorsement['group_key'], 'endorsement_id' => $value[18], 'status' => 'complete');
|
||||
}
|
||||
}
|
||||
@ -1922,7 +1980,6 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition']) && !empty($emp_endorsement_table_data)){
|
||||
$this->employeePolicyModel->updateEmpEndorsementAddition($emp_endorsement_table_data);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
}
|
||||
|
||||
// Update batch file status and amount
|
||||
@ -1939,6 +1996,11 @@ class EmpDataServiceController extends BaseController
|
||||
//update CD transaction entry if only insurer
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition', 'missed_inception'])){
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
}
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- set cashDepositCalculationForInception and sendMailForDownloadingECard in JOB QUEUE');
|
||||
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
@ -1968,6 +2030,13 @@ class EmpDataServiceController extends BaseController
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
|
||||
// $this->cashDepositCalculationForInception($depositeData);
|
||||
// $this->sendMailForDownloadingECard($emp_policy_ids);
|
||||
|
||||
@ -2358,7 +2427,9 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
// return $result;
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
}
|
||||
|
||||
if($result['field_name'] == 'dob'){
|
||||
$value[8] = change_date_format($value[8]);
|
||||
@ -2392,6 +2463,13 @@ class EmpDataServiceController extends BaseController
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
$this->setPullNotification($file_data);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id[0] ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
|
||||
|
||||
//import file to upload Google Drive
|
||||
// if(excelFileGDriveUpload($file_id, 'batch_file')){
|
||||
@ -2415,8 +2493,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 +2535,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 +2827,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]
|
||||
];
|
||||
}
|
||||
@ -2921,7 +3008,10 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
}
|
||||
|
||||
$emp_policy_ids[] = array('id' => $result['emp_policy_id'], 'is_active' => 0);
|
||||
$employeeIds[] = $result['emp_policy_id'];
|
||||
$endorsement_details[] = array('id' => $result['id'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[19], 'status' => 'complete');
|
||||
@ -2945,7 +3035,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;
|
||||
@ -2957,31 +3047,28 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// dd($emp_policy_ids, $emp_details, $endorsement_details);
|
||||
|
||||
$this->employeePolicyModel->updateBatch($emp_policy_ids, 'id');
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
|
||||
$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;
|
||||
$this->employeePolicyModel->updateBatch($emp_policy_ids, 'id');
|
||||
|
||||
// $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 = [];
|
||||
foreach ($emp_details as $emp) {
|
||||
$insertedIds[] = $this->employeePolicyModel->insert($emp);
|
||||
}
|
||||
|
||||
// dd($insertedIds);
|
||||
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
}
|
||||
|
||||
$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
|
||||
// }
|
||||
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
|
||||
|
||||
// Update batch file status and amount
|
||||
@ -3013,6 +3100,13 @@ class EmpDataServiceController extends BaseController
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
@ -3425,7 +3519,9 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) {
|
||||
|
||||
$enrollment_file_id = $result['file_id']; //files table primary key
|
||||
if(empty($enrollment_file_id)){
|
||||
$enrollment_file_id = $result['file_id']; //files table primary key
|
||||
}
|
||||
$employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite
|
||||
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => change_date_format($result['date_of_exit']), 'reason_for_exit' => $result['reason_for_exit'], 'claim_status' => $result['claim_status'], 'status' => $result['status']);
|
||||
// $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
|
||||
@ -3445,20 +3541,29 @@ class EmpDataServiceController extends BaseController
|
||||
// return ['status' => 'error', 'message' => 'Employees table data is empty or null.'];
|
||||
// }
|
||||
|
||||
// Check if $employee_policy_table_data is null or empty
|
||||
if (empty($employee_policy_table_data)) {
|
||||
return ['status' => 'error', 'message' => 'Employee policy table data is empty or null.'];
|
||||
}
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
// Check if $emp_endorsement_table_data is null or empty
|
||||
if (empty($emp_endorsement_table_data)) {
|
||||
return ['status' => 'error', 'message' => 'Employee endorsement table data is empty or null.'];
|
||||
}
|
||||
// Check if $employee_policy_table_data is null or empty
|
||||
if (empty($employee_policy_table_data)) {
|
||||
$this->batchFileModel->update($file_id, [
|
||||
'status' => "failed",
|
||||
]);
|
||||
return ['status' => 'error', 'message' => 'Employee policy table data is empty or null.'];
|
||||
}
|
||||
|
||||
// $this->employeeModel->updateBatch($employees_table_data, 'id');
|
||||
$this->employeePolicyModel->updateBatch($employee_policy_table_data, 'id');
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($emp_endorsement_table_data);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
// Check if $emp_endorsement_table_data is null or empty
|
||||
if (empty($emp_endorsement_table_data)) {
|
||||
$this->batchFileModel->update($file_id, [
|
||||
'status' => "failed",
|
||||
]);
|
||||
return ['status' => 'error', 'message' => 'Employee endorsement table data is empty or null.'];
|
||||
}
|
||||
|
||||
// $this->employeeModel->updateBatch($employees_table_data, 'id');
|
||||
$this->employeePolicyModel->updateBatch($employee_policy_table_data, 'id');
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($emp_endorsement_table_data);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
}
|
||||
|
||||
// Update batch file status and amount
|
||||
$this->batchFileModel->update($file_id, [
|
||||
@ -3487,6 +3592,13 @@ class EmpDataServiceController extends BaseController
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'emp_count' => $emp_count ?? null,
|
||||
'action_type' => $file['event_type'] ?? null,
|
||||
]]);
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
@ -4105,6 +4217,9 @@ class EmpDataServiceController extends BaseController
|
||||
AND emp_endorsement.pk IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
AND employee_polices.claim_status = 0
|
||||
AND emp_endorsement.field_name = 'date_of_exit'
|
||||
AND emp_endorsement.is_active = 1
|
||||
AND emp_endorsement.actions = 'd'
|
||||
AND emp_endorsement.status != 'truncated';
|
||||
")->getRow();
|
||||
|
||||
// dd(db_connect()->getLastQuery(), $amount);
|
||||
@ -4661,6 +4776,316 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('error',"storeEndorsementNumber --- Function execution completed for file_id: $file_id");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function makeEntryForBDSPolicyTransaction($params)
|
||||
{
|
||||
try {
|
||||
$this->myLogger->logme("error", "makeEntryForBDSPolicyTransaction() started: " . json_encode(['params' => $params]));
|
||||
|
||||
if (empty($params) || !isset($params['client_policy_id']) || empty($params['client_policy_id'])) {
|
||||
$this->myLogger->logme("error", "Invalid parameters provided: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Client Policy ID is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
if (!isset($params['action_type']) || empty($params['action_type'])) {
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Action type is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
//Function call for if the old policy transaction entries exisit than active the Policy transaction entries
|
||||
$existing_policy_transaction_entry = $this->retrivePolicyTransactionEntries($params);
|
||||
|
||||
if($existing_policy_transaction_entry != false){
|
||||
return $existing_policy_transaction_entry;
|
||||
}
|
||||
|
||||
//get the policy data
|
||||
$policy_data = $this->clientPolicyModel
|
||||
->where('id', $params['client_policy_id'])
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (empty($policy_data)) {
|
||||
$this->myLogger->logme("error", "No policy data found: " . json_encode(['client_policy_id' => $params['client_policy_id']]));
|
||||
return ['status' => "Failed", 'message' => "No policy data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
//get the leads data
|
||||
$lead_data = $this->leadsModel
|
||||
->where('is_policy_created', $params['client_policy_id'])
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (empty($lead_data)) {
|
||||
$this->myLogger->logme("error", "No lead data found: " . json_encode(['client_policy_id' => $params['client_policy_id']]));
|
||||
// return ['status' => "Failed", 'message' => "No lead data found for the given client policy ID", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Constructing policy transaction data: " . json_encode(['policy_data' => $policy_data, 'lead_data' => $lead_data]));
|
||||
|
||||
//Function to construct the policy transaction data to insert
|
||||
$policyTransactionData = $this->constructBDSData($policy_data, $lead_data, $params);
|
||||
|
||||
//insert the policy transaction data to othe table
|
||||
$insert_id = $this->policyTransactionModel->insert($policyTransactionData);
|
||||
|
||||
if (!$insert_id) {
|
||||
$this->myLogger->logme("error", "Failed to insert into policy_transaction: " . json_encode($policyTransactionData));
|
||||
return ['status' => "Failed", 'message' => "Failed to insert policy transaction record", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Policy transaction inserted successfully: " . json_encode(['insert_id' => $insert_id]));
|
||||
|
||||
//do not remove this commented item
|
||||
// $coShareDetails = $this->ConstructPTShareData($policy_data, $insert_id);
|
||||
// $pt_co_share_id = $this->PTCOShareDetailsModel->insert($coShareDetails);
|
||||
|
||||
// $this->myLogger->logme("error", "PT Co share data inserted successfully: " . json_encode(['pt_co_share_id' => $pt_co_share_id]));
|
||||
|
||||
// get the lead installment data
|
||||
|
||||
if(!empty($lead_data)){
|
||||
$lead_installment_data = $this->leadInstallmentPaymentDetailesModel
|
||||
->select('lead_id, installment_amount, payment_date, utr_no')
|
||||
->where('lead_id', $lead_data['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
if (!empty($lead_installment_data) && (isset($params['action_type']) && $params['action_type'] == "inception")) {
|
||||
|
||||
$this->myLogger->logme("error", "Found lead installment data: " . json_encode($lead_installment_data));
|
||||
$installment_ids = $this->constructInstallmentData($lead_installment_data, $insert_id);
|
||||
$this->myLogger->logme("error", "BDS Installment data inserted ids: " . json_encode(['installment_ids' => $installment_ids]));
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Failed to insert Installment data : " . json_encode($params));
|
||||
}
|
||||
}
|
||||
|
||||
return ['status' => "Success", 'message' => "Policy transaction entry created successfully", 'data' => ['params' => $params, 'insert_id' => $insert_id]];
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme("error", "Exception occurred in makeEntryForBDSPolicyTransaction(): " . json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]));
|
||||
|
||||
return ['status' => "Error", 'message' => "An unexpected error occurred", 'data' => ['error' => $e]];
|
||||
}
|
||||
}
|
||||
|
||||
private function constructBDSData($policy_data, $lead_data, $params)
|
||||
{
|
||||
|
||||
$action_type_string = $params['action_type'];
|
||||
if(in_array($params['action_type'], ['dependent_addition', 'missed_inception'])){
|
||||
$action_type_string = "addition";
|
||||
}
|
||||
|
||||
$policyTransactionData = [
|
||||
|
||||
'issuer' => 2,
|
||||
'client_id' => $policy_data['client_id'] ?? null,
|
||||
'client_branch_id' => $policy_data['client_branch_id'] ?? null,
|
||||
'insurer_id' => $policy_data['insurer_id'] ?? null,
|
||||
'insurer_branch_id' => $policy_data['insurer_branch_id'] ?? null,
|
||||
'tpa_id' => $policy_data['tpa_id'] ?? null,
|
||||
'tpa_branch_id' => $policy_data['tpa_branch_id'] ?? null,
|
||||
'policy_type_id' => $policy_data['policy_type_id'] ?? null,
|
||||
'client_policy_id' => $policy_data['id'] ?? null,
|
||||
'policy_no' => $policy_data['policy_no'] ?? null,
|
||||
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
|
||||
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
|
||||
'policy_issue_date' => $policy_data['policy_start_date'] ?? null,
|
||||
'policy_start_date' => $policy_data['policy_start_date'] ?? null,
|
||||
'policy_end_date' => $policy_data['policy_end_date'] ?? null,
|
||||
'data_received_date' => $policy_data['data_received_date'] ?? null,
|
||||
'closure_date' => $policy_data['closure_date'] ?? null,
|
||||
'emp_count' => $policy_data['emp_count'] ?? null,
|
||||
'dependent_count' => $policy_data['dependent_count'] ?? null,
|
||||
'revenue_type' => ($lead_data['lead_type'] == 1 ? "NA" : ($lead_data['lead_type'] == 2 ? "EA" : "EANR") ) ?? null,
|
||||
'co_share' => $policy_data['co_share'] ?? 0,
|
||||
'pre_payable_by' => $policy_data['pre_payable_by'] ?? 1,
|
||||
'renewal_date' => $policy_data['policy_end_date'] ?? null,
|
||||
'month' => date('Y-m-01', strtotime($policy_data['policy_start_date'])) ?? null,
|
||||
'ct_type' => 1,
|
||||
'is_cd_reduce_from_bds' => 0,
|
||||
'client_type_id' => 0,
|
||||
|
||||
'status' => "co_insurer_pending",
|
||||
'action_type' => $action_type_string ?? null,
|
||||
'endorsement_no' => $params['endorsement_no'] ?? null,
|
||||
|
||||
'issue_type' => $lead_data['lead_type'] ?? 1,
|
||||
'source_client_policy_id' => $lead_data['source_policy_id'] ?? null,
|
||||
'tsi' => generate_tsi_code($lead_data['lead_type'] ?? 1) ?? null,
|
||||
'installment' => $lead_data['no_of_installment'] ?? null,
|
||||
];
|
||||
|
||||
$this->myLogger->logme("error", "Constructed policy transaction data: " . json_encode($policyTransactionData));
|
||||
|
||||
return $policyTransactionData;
|
||||
}
|
||||
|
||||
private function ConstructPTShareData($policy_data, $pt_id)
|
||||
{
|
||||
$coShareData = [
|
||||
'pt_id' => $pt_id,
|
||||
'insurer_id' => $policy_data['insurer_id'],
|
||||
'insurer_branch_id' => $policy_data['insurer_branch_id'],
|
||||
'co_share_type' => 1,
|
||||
];
|
||||
|
||||
$this->myLogger->logme("error", "Constructed PT co-share data: " . json_encode($coShareData));
|
||||
|
||||
|
||||
return $coShareData;
|
||||
}
|
||||
|
||||
private function constructInstallmentData($data, $pt_id)
|
||||
{
|
||||
if (!empty($data)) {
|
||||
$installment_ids = [];
|
||||
foreach ($data as $key => &$value) {
|
||||
$value['pt_id'] = $pt_id;
|
||||
$installment_ids[] = $this->BdsPlacementModel->insert($value);
|
||||
}
|
||||
unset($value);
|
||||
|
||||
return $installment_ids;
|
||||
}
|
||||
}
|
||||
|
||||
private function retrivePolicyTransactionEntries($params)
|
||||
{
|
||||
$policy_transaction_data = $this->policyTransactionModel
|
||||
->where('is_active', 0)
|
||||
->where('client_policy_id', $params['client_policy_id']);
|
||||
|
||||
if ($params['action_type'] != "inception") {
|
||||
$policy_transaction_data = $policy_transaction_data->where('endorsement_no', $params['endorsement_no']);
|
||||
}
|
||||
|
||||
$policy_transaction_data = $policy_transaction_data
|
||||
->where('action_type', $params['action_type'])
|
||||
->first();
|
||||
|
||||
if(empty($policy_transaction_data)){
|
||||
$this->myLogger->logme("error", "retrive Policy Transaction Entries data not found : " . json_encode(['params' => $params]));
|
||||
return false;
|
||||
}
|
||||
|
||||
$pt_co_share_data = $this->PTCOShareDetailsModel->where('is_active', 0)->where('pt_id', $policy_transaction_data['id'])->findAll();
|
||||
|
||||
if(empty($pt_co_share_data)){
|
||||
$this->myLogger->logme("error", "PT Co Share Table data not found");
|
||||
}
|
||||
|
||||
$activated_pt_co_share_ids = [];
|
||||
foreach ($pt_co_share_data as $key => $value) {
|
||||
$this->PTCOShareDetailsModel->where('id', $value['id'])->set(['is_active' => 1])->update();
|
||||
$activated_pt_co_share_ids[] = $value['id'];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Activated pt_co_share_ids : ". json_encode($activated_pt_co_share_ids));
|
||||
|
||||
|
||||
$update_return = $this->policyTransactionModel->where('id', $policy_transaction_data['id'])->set(['is_active' => 1])->update();
|
||||
|
||||
if($update_return){
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Success", 'message' => "Policy transaction entry Retrived successfully", 'data' => ['params' => $params, 'updated_id' => $policy_transaction_data['id']]];
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Success", 'message' => "Failed to retrive the policy transaction entry", 'data' => ['params' => $params, 'updated_id' => $policy_transaction_data['id']]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function removeBDSPolicyTransactionEntryFromTruncate($params)
|
||||
{
|
||||
if (empty($params) || !isset($params['client_policy_id']) || empty($params['client_policy_id'])) {
|
||||
$this->myLogger->logme("error", "Invalid parameters provided: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Client Policy ID is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
if (!isset($params['file_id']) || empty($params['file_id'])) {
|
||||
$this->myLogger->logme("error", "File ID is missing or empty : " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "File ID is missing or empty : ", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
if (!isset($params['action_type']) || empty($params['action_type'])) {
|
||||
$this->myLogger->logme("error", "Invalid action type: " . json_encode(['params' => $params]));
|
||||
return ['status' => "Failed", 'message' => "Action type is missing or empty", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
|
||||
if($params['action_type'] != "inception"){
|
||||
|
||||
$endorsement_data = $this->endorsementModel
|
||||
->where('is_active', 1)
|
||||
->where('client_policy_id', $params['client_policy_id'])
|
||||
->where('endorsement_type', $params['action_type'])
|
||||
->where('file_id', $params['file_id'])
|
||||
->first();
|
||||
|
||||
if(empty($endorsement_data)){
|
||||
$this->myLogger->logme("error", "Endorsement data not found");
|
||||
return ['status' => "Failed", 'message' => "Endorsement data not found", 'data' => ['params' => $params]];
|
||||
}
|
||||
}
|
||||
|
||||
$action_type_string = $params['action_type'];
|
||||
if(in_array($params['action_type'], ['dependent_addition', 'missed_inception'])){
|
||||
$action_type_string = "addition";
|
||||
}
|
||||
|
||||
|
||||
$policy_transaction_data = $this->policyTransactionModel
|
||||
->where('is_active', 1)
|
||||
->where('client_policy_id', $params['client_policy_id']);
|
||||
|
||||
if ($params['action_type'] != "inception") {
|
||||
$policy_transaction_data = $policy_transaction_data->where('endorsement_no', $endorsement_data['endorsement_no']);
|
||||
}
|
||||
|
||||
$policy_transaction_data = $policy_transaction_data
|
||||
->where('action_type', $action_type_string)
|
||||
->first();
|
||||
|
||||
|
||||
if(empty($policy_transaction_data)){
|
||||
$this->myLogger->logme("error", "Policy transaction data not found");
|
||||
return ['status' => "Failed", 'message' => "Policy transaction data not found", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
|
||||
$pt_co_share_data = $this->PTCOShareDetailsModel->where('is_active', 1)->where('pt_id', $policy_transaction_data['id'])->findAll();
|
||||
|
||||
if(empty($pt_co_share_data)){
|
||||
$this->myLogger->logme("error", "PT Co Share Table data not found");
|
||||
}
|
||||
|
||||
$de_activated_pt_co_share_ids = [];
|
||||
foreach ($pt_co_share_data as $key => $value) {
|
||||
$this->PTCOShareDetailsModel->where('id', $value['id'])->set(['is_active' => 0])->update();
|
||||
$de_activated_pt_co_share_ids[] = $value['id'];
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "De-activated pt_co_share_ids : ". json_encode($de_activated_pt_co_share_ids));
|
||||
|
||||
$update_return = $this->policyTransactionModel->where('id', $policy_transaction_data['id'])->set(['is_active' => 0])->update();
|
||||
|
||||
if($update_return){
|
||||
$this->myLogger->logme("error", "Policy transaction data de-active successfully");
|
||||
return ['status' => "Success", 'message' => "Policy transaction data Truncated successfully", 'data' => ['params' => $params]];
|
||||
}else{
|
||||
$this->myLogger->logme("error", "Failed to de-active policy transaction data");
|
||||
return ['status' => "Success", 'message' => "Failed to truncated the policy transaction data", 'data' => ['params' => $params]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
@ -315,8 +315,10 @@ class EmployeeController extends AdminController
|
||||
// ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
|
||||
// ->where('files.created_by', get_session_userid())->orderBy('files.created_at', 'desc')->findAll();
|
||||
// dd($this->fileModel->getLastQuery());
|
||||
$role_id = get_role_id();
|
||||
$user_id = get_session_userid();
|
||||
|
||||
$data['fileList'] = $this->fileModel
|
||||
$query = $this->fileModel
|
||||
->select([
|
||||
'files.id','files.file_name','files.created_by','files.created_at','files.is_active','files.status','files.client_id','files.policy_id','files.client_branch_id','files.action','files.uploaded_by',
|
||||
'up.emp_code',
|
||||
@ -334,13 +336,20 @@ class EmployeeController extends AdminController
|
||||
->join('client_branch cb', 'files.client_branch_id = cb.id', 'left')
|
||||
->join('policy_type', 'policy_type.id = cp.policy_type_id')
|
||||
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
|
||||
->join("client_rm cr","cr.client_id = c.id and cr.is_active = 1",'left')
|
||||
->where('files.is_active', 1);
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
$query->where('cr.user_id', $user_id);
|
||||
}
|
||||
// ->where('files.created_by', get_session_userid())
|
||||
->orderBy('files.created_at', 'desc')
|
||||
->limit(100)
|
||||
$data['fileList'] = $query->groupBy("c.id")->orderBy('files.created_at', 'desc')
|
||||
->limit(1500)
|
||||
->find();
|
||||
// dd($data['fileList']);
|
||||
|
||||
$data['batch_list'] = $this->batchFileModel->select("
|
||||
$query2 = $this->batchFileModel->select("
|
||||
|
||||
batch_files.id,
|
||||
batch_files.client_id,
|
||||
@ -360,12 +369,13 @@ class EmployeeController extends AdminController
|
||||
batch_files.status,
|
||||
batch_files.client_branch_id,
|
||||
|
||||
CASE
|
||||
WHEN batch_files.status = 'partially success' THEN
|
||||
batch_files.error_data
|
||||
CASE
|
||||
WHEN batch_files.status = 'partially success' OR batch_files.status = 'in-progress-partially' THEN
|
||||
batch_files.error_data
|
||||
ELSE
|
||||
error_data = null
|
||||
END AS error_data,
|
||||
NULL
|
||||
END AS error_data,
|
||||
|
||||
|
||||
clients.short_name as client_short_name,
|
||||
client_branch.branch_name,
|
||||
@ -377,9 +387,18 @@ class EmployeeController extends AdminController
|
||||
->join('client_branch', 'client_branch.id = batch_files.client_branch_id')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->orderBy('batch_files.id', 'desc')
|
||||
->limit(1000)
|
||||
->find();
|
||||
->join("client_rm cr","cr.client_id = clients.id and cr.is_active = 1",'left')
|
||||
->where('batch_files.is_active', 1);
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
$query2->where('cr.user_id', $user_id);
|
||||
}
|
||||
// ->where('files.created_by', get_session_userid())
|
||||
$data['batch_list'] = $query2->groupBy("clients.id")->orderBy('batch_files.id', 'desc')
|
||||
->limit(1500)
|
||||
->find();
|
||||
|
||||
|
||||
|
||||
// dd($data['fileList']);die();
|
||||
@ -433,7 +452,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';
|
||||
@ -443,6 +462,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
|
||||
@ -756,8 +777,18 @@ class EmployeeController extends AdminController
|
||||
|
||||
public function enrollmentClientList()
|
||||
{
|
||||
$role_id = get_role_id();
|
||||
$user_id = get_session_userid();
|
||||
|
||||
$data = [];
|
||||
$client_list = $this->clientModel->where('clients.is_active', 1)->findAll();
|
||||
$client_list = $this->clientModel->join("client_rm","client_rm.client_id = clients.id",'left')->where('clients.is_active', 1);
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
$client_list->where('client_rm.user_id', $user_id);
|
||||
}
|
||||
|
||||
$client_list = $client_list->groupBy("clients.id")->findAll();
|
||||
$branch_list = $this->clientBranchModel->where('client_branch.is_active', 1)->findAll();
|
||||
$policy_list = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
@ -1011,6 +1042,7 @@ class EmployeeController extends AdminController
|
||||
|
||||
$data = $this->employeePolicyModel->select('employee_polices.id')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.client_policy_id', $id)
|
||||
->findAll();
|
||||
|
||||
@ -1381,6 +1413,13 @@ class EmployeeController extends AdminController
|
||||
$this->myLogger->logme('error', 'cash_deposite table updated -- cd transaction');
|
||||
}
|
||||
|
||||
//this job for deactive policy transaction and pt co share table entry for BDS Sync
|
||||
$r = Jobs::addJob(['job_name' => 'removeBDSPolicyTransactionEntryFromTruncate', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'file_id' => $file_id ?? null,
|
||||
'action_type' => $file['action'] ?? null,
|
||||
]]);
|
||||
|
||||
}else{
|
||||
|
||||
$this->myLogger->logme('error', '---- There is no data to truncate ----');
|
||||
@ -1531,6 +1570,13 @@ class EmployeeController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
//this job for deactive policy transaction and pt co share table entry for BDS Sync
|
||||
$r = Jobs::addJob(['job_name' => 'removeBDSPolicyTransactionEntryFromTruncate', 'payload' => [
|
||||
'client_policy_id' => $client_policy_id ?? null,
|
||||
'file_id' => $file_id ?? null,
|
||||
'action_type' => $file['action'] ?? null,
|
||||
]]);
|
||||
|
||||
$this->myLogger->logme('error', 'SUCCESSFULLY TRUNCATED');
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'success'], 200);
|
||||
@ -2358,7 +2404,7 @@ class EmployeeController extends AdminController
|
||||
} else if ($actionType == 'deletion') {
|
||||
$filePath = ROOTPATH . 'public/sample_import_excel/sample_import_Deletion.xlsx';
|
||||
}else if ($actionType == 'missed_inception') {
|
||||
$filePath = ROOTPATH . 'public/sample_import_excel/sample_import_Inception.xlsx';
|
||||
$filePath = ROOTPATH . 'public/sample_import_excel/sample_import_Addition.xlsx';
|
||||
}
|
||||
|
||||
// Check if the file exists
|
||||
|
||||
@ -1100,7 +1100,7 @@ class EmployeeRestController extends AdminController
|
||||
$keysToRemove = ["removable_keys"];
|
||||
// Retrieve employee policy data by passing the employee primary key
|
||||
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||
// dd($empPolicy);
|
||||
// dd($empPolicy);
|
||||
// Retrieve employee and dependents data by passing the employee code
|
||||
$employeeData = $this->employeeModel->where('emp_code',$emp_code)
|
||||
->where('client_id',$client_id)
|
||||
@ -2501,8 +2501,9 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
function getEmployeeActiveOrInactivePolicy()
|
||||
{
|
||||
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; }
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name,tpa.network_hospitals as network_hospitals_url, policy_type.long_name as policy_long_name')
|
||||
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; $policy_status_key = "Active"; }else{ $policy_status = 0; $policy_status_key = "InActive";}
|
||||
$dayInterval = 10;
|
||||
$ClientPolicyData = $this->clientPolicyModel->select("client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name,tpa.network_hospitals as network_hospitals_url, policy_type.long_name as policy_long_name, DATE_ADD(client_policy.policy_end_date, INTERVAL {$dayInterval} DAY) as claims_grace_date")
|
||||
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
|
||||
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
@ -2526,15 +2527,15 @@ class EmployeeRestController extends AdminController
|
||||
->get()->getRow()->name;
|
||||
$whereArrayForId = [];
|
||||
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
|
||||
|
||||
|
||||
if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (strtotime(date('Y-m-d') > strtotime($ClientPolicyValue['claims_grace_date']))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($ClientPolicyValue['policy_type_id'] == 1)
|
||||
{
|
||||
@ -2555,11 +2556,7 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
$terms = json_decode($ClientPolicyValue['policy_terms'] , true);
|
||||
$data['policy_terms'] = isset($terms['enrollment_display_key'])
|
||||
&& !empty($terms['enrollment_display_key'])
|
||||
? $terms['enrollment_display_key']
|
||||
: $this->policyTermsFiter($terms, $policyGroup);
|
||||
$terms = json_decode($ClientPolicyValue['policy_terms']);
|
||||
$data['policy_terms'] = isset($terms['enrollment_display_key']) && !empty($terms['enrollment_display_key']) ? $terms['enrollment_display_key'] : $this->policyTermsFiter($terms, $policyGroup);
|
||||
|
||||
|
||||
$data['client_id'] = $ClientPolicyValue['client_id'];
|
||||
@ -2573,6 +2570,8 @@ class EmployeeRestController extends AdminController
|
||||
$data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']);
|
||||
$data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']);
|
||||
$data['heading'] = $ClientPolicyValue['policy_long_name'];
|
||||
$data['claims_grace_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['claims_grace_date']);
|
||||
$data['policy_status'] = $policy_status_key;
|
||||
// $data['policy_terms'] = $terms;
|
||||
|
||||
// if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else
|
||||
@ -3120,6 +3119,8 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
// ---------------- TICKET API's ---------------------------------------------------------------------------------------------------
|
||||
|
||||
//Get Data from post for inserting ticket and message
|
||||
public function initiateClaim()
|
||||
{
|
||||
@ -3130,6 +3131,18 @@ class EmployeeRestController extends AdminController
|
||||
$client_policy_id = $received_data['client_policy_id'];
|
||||
$insured_emp_id = $received_data['insured_emp_id'];
|
||||
|
||||
if (empty($received_data['doa'])) {
|
||||
$received_data['doa'] = null;
|
||||
} else{
|
||||
$ticket_data['doa'] = change_date_format($received_data['doa']);
|
||||
}
|
||||
|
||||
if (empty($received_data['dod'])) {
|
||||
$received_data['dod'] = null;
|
||||
} else{
|
||||
$ticket_data['dod'] = change_date_format($received_data['dod']);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
select
|
||||
cp.policy_type_id,
|
||||
@ -3172,29 +3185,42 @@ class EmployeeRestController extends AdminController
|
||||
if(!empty($emp_ticket_data)){
|
||||
|
||||
$fetchData = $emp_ticket_data[0];
|
||||
$fetchData['claim_status_id'] = $this->claimStatusModel
|
||||
->select('id')
|
||||
->where('ticket_type', $fetchData['ticket_type_id'])
|
||||
->orderBy('id', 'asc')
|
||||
->first()['id'];
|
||||
|
||||
$claimStatusQuery = $this->claimStatusModel
|
||||
->select('id')
|
||||
->where('ticket_type', $fetchData['ticket_type_id'])
|
||||
->orderBy('id', 'asc');
|
||||
|
||||
if ($fetchData['ticket_type_id'] == 1 && !empty($fetchData['tpa_no'])) {
|
||||
$results = $claimStatusQuery->findAll(2);
|
||||
$fetchData['claim_status_id'] = $results[1]['id'] ?? $results[0]['id'];
|
||||
} else {
|
||||
$fetchData['claim_status_id'] = $claimStatusQuery->first()['id'];
|
||||
}
|
||||
|
||||
|
||||
$fetchData['priority'] = 1;
|
||||
$fetchData['mode_of_intimation'] = 1;
|
||||
$fetchData['mode_of_intimation'] = 3;
|
||||
$fetchData['claim_type'] = 1;
|
||||
$fetchData = array_merge($fetchData, $received_data);
|
||||
|
||||
$fetchData['relationship'] = strtolower($fetchData['relationship']) ?? $fetchData['relationship'];
|
||||
// print_r($fetchData); die;
|
||||
$insert_status = $this->ticketMaster->insert($fetchData);
|
||||
$ticket_id = $this->ticketMaster->insertID();
|
||||
|
||||
if ($insert_status && !empty($ticket_id)) {
|
||||
|
||||
//insert first history
|
||||
$this->ticketController->putHistoryAfterInsert($fetchData, $ticket_id);
|
||||
|
||||
$messagesData = [
|
||||
'ticket_id' => $ticket_id ?? null,
|
||||
'sender' => 'user',
|
||||
'claim_status' => $fetchData['claim_status_id'] ?? null,
|
||||
'emp_mail' => $fetchData['emp_mail'] ?? null,
|
||||
'mail_subject' => $fetchData['subject'] ?? null,
|
||||
'mail_content' => $fetchData['message'] ?? null,
|
||||
'mail_subject' => $fetchData['subject'] ?? "New Claim",
|
||||
'mail_content' => $fetchData['message'] ?? "New Claim",
|
||||
];
|
||||
|
||||
if (!empty($messagesData['ticket_id'])) {
|
||||
@ -3207,18 +3233,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';
|
||||
@ -3229,11 +3249,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);
|
||||
@ -3310,4 +3330,23 @@ class EmployeeRestController extends AdminController
|
||||
return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
|
||||
}
|
||||
|
||||
public function getWellnessUrl()
|
||||
{
|
||||
// $url = "https://aam.mohfw.gov.in/home/login";
|
||||
$url = "";
|
||||
|
||||
if (!empty($url)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $url
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'message' => 'Coming soon........!'
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -28,6 +28,9 @@ use App\Controllers\JobWorker ;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Kint\Kint;
|
||||
|
||||
use App\Helpers\ExcelSanitizeHelper;
|
||||
|
||||
|
||||
class EmployeeServiceController extends AdminController
|
||||
{
|
||||
|
||||
@ -150,7 +153,7 @@ class EmployeeServiceController extends AdminController
|
||||
'is_mandatory' => ['I', 'A', 'DA'],
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null,
|
||||
'allowed_values' => ['Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother', 'Father in Law', 'Mother in Law'],
|
||||
'custom' => 'check_relationship',
|
||||
'params' => ['row', 'relationship', 'policy_terms']
|
||||
],
|
||||
@ -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,19 @@ 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(trim($employee['relationship']));
|
||||
|
||||
if (in_array($relationship_array_key, ['son', 'daughter'])) {
|
||||
$relationship_array_key = 'childrens';
|
||||
} elseif (in_array($relationship_array_key, ['father', 'mother'])) {
|
||||
$relationship_array_key = 'parents';
|
||||
} elseif (in_array($relationship_array_key, ['father in law', 'mother in law', 'father-in-law', 'mother-in-law'])) {
|
||||
$relationship_array_key = 'parents-in-law';
|
||||
}
|
||||
|
||||
if(array_key_exists($relationship_array_key, $rack_rate_json) && $rack_rate_json[$relationship_array_key] != 0 && $rack_rate_json[$relationship_array_key] != 'NA')
|
||||
{
|
||||
$applicable_rack_rate_name = $slab_value['rack_rate_name'];
|
||||
$applicable_rack_rate_master = $slab_value['grid_master'];
|
||||
break;
|
||||
@ -1563,11 +1607,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);
|
||||
|
||||
@ -1585,6 +1631,7 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
|
||||
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
|
||||
//set success msg to pull notifications
|
||||
@ -1658,6 +1705,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 +2096,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 +2131,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']; }
|
||||
|
||||
@ -123,6 +123,14 @@ class JobWorker extends AdminController
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'makeEntryForBDSPolicyTransaction' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'removeBDSPolicyTransactionEntryFromTruncate' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmpDataServiceController',
|
||||
],
|
||||
'employeesEnrollmentInsert' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
@ -130,7 +138,11 @@ class JobWorker extends AdminController
|
||||
'calculateMembersDemography' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\LeadsController',
|
||||
]
|
||||
],
|
||||
'updatePolicyTransactionDataWhileClinetPolicyUpdate' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\ClientController',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -94,7 +94,7 @@ class LoginController extends BaseController
|
||||
// setcookie('session_data', '', time() - 3600, $path);
|
||||
$path = getenv('cookie.Path');
|
||||
$domain = getenv('cookie.Domain');
|
||||
$https = getenv('ccokie.secure');
|
||||
$https = getenv('cookie.secure');
|
||||
setcookie('session_data',null, time() -3600, $path, $domain, $https, true);
|
||||
return redirect()->to(base_url('login'));
|
||||
}
|
||||
|
||||
@ -1422,11 +1422,12 @@ class MasterController extends AdminController
|
||||
if ($insert) {
|
||||
|
||||
//for CD Tranction Table
|
||||
$cd_tranction_data['cd_ac_pk'] = $this->CDMasterModel->insertID();
|
||||
$response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
|
||||
|
||||
$cd_data = $this->CDMasterModel->where('client_id', $data['client_id'])->where('insurer_id', $data['insurer_id'])->findAll();
|
||||
|
||||
return $this->respond(['status' => true, 'data' => $cd_data, 'cd_ac_no'=>$data['cd_ac_no'], 'message' => 'CD Account number created successfully'], 200);
|
||||
return $this->respond(['status' => true, 'data' => $cd_data, 'cd_ac_no'=>$data['cd_ac_no'], 'message' => 'CD Account number created successfully', "FOR BDS PURPOSE"], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created CD Account number'], 200);
|
||||
}
|
||||
@ -1679,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";
|
||||
@ -1828,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
@ -84,7 +84,7 @@ class RestAuthenticationController extends AdminController
|
||||
->where('employees.emp_status !=', 'truncated')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('EP.is_active', 1)
|
||||
->whereIn('EP.status', ['active'])
|
||||
->whereIn('EP.status', ['active', 'expired'])
|
||||
->first();
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ class RestAuthenticationController extends AdminController
|
||||
->where('employees.emp_status !=', 'truncated')
|
||||
->where('employees.email_corporate', $email)
|
||||
->where('EP.is_active', 1)
|
||||
->whereIn('EP.status', ['draft', 'enrolled'])
|
||||
->whereIn('EP.status', ['active', 'expired'])
|
||||
->first();
|
||||
|
||||
if (isset($employeeData['employee_id'])) {
|
||||
@ -184,6 +184,47 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
public function updateEmpMPIN()
|
||||
{
|
||||
$requestData = $this->request->getJSON();
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
$old_mpin = $requestData->old_mpin ?? null;
|
||||
|
||||
if (!$new_mpin) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
}
|
||||
|
||||
$query = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
if ($mobile_number) {
|
||||
$query->where('mobile', $mobile_number);
|
||||
} elseif ($email_id) {
|
||||
$query->where('email_corporate', $email_id);
|
||||
} else {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$query->where('mpin', $old_mpin);
|
||||
}
|
||||
|
||||
// Fetch employee data
|
||||
$employeeData = $query->first();
|
||||
|
||||
if (!$employeeData) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
}
|
||||
|
||||
// Update MPIN
|
||||
$updated = $this->employeeModel->update($employeeData['id'], ['mpin' => $new_mpin]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getVerifiedUserData()
|
||||
{
|
||||
try {
|
||||
@ -521,15 +562,14 @@ class RestAuthenticationController extends AdminController
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
if ($employeeData && $mpin == $employeeData["mpin"]) {
|
||||
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
@ -547,6 +587,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
|
||||
$result = JWTToken::encode($employeeData);
|
||||
// $result = $employeeData;
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
|
||||
@ -561,7 +602,7 @@ class RestAuthenticationController extends AdminController
|
||||
try {
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
// $mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
@ -585,5 +626,32 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
// TokenController.php
|
||||
public function bookstackLoginToken()
|
||||
{
|
||||
$session = \Config\Services::session();
|
||||
$user_data = session()->get('userData');
|
||||
$user = $user_data->email;
|
||||
$secret = getenv('bookstack.token');
|
||||
// $user = 'staff@staff.com';
|
||||
$name = $user_data->first_name ?? 'User';
|
||||
|
||||
$payload = [
|
||||
'email' => $user,
|
||||
'name' => $name,
|
||||
'exp' => time() + (60 * 60 * 24) // expires in 1 day
|
||||
];
|
||||
|
||||
// dd($payload);
|
||||
$token = base64_encode(json_encode($payload));
|
||||
$signature = hash_hmac('sha256', $token, $secret);
|
||||
$bookStackUrl = getenv('bookstack.baseURL');
|
||||
|
||||
$url = $bookStackUrl . urlencode($token) . '&sig=' . $signature;
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -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();
|
||||
|
||||
@ -120,6 +122,10 @@ class TicketController extends BaseController
|
||||
'((POLICY_TYPE))' => 'policy_type',
|
||||
'((AUTO_QUERY_CONTENT))' => 'auto_query_content',
|
||||
'((CLAIM_FORM_LINK))' => 'claim_form_link',
|
||||
'((CLAIM_FEEDBACK_FORM))' => 'claim_feedback_form',
|
||||
'((SETTLED_LETTER))' => 'settle_letter',
|
||||
'((APPROVED_LETTER))' => 'approved_letter',
|
||||
'((APPROVED_DESCRIBTION))' => 'approved_description',
|
||||
];
|
||||
$this->extraFields = [
|
||||
1 => ['non_id_reason'],
|
||||
@ -129,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'],
|
||||
@ -170,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();
|
||||
@ -178,49 +187,76 @@ 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");
|
||||
log_message('error', 'Is From Dashboard: ' . $isFromDashboard);
|
||||
|
||||
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')
|
||||
// log_message('error', 'Ticket Search Action: ' . $action);
|
||||
$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')
|
||||
@ -232,13 +268,66 @@ class TicketController extends BaseController
|
||||
'tcs.claim_status AS status',
|
||||
'tm.claim_number AS claim_no',
|
||||
'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'
|
||||
'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')
|
||||
@ -247,54 +336,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.emp_name',
|
||||
'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)
|
||||
@ -456,7 +633,18 @@ class TicketController extends BaseController
|
||||
$data['placeHolders'] = $this->placeHolders;
|
||||
$data['message_data'] = $this->getTicketMessage($ticket_id);
|
||||
$data['view_ticket_page'] = [];
|
||||
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
|
||||
|
||||
if($ticket_data['ticket_type_id'] == 1){
|
||||
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
|
||||
}else{
|
||||
$data['member_data'] = array_filter(
|
||||
$this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']),
|
||||
function ($member) {
|
||||
return isset($member['emp_relationship']) && $member['emp_relationship'] == 'Self';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$data['ticket_history'] = $this->ticketHistory($ticket_id);
|
||||
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
|
||||
if (!empty($ticket_data['client_policy_id'])){
|
||||
@ -578,7 +766,9 @@ class TicketController extends BaseController
|
||||
$return_value = $this->ticketMasterModel->insert($ticket_data);
|
||||
if ($return_value) {
|
||||
//mail trigger part
|
||||
$this->putHistoryAfterInsert($ticket_data, $return_value);
|
||||
$mail_responce = $this->sendAutoMailTrigger($return_value);
|
||||
$this->autoMessageInsertBasedOnMailResponse($mail_responce, $return_value);
|
||||
return $this->respond(['status' => true, 'ticket_id' => $return_value, 'code' => 200, 'data' => $ticket_data, "message" => "Claim created successfully", 'mail_responce' => $mail_responce], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to create claim'], 200);
|
||||
@ -601,8 +791,12 @@ class TicketController extends BaseController
|
||||
$return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update();
|
||||
if ($return_value) {
|
||||
|
||||
//mail trigger part
|
||||
$mail_responce = $this->sendAutoMailTrigger($ticket_id);
|
||||
$mail_responce = null;
|
||||
if($old_ticket_data['claim_status_id'] != $ticket_data['claim_status_id']){
|
||||
//mail trigger part
|
||||
$mail_responce = $this->sendAutoMailTrigger($ticket_id);
|
||||
$this->autoMessageInsertBasedOnMailResponse($mail_responce, $ticket_id);
|
||||
}
|
||||
|
||||
//send mail to the head for rejected ticket approvel
|
||||
if($ticket_data['claim_status_id'] == 8 && $ticket_data['is_head_approved'] == 0){
|
||||
@ -751,13 +945,20 @@ class TicketController extends BaseController
|
||||
{
|
||||
// log_message('error','Function called');die();
|
||||
// $ticket_master_id = $this->request->getPost('id');
|
||||
$user_id = get_session_userid();
|
||||
$logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first();
|
||||
$dataToSend = [];
|
||||
$dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name'];
|
||||
$dataToSend['messages'] = $this->ticketMessageModel->where('is_active', 1)
|
||||
->where('ticket_id', $ticket_master_id)->orderBy('created_at', 'DESC')
|
||||
|
||||
$user_id = get_session_userid();
|
||||
// $logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first();
|
||||
// $dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name'];
|
||||
|
||||
$dataToSend['messages'] = $this->ticketMessageModel
|
||||
->select('ticket_messages.*,up.first_name as user_name')
|
||||
->join('user_profiles up', 'up.id = ticket_messages.created_by', 'left')
|
||||
->where('ticket_messages.is_active', 1)
|
||||
->where('ticket_messages.ticket_id', $ticket_master_id)
|
||||
->orderBy('ticket_messages.created_at', 'DESC')
|
||||
->findAll();
|
||||
|
||||
foreach ($dataToSend['messages'] as $message) {
|
||||
$mail_content_converted = $this->convertHtmlToText($message['mail_content']);
|
||||
$message['mail_content'] = $mail_content_converted;
|
||||
@ -775,10 +976,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----------------------------------------------------------------------------------------------
|
||||
@ -838,13 +1056,24 @@ class TicketController extends BaseController
|
||||
|
||||
// Construct Mail Data
|
||||
$mailData = [
|
||||
'mail' => $ticket_data['emp_mail'],
|
||||
'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_mail'], $ticket_data['emp_personal_mail'] ?? ""],
|
||||
// 'subject' => $subject,
|
||||
// 'message' => $message,
|
||||
// 'cc' => $ticket_data['common_mails'] ?? '',
|
||||
// 'attachments' => []
|
||||
// ];
|
||||
// }
|
||||
|
||||
// print_r($mailData); die;
|
||||
|
||||
$this->myLogger->logme('error', "Final Email Data");
|
||||
@ -861,6 +1090,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") {
|
||||
@ -869,6 +1102,12 @@ class TicketController extends BaseController
|
||||
$replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? "");
|
||||
} else if ($value == "claim_form_link"){
|
||||
$replaceData = '<a href="' . base_url('claim-form-download/' . md5($ticket_data['insurer_id'])) . '" target="_blank">Click here to download Claim Form</a>';
|
||||
} else if ($value == "claim_feedback_form" && $ticket_data['ticket_type_id'] == 1){
|
||||
$replaceData = '<a href="' . base_url('claims-feedback-form/' . md5($ticket_data['id'])) . '" target="_blank">Click to open Claim Feedback Form</a>';
|
||||
} else if ($value == "settle_letter"){
|
||||
$replaceData = '<a href="' . $ticket_data['settle_letter'] . '" target="_blank"> View Settlement Letter </a>';
|
||||
}else if ($value == "approved_letter"){
|
||||
$replaceData = '<a href="' . $ticket_data['approved_letter'] . '" target="_blank"> View Approved Letter </a>';
|
||||
}else {
|
||||
$replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : '';
|
||||
}
|
||||
@ -927,8 +1166,29 @@ class TicketController extends BaseController
|
||||
|
||||
$this->myLogger->logme('error', "Fetched ACM emails");
|
||||
|
||||
|
||||
// if(!empty($ticket_data['emp_personal_mail'])){
|
||||
|
||||
// $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' => []
|
||||
// ];
|
||||
|
||||
// $this->sendTrigger($emailPersonalData);
|
||||
|
||||
// $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' => [],
|
||||
@ -950,7 +1210,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;
|
||||
$mail_responce = $this->sendTrigger($mail_content);
|
||||
// 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 {
|
||||
@ -972,7 +1236,7 @@ class TicketController extends BaseController
|
||||
th.old_value,
|
||||
th.new_value,
|
||||
th.created_at,
|
||||
CONCAT(creator.first_name, ' ', creator.last_name) as modified_by,
|
||||
CONCAT_WS(' ', creator.first_name, creator.last_name) AS modified_by,
|
||||
-- Claim Status
|
||||
old_status.claim_status as old_status_value,
|
||||
new_status.claim_status as new_status_value,
|
||||
@ -1032,6 +1296,7 @@ class TicketController extends BaseController
|
||||
ORDER BY
|
||||
th.created_at DESC";
|
||||
$data = $this->ticketHistoryModel->query($sql)->getResultArray();
|
||||
// dd(db_connect()->getLastQuery());
|
||||
$priorityType = $this->priorityType;
|
||||
$relationshipType = $this->relationshipType;
|
||||
$modeOFIntimate = $this->modeOFIntimate;
|
||||
@ -1162,11 +1427,12 @@ 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',
|
||||
'UNDER PROCESS - CLAIM NO. UPDATION', 'UNDER PROCESS - INVESTIGATION STATUS',
|
||||
'UNDER PROCESS - CLAIM NO. UPDATION',
|
||||
'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED',
|
||||
'TOTAL'
|
||||
];
|
||||
@ -1180,12 +1446,13 @@ 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{
|
||||
$viewData['column_order'] = [
|
||||
'ACM_NAME', 'CLAIM INTIMATION', 'INTIMATION TO INSURER', 'CLIENT PENDING',
|
||||
'INSURER PENDING','INVESTIGATION','APPROVED','ON HOLD','TOTAL', 'NOT COVERED',
|
||||
'INSURER PENDING','INVESTIGATION','APPROVED','TOTAL', 'NOT COVERED',
|
||||
'CLOSED', 'SETTLED', 'CLEARED_TOTAL'
|
||||
];
|
||||
$ordered_data = [];
|
||||
@ -1198,6 +1465,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);
|
||||
}
|
||||
@ -1207,9 +1475,9 @@ class TicketController extends BaseController
|
||||
|
||||
$viewData['column_order'] = [
|
||||
'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED',
|
||||
'UNDER PROCESS - CLAIM NO. UPDATION', 'UNDER PROCESS - INVESTIGATION STATUS',
|
||||
'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
|
||||
@ -1223,6 +1491,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);
|
||||
@ -1230,6 +1499,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);
|
||||
}
|
||||
@ -1304,14 +1576,21 @@ class TicketController extends BaseController
|
||||
$statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate']);
|
||||
|
||||
foreach ($statusMapping as $status => $requiredFields) {
|
||||
|
||||
// Ensure requiredFields is an array
|
||||
if (!is_array($requiredFields)) {
|
||||
$requiredFields = [$requiredFields];
|
||||
|
||||
}
|
||||
|
||||
// Check if all required fields exist and are not empty in the incoming form values
|
||||
$allFieldsMatched = true;
|
||||
foreach ($requiredFields as $field) {
|
||||
|
||||
if(in_array($field, ['approved_description'])){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) {
|
||||
$allFieldsMatched = false;
|
||||
break;
|
||||
@ -1371,7 +1650,8 @@ class TicketController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function getPoliciesbyEmpID() {
|
||||
public function getPoliciesbyEmpID()
|
||||
{
|
||||
$received_data = $this->request->getPost();
|
||||
$emp_id = $received_data['emp_id'];
|
||||
|
||||
@ -1379,6 +1659,8 @@ class TicketController extends BaseController
|
||||
$policies = $this->employeePolicyModel
|
||||
->select('client_policy_id')
|
||||
->where('employee_id', $emp_id)
|
||||
->where('is_active', 1)
|
||||
->where('status', 'active')
|
||||
->findAll();
|
||||
|
||||
if (empty($policies)) {
|
||||
@ -1390,8 +1672,20 @@ class TicketController extends BaseController
|
||||
|
||||
// Fetch all policy names and IDs in one query
|
||||
$policyNameandID = $this->clientPolicyModel
|
||||
->select('CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name, client_policy.id as client_policy_value,client_policy.policy_type_id,client_policy.policy_no')
|
||||
->select('
|
||||
CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name,
|
||||
client_policy.id as client_policy_value,
|
||||
client_policy.policy_type_id,
|
||||
client_policy.policy_no,
|
||||
insurers.id as insurer_id,
|
||||
insurers.name as insurer_name,
|
||||
tpa.name as tpa_name,
|
||||
tpa.id as tpa_id,
|
||||
')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id AND insurers.is_active = 1', 'left')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id AND tpa.is_active = 1', 'left')
|
||||
->where('client_policy.policy_status', 1)
|
||||
->whereIn('client_policy.id', $policy_ids)
|
||||
->findAll();
|
||||
|
||||
@ -1443,5 +1737,202 @@ class TicketController extends BaseController
|
||||
return $this->response->setStatusCode(500)->setBody('An error occurred while downloading the file.');
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function autoMessageInsertBasedOnMailResponse($mail_sent_status, $ticket_id)
|
||||
{
|
||||
if (gettype($mail_sent_status) == 'array') {
|
||||
$this->myLogger->logme('error', "auto Message Insert Based On Mail Response Failed because is array :$ticket_id ");
|
||||
} else {
|
||||
$mail_sent_status = json_decode($mail_sent_status);
|
||||
$this->myLogger->logme('error', "mail_sent_status is object :$ticket_id ");
|
||||
}
|
||||
|
||||
if (!empty($mail_sent_status) && isset($mail_sent_status->status) && $mail_sent_status->status == 'success') {
|
||||
|
||||
$sent_message_data['ticket_id'] = $ticket_id;
|
||||
$sent_message_data['sender'] = 'staff';
|
||||
$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;
|
||||
|
||||
$message_insert_status = $this->ticketMessageModel->insert($sent_message_data);
|
||||
|
||||
if ($message_insert_status) {
|
||||
$this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, successfully store message:$ticket_id ");
|
||||
} else {
|
||||
$this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id ");
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', "Failed to send Mail :$ticket_id ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function putHistoryAfterInsert($ticket_data, $ticket_id)
|
||||
{
|
||||
$this->myLogger->logme('error', "Put History After Insert function called : $ticket_id");
|
||||
|
||||
if(!empty($ticket_data)){
|
||||
|
||||
$history_data = [
|
||||
'ticket_id' => $ticket_id,
|
||||
'field_name' => 'claim_status_id',
|
||||
'display_name' => 'Ticket Created',
|
||||
'old_value' => null,
|
||||
'new_value' => $ticket_data['claim_status_id'],
|
||||
'created_by' => get_session_userid(),
|
||||
'is_active' => 1
|
||||
];
|
||||
|
||||
$this->myLogger->logme('error', "Put History After Insert function called : " . json_encode($history_data));
|
||||
|
||||
|
||||
$history_insert = $this->ticketHistoryModel->insert($history_data);
|
||||
|
||||
if($history_insert){
|
||||
$this->myLogger->logme('error', "Put History After Insert Ticket Data Successfully");
|
||||
}else{
|
||||
$this->myLogger->logme('error', "Put History After Insert Ticket Data Failed");
|
||||
}
|
||||
|
||||
}else{
|
||||
$this->myLogger->logme('error', "Put History After Insert Ticket Data is empty");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function viewClaimFeedbackForm($md5_ticket_id,$empView = null)
|
||||
{
|
||||
|
||||
if ($this->request->is("get")){
|
||||
|
||||
$data['ticket_id'] = $md5_ticket_id;
|
||||
$data['ticket_data'] = $this->ticketMasterModel->select('ticket_master.*,clients.client_name')->join('clients','clients.id = ticket_master.client_id')->where('MD5(ticket_master.id)',$md5_ticket_id)->where('ticket_master.is_active',1)->first();
|
||||
$data['form_submitted'] = !empty($data['ticket_data']['feedback_json'])? 1 : 0;
|
||||
|
||||
|
||||
$data['viewer'] = !empty($empView) ? $empView : 0;
|
||||
// dd($data);
|
||||
return view('ticket_feedback_form', $data);
|
||||
}else{
|
||||
|
||||
$formDataJson = json_encode($this->request->getPost());
|
||||
// log_message("error","Form data : ".$formDataJson);
|
||||
|
||||
|
||||
$data_to_store = [
|
||||
|
||||
'feedback_json' => $formDataJson
|
||||
];
|
||||
|
||||
if (!empty($formDataJson)){
|
||||
// $this->ticketMasterModel->save($data_to_store);
|
||||
$this->ticketMasterModel->where('MD5(id)', $md5_ticket_id)->set($data_to_store)->update();
|
||||
|
||||
return $this->respond(['status' => true,'id'=> $md5_ticket_id,'received_data' => $formDataJson], 200);
|
||||
|
||||
}else{
|
||||
return $this->respond(['status' => false,'id'=> $md5_ticket_id,'received_data' => $formDataJson], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function feedbackList(){
|
||||
|
||||
$data['feedback_data'] = $this->ticketMasterModel->select("ticket_master.*,clients.client_name")->join("clients","clients.id = ticket_master.client_id")->where("ticket_master.is_active",1)->where("ticket_master.feedback_json IS NOT NULL", null, false)->where("ticket_master.feedback_json !=", "")->findAll();
|
||||
|
||||
// dd($data);
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ use App\Models\UserModel;
|
||||
use App\Models\RoleModel;
|
||||
use App\Models\TeamModel;
|
||||
use App\Models\UserTeamsModel;
|
||||
use App\Helpers\BookStackUserHelper;
|
||||
|
||||
|
||||
class UserController extends AdminController
|
||||
@ -21,6 +22,7 @@ class UserController extends AdminController
|
||||
protected $roleModel;
|
||||
protected $teamModel;
|
||||
protected $userTeamsModel;
|
||||
protected $bookStack;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -31,6 +33,7 @@ class UserController extends AdminController
|
||||
$this->roleModel = new RoleModel();
|
||||
$this->teamModel = new TeamModel();
|
||||
$this->userTeamsModel = new UserTeamsModel();
|
||||
$this->bookStack = new BookStackUserHelper();
|
||||
}
|
||||
|
||||
public function list()
|
||||
@ -60,10 +63,17 @@ class UserController extends AdminController
|
||||
$userData['created_by'] = get_session_userid();
|
||||
$temp_team = $userData['team'];
|
||||
unset($userData['team']);
|
||||
|
||||
$insert = $this->userModel->insert($userData);
|
||||
|
||||
if ($insert) {
|
||||
$bookStackData = [
|
||||
'name' => $userData['first_name'],
|
||||
'email' => $userData['email'],
|
||||
|
||||
];
|
||||
$this->bookStack->createEditUser($bookStackData);
|
||||
|
||||
if ($insert) {
|
||||
$teamData['user_id'] = $insert;
|
||||
foreach ($teams as $value) {
|
||||
$teamData['team_id'] = $value;
|
||||
@ -137,10 +147,20 @@ class UserController extends AdminController
|
||||
unset($userData['csrf_test_name']);
|
||||
unset($userData['PrimaryKey']);
|
||||
|
||||
$existingData = $this->userModel->where('id',$id)->first();;
|
||||
|
||||
// Update data in the 'users' table based on the $id
|
||||
$userData['updated_by'] = get_session_userid();
|
||||
$update = $this->userModel->where('id', $id)->set($userData)->update();
|
||||
|
||||
$bookStackData = [
|
||||
'name' => $userData['first_name'],
|
||||
'email' => $userData['email'],
|
||||
];
|
||||
|
||||
$this->bookStack->createEditUser($bookStackData,$existingData);
|
||||
|
||||
|
||||
if ($update) {
|
||||
|
||||
if ($teams) {
|
||||
@ -211,7 +231,11 @@ class UserController extends AdminController
|
||||
public function deactive($id = null)
|
||||
{
|
||||
$model = new UserModel();
|
||||
|
||||
$emailToDelete = $model->where('id', $id)->first();
|
||||
$deactive = $model->where('id', $id)->set(['is_active' => 0])->update();
|
||||
|
||||
$this->bookStack->deleteUser($emailToDelete);
|
||||
if($deactive)
|
||||
{
|
||||
// $db = \Config\Database::connect();
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
77
app/Helpers/BookStackUserHelper.php
Normal file
77
app/Helpers/BookStackUserHelper.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\BookStackUserModel;
|
||||
use App\Models\BookStackRoleModel;
|
||||
|
||||
class BookStackUserHelper {
|
||||
|
||||
protected $userModel;
|
||||
protected $roleModel;
|
||||
|
||||
public function __construct() {
|
||||
$this->userModel = new BookStackUserModel();
|
||||
$this->roleModel = new BookStackRoleModel();
|
||||
}
|
||||
|
||||
public function createEditUser($data,$preData = null) {
|
||||
// This function will handle the creation or editing of a user
|
||||
// It will check if the user already exists and update or create accordingly
|
||||
// The $data parameter should contain all necessary user information
|
||||
// For example: ['name' => 'johndoe', 'email' => 'johndoe@doe.com']
|
||||
|
||||
if (!empty($preData)) {
|
||||
|
||||
$isExistingUser = $this->userModel->where('email', $preData['email'])->first();
|
||||
|
||||
if ($isExistingUser) {
|
||||
$id = $isExistingUser['id'];
|
||||
$update = $this->userModel->where('id', $id)->set($data)->update();
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
|
||||
$password = 'password';
|
||||
$hashedPassword = ['password' => password_hash($password, PASSWORD_DEFAULT)];
|
||||
|
||||
$slug = ['slug' => $this->createSlug($data['name'])];
|
||||
|
||||
// array_push($data,$hashedPassword,$slug);
|
||||
|
||||
$data['password'] = $hashedPassword['password'];
|
||||
$data['slug'] = $slug['slug'];
|
||||
|
||||
// dd($data);
|
||||
$this->userModel->insert($data);
|
||||
$userId = $this->userModel->insertID();
|
||||
|
||||
if (!empty($userId)) {
|
||||
|
||||
$roleData = [
|
||||
'user_id' => $userId,
|
||||
'role_id' => 3 // 3 is the default role ID for viewers
|
||||
];
|
||||
|
||||
$this->roleModel->insert($roleData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function createSlug($string) {
|
||||
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
|
||||
}
|
||||
|
||||
public function deleteUser($data) {
|
||||
|
||||
$isExistingUser = $this->userModel->where('email', $data['email'])->first();
|
||||
if ($isExistingUser) {
|
||||
$id = $isExistingUser['id'];
|
||||
$delete = $this->userModel->where('id', $id)->delete();
|
||||
$this->roleModel->where('user_id', $id)->delete();
|
||||
return $delete;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -32,8 +32,11 @@ class DepositHelper
|
||||
*/
|
||||
public static function saveDeposit(array $data, int $loggedInUserID): array
|
||||
{
|
||||
|
||||
log_message("error", 'saveDeposit function called '. json_encode($data));
|
||||
|
||||
// Retrieve the last known balance
|
||||
$lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id'], $data['cd_ac_no']);
|
||||
$lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id'], $data['cd_ac_no'], $data['cd_ac_pk'] ?? null);
|
||||
|
||||
// Calculate the new balance based on the transaction type
|
||||
$newBalance = self::calculateBalance(
|
||||
@ -91,15 +94,21 @@ class DepositHelper
|
||||
*
|
||||
* @return float The last known balance.
|
||||
*/
|
||||
public static function calculateLastBalance(int $clientId, int $insurerId, $cd_ac_no): float
|
||||
public static function calculateLastBalance(int $clientId, int $insurerId, $cd_ac_no, $cd_ac_pk): float
|
||||
{
|
||||
$model = new ClientDepositModel();
|
||||
|
||||
// $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
|
||||
// $getLastBalanceParams = [$clientId, $insurerId];
|
||||
|
||||
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
|
||||
$getLastBalanceParams = [$cd_ac_no];
|
||||
if(empty($cd_ac_pk)){
|
||||
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? AND is_active = 1 ORDER BY id DESC LIMIT 1";
|
||||
$getLastBalanceParams = [$cd_ac_no];
|
||||
}else{
|
||||
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_pk = ? AND is_active = 1 ORDER BY id DESC LIMIT 1";
|
||||
$getLastBalanceParams = [$cd_ac_pk];
|
||||
}
|
||||
|
||||
|
||||
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? 0;
|
||||
|
||||
|
||||
@ -17,10 +17,13 @@ class ExcelMergeHelper {
|
||||
{
|
||||
try {
|
||||
log_message('debug', 'Attempting merge with original file order');
|
||||
// echo "Attempting merge with original file order\n";
|
||||
return self::processFiles($filePaths, $outputPath);
|
||||
} catch (Exception $e) {
|
||||
log_message('error', 'First attempt failed: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
// echo "First attempt failed: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
|
||||
log_message('debug', 'Retrying with reversed file order');
|
||||
// echo "Retrying with reversed file order\n";
|
||||
|
||||
// Reverse the file order and try again
|
||||
$reversedFiles = array_reverse($filePaths);
|
||||
@ -29,6 +32,7 @@ class ExcelMergeHelper {
|
||||
return self::processFiles($reversedFiles, $outputPath);
|
||||
} catch (Exception $e2) {
|
||||
log_message('error', 'Both attempts failed. Last error: ' . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine());
|
||||
// echo "Both attempts failed. Last error: " . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine() . "\n";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -45,7 +49,9 @@ class ExcelMergeHelper {
|
||||
private static function processFiles(array $filePaths, string $outputPath): string
|
||||
{
|
||||
log_message('debug', 'Starting Excel merge process');
|
||||
// echo "Starting Excel merge process\n";
|
||||
log_message('debug', 'Files to process: ' . json_encode($filePaths));
|
||||
// echo "Files to process: " . json_encode($filePaths) . "\n";
|
||||
|
||||
if (empty($filePaths)) {
|
||||
throw new Exception("No files provided to merge");
|
||||
@ -66,6 +72,7 @@ class ExcelMergeHelper {
|
||||
|
||||
// Save the merged file
|
||||
log_message('debug', "Saving merged file to: {$outputPath}");
|
||||
// echo "Saving merged file to: {$outputPath}\n";
|
||||
$writer = IOFactory::createWriter($mergedSpreadsheet, 'Xlsx');
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
$writer->save($outputPath);
|
||||
@ -76,6 +83,7 @@ class ExcelMergeHelper {
|
||||
gc_collect_cycles();
|
||||
|
||||
log_message('debug', 'Excel merge process completed successfully');
|
||||
// echo "Excel merge process completed successfully\n";
|
||||
return $outputPath;
|
||||
}
|
||||
|
||||
@ -87,15 +95,17 @@ class ExcelMergeHelper {
|
||||
* @param int|null $index
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, int $index = null)
|
||||
private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, ?int $index = null)
|
||||
{
|
||||
if (!isset($fileInfo['file_path']) || !file_exists($fileInfo['file_path'])) {
|
||||
$path = $fileInfo['file_path'] ?? 'undefined';
|
||||
log_message('error', "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}");
|
||||
// echo "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
log_message('debug', "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path']);
|
||||
// echo "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path'] . "\n";
|
||||
|
||||
try {
|
||||
// Load the source spreadsheet
|
||||
@ -105,6 +115,7 @@ class ExcelMergeHelper {
|
||||
$worksheets = $sourceSpreadsheet->getAllSheets();
|
||||
$totalSheets = count($worksheets);
|
||||
log_message('debug', "Total sheets in file: " . $totalSheets);
|
||||
// echo "Total sheets in file: " . $totalSheets . "\n";
|
||||
|
||||
$sheetsToMerge = $fileInfo['sheets'] ?? [];
|
||||
|
||||
@ -114,26 +125,36 @@ class ExcelMergeHelper {
|
||||
try {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
log_message('debug', "Processing sheet: {$sheetName}");
|
||||
// echo "Processing sheet: {$sheetName}\n";
|
||||
|
||||
// Generate unique sheet name before cloning
|
||||
$newName = $sheetName;
|
||||
$counter = 1;
|
||||
|
||||
while (in_array($newName, $mergedSpreadsheet->getSheetNames())) {
|
||||
$newName = $sheetName . "_" . $counter++;
|
||||
log_message('debug', "Sheet name already exists. Trying new name: {$newName}");
|
||||
// while (in_array($newName, $mergedSpreadsheet->getSheetNames())) {
|
||||
// // $newName = $sheetName . "_" . $counter++;
|
||||
// log_message('debug', "Sheet name already exists. Trying new name: {$newName}");
|
||||
// // echo "Sheet name already exists. Trying new name: {$newName}\n";
|
||||
// }
|
||||
|
||||
if (in_array($newName, $mergedSpreadsheet->getSheetNames())) {
|
||||
$newName = $sheetName . '_' . $counter++;
|
||||
$worksheet->setTitle($newName);
|
||||
|
||||
}
|
||||
|
||||
// Clone the worksheet and set the new name
|
||||
$clonedSheet = clone $worksheet;
|
||||
$clonedSheet->setTitle($newName);
|
||||
// $clonedSheet = clone $worksheet;
|
||||
// $clonedSheet->setTitle($newName);
|
||||
|
||||
// Add as external sheet
|
||||
$mergedSpreadsheet->addExternalSheet($clonedSheet);
|
||||
$mergedSpreadsheet->addExternalSheet($worksheet);
|
||||
|
||||
log_message('debug', "Successfully added sheet: {$newName}");
|
||||
// echo "Successfully added sheet: {$newName}\n";
|
||||
} catch (Exception $e) {
|
||||
log_message('error', "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
// echo "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,6 +166,7 @@ class ExcelMergeHelper {
|
||||
|
||||
} catch (Exception $e) {
|
||||
log_message('error', "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
// echo "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@ class ExcelSanitizeHelper
|
||||
$cleanData[$key] = self::sanitizeArrayData($value); // Recursive call for nested arrays
|
||||
} elseif (is_string($value)) {
|
||||
// Remove non-printable characters and trim whitespace from strings
|
||||
$value = str_replace("\u00a0", " ", $value);
|
||||
$cleanData[$key] = trim(preg_replace(self::$nonPrintablePattern, '', $value));
|
||||
} else {
|
||||
$cleanData[$key] = $value; // Keep non-string/non-array data as is
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -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 "";
|
||||
@ -665,3 +665,123 @@ if (!function_exists('check_pay_by_employee_or_company')) {
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('is_json_string')) {
|
||||
function is_json_string($string)
|
||||
{
|
||||
if (!is_string($string)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$decoded = json_decode($string, true);
|
||||
return (json_last_error() === JSON_ERROR_NONE && is_array($decoded));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('check_cd_entry_exist')) {
|
||||
function check_cd_entry_exist($params)
|
||||
{
|
||||
$db = db_connect();
|
||||
|
||||
$client_id = $params['client_id'];
|
||||
$client_policy_id = $params['client_policy_id'];
|
||||
$insurer_id = $params['insurer_id'];
|
||||
$cd_ac_pk = $params['cd_ac_pk'];
|
||||
$event_name = $params['event_name'];
|
||||
|
||||
// Check if truncated entry (sub_type = 8) exists
|
||||
$has_truncated = $db->table('cash_deposit')
|
||||
->where('client_id', $client_id)
|
||||
->where('insurer_id', $insurer_id)
|
||||
->where('cd_ac_pk', $cd_ac_pk)
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('event_name', $event_name)
|
||||
->where('sub_type', 8)
|
||||
->where('is_active', 1)
|
||||
->countAllResults();
|
||||
|
||||
if ($has_truncated) {
|
||||
|
||||
echo "has_truncated";
|
||||
// Get all entries with same details (including truncated)
|
||||
$entries = $db->table('cash_deposit')
|
||||
->where('client_id', $client_id)
|
||||
->where('insurer_id', $insurer_id)
|
||||
->where('cd_ac_pk', $cd_ac_pk)
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('event_name', $event_name)
|
||||
->where('is_active', 1)
|
||||
->where('sub_type !=', 8)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
if (count($entries) > 1) {
|
||||
// Only one entry found (truncated)
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Check if any other entry exists
|
||||
$entry = $db->table('cash_deposit')
|
||||
->where('client_id', $client_id)
|
||||
->where('insurer_id', $insurer_id)
|
||||
->where('cd_ac_pk', $cd_ac_pk)
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('event_name', $event_name)
|
||||
->where('is_active', 1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!empty($entry)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('expected_amount_calc')) {
|
||||
function expected_amount_calc($data, $index)
|
||||
{
|
||||
$agreed_amount = (float) ($data['agreed_amount'][$index] ?? 0);
|
||||
$agreed_bp_per = (float) ($data['agreed_bp'][$index] ?? 0);
|
||||
$agreed_tp_per = (float) ($data['agreed_tp'][$index] ?? 0);
|
||||
$agreed_tep_per = (float) ($data['agreed_ter'][$index] ?? 0);
|
||||
|
||||
$standard_bp_per = (float) ($data['standard_bp'][$index] ?? 0);
|
||||
$standard_tp_per = (float) ($data['standard_tp'][$index] ?? 0);
|
||||
$standard_tep_per = (float) ($data['standard_ter'][$index] ?? 0);
|
||||
|
||||
|
||||
if($data['bro_payable_by'] == 0){
|
||||
$base_premium = (float) ($data['co_premium'][$index] ?? 0);
|
||||
$third_part_premium = (float) ($data['co_tp_premium'][$index] ?? 0);
|
||||
$terrisom_premium = (float) ($data['co_ter_premium'][$index] ?? 0);
|
||||
}else{
|
||||
$base_premium = (float) ($data['base_premium'][$index] ?? 0);
|
||||
$third_part_premium = (float) ($data['tp_premium'][$index] ?? 0);
|
||||
$terrisom_premium = (float) ($data['ter_premium'][$index] ?? 0);
|
||||
}
|
||||
|
||||
$sum_of_agreed_premium = $agreed_bp_per + $agreed_tp_per + $agreed_tep_per;
|
||||
|
||||
$expectedAmount = 0;
|
||||
|
||||
if ($agreed_amount > 0) {
|
||||
$expectedAmount = $agreed_amount;
|
||||
} elseif ($sum_of_agreed_premium > 0) {
|
||||
$expectedAmount =
|
||||
($base_premium * $agreed_bp_per / 100) +
|
||||
($third_part_premium * $agreed_tp_per / 100) +
|
||||
($terrisom_premium * $agreed_tep_per / 100);
|
||||
} else {
|
||||
$expectedAmount =
|
||||
($base_premium * $standard_bp_per / 100) +
|
||||
($third_part_premium * $standard_tp_per / 100) +
|
||||
($terrisom_premium * $standard_tep_per / 100);
|
||||
}
|
||||
|
||||
return round($expectedAmount, 2); // Optional: round to 2 decimal places
|
||||
}
|
||||
}
|
||||
|
||||
126
app/Models/BdsPlacementModel.php
Normal file
126
app/Models/BdsPlacementModel.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?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'
|
||||
];
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
19
app/Models/BookStackRoleModel.php
Normal file
19
app/Models/BookStackRoleModel.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class BookStackRoleModel extends Model
|
||||
{
|
||||
protected $DBGroup = 'book_stack';
|
||||
protected $table = 'role_user';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDelete = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'user_id','role_id'
|
||||
];
|
||||
|
||||
}
|
||||
19
app/Models/BookStackUserModel.php
Normal file
19
app/Models/BookStackUserModel.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class BookStackUserModel extends Model
|
||||
{
|
||||
protected $DBGroup = 'book_stack';
|
||||
protected $table = 'users';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDelete = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'name','email','password','slug'
|
||||
];
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -53,17 +53,19 @@ class ClientModel extends Model
|
||||
|
||||
$columns = ['clients.id ', 'client_name','short_name'];
|
||||
$clients = $this->select($columns)
|
||||
->where('is_active',1)
|
||||
->where('clients.is_active',1)
|
||||
->findAll();
|
||||
|
||||
// if($role_id == 2 || $role_id == 3){
|
||||
if($role_id == 2 || $role_id == 3){
|
||||
|
||||
// $clients = $this->select($columns)
|
||||
// ->join('client_rm', 'client_rm.client_id = clients.id')
|
||||
// ->where('client_rm.user_id', $user_id)
|
||||
// ->where('clients.is_active',1)
|
||||
// ->findAll();
|
||||
// }
|
||||
$clients = $this->select($columns)
|
||||
->join('client_rm', 'client_rm.client_id = clients.id')
|
||||
->where('client_rm.user_id', $user_id)
|
||||
->where('clients.is_active',1)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
// $clients->findAll();
|
||||
|
||||
|
||||
|
||||
@ -107,11 +109,24 @@ class ClientModel extends Model
|
||||
|
||||
public function getCreatedByUserName(){
|
||||
|
||||
return $this->db->table('clients')
|
||||
$role_id = get_role_id();
|
||||
$user_id = get_session_userid();
|
||||
|
||||
$query = $this->db->table('clients')
|
||||
->select('clients.*')
|
||||
->where('is_active', 1)
|
||||
->get()
|
||||
->getResult();
|
||||
->join('client_rm', 'client_rm.client_id = clients.id','left')
|
||||
->where('clients.is_active', 1);
|
||||
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
$query->where('client_rm.user_id', $user_id);
|
||||
}
|
||||
|
||||
$data = $query->groupBy("clients.id")->get()->getResult();
|
||||
// dd($data);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ class ClientPolicyModel extends Model
|
||||
"is_member_modify_allowed",
|
||||
"cd_ac_pk",
|
||||
"is_lgbtq",
|
||||
"placement_json",
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
@ -70,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();
|
||||
}
|
||||
@ -81,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();
|
||||
}
|
||||
@ -89,100 +90,102 @@ 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')
|
||||
->where('cd_master.is_active', 1)
|
||||
->groupBy('client_policy.client_id', $id) // Group by insurer_id
|
||||
->groupBy('client_policy.insurer_id')
|
||||
->groupBy('client_policy.cd_ac_pk')
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
// return $this->db->table('client_policy')
|
||||
// ->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
@ -197,34 +200,36 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
public function getDepositData($clientId, $insurerId)
|
||||
public function getDepositData($clientId, $insurerId, $cd_ac_pk = null)
|
||||
{
|
||||
// Fetch the deposit data based on client and insurer IDs
|
||||
return $this->db->table('cash_deposit')
|
||||
// Fetch the deposit data based on client and insurer IDs
|
||||
$query = $this->db->table('cash_deposit')
|
||||
->select('cash_deposit.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as clientname, clients.short_name as clientshort, client_policy.policy_no')
|
||||
@ -241,184 +246,193 @@ class ClientPolicyModel extends Model
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
|
||||
->where('cash_deposit.client_id', $clientId)
|
||||
->where('cash_deposit.insurer_id', $insurerId)
|
||||
->where('cash_deposit.is_active', 1)
|
||||
->where('cash_deposit.is_active', 1);
|
||||
// ->where('cash_deposit.cd_ac_pk = cd_master.id')
|
||||
->orderBy('cash_deposit.id', 'DESC')
|
||||
if(!empty($cd_ac_pk)){
|
||||
$query->where('cash_deposit.cd_ac_pk', $cd_ac_pk);
|
||||
}
|
||||
$query->orderBy('cash_deposit.id', 'DESC');
|
||||
|
||||
return $query->get()->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getDepositSummary($clientId, $insurerId, $cd_ac_pk)
|
||||
{
|
||||
// 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('cd_ac_pk', $cd_ac_pk)
|
||||
->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');
|
||||
|
||||
// $depositData = $builder->get()->getResult();
|
||||
|
||||
// $currentBalance = 0;
|
||||
|
||||
// foreach ($depositData as $transaction) {
|
||||
// if ($transaction->transaction_type == 'Credit') {
|
||||
// $currentBalance += $transaction->amount;
|
||||
// } elseif ($transaction->transaction_type == 'Debit') {
|
||||
// $currentBalance -= $transaction->amount;
|
||||
// }
|
||||
|
||||
// $transaction->balance = $currentBalance;
|
||||
// }
|
||||
|
||||
// return $depositData;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function getBalances($clientId)
|
||||
{
|
||||
$depositsummary = $this->getDepositlistsummary($clientId);
|
||||
$balances = [];
|
||||
|
||||
foreach ($depositsummary as $summary) {
|
||||
$insurerId = $summary->insurer_id;
|
||||
$balances[$insurerId] = $summary;
|
||||
}
|
||||
|
||||
return $balances;
|
||||
}
|
||||
|
||||
public function getDepositlistsummary($id)
|
||||
{
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('insurer_id, cd_ac_pk')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->where('client_id', $id)
|
||||
->where('is_active', 1)
|
||||
->groupBy('insurer_id')
|
||||
// ->groupBy('cd_ac_pk')
|
||||
->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');
|
||||
|
||||
// $builder->where('client_id', $clientId);
|
||||
// $builder->where('insurer_id', $insurerId);
|
||||
// $builder->orderBy('created_at', 'asc');
|
||||
|
||||
// $depositData = $builder->get()->getResult();
|
||||
|
||||
// $currentBalance = 0;
|
||||
|
||||
// foreach ($depositData as $transaction) {
|
||||
// if ($transaction->transaction_type == 'Credit') {
|
||||
// $currentBalance += $transaction->amount;
|
||||
// } elseif ($transaction->transaction_type == 'Debit') {
|
||||
// $currentBalance -= $transaction->amount;
|
||||
// }
|
||||
|
||||
// $transaction->balance = $currentBalance;
|
||||
// }
|
||||
|
||||
// return $depositData;
|
||||
// }
|
||||
|
||||
|
||||
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();
|
||||
|
||||
public function getBalances($clientId)
|
||||
{
|
||||
$depositsummary = $this->getDepositlistsummary($clientId);
|
||||
$balances = [];
|
||||
// Log the result
|
||||
log_message('info', "Client policies updated: {$client_count}");
|
||||
log_message('info', "Employee policies updated: {$emp_count}");
|
||||
|
||||
foreach ($depositsummary as $summary) {
|
||||
$insurerId = $summary->insurer_id;
|
||||
$balances[$insurerId] = $summary;
|
||||
return ['client' => $client_count, 'emp' => $emp_count];
|
||||
}
|
||||
|
||||
return $balances;
|
||||
}
|
||||
public function getpolicyWithPattern($client_id)
|
||||
{
|
||||
|
||||
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();
|
||||
}
|
||||
$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();
|
||||
|
||||
|
||||
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();
|
||||
|
||||
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 getTopUpPolicy($client_id, $type){
|
||||
|
||||
$query = "
|
||||
SELECT client_policy.*, policies.name, policies.policy_type_id
|
||||
FROM client_policy
|
||||
JOIN policies ON policies.id = client_policy.policy_id
|
||||
JOIN policy_type ON policy_type.id = policies.policy_type_id
|
||||
WHERE policy_type.policy_type = '{$type}'
|
||||
AND client_policy.client_id = {$client_id}";
|
||||
|
||||
$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 $query;
|
||||
}
|
||||
|
||||
$result = $query->get()->getResult();
|
||||
public function getTopUpPolicy($client_id, $type)
|
||||
{
|
||||
|
||||
return $result;
|
||||
$query = "
|
||||
SELECT client_policy.*, policies.name, policies.policy_type_id
|
||||
FROM client_policy
|
||||
JOIN policies ON policies.id = client_policy.policy_id
|
||||
JOIN policy_type ON policy_type.id = policies.policy_type_id
|
||||
WHERE policy_type.policy_type = '{$type}'
|
||||
AND client_policy.client_id = {$client_id}";
|
||||
|
||||
$result = $this->db->query($query)->getResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function getClientPolicyByPolicyType($client_id, $type)
|
||||
{
|
||||
|
||||
|
||||
public function getPolicyTypeForPolicyBinding($client_id){
|
||||
$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);
|
||||
|
||||
$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();
|
||||
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 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();
|
||||
|
||||
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')
|
||||
@ -426,49 +440,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;
|
||||
}
|
||||
|
||||
|
||||
@ -81,6 +81,146 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "")
|
||||
// {
|
||||
// // dd($status);
|
||||
|
||||
// $result = $this->select([
|
||||
// 'employee_polices.*',
|
||||
// 'policy_type.policy_type as policy_name',
|
||||
// 'im.short_name as insurer_short_name',
|
||||
// 'ib.branch_name as insurer_branch_name',
|
||||
// 'ib.branch_code as insurer_branch_code',
|
||||
// 'tpam.name as tpa_name',
|
||||
// 'tpam.short_name as tpa_short_name',
|
||||
// 'tpab.branch_code as tpa_branch_code',
|
||||
// 'cm.client_name',
|
||||
// 'cm.short_name as client_short_name',
|
||||
// // 'emp.id as employee_primary_id',
|
||||
// 'emp.relationship',
|
||||
// 'emp.relationship_code',
|
||||
// 'emp.change_event',
|
||||
// 'emp.emp_code',
|
||||
// 'emp.name',
|
||||
// 'emp.email_corporate',
|
||||
// 'emp.dob',
|
||||
// 'DATE_FORMAT(emp.dob, "%d/%m/%Y") AS formatted_dob',
|
||||
// 'emp.gender',
|
||||
// 'emp.emp_status',
|
||||
// 'emp.is_active as emp_is_active',
|
||||
// 'emp.mobile as mobile',
|
||||
// 'emp.doj',
|
||||
// 'emp.basic_pay',
|
||||
// 'emp.band as grade',
|
||||
// 'policy_type.policy_type',
|
||||
// 'client_branch.branch_name as client_branch_name',
|
||||
// 'client_branch.branch_code as client_branch_code',
|
||||
// 'cp.policy_no',
|
||||
// 'cp.policy_type_id',
|
||||
|
||||
// // Name audit trail
|
||||
// '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS name_first_old',
|
||||
// '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS name_last_new',
|
||||
|
||||
// // DOB audit trail
|
||||
// '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS dob_first_old',
|
||||
// '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS dob_last_new',
|
||||
|
||||
// // Gender audit trail
|
||||
// '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS gender_first_old',
|
||||
// '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS gender_last_new',
|
||||
|
||||
// '(CASE
|
||||
// WHEN emp.relationship = "Self"
|
||||
// THEN (SELECT COUNT(id) FROM employees WHERE emp_code = emp.emp_code AND is_active = 0 AND emp_status != "truncated")
|
||||
// ELSE NULL
|
||||
// END) AS removed_count',
|
||||
|
||||
// '(CASE
|
||||
// WHEN emp.relationship != "Self" AND emp.created_at != (
|
||||
// SELECT created_at
|
||||
// FROM employees
|
||||
// WHERE emp_code = emp.emp_code AND relationship = "Self" AND is_active = 1
|
||||
// LIMIT 1
|
||||
// )
|
||||
// THEN "Newly Added"
|
||||
// ELSE NULL
|
||||
// END) AS newly_added',
|
||||
|
||||
// ])
|
||||
// ->join('employees emp', 'employee_polices.employee_id = emp.id')
|
||||
// ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
|
||||
// ->join('policies pm', 'cp.policy_id = pm.id', 'left') //pm - policy master
|
||||
// ->join('policy_type', 'policy_type.id = cp.policy_type_id')
|
||||
// ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master
|
||||
// ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch
|
||||
// ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
|
||||
// ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch
|
||||
// ->join('clients cm', 'cp.client_id = cm.id') //cm - client master
|
||||
// ->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
|
||||
// ->orderBy('emp.emp_code', 'ASC')
|
||||
// ->orderBy('employee_polices.employee_id', 'ASC');
|
||||
|
||||
|
||||
// // Conditionally add where clauses
|
||||
// if ($client_id != 0 && !empty($client_id)) {
|
||||
// $result->where('emp.client_id', $client_id);
|
||||
// }
|
||||
// if ($branch_id != 0 && !empty($branch_id)) {
|
||||
// $result->where('emp.client_branch_id', $branch_id);
|
||||
// }
|
||||
// if ($policy_id != 0 && !empty($policy_id)) {
|
||||
// $result->where('employee_polices.client_policy_id', $policy_id);
|
||||
// }
|
||||
|
||||
// if (is_array($status) && count($status) > 0) {
|
||||
|
||||
// $result->where('employee_polices.status !=', 'expired');
|
||||
|
||||
// if (in_array("active", $status)) {
|
||||
|
||||
// $result->where('employee_polices.tpa_id IS NOT NULL');
|
||||
// $result->where('employee_polices.uhid IS NOT NULL');
|
||||
// $result->whereIn('employee_polices.status', $status);
|
||||
// } elseif (in_array("pending", $status)) {
|
||||
|
||||
// $result->where('employee_polices.tpa_id IS NULL');
|
||||
// $result->where('employee_polices.uhid IS NULL');
|
||||
// $result->whereIn('employee_polices.status', array_merge($status, ['active']));
|
||||
// } else {
|
||||
|
||||
// $result->whereIn('employee_polices.status', $status);
|
||||
// }
|
||||
|
||||
// // if($status == 'active'){
|
||||
// // $result->where('employee_polices.tpa_id IS NOT NULL');
|
||||
// // $result->where('employee_polices.uhid IS NOT NULL');
|
||||
// // }else if($status == 'pending'){
|
||||
// // $status = 'active';
|
||||
// // $result->where('employee_polices.status', $status);
|
||||
// // }else{
|
||||
// // $result->where('employee_polices.status', $status);
|
||||
// // }
|
||||
// }
|
||||
|
||||
// if (!empty($emp_code)) {
|
||||
// $result->where('emp.emp_code', $emp_code);
|
||||
// }
|
||||
// if (!empty($emp_name)) {
|
||||
// $result->like('emp.name', $emp_name);
|
||||
// }
|
||||
|
||||
// // Always check these conditions
|
||||
// $result->where('employee_polices.is_active', 1)
|
||||
// ->where('emp.is_active', 1);
|
||||
|
||||
// $res = $result->findAll();
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
|
||||
// return $res;
|
||||
// } // remarks do not remove
|
||||
|
||||
public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "")
|
||||
{
|
||||
// dd($status);
|
||||
@ -179,9 +319,11 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
// Always check these conditions
|
||||
$result->where('employee_polices.is_active', 1)
|
||||
->where('emp.is_active', 1);
|
||||
|
||||
$result
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('emp.is_active', 1)
|
||||
->where('employee_polices.status !=', 'inactive');
|
||||
|
||||
$res = $result->findAll();
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
@ -274,7 +416,7 @@ class EmployeePolicyModel extends Model
|
||||
employees.designation AS emp_designation,
|
||||
employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
TIMESTAMPDIFF(YEAR, employees.dob, employee_polices.date_coverage) AS emp_age,
|
||||
employees.emp_type as emp_type,
|
||||
|
||||
|
||||
@ -452,20 +594,20 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data)
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0)
|
||||
{
|
||||
|
||||
$client_id = $ref_data['client_id'];
|
||||
$client_policy_id = $ref_data['client_policy_id'];
|
||||
$client_branch_id = $ref_data['client_branch_id'];
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
$client_id = $ref_data['client_id'];
|
||||
$client_policy_id = $ref_data['client_policy_id'];
|
||||
$client_branch_id = $ref_data['client_branch_id'];
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
|
||||
|
||||
$query = $this->db->query("
|
||||
SELECT
|
||||
a.id as endorsement_primarykey,
|
||||
$query = $this->db->query("
|
||||
SELECT
|
||||
a.id AS endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id AS primaryKey,
|
||||
employees.name AS emp_name,
|
||||
@ -474,10 +616,8 @@ class EmployeePolicyModel extends Model
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.emp_type as emp_type,
|
||||
'SI' as event_type_data,
|
||||
|
||||
|
||||
employees.emp_type AS emp_type,
|
||||
'SI' AS event_type_data,
|
||||
employees.doj AS emp_doj,
|
||||
employees.mobile AS emp_mobile,
|
||||
employees.email_corporate AS emp_email_c,
|
||||
@ -485,97 +625,59 @@ class EmployeePolicyModel extends Model
|
||||
employees.band AS emp_grade,
|
||||
employees.designation AS emp_designation,
|
||||
employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
employee_polices.uhid AS uhid,
|
||||
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,
|
||||
employee_polices.basic_cover_si AS old_basic_cover_si,
|
||||
employee_polices.premium AS old_si_premium,
|
||||
employee_polices.rata_premimum AS old_rata_premium,
|
||||
employee_polices.age_band,
|
||||
|
||||
batch_data.emp_policy_id,
|
||||
batch_data.bl AS batch_list_batch_code,
|
||||
batch_data.bf AS batch_files_batch_code,
|
||||
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_si_premium,
|
||||
sidata.old_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_premium,
|
||||
|
||||
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,
|
||||
|
||||
ROUND(sidata.new_si_premium - sidata.old_si_premium, 2) AS difference_premium,
|
||||
ROUND(
|
||||
((sidata.new_si_premium - employee_polices.rata_premimum) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) +
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365,
|
||||
2
|
||||
) AS pro_rata_premium,
|
||||
ROUND(
|
||||
(
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
|
||||
) * 0.18,
|
||||
2
|
||||
) AS gst,
|
||||
ROUND(
|
||||
(
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(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
|
||||
), 2
|
||||
(
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
|
||||
) * 0.18,
|
||||
2
|
||||
),
|
||||
2
|
||||
) AS total
|
||||
|
||||
FROM
|
||||
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 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
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT
|
||||
batch_list.emp_policy_id,
|
||||
batch_list.batch_code AS bl,
|
||||
batch_files.batch_code AS bf
|
||||
FROM
|
||||
batch_files
|
||||
LEFT JOIN
|
||||
batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
WHERE
|
||||
batch_files.event_type = 'si_enhancement'
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
|
||||
SELECT
|
||||
emp_code,
|
||||
CAST(MAX(CASE WHEN field_name = 'basic_cover_si' THEN new_value END) AS UNSIGNED) AS new_basic_cover_si,
|
||||
CAST(MAX(CASE WHEN field_name = 'premium' THEN new_value END) AS DECIMAL(10,2)) AS new_si_premium,
|
||||
CAST(MAX(CASE WHEN field_name = 'premium' THEN old_value END) AS DECIMAL(10,2)) AS old_si_premium,
|
||||
MAX(CASE WHEN field_name = 'si_enhancement_date' THEN new_value END) AS date_of_coverage
|
||||
FROM emp_endorsement
|
||||
GROUP BY 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}'
|
||||
$endorsement_condition
|
||||
@ -588,13 +690,177 @@ class EmployeePolicyModel extends Model
|
||||
group by group_key
|
||||
");
|
||||
|
||||
// Get the result set
|
||||
$results = $query->getResult();
|
||||
// dd($this->db->getLastQuery(), $results);
|
||||
return $results;
|
||||
// Get the result set
|
||||
$results = $query->getResult();
|
||||
|
||||
if ($return_type == 1) {
|
||||
$results = $query->getResultArray();
|
||||
} else {
|
||||
$results = $query->getResult();
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
return $results;
|
||||
}
|
||||
|
||||
// DO NOT DELETE this SI ENHANCEMENT QUERY FUNCTION
|
||||
|
||||
// public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0)
|
||||
// {
|
||||
|
||||
// $client_id = $ref_data['client_id'];
|
||||
// $client_policy_id = $ref_data['client_policy_id'];
|
||||
// $client_branch_id = $ref_data['client_branch_id'];
|
||||
// $insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
// $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
|
||||
|
||||
// $query = $this->db->query("
|
||||
// SELECT
|
||||
// a.id as endorsement_primarykey,
|
||||
// a.group_key,
|
||||
// employee_polices.id AS primaryKey,
|
||||
// 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,
|
||||
// employees.relationship AS emp_relationship,
|
||||
// employees.emp_type as emp_type,
|
||||
// 'SI' as event_type_data,
|
||||
|
||||
|
||||
// employees.doj AS emp_doj,
|
||||
// employees.mobile AS emp_mobile,
|
||||
// employees.email_corporate AS emp_email_c,
|
||||
// employees.email_personal AS emp_email_p,
|
||||
// employees.band AS emp_grade,
|
||||
// employees.designation AS emp_designation,
|
||||
// employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
// employee_polices.uhid AS uhid,
|
||||
// employee_polices.pre_existing_alignments,
|
||||
// employee_polices.policy_end_date,
|
||||
// employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
// employee_polices.premium as old_si_premium,
|
||||
// employee_polices.rata_premimum as old_rata_premium,
|
||||
// employee_polices.age_band,
|
||||
|
||||
// batch_data.emp_policy_id,
|
||||
// batch_data.bl AS batch_list_batch_code,
|
||||
// batch_data.bf AS batch_files_batch_code,
|
||||
|
||||
// sidata.new_basic_cover_si,
|
||||
// sidata.new_si_premium,
|
||||
// sidata.old_si_premium,
|
||||
// sidata.date_of_coverage,
|
||||
|
||||
// DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
|
||||
// ROUND(sidata.new_si_premium - sidata.old_si_premium, 2) AS difference_premium,
|
||||
|
||||
// ROUND((sidata.new_si_premium - sidata.old_si_premium) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premium,
|
||||
|
||||
// ROUND(((sidata.new_si_premium - sidata.old_si_premium) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
|
||||
// ROUND(
|
||||
// ((sidata.new_si_premium - sidata.old_si_premium) *
|
||||
// (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) +
|
||||
// ROUND(
|
||||
// ((sidata.new_si_premium - sidata.old_si_premium) *
|
||||
// (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2
|
||||
// ), 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',
|
||||
// bb.old_value as 'old_si_premium',
|
||||
// cc.new_value as 'date_of_coverage'
|
||||
// FROM (
|
||||
// SELECT
|
||||
// a1.emp_code,
|
||||
// a1.field_name,
|
||||
// a1.new_value,
|
||||
// a1.old_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,
|
||||
// b1.old_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,
|
||||
// c1.old_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
|
||||
// LEFT JOIN (
|
||||
// SELECT DISTINCT
|
||||
// batch_list.emp_policy_id,
|
||||
// batch_list.batch_code AS bl,
|
||||
// batch_files.batch_code AS bf
|
||||
// FROM
|
||||
// batch_files
|
||||
// LEFT JOIN
|
||||
// batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
// WHERE
|
||||
// batch_files.event_type = 'si_enhancement'
|
||||
// AND batch_files.actions = 'export'
|
||||
// AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
// ) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
|
||||
// WHERE employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
// AND employees.client_branch_id = '{$client_branch_id}'
|
||||
// $endorsement_condition
|
||||
// AND a.actions = 'si'
|
||||
// AND a.status != 'truncated'
|
||||
// AND employee_polices.is_active = 1
|
||||
// AND employee_polices.status = 'active'
|
||||
// AND employees.is_active = 1
|
||||
// AND employees.emp_status = 'active'
|
||||
// group by group_key
|
||||
// ");
|
||||
|
||||
// // Get the result set
|
||||
// $results = $query->getResult();
|
||||
|
||||
// if($return_type == 1){
|
||||
// $results = $query->getResultArray();
|
||||
// }else{
|
||||
// $results = $query->getResult();
|
||||
// }
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
// return $results;
|
||||
|
||||
// }
|
||||
|
||||
// DO NOT DELETE this DELETION QUERY FUNCTION
|
||||
|
||||
// public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
|
||||
@ -795,10 +1061,10 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
$status_condition = "{$insurer_or_tpa}" === 'tpa'
|
||||
? "employee_polices.status = 'active' AND employees.emp_status = 'active'"
|
||||
? "employee_polices.status = 'inactive' AND employees.emp_status = 'active'"
|
||||
: "employee_polices.status = 'active' AND employees.emp_status = 'active'";
|
||||
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
|
||||
$query = $this->db->query("
|
||||
SELECT DISTINCT
|
||||
@ -823,7 +1089,8 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
employee_polices.basic_cover_si,
|
||||
employee_polices.uhid as uhid,
|
||||
employee_polices.rata_premimum as premium,
|
||||
employee_polices.rata_premimum,
|
||||
ROUND(employee_polices.premium,2) as premium,
|
||||
employee_polices.claim_status,
|
||||
employee_polices.age_band,
|
||||
employee_polices.tpa_id,
|
||||
@ -849,22 +1116,22 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 OR deletiondata.claimstatus IS NULL THEN
|
||||
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
|
||||
ROUND((employee_polices.premium * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
|
||||
ELSE
|
||||
0
|
||||
END AS pro_rata_premium,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 OR deletiondata.claimstatus IS NULL THEN
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
|
||||
ROUND(((employee_polices.premium * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
|
||||
ELSE
|
||||
0
|
||||
END AS gst,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 OR deletiondata.claimstatus IS NULL THEN
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
|
||||
(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
|
||||
ROUND(((employee_polices.premium * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
|
||||
(((employee_polices.premium * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
|
||||
ELSE
|
||||
0
|
||||
END AS total,
|
||||
@ -1386,73 +1653,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) {
|
||||
|
||||
@ -24,6 +24,7 @@ class EndorsementModel extends Model
|
||||
'created_at',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
'file_id',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
55
app/Models/LeadFilesModel.php
Normal file
55
app/Models/LeadFilesModel.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class LeadFilesModel extends Model
|
||||
{
|
||||
protected $table = 'lead_files';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'lead_id',
|
||||
'docs_name',
|
||||
'file_name',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'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;
|
||||
}
|
||||
}
|
||||
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',
|
||||
@ -87,6 +87,17 @@ class LeadsModel extends Model
|
||||
|
||||
'lead_form_type',
|
||||
'custom_fields',
|
||||
|
||||
'source_policy_start_date',
|
||||
'source_policy_end_date',
|
||||
|
||||
'payment_date',
|
||||
'is_cd',
|
||||
|
||||
'is_installment',
|
||||
'no_of_installment',
|
||||
'is_policy_created',
|
||||
'claim_history'
|
||||
];
|
||||
|
||||
|
||||
@ -104,7 +115,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();
|
||||
}
|
||||
@ -115,7 +126,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();
|
||||
}
|
||||
@ -147,10 +158,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);
|
||||
@ -162,12 +173,13 @@ 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)")
|
||||
->where("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)");
|
||||
|
||||
|
||||
|
||||
@ -177,11 +189,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];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
22
app/Models/OccupancyMasterModel.php
Normal file
22
app/Models/OccupancyMasterModel.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OccupancyMasterModel extends Model
|
||||
{
|
||||
protected $table = 'occupancy_master';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'iib_code',
|
||||
'section',
|
||||
'description',
|
||||
'iib_loss_rate',
|
||||
'created_by',
|
||||
'created_at',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
@ -79,8 +79,9 @@ class PolicyTransactionModel extends Model
|
||||
'cd_ac_pk',
|
||||
'install_due_date',
|
||||
'policy_with_corr',
|
||||
'is_cd_reduce_from_bds',
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
// Callbacks
|
||||
@ -97,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();
|
||||
}
|
||||
@ -108,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();
|
||||
}
|
||||
@ -266,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);
|
||||
}
|
||||
@ -288,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();
|
||||
}
|
||||
|
||||
@ -445,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,
|
||||
@ -510,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') {
|
||||
|
||||
@ -546,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);
|
||||
// }
|
||||
@ -554,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);
|
||||
// }
|
||||
@ -564,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);
|
||||
// }
|
||||
@ -577,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);
|
||||
|
||||
@ -588,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 . "'
|
||||
";
|
||||
}
|
||||
|
||||
@ -781,18 +781,33 @@ 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 (
|
||||
(!in_array(get_role_id(), [1, 5])) &&
|
||||
!(
|
||||
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
in_array(BUSINESS_TEAM_ID, user_team())
|
||||
)
|
||||
) {
|
||||
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
$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){
|
||||
@ -809,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);
|
||||
}
|
||||
@ -827,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);
|
||||
}
|
||||
@ -837,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');
|
||||
@ -861,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);
|
||||
@ -903,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);
|
||||
// }
|
||||
@ -911,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);
|
||||
// }
|
||||
@ -931,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();
|
||||
@ -946,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('
|
||||
@ -973,10 +989,23 @@ class PolicyTransactionModel extends Model
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type', 'inception');
|
||||
|
||||
if (
|
||||
(!in_array(get_role_id(), [1, 5])) &&
|
||||
!(
|
||||
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
in_array(BUSINESS_TEAM_ID, user_team())
|
||||
)
|
||||
) {
|
||||
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
$builder->where('policy_transaction.created_by', get_session_userid());
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -997,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
|
||||
@ -1011,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);
|
||||
@ -1028,25 +1061,38 @@ 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)
|
||||
->where('policy_transaction.action_type !=', 'inception');
|
||||
|
||||
if (
|
||||
(!in_array(get_role_id(), [1, 5])) &&
|
||||
!(
|
||||
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
in_array(BUSINESS_TEAM_ID, user_team())
|
||||
)
|
||||
) {
|
||||
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
$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);
|
||||
}
|
||||
@ -1054,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);
|
||||
}
|
||||
@ -1070,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();
|
||||
@ -1195,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) {
|
||||
|
||||
@ -1239,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);
|
||||
}
|
||||
@ -1256,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',
|
||||
@ -1279,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) {
|
||||
|
||||
@ -1320,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,
|
||||
@ -1348,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) {
|
||||
|
||||
@ -1449,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,
|
||||
@ -1513,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();
|
||||
}
|
||||
|
||||
@ -1548,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.*,
|
||||
@ -1578,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);
|
||||
@ -1589,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
|
||||
@ -1597,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];
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ class RFQModel extends Model
|
||||
'type',
|
||||
'lead_id',
|
||||
'json',
|
||||
"registration_json",
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
@ -67,6 +68,7 @@ class RFQModel extends Model
|
||||
tpa_branch.branch_name as tpa_branch_name,
|
||||
policy_type.policy_type,
|
||||
rfq.json,
|
||||
rfq.registration_json
|
||||
')
|
||||
->join('leads', 'rfq.lead_id = leads.id')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
|
||||
@ -12,7 +12,7 @@ class TicketHistoryModel extends Model
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = ['id','field_name','display_name','old_value',
|
||||
protected $allowedFields = ['id', "ticket_id", 'field_name','display_name','old_value',
|
||||
'new_value','created_by','created_at','updated_by','updated_at','is_active'];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -15,6 +15,7 @@ class TicketMasterModel extends Model
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'ticket_type_id',
|
||||
'feedback_json',
|
||||
'claim_status_id',
|
||||
'acm_id',
|
||||
'insurer_id',
|
||||
@ -73,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"];
|
||||
@ -92,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();
|
||||
}
|
||||
@ -103,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();
|
||||
}
|
||||
@ -129,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;
|
||||
}
|
||||
@ -172,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)
|
||||
// {
|
||||
@ -209,7 +212,7 @@ class TicketMasterModel extends Model
|
||||
// ";
|
||||
// $statusResult = $this->db->query($statusQuery)->getResultArray();
|
||||
// // dd($statusResult);
|
||||
|
||||
|
||||
// // Initialize dynamic query parts
|
||||
// $dynamicSelect = '';
|
||||
|
||||
@ -247,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
|
||||
@ -316,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;
|
||||
@ -328,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)) {
|
||||
@ -510,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
|
||||
@ -531,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,
|
||||
@ -552,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
|
||||
@ -610,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, ' +');
|
||||
@ -659,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,
|
||||
@ -674,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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,6 +791,7 @@ class TicketMasterModel extends Model
|
||||
$query = $this->select('ticket_master.*, tms.mail_subject as subject')
|
||||
->join('ticket_messages tms', 'ticket_master.id = tms.ticket_id', 'left')
|
||||
->where('ticket_master.is_active', 1)
|
||||
->where('tms.sender', "user")
|
||||
->where('ticket_master.emp_id', $emp_id);
|
||||
|
||||
if (!empty($ticket_id)) {
|
||||
@ -703,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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,5 +134,20 @@ class UserModel extends Model
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function getexclusiveUserListForRFQ(){
|
||||
$data = $this->db->table('user_profiles')
|
||||
->select('user_profiles.*,user_teams.team_id')
|
||||
->select('roles.role as user_role')
|
||||
->join('roles', 'roles.id = user_profiles.role')
|
||||
->join('user_teams', 'user_teams.user_id = user_profiles.id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
// dd($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -139,40 +139,41 @@
|
||||
|
||||
<style>
|
||||
|
||||
body {
|
||||
.multiselect-native-select {
|
||||
position: relative;
|
||||
/* bottom: 32px; */
|
||||
select {
|
||||
border: 0 !important;
|
||||
clip: rect(0 0 0 0) !important;
|
||||
height: 1px !important;
|
||||
margin: -1px -1px -1px -3px !important;
|
||||
overflow: hidden !important;
|
||||
padding: 0 !important;
|
||||
position: absolute !important;
|
||||
width: 1px !important;
|
||||
left: 50%;
|
||||
top: 30px;
|
||||
body {
|
||||
|
||||
.multiselect-native-select {
|
||||
position: relative;
|
||||
/* bottom: 32px; */
|
||||
select {
|
||||
border: 0 !important;
|
||||
clip: rect(0 0 0 0) !important;
|
||||
height: 1px !important;
|
||||
margin: -1px -1px -1px -3px !important;
|
||||
overflow: hidden !important;
|
||||
padding: 0 !important;
|
||||
position: absolute !important;
|
||||
width: 1px !important;
|
||||
left: 50%;
|
||||
top: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.multiselect-container{
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.multiselect-selected-text{
|
||||
float: left !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.multiselect-container{
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.multiselect-selected-text{
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.navtab-bg .nav-link {
|
||||
margin: 0 5px 10px!important;
|
||||
}
|
||||
.navtab-bg .nav-link {
|
||||
margin: 0 5px 10px!important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<?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">
|
||||
@ -188,21 +189,25 @@ body {
|
||||
<br>
|
||||
|
||||
<ul class="nav nav-pills navtab-bg">
|
||||
<li class="nav-item">
|
||||
<a href="#pending-actions-dash-tab" data-toggle="tab" aria-expanded="false"
|
||||
class="nav-link px-3 py-2 active" id="pending_actions_tab">
|
||||
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Pending Actions</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#enrollment-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="enrollemnt_tab">
|
||||
<span class="mr-1"><i class="fa fa-file"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Enrolment</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php if(in_array(get_role_id(), [1,2,3,5])) { ?>
|
||||
|
||||
<?php if(get_role_id() == 1 || get_role_id() == 5 && (in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
|
||||
<li class="nav-item">
|
||||
<a href="#pending-actions-dash-tab" data-toggle="tab" aria-expanded="false"
|
||||
class="nav-link px-3 py-2 active" id="pending_actions_tab">
|
||||
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Pending Actions</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#enrollment-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="enrollemnt_tab">
|
||||
<span class="mr-1"><i class="fa fa-file"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Enrolment</span>
|
||||
</a>
|
||||
</li>
|
||||
<?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()))) { ?>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="#bds-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="bds_tab">
|
||||
@ -212,18 +217,61 @@ body {
|
||||
</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 include('endorsement_dash.php'); ?>
|
||||
<?php include('bds_dash.php'); ?>
|
||||
<?php include('enrollment_dash.php'); ?>
|
||||
<?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 // } ?> -->
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -90,6 +90,17 @@
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } else if ($file['status'] == 'in-progress-partially') { ?>
|
||||
|
||||
<?php echo $file['status']; ?>
|
||||
<?php if (!is_json_string($file['error_data'])) { ?>
|
||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-1') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
@ -146,7 +157,7 @@
|
||||
onclick="getBatchFileData(this)" class="dropdown-item upload_button" ><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (str_starts_with($file['status'], 'failed')) { ?>
|
||||
<?php if ($file['actions'] == "import") { ?>
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@ -125,12 +125,20 @@ body{
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="tab-pane fade" id="bds-dash-tab" style="padding-right: 35px;">
|
||||
<?php if((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 $add_active_calss = "active show" ?>
|
||||
<?php } ?>
|
||||
|
||||
<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="tab-pane <?= isset($add_active_calss) ? $add_active_calss : 'fade' ?>" id="bds-dash-tab" style="padding-right: 35px;">
|
||||
<div class="row">
|
||||
<div class="StatusTileHide" style="display: none; 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())) { ?>
|
||||
@ -219,6 +227,10 @@ body{
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".StatusTileHide").hide();
|
||||
})
|
||||
|
||||
function linkRedirectForBDS(input, team)
|
||||
{
|
||||
var link = "";
|
||||
@ -231,7 +243,8 @@ function linkRedirectForBDS(input, team)
|
||||
console.log(link);
|
||||
|
||||
if(link){
|
||||
window.location.href = link;
|
||||
|
||||
window.open(link, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,6 +252,7 @@ function show_business_status_tile(){
|
||||
|
||||
$('.businessStatusTile').show()
|
||||
$('.StatusTileHide').show()
|
||||
$("#mainMenuTiles").text("Viewing Details of Business Team Pending");
|
||||
|
||||
$('.businessPendingTile').hide()
|
||||
$('.financePendingTile').hide()
|
||||
@ -252,6 +266,8 @@ function show_finance_status_tile(){
|
||||
|
||||
$('.financePendingTile').hide()
|
||||
$('.businessPendingTile').hide()
|
||||
$("#mainMenuTiles").text("Viewing Details of Finance Team Pending");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -262,6 +278,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>
|
||||
@ -41,7 +41,7 @@
|
||||
origin: "mobile", // origin
|
||||
emp_code:"HTL-007",
|
||||
client_id:159,
|
||||
client_branch_id:125
|
||||
client_branch_id:126
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
330
app/Views/claims_dash.php
Normal file
330
app/Views/claims_dash.php
Normal file
@ -0,0 +1,330 @@
|
||||
<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
|
||||
}
|
||||
|
||||
|
||||
|
||||
redirectWithPost2("<?= base_url("ticket/list") ?>", data);
|
||||
}
|
||||
|
||||
function redirectWithPost2(url, data = {}) {
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = url;
|
||||
form.target = '_blank';
|
||||
|
||||
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>
|
||||
@ -125,13 +125,13 @@ input:checked + .slider:before {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<!-- <div>
|
||||
<label class="switch">
|
||||
<input id="is_download_btn" type="checkbox" name="is_download_btn" <?= (isset($client['is_download_btn']) && $client['is_download_btn'] == 1) ? 'checked' : '' ?>>
|
||||
<input id="is_download_btn" type="checkbox" name="is_download_btn" <?php // echo(isset($client['is_download_btn']) && $client['is_download_btn'] == 1) ? 'checked' : '' ?>>
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
<label for="is_download_btn" style=" position: relative;bottom: 5px;">Enable Client Export Option</label>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<a class="dropdown-item"
|
||||
href="<?= base_url("client/view_deposit/{$value->insurer_id}?client_id={$value->client_id}"); ?>">
|
||||
href="<?= base_url("client/view_deposit/{$value->insurer_id}?client_id={$value->client_id}&cd_ac_pk={$value->cd_ac_pk}"); ?>">
|
||||
<i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View Deposit
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@ -17,6 +17,10 @@ table.dataTable thead th {
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.btn-filter{
|
||||
margin-left: 20px !important;
|
||||
}
|
||||
|
||||
.custom-dropdown-menu {
|
||||
display: none;
|
||||
position: absolute;
|
||||
@ -53,12 +57,12 @@ table.dataTable thead th {
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Client List</h4>
|
||||
</div>
|
||||
<div class="col-2" style="text-align: right; position: relative;top: 56px; left: 303px;">
|
||||
<!-- <div class="col-2" style="text-align: right; position: relative;top: 56px; left: 303px;">
|
||||
<a class="btn btn-primary waves-effect waves-light" onclick="showModal()">Add From Lead</a>
|
||||
</div>
|
||||
<div class="col-1" style="text-align: right; position: relative;top: 56px; left: 294px;">
|
||||
<a href="<?= base_url("client/create"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">Add</a>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
|
||||
id="tickets-table">
|
||||
@ -269,18 +273,40 @@ table.dataTable thead th {
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
|
||||
dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'ClientList',
|
||||
className: 'my_class',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'ClientList',
|
||||
className: 'my_class',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Add From Lead',
|
||||
className: 'btn-filter', // custom class
|
||||
action: function(e, dt, node, config) {
|
||||
showModal();
|
||||
}
|
||||
},
|
||||
}],
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn-filter', // custom class
|
||||
action: function(e, dt, node, config) {
|
||||
addClient();
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
initComplete: function() {
|
||||
$('.btn-filter')
|
||||
.removeClass('btn-secondary')
|
||||
.addClass('btn btn-primary');
|
||||
},
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
@ -440,4 +466,9 @@ function featchClient(){
|
||||
});
|
||||
}
|
||||
|
||||
function addClient(){
|
||||
let url = "<?= base_url("client/create"); ?>";
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -88,15 +88,22 @@ body {
|
||||
<span class="d-none d-sm-inline-block">Policies</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<!-- <li class="nav-item">
|
||||
<a href="#api-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="api_tab">
|
||||
<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>
|
||||
<span class="d-none d-sm-inline-block">Others</span>
|
||||
</a>
|
||||
</li>
|
||||
</li> -->
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<?php include('client_others_tab.php'); ?>
|
||||
<?php include("client_api.php"); ?>
|
||||
<?php // include('client_others_tab.php'); ?>
|
||||
<?php include('notification.php'); ?>
|
||||
<?php include('client_basic_info.php'); ?>
|
||||
<?php include('client_kyc.php'); ?>
|
||||
@ -172,10 +179,9 @@ body {
|
||||
}
|
||||
|
||||
function client_policies() {
|
||||
var check_client_id = $('#general_PrimaryKey');
|
||||
var check_client_id = $('#general_PrimaryKey').val();
|
||||
|
||||
|
||||
if(check_client_id[0].value == '' || check_client_id[0].value == null || check_client_id[0].value == 0){
|
||||
if(check_client_id == '' || check_client_id == null || check_client_id == 0){
|
||||
$('#BtnAdd').hide();
|
||||
toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
|
||||
}else{
|
||||
@ -246,7 +252,7 @@ body {
|
||||
event.preventDefault();
|
||||
client_notification();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<th>Client Branch</th>
|
||||
<th>TPA</th>
|
||||
<th>Date</th>
|
||||
<th>Enrolment Status</th>
|
||||
<!-- <th>Enrolment Status</th> -->
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
@ -136,7 +136,7 @@
|
||||
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<!-- <div class="form-group col-md-4 EB">
|
||||
<label class="switch" style="position: relative;top: 43px;left: 20px;">
|
||||
<input id="inception_type" type="checkbox" name="inception_type">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
@ -159,14 +159,14 @@
|
||||
<div class="form-group col-md-4">
|
||||
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Remainder Dates( eg, 28,29,30 )" name="reminder_date" id="reminder_date" >
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<div class="form-group col-md-12 EB">
|
||||
<label for="disclaimer">Disclaimer<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" placeholder="Enter Disclaimer" name="disclaimer" id="disclaimer" ></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-4 EB">
|
||||
<label class="switch" style="position: relative;top: 43px;left: 20px;">
|
||||
<input id="policy_visibility" type="checkbox" name="enrolment_visibility" checked>
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
@ -175,7 +175,7 @@
|
||||
<label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty in Enrollment App</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-4 EB">
|
||||
<label class="switch" style="position: relative;top: 43px;left: 20px;">
|
||||
<input id="is_lgbtq" type="checkbox" name="is_lgbtq">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
@ -239,23 +239,23 @@
|
||||
|
||||
<script>
|
||||
|
||||
$('#inception_type').change(function () {
|
||||
var open_data = $('#open_date').parent();
|
||||
var close_data = $('#close_date').parent();
|
||||
var reminder_data = $('#reminder_date').parent();
|
||||
if($(this).prop('checked')){
|
||||
$(open_data).show();
|
||||
$(close_data).show();
|
||||
$(reminder_data).show();
|
||||
$('.dateofdata').attr('required', true);
|
||||
}else{
|
||||
$(open_data).hide();
|
||||
$(close_data).hide();
|
||||
$(reminder_data).hide();
|
||||
$('.dateofdata').attr('required', false);
|
||||
// $('#inception_type').change(function () {
|
||||
// var open_data = $('#open_date').parent();
|
||||
// var close_data = $('#close_date').parent();
|
||||
// var reminder_data = $('#reminder_date').parent();
|
||||
// if($(this).prop('checked')){
|
||||
// $(open_data).show();
|
||||
// $(close_data).show();
|
||||
// $(reminder_data).show();
|
||||
// $('.dateofdata').attr('required', true);
|
||||
// }else{
|
||||
// $(open_data).hide();
|
||||
// $(close_data).hide();
|
||||
// $(reminder_data).hide();
|
||||
// $('.dateofdata').attr('required', false);
|
||||
|
||||
}
|
||||
})
|
||||
// }
|
||||
// })
|
||||
|
||||
var policy_PrimaryKey = $('#client_id_policy').val();
|
||||
var policy_client = $('#policy_PrimaryKey').val();
|
||||
@ -348,28 +348,28 @@
|
||||
}
|
||||
//console.log('search_term :', search_term)
|
||||
|
||||
var enrollmentStatus = '';
|
||||
if (item.inception_type == 1) {
|
||||
// var enrollmentStatus = '';
|
||||
// if (item.inception_type == 1) {
|
||||
|
||||
enrollmentStatus = 'N/A'
|
||||
// enrollmentStatus = 'N/A'
|
||||
|
||||
} else if (item.inception_type == 2) {
|
||||
// } else if (item.inception_type == 2) {
|
||||
|
||||
if (item.open_for_enrollment == 1) {
|
||||
// if (item.open_for_enrollment == 1) {
|
||||
|
||||
enrollmentStatus = '<a href="#" data-id="' + item.id + '" id="' + item.policy_id +
|
||||
'" class="btnOpenEnroll" data-toggle="tooltip" data-placement="left" title="Click To Close Enrolment">Open</a>'
|
||||
// enrollmentStatus = '<a href="#" data-id="' + item.id + '" id="' + item.policy_id +
|
||||
// '" class="btnOpenEnroll" data-toggle="tooltip" data-placement="left" title="Click To Close Enrolment">Open</a>'
|
||||
|
||||
|
||||
} else if (item.open_for_enrollment == 0) {
|
||||
// } else if (item.open_for_enrollment == 0) {
|
||||
|
||||
enrollmentStatus =
|
||||
'<a href="#" data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" data-id="' +
|
||||
item.id + '" id="' + item.policy_id + '" class="btnOpenEnroll">Closed</a>'
|
||||
// enrollmentStatus =
|
||||
// '<a href="#" data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" data-id="' +
|
||||
// item.id + '" id="' + item.policy_id + '" class="btnOpenEnroll">Closed</a>'
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
var tpaValue = 'TPA Unavailable';
|
||||
|
||||
@ -388,7 +388,7 @@
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
@ -434,6 +434,7 @@
|
||||
|
||||
$('#policy_form')[0].reset();
|
||||
$('#add_form').show();
|
||||
// console.log("Policy Form Added")
|
||||
$('#table_list').hide();
|
||||
$('.btnBack').show();
|
||||
$('.btnAdd').hide();
|
||||
@ -442,9 +443,9 @@
|
||||
$('#tpa').val('').change();
|
||||
$('#policy_no').val('').change();
|
||||
$('#policy_no').val('').change();
|
||||
$('#start_date').val('').change();
|
||||
$('#end_date').val('').change();
|
||||
$('#close_date').val('').change();
|
||||
// $('#start_date').val('').change();
|
||||
// $('#end_date').val('').change();
|
||||
// $('#close_date').val('').change();
|
||||
// $('#policy').html('<option value="" selected>Select Policy</option>').change();
|
||||
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
|
||||
$('#policy_status_field').hide()
|
||||
@ -590,31 +591,31 @@
|
||||
|
||||
// //console.log('search_term :', search_term)
|
||||
|
||||
var enrollmentStatus = '';
|
||||
if (item.inception_type == 1) {
|
||||
// var enrollmentStatus = '';
|
||||
// if (item.inception_type == 1) {
|
||||
|
||||
enrollmentStatus = 'N/A'
|
||||
// enrollmentStatus = 'N/A'
|
||||
|
||||
} else if (item.inception_type == 2) {
|
||||
// } else if (item.inception_type == 2) {
|
||||
|
||||
if (item.open_for_enrollment == 1) {
|
||||
// if (item.open_for_enrollment == 1) {
|
||||
|
||||
enrollmentStatus =
|
||||
'<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrolment" href="#" data-id="' +
|
||||
item.id + '" id="' + item.policy_id +
|
||||
'" class="btnOpenEnroll">Open</a>'
|
||||
// enrollmentStatus =
|
||||
// '<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrolment" href="#" data-id="' +
|
||||
// item.id + '" id="' + item.policy_id +
|
||||
// '" class="btnOpenEnroll">Open</a>'
|
||||
|
||||
|
||||
} else if (item.open_for_enrollment == 0) {
|
||||
// } else if (item.open_for_enrollment == 0) {
|
||||
|
||||
enrollmentStatus =
|
||||
'<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" href="#" data-id="' +
|
||||
item.id + '" id="' + item.policy_id +
|
||||
'" class="btnOpenEnroll">Closed</a>'
|
||||
// enrollmentStatus =
|
||||
// '<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" href="#" data-id="' +
|
||||
// item.id + '" id="' + item.policy_id +
|
||||
// '" class="btnOpenEnroll">Closed</a>'
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
var tpaValue = 'TPA Unavailable';
|
||||
|
||||
@ -632,7 +633,6 @@
|
||||
<td>${tpaValue}</td>
|
||||
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
@ -725,10 +725,12 @@
|
||||
$(document).ready(function() {
|
||||
/********* set the Policy_Type_id for Form Submit *******/
|
||||
$('#policy_type').change(function() {
|
||||
// alert('policy_type change');
|
||||
|
||||
var policy_type_id = $(this).val();
|
||||
// alert(policy_type_id);
|
||||
|
||||
if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) {
|
||||
if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7 || policy_type_id > 10) {
|
||||
$('#tpa').prop('required', false);
|
||||
$('#tpa_danger').hide()
|
||||
} else {
|
||||
@ -804,19 +806,19 @@
|
||||
|
||||
|
||||
//Open for enrollment yes or no
|
||||
if (res.data.inception_type == 2) {
|
||||
$('#inception_type').prop('checked', true);
|
||||
$('#open_date').parent().show();
|
||||
$('#close_date').parent().show();
|
||||
$('#reminder_date').parent().show();
|
||||
$('.dateofdata').attr('required', true);
|
||||
} else {
|
||||
$('#inception_type').prop('checked', false);
|
||||
$('#open_date').parent().hide();
|
||||
$('#close_date').parent().hide();
|
||||
$('#reminder_date').parent().hide();
|
||||
$('.dateofdata').attr('required', false);
|
||||
}
|
||||
// if (res.data.inception_type == 2) {
|
||||
// $('#inception_type').prop('checked', true);
|
||||
// $('#open_date').parent().show();
|
||||
// $('#close_date').parent().show();
|
||||
// $('#reminder_date').parent().show();
|
||||
// $('.dateofdata').attr('required', true);
|
||||
// } else {
|
||||
// $('#inception_type').prop('checked', false);
|
||||
// $('#open_date').parent().hide();
|
||||
// $('#close_date').parent().hide();
|
||||
// $('#reminder_date').parent().hide();
|
||||
// $('.dateofdata').attr('required', false);
|
||||
// }
|
||||
|
||||
//Policy Visibility in Web App
|
||||
if (res.data.enrolment_visibility == 1) {
|
||||
@ -897,6 +899,17 @@
|
||||
|
||||
}
|
||||
|
||||
if (res.data.policy_type_id > 7) {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
$('#third').show();
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
$("#tpa").prop('required', false);
|
||||
$('#tpa_danger').hide();
|
||||
$(".EB").hide();
|
||||
}
|
||||
|
||||
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
|
||||
|
||||
@ -1440,14 +1453,29 @@
|
||||
$('#base_policy').prop('required', false);
|
||||
$('#base_danger').hide();
|
||||
}
|
||||
|
||||
if($('#inception_type').prop('checked')){
|
||||
|
||||
if ($(this).val() > 7) {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
$('#third').show();
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
$(".EB").hide();
|
||||
setTimeout(() => {
|
||||
$("#tpa").prop('required', false);
|
||||
$('#tpa_danger').hide();
|
||||
}, 100);
|
||||
|
||||
}else{
|
||||
$('#open_date').parent().hide();
|
||||
$('#close_date').parent().hide();
|
||||
$('#reminder_date').parent().hide();
|
||||
}
|
||||
|
||||
// if($('#inception_type').prop('checked')){
|
||||
|
||||
// }else{
|
||||
// $('#open_date').parent().hide();
|
||||
// $('#close_date').parent().hide();
|
||||
// $('#reminder_date').parent().hide();
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
@ -1520,6 +1548,7 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#base_policy').change(function() {
|
||||
// alert('Base Policy Change');
|
||||
|
||||
var client_policy_id = $(this).val() ? $(this).val() : 0;
|
||||
var policy_type = $('#policy_type').val()
|
||||
@ -1872,19 +1901,19 @@
|
||||
$('#policy_status_field').show();
|
||||
|
||||
|
||||
if (res.data.inception_type == 2) {
|
||||
$('#inception_type').prop('checked', true);
|
||||
$('#open_date').parent().show();
|
||||
$('#close_date').parent().show();
|
||||
$('#reminder_date').parent().show();
|
||||
$('.dateofdata').attr('required', true);
|
||||
} else {
|
||||
$('#inception_type').prop('checked', false);
|
||||
$('#open_date').parent().hide();
|
||||
$('#close_date').parent().hide();
|
||||
$('#reminder_date').parent().hide();
|
||||
$('.dateofdata').attr('required', false);
|
||||
}
|
||||
// if (res.data.inception_type == 2) {
|
||||
// $('#inception_type').prop('checked', true);
|
||||
// $('#open_date').parent().show();
|
||||
// $('#close_date').parent().show();
|
||||
// $('#reminder_date').parent().show();
|
||||
// $('.dateofdata').attr('required', true);
|
||||
// } else {
|
||||
// $('#inception_type').prop('checked', false);
|
||||
// $('#open_date').parent().hide();
|
||||
// $('#close_date').parent().hide();
|
||||
// $('#reminder_date').parent().hide();
|
||||
// $('.dateofdata').attr('required', false);
|
||||
// }
|
||||
|
||||
|
||||
if (res.data.enrolment_visibility == 1) {
|
||||
@ -1984,6 +2013,18 @@
|
||||
$('#tpa').prop('required', true);
|
||||
$('#tpa_danger').show()
|
||||
}
|
||||
|
||||
if (res.data.policy_type_id > 7) {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
$('#third').show();
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
$("#tpa").prop('required', false);
|
||||
$('#tpa_danger').hide();
|
||||
$(".EB").hide();
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
$('#client_branch').val(res.data.client_branch_id).select2();
|
||||
|
||||
@ -71,13 +71,10 @@ $(document).ready(function(){
|
||||
|
||||
$('#client_rm_edit').hide()
|
||||
|
||||
$('#account_manager').multiselect({
|
||||
nonSelectedText: 'Select Account Manager',
|
||||
enableFiltering: false,
|
||||
enableCaseInsensitiveFiltering: false,
|
||||
includeSelectAllOption : false,
|
||||
buttonWidth:'100%'
|
||||
});
|
||||
$('#account_manager').prop('disabled', true);
|
||||
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
|
||||
|
||||
var data = <?= isset($client_relation) ? json_encode($client_relation) : '[]' ?>;
|
||||
@ -94,10 +91,16 @@ $(document).ready(function(){
|
||||
}
|
||||
});
|
||||
|
||||
$('#account_manager').multiselect('refresh');
|
||||
|
||||
$('#account_manager').select2({
|
||||
placeholder: "Select Account Manager",
|
||||
}).prop('disabled', true);
|
||||
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
|
||||
$('#head').prop('disabled', true);
|
||||
$('#manager').prop('disabled', true);
|
||||
$('#account_manager').multiselect('disable');
|
||||
|
||||
}
|
||||
|
||||
@ -172,14 +175,25 @@ $(document).ready(function(){
|
||||
$('#manager').prop('disabled', !isDisabled);
|
||||
|
||||
if (isDisabled) {
|
||||
$('#account_manager').multiselect('enable');
|
||||
$('#account_manager').select2({
|
||||
placeholder: "Select Account Manager",
|
||||
}).prop('disabled', false);
|
||||
|
||||
$('#client_rm_btnSubmit').show();
|
||||
$(this).html('<span id="rm_icons" class="fa fa-times-circle"></span> Close Edit ');
|
||||
} else {
|
||||
$('#account_manager').multiselect('disable');
|
||||
$('#account_manager').select2({
|
||||
placeholder: "Select Account Manager"
|
||||
}).prop('disabled', true);
|
||||
|
||||
$('#client_rm_btnSubmit').hide();
|
||||
$(this).html('<span id="rm_icons" class="mdi mdi-lead-pencil"></span> Edit ');
|
||||
}
|
||||
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ table.dataTable tbody td {
|
||||
// });
|
||||
// });
|
||||
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
// document.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
function init() {
|
||||
const table = document.getElementById("tickets-table");
|
||||
|
||||
@ -627,10 +627,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (isDuplicate) {
|
||||
toastr.warning('This value is already selected in another dropdown.', 'Warning');
|
||||
selectElement.value = '';
|
||||
}
|
||||
// if (isDuplicate) {
|
||||
// toastr.warning('This value is already selected in another dropdown.', 'Warning');
|
||||
// selectElement.value = '';
|
||||
// }
|
||||
}
|
||||
|
||||
$('.close').click(function()
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -80,7 +80,17 @@
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
|
||||
<!-- srinivas -->
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
|
||||
<script src="https://editor.unlayer.com/embed.js"></script>
|
||||
|
||||
<!-- MD5 Hash Start -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.19.0/js/md5.min.js"></script>
|
||||
|
||||
|
||||
<!-- MD5 Hash End -->
|
||||
|
||||
<!-- <script src="<?= base_url('public/unlayer/js/embed.js') . '' ?>"></script> -->
|
||||
<!-- srinivas -->
|
||||
<style>
|
||||
@ -514,10 +524,9 @@
|
||||
</div>
|
||||
<!-- end Topbar -->
|
||||
|
||||
<!-- ========== Left Sidebar Start ========== -->
|
||||
<!-- ========== Left Sidebar Start ========== -->
|
||||
<div class="left-side-menu">
|
||||
|
||||
|
||||
<!-- LOGO -->
|
||||
<div class="logo-box">
|
||||
<a href="<?= base_url('/dashboard/view') ?>" class="logo logo-dark text-center">
|
||||
@ -542,7 +551,6 @@
|
||||
</div>
|
||||
|
||||
<div class="h-100" data-simplebar>
|
||||
|
||||
<!--- Sidemenu -->
|
||||
<div id="sidebar-menu">
|
||||
<ul id="side-menu">
|
||||
@ -554,41 +562,48 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/client/list') ?>">
|
||||
<i class="mdi mdi-domain"></i>
|
||||
<span> Clients </span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- client -->
|
||||
<?php if (in_array(get_role_id(), [1,2,3,5])) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/client/list') ?>">
|
||||
<i class="mdi mdi-domain"></i>
|
||||
<span> Clients </span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<li>
|
||||
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
|
||||
<i class="fas fa-user-tie"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Action on Policies </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboards">
|
||||
<ul class="nav-second-level">
|
||||
<!-- Enrollment process -->
|
||||
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(ENROLLMENT_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
|
||||
<i class="fas fa-user-tie"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Action on Policies </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboards">
|
||||
<ul class="nav-second-level">
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/upload') ?>">View Inception</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/list') ?>">View Members</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/endorsement-list') ?>">View Endorsement</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/test_members_list') ?>">Test Members List</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/upload') ?>">View Inception</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/list') ?>">View Members</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/endorsement-list') ?>">View Endorsement</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/test_members_list') ?>">Test Members List</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Masters -->
|
||||
<?php if (get_role_id() == 1 || get_role_id() == 5) { ?>
|
||||
|
||||
<li>
|
||||
@ -625,8 +640,8 @@
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
<!--
|
||||
<li>
|
||||
|
||||
<!-- <li>
|
||||
<?php
|
||||
$sessionData = get_session_userdata();
|
||||
$currentUrl = base_url();
|
||||
@ -641,181 +656,229 @@
|
||||
</a>
|
||||
</li> -->
|
||||
|
||||
<li>
|
||||
<a href="#sidebarDashboardsTicket" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-lifebuoy"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Claims </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboardsTicket">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="#" onclick="openTicketTypeAskModal()">New claim</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/list') ?>">Claim List</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/mail_template') ?>">Mail Template</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/ticket_reports') ?>">Claim Reports</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a id="app_content_management" href="#sidebarDashboardsmenu" data-toggle="collapse" class="waves-effect" style="color: grey;">
|
||||
<i class="fa fa-info-circle" aria-hidden="true"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> App Content Management </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboardsmenu">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/add_image_index') ?>"> Advertisement Images </a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/frontend_content') ?>">Front-end Content</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<!-- Claims -->
|
||||
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(CLAIMS_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="#sidebarDashboardsTicket" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-lifebuoy"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Claims </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboardsTicket">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="#" onclick="openTicketTypeAskModal()">New claim</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/list') ?>">Claim List</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/mail_template') ?>">Mail Template</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/ticket_reports') ?>">Claim Reports</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/feedback-list') ?>">Claim Feedback List</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<!-- leads -->
|
||||
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/leads/list') ?>">
|
||||
<i class="mdi mdi-chart-bar"></i>
|
||||
<span> Leads </span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<!-- BDS -->
|
||||
<?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()) || in_array(POS_TEAM_ID, user_team()))) { ?>
|
||||
<li>
|
||||
<a href="#policyTransactions" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-format-list-bulleted"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Policy Transactions </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyTransactions">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="#policyTransactionsSub" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-format-list-bulleted"></i>
|
||||
<span>Policy Transactions</span>
|
||||
</a>
|
||||
<div class="collapse" id="policyTransactionsSub">
|
||||
<ul>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1,5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/endorsement/list') ?>">Endorsement</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1,5]) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/statement/list') ?>">Statement Upload</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</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()) || in_array(POS_TEAM_ID, user_team()))) { ?>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()) ) { ?>
|
||||
<li>
|
||||
<a href="#policyReports" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-file-chart-fill"></i>
|
||||
<span> Policy Reports </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyReports">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/list') ?>">BDS</a>
|
||||
</li>
|
||||
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-varience-list') ?>">Variance</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-outstanding-list') ?>">Outstanding</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/irba_report') ?>">IRDA Reports</a>
|
||||
</li>
|
||||
<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>
|
||||
<a href="#policyPendingActions" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-timer-sand"></i>
|
||||
<span> Policy Pending Actions </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyPendingActions">
|
||||
<ul class="nav-third-level">
|
||||
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-finance-list') ?>">Finance Team</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-business-list') ?>">Business Team</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?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>
|
||||
<a href="#policyMasters" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-database-2-line"></i>
|
||||
<span> Masters </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyMasters">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?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>
|
||||
<a href="<?= base_url('/dmsSearch') ?>">
|
||||
<i class="ri-book-open-line"></i>
|
||||
<span> Documents</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Ad -->
|
||||
<?php if (in_array(get_role_id(), [1,2,3,5])) { ?>
|
||||
<li>
|
||||
<a id="app_content_management" href="#sidebarDashboardsmenu" data-toggle="collapse" class="waves-effect" style="color: grey;">
|
||||
<i class="fa fa-edit" aria-hidden="true"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span>App Content Mgmt</span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboardsmenu">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/add_image_index') ?>"> Advertisement Images </a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/frontend_content') ?>">Front-end Content</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/leads/list') ?>">
|
||||
<i class="mdi mdi-chart-bar"></i>
|
||||
<span> Leads </span>
|
||||
<a id="user_manual" href="<?= base_url("autobookstackLogin") ?>" class="waves-effect" target="_blank" rel="noopener noreferrer">
|
||||
<i class="fa fa-info-circle" aria-hidden="true"></i>
|
||||
<span>User Manual</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- End Sidebar -->
|
||||
</div>
|
||||
<!-- Sidebar -left -->
|
||||
|
||||
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
|
||||
|
||||
<li>
|
||||
<a href="#policyTransactions" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-format-list-bulleted"></i>
|
||||
<span class="badge badge-success badge-pill float-right">2</span>
|
||||
<span> Policy Transactions </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyTransactions">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="#policyTransactionsSub" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-format-list-bulleted"></i>
|
||||
<span>Policy Transactions</span>
|
||||
</a>
|
||||
<div class="collapse" id="policyTransactionsSub">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/endorsement/list') ?>">Endorsement</a>
|
||||
</li>
|
||||
|
||||
<?php if (in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/statement/list') ?>">Statement Upload</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php if (in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="#policyReports" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-file-chart-fill"></i>
|
||||
<span> Policy Reports </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyReports">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/list') ?>">BDS</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-varience-list') ?>">Variance</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-outstanding-list') ?>">Outstanding</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/irba_report') ?>">IRDA Reports</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/renewal_report') ?>">Renewal Reports</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<li>
|
||||
<a href="#policyPendingActions" data-toggle="collapse" class="waves-effect">
|
||||
<i class="mdi mdi-timer-sand"></i>
|
||||
<span> Policy Pending Actions </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyPendingActions">
|
||||
<ul class="nav-third-level">
|
||||
<?php if (in_array(FINANCE_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-finance-list') ?>">Finance Team</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-business-list') ?>">Business Team</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#policyMasters" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-database-2-line"></i>
|
||||
<span> Masters </span>
|
||||
</a>
|
||||
<div class="collapse" id="policyMasters">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/dmsSearch') ?>">
|
||||
<i class="ri-book-open-line"></i>
|
||||
<span> Documents</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- End Sidebar -->
|
||||
|
||||
</div>
|
||||
<!-- Sidebar -left -->
|
||||
|
||||
</div>
|
||||
<!-- Left Sidebar End -->
|
||||
<!-- Left Sidebar End -->
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start Page Content here -->
|
||||
|
||||
330
app/Views/leads_dash.php
Normal file
330
app/Views/leads_dash.php
Normal file
@ -0,0 +1,330 @@
|
||||
<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;
|
||||
form.target = '_blank';
|
||||
|
||||
|
||||
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>
|
||||
@ -36,6 +36,53 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.info-icon-wrapper {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
top: 30px;
|
||||
left: 35px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.info-tooltip {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
width: max-content;
|
||||
max-width: 300px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
text-align: left;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
bottom: 125%; /* Show above icon */
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 12px;
|
||||
white-space: normal;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.info-tooltip::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%; /* Arrow below tooltip */
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: #333 transparent transparent transparent;
|
||||
}
|
||||
|
||||
.info-icon-wrapper:hover .info-tooltip {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row" id="leads_form">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
@ -149,7 +196,7 @@
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="client_branch_id">Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_branch_id" name="client_branch_id"
|
||||
onchange="getBranchData(this)">
|
||||
onchange="getBranchData(this,1)">
|
||||
<option value="">Select Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -162,6 +209,16 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="source_policy_start_date">Source Policy Start Date<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control readonly-select" id="source_policy_start_date" name="source_policy_start_date" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="source_policy_end_date">Source Policy End Date<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="source_policy_end_date" name="source_policy_end_date" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pan">PAN<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number"
|
||||
@ -197,6 +254,14 @@
|
||||
placeholder="Enter Branch Code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="contact_person_summary">Contact Person's</label>
|
||||
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
||||
<option value="">Select a Person</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
@ -228,9 +293,9 @@
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="salse_person_id">Sales Person<span class="text-danger">*</span></label>
|
||||
<label for="salse_person_id">Salse Person<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="salse_person_id" name="salse_person_id" multiple required>
|
||||
<option value="">Select Sales Person</option>
|
||||
<option value="">Select Salse Person</option>
|
||||
<?php if (isset($salse_team)) { ?>
|
||||
<?php foreach ($salse_team as $value) { ?>
|
||||
<option value="<?= $value['id']; ?>">
|
||||
@ -279,6 +344,8 @@
|
||||
</div>
|
||||
</div><!-- end form row -->
|
||||
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
|
||||
<script>
|
||||
let claimIndex = 1;
|
||||
@ -343,32 +410,116 @@
|
||||
1); // Set end date to last day of selected year
|
||||
policy_end_datePicker.setDate(policy_end_date);
|
||||
|
||||
console.log('this object', this);
|
||||
console.log('id of this element:', this.element);
|
||||
console.log('id of this element:', this.element.id);
|
||||
// console.log('this object', this);
|
||||
// console.log('id of this element:', this.element);
|
||||
// console.log('id of this element:', this.element.id);
|
||||
|
||||
let increment = this.element.id.split('_').pop();
|
||||
console.log(increment); // Outputs: 1
|
||||
// let increment = this.element.id.split('_').pop();
|
||||
// console.log(increment); // Outputs: 1
|
||||
|
||||
|
||||
console.log('increment', increment);
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
console.log('policy_start_datePicker incurred_claim_date_', $(
|
||||
"#incurred_claim_date_" + increment).val());
|
||||
// console.log('increment', increment);
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// console.log('policy_start_datePicker incurred_claim_date_', $(
|
||||
// "#incurred_claim_date_" + increment).val());
|
||||
|
||||
// Recalculate policy_run_days if incurred claim date is already selected
|
||||
if ($("#incurred_claim_date_" + increment).val()) {
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if ($("#incurred_claim_date_" + increment).val()) {
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}else if (lead_type == 3) {
|
||||
|
||||
if ($('#client_id option[value="add_client"]').length === 0) {
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
}
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
$("#source_policy_id").hide();
|
||||
$('#source_policy_id').closest('.form-group').hide();
|
||||
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_start_date").closest("div") .find("label .text-danger").remove();
|
||||
$("#source_policy_start_date").hide();
|
||||
$('#source_policy_start_date').closest('.form-group').hide();
|
||||
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
$("#source_policy_end_date").closest("div") .find("label .text-danger").remove();
|
||||
$("#source_policy_end_date").hide();
|
||||
$('#source_policy_end_date').closest('.form-group').hide();
|
||||
|
||||
|
||||
|
||||
} else if (lead_type != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_start_date").prop("required", true);
|
||||
$("#source_policy_end_date").prop("required", true);
|
||||
|
||||
$("#source_policy_id").show();
|
||||
$("#source_policy_start_date").show();
|
||||
$("#source_policy_start_date").show();
|
||||
|
||||
$('#source_policy_id').closest('.form-group').find('label').show();
|
||||
$('#source_policy_start_date').closest('.form-group').find('label').show();
|
||||
$('#source_policy_end_date').closest('.form-group').find('label').show();
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id").closest("div") .find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
let $label2 = $("#source_policy_start_date").closest("div") .find("label");
|
||||
|
||||
if ($label2.find(".text-danger").length === 0) {
|
||||
$label2.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label3 = $("#source_policy_end_date").closest("div").find("label");
|
||||
|
||||
if ($label3.find(".text-danger").length === 0) {
|
||||
$label3.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(lead_type != 1){
|
||||
dataIncrement = 1;
|
||||
// updateRenewalFields(dataIncrement);
|
||||
|
||||
let incurred_claim_date_id = 'incurred_claim_date';
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
});
|
||||
}
|
||||
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
document.getElementById('source_policy_start_date').readOnly = true;
|
||||
document.getElementById('source_policy_end_date').readOnly = true;
|
||||
|
||||
$('#source_policy_start_date, #source_policy_end_date').addClass('readonly-select');
|
||||
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#source_policy_id').val("");
|
||||
|
||||
console.log('---- completed ----')
|
||||
});
|
||||
|
||||
console.log('increment count for insurer and tpa ', increment);
|
||||
@ -391,8 +542,14 @@
|
||||
$('#tpa_' + increment).select2();
|
||||
$('#proposed_insurer').select2();
|
||||
$('#proposed_tpa').select2();
|
||||
})
|
||||
$('#client_id').select2();
|
||||
$('#client_branch_id').select2();
|
||||
$('#source_policy_id').val("");
|
||||
|
||||
console.log('---- completed ----')
|
||||
|
||||
|
||||
})
|
||||
//------------------------------ GET DATA ( EDIT, BRANCH, POLICY ) ---------------------------------------------------------------------------
|
||||
|
||||
//view and edit Lead data function
|
||||
@ -453,7 +610,7 @@
|
||||
|
||||
updateRenewalFields(dataIncrement);
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -466,26 +623,26 @@
|
||||
let increment = this.input.id.split('_').pop();
|
||||
console.log('Extracted increment:', increment);
|
||||
|
||||
var policyStartDate = $("#policy_start_date_" + increment)
|
||||
.length ?
|
||||
$("#policy_start_date_" + increment) :
|
||||
$("#policy_start_date");
|
||||
|
||||
let lead_type = $('#lead_type').val();
|
||||
var policyStartDate = $("#source_policy_start_date");
|
||||
if(lead_type == 3){
|
||||
policyStartDate = $("#policy_start_date");
|
||||
}
|
||||
console.log('Selected Dates:', selectedDates);
|
||||
console.log('policy start date instance', policyStartDate)
|
||||
console.log('Policy Start Date:', policyStartDate.val());
|
||||
|
||||
// Recalculate policy_run_days if policy start date is already selected
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if (policyStartDate.val()) {
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
// var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
@ -565,10 +722,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
var allContacts = "";
|
||||
//client branch data
|
||||
function getBranchData(input) {
|
||||
function getBranchData(input, inputType) {
|
||||
|
||||
var client_branch_id = $(input).val();
|
||||
if (inputType == 1 ) {
|
||||
var client_branch_id = $(input).val();
|
||||
} else {
|
||||
client_branch_id = input;
|
||||
}
|
||||
|
||||
if (client_branch_id) {
|
||||
|
||||
@ -589,9 +751,29 @@
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res?.contact?.name || '');
|
||||
$('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
$('#contact_person_email').val(res?.contact?.email || '');
|
||||
allContacts = res.contact;
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
res.contact.forEach((value, key) => {
|
||||
|
||||
if (value.name && value.email) {
|
||||
|
||||
let display_value = `${value.name} - ${value.email} - ${value.mobile}`;
|
||||
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: key, // index or key in array/object
|
||||
text: display_value
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
// $('#contact_person_name').val(res?.contact?.name || '');
|
||||
// $('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
// $('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
|
||||
$('#pan').prop('readOnly', true);
|
||||
@ -651,6 +833,12 @@
|
||||
|
||||
if (res.status === true && res.data) {
|
||||
|
||||
console.log("res.data.source_policy_start_date", res.data.source_policy_start_date)
|
||||
console.log("res.data.source_policy_end_date", res.data.source_policy_end_date)
|
||||
|
||||
$('#source_policy_start_date').val(res.data.source_policy_start_date);
|
||||
$('#source_policy_end_date').val(res.data.source_policy_end_date);
|
||||
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
|
||||
$(`#policy_type_id`).removeClass('readonly-select ').select2();
|
||||
@ -682,6 +870,7 @@
|
||||
$(`#proposed_tpa_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
console.warn('Invalid response:', res.message || 'Unknown error');
|
||||
// Reset fields if response is invalid
|
||||
@ -694,6 +883,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Hide loader
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -758,6 +948,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;
|
||||
@ -787,7 +978,7 @@
|
||||
|
||||
updateRenewalFields(dataIncrement);
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -800,25 +991,26 @@
|
||||
let increment = this.input.id.split('_').pop();
|
||||
console.log('Extracted increment:', increment);
|
||||
|
||||
var policyStartDate = $("#policy_start_date_" + increment).length ?
|
||||
$("#policy_start_date_" + increment) :
|
||||
$("#policy_start_date");
|
||||
|
||||
var policyStartDate = $("#source_policy_start_date");
|
||||
if(lead_type == 3){
|
||||
policyStartDate = $("#policy_start_date");
|
||||
}
|
||||
|
||||
console.log('Selected Dates:', selectedDates);
|
||||
console.log('policy start date instance', policyStartDate)
|
||||
console.log('Policy Start Date:', policyStartDate.val());
|
||||
|
||||
// Recalculate policy_run_days if policy start date is already selected
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if (policyStartDate.val()) {
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
// var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
@ -868,7 +1060,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>";
|
||||
}
|
||||
}
|
||||
@ -907,7 +1099,7 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="">Date of Commencement <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC">
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" onchange="calculatePolicyMetrics(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -917,12 +1109,8 @@
|
||||
|
||||
<div id="appendArea_${increment}" class = "form-group col-md-12 appendArea"></div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="file_upload">File Upload<span class="text-danger"></span></label>
|
||||
<input type="file" class="form-control" id="file_name_${increment}" name="file_name[]" accept=".xls,.xlsx">
|
||||
<span class="text-danger" id="file_name_display"></span>
|
||||
</div>
|
||||
|
||||
<div id="multiFileAppendArea_${increment}"></div>
|
||||
|
||||
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
|
||||
@ -931,6 +1119,8 @@
|
||||
|
||||
container.appendChild(newRow);
|
||||
|
||||
//append mutli file html
|
||||
addFileField(increment);
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
leadTypeBsedHideAndShow(lead_type)
|
||||
@ -970,16 +1160,16 @@
|
||||
console.log(increment); // Outputs: 1
|
||||
|
||||
|
||||
console.log('increment', increment);
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" +
|
||||
increment).val());
|
||||
// console.log('increment', increment);
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" +
|
||||
// increment).val());
|
||||
|
||||
// Recalculate policy_run_days if incurred claim date is already selected
|
||||
if ($("#incurred_claim_date_" + increment).val()) {
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if ($("#incurred_claim_date_" + increment).val()) {
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1048,103 +1238,274 @@
|
||||
//------------------------ CALCULATION ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function calculatePolicyRunDays(increment) {
|
||||
// function calculatePolicyRunDays(increment) {
|
||||
|
||||
console.log('calculatePolicyRunDays function called');
|
||||
console.log('increment', increment);
|
||||
// // console.log('calculatePolicyRunDays function called');
|
||||
// // console.log('increment', increment);
|
||||
// // let lead_type = $('#lead_type').val();
|
||||
// // var policyStartDate = $("#source_policy_start_date");
|
||||
// // if(lead_type == 3){
|
||||
// // policyStartDate = $("#policy_start_date");
|
||||
// // }
|
||||
// // var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y");
|
||||
// // var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
|
||||
var policyStartDate = $("#policy_start_date_" + increment).length ?
|
||||
$("#policy_start_date_" + increment) :
|
||||
$("#policy_start_date");
|
||||
// // console.log('policyStartDate', policyStartDate)
|
||||
// // console.log('incurredClaimDate', incurredClaimDate)
|
||||
|
||||
var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y");
|
||||
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
// // if (policyStartDate && incurredClaimDate) {
|
||||
// // var timeDiff = Math.abs(policyStartDate - incurredClaimDate); // Time difference in milliseconds
|
||||
// // console.log('timeDiff', timeDiff);
|
||||
// // var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1); // Convert to days and add 1
|
||||
// // console.log('daysDiff', daysDiff);
|
||||
// // $("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
|
||||
// // }
|
||||
// }
|
||||
|
||||
console.log('policyStartDate', policyStartDate)
|
||||
console.log('incurredClaimDate', incurredClaimDate)
|
||||
// function incurredClaimSum(input) {
|
||||
|
||||
// // let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
// // console.log('increment', increment);
|
||||
|
||||
// // // Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
// // let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
|
||||
// // console.log('paid_claims', paid_claims);
|
||||
|
||||
// // let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
|
||||
// // console.log('outstanding_claims', outstanding_claims);
|
||||
|
||||
// // // Calculate the incurred claim
|
||||
// // let incurred_claims = paid_claims + outstanding_claims;
|
||||
// // console.log('incurred_claims', incurred_claims);
|
||||
|
||||
// // // Set the calculated value
|
||||
// // $('#incurred_claims_' + increment).val(incurred_claims);
|
||||
|
||||
// // // ------------------------------------------------------------------------------------------
|
||||
|
||||
// // let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
// // console.log('policy_run_days', policy_run_days);
|
||||
// // console.log('incurred claims ' + incurred_claims);
|
||||
// // // Prevent division by zero in annualised claims calculation
|
||||
// // let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
|
||||
// // let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
// // console.log('annualised_claims', annualised_claims_roundoff);
|
||||
|
||||
// // $('#annualised_claims_' + increment).val(annualised_claims_roundoff);
|
||||
|
||||
// // // ------------------------------------------------------------------------------------------
|
||||
|
||||
// // // Prevent division by zero in incurred claim ratio calculation
|
||||
// // let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
// // let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0)
|
||||
// // ? (annualised_claims / premium_as_on_date)
|
||||
// // : 0;
|
||||
|
||||
// // let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio)
|
||||
// // ? Math.round(incurred_claim_ratio)
|
||||
// // : 0;
|
||||
|
||||
// // console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
|
||||
|
||||
// // $('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff);
|
||||
|
||||
// // // ------------------------------------------------------------------------------------------
|
||||
|
||||
// // let earnedPremium = parseFloat($('#earned_premium_' + increment).val()) || 0;
|
||||
// // console.log('earnedPremium:', earnedPremium);
|
||||
|
||||
// // // Prevent division by zero
|
||||
// // let earnedClaimsRatio = earnedPremium > 0 ? annualised_claims / earnedPremium : 0;
|
||||
|
||||
// // // Round to nearest integer
|
||||
// // let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio);
|
||||
// // console.log('earnedClaimsRatio:', earnedClaimsRatio);
|
||||
|
||||
// // // Set the value to the corresponding input
|
||||
// // $('#earned_claims_ratio_' + increment).val(earnedClaimsRatioRounded);
|
||||
|
||||
// }
|
||||
|
||||
// function earnedPremiumCalc(input) {
|
||||
|
||||
// // let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
// // console.log('increment', increment);
|
||||
|
||||
// // let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
|
||||
// // // Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
// // let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
|
||||
// // console.log('premium_at_inception', premium_at_inception);
|
||||
|
||||
// // let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
// // console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// // // Prevent division by zero and calculate earned premium
|
||||
// // let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
// // console.log('earned_premium', earned_premium);
|
||||
// // let earned_premium_roundoff = Math.round(earned_premium);
|
||||
// // // Set the calculated value with two decimal places
|
||||
// // $('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
// }
|
||||
|
||||
function calculatePolicyMetrics(input) {
|
||||
|
||||
let lead_type = $('#lead_type').val();
|
||||
console.log('Lead Type:', lead_type);
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract increment
|
||||
if(lead_type != 1){
|
||||
increment = "1";
|
||||
}
|
||||
|
||||
console.log('--- calculatePolicyMetrics called ---');
|
||||
console.log('Input ID:', input.id);
|
||||
console.log('Increment:', increment);
|
||||
|
||||
let sourcePolicyDateVal = $('#source_policy_start_date').val()?.trim();
|
||||
let policyStartDateVal = $('#policy_start_date').val()?.trim();
|
||||
let policyStartDateInput = null;
|
||||
|
||||
if (sourcePolicyDateVal) {
|
||||
policyStartDateInput = $('#source_policy_start_date');
|
||||
console.log('Using Source Policy Start Date:', sourcePolicyDateVal);
|
||||
} else if (policyStartDateVal) {
|
||||
policyStartDateInput = $('#policy_start_date');
|
||||
console.log('Using Policy Start Date:', policyStartDateVal);
|
||||
} else {
|
||||
toastr.warning('Policy start date or Date of Commencement is empty. Please fill in the date field.', "WARNING.. !");
|
||||
console.warn('Both policy start dates are missing or invalid');
|
||||
$(input).val('');
|
||||
return; // stop further execution
|
||||
}
|
||||
|
||||
// let policyStartDateInput = (lead_type == 3) ? $('#policy_start_date') : $('#source_policy_start_date');
|
||||
console.log('Policy Start Date Input:', policyStartDateInput.val());
|
||||
|
||||
let policyStartDate = flatpickr.parseDate(policyStartDateInput.val(), "d/m/Y");
|
||||
let incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
|
||||
console.log('Parsed Policy Start Date:', policyStartDate);
|
||||
console.log('Parsed Incurred Claim Date:', incurredClaimDate);
|
||||
|
||||
if (policyStartDate && incurredClaimDate) {
|
||||
var timeDiff = incurredClaimDate - policyStartDate; // Time difference in milliseconds
|
||||
console.log('timeDiff', timeDiff);
|
||||
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1
|
||||
console.log('daysDiff', daysDiff);
|
||||
$("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
|
||||
let timeDiff = Math.abs(incurredClaimDate - policyStartDate);
|
||||
console.log('Time Difference (ms):', timeDiff);
|
||||
|
||||
let daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1);
|
||||
console.log('Policy Run Days:', daysDiff);
|
||||
|
||||
$('#policy_run_days_' + increment).val(daysDiff);
|
||||
}
|
||||
}
|
||||
|
||||
function incurredClaimSum(input) {
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
|
||||
console.log('paid_claims', paid_claims);
|
||||
|
||||
let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
|
||||
console.log('outstanding_claims', outstanding_claims);
|
||||
console.log('Paid Claims:', paid_claims);
|
||||
console.log('Outstanding Claims:', outstanding_claims);
|
||||
|
||||
// Calculate the incurred claim
|
||||
let incurred_claims = paid_claims + outstanding_claims;
|
||||
console.log('incurred_claims', incurred_claims);
|
||||
|
||||
// Set the calculated value
|
||||
console.log('Incurred Claims:', incurred_claims);
|
||||
$('#incurred_claims_' + increment).val(incurred_claims);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
console.log('incurred claims ' + incurred_claims);
|
||||
// Prevent division by zero in annualised claims calculation
|
||||
let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
|
||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
console.log('annualised_claims', annualised_claims_roundoff);
|
||||
console.log('Policy Run Days (Final):', policy_run_days);
|
||||
|
||||
let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0;
|
||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
||||
console.log('Annualised Claims:', annualised_claims);
|
||||
console.log('Annualised Claims (Rounded):', annualised_claims_roundoff);
|
||||
$('#annualised_claims_' + increment).val(annualised_claims_roundoff);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
// Prevent division by zero in incurred claim ratio calculation
|
||||
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0;
|
||||
let incurred_claim_ratio_roundoff = Math.round(incurred_claim_ratio);
|
||||
console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
|
||||
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
console.log('Premium as on Date:', premium_as_on_date);
|
||||
|
||||
let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0)
|
||||
? (annualised_claims / premium_as_on_date)
|
||||
: 0;
|
||||
let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? Math.round(incurred_claim_ratio) : 0;
|
||||
console.log('Incurred Claim Ratio:', incurred_claim_ratio);
|
||||
console.log('Incurred Claim Ratio (Rounded):', incurred_claim_ratio_roundoff);
|
||||
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio_roundoff);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
let earned_premium = Number($('#earned_premium_' + increment).val()) || 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
|
||||
// Prevent division by zero in earned claims ratio calculation
|
||||
let earned_claims_ratio = earned_premium > 0 ? incurred_claims / earned_premium : 0;
|
||||
let earned_claims_ration_roundoff = Math.round(earned_claims_ratio);
|
||||
console.log('earned_claims_ratio', earned_claims_ratio);
|
||||
|
||||
$('#earned_claims_ratio_' + increment).val(earned_claims_ration_roundoff);
|
||||
}
|
||||
|
||||
function earnedPremiumCalc(input) {
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
|
||||
console.log('premium_at_inception', premium_at_inception);
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// Prevent division by zero and calculate earned premium
|
||||
let earned_premium = policy_run_days > 0 ? premium_at_inception / policy_run_days : 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
let earned_premium_roundoff = Math.round(earned_premium);
|
||||
// Set the calculated value with two decimal places
|
||||
console.log('Earned Premium:', earned_premium);
|
||||
console.log('Earned Premium (Rounded):', earned_premium_roundoff);
|
||||
$('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
|
||||
let earnedClaimsRatio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
|
||||
let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio);
|
||||
console.log('Earned Claims Ratio:', earnedClaimsRatio);
|
||||
console.log('Earned Claims Ratio (Rounded):', earnedClaimsRatioRounded);
|
||||
$('#earned_claims_ratio_' + increment).val(earnedClaimsRatioRounded);
|
||||
|
||||
console.log('--- End of calculatePolicyMetrics ---\n');
|
||||
}
|
||||
|
||||
|
||||
$(document).on("input", "#incept_emp_count, #incept_dept_count, #renewal_emp_count, #renewal_dept_count, #exp_emp_count, #exp_dept_count", function() {
|
||||
calculateTotalLives(this);
|
||||
});
|
||||
|
||||
function calculateTotalLives(input) {
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
|
||||
if (lead_type == 1) {
|
||||
|
||||
let formRow = input.closest('.form-row');
|
||||
|
||||
if (formRow) {
|
||||
// Get the employee count and dependent count within the same row
|
||||
let empCountInput = formRow.querySelector('[name="incept_emp_count[]"]');
|
||||
let depCountInput = formRow.querySelector('[name="incept_dept_count[]"]');
|
||||
let totalLivesInput = formRow.querySelector('[name="incept_no_of_lives[]"]');
|
||||
|
||||
// Parse the input values as integers, defaulting to 0 if empty
|
||||
let empCount = empCountInput ? parseInt(empCountInput.value) || 0 : 0;
|
||||
let depCount = depCountInput ? parseInt(depCountInput.value) || 0 : 0;
|
||||
|
||||
// Calculate total lives
|
||||
let totalLives = empCount + depCount;
|
||||
|
||||
// Set the total lives input value
|
||||
if (totalLivesInput) {
|
||||
totalLivesInput.value = totalLives;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
console.log("Function Called");
|
||||
|
||||
if (input.id === "incept_emp_count" || input.id === "incept_dept_count") {
|
||||
var incept_emp_count = parseInt($("#incept_emp_count").val()) || 0;
|
||||
var incept_dept_count = parseInt($("#incept_dept_count").val()) || 0;
|
||||
|
||||
var totalCount = incept_emp_count + incept_dept_count;
|
||||
$("#incept_no_of_lives").val(totalCount);
|
||||
|
||||
} else if (input.id === "renewal_emp_count" || input.id === "renewal_dept_count") {
|
||||
var renewal_emp_count = parseInt($("#renewal_emp_count").val()) || 0;
|
||||
var renewal_dept_count = parseInt($("#renewal_dept_count").val()) || 0;
|
||||
|
||||
var totalCount = renewal_emp_count + renewal_dept_count;
|
||||
$("#renewal_no_of_lives").val(totalCount);
|
||||
|
||||
} else {
|
||||
var exp_emp_count = parseInt($("#exp_emp_count").val()) || 0;
|
||||
var exp_dept_count = parseInt($("#exp_dept_count").val()) || 0;
|
||||
|
||||
var totalCount = exp_emp_count + exp_dept_count;
|
||||
$("#exp_no_of_lives").val(totalCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------ FORM SUBMIT ---------------------------------------------------------------------------------
|
||||
|
||||
$("#leads_form_id").submit(function(event) {
|
||||
@ -1452,7 +1813,7 @@
|
||||
$('.freshFields').find('select, input').attr('required', 'required');
|
||||
$('.freshFields').show();
|
||||
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
// $('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
|
||||
if (resetValues) {
|
||||
|
||||
@ -1484,13 +1845,41 @@
|
||||
$('.freshFields').hide();
|
||||
|
||||
$('.renewalFields').show();
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
if (value != 3) {
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
|
||||
$('#source_policy_id').show();
|
||||
$('#source_policy_start_date').show();
|
||||
$('#source_policy_end_date').show();
|
||||
|
||||
$('#source_policy_id').closest('.form-group').show();
|
||||
$('#source_policy_start_date').closest('.form-group').show();
|
||||
$('#source_policy_end_date').closest('.form-group').show();
|
||||
|
||||
}else{
|
||||
|
||||
$('#source_policy_id').hide();
|
||||
$('#source_policy_start_date').hide();
|
||||
$('#source_policy_end_date').hide();
|
||||
|
||||
$('#source_policy_id').closest('.form-group').hide();
|
||||
$('#source_policy_start_date').closest('.form-group').hide();
|
||||
$('#source_policy_end_date').closest('.form-group').hide();
|
||||
}
|
||||
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
|
||||
$('#policy_end_date').removeAttr('required');
|
||||
$('#policy_start_date').removeAttr('required');
|
||||
$('#claims').removeAttr('required');
|
||||
$('#source_policy_start_date').attr('readonly', 'readonly');
|
||||
$('#source_policy_end_date').attr('readonly', 'readonly');
|
||||
|
||||
console.log('readonly set', $('#source_policy_start_date').prop('readonly')); // should print true
|
||||
|
||||
if (resetValues) {
|
||||
|
||||
@ -1532,6 +1921,7 @@
|
||||
}
|
||||
|
||||
function updateRenewalFields(increment) {
|
||||
console.log('updateRenewalFields function called');
|
||||
$(".renewalCalculation input, .renewalCalculation select").each(function() {
|
||||
let oldId = $(this).attr("id");
|
||||
if (oldId) {
|
||||
@ -1540,4 +1930,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
</script>
|
||||
@ -83,6 +83,10 @@ if (isset($selected_lead_type)) {
|
||||
var client_list = ''; // local variable for storing the client branch list
|
||||
var branch_list = ''; // local variable for storing the client branch list
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
var temp_client_id = 0;
|
||||
var temp_branch_id = 0;
|
||||
var selected_lead_form_type = <?= isset($selected_lead_type) ? $selected_lead_type : 0 ?>;
|
||||
var fileIndex = 1; // Initialize index
|
||||
|
||||
|
||||
// select2 document ready
|
||||
@ -146,8 +150,20 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
|
||||
function appendClients(data) {
|
||||
// console.log("lead_type",lead_type.value);
|
||||
|
||||
$('#client_id').empty();
|
||||
|
||||
if (lead_type.value == 3) {
|
||||
if ($('#client_id option[value="add_client"]').length === 0) {
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
$('#client_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Client'
|
||||
@ -187,7 +203,9 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
|
||||
function appendRenewalPolicies(data) {
|
||||
|
||||
console.log('appendRenewalPolicies', data);
|
||||
console.log('selected_lead_form_type', selected_lead_form_type);
|
||||
|
||||
$('#source_policy_id').empty();
|
||||
|
||||
@ -195,16 +213,27 @@ if (isset($selected_lead_type)) {
|
||||
value: '',
|
||||
text: 'Select Policy',
|
||||
}));
|
||||
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
let shouldAppend = false;
|
||||
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.policy_type + '-' + item.policy_no,
|
||||
});
|
||||
if (selected_lead_form_type == 1) {
|
||||
shouldAppend = (item.allocg !== "Non-EB" && item.allocg !== "Marine");
|
||||
} else if (selected_lead_form_type == 2) {
|
||||
shouldAppend = (item.allocg === "Non-EB" || item.allocg === "Marine");
|
||||
} else {
|
||||
shouldAppend = true;
|
||||
}
|
||||
|
||||
$('#source_policy_id').append(option);
|
||||
if (shouldAppend) {
|
||||
const option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.policy_type + ' - ' + item.policy_no,
|
||||
});
|
||||
$('#source_policy_id').append(option);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
@ -214,6 +243,16 @@ if (isset($selected_lead_type)) {
|
||||
$('#client_id').change(function() {
|
||||
|
||||
let client_id = $(this).val();
|
||||
|
||||
|
||||
if (client_id == 'add_client') {
|
||||
// alert("Hello");
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
myModal.show();
|
||||
// $('#upload_enrollment_model').modal('toggle');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("client_id", client_id)
|
||||
let client_type = $('#client_id option:selected').data('ct');
|
||||
|
||||
@ -222,14 +261,40 @@ if (isset($selected_lead_type)) {
|
||||
let data = branch_list[client_id];
|
||||
appendBranch(data);
|
||||
} else {
|
||||
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
||||
if (temp_client_id == 0) {
|
||||
console.log("Step 1: temp_client_id is 0 - No Branch Found for the selected Client");
|
||||
console.log('second client_id', client_id);
|
||||
if (client_id == null || client_id == 0) {
|
||||
console.log("Step 2: client_id is null or 0 - Setting temp_client_id to 0");
|
||||
temp_client_id = 0;
|
||||
} else {
|
||||
console.log("Step 3: client_id exists - Assigning temp_client_id = client_id");
|
||||
temp_client_id = client_id;
|
||||
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
||||
}
|
||||
} else {
|
||||
console.log("Step 4: temp_client_id is not 0 - Showing warning");
|
||||
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$("#contact_person_summary").change(function () {
|
||||
let selectedKey = $(this).val();
|
||||
|
||||
if (allContacts[selectedKey]) {
|
||||
$('#contact_person_name').val(allContacts[selectedKey].name || '');
|
||||
$('#contact_person_mobile').val(allContacts[selectedKey].mobile || '');
|
||||
$('#contact_person_email').val(allContacts[selectedKey].email || '');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#client_branch_id').change(function() {
|
||||
|
||||
let client_branch_id = $(this).val();
|
||||
console.log('client_branch_id', client_branch_id);
|
||||
|
||||
if (policy_list[client_branch_id] != '' && policy_list[client_branch_id] != null &&
|
||||
client_branch_id != '' && client_branch_id != null) {
|
||||
@ -238,7 +303,29 @@ if (isset($selected_lead_type)) {
|
||||
appendRenewalPolicies(data);
|
||||
} else {
|
||||
$('#source_policy_id').empty();
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
|
||||
// let lead_type = data.lead_type || null;
|
||||
if (temp_branch_id == 0) {
|
||||
console.log("Step 1: temp_branch_id is 0 - No Policies Found for the selected branch");
|
||||
console.log('second client_branch_id', client_branch_id);
|
||||
if (client_branch_id == null || client_branch_id == 0) {
|
||||
console.log("Step 2: client_branch_id is null or 0 - Setting temp_branch_id to 0");
|
||||
temp_branch_id = 0;
|
||||
} else {
|
||||
console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id");
|
||||
temp_branch_id = client_id;
|
||||
if (lead_type != 3) {
|
||||
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("Step 4: temp_branch_id is not 0 - Showing warning");
|
||||
if (lead_type != 3) {
|
||||
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -263,6 +350,153 @@ if (isset($selected_lead_type)) {
|
||||
$('#salse_person_id').trigger('change');
|
||||
}
|
||||
|
||||
// function validateInput(input, table, field){
|
||||
|
||||
// let value = $(input).val();
|
||||
// let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
|
||||
// let message = "Value is duplicate!";
|
||||
// if(label){
|
||||
// message = label + " already exists!";
|
||||
// }
|
||||
|
||||
// checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
// if (isDuplicate) {
|
||||
// toastr.warning(message, 'WARNING');
|
||||
// $(input).val('')
|
||||
// }
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
function addFileField(increment) {
|
||||
|
||||
console.log('addFileField function called');
|
||||
|
||||
const container = document.getElementById(`multiFileAppendArea_${increment}`);
|
||||
if (!container) return;
|
||||
|
||||
const div = document.createElement("div");
|
||||
div.className = "form-row d-flex align-items-end";
|
||||
div.setAttribute("id", `fileField_${fileIndex}`);
|
||||
|
||||
let isFirstField = container.childElementCount === 0; // Check if it's the first field
|
||||
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 ${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">
|
||||
<label>File Upload<span class="text-danger"></span></label>
|
||||
<input type="file" class="form-control" id="file_name_${fileIndex}" name="file_name_${increment}[]" accept="${accept}">
|
||||
</div>
|
||||
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(${fileIndex})">x</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addFileField(${increment})">+</button>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(div);
|
||||
fileIndex++;
|
||||
}
|
||||
|
||||
function removeFileField(index, lead_file_id = null) {
|
||||
|
||||
if(index == 1){
|
||||
toastr.warning("You can't remove the first file field", 'WARNING');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(lead_file_id != null) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Do you want to remove this file?",
|
||||
// text: "Do you want Save this!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, Procced!"
|
||||
}).then((result) => {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
|
||||
let url = '<?= base_url('util/removeMultiFile') ?>';
|
||||
|
||||
let requestData = {
|
||||
lead_file_id: lead_file_id
|
||||
};
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
|
||||
//remove the file field
|
||||
const field = document.getElementById(`fileField_${index}`);
|
||||
if(index != 1){
|
||||
if (field) field.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 checking the CD amount.', 'ERROR');
|
||||
});
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}else{
|
||||
const field = document.getElementById(`fileField_${index}`);
|
||||
if(index != 1){
|
||||
if (field) field.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function showFileName(input, index) {
|
||||
if (input.files.length > 0) {
|
||||
document.getElementById(`file_name_display_${index}`).textContent = input.files[0].name;
|
||||
} else {
|
||||
document.getElementById(`file_name_display_${index}`).textContent = "No file chosen";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@ -270,12 +504,26 @@ if (isset($selected_lead_type)) {
|
||||
<?php if (isset($lead_edit_data)) { ?>
|
||||
<script>
|
||||
|
||||
setTimeout(function(){
|
||||
handleEbAndNonEbEdit(
|
||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>);
|
||||
}, 1000)
|
||||
var lead_type = "";
|
||||
|
||||
$(document).ready(async function () {
|
||||
|
||||
$('.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){
|
||||
lead_type = data.lead_type || null;
|
||||
if(data.lead_form_type == 1){
|
||||
dynamicLeadsDataForEdit(data)
|
||||
}else{
|
||||
@ -285,10 +533,15 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
function dynamicLeadsDataForEdit(data) {
|
||||
try {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
console.log('########### THIS IS EB LEAD ###############')
|
||||
|
||||
console.log('Received data:', data);
|
||||
let dataIncrement = 1;
|
||||
fileIndex = data.lead_file_count + 1;
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
console.error('Invalid data received for editing.');
|
||||
@ -297,6 +550,7 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
$('.btnDiv').hide();
|
||||
$('#appendArea_' + dataIncrement).empty();
|
||||
|
||||
|
||||
if (data.html) {
|
||||
$('#appendArea_' + dataIncrement).append(data.html);
|
||||
@ -304,6 +558,15 @@ if (isset($selected_lead_type)) {
|
||||
console.warn('HTML content missing in data.');
|
||||
}
|
||||
|
||||
if (data.multi_file_html && data.multi_file_html != '') {
|
||||
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||
setTimeout(function(){
|
||||
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
||||
}, 2000)
|
||||
} else {
|
||||
console.warn('MULTI FILE HTML content missing in data.');
|
||||
}
|
||||
|
||||
let policy_type_id = data.policy_type_id || null;
|
||||
let lead_type = data.lead_type || null;
|
||||
|
||||
@ -314,6 +577,10 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
leadTypeBsedHideAndShow(lead_type);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
|
||||
if (lead_type == 1) {
|
||||
$('.claim-row').hide();
|
||||
} else {
|
||||
@ -325,10 +592,10 @@ if (isset($selected_lead_type)) {
|
||||
$('.gpaClaimFileds').hide();
|
||||
$('.lifeClaimFields').show();
|
||||
} else {
|
||||
updateRenewalFields(dataIncrement);
|
||||
// updateRenewalFields(dataIncrement);
|
||||
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
if ($('#' + incurred_claim_date_id).length) {
|
||||
flatpickr("#" + incurred_claim_date_id, {
|
||||
@ -337,10 +604,7 @@ if (isset($selected_lead_type)) {
|
||||
onChange: function (selectedDates) {
|
||||
try {
|
||||
let increment = this.input.id.split('_').pop();
|
||||
let policyStartDate = $("#policy_start_date_" + increment).length
|
||||
? $("#policy_start_date_" + increment)
|
||||
: $("#policy_start_date");
|
||||
|
||||
let policyStartDate = $("#source_policy_start_date");
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
@ -353,20 +617,55 @@ if (isset($selected_lead_type)) {
|
||||
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
|
||||
}
|
||||
|
||||
if ($('#' + premium_date_id).length) {
|
||||
flatpickr("#" + premium_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
} else {
|
||||
console.warn(`Premium date field #${premium_date_id} not found.`);
|
||||
}
|
||||
// if ($('#' + premium_date_id).length) {
|
||||
// flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
// } else {
|
||||
// console.warn(`Premium date field #${premium_date_id} not found.`);
|
||||
// }
|
||||
|
||||
// console.log($('#proposed_insurer_' + dataIncrement).length);
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
}
|
||||
}
|
||||
|
||||
// if (lead_type == 3) {
|
||||
|
||||
// $('#client_id').prepend($('<option>', {
|
||||
// value: 'add_client',
|
||||
// text: '+ Add Client'
|
||||
// }));
|
||||
|
||||
// console.log("trying to remove required ");
|
||||
// $("#source_policy_id").prop("required",false);
|
||||
// $("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
// } else if (lead_type != 3) {
|
||||
// $("#source_policy_id").prop("required",true);
|
||||
// $("#source_policy_id").prop("required", true);
|
||||
|
||||
// // Check if the asterisk doesn't already exist, then add it
|
||||
// let $label = $("#source_policy_id")
|
||||
// .closest("div")
|
||||
// .find("label");
|
||||
|
||||
// if ($label.find(".text-danger").length === 0) {
|
||||
// $label.append(' <span class="text-danger">*</span>');
|
||||
// }
|
||||
|
||||
// var addOption = $('#client_id option[value="add_client"]');
|
||||
// if (addOption.length > 0) {
|
||||
// addOption.remove();
|
||||
// }
|
||||
|
||||
// console.log("rying to remove required and option removed from client")
|
||||
|
||||
// }
|
||||
|
||||
hide_list_show_add();
|
||||
|
||||
$('#page_title').text('Edit Lead');
|
||||
@ -381,25 +680,33 @@ if (isset($selected_lead_type)) {
|
||||
$('#lead_status').val(data.status || '');
|
||||
$('#notes').val(data.notes || '');
|
||||
|
||||
setTimeout(() => {
|
||||
$('#client_id').val(data.client_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#source_policy_id').val(data.source_policy_id || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
$('#branch_code').val(data.branch_code || '');
|
||||
$('#contact_person_name').val(data.contact_person_name || '');
|
||||
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
// setTimeout(() => {
|
||||
// $('#client_id').val(data.client_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#source_policy_id').val(data.source_policy_id || '');
|
||||
// $('#source_policy_end_date').val(data.source_policy_end_date || '');
|
||||
// $('#source_policy_start_date').val(data.source_policy_start_date || '');
|
||||
// $('#pan').val(data.pan || '');
|
||||
// $('#gst').val(data.gst || '');
|
||||
// $('#branch_name').val(data.branch_name || '');
|
||||
// $('#branch_code').val(data.branch_code || '');
|
||||
// $('#contact_person_name').val(data.contact_person_name || '');
|
||||
// $('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
// $('#contact_person_email').val(data.contact_person_email || '');
|
||||
// $('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }, 1000);
|
||||
// }, 1000);
|
||||
// }, 5000);
|
||||
|
||||
// setTimeout(() => {
|
||||
populateForm(data);
|
||||
|
||||
// },5000);
|
||||
|
||||
|
||||
let insurer = (data.insurer_branch_id && data.insurer_id)
|
||||
? `${data.insurer_branch_id}-${data.insurer_id}`
|
||||
@ -426,6 +733,8 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,6 +743,7 @@ if (isset($selected_lead_type)) {
|
||||
console.log('########### THIS IS NON EB LEAD ###############')
|
||||
console.log('Received data:', data);
|
||||
let dataIncrement = 1;
|
||||
fileIndex = data.lead_file_count + 1;
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
console.error('Invalid data received for editing.');
|
||||
@ -441,6 +751,8 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
|
||||
$('#appendArea').empty();
|
||||
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||
|
||||
|
||||
if (data.html) {
|
||||
$('#appendArea').append(data.html);
|
||||
@ -448,11 +760,26 @@ if (isset($selected_lead_type)) {
|
||||
console.warn('HTML content missing in data.');
|
||||
}
|
||||
|
||||
if (data.multi_file_html) {
|
||||
// console.log(data.multi_file_html);
|
||||
setTimeout(function(){
|
||||
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
||||
}, 1000)
|
||||
} else {
|
||||
console.warn('MULTI FILE HTML content missing in data.');
|
||||
}
|
||||
|
||||
let policy_type_id = data.policy_type_id || null;
|
||||
let lead_type = data.lead_type || null;
|
||||
|
||||
leadTypeBsedHideAndShow(lead_type);
|
||||
|
||||
if(data.client_id == 0 || data.client_id == null){
|
||||
temp_client_id = 0;
|
||||
}else{
|
||||
temp_client_id = data.client_id
|
||||
}
|
||||
|
||||
|
||||
$('#page_title').text('Edit Lead');
|
||||
$('#leads_primarykey').val(data.id || '');
|
||||
@ -466,25 +793,33 @@ if (isset($selected_lead_type)) {
|
||||
$('#lead_status').val(data.status || '');
|
||||
$('#notes').val(data.notes || '');
|
||||
|
||||
setTimeout(() => {
|
||||
$('#client_id').val(data.client_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#source_policy_id').val(data.source_policy_id || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
$('#branch_code').val(data.branch_code || '');
|
||||
$('#contact_person_name').val(data.contact_person_name || '');
|
||||
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
// setTimeout(() => {
|
||||
// $('#client_id').val(data.client_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
// setTimeout(() => {
|
||||
// $('#source_policy_id').val(data.source_policy_id || '');
|
||||
// $('#pan').val(data.pan || '');
|
||||
// $('#gst').val(data.gst || '');
|
||||
// $('#branch_name').val(data.branch_name || '');
|
||||
// $('#branch_code').val(data.branch_code || '');
|
||||
// $('#contact_person_name').val(data.contact_person_name || '');
|
||||
// $('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
// $('#contact_person_email').val(data.contact_person_email || '');
|
||||
// $('#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);
|
||||
|
||||
populateForm(data);
|
||||
|
||||
|
||||
let insurer = (data.insurer_branch_id && data.insurer_id)
|
||||
? `${data.insurer_branch_id}-${data.insurer_id}`
|
||||
@ -514,10 +849,105 @@ if (isset($selected_lead_type)) {
|
||||
referenceDiv.innerHTML = '';
|
||||
referenceDiv.insertAdjacentHTML('beforeend', data.claims_details_html);
|
||||
|
||||
console.log("wdesfgefwregfefwregffeegf",data.lead_type);
|
||||
var lead_type_value = data.lead_type;
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function waitForDropdownValue(selector, value, callback, retries = 20) {
|
||||
|
||||
const trySet = () => {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
const $el = $(selector);
|
||||
if ($el.find(`option[value="${value}"]`).length > 0) {
|
||||
$el.val(value).trigger('change');
|
||||
callback();
|
||||
} else if (retries > 0) {
|
||||
setTimeout(trySet, 300); // retry without re-passing arguments
|
||||
retries--;
|
||||
} else {
|
||||
console.warn(`Value ${value} not found for ${selector}`);
|
||||
callback(); // Proceed anyway to avoid hanging
|
||||
}
|
||||
};
|
||||
|
||||
trySet();
|
||||
}
|
||||
|
||||
function populateForm(data) {
|
||||
|
||||
let lead_type = data.lead_type || null;
|
||||
waitForDropdownValue('#client_id', data.client_id || '', () => {
|
||||
|
||||
if (lead_type == 3) {
|
||||
// Add "+ Add Client" option if not already present
|
||||
if ($('#client_id option[value="add_client"]').length === 0) {
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
}
|
||||
|
||||
console.log("Trying to remove 'required' attribute and asterisk");
|
||||
$("#source_policy_id").prop("required", false);
|
||||
$("#source_policy_id").closest("div").find("label .text-danger").remove();
|
||||
|
||||
} else {
|
||||
|
||||
if(lead_type == 2){
|
||||
$("#source_policy_id").prop("required", true);
|
||||
}else{
|
||||
$("#source_policy_id").prop("required", false);
|
||||
}
|
||||
|
||||
// Add asterisk if not present
|
||||
let $label = $("#source_policy_id").closest("div").find("label");
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
// Remove "+ Add Client" option if exists
|
||||
$('#client_id option[value="add_client"]').remove();
|
||||
|
||||
console.log("Set 'required' for source_policy_id and removed add_client option if present");
|
||||
}
|
||||
|
||||
waitForDropdownValue('#client_branch_id', data.client_branch_id || '', () => {
|
||||
// Fill other form fields
|
||||
$('#source_policy_id').val(data.source_policy_id || '');
|
||||
$('#source_policy_end_date').val(data.source_policy_end_date || '');
|
||||
$('#source_policy_start_date').val(data.source_policy_start_date || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
$('#branch_code').val(data.branch_code || '');
|
||||
$('#contact_person_name').val(data.contact_person_name || '');
|
||||
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
||||
$('#contact_person_email').val(data.contact_person_email || '');
|
||||
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
||||
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
$(".loss_date").each(function () {
|
||||
flatpickr(this, {
|
||||
dateFormat: "d-m-Y"
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
298
app/Views/newClientModal.php
Normal file
298
app/Views/newClientModal.php
Normal file
@ -0,0 +1,298 @@
|
||||
<!-- Client form content modal-->
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">PAN</label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInputForClient(this, 'clients', 'pan')">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Client Type -->
|
||||
<div class="form-row clienttypediv" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||
onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email2">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email2" placeholder="Enter Email" name="email2">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="aadhar">Aadhar</label>
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- branch -->
|
||||
<div class="form-row branchdiv">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
if (isset($entity) && count($entity)) {
|
||||
foreach ($entity as $key => $value) {
|
||||
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" oninput="validateInputForClient(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let isGSTValidating = false;
|
||||
let isGSTValid = false;
|
||||
|
||||
function validateInputForClient(input, table, field) {
|
||||
let value = $(input).val();
|
||||
if (!value) return;
|
||||
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
let message = label ? label + " already exists!" : "Value is duplicate!";
|
||||
|
||||
// Set validating state
|
||||
isGSTValidating = true;
|
||||
isGSTValid = false;
|
||||
$('#hide_smbt_btn button').prop('disabled', true);
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
isGSTValidating = false;
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
$(input).val('');
|
||||
isGSTValid = false;
|
||||
} else {
|
||||
isGSTValid = true;
|
||||
}
|
||||
});
|
||||
$('#hide_smbt_btn button').prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// If GST is currently validating, wait for it to complete
|
||||
if (isGSTValidating) {
|
||||
if($('#Owner_type').val() == 1){
|
||||
toastr.info('Please wait while we validate your GST number...', 'Validating');
|
||||
return;
|
||||
}else if ($('#client_type').val() == 1){
|
||||
toastr.info('Please wait while we validate your GST number...', 'Validating');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If GST validation failed, prevent submission
|
||||
if ($('#gst').val() && !isGSTValid) {
|
||||
toastr.warning('Please fix the GST number before submitting', 'Validation Error');
|
||||
return;
|
||||
}
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
|
||||
console.log('onsubmit event', this)
|
||||
console.log('onsubmit event get data value',form_type)
|
||||
console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
$('#aadhar').attr('data-parsley-required', 'false');
|
||||
$('#aadhar').removeAttr('required');
|
||||
|
||||
if($('#Owner_type').val() == 2){
|
||||
$('#gst').removeAttr('required');
|
||||
}
|
||||
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
|
||||
if (!isValid) {
|
||||
var emptyFieldIds = [];
|
||||
|
||||
$('#client_form').parsley().fields.forEach(function(field) {
|
||||
if (!field.isValid()) {
|
||||
var elem = field.$element;
|
||||
var id = elem.attr('id') || elem.attr('name');
|
||||
emptyFieldIds.push(id);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Empty/Invalid Fields:', emptyFieldIds);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val() || 1;
|
||||
console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
console.log("formData : ",formData);
|
||||
// return
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
$('#client_id').val(res.client_id).change();
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 1000)
|
||||
|
||||
}, 3000)
|
||||
|
||||
}else{
|
||||
|
||||
console.log("Couldn't Add Client","Error");
|
||||
}
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData", res.client_id);
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -10,9 +10,9 @@
|
||||
overflow-y: auto !important;
|
||||
}
|
||||
#editor-container {
|
||||
width: 100%;
|
||||
min-height: 600px;
|
||||
}
|
||||
width: 100%;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.modal-dialog {
|
||||
max-width: 90% !important;
|
||||
@ -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'] : '' ?>" />
|
||||
@ -264,7 +265,7 @@
|
||||
<!-- Unlayer editor -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<div id="member_welcome_mail_editor_container" style="height: 600px;width:max-content"></div>
|
||||
<div id="member_welcome_mail_editor_container" style="height: 600px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -360,7 +361,7 @@
|
||||
<!-- Unlayer editor -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<div id="member_reminder_mail_editor_container" style="height: 600px;width:max-content"></div>
|
||||
<div id="member_reminder_mail_editor_container" style="height: 600px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -426,7 +427,7 @@
|
||||
<select id="member_ecard_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||||
<option value="">PlaceHolders</option>
|
||||
<?php foreach ($placeHolders as $value): ?>
|
||||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
|
||||
<?php if ($value) { ?>
|
||||
<?php $valueChange = str_replace('_', ' ', $value);
|
||||
$valueChange = ucwords($valueChange); ?>
|
||||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||||
@ -440,7 +441,7 @@
|
||||
<!-- Unlayer editor -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<div id="member_ecard_mail_editor_container" style="height: 600px;width:max-content"></div>
|
||||
<div id="member_ecard_mail_editor_container" style="height: 600px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -542,7 +543,7 @@
|
||||
<!-- Unlayer editor -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<div id="member_review_and_summary_mail_editor_container" style="height: 600px;width:max-content"></div>
|
||||
<div id="member_review_and_summary_mail_editor_container" style="height: 600px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -615,7 +616,7 @@
|
||||
<!-- Unlayer editor -->
|
||||
<!-- <div class="form-row" id="rac_rate_dropdown"> -->
|
||||
<div class="form-group col-md-12">
|
||||
<div id="account_maneger_summary_mail_editor_container" style="height: 600px;width:max-content"></div>
|
||||
<div id="account_maneger_summary_mail_editor_container" style="height: 600px"></div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<div class="form-group text-right m-b-0">
|
||||
@ -702,7 +703,7 @@
|
||||
<!-- Unlayer editor -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<div id="client_hr_summary_mail_editor_container" style="height: 600px;width:max-content"></div>
|
||||
<div id="client_hr_summary_mail_editor_container" style="height: 600px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -87,7 +87,24 @@ label {
|
||||
<input type="hidden" name="client_policy_id" id="other_client_policy_id" />
|
||||
<input type="hidden" name="policy_id" id="gpa_policy_id" />
|
||||
<input type="hidden" id="emp_count" />
|
||||
<div id="sumInsuredDiv" class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-6">
|
||||
<label for="sumInsured">Sum Insured</label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
|
||||
</div>
|
||||
<div class="col-md-2" style="position: relative;left: 88px;">
|
||||
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div id='numberToWordOthers' class="text-danger-2" ></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 10px;margin-bottom:15px;" id="sum_insured_add_more" ></div>
|
||||
<div id="append_html_for_other_policy_terms"></div>
|
||||
|
||||
<hr>
|
||||
@ -164,6 +181,9 @@ $("#otherPolicyTerms").submit(function(event) {
|
||||
// Append the JSON string to the FormData object
|
||||
formData.append('policy_terms', jsonString);
|
||||
|
||||
formData.forEach((value, key) => {
|
||||
console.log(key + ': ' + value);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
data: formData,
|
||||
@ -187,6 +207,7 @@ $("#otherPolicyTerms").submit(function(event) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
@ -207,17 +228,18 @@ $("#otherPolicyTerms").submit(function(event) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
var policy_type_id = "";
|
||||
$('body').on('click', '.btnPolicyMaster', function() {
|
||||
$("#append_html_for_other_policy_terms").empty();
|
||||
|
||||
|
||||
var client_policy_id = $(this).data('id');
|
||||
var policy_type_id = $(this).data('typeid');
|
||||
policy_type_id = $(this).data('typeid');
|
||||
console.log('policy_type_id', policy_type_id);
|
||||
console.log('client_policy_id :', client_policy_id);
|
||||
|
||||
$('#other_client_policy_id').val(client_policy_id);
|
||||
|
||||
appendPolicyTermsHTML(policy_type_id);
|
||||
|
||||
var gpa_policy_type_id = $(this).attr('id');
|
||||
// console.log('gpa_policy_type_id', gpa_policy_type_id)
|
||||
@ -262,16 +284,17 @@ $('body').on('click', '.btnPolicyMaster', function() {
|
||||
}
|
||||
|
||||
|
||||
if (res) {
|
||||
if (res.data) {
|
||||
|
||||
//special conditions fields
|
||||
let gpaJsonObjectForSpecialCondition = JSON.parse(res.data);
|
||||
Object.keys(gpaJsonObjectForSpecialCondition).forEach(function(key) {
|
||||
if (key.includes("other_special_condition_label") || key.includes(
|
||||
"other_special_condition_input")) {
|
||||
if (key.includes("other_special_condition_label")) {
|
||||
let otherTermsJsonObjectSpecialCondition = JSON.parse(res.data);
|
||||
Object.keys(otherTermsJsonObjectSpecialCondition).forEach(function(key) {
|
||||
if (key.includes("special_condition_label") || key.includes(
|
||||
"special_condition_input")) {
|
||||
if (key.includes("special_condition_label")) {
|
||||
|
||||
for (let index = 0; index <
|
||||
gpaJsonObjectForSpecialCondition[key].length; index++) {
|
||||
otherTermsJsonObjectSpecialCondition[key].length; index++) {
|
||||
specialConditionForOthers();
|
||||
}
|
||||
}
|
||||
@ -280,26 +303,55 @@ $('body').on('click', '.btnPolicyMaster', function() {
|
||||
if (elements) {
|
||||
elements.forEach((element, index) => {
|
||||
|
||||
if (gpaJsonObjectForSpecialCondition[key][
|
||||
if (otherTermsJsonObjectSpecialCondition[key][
|
||||
index
|
||||
] == undefined) {
|
||||
element.value = " ";
|
||||
} else {
|
||||
element.value =
|
||||
gpaJsonObjectForSpecialCondition[key][
|
||||
otherTermsJsonObjectSpecialCondition[key][
|
||||
index
|
||||
];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!key.startsWith("special_condition") && !key.startsWith('multiple_sum_insured') && !key.startsWith("sum_insured") && !key.startsWith("enrollment_display_key") ) {
|
||||
|
||||
termsHTML = `
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-1">
|
||||
<input type="checkbox" style="margin-top: 12px" name="${key}_display"
|
||||
id="${key}_display" class="unchecked" checked>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label for="${key}">${beautifyString(key)}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="${key}" id="${key}" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
$("#append_html_for_other_policy_terms").append(termsHTML);
|
||||
}
|
||||
|
||||
if (key.includes("multiple_sum_insured")) {
|
||||
gpaJsonObjectForSpecialCondition[key].forEach((value, index) => {
|
||||
appendOtherSIAddMore(value);
|
||||
});
|
||||
|
||||
const value = otherTermsJsonObjectSpecialCondition[key];
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(item => appendOtherSIAddMore(item));
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
Object.values(value).forEach(item => appendOtherSIAddMore(item));
|
||||
}
|
||||
// else if (typeof value === 'string') {
|
||||
// appendOtherSIAddMore(value); // Use directly, no loop
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@ -347,6 +399,10 @@ $('body').on('click', '.btnPolicyMaster', function() {
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
appendPolicyTermsHTML(policy_type_id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -367,6 +423,11 @@ $('body').on('click', '.btnPolicyMaster', function() {
|
||||
|
||||
}
|
||||
|
||||
if(policy_type_id > 7) {
|
||||
|
||||
$("#sumInsuredDiv").empty();
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -395,11 +456,11 @@ function specialConditionForOthers(count = 0) {
|
||||
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
|
||||
|
||||
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
|
||||
<input class="form-control" name="other_special_condition_label[]" id="other_special_condition_label[]" style="position: relative;right: 15px;">
|
||||
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 0px;">
|
||||
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
|
||||
</label>
|
||||
|
||||
<input type="text" name="other_special_condition_input[]" id="other_special_condition_input[]" class="form-control s special_condition_input[]">
|
||||
<input type="text" name="special_condition_input[]" id="special_condition_input[]" class="form-control s special_condition_input[]">
|
||||
</div>`;
|
||||
console.log($(this));
|
||||
$('.other_special_condition').each(function() {
|
||||
@ -467,29 +528,29 @@ function appendPolicyTermsHTML(policy_type) {
|
||||
|
||||
if (policy_type == 7) {
|
||||
|
||||
termsHTML = `
|
||||
|
||||
|
||||
// <div class="row" style="margin-bottom: 10px;">
|
||||
// <div class="col-md-6">
|
||||
// <label for="sumInsured">Sum Insured</label>
|
||||
// </div>
|
||||
// <div class="col-md-4">
|
||||
// <input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
|
||||
// </div>
|
||||
// <div class="col-md-2" style="position: relative;left: 88px;">
|
||||
// <button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
|
||||
// </div>
|
||||
// <div class="col-md-6">
|
||||
// </div>
|
||||
// <div class="col-md-6">
|
||||
// <div id='numberToWordOthers' class="text-danger-2" ></div>
|
||||
// </div>
|
||||
// </div>
|
||||
|
||||
// <div id="sum_insured_add_more" ></div>
|
||||
termsHTML = `
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-6">
|
||||
<label for="sumInsured">Sum Insured</label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
|
||||
</div>
|
||||
<div class="col-md-2" style="position: relative;left: 88px;">
|
||||
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div id='numberToWordOthers' class="text-danger-2" ></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sum_insured_add_more" ></div>
|
||||
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-6">
|
||||
<label for="totalSumInsured">Policy Type</label>
|
||||
@ -585,29 +646,30 @@ function appendPolicyTermsHTML(policy_type) {
|
||||
|
||||
} else if (policy_type == 6) {
|
||||
|
||||
termsHTML = `
|
||||
|
||||
|
||||
// <div class="row" style="margin-bottom: 10px;">
|
||||
// <div class="col-md-6">
|
||||
// <label for="sumInsured">Sum Insured</label>
|
||||
// </div>
|
||||
// <div class="col-md-4" >
|
||||
// <input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
|
||||
// </div>
|
||||
// <div class="col-md-2" style="position: relative;left: 88px;">
|
||||
// <button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
|
||||
// </div>
|
||||
// <div class="col-md-6">
|
||||
// </div>
|
||||
// <div class="col-md-6">
|
||||
// <div id='numberToWordOthers' class="text-danger-2" ></div>
|
||||
// </div>
|
||||
// </div>
|
||||
|
||||
// <div id="sum_insured_add_more" ></div>
|
||||
termsHTML = `
|
||||
|
||||
<div class="form-group EDLI">
|
||||
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-6">
|
||||
<label for="sumInsured">Sum Insured</label>
|
||||
</div>
|
||||
<div class="col-md-4" >
|
||||
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
|
||||
</div>
|
||||
<div class="col-md-2" style="position: relative;left: 88px;">
|
||||
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div id='numberToWordOthers' class="text-danger-2" ></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sum_insured_add_more" ></div>
|
||||
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-6">
|
||||
<label for="totalSumInsured">Existing Insurer</label>
|
||||
@ -676,10 +738,12 @@ function appendOtherSIAddMore(data = null) {
|
||||
|
||||
const addMoreContainer = document.getElementById('sum_insured_add_more');
|
||||
|
||||
// addMoreContainer.innerHTML = ''; // Clear previous content if needed
|
||||
|
||||
console.log(addMoreContainer)
|
||||
|
||||
const html = `
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label for="sumInsured">Additional Sum Insured</label>
|
||||
</div>
|
||||
@ -699,4 +763,13 @@ function appendOtherSIAddMore(data = null) {
|
||||
|
||||
addMoreContainer.insertAdjacentHTML('beforeend', html);
|
||||
}
|
||||
|
||||
function beautifyString(str) {
|
||||
return str
|
||||
.split('_') // Split the string by underscores
|
||||
.map(word =>
|
||||
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() // Capitalize each word
|
||||
)
|
||||
.join(' '); // Join with spaces instead of underscores
|
||||
}
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -475,75 +475,75 @@ $('.close').click(function() {
|
||||
});
|
||||
|
||||
|
||||
$('input[name="burnExpenses"]').change(function() {
|
||||
// $('input[name="burnExpenses"]').change(function() {
|
||||
|
||||
console.log($(this).val());
|
||||
// console.log($(this).val());
|
||||
|
||||
if ($(this).val() == '1') {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "");
|
||||
// if ($(this).val() == '1') {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "");
|
||||
|
||||
} else {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "none");
|
||||
}
|
||||
});
|
||||
// } else {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "none");
|
||||
// }
|
||||
// });
|
||||
|
||||
$('input[name="compassionateVisitExpenses"]').change(function() {
|
||||
// $('input[name="compassionateVisitExpenses"]').change(function() {
|
||||
|
||||
console.log($(this).val());
|
||||
// console.log($(this).val());
|
||||
|
||||
if ($(this).val() == '1') {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "");
|
||||
// if ($(this).val() == '1') {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "");
|
||||
|
||||
} else {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "none");
|
||||
}
|
||||
});
|
||||
// } else {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "none");
|
||||
// }
|
||||
// });
|
||||
|
||||
$('input[name="carriageOfDeadBody"]').change(function() {
|
||||
// $('input[name="carriageOfDeadBody"]').change(function() {
|
||||
|
||||
console.log($(this).val());
|
||||
// console.log($(this).val());
|
||||
|
||||
if ($(this).val() == '1') {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "");
|
||||
// if ($(this).val() == '1') {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "");
|
||||
|
||||
} else {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "none");
|
||||
}
|
||||
});
|
||||
// } else {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "none");
|
||||
// }
|
||||
// });
|
||||
|
||||
$('input[name="ambulanceCharges"]').change(function() {
|
||||
// $('input[name="ambulanceCharges"]').change(function() {
|
||||
|
||||
console.log($(this).val());
|
||||
// console.log($(this).val());
|
||||
|
||||
if ($(this).val() == '1') {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "");
|
||||
// if ($(this).val() == '1') {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "");
|
||||
|
||||
} else {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "none");
|
||||
}
|
||||
});
|
||||
// } else {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "none");
|
||||
// }
|
||||
// });
|
||||
|
||||
$('input[name="brokenBoneExpenses"]').change(function() {
|
||||
// $('input[name="brokenBoneExpenses"]').change(function() {
|
||||
|
||||
console.log($(this).val());
|
||||
// console.log($(this).val());
|
||||
|
||||
if ($(this).val() == '1') {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "");
|
||||
// if ($(this).val() == '1') {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "");
|
||||
|
||||
} else {
|
||||
var element = $(this).parent().parent().next()[0];
|
||||
$(element).css("display", "none");
|
||||
}
|
||||
});
|
||||
// } else {
|
||||
// var element = $(this).parent().parent().next()[0];
|
||||
// $(element).css("display", "none");
|
||||
// }
|
||||
// });
|
||||
|
||||
$("#policyGPATerms").submit(function(event) {
|
||||
|
||||
@ -784,6 +784,7 @@ $('body').on('click', '.btnPolicyMaster', function() {
|
||||
.next()[0];
|
||||
$(element).css("display", "");
|
||||
}
|
||||
disableUnwantedTermsforGPA(jsonObject);
|
||||
|
||||
Object.keys(jsonObject).forEach(function(key) {
|
||||
|
||||
@ -853,6 +854,34 @@ $('body').on('click', '.btnPolicyMaster', function() {
|
||||
|
||||
<script>
|
||||
|
||||
const gpaFields = [
|
||||
'accidentalDeathBenefit',
|
||||
'permanentTotalDisablement',
|
||||
'permanentPartialDisablement',
|
||||
'temporaryTotalDisablementBenefit',
|
||||
'medical_expenses_medical_extension',
|
||||
'opd_treatment_cover',
|
||||
'ambulanceCharges',
|
||||
'repatriation_of_mortal_remains',
|
||||
'childrenEducationWelfareFund',
|
||||
'terrorism',
|
||||
'worldwideCover',
|
||||
'family_transportation_benefits',
|
||||
'fractures_dislocation_burns',
|
||||
'coma',
|
||||
'carriageOfDeadBody',
|
||||
'compassionateVisitExpenses',
|
||||
'travel_expenses_for_medical_treatment',
|
||||
'daily_cash_allowance',
|
||||
'artifical_limb_and_prosthesis',
|
||||
'animalSnakeInsectBite',
|
||||
'air_ambulance',
|
||||
'gpa_special_condition_label',
|
||||
'gpa_special_condition_input',
|
||||
'multiple_sum_insured'
|
||||
];
|
||||
|
||||
|
||||
document.getElementById('gpaButtonSpecialCondition').addEventListener('click', function(event) {
|
||||
|
||||
console.log('specialConditionForGPA callback clicked')
|
||||
@ -1040,4 +1069,37 @@ function processJsonObject2(jsonObject) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disableUnwantedTermsforGPA(jsonObject) {
|
||||
// alert("Disabling unwanted terms");
|
||||
|
||||
gpaFields.forEach(function(key) {
|
||||
// If key NOT in jsonObject, then hide and disable its associated elements
|
||||
if (!jsonObject.hasOwnProperty(key)) {
|
||||
const elements = document.getElementsByName(key);
|
||||
|
||||
elements.forEach(element => {
|
||||
element.style.display = "none";
|
||||
element.disabled = true;
|
||||
|
||||
const label = document.querySelector(`label[for="${element.id}"]`);
|
||||
if (label) {
|
||||
label.style.display = "none";
|
||||
}
|
||||
|
||||
const displayElement = document.getElementById(`${element.id}_display`);
|
||||
if (displayElement) {
|
||||
displayElement.checked = false;
|
||||
displayElement.disabled = true;
|
||||
displayElement.style.display = "none";
|
||||
}
|
||||
|
||||
const rowDiv = element.closest('.row');
|
||||
if (rowDiv) {
|
||||
rowDiv.style.display = "none";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@ -108,6 +108,7 @@
|
||||
onchange="addGridHTML(this)" required>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" id="hidden_unit" />
|
||||
|
||||
<div class="form-group col-md-6"
|
||||
style="position: relative; left: 45px; display:none" id="premium_type">
|
||||
@ -385,6 +386,14 @@ $('body').on('click', '.btnPolicyModel', function()
|
||||
// console.log('rack rate responce.premium data', res.premiumData)
|
||||
// console.log('rack rate responce.premium data parsed', JSON.parse(res.premiumData));
|
||||
|
||||
branch_units = JSON.parse(res.branch_units) ?? [];
|
||||
|
||||
if (branch_units && branch_units.length == 1) {
|
||||
|
||||
$("#hidden_unit").val(branch_units[0]);
|
||||
console.log('unit', branch_units[0]);
|
||||
$("#gpa_unit1").val(branch_units[0]);
|
||||
}
|
||||
var data_for_the_rack_rate = JSON.parse(res.premiumData) ?? [];
|
||||
var groupedData = groupByRackRateName(data_for_the_rack_rate) ?? [];
|
||||
rarc_rate_json_array.push(res.jsonArray);
|
||||
@ -673,8 +682,12 @@ $('#grid').change(function()
|
||||
|
||||
if(unit_length == 1 || unit_length == 0){
|
||||
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv').find('input').removeAttr('required');
|
||||
// $('.unitDiv').hide();
|
||||
// $('.unitDiv').find('input').removeAttr('required');
|
||||
setTimeout(() => {
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv input').removeAttr('required');
|
||||
}, 1000); // Run after DOM updates
|
||||
}else{
|
||||
$('.unitDiv').show();
|
||||
$('.unitDiv').find('input').attr('required', true);
|
||||
@ -734,6 +747,9 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
|
||||
var id_var = 'grid_';
|
||||
|
||||
var default_unit = $('#hidden_unit').val();
|
||||
|
||||
|
||||
var dataIdValue = ''
|
||||
if (event === false) {
|
||||
var dataIdValue = ui_type
|
||||
@ -801,14 +817,14 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
|
||||
<div id="si_or_bp_sum_insure" class="form-row">
|
||||
|
||||
<div class="form-row col-md-4" style="margin-left: 346px; margin-top: -114px;">
|
||||
<label for="mobile">Premium Multiplier<span class="text-danger">*</span></label>
|
||||
<div class="form-row col-md-4" style="margin-left: 381px; margin-top: -114px;">
|
||||
<label for="mobile" style = "margin-bottom: -10px;margin-top: 17px;">Premium Multiplier<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.multiplier : '') : ''}" type="text" class="form-control" placeholder="Multiplier" name="gpa_sum_multiplier" id="gpa_sum_multiplier" onchange="gpaSumInsureMultiplier(this)" required>
|
||||
</div>
|
||||
<div class="form-row" style="width:101%;padding: 10px;" id="removeChild_${Count}">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.unit : '') : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.unit : default_unit) : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="">
|
||||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||||
@ -1341,8 +1357,13 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
}
|
||||
|
||||
if(unit_length == 1 || unit_length == 0){
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv').find('input').removeAttr('required');
|
||||
// alert("Hello World");
|
||||
// $('.unitDiv').hide();
|
||||
// $('.unitDiv').find('input').removeAttr('required');
|
||||
setTimeout(() => {
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv input').removeAttr('required');
|
||||
}, 1000); // Run after DOM updates
|
||||
}else{
|
||||
$('.unitDiv').show();
|
||||
$('.unitDiv').find('input').attr('required', true);
|
||||
@ -1399,7 +1420,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
||||
html = `<div class="form-row gpa_sum_insure_remove" style="width:101%" id="removeChild_${Count}">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||||
<input value="${data !== false && data !== undefined && data !== default_unit ? data.unit : default_unit}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="">
|
||||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||||
@ -1840,8 +1861,12 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
||||
// Count++
|
||||
|
||||
if(unit_length == 1 || unit_length == 0){
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv').find('input').removeAttr('required');
|
||||
// $('.unitDiv').hide();
|
||||
// $('.unitDiv').find('input').removeAttr('required');
|
||||
setTimeout(() => {
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv input').removeAttr('required');
|
||||
}, 1000); // Run after DOM updates
|
||||
}else{
|
||||
$('.unitDiv').show();
|
||||
$('.unitDiv').find('input').attr('required', true);
|
||||
@ -2770,7 +2795,7 @@ function si_orbp_change_function()
|
||||
$('#gpa_sum_multiplier').attr('required', true);
|
||||
$('#gpa_sum_si').attr('required', true);
|
||||
$('#gpa_sum_premium').attr('required', true);
|
||||
$('#gpa_unit1').attr('required', true);
|
||||
$('#gpa_unit1').attr('required', false);
|
||||
|
||||
var gridContentInput = $('#grid_content_input');
|
||||
|
||||
@ -3936,8 +3961,12 @@ function appendFourthAndSixthRackRate(data = null, uniqueId = null)
|
||||
grid_container.insertAdjacentHTML('beforeend', grid_html);
|
||||
|
||||
if(unit_length == 1 || unit_length == 0){
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv').find('input').removeAttr('required');
|
||||
// $('.unitDiv').hide();
|
||||
// $('.unitDiv').find('input').removeAttr('required');
|
||||
setTimeout(() => {
|
||||
$('.unitDiv').hide();
|
||||
$('.unitDiv input').removeAttr('required');
|
||||
}, 1000); // Run after DOM updates
|
||||
}else{
|
||||
$('.unitDiv').show();
|
||||
$('.unitDiv').find('input').attr('required', true);
|
||||
|
||||
@ -119,9 +119,10 @@
|
||||
<input type="hidden" name="client_id" id="client_id_for_edit">
|
||||
<input type="hidden" name="insurer_id" id="insurer_id">
|
||||
<input type="hidden" name="cd_ac_no" id="cd_ac_no">
|
||||
<input type="hidden" name="cd_ac_pk" id="cd_ac_pk">
|
||||
<input type="hidden" name="ct_type" id="ct_type">
|
||||
<input type="hidden" name="" id="bro_payable_by">
|
||||
<input type="hidden" name="" id="cop_yes">
|
||||
<input type="hidden" name="bro_payable_by" id="bro_payable_by">
|
||||
<input type="hidden" name="cop_yes" id="cop_yes">
|
||||
|
||||
|
||||
<!-- Client Row -->
|
||||
@ -152,7 +153,7 @@
|
||||
<label for="client_branch">Client<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_id" name="client_id" required>
|
||||
<option value="">Select Client</option>
|
||||
<option value="add_client"> + Add Client</option>
|
||||
<!-- <option value="add_client"> + Add Client</option> -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -310,6 +311,15 @@
|
||||
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="switch" style="position: relative;top: 32px;left: 20px;">
|
||||
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
|
||||
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;">Make Entry in CD <i class="fa fa-info-circle" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i></label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
@ -550,7 +560,10 @@ $(document).ready(function(){
|
||||
if(policyListByClient != '') {
|
||||
// console.log(branch_list[client_id]);
|
||||
let data = policyListByClient[client_id];
|
||||
if (data) {
|
||||
appendPolicies(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -585,6 +598,14 @@ $(document).ready(function(){
|
||||
var cd_ac_no = $(this).find('option:selected').attr('data-cd');
|
||||
var start_date = $(this).find('option:selected').attr('data-sd');
|
||||
var end_date = $(this).find('option:selected').attr('data-ed');
|
||||
var policy_type_id = $(this).find('option:selected').attr('data-ptid');
|
||||
|
||||
if(policy_type_id == 1 || policy_type_id == 2 || policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5 || policy_type_id == 6 || policy_type_id == 7){
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false)
|
||||
}else{
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',false)
|
||||
}
|
||||
|
||||
|
||||
// console.log('client_id', client_id);
|
||||
// console.log('client_policy_id', client_policy_id);
|
||||
@ -596,7 +617,7 @@ $(document).ready(function(){
|
||||
$('#policy_no').val(policy_no);
|
||||
$('#insurer_id').val(insurer);
|
||||
$('#tpa').val(tpa).change();
|
||||
$('#cd_ac_no').val(cd_ac_no);
|
||||
// $('#cd_ac_no').val(cd_ac_no);
|
||||
$('#policy_start_date').val(start_date);
|
||||
$('#policy_end_date').val(end_date);
|
||||
|
||||
@ -619,6 +640,9 @@ $(document).ready(function(){
|
||||
if(res.status == true){
|
||||
if(res.data.length > 0){
|
||||
|
||||
$('#ct_type').val(2)
|
||||
$('#cd_ac_pk').val(res.is_copay_yes.cd_ac_pk);
|
||||
$('#cd_ac_no').val(res.cd_master_data.cd_ac_no ?? "");
|
||||
$('#bro_payable_by').val(res.data[0].bro_payable_by)
|
||||
|
||||
if(res.is_copay_yes && res.is_copay_yes.co_share == 1){
|
||||
@ -631,12 +655,19 @@ $(document).ready(function(){
|
||||
|
||||
populateTable(res.data);
|
||||
|
||||
$('#btnSubmit').prop('disabled', false).data('disable', false);
|
||||
|
||||
}else{
|
||||
addInsurerColumn()
|
||||
$('#ct_type').val(1)
|
||||
// addInsurerColumn()
|
||||
toastr.warning("There is no policy inception data.", 'WARNING!');
|
||||
$('#btnSubmit').prop('disabled', true).data('disable', true);
|
||||
}
|
||||
}else{
|
||||
addInsurerColumn()
|
||||
$('#ct_type').val(1)
|
||||
// addInsurerColumn()
|
||||
toastr.warning(res.message, 'WARNING!');
|
||||
$('#btnSubmit').prop('disabled', true).data('disable', true);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
@ -751,7 +782,7 @@ $("#endorsement_form_id").submit(function(event) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('inception_form_response', res)
|
||||
console.log('ENDORSEMENT FOR SUBMIT RESPONSE : ', res);
|
||||
|
||||
if (res.status == true) {
|
||||
toastr.success(res.message, 'Success');
|
||||
@ -825,8 +856,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) {
|
||||
|
||||
@ -914,6 +946,9 @@ function getPolicyTransactionDataForEndorsementEdit(input){
|
||||
$('#last_action_date').val(res.data.last_action_date);
|
||||
$('#install_due_date').val(res.data.install_due_date);
|
||||
$('#bro_payable_by').val(res.data.bro_payable_by);
|
||||
$('#cd_ac_pk').val(res.data.cd_ac_pk);
|
||||
$('#cd_ac_no').val(res.data.cd_ac_no);
|
||||
$('#ct_type').val(res.data.ct_type);
|
||||
|
||||
if (res.data.policy_with_corr == 1) {
|
||||
$('#policy_with_corr').prop('checked', true);
|
||||
@ -921,6 +956,12 @@ function getPolicyTransactionDataForEndorsementEdit(input){
|
||||
$('#policy_with_corr').prop('checked', false);
|
||||
}
|
||||
|
||||
if (res.data.is_cd_reduce_from_bds == 1) {
|
||||
$('#is_cd_reduce_from_bds').prop('checked', true).prop('checked', false);
|
||||
} else {
|
||||
$('#is_cd_reduce_from_bds').prop('checked', false);
|
||||
}
|
||||
|
||||
if (res.data.action_type == 'policy_instalment') {
|
||||
$('.install_due_date_div').show()
|
||||
}else{
|
||||
@ -937,6 +978,13 @@ function getPolicyTransactionDataForEndorsementEdit(input){
|
||||
addInsurerColumn();
|
||||
}
|
||||
|
||||
if(res.data.policy_type_id == 1 || res.data.policy_type_id == 2 || res.data.policy_type_id == 3 || res.data.policy_type_id == 4 || res.data.policy_type_id == 5 || res.data.policy_type_id == 6 || res.data.policy_type_id == 7){
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false);
|
||||
}else{
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',false);
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
console.log('No data found');
|
||||
}
|
||||
@ -1769,7 +1817,7 @@ function addInsurerColumn() {
|
||||
break;
|
||||
}
|
||||
|
||||
}else if(team_id.includes('3')){
|
||||
}else if(team_id.includes('3') || team_id.includes('8')){
|
||||
|
||||
switch(index) {
|
||||
case 0: // Insurer selection
|
||||
@ -2155,7 +2203,7 @@ function populateTable(dataArray, status = false) {
|
||||
cell.find('input[type="hidden"]').val(status ? data.id : '');
|
||||
break;
|
||||
}
|
||||
}else if(team_id.includes('3')){
|
||||
}else if(team_id.includes('3') || team_id.includes('8')){
|
||||
switch (rowIndex) {
|
||||
case 0: // Insurer selection
|
||||
cell.find('select').val(insurer);
|
||||
@ -2275,9 +2323,13 @@ function getURLParamsForReport()
|
||||
|
||||
function onlyNumbers(event)
|
||||
{
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
||||
var charcode = event.which || event.keyCode;
|
||||
|
||||
// Allow: 0-9 (48-57), dot (46), minus (45)
|
||||
if ((charcode >= 48 && charcode <= 57) || charcode === 46 || charcode === 45) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -445,10 +445,11 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
</script>
|
||||
<script>
|
||||
|
||||
var client_list = ''; // local variable for storing the client branch list
|
||||
var branch_list = ''; // local variable for storing the client branch list
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
var policyListByClient = ''; // local variable for storing the client policy list
|
||||
var client_list = '';
|
||||
var branch_list = '';
|
||||
var policy_list = <?= json_encode($endorsementPolicies) ?>;
|
||||
// console.log("POLICY List",policy_list);
|
||||
var policyListByClient = <?= json_encode($endorsementPolicyListByClient) ?>;
|
||||
var branch_policy = '';
|
||||
var unit_list = '';
|
||||
|
||||
@ -607,8 +608,8 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
if(res.status == true){
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
policyListByClient = res.policyListByClient;
|
||||
// policy_list = res.policy_data;
|
||||
// policyListByClient = res.policyListByClient;
|
||||
client_list = res.client_data;
|
||||
unit_list = res.unit_data;
|
||||
appendClients(res.client_data);
|
||||
@ -633,10 +634,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
text: 'Select Client'
|
||||
}));
|
||||
|
||||
$('#client_id').append($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
// $('#client_id').append($('<option>', {
|
||||
// value: 'add_client',
|
||||
// text: '+ Add Client'
|
||||
// }));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
@ -674,6 +675,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
function appendPolicies(data)
|
||||
{
|
||||
if (!data) {
|
||||
|
||||
toastr.warning("There are no policies in Inception for the selected client and branch.");
|
||||
}
|
||||
console.log('appendPolicies', data);
|
||||
console.log('appendPolicies', $('#client_policy_id'));
|
||||
|
||||
@ -698,6 +703,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
'data-itp' : item.itp,
|
||||
'data-bap' : item.bap,
|
||||
'data-tpa' : item.tpa_branch_id + '-' + item.tpa_id,
|
||||
'data-ptid' : item.policy_type_id,
|
||||
});
|
||||
$('#client_policy_id').append(option);
|
||||
});
|
||||
|
||||
@ -123,6 +123,24 @@
|
||||
color: white !important;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
:disabled {
|
||||
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="tab-pane fade active show" id="form">
|
||||
@ -422,6 +440,16 @@
|
||||
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="switch" style="position: relative;top: 32px;left: 20px;">
|
||||
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
|
||||
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD <i class="fa fa-info-circle info-icon" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-3 current_date" style="display: none;">
|
||||
<label for="bp_igst">Process Start Date</label>
|
||||
<input id="process_start_date" type="text" class="form-control" name="process_start_date" placeholder="DD/MM/YYYY">
|
||||
@ -504,12 +532,14 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="installment">Installment</label>
|
||||
<label for="installment">Installment <i id="infoIcon" class="fas fa-info-circle info-icon" data-toggle="tooltip" title="Click for Installment details" style="margin-left: 5px;"></i></label>
|
||||
<input id="installment" value="" type="text" class="form-control" name="installment">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="installment_data">Installment Data</label>
|
||||
<label for="installment_data">
|
||||
Installment Data
|
||||
</label>
|
||||
<input id="installment_data" class="form-control" name="installment_data">
|
||||
</div>
|
||||
|
||||
@ -779,115 +809,7 @@
|
||||
</div>
|
||||
<!-- end form row -->
|
||||
|
||||
<!-- Client form content modal-->
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">PAN</label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInput(this, 'clients', 'pan')">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Client Type -->
|
||||
<div class="form-row clienttypediv" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||
onkeypress="return onlyNumbers(event)" onchange="validateInput(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="aadhar">Aadhar</label>
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInput(this, 'clients', 'aadhar')">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- branch -->
|
||||
<div class="form-row branchdiv">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
if (isset($entity) && count($entity)) {
|
||||
foreach ($entity as $key => $value) {
|
||||
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" onchange="validateInput(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
<!-- Vehicle form content modal-->
|
||||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
@ -1025,8 +947,220 @@
|
||||
</div>
|
||||
</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">
|
||||
<form id="installmentForm">
|
||||
<div id="dynamicDivFillInfo"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$("#infoIcon").click(function() {
|
||||
var policyTransactionPK = $('#policy_tranction_primarykey').val();
|
||||
getDataForInfo(policyTransactionPK, 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.bds_data);
|
||||
} else {
|
||||
// toastr.warning("Data not Found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getDataForInfo (policyTransactionPK,callback) {
|
||||
// alert(policyTransactionPK)
|
||||
$.ajax({
|
||||
url: "<?= base_url('policy_tranction/getMoreInfo') ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
pt_id: policyTransactionPK
|
||||
},
|
||||
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) {
|
||||
|
||||
const items = Array.isArray(data) ? data : data?.bds_data || [];
|
||||
|
||||
const container = document.getElementById('dynamicDivFillInfo');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (!Array.isArray(items) || items.length === 0) {
|
||||
container.innerHTML = '<p>No data available.</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function(item, index) {
|
||||
// Create .row container
|
||||
const row = document.createElement('div');
|
||||
row.className = 'row mb-3';
|
||||
|
||||
// Hidden input for ID
|
||||
const hiddenId = document.createElement('input');
|
||||
hiddenId.type = 'hidden';
|
||||
hiddenId.name = `installments[${index}][id]`;
|
||||
hiddenId.value = item.id;
|
||||
row.appendChild(hiddenId);
|
||||
|
||||
// Payment Date
|
||||
const paymentCol = document.createElement('div');
|
||||
paymentCol.className = 'col-md-3';
|
||||
|
||||
// Use type="text" for flatpickr
|
||||
const paymentGroup = createEditableInputGroup('Payment Date', 'payment_date', index, '', 'text');
|
||||
paymentCol.appendChild(paymentGroup);
|
||||
row.appendChild(paymentCol);
|
||||
|
||||
// Flatpickr target
|
||||
const paymentInput = paymentGroup.querySelector('input');
|
||||
|
||||
// Convert DB date to d-m-Y (Flatpickr display format)
|
||||
if (item.payment_date) {
|
||||
|
||||
flatpickr(paymentInput, {
|
||||
dateFormat: "d-m-Y",
|
||||
defaultDate: item.payment_date,
|
||||
allowInput: true
|
||||
});
|
||||
}
|
||||
|
||||
// Installment Amount
|
||||
const amountCol = document.createElement('div');
|
||||
amountCol.className = 'col-md-3';
|
||||
amountCol.appendChild(createEditableInputGroup('Installment Amount', 'installment_amount', index, item.installment_amount, 'number'));
|
||||
row.appendChild(amountCol);
|
||||
|
||||
// UTR Number
|
||||
const utrCol = document.createElement('div');
|
||||
utrCol.className = 'col-md-3';
|
||||
utrCol.appendChild(createEditableInputGroup('UTR Number', 'utr_no', index, item.utr_no, 'text'));
|
||||
row.appendChild(utrCol);
|
||||
|
||||
container.appendChild(row);
|
||||
});
|
||||
|
||||
// Add submit button at the end
|
||||
const submitRow = document.createElement('div');
|
||||
submitRow.className = 'row';
|
||||
|
||||
const submitCol = document.createElement('div');
|
||||
submitCol.className = 'col-md-12 text-end d-flex align-items-center justify-content-end';
|
||||
|
||||
const submitBtn = document.createElement('button');
|
||||
submitBtn.type = 'submit';
|
||||
submitBtn.id = 'submitInstallments';
|
||||
submitBtn.className = 'btn btn-primary';
|
||||
submitBtn.innerText = 'Save Installments';
|
||||
|
||||
submitCol.appendChild(submitBtn);
|
||||
submitRow.appendChild(submitCol);
|
||||
container.appendChild(submitRow);
|
||||
}
|
||||
|
||||
$(document).on('click', '#submitInstallments', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const installments = [];
|
||||
|
||||
$('#dynamicDivFillInfo .row').each(function () {
|
||||
const row = $(this);
|
||||
const installment = {};
|
||||
|
||||
const id = row.find('input[name*="[id]"]').val();
|
||||
const payment_date = row.find('input[name*="[payment_date]"]').val();
|
||||
const installment_amount = row.find('input[name*="[installment_amount]"]').val();
|
||||
const utr_no = row.find('input[name*="[utr_no]"]').val();
|
||||
|
||||
// Ignore empty rows
|
||||
if (payment_date && installment_amount && utr_no) {
|
||||
installment.id = id;
|
||||
installment.payment_date = payment_date;
|
||||
installment.installment_amount = installment_amount;
|
||||
installment.utr_no = utr_no;
|
||||
installments.push(installment);
|
||||
}
|
||||
});
|
||||
|
||||
if (installments.length === 0) {
|
||||
toastr.warning("No valid installment data to save.");
|
||||
return;
|
||||
}
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
$.ajax({
|
||||
url: "<?= base_url('policy_tranction/saveInstallment') ?>",
|
||||
type: "POST",
|
||||
data: { installments },
|
||||
success: function (response) {
|
||||
if (response.status) {
|
||||
toastr.success("Installments saved successfully!");
|
||||
$('#moreInfoModal').modal('hide');
|
||||
} else {
|
||||
toastr.error(response.message || "Save failed.");
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
console.error(xhr.responseText);
|
||||
toastr.error("Server error.");
|
||||
}
|
||||
});
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
|
||||
function createEditableInputGroup(labelText, fieldName, index, value, type) {
|
||||
var group = document.createElement('div');
|
||||
group.className = 'form-group mb-2';
|
||||
|
||||
var label = document.createElement('label');
|
||||
label.innerText = labelText;
|
||||
|
||||
var input = document.createElement('input');
|
||||
input.type = type;
|
||||
input.className = 'form-control';
|
||||
input.name = `installments[${index}][${fieldName}]`;
|
||||
input.value = value;
|
||||
|
||||
group.appendChild(label);
|
||||
group.appendChild(input);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
var team_id = [];
|
||||
let isClientFormSubmitting = false;
|
||||
var insurer_count_array = [];
|
||||
@ -1181,10 +1315,12 @@ $(document).ready(function(){
|
||||
$('#name').prop('required', false);
|
||||
$('#mobile').prop('required', false);
|
||||
$('#gst').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
|
||||
|
||||
$('#dob').prop('required', true);
|
||||
$('#phone').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
$('#email2').prop('required', true);
|
||||
$('#aadhar').prop('required', true);
|
||||
|
||||
} else {
|
||||
@ -1198,10 +1334,11 @@ $(document).ready(function(){
|
||||
$('#name').prop('required', true);
|
||||
$('#mobile').prop('required', true);
|
||||
$('#gst').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
|
||||
$('#dob').prop('required', false);
|
||||
$('#phone').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
$('#email2').prop('required', false);
|
||||
$('#aadhar').prop('required', false);
|
||||
|
||||
}
|
||||
@ -1352,6 +1489,11 @@ $(document).ready(function(){
|
||||
$('#tpa_div').show();
|
||||
}
|
||||
|
||||
if(value == 1 || value == 2 || value == 3 || value == 4 || value == 5 || value == 6 || value == 7){
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false)
|
||||
}else{
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',false)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -1527,12 +1669,19 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
$('#tpa_div').show();
|
||||
}
|
||||
|
||||
if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
|
||||
$('#hide_file_upload').show();
|
||||
if(policy_type_id_for_hide_tpa == 1 || policy_type_id_for_hide_tpa == 2 || policy_type_id_for_hide_tpa == 3 || policy_type_id_for_hide_tpa == 4 || policy_type_id_for_hide_tpa == 5 || policy_type_id_for_hide_tpa == 6 || policy_type_id_for_hide_tpa == 7){
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false)
|
||||
}else{
|
||||
$('#hide_file_upload').hide();
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',false)
|
||||
}
|
||||
|
||||
// if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
|
||||
// $('#hide_file_upload').show();
|
||||
// }else{
|
||||
// $('#hide_file_upload').hide();
|
||||
// }
|
||||
$('#hide_file_upload').show();
|
||||
|
||||
if (res.data.master_policy_type_id) {
|
||||
$('#policy_type_id').val(res.data.master_policy_type_id).change();
|
||||
} else {
|
||||
@ -1744,6 +1893,12 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
$('#policy_with_corr').prop('checked', false);
|
||||
}
|
||||
|
||||
if (res.data.is_cd_reduce_from_bds == 1) {
|
||||
$('#is_cd_reduce_from_bds').prop('checked', true).prop('checked', false);
|
||||
} else {
|
||||
$('#is_cd_reduce_from_bds').prop('checked', false);
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('No data found');
|
||||
}
|
||||
@ -3080,12 +3235,11 @@ $("#inception_form_id").submit(function(event) {
|
||||
$('#policy_tranction_primarykey_for_file_upload').val(res.pt_id);
|
||||
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
|
||||
|
||||
if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
|
||||
$('#hide_file_upload').show();
|
||||
}else{
|
||||
$('#hide_file_upload').hide();
|
||||
}
|
||||
|
||||
//if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
|
||||
// $('#hide_file_upload').show();
|
||||
//}else{
|
||||
// $('#hide_file_upload').hide();
|
||||
//}
|
||||
$('#client_id_for_vehicle_file_upload').val(res.data.client_id);
|
||||
$('#vehicle_id_for_file_upload').val(res.data.vehicle_id);
|
||||
|
||||
@ -3122,108 +3276,108 @@ $("#inception_form_id").submit(function(event) {
|
||||
});
|
||||
});
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
// $("#client_form").submit(function(event) {
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
// let form_type = $(this).data('id') || 0;
|
||||
|
||||
console.log('onsubmit event', this)
|
||||
console.log('onsubmit event get data value',form_type)
|
||||
console.log('client_type', $('#client_type').val());
|
||||
// console.log('onsubmit event', this)
|
||||
// console.log('onsubmit event get data value',form_type)
|
||||
// console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
// event.preventDefault();
|
||||
|
||||
|
||||
$('#aadhar').attr('data-parsley-required', 'false');
|
||||
$('#aadhar').removeAttr('required');
|
||||
// $('#aadhar').attr('data-parsley-required', 'false');
|
||||
// $('#aadhar').removeAttr('required');
|
||||
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
// isClientFormSubmitting = true;
|
||||
// var isValid = $('#client_form').parsley().validate();
|
||||
// if (!isValid) {
|
||||
// console.log('Form is Empty', 'Warning');
|
||||
// return ;
|
||||
// }
|
||||
|
||||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
// form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
// $('.loader').fadeIn();
|
||||
// $('.loader-mask').fadeIn();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
console.log('client_type:', client_type);
|
||||
// var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
// console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
// //FORM Data
|
||||
// var formData = new FormData($('#client_form')[0]);
|
||||
// formData.append('client_type', client_type);
|
||||
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
// $.ajax({
|
||||
// data:formData,
|
||||
// url: form_action,
|
||||
// type: "POST",
|
||||
// dataType: 'json',
|
||||
// processData: false,
|
||||
// contentType: false,
|
||||
// success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('create_Client_With_Minimal_Data', res)
|
||||
// console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
// if(res.status == true){
|
||||
// getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
// if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
$('#client_id').val(res.client_id).change();
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
// setTimeout(function(){
|
||||
// $('#client_id').val(res.client_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#client_branch_id').val(res.branch_id).change();
|
||||
// }, 1000)
|
||||
// }, 2000)
|
||||
|
||||
}else{
|
||||
// }else{
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#owner').val(res.client_id).change();
|
||||
// $('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
// }, 2000)
|
||||
// }
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
// toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
// }else{
|
||||
// toastr.error(res.message, 'Error');
|
||||
// }
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
// $('#client_form')[0].reset();
|
||||
// $('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
// if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
// myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
// $('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
}
|
||||
// // Load form data into #vehicle_form from localStorage
|
||||
// setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
// }
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
// isClientFormSubmitting = false;
|
||||
// },
|
||||
// error: function (xhr, status, error) {
|
||||
// console.error(xhr.responseText);
|
||||
// console.error(status, error);
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
$("#vehicle_form").submit(function(event) {
|
||||
|
||||
@ -3450,10 +3604,11 @@ $('#client_type').change(function() {
|
||||
$('#name').prop('required', false);
|
||||
$('#mobile').prop('required', false);
|
||||
$('#gst').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
|
||||
$('#dob').prop('required', true);
|
||||
$('#phone').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
$('#email2').prop('required', true);
|
||||
$('#aadhar').prop('required', true);
|
||||
|
||||
$('#owner_branch').prop('required', false);
|
||||
@ -3476,10 +3631,11 @@ $('#client_type').change(function() {
|
||||
$('#name').prop('required', true);
|
||||
$('#mobile').prop('required', true);
|
||||
$('#gst').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
|
||||
$('#dob').prop('required', false);
|
||||
$('#phone').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
$('#email2').prop('required', false);
|
||||
$('#aadhar').prop('required', false);
|
||||
|
||||
$('#owner_branch').prop('required', true);
|
||||
@ -3688,8 +3844,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) {
|
||||
|
||||
@ -3697,15 +3854,15 @@ $('#policy_no').change(function(){
|
||||
|
||||
if(res.status == true){
|
||||
$('#ct_type').val(1);
|
||||
$('#client_policy_id').val(res.data.client_policy_id);
|
||||
$('#client_policy_id').val(res.data.id);
|
||||
$('#policy_start_date').val(res.data.policy_start_date);
|
||||
$('#policy_end_date').val(res.data.policy_end_date);
|
||||
$('#tpa').val(res.data.tpa_branch_id+'-'+res.data.tpa_id).select2();
|
||||
}else{
|
||||
$('#ct_type').val(2);
|
||||
$('#client_policy_id').val();
|
||||
$('#policy_start_date').val();
|
||||
$('#policy_end_date').val();
|
||||
$('#client_policy_id').val('');
|
||||
$('#policy_start_date').val('');
|
||||
$('#policy_end_date').val('');
|
||||
$('#tpa').val('').select2();
|
||||
console.log(res.message, 'warning');
|
||||
}
|
||||
@ -3917,7 +4074,7 @@ function addInsurerColumn() {
|
||||
|
||||
}
|
||||
|
||||
}else if(team_id.includes('3')){
|
||||
}else if(team_id.includes('3') || team_id.includes('8')){
|
||||
|
||||
switch(index) {
|
||||
case 0: // Insurer selection
|
||||
@ -4312,7 +4469,7 @@ function populateTable(dataArray, cd_ac_pk) {
|
||||
cell.find('input[type="hidden"]').val(data.id);
|
||||
break;
|
||||
}
|
||||
}else if(team_id.includes('3')){
|
||||
}else if(team_id.includes('3') || team_id.includes('8')){
|
||||
|
||||
switch (rowIndex) {
|
||||
case 0: // Insurer selection
|
||||
|
||||
14
app/Views/rfq/attachment_files.php
Normal file
14
app/Views/rfq/attachment_files.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php if (!empty($multi_file_data)) : ?>
|
||||
<div class="form-group col-md-12">
|
||||
<label>Select Files:</label>
|
||||
<?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'] ?>">
|
||||
<label class="form-check-label" for="file_<?= $file['id'] ?>">
|
||||
<?= htmlspecialchars($file['docs_name']) ?> - <?= htmlspecialchars($file['file_name']) ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@ -11,16 +11,20 @@
|
||||
</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>
|
||||
<label class="form-check-label">Multi with Floater</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>
|
||||
<label class="form-check-label">Multi without Floater</label>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
@ -11,16 +11,20 @@
|
||||
</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>
|
||||
<label class="form-check-label">Multi with Floater</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>
|
||||
<label class="form-check-label">Multi without Floater</label>
|
||||
</div>
|
||||
</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 Floater</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 Floater</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>
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
<?php if(isset($lead_edit_data)) {
|
||||
$claims = !empty($lead_edit_data['fin_years_claims_array']) ? $lead_edit_data['fin_years_claims_array'] : [ ['year' => '', 'claim_amount' => '', 'status' => '', 'claim_type' => '', 'cause_of_death' => '', 'death_date' => ''] ];
|
||||
foreach ($claims as $key => $value) { ?>
|
||||
?>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" onchange="claimHistoryToggle()" class="custom-control-input" id="claim_history" name="claim_history" <?= $lead_edit_data['claim_history'] == 1 ? "checked" : "" ?> />
|
||||
<label class="custom-control-label" for="claim_history">Claims History</label>
|
||||
</div><br>
|
||||
<?php
|
||||
|
||||
if ($lead_edit_data['claim_history'] == 1) {
|
||||
foreach ($claims as $key => $value) { ?>
|
||||
|
||||
<div class="row claim-row">
|
||||
<div class="form-group col-md-2">
|
||||
@ -13,6 +21,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 +46,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[]"
|
||||
@ -41,5 +59,5 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<?php } } ?>
|
||||
<?php } ?>
|
||||
@ -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>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user