MERGE_TO_TEST_LIVE_ALL_COMBINED

This commit is contained in:
Venba 2025-01-14 08:34:41 +00:00
commit 67b3ecadf2
94 changed files with 15551 additions and 3186 deletions

View File

@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig
* @var string[] * @var string[]
* @phpstan-var list<string> * @phpstan-var list<string>
*/ */
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive']; public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper'];
} }

View File

@ -22,6 +22,12 @@ $routes->get("view", "EmployeeController::viewECard/$1");
$routes->get("smapletest", "ClientController::smapletest"); $routes->get("smapletest", "ClientController::smapletest");
$routes->get("testMailAttachments", "ClientController::testMailAttachments"); $routes->get("testMailAttachments", "ClientController::testMailAttachments");
$routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey"); $routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey");
$routes->get("updateRemainderDate", "ClientController::updateRemainderDate");
$routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
$routes->get("sendextraparam", "ClientController::sendextraparam");
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image"); $routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
$routes->get("add_image_index", "AppContentManagementController::add_image_index"); $routes->get("add_image_index", "AppContentManagementController::add_image_index");
@ -130,6 +136,11 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->get("list/(:any)", "ClientController::listVehicleFiles/$1"); $routes->get("list/(:any)", "ClientController::listVehicleFiles/$1");
$routes->get("delete/(:any)", "ClientController::deleteVehicleFiles/$1"); $routes->get("delete/(:any)", "ClientController::deleteVehicleFiles/$1");
}); });
$routes->group("others", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "ClientController::createOtherTabContent");
});
}); });
$routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
@ -144,6 +155,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1"); $routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
$routes->get("test-rack-rate", "EmployeeController::testRackRate"); $routes->get("test-rack-rate", "EmployeeController::testRackRate");
$routes->post("test-rack-rate", "EmployeeController::testRackRate"); $routes->post("test-rack-rate", "EmployeeController::testRackRate");
$routes->get('test_members_list', 'EmployeeController::test_members_list');
}); });
$routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->group("/master", ["filter" => "authMVC"], function ($routes) {
@ -316,6 +328,13 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('view_log/(:any)', 'EmployeeController::viewLog/$1'); $routes->get('view_log/(:any)', 'EmployeeController::viewLog/$1');
$routes->get('download_log/(:any)', 'EmployeeController::downloadLog/$1'); $routes->get('download_log/(:any)', 'EmployeeController::downloadLog/$1');
$routes->post('checkDuplicateTableFieldValue', 'ClientController::checkDuplicateTableFieldValue'); $routes->post('checkDuplicateTableFieldValue', 'ClientController::checkDuplicateTableFieldValue');
$routes->get('getCoShareStatementDetails/(:any)', 'PolicyTransactionController::getCoShareStatementDetails/$1');
$routes->get('getClientPolicyDataBasedOnClientAndInsuer', 'PolicyTransactionController::getClientPolicyDataBasedOnClientAndInsuer');
$routes->get('checkCDAmountForBasePremium', 'PolicyTransactionController::checkCDAmountForBasePremium');
$routes->post('map_employees', 'EmployeeController::mapEmployees');
$routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping');
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
}); });
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
@ -351,6 +370,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1"); $routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement"); $routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1"); $routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
$routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth");
$routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1");
}); });
}); });
@ -361,9 +382,11 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "LeadsController::createLead"); $routes->post("create", "LeadsController::createLead");
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1"); $routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
$routes->get("sendMail", "LeadsController::sendMailWithAttachement"); $routes->get("sendMail", "LeadsController::sendMailWithAttachement");
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1"); $routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1"); $routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
}); });
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) { $routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
@ -377,6 +400,7 @@ $routes->get("driveListFiles", "GoogleDriveController::listFiles");
$routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']); $routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']); $routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']); $routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']);
$routes->get('cli/sendZeptoMail', 'MasterController::testZeptoSMTP');
$routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs'); $routes->cli('cli/processjobs', 'JobWorker::processJobs');
@ -384,6 +408,7 @@ $routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->get("processjob", "JobWorker::processJob"); $routes->get("processjob", "JobWorker::processJob");
$routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken'); $routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken');
$routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI'); $routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI');
$routes->cli('cli/sendZeptoMail', 'MasterController::testZeptoSMTP');
$routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails'); $routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails');
$routes->cli('cli/app_check_list', 'MasterController::appCheckList'); $routes->cli('cli/app_check_list', 'MasterController::appCheckList');
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken'); $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
@ -393,6 +418,7 @@ $routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationControlle
$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); $routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin");
$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin"); $routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin");
$routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId");
//HR login api's //HR login api's
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
@ -402,7 +428,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->post("logined", "RestAuthenticationController::logined"); $routes->post("logined", "RestAuthenticationController::logined");
$routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); $routes->post("getId", "RestAuthenticationController::getUserIdFromToken");
}); });
// $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
@ -443,10 +469,11 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("getFEContent", "EmployeeRestController::getFEContent"); $routes->get("getFEContent", "EmployeeRestController::getFEContent");
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
}); });
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
$routes->post("sendEmail", "EmployeeRestController::send_email"); $routes->post("sendEmail", "EmployeeRestController::send_email");
$routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrolledDetails");
// Ticketing System // Ticketing System

View File

@ -73,7 +73,7 @@ class ChatBotController extends AdminController
public function getChatResponse() public function getChatResponse()
{ {
// try { try {
$emp_code = $this->request->getVar('emp_code'); $emp_code = $this->request->getVar('emp_code');
$client_id = $this->request->getVar('client_id'); $client_id = $this->request->getVar('client_id');
$client_branch_id = $this->request->getVar('client_branch_id'); $client_branch_id = $this->request->getVar('client_branch_id');
@ -236,9 +236,9 @@ class ChatBotController extends AdminController
return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404); return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404);
} }
// } catch (\Throwable $th) { } catch (\Throwable $th) {
// return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
// } }
} }

View File

@ -118,6 +118,8 @@ class ClientController extends AdminController
$this->leadsModel = new LeadsModel(); $this->leadsModel = new LeadsModel();
} }
//--------------------------------------------------------------------------------------------------------
public function checkDuplicateTableFieldValue() public function checkDuplicateTableFieldValue()
{ {
$table = $this->request->getPost('table'); $table = $this->request->getPost('table');
@ -181,7 +183,7 @@ class ClientController extends AdminController
print_rr($attachments); print_rr($attachments);
} }
public function testingForReviewMail($client_id = 77, $emp_code = 'MGL-004', $mail_active = 0) //this function for only tsesting some logics not use for business logic public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) //this function for only tsesting some logics not use for business logic
{ {
$client_policy_ids = $this->employeeModel $client_policy_ids = $this->employeeModel
@ -209,6 +211,13 @@ class ClientController extends AdminController
if (!is_null($client_policy_id) && is_array($client_policy_id)) if (!is_null($client_policy_id) && is_array($client_policy_id))
{ {
$empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll();
$filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self');
// dd($filteredEmpData);
$array_list = []; $array_list = [];
foreach ($client_policy_id as $key => $value) foreach ($client_policy_id as $key => $value)
{ {
@ -230,6 +239,14 @@ class ClientController extends AdminController
$params ['emp_code'] = $emp_code; $params ['emp_code'] = $emp_code;
$params ['client_id'] = $client_id; $params ['client_id'] = $client_id;
$params ['notification'] = $notification; $params ['notification'] = $notification;
$params['common'] = [
'client_id' => $filteredEmpData[0]['client_id'],
'client_branch_id' => $filteredEmpData[0]['client_branch_id'],
'client_policy_id' => null,
'employee_policy_id' => null,
'employee_id' => $filteredEmpData[0]['id'],
'mail_type' => 'member_review_and_summary_mail',
];
// dd($params); // dd($params);
@ -243,6 +260,7 @@ class ClientController extends AdminController
if (isset($wholeData[0])) { if (isset($wholeData[0])) {
$params['common']['mail_type'] = 'account_maneger_summary_mail';
$account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params); $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
// print_r($account_manager_wholeData); die; // print_r($account_manager_wholeData); die;
@ -261,6 +279,7 @@ class ClientController extends AdminController
$this->myLogger->logme("error", 'Account Manager Mail Configuration not Enable for this client'); $this->myLogger->logme("error", 'Account Manager Mail Configuration not Enable for this client');
} }
$params['common']['mail_type'] = 'client_hr_summary_mail';
$client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params); $client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
// print_r($client_hr_wholeData); die; // print_r($client_hr_wholeData); die;
@ -298,6 +317,8 @@ class ClientController extends AdminController
// return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200); // return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
} }
//--------------------------------------------------------------------------------------------------------
public function index() public function index()
{ {
$this->myLogger->logme('error', 'Client list function called'); $this->myLogger->logme('error', 'Client list function called');
@ -463,7 +484,7 @@ class ClientController extends AdminController
// Fetch associated insurer names and balances // Fetch associated insurer names and balances
$balances = $this->clientPolicyModel->getBalances($id); $balances = $this->clientPolicyModel->getBalances($id);
$data['balances'] = $balances; $data['balances'] = $balances;
// dd($data);
echo view('layout/header', $headerData); echo view('layout/header', $headerData);
echo view('client_deposit_list', $data); echo view('client_deposit_list', $data);
echo view('layout/footer'); echo view('layout/footer');
@ -500,7 +521,7 @@ class ClientController extends AdminController
$data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['clientData'] = $this->clientPolicyModel->getClientById($clientId);
$data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId);
// dd($data['depositdata']); // dd($data['insurerName']);
// print_r($data['depositdata'] );die; // print_r($data['depositdata'] );die;
// Load the view for the new list page; // Load the view for the new list page;
@ -584,7 +605,7 @@ class ClientController extends AdminController
$editData['client_policy'] = $clientPoliceData; $editData['client_policy'] = $clientPoliceData;
$editData['client_policy']['role'] = get_role_id(); $editData['client_policy']['role'] = get_role_id();
$editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll(); $editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll();
$editData['placeHolders'] = ['member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; $editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
// dd($editData); // dd($editData);
echo view('layout/header', $headerData); echo view('layout/header', $headerData);
@ -1030,9 +1051,12 @@ class ClientController extends AdminController
$data['policy_status'] = 1; $data['policy_status'] = 1;
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst'); $data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer'); $data['disclaimer'] = $this->request->getPost('disclaimer');
$data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0;
$data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0;
if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) { if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) {
@ -1059,14 +1083,15 @@ class ClientController extends AdminController
if ($data['inception_type'] == 2) { if ($data['inception_type'] == 2) {
$data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d');
$data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d');
$data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); // $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
$data['reminder_date'] = $this->request->getPost('reminder_date');
} else { } else {
$data['open_date'] = null; $data['open_date'] = null;
$data['closedate'] = null; $data['closedate'] = null;
$data['reminder_date'] = null; $data['reminder_date'] = null;
} }
$data['created_by'] = get_session_userid(); $data['created_by'] = get_session_userid();
$policy_tranction_data = [ $policy_tranction_data = [
@ -1077,7 +1102,7 @@ class ClientController extends AdminController
'insurer_branch_id' => $insurerBranchId, 'insurer_branch_id' => $insurerBranchId,
'issue_type' => 1, 'issue_type' => 1,
'policy_no' => $this->request->getPost('policy_no'), 'policy_no' => $this->request->getPost('policy_no'),
'cd_ac_no' => $this->request->getPost('cd_ac_no'), 'cd_ac_pk' => $this->request->getPost('cd_ac_no'),
'policy_issue_date' => date('Y-m-d'), 'policy_issue_date' => date('Y-m-d'),
'policy_start_date' => change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'), 'policy_start_date' => change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'),
'policy_end_date' => change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'), 'policy_end_date' => change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'),
@ -1087,7 +1112,6 @@ class ClientController extends AdminController
]; ];
$insert = $this->clientPolicyModel->insert($data); $insert = $this->clientPolicyModel->insert($data);
if ($insert) { if ($insert) {
@ -1114,6 +1138,7 @@ class ClientController extends AdminController
public function editClientPolicy() public function editClientPolicy()
{ {
// print_r('test'); die;
$this->myLogger->logme('error', 'Client policy function called'); $this->myLogger->logme('error', 'Client policy function called');
@ -1157,16 +1182,17 @@ class ClientController extends AdminController
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0; $data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0;
$data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst'); $data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer'); $data['disclaimer'] = $this->request->getPost('disclaimer');
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0;
if ($data['inception_type'] == 2) { if ($data['inception_type'] == 2) {
$data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d');
$data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d');
$data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); // $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
$data['reminder_date'] = $this->request->getPost('reminder_date');
} else { } else {
$data['open_date'] = null; $data['open_date'] = null;
$data['close_date'] = null; $data['close_date'] = null;
@ -2056,6 +2082,11 @@ class ClientController extends AdminController
$data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age") ? $this->request->getPost("other_member_min_age") : 0; $data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age") ? $this->request->getPost("other_member_min_age") : 0;
$data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age") ? $this->request->getPost("other_member_max_age") : 0; $data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age") ? $this->request->getPost("other_member_max_age") : 0;
$data['is_payable_employee']['self'] = $this->request->getPost("is_payable_employee_for_self") ? 1 : 0;
$data['is_payable_employee']['spouse'] = $this->request->getPost("is_payable_employee_for_spouse") ? 1 : 0;
$data['is_payable_employee']['childern'] = $this->request->getPost("is_payable_employee_for_child") ? 1 : 0;
$data['is_payable_employee']['elders'] = $this->request->getPost("is_payable_employee_for_elders") ? 1 : 0;
// if (!in_array("self", $data['family_floaters'])) { // if (!in_array("self", $data['family_floaters'])) {
@ -2146,6 +2177,7 @@ class ClientController extends AdminController
$data['preandpostnatal'] = ""; $data['preandpostnatal'] = "";
$data['babyday1cover'] = ""; $data['babyday1cover'] = "";
} }
$data['9monthwaitingperiodwaived'] = str_replace(',', '', $this->request->getPost("9monthwaitingperiodwaived")); $data['9monthwaitingperiodwaived'] = str_replace(',', '', $this->request->getPost("9monthwaitingperiodwaived"));
$data['coverfromthedateofjoining'] = str_replace(',', '', $this->request->getPost("coverfromthedateofjoining")); $data['coverfromthedateofjoining'] = str_replace(',', '', $this->request->getPost("coverfromthedateofjoining"));
$data['waiverof1,2,3&4thyearexclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions"); $data['waiverof1,2,3&4thyearexclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions");
@ -2286,6 +2318,8 @@ class ClientController extends AdminController
$data['totalSumInsured'] = str_replace(',', '', $this->request->getPost("totalSumInsured")); $data['totalSumInsured'] = str_replace(',', '', $this->request->getPost("totalSumInsured"));
$data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age"); $data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age");
$data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age"); $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age");
$data['is_payable_employee']['self'] = 0;
$data['accidentalDeathBenefit'] = str_replace(',', '', $this->request->getPost("accidentalDeathBenefit")); $data['accidentalDeathBenefit'] = str_replace(',', '', $this->request->getPost("accidentalDeathBenefit"));
$data['permanentTotalDisablement'] = str_replace(',', '', $this->request->getPost("permanentTotalDisablement")); $data['permanentTotalDisablement'] = str_replace(',', '', $this->request->getPost("permanentTotalDisablement"));
$data['permanentPartialDisablement'] = $this->request->getPost("permanentPartialDisablement"); $data['permanentPartialDisablement'] = $this->request->getPost("permanentPartialDisablement");
@ -2419,11 +2453,11 @@ class ClientController extends AdminController
$termsData = json_decode($termsData['policy_terms']); $termsData = json_decode($termsData['policy_terms']);
if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) { if (isset($termsData->sum_insured) && $termsData->sum_insured == "" && $termsData->sum_insured == null) {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty', 'data' => $record], 200); return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty', 'data' => $record], 200);
} }
if (isset($termsData->SumInsured) && empty($termsData->sum_insured)) { if (isset($termsData->sumInsured2) && $termsData->sumInsured2 == "" && $termsData->sumInsured2 == null) {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty'], 200); return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty'], 200);
} }
@ -2515,12 +2549,14 @@ class ClientController extends AdminController
} }
} }
//for this function policy binding dropdown list use ( client policy )
public function getClientBranch($client_id) public function getClientBranch($client_id)
{ {
$branchs = $this->clientBranchModel $branchs = $this->clientBranchModel
->select('*') ->select('*')
->where('client_id', $client_id) ->where('client_id', $client_id)
->where('is_active', 1)
->findAll(); ->findAll();
return $this->respond(['status' => true, 'code' => 200, 'data' => $branchs], 200); return $this->respond(['status' => true, 'code' => 200, 'data' => $branchs], 200);
@ -2869,6 +2905,13 @@ class ClientController extends AdminController
$client_policy_id = $this->request->getPost("client_policy_id"); $client_policy_id = $this->request->getPost("client_policy_id");
$policy_terms = $this->request->getPost("policy_terms"); $policy_terms = $this->request->getPost("policy_terms");
if (!empty($policy_terms)) {
$policy_terms = json_decode($policy_terms, true);
$policy_terms['is_payable_employee']['self'] = 0;
$policy_terms = json_encode($policy_terms);
}
$record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); $record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
if ($record) { if ($record) {
@ -2936,15 +2979,15 @@ class ClientController extends AdminController
$multi_si = []; $multi_si = [];
if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { if (isset($JSON->sum_insured) && $JSON->sum_insured != "" && $JSON->sum_insured != null) {
$multi_si[] = $JSON->sum_insured; $multi_si[] = $JSON->sum_insured;
} elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { } elseif (isset($JSON->sumInsured2) && $JSON->sumInsured2 != "" && $JSON->sumInsured2 != null) {
$multi_si[] = $JSON->sumInsured2; $multi_si[] = $JSON->sumInsured2;
} }
if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) { if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) {
foreach ($JSON->multiple_sum_insured as $msi) { foreach ($JSON->multiple_sum_insured as $msi) {
if (!empty($msi)) { if ($msi != "" && $msi != null) {
$multi_si[] = $msi; $multi_si[] = $msi;
} }
} }
@ -3256,11 +3299,10 @@ class ClientController extends AdminController
public function getClientAndBranchAndPolicy() public function getClientAndBranchAndPolicy()
{ {
// ---------for client-----------------------------------------------------------------------------
$clients = $this->clientModel->where('is_active', 1)->findAll(); $clients = $this->clientModel->where('is_active', 1)->findAll();
$vehicles = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'clients.id=vehicle.owner')
->where('vehicle.is_active', 1)->findAll();
$clientIds = array_column($clients, 'id'); $clientIds = array_column($clients, 'id');
// Fetch branches in a single query // Fetch branches in a single query
@ -3269,6 +3311,29 @@ class ClientController extends AdminController
->where('is_active', 1) ->where('is_active', 1)
->findAll(); ->findAll();
// -----------for vehicle ---------------------------------------------------------------------------
$vehicles = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'clients.id=vehicle.owner')
->where('vehicle.is_active', 1)->findAll();
// -----------for Insurer ---------------------------------------------------------------------------
//fetch all insurer data
$insurers = $this->insurerModel->where('is_active', 1)->findAll();
//map the insurer primary key to column
$insurersIds = array_column($insurers, 'id');
// Fetch insurer branches in a single query
$insurerBranches = $this->insurerBranchModel
->whereIn('insurer_id', $insurersIds)
->where('is_active', 1)
->findAll();
// -----------for Policy ---------------------------------------------------------------------------
// Fetch policies in a single query // Fetch policies in a single query
$policies = $this->clientPolicyModel $policies = $this->clientPolicyModel
->select(" ->select("
@ -3287,16 +3352,26 @@ class ClientController extends AdminController
->where('client_policy.is_active', 1) ->where('client_policy.is_active', 1)
->findAll(); ->findAll();
// --------------------------------------------------------------------------------------
$branchList = []; $branchList = [];
$policyList = []; $policyList = [];
$policyListByClient = []; $policyListByClient = [];
$unitList = []; $unitList = [];
$insurerBranchList = [];
//for client branch mapping to the client
foreach ($branches as $branch) { foreach ($branches as $branch) {
$branchList[$branch['client_id']][] = $branch; $branchList[$branch['client_id']][] = $branch;
$unitList[$branch['id']][] = json_decode($branch['units']); $unitList[$branch['id']][] = json_decode($branch['units']);
} }
//for insurer branch mapping to the insurer
foreach ($insurerBranches as $branch) {
$insurerBranchList[$branch['insurer_id']][] = $branch;
}
//for client policy mapping to the branch and client
foreach ($policies as $policy) { foreach ($policies as $policy) {
$policyList[$policy['client_branch_id']][] = $policy; $policyList[$policy['client_branch_id']][] = $policy;
$policyListByClient[$policy['client_id']][] = $policy; $policyListByClient[$policy['client_id']][] = $policy;
@ -3307,6 +3382,7 @@ class ClientController extends AdminController
} }
} }
//get policy count
foreach ($clients as &$client) { foreach ($clients as &$client) {
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0; $client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
} }
@ -3319,6 +3395,8 @@ class ClientController extends AdminController
'branch_data' => $branchList, 'branch_data' => $branchList,
'policy_data' => $policyList, 'policy_data' => $policyList,
'policyListByClient' => $policyListByClient, 'policyListByClient' => $policyListByClient,
'insurer_data' => $insurers,
'insurer_branch_data' => $insurerBranchList,
'unit_data' => $unitList, 'unit_data' => $unitList,
], 200); ], 200);
} else { } else {
@ -3579,15 +3657,22 @@ class ClientController extends AdminController
dd($result); dd($result);
} }
// ---------------------------------------------------------------------------------------------------------
public function updatePolicyTermsKey() public function updatePolicyTermsKey()
{ {
$client_id = $this->request->getGet('client_id');
$data = $this->clientPolicyModel $query = $this->clientPolicyModel
->where("policy_terms IS NOT NULL AND policy_terms <> ''") ->where("policy_terms IS NOT NULL AND policy_terms <> ''")
->where('policy_type_id', 2) ->where('is_active', 1);
->where('is_active', 1)
->findAll(); if (!empty($client_id)) {
$query->where('client_id', $client_id);
}
$data = $query->findAll();
for ($i = 0; $i < count($data); $i++) { for ($i = 0; $i < count($data); $i++) {
if (isset($data[$i]['policy_terms']) && !empty($data[$i]['policy_terms'])) { if (isset($data[$i]['policy_terms']) && !empty($data[$i]['policy_terms'])) {
@ -3596,82 +3681,269 @@ class ClientController extends AdminController
continue; continue;
} }
// Set default value of copayzonewisecopay to "empty" $is_addon = $data[$i]['is_addon'];
$ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
$payable_arr = [];
if (in_array($data[$i]['policy_type_id'], [2,3]) && $is_addon == 1) {
$payable_arr = [ "self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0, ];
} else if ($data[$i]['policy_type_id'] == 3 && $is_addon == 3) {
$payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
} else if (in_array($data[$i]['policy_type_id'], [4, 5])) {
$payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
}
// Initialize an empty array for the ordered policy terms // Initialize an empty array for the ordered policy terms
$orderedPolicyTerms = []; $orderedPolicyTerms = [];
// Add copayzonewisecopay and copayzonewisecopaydata if they exist_ if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
if (isset($policyTerms['copayzonewisecopay'])) {
$orderedPolicyTerms['copayzonewisecopay'] = $policyTerms['copayzonewisecopay'];
$orderedPolicyTerms['co_pay_details'] = isset($policyTerms['co_pay_details']) ? $policyTerms['co_pay_details'] : '';
}
// Set default value of copayzonewisecopay to "empty"
$ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
// Add ailmentcapping and ailmentcappingdata if they exist_ // add is_payable_employee for the GMC Policy
if (isset($policyTerms['ailmentcapping'])) { if (isset($policyTerms['age_ratio'])) {
$orderedPolicyTerms['ailmentcapping'] = $policyTerms['ailmentcapping']; if(!isset($policyTerms['is_payable_employee'])){
$orderedPolicyTerms['ailment_capping_details'] = isset($policyTerms['ailment_capping_details']) ? $policyTerms['ailment_capping_details'] : ''; $aliment_index = array_search('age_ratio', array_keys($policyTerms));
} $orderedPolicyTerms[] = [
"key" => "is_payable_employee",
"value" => $payable_arr,
// Now add the rest of the policy terms that are not copayzonewisecopay, copayzonewisecopaydata, ailmentcapping, or ailmentcapping_data_ "position" => $aliment_index + 1,
foreach ($policyTerms as $key => $value) { ];
if (!in_array($key, ['copayzonewisecopay', 'co_pay_details', 'ailmentcapping', 'ailment_capping_details'])) { }
$orderedPolicyTerms[$key] = $value;
} }
// Add copayzonewisecopay and copayzonewisecopaydata if they exist_
if (isset($policyTerms['copayzonewisecopay'])) {
if(!isset($policyTerms['co_pay_details'])){
$co_pay_details_value = "";
if (strtolower($ans) == "nil" || $ans == 0) {
$policyTerms['copayzonewisecopay'] = 0;
$co_pay_details_value = "";
} elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) {
$policyTerms['copayzonewisecopay'] = 1;
$co_pay_details_value = $ans;
}
$co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms));
$orderedPolicyTerms[] = [
"key" => "co_pay_details",
"value" => $co_pay_details_value,
"position" => $co_pay_index + 2,
];
unset($policyTerms['optionalparentalcopay']);
}
}
// Add ailmentcapping and ailmentcappingdata if they exist
if (isset($policyTerms['ailmentcapping'])) {
if(!isset($policyTerms['ailment_capping_details'])){
$aliment_index = array_search('ailmentcapping', array_keys($policyTerms));
$orderedPolicyTerms[] = [
"key" => "ailment_capping_details",
"value" => "",
"position" => $aliment_index + 3,
];
}
}
}else {
// add is_payable_employee for the GMC Policy
if (isset($policyTerms['age_ratio'])) {
if(!isset($policyTerms['is_payable_employee'])){
$aliment_index = array_search('age_ratio', array_keys($policyTerms));
$orderedPolicyTerms[] = [
"key" => "is_payable_employee",
"value" => [
"self" => 0,
],
"position" => $aliment_index + 1,
];
}
}else{
if(!isset($policyTerms['is_payable_employee'])){
$orderedPolicyTerms[] = [
"key" => "is_payable_employee",
"value" => [
"self" => 0,
],
"position" => 2,
];
}
}
} }
foreach ($orderedPolicyTerms as $term) {
$position = $term['position'];
$key = $term['key'];
$value = $term['value']; // Insert the key-value pair at the specified index
$policyTerms = array_merge(
array_slice($policyTerms, 0, $position, true),
[$key => $value],
array_slice($policyTerms, $position, null, true)
);
}
// Re-encode the ordered policy terms // Re-encode the ordered policy terms
$updatedPolicyTerms = json_encode($orderedPolicyTerms); $updatedPolicyTerms = json_encode($policyTerms);
// dd($orderedPolicyTerms, $updatedPolicyTerms);
// Update the policyterms in the database_
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
}
}
public function updateRemainderDate()
{
// Connect to the database and fetch the data
$data = db_connect()->table('client_policy')
->where("reminder_date IS NOT NULL AND reminder_date <> ''")
->where('is_active', 1)
->get()
->getResultArray();
$days = [];
foreach ($data as $value) {
$reminderDate = strtotime($value['reminder_date']);
if ($reminderDate) {
$date_of_date = date('d', $reminderDate);
$days[] = $date_of_date;
$days[] = $value['reminder_date'];
db_connect()->table('client_policy')->where('id', $value['id'])->set('reminder_date', $date_of_date)->update();
}
}
dd($days);
}
public function sendextraparam()
{
$batch_data = [
'client_id' => 17,
'client_policy_id' => 30,
'client_branch_id' => 18,
'event_type' => "inception",
];
// $batch_data['insurer_or_tpa'] = 'insurer';
$batch_data['insurer_or_tpa'] = 'tpa';
// dd($this->request);
// $employeeRestController = new EmployeeServiceController();
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 721]);
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
// Handle different conditions for copayzonewisecopay // $dashBoardController = new DashboardController();
if (strtolower($ans) == "nil" || $ans == 0) { // $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126);
// If copayzonewisecopay is "nil" or 0, reset it to 0 and add copayzonewisecopaydata as empty_ // $dashBoardController->sendRemainderMail($client_policy_data);
if (isset($orderedPolicyTerms['copayzonewisecopay'])) {
$orderedPolicyTerms['copayzonewisecopay'] = 0; // $EmpDataServiceController = new EmpDataServiceController();
$orderedPolicyTerms['co_pay_details'] = ""; // $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12);
// $ids = array_column($emp_data, 'id');
// $EmpDataServiceController->sendMailForDownloadingECard($ids);
// $EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
// print_rr($result); die;
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => '741']);
// $PolicyTransactionController = new PolicyTransactionController();
// $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']);
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileDataValidation(['file_id' => '319']);
// dd($res);
// $EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]);
$EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]);
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]);
// $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
// $EmpDataServiceController->importCorrectionUpdateEndorsementID(['file_id' => 188]);
$array = [
"employeeIds" => ["12800", "12798", "12797", "12799"],
"client_id" => "159",
"client_policy_id" => "336",
"client_branch_id" => "126",
"cd_ac_no" => "Apple_123",
"endorsement_no" => "ENDORSEMENT_ID",
"count" => 4,
"event_name" => "deletion",
"policy_name" => "GMC",
"user_id" => "1"
];
// $EmpDataServiceController->cashDepositCalculationForDeletion($array);
// $employeeRestController = new EmployeeServiceController();
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]);
// $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data);
// dd(db_connect()->getLastQuery());
}
// -------------------------------------------------------------------------------------------------------
public function createOtherTabContent()
{
$this->myLogger->logme('error', 'Client Others function called');
$data = $this->request->getPost();
$data['created_by'] = get_session_userid();
$client_id = $data['client_id'];
unset($data['client_id']);
$insert = $this->clientModel->where('id', $client_id)->set($data)->update();
if ($insert) {
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Client others data updated', 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data to update'], 200);
}
}
// -------------------------------------------------------------------------------------------------------
public function enrollmentAddonSIAmountDropdown($client_policy_id)
{
if(!empty($client_policy_id)){
$client_policy_details = $this->clientPolicyModel->where('id', $client_policy_id)->where('policy_status', 1)->where('is_active', 1)->first();
if(!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3){
$base_policy_id = $client_policy_details['base_policy'] ?? 0;
if(!empty($base_policy_id)){
} }
// Rebuild the array after modification
foreach ($policyTerms as $key => $value) {
if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) {
$orderedPolicyTerms[$key] = $value;
}
}
$updatedPolicyTerms = json_encode($orderedPolicyTerms);
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
continue;
} elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) {
// If copayzonewisecopay has a valid value, update it
if (isset($orderedPolicyTerms['copayzonewisecopay'])) {
$orderedPolicyTerms['copayzonewisecopay'] = 1;
$orderedPolicyTerms['co_pay_details'] = $ans;
}
// Rebuild the array after modification
foreach ($policyTerms as $key => $value) {
if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) {
$orderedPolicyTerms[$key] = $value;
}
}
$updatedPolicyTerms = json_encode($orderedPolicyTerms);
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
} }
} }
} }

View File

@ -362,173 +362,247 @@ class DashboardController extends AdminController
// dd($client_policy_data, $send_mail_for_manual_or_crone); // dd($client_policy_data, $send_mail_for_manual_or_crone);
$reminder_whole_mail = []; $reminder_whole_mail = [];
foreach ($client_policy_data as $client_policy) { foreach ($client_policy_data as $client_policy) {
if(empty($send_mail_for_manual_or_crone)){ // Fetch client data
$client_data = $this->clientModel->find($client_policy['client_id']);
// echo '1'; // Fetch notification settings
$notification_data = $this->notificationModel
->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
// Fetch client data if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) {
$client_data = $this->clientModel->find($client_policy['client_id']);
// Fetch notification settings
$notification_data = $this->notificationModel
->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
// $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data)); //manaual
if (empty($send_mail_for_manual_or_crone)) {
// Check if notification should be sent
if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { // Check if notification should be sent
$this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']);
// Fetch all employees related to the client policy $employees = [];
$employees = $this->employeePolicyModel if (in_array($client_policy['policy_type_id'], [2, 4]) || ($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 1)) {
->select('employees.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left') // Fetch all employees related to the client policy
->where('employee_polices.client_policy_id', $client_policy['id']) $employees = $this->employeePolicyModel
->where('employees.emp_status', 'draft') ->select('employees.*, employee_polices.id as emp_policy_id')
->where('employees.is_active', 1) ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.status', 'draft') ->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employee_polices.is_active', 1) ->where('employees.is_active', 1)
->where('employees.relationship', 'Self') ->where('employee_polices.is_active', 1)
->findAll(); ->where('employees.emp_status', 'draft')
->where('employee_polices.status', 'draft')
->where('employees.relationship', 'Self')
->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
->findAll();
// dd($employees, 'first');
} else if (($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 3) || $client_policy['policy_type_id'] == 5) {
$empDependentData = $this->employeePolicyModel
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.emp_status', 'draft')
->where('employee_polices.status', 'draft')
->where('employees.relationship !=', 'Self')
->findAll();
$empCodes = array_column($empDependentData, 'emp_code');
// dd($empDependentData, $empCodes,'second');
if (!empty($empCodes)) {
$empSelfData = $this->employeePolicyModel
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->whereIn('employees.emp_code', $empCodes)
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.relationship', 'Self')
->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
->findAll();
$employees = array_merge($employees, $empSelfData);
}
}
// dd($employees);
// Process each employee // Process each employee
foreach ($employees as $employee) { if (!empty($employees) && count($employees) > 0) {
if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { foreach ($employees as $employee) {
$this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']);
// Mail params // Mail params
$params['emp_data'] = $employee; $params['emp_data'] = $employee;
$params['client_data'] = $client_data; $params['client_data'] = $client_data;
$params['notification_data'] = $notification_data; $params['notification_data'] = $notification_data;
$params['common'] = [
'client_id' => $client_policy['client_id'],
'client_branch_id' => $client_policy['client_branch_id'],
'client_policy_id' => $client_policy['id'],
'employee_policy_id' => $employee['emp_policy_id'],
'employee_id' => $employee['id'],
'mail_type' => 'member_reminder_mail',
];
// Send the mail notification // Send the mail notification
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
// dd($mail_result);
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
$reminder_whole_mail[] = $mail_result; $reminder_whole_mail[] = $mail_result;
} }
} }
} else {
$this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } else { // crone
if (!empty($client_policy['reminder_date'])) {
$currentDate = date('d');
$remainder_dates = explode(",", $client_policy['reminder_date']);
foreach ($remainder_dates as $date) {
if ($currentDate == $date) {
$this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']);
// Fetch all employees related to the client policy
$employees = [];
if (in_array($client_policy['policy_type_id'], [2, 4]) || ($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 1)) {
$employees = $this->employeePolicyModel
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.emp_status', 'draft')
->where('employee_polices.status', 'draft')
->where('employees.relationship', 'Self')
->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
->findAll();
// dd($employees, 'first');
} else if (($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 3) || $client_policy['policy_type_id'] == 5) {
$empDependentData = $this->employeePolicyModel
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.emp_status', 'draft')
->where('employee_polices.status', 'draft')
->where('employees.relationship !=', 'Self')
->findAll();
$empCodes = array_column($empDependentData, 'emp_code');
// dd($empDependentData, $empCodes,'second');
if (!empty($empCodes)) {
$empSelfData = $this->employeePolicyModel
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->whereIn('employees.emp_code', $empCodes)
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.relationship', 'Self')
->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
->findAll();
$employees = array_merge($employees, $empSelfData);
}
}
// dd($employees);
// Process each employee
foreach ($employees as $employee) {
$this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']);
// Mail params
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
$params['common'] = [
'client_id' => $client_policy['client_id'],
'client_branch_id' => $client_policy['client_branch_id'],
'client_policy_id' => $client_policy['id'],
'employee_policy_id' => $employee['emp_policy_id'],
'employee_id' => $employee['id'],
'mail_type' => 'member_reminder_mail',
];
// Send the mail notification
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
// $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 { } else {
// echo '2'; $this->myLogger->logme('error', 'Notification setup not found or not enabled');
$this->myLogger->logme('error', 'Notification was not sent for this Client ID: ' . $client_policy['client_id']);
$currentDate = date('d-m-Y');
if($currentDate == date('d-m-Y', strtotime($client_policy['reminder_date']))){
// echo '3';
$client_data = $this->clientModel->find($client_policy['client_id']);
// Fetch notification settings
$notification_data = $this->notificationModel
->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
// Check if notification should be sent
if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) {
// echo '4';
$this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']);
// Fetch all employees related to the client policy
$employees = $this->employeePolicyModel
->select('employees.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.emp_status', 'draft')
->where('employees.is_active', 1)
->where('employee_polices.status', 'draft')
->where('employee_polices.is_active', 1)
->where('employees.relationship', 'Self')
->findAll();
// Process each employee
foreach ($employees as $employee) {
if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') {
$this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']);
// Mail params
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
// Send the mail notification
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
$reminder_whole_mail[] = $mail_result;
}
}
} else {
// echo '5';
$this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']);
}
}
} }
} }
// dd($reminder_whole_mail); // dd($reminder_whole_mail);
// print_rr($reminder_whole_mail); die;
// $this->myLogger->logme('error', 'Whole email, count: ' . $reminder_whole_mail);
// Process and queue bulk emails // Process and queue bulk emails
$temp_whole_data = []; if (!empty($reminder_whole_mail) && count($reminder_whole_mail) > 0) {
$count = 0;
$reminder_whole_mail = array_chunk($reminder_whole_mail, 20);
foreach ($reminder_whole_mail as $whole_index => $values) { foreach ($reminder_whole_mail as $key => $value) {
foreach ($values as $index => $value) { // $job_details = new Jobs();
$temp_whole_data[] = $value; $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
$count++;
$this->myLogger->logme('error', 'Queueing email, count: ' . $count);
if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) {
if (!empty($temp_whole_data)) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$this->myLogger->logme('error', 'Added bulk mail job: ' . json_encode($temp_whole_data));
$temp_whole_data = [];
$count = 0;
}
}
} }
} }
if (count($temp_whole_data) > 0) { if (count($reminder_whole_mail) > 0) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$this->myLogger->logme('error', 'Added final bulk mail job: ' . json_encode($temp_whole_data));
return true; return true;
} } else {
if(count($reminder_whole_mail) > 0){
return true;
}else{
return false; return false;
} }
} }
public function sendManualReminder($client_id, $client_branch_id) public function sendManualReminder($client_id, $client_branch_id, $client_policy_id = null)
{ {
$this->myLogger->logme('error','Log Works');
$this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}"); $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_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id, $client_policy_id);
// print_r($client_policy_data); die; // print_r($client_policy_data); die;
// print_r($this->clientPolicyModel->getLastQuery()); die; // print_r($this->clientPolicyModel->getLastQuery()); die;
// $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data)); // $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data));
if ($client_policy_data) { if ($client_policy_data) {
$result = $this->sendRemainderMail($client_policy_data); $result = $this->sendRemainderMail($client_policy_data);
log_message('error',json_encode($result));
$this->myLogger->logme('error',$result);
$this->myLogger->logme('error', "Manual Remainder Mail sending result: " . ($result ? 'success' : 'failure')); $this->myLogger->logme('error', "Manual Remainder Mail sending result: " . ($result ? 'success' : 'failure'));
if ($result) { if ($result) {
@ -545,7 +619,7 @@ class DashboardController extends AdminController
} }
} }
public function sendManualEcard($client_id, $client_branch_id, $policy_id) 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}"); $this->myLogger->logme('error', "sendManualEcard called with client_id: {$client_id}, client_branch_id: {$client_branch_id}, policy id : {$policy_id}");
@ -555,6 +629,7 @@ class DashboardController extends AdminController
{ {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200); return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200);
} }
$emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id); $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id);
if(count($emp_data) == 0) if(count($emp_data) == 0)
@ -574,7 +649,8 @@ class DashboardController extends AdminController
} }
public function data_construct_for_bds($data){ public function data_construct_for_bds($data)
{
$groupedData = [ $groupedData = [
'under_process' => [], 'under_process' => [],

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -132,7 +132,7 @@ class EmployeeServiceController extends AdminController
'format' => 'd-M-Y', 'format' => 'd-M-Y',
'allowed_values' => null, 'allowed_values' => null,
'custom' => 'check_dob_diff', 'custom' => 'check_dob_diff',
'params' => ['row', 'relationship', 'default_age_ratio'] 'params' => ['row', 'relationship', 'default_age_ratio','policy_details']
], ],
'gender' => [ 'gender' => [
'col_idx' => 4, 'col_idx' => 4,
@ -236,7 +236,9 @@ class EmployeeServiceController extends AdminController
'is_mandatory' => false, 'is_mandatory' => false,
'data_type' => 'str', 'data_type' => 'str',
'format' => null, 'format' => null,
'allowed_values' => null 'allowed_values' => null,
'custom' => 'check_dup_email',
'params' => ['row', 'existing_mobilenos']
], ],
'pre_existing_ailments' => [ 'pre_existing_ailments' => [
'col_idx' => 14, 'col_idx' => 14,
@ -342,6 +344,15 @@ class EmployeeServiceController extends AdminController
'data_type' => 'str', 'data_type' => 'str',
'format' => null, 'format' => null,
'allowed_values' => null 'allowed_values' => null
],
'claim_status' => [
'col_idx' => 6,
'col_cell_name' => 'G',
'col_name' => 'Claim status',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => null,
'allowed_values' => [0,1]
] ]
]; ];
@ -765,10 +776,9 @@ class EmployeeServiceController extends AdminController
$relationship = $this->general_relationships; $relationship = $this->general_relationships;
//get exisiting mobilr nos //get exisiting mobilr nos
$existing_mobilenos = $this->employeePolicyModel->getExisitingMobileNos(client_policy_id: $file['policy_id']); $existing_mobilenos = $this->employeePolicyModel->getExisitingMobileNos(client_policy_id: $file['policy_id']);
//get existing units in the current branch //get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']); $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
// dd($existing_units); // dd($excel_data);
foreach ($excel_data as $row_key => $row) foreach ($excel_data as $row_key => $row)
{ {
//define row wise action/event in temporary variable //define row wise action/event in temporary variable
@ -1036,7 +1046,7 @@ class EmployeeServiceController extends AdminController
} }
} }
if(($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon) if((($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
{ {
$res = check_self_available_in_family($family,$file['action']); $res = check_self_available_in_family($family,$file['action']);
if(!$res['is_self_found']) if(!$res['is_self_found'])
@ -1049,7 +1059,7 @@ class EmployeeServiceController extends AdminController
//check self avaialbe either same policy DB level(i.e.) gMC parents //check self avaialbe either same policy DB level(i.e.) gMC parents
if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon) if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon)
{ {
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']); $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active','draft','enrolled'],policy_status:['active','draft','enrolled'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']);
// dd($self_details); // dd($self_details);
if(!count($self_details)) if(!count($self_details))
{ {
@ -1232,7 +1242,6 @@ class EmployeeServiceController extends AdminController
// Kint::dump($family);die(); // Kint::dump($family);die();
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units); $data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
// dd($data);
$employee_data_group_by_family[$emp_id] = $data; $employee_data_group_by_family[$emp_id] = $data;
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]); $this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
} }
@ -1326,7 +1335,7 @@ class EmployeeServiceController extends AdminController
// } // }
// dd($row[4]); // dd($row[4]);
//for emp table //for emp table
$this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); // $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
// dd( $this->empEndorsementModel->getLastQuery()); // dd( $this->empEndorsementModel->getLastQuery());
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']); // $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']);
@ -1334,6 +1343,7 @@ class EmployeeServiceController extends AdminController
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => $row[4],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => $row[4],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'inactive','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'inactive','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'claim_status','old_value' => $data['claim_status'],'new_value' => $row[6],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
}; };
//iterate each row //iterate each row
foreach ($excel_data as $col_key => $row) foreach ($excel_data as $col_key => $row)
@ -1368,7 +1378,7 @@ class EmployeeServiceController extends AdminController
if(!in_array($employee['id'],$endorsement_data))//make entry in endorsement firsttime only with checking that PK of emp exisintg in variable $endorsement_data if(!in_array($employee['id'],$endorsement_data))//make entry in endorsement firsttime only with checking that PK of emp exisintg in variable $endorsement_data
{ {
$employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first(); $employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
$data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status']]; $data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status'],'claim_status' => $employee_policy['claim_status']];
$endorsement($data,$file,$row); $endorsement($data,$file,$row);
$endorsement_data[] = $employee['id']; $endorsement_data[] = $employee['id'];
} }
@ -1459,6 +1469,8 @@ class EmployeeServiceController extends AdminController
->where('emp_code',$employee['emp_code']) ->where('emp_code',$employee['emp_code'])
->where('name',$employee['name']) ->where('name',$employee['name'])
->where('field_name',$field_name) ->where('field_name',$field_name)
->where('is_active',1)
->where('status !=','truncated')
->findAll(); ->findAll();
// dd($existing_endorsements); // dd($existing_endorsements);
//make entry in endorsement table //make entry in endorsement table
@ -1580,9 +1592,15 @@ class EmployeeServiceController extends AdminController
// insert or update in db for inception addition depent addition // insert or update in db for inception addition depent addition
public function employeesOnboardProcess($params) public function employeesOnboardProcess($params)
{ {
// dd($params);
$familiy_data = $params['familiy_data']; $familiy_data = $params['familiy_data'];
$file = $params['file']; $file = $params['file'];
$policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first();
// dd($policy_details);
foreach($familiy_data as $fkey => $value) foreach($familiy_data as $fkey => $value)
{ {
if(is_array($value)) if(is_array($value))
@ -1603,7 +1621,7 @@ class EmployeeServiceController extends AdminController
// echo '---------------------------------------'; // echo '---------------------------------------';
//start implemet of si enhancement of grid type 10,11 //start implemet of si enhancement of grid type 10,11
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($value['temp']['grid_id'],[10,11]) && ( ($value['temp']['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null))) if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($temp['grid_id'],[10,11]) && ( ($temp['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($temp['premium_type'] == 2 || $temp['premium_type'] == null)))
{ {
$log_message = 'Employee record from DB,Checking SI for - '.$employee[0]['name'].'('.$employee[0]['emp_code'].')'; $log_message = 'Employee record from DB,Checking SI for - '.$employee[0]['name'].'('.$employee[0]['emp_code'].')';
$this->myLogger->logme('error',$log_message); $this->myLogger->logme('error',$log_message);
@ -1612,7 +1630,6 @@ class EmployeeServiceController extends AdminController
break;//skip db employee break;//skip db employee
} }
//end implemet of si enhancement of grid type //end implemet of si enhancement of grid type
//save employee table //save employee table
$value['relationship'] = ucfirst(trim($value['relationship'])); $value['relationship'] = ucfirst(trim($value['relationship']));
if(count($employee)) if(count($employee))
@ -1621,6 +1638,7 @@ class EmployeeServiceController extends AdminController
$value['id'] = $employee[0]['id']; $value['id'] = $employee[0]['id'];
$value['emp_status'] = 'active'; $value['emp_status'] = 'active';
$value['client_branch_id'] = $file['client_branch_id']; $value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ;
$log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id']; $log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id'];
// $this->myLogger->logme('error',('Update - ' . $employee[0]['id'].' - '. $employee[0]['emp_code'] .' - '.$employee[0]['name'])); // $this->myLogger->logme('error',('Update - ' . $employee[0]['id'].' - '. $employee[0]['emp_code'] .' - '.$employee[0]['name']));
// echo 'insert emp'; // echo 'insert emp';
@ -1631,11 +1649,11 @@ class EmployeeServiceController extends AdminController
$value['created_by'] = $file['created_by']; $value['created_by'] = $file['created_by'];
$value['client_branch_id'] = $file['client_branch_id']; $value['client_branch_id'] = $file['client_branch_id'];
$value['family_floater_key'] = generate_family_floater_key($value['relationship']); $value['family_floater_key'] = generate_family_floater_key($value['relationship']);
$value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ;
$log_message = 'Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK '; $log_message = 'Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
// $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name'])); // $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name']));
// echo 'update emp'; // echo 'update emp';
} }
$this->employeeModel->save($value); $this->employeeModel->save($value);
if (isset($value['id'])) { if (isset($value['id'])) {
$emp_id = $value['id']; $emp_id = $value['id'];
@ -1658,7 +1676,8 @@ class EmployeeServiceController extends AdminController
$policy_data['updated_by'] = $file['created_by']; $policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id']; $policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'active'; $policy_data['status'] = 'active';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = isset($employee_policy[0]['file_id']) && $employee_policy[0]['file_id'] != '' ? $employee_policy[0]['file_id'] : $file['id'] ;
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si']; $log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
// echo 'insert policy'; // echo 'insert policy';
} }
@ -1668,11 +1687,15 @@ class EmployeeServiceController extends AdminController
$policy_data['client_policy_id'] = $file['policy_id']; $policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by']; $policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'active'; $policy_data['status'] = 'active';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = $file['id'];
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si']; $log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy'; // echo 'update policy';
} }
// log_message('error',json_encode($policy_data));
$this->employeePolicyModel->save($policy_data); // dd($this->employeePolicyModel->save($policy_data));
$res = $this->employeePolicyModel->save($policy_data);
// if($res){log_message('error','ths the resul'.$res);}
if(isset($policy_data['id'])) if(isset($policy_data['id']))
{ {
$emp_policy_id = $policy_data['id']; $emp_policy_id = $policy_data['id'];
@ -1691,7 +1714,7 @@ class EmployeeServiceController extends AdminController
$log_message = $file['action'].' - endorsement'. $value['emp_code'].' - '.$value['name'].' - with policy id'.$emp_policy_id; $log_message = $file['action'].' - endorsement'. $value['emp_code'].' - '.$value['name'].' - with policy id'.$emp_policy_id;
$this->myLogger->logme('error',$log_message); $this->myLogger->logme('error',$log_message);
$actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : 'a')); $actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : 'a'));
$addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by']]; $addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by'],'status' => 'pending'];
$this->employeeEndorsementforAddtionAndDependentAddition($addition_endorse_data); $this->employeeEndorsementforAddtionAndDependentAddition($addition_endorse_data);
} }
@ -1879,7 +1902,7 @@ class EmployeeServiceController extends AdminController
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
public function getFileMetaDataByFileId($file_id, $status = 'success'){ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$data = $this->fileModel $data = $this->fileModel
->select('files.*, clients.client_name, clients.short_name, policy_type.policy_type as policy_name,client_branch.branch_code') ->select('files.*, clients.client_name, clients.short_name, policy_type.policy_type as policy_name,client_branch.branch_code')
@ -1928,191 +1951,221 @@ class EmployeeServiceController extends AdminController
} }
public function employeesEnrollmentInsert($params)
public function employeesEnrollmentInsert($params) {
{ // dd($this->request);
helper('excel_util_helper');
helper('excel_util_helper'); //get file name
//get file name $file_id = $params['file_id'];
$file_id = $params['file_id']; $file = $this->fileModel->find($file_id);
$file = $this->fileModel->find($file_id); // dd($file);
// dd($file); $return = [];
$return = []; if(!isset($file))
if(!isset($file))
{
//file not found in DB
return array('status' => false, 'msg' => 'file not found in DB');
}
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
//check physical file
if(!file_exists($file_name_with_path))
{
//file not found update status and reason
$message = "Physical file not found";
// echo $message;
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
return array('error_summary' => [5], 'error_data' => $message);
}
//get excel data
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$sheet = $spreadsheet->getActiveSheet();
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$result = ['error_type' => 2,'error_summary' => [], 'error_data' => [] ];
$columns_to_check = $this->enrollment_excel_columns;
$keys = array_keys($columns_to_check);
$allowedHighestColumn = end($columns_to_check);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// print_r($keys);die();
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
//remove header
unset($excel_data[0]);
// dd($excel_data);
$emp_emails = [];
//check is welcome notification enabled
$notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
// dd($notification);
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
foreach ($excel_data as $key => $row)
{
// dd($key.'-'.count($excel_data));
$value = [];
$policy_data = [];
$temp_unit = '';
if(empty($row[12]))
{ {
$temp_unit = $existing_units[0]; //file not found in DB
return array('status' => false, 'msg' => 'file not found in DB');
}
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
//check physical file
if(!file_exists($file_name_with_path))
{
//file not found update status and reason
$message = "Physical file not found";
// echo $message;
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
return array('error_summary' => [5], 'error_data' => $message);
} }
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
$value['email_corporate'] = $row[7];
$value['mobile'] = $row[8];
$value['band'] = $row[10];
$value['basic_pay'] = $row[11];
$value['unit'] = $temp_unit;
$value['family_floater_key'] = null;
$value['client_id'] = $file['client_id'];
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = $file_id;
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model //get excel data
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') { $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$relation = 'parent'; $sheet = $spreadsheet->getActiveSheet();
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$relation = 'child'; $highestRowAndColumn = $sheet->getHighestRowAndColumn();
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){ $result = ['error_type' => 2,'error_summary' => [], 'error_data' => [] ];
$relation = 'parent_in_law'; $columns_to_check = $this->enrollment_excel_columns;
}else if(strtolower(trim($value['relationship'])) === 'spouse'){ $keys = array_keys($columns_to_check);
$relation = 'spouse'; $allowedHighestColumn = end($columns_to_check);
}else{ $excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
$relation = 'self'; // print_r($keys);die();
} //get existing units in the current branch
$value['family_floater_key'] = $relation; $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
//remove header
unset($excel_data[0]);
// dd($excel_data);
$emp_emails = [];
$policy_data['basic_cover_si'] = $row[9]; //check is welcome notification enabled
$policy_data['date_coverage'] = $row[13]; $notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
$policy_data['client_policy_id'] = $file['policy_id']; // dd($notification);
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
$policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first();
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); // dd($policy_details);
unset($value['temp']);
//save employee table //get policy slab rates
// dd($employee['id']); // $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
if($employee !== null) // dd($slab_details);
foreach ($excel_data as $key => $row)
{
$is_row_empty = check_row_is_empty_or_null($row);
if(!$is_row_empty)
{
$value = [];
$policy_data = [];
$temp_unit = '';
if(empty($row[12]))
{ {
$value['updated_by'] = $file['created_by']; $temp_unit = $existing_units[0];
$value['id'] = $employee['id'];
$value['emp_status'] = 'draft';
$log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
}
else
{
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
} }
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d') : null );
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = change_date_format($row[6],'d-M-Y','Y-m-d');
$value['email_corporate'] = $row[7];
$value['mobile'] = $row[8];
$value['band'] = $row[10];
$value['basic_pay'] = $row[11];
$value['unit'] = $temp_unit;
$value['family_floater_key'] = null;
$value['client_id'] = $file['client_id'];
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = $file_id;
$value['is_addon_value'] = $policy_details['policy_type_id'] == 3 ? 1 : 0;
$this->employeeModel->save($value); $value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
if (isset($value['id'])) if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
{ $emp_id = $value['id']; } $relation = 'parent';
else { $emp_id = $this->employeeModel->getInsertID(); } else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$log_message .= $emp_id; $relation = 'child';
} }else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
$relation = 'parent_in_law';
// $emp_id = $this->employeeModel->getInsertID(); }else if(strtolower(trim($value['relationship'])) === 'spouse'){
// if($emp_id != 0){ $log_message .= $emp_id; } $relation = 'spouse';
// else{ $emp_id = $employee['id']; } }else{
$relation = 'self';
$this->myLogger->logme('error',$log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
if(count($employee_policy))
{
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
// echo 'insert policy';
}
else
{
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy';
}
$this->employeePolicyModel->save($policy_data);
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error',$log_message);
//save email of self for send mail later
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
{
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
{
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
if (count($emp_emails) == 20 || $key == count($excel_data) ) {
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
// echo 'Mail triggered';
$emp_emails = [];
} }
$value['family_floater_key'] = $relation;
}
}
} //end of for loop
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update(); $policy_data['basic_cover_si'] = $row[9];
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]); $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null;
$policy_data['client_policy_id'] = $file['policy_id'];
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success')); $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
unset($value['temp']);
//save employee table
// dd($employee['id']);
if($employee !== null)
{
$value['updated_by'] = $file['created_by'];
$value['id'] = $employee['id'];
$value['emp_status'] = 'draft';
$log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
}
else
{
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
}
$this->employeeModel->save($value);
if (isset($value['id']))
{ $emp_id = $value['id']; }
else { $emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
// $emp_id = $this->employeeModel->getInsertID();
// if($emp_id != 0){ $log_message .= $emp_id; }
// else{ $emp_id = $employee['id']; }
$this->myLogger->logme('error',$log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
if(count($employee_policy))
{
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = isset($employee_policy[0]['file_id']) && $employee_policy[0]['file_id'] != '' ? $employee_policy[0]['file_id'] : $file_id ;
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
// echo 'insert policy';
}
else
{
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = $file_id;
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy';
}
log_message('error',json_encode($policy_data));
// dd($policy_data);
$this->employeePolicyModel->save($policy_data);
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error',$log_message);
$employeeRestController = new EmployeeRestController();
$employeeRestController->updatePremiumAmount($file['policy_id'], $value['emp_code'], $file['client_branch_id']);
//save email of self for send mail later
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
{
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
{
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
$params['common'] = [
'client_id' => $file['client_id'],
'client_branch_id' => $file['client_branch_id'],
'client_policy_id' => $file['policy_id'],
'employee_policy_id' => $emp_policy_id ?? null,
'employee_id' => $emp_id,
'mail_type' => 'member_welcome_mail',
];
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
}
}
}// endof if row is empty check
} //end of for loop
// dd($emp_emails);
// for bulk mail queue job push
if (!empty($emp_emails) && count($emp_emails) > 0) {
$emp_emails = array_chunk($emp_emails, 20);
foreach ($emp_emails as $key => $value) {
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
}
}
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
return true; return true;
} }//end of employeesEnrollmentInsert
} }

View File

@ -126,6 +126,10 @@ class JobWorker extends AdminController
'employeesEnrollmentInsert' => [ 'employeesEnrollmentInsert' => [
'type' => 'CC', // Handler Category 'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeServiceController', 'handler' => 'App\Controllers\EmployeeServiceController',
],
'calculateMembersDemography' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\LeadsController',
] ]
]; ];

File diff suppressed because it is too large Load Diff

View File

@ -19,17 +19,16 @@ class LoginController extends BaseController
// set_session_data($session_data); // set_session_data($session_data);
// $isLoggedIn = check_session(); // $isLoggedIn = check_session();
$isLoggedIn = check_session(); $isLoggedIn = check_session();
$hasCookie = check_cookie();
if ($isLoggedIn) { if ($isLoggedIn || $hasCookie) {
return redirect()->to(base_url('/dashboard/view')); return redirect()->to(base_url('/dashboard/view'));
} }
return view('login'); return view('login');
} }
public function receiveGoogleOAuthResponse() public function receiveGoogleOAuthResponse()
{ {
$UserModel = new UserModel(); $UserModel = new UserModel();
//echo 'DONE';die(); //echo 'DONE';die();
if ($this->request->getGet('code')) { if ($this->request->getGet('code')) {
@ -52,7 +51,10 @@ class LoginController extends BaseController
'userProfile' => $value->picture, 'userProfile' => $value->picture,
'user_team' => $user_team, 'user_team' => $user_team,
]; ];
$path = getenv('cookie.Path');
$domain = getenv('cookie.Domain');
$https = getenv('ccokie.secure');
setcookie('session_data', json_encode($session_data), time() + 12 * 60 * 60, $path, $domain, $https, true);
set_session_data($session_data); set_session_data($session_data);
log_message('error', 'Set The UserId : `'. $user->id .'` in Session'); log_message('error', 'Set The UserId : `'. $user->id .'` in Session');
@ -82,12 +84,14 @@ class LoginController extends BaseController
public function initiateGoogleOAuth() public function initiateGoogleOAuth()
{ {
return googleOAuthLogin(false); return googleOAuthLogin(false);
} }
public function logout() public function logout()
{ {
$path = getenv('cookie.Path');
session()->destroy(); session()->destroy();
setcookie('session_data', '', time() - 3600, $path);
return redirect()->to(base_url('login')); return redirect()->to(base_url('login'));
} }

View File

@ -30,6 +30,8 @@ use App\Models\StateModel;
use App\Models\PolicyTypeModel; use App\Models\PolicyTypeModel;
use App\Models\CDMasterModel; use App\Models\CDMasterModel;
use App\Models\ClientDepositModel; use App\Models\ClientDepositModel;
use App\Models\EmployeePolicyModel;
use App\Models\FileModel;
use App\Models\InsurerExcelExportTemplateModel; use App\Models\InsurerExcelExportTemplateModel;
use App\Models\SettingsModel; use App\Models\SettingsModel;
use App\Models\VehicleModel; use App\Models\VehicleModel;
@ -1222,7 +1224,7 @@ class MasterController extends AdminController
$data = $this->request->getPost(); $data = $this->request->getPost();
$date = (string) $this->request->getPost('opening_date'); $date = (string) $this->request->getPost('opening_date');
$data['opening_date'] = date('Y-m-d', strtotime($date)); $data['opening_date'] = date('Y-m-d', strtotime($date));
// print_rr($data);die();
// Prepare the array with data // Prepare the array with data
$cd_tranction_data = [ $cd_tranction_data = [
'amount' => $data['opening_bal'], 'amount' => $data['opening_bal'],
@ -1245,7 +1247,7 @@ class MasterController extends AdminController
$insert = $this->CDMasterModel->insert($data); $insert = $this->CDMasterModel->insert($data);
if ($insert) { if ($insert) {
$cd_tranction_data['cd_ac_pk'] = $this->CDMasterModel->insertID();
$response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID); $response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
session()->setFlashdata('success', "Cash Deposite Master Added Successfully"); session()->setFlashdata('success', "Cash Deposite Master Added Successfully");
@ -1311,12 +1313,31 @@ class MasterController extends AdminController
->where('id', $id) ->where('id', $id)
->where('is_active', 1) ->where('is_active', 1)
->first(); ->first();
$db = db_connect();
$builder = $db->table('cd_master');
$builder->select('cd_master.cd_ac_no, cd_master.id, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction');
$builder->join('cash_deposit', 'cash_deposit.cd_ac_pk = cd_master.id');
$builder->where('cash_deposit.is_active', 1);
$builder->where('cd_master.is_active', 1);
$builder->where('cd_master.id', $id);
$builder->groupBy('cd_master.id');
// convert the date formate 2000-01-01 to 01-01-2000 $query = $builder->get();
$result = $query->getResultArray();
// print_r($result); die;
$count = 0;
if(isset($result[0])){
$count = $result[0]['cd_ac_no_count_cd_tranction'];
}
// convert the date formate 2000-01-01 to 01-01-2000
$cd_data['opening_date'] = date('d-m-Y', strtotime($cd_data['opening_date'])); $cd_data['opening_date'] = date('d-m-Y', strtotime($cd_data['opening_date']));
if ($cd_data) { if ($cd_data) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200); return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data, 'cd_transaction_count' => $count], 200);
} else { } else {
return $this->respond(['status' => false, 'code' => 404], 200); return $this->respond(['status' => false, 'code' => 404], 200);
} }
@ -1500,25 +1521,34 @@ class MasterController extends AdminController
} }
public function duplicateTemplate($template_id, $event_name) // Duplicate the insuer same policy type other events template
public function duplicateTemplate($template_id, $event_name, $insurer_id)
{ {
// Fetch the template data based on the provided ID and ensure it is active // Fetch the template data based on the provided ID and ensure it is active
$insurer_template_data = $this->insurerTemplateModel->where('id', $template_id) $insurer_template_data = $this->insurerTemplateModel->where('id', $template_id)
->where('is_active', 1) ->where('is_active', 1)
->first(); ->first();
// Check if the event name matches the existing template's event name
$insurer_template_data_check_duplicate = $this->insurerTemplateModel
->where('insurer_id', $insurer_id)
->where('event_name', $event_name)
->where('policy_type_id', $insurer_template_data['policy_type_id'])
->where('is_active', 1)
->findAll();
//if the template already exist than return the message
if (!empty($insurer_template_data_check_duplicate) && count($insurer_template_data_check_duplicate) > 0) {
return $this->respond([
'status' => false,
'message' => 'Template with the same event already exists.',
'data' => $insurer_template_data_check_duplicate
]);
}
if ($insurer_template_data) { if ($insurer_template_data) {
// Check if the event name matches the existing template's event name
if ($insurer_template_data['event_name'] == $event_name) {
return $this->respond([
'status' => false,
'message' => 'Template with the same event already exists.',
'data' => $insurer_template_data
]);
}
// Prepare data for insertion as a duplicate // Prepare data for insertion as a duplicate
$data_to_insert = [ $data_to_insert = [
"insurer_id" => $insurer_template_data['insurer_id'], "insurer_id" => $insurer_template_data['insurer_id'],
@ -1529,28 +1559,28 @@ class MasterController extends AdminController
"created_by" => get_session_user(), "created_by" => get_session_user(),
"is_active" => 1, "is_active" => 1,
]; ];
// Insert the duplicate template data // Insert the duplicate template data
$insert_result = $this->insurerTemplateModel->insert($data_to_insert); $insert_result = $this->insurerTemplateModel->insert($data_to_insert);
if ($insert_result) { if ($insert_result) {
return $this->respond([ return $this->respond([
'status' => true, 'status' => true,
'message' => 'Template duplicated successfully.', 'message' => 'Template duplicated successfully.',
'data' => $insurer_template_data 'data' => $insurer_template_data
]); ]);
} else { } else {
return $this->respond([ return $this->respond([
'status' => false, 'status' => false,
'message' => 'Failed to duplicate template.', 'message' => 'Failed to duplicate template.',
'data' => $insurer_template_data 'data' => $insurer_template_data
]); ]);
} }
} else { } else {
// No matching active template found // No matching active template found
return $this->respond([ return $this->respond([
'status' => false, 'status' => false,
'message' => 'No active template data found.', 'message' => 'No active template data found.',
'data' => null 'data' => null
]); ]);
} }
@ -1574,7 +1604,7 @@ class MasterController extends AdminController
$to = $this->request->getPost('to'); $to = $this->request->getPost('to');
$subject = $this->request->getPost('subject'); $subject = $this->request->getPost('subject');
$mail_content = $this->request->getPost('content'); $mail_content = $this->request->getPost('content');
$common = ['mail_type'=>'test_mail_ui'];
/*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/ /*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
/*****CALLING DIRECLT USING LIB******/ /*****CALLING DIRECLT USING LIB******/
@ -1591,7 +1621,7 @@ class MasterController extends AdminController
/*****CALLING DIRECLT USING LIB******/ /*****CALLING DIRECLT USING LIB******/
/*****CALLING VIA MAIL HELPER******/ /*****CALLING VIA MAIL HELPER******/
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject, 'message' => $mail_content]); $res = MailHelper::send_email(['mail' => $to, 'subject' => $subject,'common'=>$common ,'message' => $mail_content]);
return $this->respond(['status' => 'success','code' => 200,'data' => $res],200); return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
/*****CALLING VIA MAIL HELPER******/ /*****CALLING VIA MAIL HELPER******/
@ -1623,14 +1653,42 @@ class MasterController extends AdminController
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.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"] ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
]; ];
$common = ['mail_type'=>'test_mail_cli'];
$email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id; $email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments]); $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
echo "Inside the master controller";
print_r($res); print_r($res);
} }
public function testZeptoSMTP() {
$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 = 'srinivas.saravanan@venbainfotech.com';
$common = ['mail_type'=>'test_mail_cli'];
// Send email and get response
$result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
log_message('error',json_encode($result));
// Format the response for display/debugging
$response = [
'success' => $result['success'] ?? false,
'smtp_data' => [
'last_reply' => $result['smtp_data']['last_reply'] ?? '',
'error_info' => $result['smtp_data']['error_info'] ?? ''
],
'message_id' => $result['message_id'] ?? '',
'timestamp' => $result['timestamp'] ?? ''
];
// Return JSON response
return $this->response->setJSON($result);
}
public function testCheckBounceMails() public function testCheckBounceMails()
{ {
$gmailapi = \Config\Services::gmailapi(); $gmailapi = \Config\Services::gmailapi();
@ -1672,6 +1730,7 @@ class MasterController extends AdminController
'template_bg' => ROOTPATH . 'public/uploads/template_bg/', 'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
'attachments' => WRITEPATH . 'uploads/attachments/', 'attachments' => WRITEPATH . 'uploads/attachments/',
'sample_import_excel' => ROOTPATH . 'public/sample_import_excel', 'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
'lead_files' => WRITEPATH . 'uploads/lead_files/',
]; ];
foreach ($folders as $folderName => $folderPath) { foreach ($folders as $folderName => $folderPath) {

View File

@ -31,6 +31,7 @@ use App\Models\InsurerStatements;
use App\Models\InvPaymentDetailsModel; use App\Models\InvPaymentDetailsModel;
use App\Models\BatchFileModel; use App\Models\BatchFileModel;
use App\Models\FileModel; use App\Models\FileModel;
use App\Models\COShareStmtDetailsModel;
use Kint; use Kint;
class PolicyTransactionController extends BaseController class PolicyTransactionController extends BaseController
@ -62,6 +63,7 @@ class PolicyTransactionController extends BaseController
protected $invPaymentDetailsModel; protected $invPaymentDetailsModel;
protected $batchFileModel; protected $batchFileModel;
protected $filesModel; protected $filesModel;
protected $coShareStmtDetailsModel;
public function __construct() public function __construct()
{ {
@ -91,11 +93,12 @@ class PolicyTransactionController extends BaseController
$this->invPaymentDetailsModel = new InvPaymentDetailsModel(); $this->invPaymentDetailsModel = new InvPaymentDetailsModel();
$this->batchFileModel = new BatchFileModel(); $this->batchFileModel = new BatchFileModel();
$this->filesModel = new FileModel(); $this->filesModel = new FileModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->invoiceStatus = [ $this->invoiceStatus = [
'pending' => 'Pending', 'pending' => 'Pending',
'generated' => 'Generated', 'generated' => 'Generated',
'sent' => 'Sent', 'sent' => 'Sent',
'payment_received' => 'Payment Received', 'payment_received' => 'Payment<br> Received',
]; ];
} }
@ -179,6 +182,7 @@ class PolicyTransactionController extends BaseController
// Fetch additional data // Fetch additional data
$data['client'] = $this->clientModel->where('is_active', 1)->findAll(); $data['client'] = $this->clientModel->where('is_active', 1)->findAll();
$data['client_branch'] = $this->clientBranchModel->where('is_active', 1)->findAll();
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll(); $data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll(); $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll(); $data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
@ -221,6 +225,7 @@ class PolicyTransactionController extends BaseController
// print_r($this->request->getPost()); die; // print_r($this->request->getPost()); die;
$id = $this->request->getPost('id'); $id = $this->request->getPost('id');
$data = $this->preparePolicyData(); $data = $this->preparePolicyData();
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
// print_r($this->request->getPost()); die; // print_r($this->request->getPost()); die;
@ -430,7 +435,7 @@ class PolicyTransactionController extends BaseController
if(isset($data['follow_insurer_id'])){ if(isset($data['follow_insurer_id'])){
foreach ($data['follow_insurer_id'] as $index => $insurer) { foreach ($data['follow_insurer_id'] as $index => $insurer) {
// Separate the insurer and insurer branch // Separate the insurer and insurer branch
list($insurer_branch_id, $insurer_id) = explode('-', $insurer); list($insurer_branch_id, $insurer_id) = explode('-', $insurer);
@ -473,6 +478,7 @@ class PolicyTransactionController extends BaseController
'created_by' => get_session_userid() ?? null, 'created_by' => get_session_userid() ?? null,
'updated_by' => get_session_userid() ?? null, 'updated_by' => get_session_userid() ?? null,
'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records 'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records
'follower_policy_no' => $data['follower_policy_no'][$index] ?? null, // Assuming this is the ID to identify existing records
]; ];
} }
@ -529,7 +535,7 @@ class PolicyTransactionController extends BaseController
'created_by' => get_session_userid(), 'created_by' => get_session_userid(),
'policy_no' => $data['policy_no'] ?? null, 'policy_no' => $data['policy_no'] ?? null,
'client_branch_id' => $data['client_branch_id'] ?? 0, 'client_branch_id' => $data['client_branch_id'] ?? 0,
'cd_ac_no' => $data['cd_ac_no'] ?? null, 'cd_ac_pk' => $data['cd_ac_no'] ?? null,
'gst' => 18, 'gst' => 18,
]; ];
} }
@ -786,10 +792,24 @@ class PolicyTransactionController extends BaseController
->findAll(); ->findAll();
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel $data['pt_co_share_details'] = $this->PTCOShareDetailsModel
->where('pt_id', $id) ->select("
->where('is_active', 1) pt_co_share_details.*,
->orderBy('id', 'asc')
->findAll(); (
SELECT
COUNT(*)
FROM
co_share_stmt_details
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
) AS record_count
")
->where('pt_id', $id)
->where('is_active', 1)
->orderBy('id', 'asc')
->findAll();
$data['emp_data'] = $this->employeeModel $data['emp_data'] = $this->employeeModel
->select('employees.*, employee_polices.id as emp_policy_id') ->select('employees.*, employee_polices.id as emp_policy_id')
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left') ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
@ -1329,8 +1349,8 @@ class PolicyTransactionController extends BaseController
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
//get BDS Reports data //get BDS Reports data old function
public function reportBDS() public function reportBDSOld()
{ {
$data['page_name'] = 'BDS Report'; $data['page_name'] = 'BDS Report';
@ -1390,6 +1410,81 @@ class PolicyTransactionController extends BaseController
$this->loadLayout('report_bds_filter', $data); $this->loadLayout('report_bds_filter', $data);
} }
//get BDS Reports data New Function
public function reportBDS()
{
$data['page_name'] = 'BDS Report';
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$data['policy_status'] = [
'pending' => 'Pending',
'exported_to_insurer' => 'Exported to Insurer',
'imported_from_insurer' => 'Imported from Insurer',
'exported_to_tpa' => 'Exported to TPA',
'imported_from_tpa' => 'Imported from TPA',
'completed' => 'Completed'
];
$data['invoice_status_array'] = [
'yet_to_generate' => 'Yet to Generate',
'generated' => 'Generated',
'send' => 'Send',
'recived' => 'Recived',
];
$data['date_type'] = [
'policy_issue_date' => 'Policy Issue Date',
'policy_start_date' => 'Policy Start Date',
'policy_end_date' => 'Policy End Date',
'data_received_date' => 'Data Received Date',
'closure_date' => 'Closure Date',
'statement_month' => 'Statement Month',
];
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
//filter datas
$start_date = $this->request->getGet('start_date');
$end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer');
$client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id');
if($date_type == 'statement_month'){
$start_date = (string)date('Y-m-01', strtotime($start_date));
$end_date = (string)date('Y-m-31', strtotime($end_date));
}
// dd($start_date, $end_date, $date_type);
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$client_branch_id = (!isset($client_branch_id) || $client_branch_id === '' || $client_branch_id === null) ? 0 : $client_branch_id;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id;
//Actual data for the list
$data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id);
// dd($data['report_list']);
$this->loadLayout('report_bds_filter', $data);
}
public function reportVarience() public function reportVarience()
{ {
$data['page_name'] = 'Variance Report'; $data['page_name'] = 'Variance Report';
@ -1414,6 +1509,10 @@ class PolicyTransactionController extends BaseController
$policy_type_id = $this->request->getGet('policy_type_id'); $policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type'); $date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer'); $issuer = $this->request->getGet('issuer');
$client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id');
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date; $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date; $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
@ -1424,7 +1523,12 @@ class PolicyTransactionController extends BaseController
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type; $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer; $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer); $client_branch_id = (!isset($client_branch_id) || $client_branch_id === '' || $client_branch_id === null) ? 0 : $client_branch_id;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id;
$data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id);
$this->loadLayout('variance_report_list', $data); $this->loadLayout('variance_report_list', $data);
} }
@ -1531,20 +1635,17 @@ class PolicyTransactionController extends BaseController
$end_date = $this->request->getGet('end_date'); $end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id'); $client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id'); $insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id'); $insurer_branch_id = $this->request->getGet('insurer_branch_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer'); $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : change_date_format($start_date,'d-m-Y','Y-m-01');
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : change_date_format($end_date,'d-m-Y','Y-m-31');
// dd([$start_date,$end_date]);
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id; $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id; $insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer); $data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date,$insurer_id, $insurer_branch_id);
// dd($this->policyTransactionModel->getLastQuery()); // dd($this->policyTransactionModel->getLastQuery());
// dd($data); // dd($data);
$this->loadLayout('outstanding_report_list', $data); $this->loadLayout('outstanding_report_list', $data);
@ -1576,7 +1677,7 @@ class PolicyTransactionController extends BaseController
WHERE pt_co_share_details.is_active = 1 WHERE pt_co_share_details.is_active = 1
AND pt_co_share_details.statement_id = insurer_statements.id AND pt_co_share_details.statement_id = insurer_statements.id
) AS exp_inv_amt, ) AS exp_inv_amt,
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + SUM(inv_payment_details.gst)
FROM inv_payment_details FROM inv_payment_details
WHERE inv_payment_details.is_active = 1 WHERE inv_payment_details.is_active = 1
AND inv_payment_details.statement_id = insurer_statements.id AND inv_payment_details.statement_id = insurer_statements.id
@ -1649,9 +1750,10 @@ class PolicyTransactionController extends BaseController
$month = $month.'-01'; $month = $month.'-01';
// print_r($month);die; // print_r($month);die;
$month = change_date_format($month,'Y-M-d','Y-m-d'); $month = change_date_format($month,'Y-M-d','Y-m-d');
$stmt_sno = $this->request->getPost('statement_no');
// print_r($month);die; // print_r($month);die;
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID]); //here field policy_id have client_policy_id and not policy id from policy master $file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID,'stmt_sno' => $stmt_sno]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]); $this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]);
//validate file //validate file
@ -1739,47 +1841,52 @@ class PolicyTransactionController extends BaseController
unset($excel_data[0]); unset($excel_data[0]);
// Kint::dump($excel_data); // Kint::dump($excel_data);
//get no of line items and update in DB //get no of line items and update in DB
$line_items = count($excel_data); $line_items = 0;
// get uploaded month transactions data // get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// var_dump($source_data);die(); // var_dump($source_data);die();
// Kint::dump($source_data);//die(); // Kint::dump($source_data);//die();
// check policy no,insurer and etc in DB for this month // check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage // if all good return true, otherwise return false with messssage
foreach ($excel_data as $excel_key => $excel_row) foreach ($excel_data as $excel_key => $excel_row)
{ {
$is_row_empty = check_row_is_empty_or_null($excel_row); $is_row_empty = check_row_is_empty_or_null($excel_row);
if($is_row_empty) if(!$is_row_empty)
{ {
continue; $is_source_found = 0;
} $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
$is_source_found = 0; foreach ($source_data as $source_key => $source_row)
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
foreach ($source_data as $source_key => $source_row)
{
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d/m/Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d/m/Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
{ {
$is_source_found = 1; $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : "";
unset($source_data[$source_key]); if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
continue 2; {
$is_source_found = 1;
$line_items = $line_items + 1;
unset($source_data[$source_key]);
continue 2;
}
}
if($is_source_found == 0)
{
// echo $excel_key.'-'.$excel_row[1] . '- not found<br>';
$error_data['error_code'] = 1;//match not found
// $error_data['error_data'] = ($error_data['error_data'] ?? []);
$error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
} }
}
if($is_source_found == 0)
{
// echo $excel_key.'-'.$excel_row[1] . '- not found<br>';
$error_data['error_code'] = 1;//match not found
// $error_data['error_data'] = ($error_data['error_data'] ?? []);
$error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
} }
} }
// dd($error_data);
if($error_data['error_code']) if($error_data['error_code'])
{ {
$status = 'failed'; $status = 'failed';
@ -1793,6 +1900,7 @@ class PolicyTransactionController extends BaseController
public function updateInsurerStatement($params) public function updateInsurerStatement($params)
{ {
helper('excel_util_helper');
//get file info //get file info
$file_id = $params['file_id']; $file_id = $params['file_id'];
$file = $this->insurerStatements->find($file_id); $file = $this->insurerStatements->find($file_id);
@ -1837,7 +1945,7 @@ class PolicyTransactionController extends BaseController
//get no of line items and update in DB //get no of line items and update in DB
$line_items = count($excel_data); $line_items = count($excel_data);
// get uploaded month transactions data // get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// Kint::dump($source_data);die; // Kint::dump($source_data);die;
// Kint::dump($excel_data); // Kint::dump($excel_data);
@ -1846,92 +1954,100 @@ class PolicyTransactionController extends BaseController
$data_to_update = []; $data_to_update = [];
foreach ($excel_data as $excel_key => $excel_row) foreach ($excel_data as $excel_key => $excel_row)
{ {
$is_source_found = 0; $is_row_empty = check_row_is_empty_or_null($excel_row);
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel if(!$is_row_empty)
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
foreach ($source_data as $source_key => $source_row)
{ {
// Kint::dump(change_date_format($excel_row[3],'d/m/Y','Y-m-d'));
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d/m/Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d/m/Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) $is_source_found = 0;
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
foreach ($source_data as $source_key => $source_row)
{ {
$is_source_found = 1; // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : "";
//calculate percentage first if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
$total_amt = 0;
$actual_bp_per = trim($excel_row[9]);
$actual_bp_brokerage = trim($excel_row[12]);
$actual_bp_amt = trim($excel_row[6]);
if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != ""))
{ {
$total_amt += $actual_bp_brokerage; $is_source_found = 1;
//percentage reverse calculation
if($actual_bp_per == 0 || $actual_bp_per == "") //calculate percentage first
$total_amt = 0;
$actual_bp_per = trim($excel_row[9]);
$actual_bp_brokerage = trim($excel_row[12]);
$actual_bp_amt = trim($excel_row[6]);
if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != ""))
{ {
$actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2); $total_amt += $actual_bp_brokerage;
//percentage reverse calculation
if($actual_bp_per == 0 || $actual_bp_per == "")
{
$actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2);
}
} }
else
}
else
{
$actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
$total_amt += $actual_bp_brokerage;
}
$actual_tp_per = trim($excel_row[10]);
$actual_tp_brokerage = trim($excel_row[13]);
$actual_tp_amt = trim($excel_row[7]);
if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "")
{
$total_amt += $actual_tp_brokerage;
//percentage reverse calculation
if($actual_tp_per == 0 || $actual_tp_per == "")
{ {
$actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100; $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
$total_amt += $actual_bp_brokerage;
} }
}
else
{
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
$total_amt += $actual_tp_brokerage;
}
$actual_tep_per = trim($excel_row[11]); $actual_tp_per = trim($excel_row[10]);
$actual_tep_brokerage = trim($excel_row[14]); $actual_tp_brokerage = trim($excel_row[13]);
$actual_tep_amt = trim($excel_row[8]); $actual_tp_amt = trim($excel_row[7]);
if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "")
{
$total_amt += $actual_tep_brokerage;
//percentage reverse calculation
if($actual_tep_per == 0 || $actual_tep_per == "")
{ {
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; $total_amt += $actual_tp_brokerage;
//percentage reverse calculation
if($actual_tp_per == 0 || $actual_tp_per == "")
{
$actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
}
} }
else
{
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
$total_amt += $actual_tp_brokerage;
}
$actual_tep_per = trim($excel_row[11]);
$actual_tep_brokerage = trim($excel_row[14]);
$actual_tep_amt = trim($excel_row[8]);
if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "")
{
$total_amt += $actual_tep_brokerage;
//percentage reverse calculation
if($actual_tep_per == 0 || $actual_tep_per == "")
{
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
}
}
else
{
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
$total_amt += $actual_tep_brokerage;
}
//find variance
$variance_amt = $source_row['exp_amt'] - $total_amt;
$data_to_update[] = ['co_share_id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
unset($source_data[$source_key]);
continue 2;
} }
else
{
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
$total_amt += $actual_tep_brokerage;
}
//find variance
$variance_amt = $source_row['exp_amt'] - $total_amt;
$data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
unset($source_data[$source_key]);
continue 2;
} }
} }
} }
$this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id'); // dd($data_to_update);
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
// dd($data_to_update); // dd($data_to_update);
// if($error_data['error_code']) // if($error_data['error_code'])
// { // {
@ -1953,8 +2069,24 @@ class PolicyTransactionController extends BaseController
->where('is_active',1) ->where('is_active',1)
->get() ->get()
->getResultArray(); ->getResultArray();
if(!$inv_details['invoice_value'])
{
$stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value')
->where('statement_id',$statement_id)
->groupBy('statement_id')
->get()
->getResultArray();
// print_r($stmt_level_value);
if($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0]))
{
$inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value'];
}
}
// ~dd($inv_details); // ~dd($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'], $data = [ 'invoice_status' => $inv_details['invoice_status'],
'gst_per' => isset($inv_details['gst_per']) ? $inv_details['gst_per'] : 18 ,
'invoice_value' => $inv_details['invoice_value'],
'gst_value' => $inv_details['gst_value'],
'invoice_no' => $inv_details['invoice_no'], 'invoice_no' => $inv_details['invoice_no'],
'invoice_amount' => $inv_details['invoice_amount'], 'invoice_amount' => $inv_details['invoice_amount'],
'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ]; 'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ];
@ -1976,6 +2108,9 @@ class PolicyTransactionController extends BaseController
$invoiceNo = $jsonData['invoice_no']; $invoiceNo = $jsonData['invoice_no'];
$invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d'); $invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d');
$invoice_amount = $jsonData['invoice_amount']; $invoice_amount = $jsonData['invoice_amount'];
$invoice_value = $jsonData['invoice_value'];
$gst_per = $jsonData['invoice_gst_per'];
$gst_value = $jsonData['invoice_gst'];
//Update statement table //Update statement table
$parentData = [ $parentData = [
@ -1983,6 +2118,9 @@ class PolicyTransactionController extends BaseController
'invoice_no' => $invoiceNo, 'invoice_no' => $invoiceNo,
'invoice_date' => $invoiceDate, 'invoice_date' => $invoiceDate,
'invoice_amount' => $invoice_amount, 'invoice_amount' => $invoice_amount,
'gst_per' => $gst_per,
'gst_value' => $gst_value,
'invoice_value' => $invoice_value,
'updated_by' => get_session_userid() 'updated_by' => get_session_userid()
]; ];
@ -1994,6 +2132,7 @@ class PolicyTransactionController extends BaseController
$receivedAmounts = $jsonData['received_amount']; $receivedAmounts = $jsonData['received_amount'];
$utrNos = $jsonData['utr_no']; $utrNos = $jsonData['utr_no'];
$tdsTotal = $jsonData['tds']; $tdsTotal = $jsonData['tds'];
$gstTotal = $jsonData['gst_amount'];
$paymentDates = $jsonData['payment_date']; $paymentDates = $jsonData['payment_date'];
$pks = $jsonData['pk']; $pks = $jsonData['pk'];
@ -2001,6 +2140,7 @@ class PolicyTransactionController extends BaseController
$pk = $pks[$index]; // Get the pk for the current record $pk = $pks[$index]; // Get the pk for the current record
$utrNo = $utrNos[$index]; $utrNo = $utrNos[$index];
$tds = $tdsTotal[$index]; $tds = $tdsTotal[$index];
$gst = $gstTotal[$index];
$paymentDate = $paymentDates[$index]; $paymentDate = $paymentDates[$index];
// Prepare data for insert/update // Prepare data for insert/update
@ -2008,6 +2148,7 @@ class PolicyTransactionController extends BaseController
'inv_amt' => $receivedAmount, 'inv_amt' => $receivedAmount,
'utr_no' => $utrNo, 'utr_no' => $utrNo,
'tds' => $tds, 'tds' => $tds,
'gst' => $gst,
'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'), 'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'),
'statement_id' => $hiddenStatementId 'statement_id' => $hiddenStatementId
]; ];
@ -2107,5 +2248,182 @@ class PolicyTransactionController extends BaseController
} }
//---------------------------------------------------------------------------------------------------
public function getCoShareStatementDetails($pt_id)
{
if (!$pt_id) {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'No data found'
], 200);
}
// Fetch data from the database
$data = db_connect()->table("co_share_stmt_details")
->select("
co_share_stmt_details.*,
insurer_statements.month,
insurer_statements.invoice_status,
insurer_statements.invoice_date,
insurer_statements.invoice_no,
insurer_statements.invoice_amount,
insurer_statements.stmt_sno,
(co_share_stmt_details.actual_bp_amt + co_share_stmt_details.actual_tp_amt + co_share_stmt_details.actual_tep_amt) AS sum_of_actual_amt
")
->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id')
->where([
'co_share_stmt_details.is_active' => 1,
'insurer_statements.is_active' => 1,
'co_share_stmt_details.co_share_id' => $pt_id
])
->get()
->getResultArray();
// Check if data exists before formatting
if ($data) {
foreach ($data as &$row) {
// Check if invoice_date is not null before formatting
$row['invoice_date'] = $row['invoice_date'] ? change_date_format($row['invoice_date'], 'Y-m-d', 'd/m/Y') : null;
// Check if month is not null before formatting
$row['month'] = $row['month'] ? change_date_format($row['month'], 'Y-m-d', 'M-Y') : null;
}
return $this->respond([
'status' => true,
'code' => 200,
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'No data found'
], 200);
}
}
public function getClientPolicyDataBasedOnClientAndInsuer()
{
$client_id = $this->request->getGet('client_id') ?? 0;
$client_branch_id = $this->request->getGet('client_branch_id') ?? 0;
$insurer_id = $this->request->getGet('insurer_id') ?? 0;
$insurer_branch_id = $this->request->getGet('insurer_branch_id') ?? 0;
$policy_type_id = $this->request->getGet('policy_type_id') ?? 0;
$builder = db_connect()->table("client_policy")
->select("
client_policy.*,
policy_type.policy_type,
")
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
->where([
'client_policy.is_active' => 1,
]);
if (!empty($client_id)) {
$builder->where('client_policy.client_id', $client_id);
}
if (!empty($client_branch_id)) {
$builder->where('client_policy.client_branch_id', $client_branch_id);
}
if (!empty($insurer_id)) {
$builder->where('client_policy.insurer_id', $insurer_id);
}
if (!empty($insurer_branch_id)) {
$builder->where('client_policy.insurer_branch_id', $insurer_branch_id);
}
if (!empty($policy_type_id)) {
$builder->where('client_policy.policy_type_id', $policy_type_id);
}
$result = $builder->get()->getResultArray();
if ($result) {
return $this->respond(['status' => true,'code' => 200,'data' => $result, 'getData' => $this->request->getGet()], 200);
} else {
return $this->respond(['status' => false,'code' => 400,'message' => 'No data found'], 200);
}
}
public function checkCDAmountForBasePremium()
{
$base_premium = $this->request->getGet('base_premium') ?? 0;
$cd_ac_no = $this->request->getGet('cd_ac_no') ?? 0;
// Validate inputs
if (empty($cd_ac_no)) {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'CD Account Number is required'], 200);
}
// Build query
$db = db_connect();
$builder = $db->table("cash_deposit")
->where('cd_ac_no', $cd_ac_no)
->where('is_active', 1)
->orderBy('id', 'desc')
->limit(1);
$result = $builder->get()->getRowArray();
if ($result) {
// Check if base premium exceeds balance
$base_premium_greater_than_balance = $base_premium > $result['balance'];
return $this->respond([
'status' => true,
'code' => 200,
'data' => $result,
'base_premium_greater_than_balance' => $base_premium_greater_than_balance,
], 200);
}
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found for this CD'], 200);
}
public function getInsurerStatementMonth()
{
$insurer_id = $this->request->getGet('insurer_id');
$month = $this->request->getGet('month');
// echo $month;
$insurer_branch_id = explode('-',$insurer_id)[1];
$insurer_id = explode('-',$insurer_id)[0];
$month = $month.'-01';
$month = change_date_format($month,'Y-M-d','Y-m-d');
// echo $month;
$res_data = $this->insurerStatements
->where('insurer_id',$insurer_id)
->where('branch_id',$insurer_branch_id)
->where('month', $month)
->where('is_active', 1)
->where('file_status', 'success')
->findAll();
return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $res_data], 200);
}
public function deleteStatement($id)
{
// echo $id;die();
$this->coShareStmtDetailsModel->where('statement_id',$id)
->set(['is_active' => 0])
->update();
$this->invPaymentDetailsModel->where('statement_id',$id)
->set(['is_active' => 0])
->update();
$this->insurerStatements->where('id',$id)
->set(['is_active' => 0])
->update();
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
}
} }

View File

@ -4,7 +4,7 @@
namespace App\Controllers; namespace App\Controllers;
use App\Helpers\MailHelper;
use App\Controllers\LoginController; use App\Controllers\LoginController;
use App\Helpers\DepositHelper; use App\Helpers\DepositHelper;
use App\Helpers\JWTToken; use App\Helpers\JWTToken;
@ -73,7 +73,9 @@ class RestAuthenticationController extends AdminController
$employeeData = $this->employeeModel->where('mobile', $mobile_number) $employeeData = $this->employeeModel->where('mobile', $mobile_number)
->where('relationship', 'self') ->where('relationship', 'self')
->where('is_active', 1)->first(); ->where('emp_status !=', 'truncated')
->where('is_active', 1)
->first();
if ($employeeData) { if ($employeeData) {
@ -88,24 +90,93 @@ class RestAuthenticationController extends AdminController
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
} }
} }
public function verifyEmployeeWithEmailId()
{
try {
$email = $this->request->getJSON()->email;
$employeeData = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
->where('emp_status !=', 'truncated')->where('is_active', 1)
->first();
if ($employeeData) {
$otp = random_int(100000, 999999);
$update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
->where('is_active', 1)->set(array('otp' => $otp ))
->update();
if($update)
{
$common = [
'client_id' => $employeeData['client_id'],
'client_branch_id' => $employeeData['client_branch_id'],
'client_policy_id' => null,
'employee_policy_id' => null,
'employee_id' => $employeeData['id'],
'mail_type' => 'otp_mail',
];
$subject = 'Nhance user verification - OTP';
$mail_content = $otp.' is your verification code for Nhance.';
$res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]);
$this->myLogger->logme("info", $res);
if(json_decode($res)->status == 'success')
{
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
}else{
$result = ['user_verification' => false , 'message' => "Mail sending failed , try again"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
}
}else{
$result = ['user_verification' => false , 'message' => "Verification failed , try again"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
}
} else {
$result = ['user_verification' => false , 'message' => "User not found"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
}
} catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
}
}
public function getVerifiedUserData() public function getVerifiedUserData()
{ {
try { try {
$mobile_number = $this->request->getJSON()->mobile_number;
$otp_verification = $this->request->getJSON()->otp_verification; $otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
if (isset($this->request->getJSON()->login_by_hr)) if (isset($this->request->getJSON()->login_by_hr))
{ {
$employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->first(); $employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
}else{ }else{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); if (isset($mobile_number))
{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
} else {
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
}
} }
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr) || $employeeData && isset($this->request->getJSON()->otp) ) {
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
$auth = HttpRequestHelper::getRequestInfo(); $auth = HttpRequestHelper::getRequestInfo();
if ($auth) { if ($auth) {
$data = [ $data = [
@ -120,6 +191,11 @@ class RestAuthenticationController extends AdminController
$result = JWTToken::encode($employeeData); $result = JWTToken::encode($employeeData);
if(isset($this->request->getJSON()->otp)){
$this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update();
}
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else { } else {
@ -137,7 +213,8 @@ class RestAuthenticationController extends AdminController
$HrData = $this->hrModel->where('mobile', $mobile_number) $HrData = $this->hrModel->where('mobile', $mobile_number)
->where('contact_type', 'client') ->where('contact_type', 'client')
->where('is_active', 1)->first(); ->where('is_active', 1)
->first();
if ($HrData) { if ($HrData) {
@ -214,11 +291,20 @@ class RestAuthenticationController extends AdminController
public function saveMpin() public function saveMpin()
{ {
try { try {
$mobile_number = $this->request->getJSON()->mobile_number;
$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;
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();
}
$mpin = $this->request->getJSON()->mpin; $mpin = $this->request->getJSON()->mpin;
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
if ($employeeData) { if ($employeeData) {
$id= $employeeData["id"]; $id= $employeeData["id"];
@ -245,12 +331,20 @@ class RestAuthenticationController extends AdminController
public function updateMpin() public function updateMpin()
{ {
try { try {
$mobile_number = $this->request->getJSON()->mobile_number;
$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;
$old_mpin = $this->request->getJSON()->old_mpin; $old_mpin = $this->request->getJSON()->old_mpin;
$mpin = $this->request->getJSON()->new_mpin; $mpin = $this->request->getJSON()->new_mpin;
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); if (isset($mobile_number))
{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
}else{
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
}
if ($employeeData) { if ($employeeData) {
$id= $employeeData["id"]; $id= $employeeData["id"];
@ -277,10 +371,17 @@ class RestAuthenticationController extends AdminController
public function verifyMpin() public function verifyMpin()
{ {
try { try {
$mobile_number = $this->request->getJSON()->mobile_number;
$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;
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); 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"]) { if ($employeeData && $mpin == $employeeData["mpin"]) {
$auth = HttpRequestHelper::getRequestInfo(); $auth = HttpRequestHelper::getRequestInfo();
@ -312,10 +413,19 @@ class RestAuthenticationController extends AdminController
public function checkMpin() public function checkMpin()
{ {
try { try {
$mobile_number = $this->request->getJSON()->mobile_number; $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();
}
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
if ($employeeData && $employeeData["mpin"] != null) { if ($employeeData && $employeeData["mpin"] != null) {

View File

@ -40,7 +40,7 @@ class UserController extends AdminController
$data['UserList'] = $this->userModel->getUserList(); $data['UserList'] = $this->userModel->getUserList();
// echo '<pre>'; // echo '<pre>';
// print_r($data); die; // print_r($data); die;
$data['roleData'] = $this->roleModel->select('id, role')->findAll(); $data['roleData'] = $this->roleModel->select('id, role')->findAll();
$data['teamData'] = $this->teamModel->select('id, name')->findAll(); $data['teamData'] = $this->teamModel->select('id, name')->findAll();
$this->loadLayout('UserList', $data); $this->loadLayout('UserList', $data);
} }
@ -71,39 +71,43 @@ class UserController extends AdminController
$this->userTeamsModel->insert($teamData); $this->userTeamsModel->insert($teamData);
} }
$db = \Config\Database::connect();
$tableName = 'hdz_staff';
// Set default values
$admin = 0;
$acm = 0;
$acm_id = null;
if ($userData['role'] == 3) { if ($userData['role'] == 3) {
$db = \Config\Database::connect();
$tableName = 'hdz_staff';
$admin = 0; $admin = 0;
$acm = 1; $acm = 1;
$acm_id = $insert; $acm_id = $insert;
} else if (in_array($userData['role'], [1, 5])) {
$password = '12345678'; //Default password $admin = 1;
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); $acm = 0;
$acm_id = null;
foreach ($temp_team as $key => $value) {
$team = $this->teamModel->where('id', $value)->first();
if ($team['name'] == 'Claims') {
$hdz_staff = [
'emp_code' => $userData['emp_code'],
'fullname' => $userData['first_name'],
'username' => strtolower($userData['first_name']),
'email' => $userData['email'],
'admin' => $admin,
'acm' => $acm,
'acm_id' => $acm_id,
'registration' => time(),
'password' => $hashedPassword,
'active' => 1,
];
$db->table($tableName)->insert($hdz_staff);
}
}
} }
$password = '12345678'; // Default password
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$hdz_staff = [
'emp_code' => $userData['emp_code'],
'fullname' => $userData['first_name'],
'username' => strtolower($userData['first_name']),
'email' => $userData['email'],
'admin' => $admin,
'acm' => $acm,
'acm_id' => $acm_id,
'registration' => time(),
'password' => $hashedPassword,
'active' => 1,
'department' => 'a:7:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"5";i:3;s:1:"3";i:4;s:1:"9";i:5;s:1:"4";i:6;s:2:"10";}',
];
$db->table($tableName)->insert($hdz_staff);
} }
} }
$this->myLogger->logme('error', 'User create Successfully created by id {data}', ['data' => get_session_userid()]); $this->myLogger->logme('error', 'User create Successfully created by id {data}', ['data' => get_session_userid()]);
@ -149,33 +153,55 @@ class UserController extends AdminController
} }
} }
$db = \Config\Database::connect();
$tableName = 'hdz_staff';
$hdz_staff = [
'emp_code' => $userData['emp_code'],
'fullname' => $userData['first_name'],
'username' => strtolower($userData['first_name']),
'email' => $userData['email'],
'registration' => time(),
'active' => 1,
'department' => 'a:7:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"5";i:3;s:1:"3";i:4;s:1:"9";i:5;s:1:"4";i:6;s:2:"10";}',
];
if ($userData['role'] == 3) { if ($userData['role'] == 3) {
$hdz_staff['admin'] = 0;
$db = \Config\Database::connect(); $hdz_staff['acm'] = 1;
$tableName = 'hdz_staff'; $hdz_staff['acm_id'] = $id;
$admin = 1; } elseif (in_array($userData['role'], [1, 5])) {
$hdz_staff['admin'] = 1;
foreach ($userData['team'] as $key => $value) { $hdz_staff['acm'] = 0;
if ($value == 2) { $hdz_staff['acm_id'] = null;
} else {
$hdz_staff = [
'emp_code' => $userData['emp_code'], return redirect()->to(base_url('/user/list'));
'fullname' => $userData['first_name'],
'username' => strtolower($userData['first_name']),
'email' => $userData['email'],
'admin' => $admin,
'registration' => time(),
'active' => 1,
];
$db->table($tableName)->where('emp_code', $userData['emp_code'])
->where('email', $userData['email'])
->set($hdz_staff)
->update();
}
}
} }
// Check if staff data exists
$staffData = $db->table($tableName)
// ->where('emp_code', $userData['emp_code'])
->where('email', $userData['email'])
->get()->getResult();
if (!empty($staffData)) {
// Update existing record
$db->table($tableName)
// ->where('emp_code', $userData['emp_code'])
->where('email', $userData['email'])
->set($hdz_staff)->update();
} else {
$password = '12345678'; // Default password
$hdz_staff['password'] = password_hash($password, PASSWORD_DEFAULT);
// Insert new record
$db->table($tableName)->insert($hdz_staff);
}
} }
return redirect()->to(base_url('/user/list')); return redirect()->to(base_url('/user/list'));

View File

@ -9,7 +9,7 @@ class AuthMVC implements FilterInterface
{ {
public function before(RequestInterface $request, $arguments = null) public function before(RequestInterface $request, $arguments = null)
{ {
if (!check_session()) { if (!check_session() && !check_cookie()) {
return redirect()->to(base_url('/login')); return redirect()->to(base_url('/login'));
} }

View File

@ -62,6 +62,7 @@ class DepositHelper
'created_by' => $loggedInUserID, 'created_by' => $loggedInUserID,
'updated_by' => $data['updated_by'], 'updated_by' => $data['updated_by'],
'balance' => $newBalance, // Include the new balance in the data array 'balance' => $newBalance, // Include the new balance in the data array
'cd_ac_pk'=> isset($data['cd_ac_pk'])?$data['cd_ac_pk']:null,
]; ];
// Insert data and get the insert ID // Insert data and get the insert ID

View File

@ -0,0 +1,150 @@
<?php
namespace App\Helpers;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use Exception;
class ExcelMergeHelper {
/**
* Main merge function with auto-retry
*
* @param array $filePaths Array of file paths with optional sheets to merge.
* @param string $outputPath Path to save the merged Excel file.
* @return string|null Returns output path on success, null on failure.
*/
public static function mergeExcelFiles(array $filePaths, string $outputPath): ?string
{
try {
log_message('debug', 'Attempting merge with original file order');
return self::processFiles($filePaths, $outputPath);
} catch (Exception $e) {
log_message('error', 'First attempt failed: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
log_message('debug', 'Retrying with reversed file order');
// Reverse the file order and try again
$reversedFiles = array_reverse($filePaths);
try {
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());
return null;
}
}
}
/**
* Process files to merge spreadsheets
*
* @param array $filePaths
* @param string $outputPath
* @return string
* @throws Exception
*/
private static function processFiles(array $filePaths, string $outputPath): string
{
log_message('debug', 'Starting Excel merge process');
log_message('debug', 'Files to process: ' . json_encode($filePaths));
if (empty($filePaths)) {
throw new Exception("No files provided to merge");
}
// Initialize an empty merged spreadsheet
$mergedSpreadsheet = new Spreadsheet();
$mergedSpreadsheet->removeSheetByIndex(0); // Remove the default empty sheet
// Process the base file
$firstFile = array_shift($filePaths);
self::processSingleFile($firstFile, $mergedSpreadsheet);
// Process remaining files
foreach ($filePaths as $index => $fileInfo) {
self::processSingleFile($fileInfo, $mergedSpreadsheet, $index);
}
// Save the merged file
log_message('debug', "Saving merged file to: {$outputPath}");
$writer = IOFactory::createWriter($mergedSpreadsheet, 'Xlsx');
$writer->setPreCalculateFormulas(false);
$writer->save($outputPath);
// Clean up
$mergedSpreadsheet->disconnectWorksheets();
unset($mergedSpreadsheet);
gc_collect_cycles();
log_message('debug', 'Excel merge process completed successfully');
return $outputPath;
}
/**
* Process a single file to merge its sheets into the merged spreadsheet
*
* @param array $fileInfo
* @param Spreadsheet $mergedSpreadsheet
* @param int|null $index
* @throws Exception
*/
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}");
return;
}
log_message('debug', "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path']);
try {
// Load the source spreadsheet
$sourceSpreadsheet = IOFactory::load($fileInfo['file_path']);
// Get all worksheets
$worksheets = $sourceSpreadsheet->getAllSheets();
$totalSheets = count($worksheets);
log_message('debug', "Total sheets in file: " . $totalSheets);
$sheetsToMerge = $fileInfo['sheets'] ?? [];
// Process each worksheet
foreach ($worksheets as $sheetIndex => $worksheet) {
if (empty($sheetsToMerge) || in_array($sheetIndex, $sheetsToMerge)) {
try {
$sheetName = $worksheet->getTitle();
log_message('debug', "Processing sheet: {$sheetName}");
// 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}");
}
// Clone the worksheet and set the new name
$clonedSheet = clone $worksheet;
$clonedSheet->setTitle($newName);
// Add as external sheet
$mergedSpreadsheet->addExternalSheet($clonedSheet);
log_message('debug', "Successfully added sheet: {$newName}");
} catch (Exception $e) {
log_message('error', "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
}
}
}
// Clean up source spreadsheet
$sourceSpreadsheet->disconnectWorksheets();
unset($sourceSpreadsheet);
gc_collect_cycles();
} catch (Exception $e) {
log_message('error', "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
}
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace App\Helpers;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class ExcelSanitizeHelper
{
/**
* Array of non-printable characters to be removed from strings.
*
* You can modify this array to include any characters you want to remove.
*/
private static $nonPrintableChars = [
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09",
"\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13",
"\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D",
"\x1E", "\x1F", "\x7F", "_x000D_", "_x000A_", "_x0009_", "_x0008_", "_x0007_",
"_x0006_", "_x0005_", "_x0004_", "_x0003_", "_x0002_", "_x0001_"
];
/**
* Sanitizes array data by removing non-printable characters and trimming whitespace from strings.
*
* @param array $data Input array containing data to sanitize
* @return array Sanitized array with non-printable characters removed and leading/trailing whitespace trimmed
*/
public static function sanitizeArrayData(array $data): array
{
try {
$cleanData = [];
foreach ($data as $key => $value) {
if (is_array($value)) {
$cleanData[$key] = self::sanitizeArrayData($value); // Recursive call for nested arrays
} elseif (is_string($value)) {
// Remove non-printable characters and trim whitespace from strings
$cleanData[$key] = trim(str_replace(self::$nonPrintableChars, '', $value));
} else {
$cleanData[$key] = $value; // Keep non-string/non-array data as is
}
}
return $cleanData;
} catch (\Exception $e) {
// Log the error and the problematic data for debugging
log_message('error', 'Error sanitizing array data: ' . $e->getMessage());
log_message('error', 'Problematic data: ' . json_encode($data));
return $data; // Return the original data in case of error
}
}
}

View File

@ -0,0 +1,125 @@
<?php
namespace App\Helpers;
use App\Models\EmployeePolicyModel;
use App\Models\GmailSentHistoryModel;
use Exception;
class GmailResponseHandler{
private $myLogger;
public function __construct()
{
$this->myLogger = \Config\Services::mylogger();
}
public function receive_and_distribute_param_to_functions($params)
{
try{
$this->store_gmail_response_data($params);
$this->gmail_response_logger($params);
$this->client_id_flag_setter($params);
}
catch(Exception $e)
{
$error = $e->getMessage();
echo "An Error Occured" . $error;
log_message('error',$error);
}
}
public function store_gmail_response_data($params){
// foreach ($params as $key => $value){
// $prepare_data = [
// $key => $value
// ];
// }
// $data = [
// 'email' => isset($params['params']['mail']) ? $params['params']['mail'] : null,
// 'bcc' => isset($params['params']['bcc']) ? json_encode($params['params']['bcc']) : null,
// 'cc' => isset($params['params']['cc']) ? json_encode($params['params']['cc']) : null,
// 'message' => isset($params['params']['message']) ? $params['params']['message'] : null,
// 'attachments' => isset($params['params']['attachments']) ? json_encode($params['params']['attachments']) : null,
// 'client_id' => isset($params['params']['common']['client_id']) ? $params['params']['common']['client_id'] : null,
// 'client_branch_id' => isset($params['params']['common']['client_branch_id']) ? $params['params']['common']['client_branch_id'] : null,
// 'client_policy_id' => isset($params['params']['common']['client_policy_id']) ? $params['params']['common']['client_policy_id'] : null,
// 'employee_policy_id' => isset($params['params']['common']['employee_policy_id']) ? $params['params']['common']['employee_policy_id'] : null,
// 'employee_id' => isset($params['params']['common']['employee_id']) ? $params['params']['common']['employee_id'] : null,
// 'mail_type' => isset($params['params']['common']['mail_type']) ? $params['params']['common']['mail_type'] : null,
// 'gmail_api_status' => isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null,
// 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null
// ];
// Initialize data array
$data = [];
// print_r($params['params']['common']);die();
if (isset($params['params']['common'])) {
foreach ($params['params']['common'] as $key => $value) {
$data[$key] = isset($value) ? $value : null;
}
unset($params['params']['common']);
}
if (isset($params['params'])){
foreach($params['params'] as $key => $value){
$arr = ['bcc','cc','attachments'];
if(in_array($key,$arr)){
$data[$key] = isset($value)?json_encode($value):null;
}else{
$data[$key] = isset($value)?$value:null;
}
}
}
if(isset($params['zepto_api']['data']) && $params['zepto_api']['message'] == 'OK' ){
$data['gmail_api_status'] = isset($params['zepto_api']['data']) ? $params['zepto_api']['data'][0]['code'] : null;
$data['gmail_api_id'] = isset($params['zepto_api']['request_id']) ? $params['zepto_api']['request_id'] : null;
$data['received_message'] = isset($params['zepto_api']['data'][0]['message']) ? json_encode($params['zepto_api']['data'][0]['message']) : null;
}
elseif(isset($params['zepto_api']['error'])){
$data['gmail_api_status'] = isset($params['zepto_api']['error']['code'])?$params['zepto_api']['error']['code']:null;
$data['received_message'] = json_encode($params['zepto_api']);
$data['gmail_api_id'] = isset($params['zepto_api']['error']['request_id']) ? $params['zepto_api']['error']['request_id'] : null;
}
$gmailModel = new GmailSentHistoryModel();
$save_status = $gmailModel->insert($data);
}
public function gmail_response_logger($params)
{
if(isset($params['zepto_api']['error'])){
$this->myLogger->logme('error',json_encode($params));
}
}
public function client_id_flag_setter($params)
{
try{
if (isset($params['params']['common']['mail_type'])){
if($params['params']['common']['mail_type'] == 'member_ecard_mail'){
$employeePolicyModel = new EmployeePolicyModel();
$update_status = $employeePolicyModel->where('id',$params['params']['common']['employee_policy_id'])->set('ecard_sent_status',1)->update();
if($update_status){
$this->myLogger->logme('error',"ecard_sent_status updated for ".$params['params']['common']['employee_policy_id']);
}else{
$this->myLogger->logme('error','ecard_sent_status failed to update');
}
}
}
}
catch(Exception $e){
$error = $e->getMessage();
$this->myLogger->logme('error','An Error Occured - '.$error);
}
}
}

View File

@ -11,7 +11,7 @@ use Firebase\JWT\SignatureInvalidException;
// use Psr\Http\Message\RequestInterface; // use Psr\Http\Message\RequestInterface;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use ReflectionClass; use ReflectionClass;
use Exception;
use App\Models\EmployeeModel; use App\Models\EmployeeModel;
use App\Models\LevelContactModel; use App\Models\LevelContactModel;

View File

@ -1,164 +1,422 @@
<?php <?php
// namespace App\Helpers;
// use Psr\Log\LoggerInterface;
// use App\Controllers\BaseController;
// use PHPMailer\PHPMailer\PHPMailer;
// use PHPMailer\PHPMailer\SMTP;
// use PHPMailer\PHPMailer\Exception;
// use App\Models\JobModel;
// class MailHelper
// {
// public static function send_email_smtp($params)
// {
// // print_r($params);die;
// $myLogger = \Config\Services::mylogger();
// $emaill = $params['mail'];
// $subject = $params['subject'];
// $message = $params['message'];
// if (isset($params['bcc'])) {
// $bcc = $params['bcc'];
// }else{
// $bcc= '';
// }
// try {
// $email = \Config\Services::email();
// $email->setMailType('html');
// $email->setFrom('bbone@venbait.in', 'Nhance');
// $email->setTo($emaill);
// if (!empty($bcc)) {
// // Convert the comma-separated string into an array
// $bccList = explode(',', $bcc);
// // Trim whitespace from each email ID
// $bccList = array_map('trim', $bccList);
// // Set BCC recipients
// $email->setBCC($bccList);
// }
// $email->setSubject($subject);
// $email->setMessage($message);
// if ($email->send()) {
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200);
// } else {
// $myLogger->logme('error', "mail sent failed - $emaill");
// return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404);
// }
// } catch (Exception $e) {
// $msg = $e->getMessage();
// $myLogger->logme('error', "mail sent failed - $msg");
// return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
// }
// }
// public static function bulk_mail_smtp(array $mails = [])
// {
// // print_r();die;
// $model = new JobModel();
// $start = microtime(true);
// $runtime= 0;
// try {
// foreach ( $mails as $index=>$mail) {
// $runtime = microtime(true) - $start;
// $send_mail = self::send_email($mail);
// }
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
// } catch (\Throwable $th) {
// return json_encode(['status' => 'failed','code' => 500],500);
// }
// }
// //using GmailAPI
// public static function send_email($params)
// {
// // print_r($params);die;
// $myLogger = \Config\Services::mylogger();
// $gmailapi = \Config\Services::gmailapi();
// $emaill = $params['mail'];
// $subject = $params['subject'];
// $message = $params['message'];
// $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
// $common = isset($params['common'])?$params['common']:'';
// //check BCC mail
// if (isset($params['bcc'])) {
// $bcc = $params['bcc'];
// if(!is_array($bcc)){
// $bcc = explode(',', $bcc);
// }
// }else{
// $bcc = [];
// }
// //check CC mail
// if (isset($params['cc'])) {
// $cc = $params['cc'];
// if(!is_array($cc)){
// $cc = explode(',', $cc);
// }
// }else{
// $cc = [];
// }
// //check REPLY TO mail
// $reply_to = "";
// if(isset($params['reply_to']) && !empty($params['reply_to'])){
// $reply_to = $params['reply_to'];
// }
// $MailDataHelper = new GmailResponseHandler();
// $res['params'] = $params;
// try {
// $res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
// if($res['gmail_api']['status'])
// {
// $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);
// }
// else
// {
// $myLogger->logme('error', "mail sent failed - $emaill");
// $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);
// }
// } catch (Exception $e) {
// $msg['error'] = $e->getMessage();
// $msg['params'] = $params;
// $myLogger->logme('error', "mail sent failed - $msg");
// $response = $msg;
// $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 = [])
// {
// // print_r($mails);die;
// $model = new JobModel();
// $start = microtime(true);
// $runtime= 0;
// try {
// foreach ( $mails as $index=>$mail) {
// $runtime = microtime(true) - $start;
// $send_mail = self::send_email($mail);
// }
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
// } catch (\Throwable $th) {
// $error = $th->getMessage();
// log_message('error',$error);
// return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
// }
// }
// }
namespace App\Helpers; namespace App\Helpers;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Controllers\BaseController; use App\Controllers\BaseController;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use App\Models\JobModel; use App\Models\JobModel;
class MailHelper class MailHelper
{ {
public static function send_email_smtp($params) public static function send_email_smtp($params)
{ {
// print_r($params);die;
$myLogger = \Config\Services::mylogger(); $myLogger = \Config\Services::mylogger();
$emaill = $params['mail']; $emaill = $params['mail'];
$subject = $params['subject']; $subject = $params['subject'];
$message = $params['message']; $message = $params['message'];
if (isset($params['bcc'])) { if (isset($params['bcc'])) {
$bcc = $params['bcc']; $bcc = $params['bcc'];
}else{ } else {
$bcc= ''; $bcc = '';
} }
$from_address = getenv('email.fromEmail');
try { try {
$curl = curl_init();
$email = \Config\Services::email(); $postData = [
$email->setMailType('html'); 'from' => [
$email->setFrom('bbone@venbait.in', 'Nhance'); 'address' => $from_address
],
$email->setTo($emaill); 'to' => [
[
'email_address' => [
'address' => $emaill
]
]
],
'subject' => $subject,
'htmlbody' => $message
];
// Add BCC if present
if (!empty($bcc)) { if (!empty($bcc)) {
// Convert the comma-separated string into an array
$bccList = explode(',', $bcc); $bccList = explode(',', $bcc);
// Trim whitespace from each email ID
$bccList = array_map('trim', $bccList); $bccList = array_map('trim', $bccList);
// Set BCC recipients $postData['bcc'] = array_map(function($email) {
$email->setBCC($bccList); return [
'email_address' => [
'address' => $email
]
];
}, $bccList);
} }
$email->setSubject($subject); 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",
],
]);
$email->setMessage($message); $response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl);
if ($email->send()) { curl_close($curl);
if ($err) {
$myLogger->logme('error', "mail sent failed - $emaill");
return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404);
}
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200); $apiResponse = json_decode($response, true);
if ($httpCode === 200) {
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200);
} else { } else {
$myLogger->logme('error', "mail sent failed - $emaill"); $myLogger->logme('error', "mail sent failed - $emaill");
return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404); return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404);
} }
} catch (Exception $e) { } catch (\Exception $e) {
$msg = $e->getMessage(); $msg = $e->getMessage();
$myLogger->logme('error', "mail sent failed - $msg"); $myLogger->logme('error', "mail sent failed - $msg");
return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500); return json_encode(['status' => 'failed', 'code' => 500, 'data' => $emaill], 500);
} }
} }
public static function bulk_mail_smtp(array $mails = []) public static function bulk_mail_smtp(array $mails = [])
{ {
// print_r();die;
$model = new JobModel(); $model = new JobModel();
$start = microtime(true); $start = microtime(true);
$runtime= 0; $runtime = 0;
try { try {
foreach ( $mails as $index=>$mail) { foreach ($mails as $index => $mail) {
$runtime = microtime(true) - $start; $runtime = microtime(true) - $start;
$send_mail = self::send_email($mail); $send_mail = self::send_email($mail);
} }
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200); return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200);
} catch (\Throwable $th) { } catch (\Throwable $th) {
return json_encode(['status' => 'failed','code' => 500],500); return json_encode(['status' => 'failed', 'code' => 500], 500);
} }
} }
//using GmailAPI public static function send_email($params)
public static function send_email($params)
{ {
// print_r($params);die;
$myLogger = \Config\Services::mylogger(); $myLogger = \Config\Services::mylogger();
$gmailapi = \Config\Services::gmailapi();
$emaill = $params['mail']; $emaill = $params['mail'];
$subject = $params['subject']; $subject = $params['subject'];
$message = $params['message']; $message = $params['message'];
$attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : []; $attachments = isset($params['attachments']) ? $params['attachments'] : [];
$common = isset($params['common']) ? $params['common'] : '';
//check BCC mail
if (isset($params['bcc'])) {
$bcc = $params['bcc'];
$bcc = explode(',', $bcc);
}else{
$bcc = [];
}
//check CC mail
if (isset($params['cc'])) {
$cc = $params['cc'];
if(!is_array($cc)){
$cc = explode(',', $cc);
}
}else{
$cc = [];
}
//check REPLY TO mail
$reply_to = "";
if(isset($params['reply_to']) && !empty($params['reply_to'])){
$reply_to = $params['reply_to'];
}
$from_address = getenv('email.fromEmail');
try { try {
$curl = curl_init();
$res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
$postData = [
'from' => [
'address' => $from_address
],
'to' => [
[
'email_address' => [
'address' => $emaill
]
]
],
'subject' => $subject,
'htmlbody' => $message
];
if($res['status']) // Handle attachments
{ if (!empty($attachments)) {
return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200); $postData['attachments'] = [];
} foreach ($attachments as $attachment) {
else if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) {
{ // Determine MIME type dynamically
$myLogger->logme('error', "mail sent failed - $emaill"); $fileMimeType = mime_content_type($attachment['filePath']);
return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
} $postData['attachments'][] = [
'content' => base64_encode(file_get_contents($attachment['filePath'])),
} catch (Exception $e) { 'name' => $attachment['fileName'],
$msg = $e->getMessage(); 'mime_type' => $fileMimeType, // Add mime_type field
$myLogger->logme('error', "mail sent failed - $msg"); ];
return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500); }
} }
}
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);
// log_message('error','inside mail helper');
// log_message('error', $response.' error->'.$err);die();
$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...' . $emaill,
'data' => $res
], 404);
}
// $apiResponse = json_decode($response, true);
// Check if request_id exists in response (indicates success)
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 = []) public static function bulk_mail(array $mails = [])
{ {
// print_r();die;
$model = new JobModel(); $model = new JobModel();
$start = microtime(true); $start = microtime(true);
$runtime= 0; $runtime = 0;
try { try {
foreach ( $mails as $index=>$mail) { foreach ($mails as $index => $mail) {
$runtime = microtime(true) - $start; $runtime = microtime(true) - $start;
$send_mail = self::send_email($mail); $send_mail = self::send_email($mail);
}
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200);
} catch (\Throwable $th) {
$error = $th->getMessage();
log_message('error', $error);
return json_encode(['status' => 'failed', 'code' => 500, 'error' => $error], 500);
} }
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
} catch (\Throwable $th) {
return json_encode(['status' => 'failed','code' => 500],500);
}
} }
} }
?> ?>

View File

@ -128,7 +128,7 @@ if (! function_exists('transform_objects_to_array_for_inception')) {
$obj->emp_gender, // Employee Gender $obj->emp_gender, // Employee Gender
$obj->pre_existing_alignments, // Pre-existing Alignments $obj->pre_existing_alignments, // Pre-existing Alignments
$obj->basic_cover_si, // Basic Cover SI $obj->basic_cover_si, // Basic Cover SI
$obj->date_coverage, // Date Coverage $obj->date_of_coverage, // Date Coverage
$obj->emp_age, // Employee Age $obj->emp_age, // Employee Age
$obj->emp_relationship, // Employee Relationship $obj->emp_relationship, // Employee Relationship
$obj->change_event, // Change Event $obj->change_event, // Change Event
@ -260,7 +260,6 @@ if (! function_exists('transform_objects_to_array_for_deletion')) {
$obj->total, $obj->total,
$claim_status, $claim_status,
$endorsement_id $endorsement_id
]; ];
// Append the row data to the main data array // Append the row data to the main data array
@ -487,7 +486,7 @@ if (!function_exists('format_Excel_BasedOn_Client'))
$rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI $rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI
break; break;
case 'dateofcoverage': case 'dateofcoverage':
$rowData[] = $obj->date_coverage; // DATE OF COVERAGE $rowData[] = $obj->date_of_coverage; // DATE OF COVERAGE
break; break;
case 'age': case 'age':
$rowData[] = $obj->emp_age; // Employee AGE $rowData[] = $obj->emp_age; // Employee AGE

View File

@ -345,8 +345,7 @@ if(!function_exists('check_basic_pay'))
if (!function_exists('check_dob_diff')) if (!function_exists('check_dob_diff'))
{ {
function check_dob_diff($row,$relationships,$default_age_ratio) { function check_dob_diff($row,$relationships,$default_age_ratio,$policy_details) {
// echo 'called';
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
{ {
if($row[3] != null && $row[5] != null) if($row[3] != null && $row[5] != null)
@ -358,13 +357,11 @@ if (!function_exists('check_dob_diff'))
} }
// return array('status' => true); // return array('status' => true);
$dob = $dateString; $dob = $dateString;
// echo $row[3].' - '.$dob;echo '<br>'; //$currentDateTime = new DateTime();//previously dob calculated from current date time
$currentDateTime = new DateTime();//die(); $temp_date = ($row[7] != null && $row[7] != "") ? convert_string_to_date($row[7]) : $policy_details[0]->policy_start_date; //pick date of coverage from row if not then use policy start date as from to calculate DOB
// print_r($currentDateTime); $currentDateTime = new DateTime($temp_date);//later DOB calculated from date of coverage or policy_start_date
// die(); // die();
$passedDateTime = new DateTime($dob); $passedDateTime = new DateTime($dob);
// print_r($passedDateTime);
$interval = $currentDateTime->diff($passedDateTime); $interval = $currentDateTime->diff($passedDateTime);
//remap default age ratio data into relationship array //remap default age ratio data into relationship array
if(count($default_age_ratio)) if(count($default_age_ratio))
@ -375,7 +372,6 @@ if (!function_exists('check_dob_diff'))
$relationship = $slug->slugify($row[5]); $relationship = $slug->slugify($row[5]);
$age_min = isset($relationships[$relationship]['age_min']) ? $relationships[$relationship]['age_min'] : NULL; $age_min = isset($relationships[$relationship]['age_min']) ? $relationships[$relationship]['age_min'] : NULL;
$age_max = isset($relationships[$relationship]['age_max']) ? $relationships[$relationship]['age_max'] : NULL; $age_max = isset($relationships[$relationship]['age_max']) ? $relationships[$relationship]['age_max'] : NULL;
// echo $relationship.','.$age_min.'-'.$age_max;
if($age_min !== null && $age_min > $interval->y) if($age_min !== null && $age_min > $interval->y)
{ {
return array('status' => false,'error' => "Age conflict : minimum $age_min yrs allowed, received $interval->y"); return array('status' => false,'error' => "Age conflict : minimum $age_min yrs allowed, received $interval->y");
@ -965,7 +961,6 @@ if (!function_exists('calculate_premium_new'))
if(empty($member[18])){ $member[18] = $existing_units[0]; } if(empty($member[18])){ $member[18] = $existing_units[0]; }
//transform as db row column //transform as db row column
$transformed_familiy_member_data = transform_excel_data_to_db($member,$fileArr); $transformed_familiy_member_data = transform_excel_data_to_db($member,$fileArr);
// kint::dump($transformed_familiy_member_data);
//generate relationship code //generate relationship code
if($transformed_familiy_member_data['temp']['action'] != 'D' && $transformed_familiy_member_data['temp']['action'] != 'C' && $transformed_familiy_member_data['temp']['action'] != 'SI') if($transformed_familiy_member_data['temp']['action'] != 'D' && $transformed_familiy_member_data['temp']['action'] != 'C' && $transformed_familiy_member_data['temp']['action'] != 'SI')
{ {
@ -979,7 +974,7 @@ if (!function_exists('calculate_premium_new'))
'isEmployeeSourceEnrollment' => $fileArr['id'] == null, 'isEmployeeSourceEnrollment' => $fileArr['id'] == null,
'isEmployeeSourceExcelFile' => $transformed_familiy_member_data['temp']['source'] == 'excel', 'isEmployeeSourceExcelFile' => $transformed_familiy_member_data['temp']['source'] == 'excel',
'isCurrentActionDependentAddition' => $fileArr['action'] == 'dependent_addition', 'isCurrentActionDependentAddition' => $fileArr['action'] == 'dependent_addition',
// 'isPrimaryGridPremiumTypeSingle' => $transformed_familiy_member_data['temp']['premium_type'] == 1, 'isPrimaryGridPremiumTypeSingle' => isset($transformed_familiy_member_data['temp']['premium_type']) ? $transformed_familiy_member_data['temp']['premium_type'] == 1 : 0,
'isCurrentRelationshipSelf' => (strtolower($transformed_familiy_member_data['relationship']) == 'self' || (isset($transformed_familiy_member_data['temp']['acting_self']) && $transformed_familiy_member_data['temp']['acting_self'] === true)), 'isCurrentRelationshipSelf' => (strtolower($transformed_familiy_member_data['relationship']) == 'self' || (isset($transformed_familiy_member_data['temp']['acting_self']) && $transformed_familiy_member_data['temp']['acting_self'] === true)),
'isBasicCoverCalculatedToCurrentEmployee' => ($transformed_familiy_member_data['policy_details']['basic_cover_si'] != null && $transformed_familiy_member_data['policy_details']['basic_cover_si'] != 0) 'isBasicCoverCalculatedToCurrentEmployee' => ($transformed_familiy_member_data['policy_details']['basic_cover_si'] != null && $transformed_familiy_member_data['policy_details']['basic_cover_si'] != 0)
]; ];
@ -1049,7 +1044,7 @@ if (!function_exists('transform_excel_data_to_db'))
$result['designation'] = $memArr[11]; $result['designation'] = $memArr[11];
$result['mobile'] = $memArr[12]; $result['mobile'] = $memArr[12];
$result['email_corporate'] = $memArr[13]; $result['email_corporate'] = $memArr[13];
$result['file_id'] = $actionArr['id']; $result['file_id'] = isset($memArr['temp']['source']) && $memArr['temp']['source'] == 'db' && isset($memArr['temp']['file_id']) ? $memArr['temp']['file_id'] : $actionArr['id'];
$result['client_id'] = $actionArr['client_id']; $result['client_id'] = $actionArr['client_id'];
$result['change_event'] = $memArr[15]; $result['change_event'] = $memArr[15];
$result['unit'] = $memArr[18]; $result['unit'] = $memArr[18];
@ -1078,8 +1073,6 @@ if (!function_exists('premium_calculation_manager'))
{ {
function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null) function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null)
{ {
// Kint::dump($emp_data);die();
$myLogger = \Config\Services::mylogger(); $myLogger = \Config\Services::mylogger();
// grid type // grid type
// 1 = premium => si // 1 = premium => si
@ -1091,25 +1084,25 @@ if (!function_exists('premium_calculation_manager'))
//check emp records //check emp records
if($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft') if($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft')
{ {
$original_emp_records = get_emp_records_from_audit_history($emp_data['temp']['emp_id']); // $original_emp_records = get_emp_records_from_audit_history($emp_data['temp']['emp_id']);
if(is_array($original_emp_records)) // if(is_array($original_emp_records))
{ // {
// Kint::dump($original_emp_records); // // Kint::dump($original_emp_records);
$emp_data = replace_original_data(original_data:$original_emp_records,current_data:$emp_data); // // $emp_data = replace_original_data(original_data:$original_emp_records,current_data:$emp_data);
// Kint::dump($value); // // Kint::dump($value);
} // }
} }
//check emp policy records //check emp policy records
if($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft') if($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft')
{ {
$original_emp_policy_records = get_emp_policy_records_from_audit_history($emp_data['temp']['emp_policy_id']); // $original_emp_policy_records = get_emp_policy_records_from_audit_history($emp_data['temp']['emp_policy_id']);
if(is_array($original_emp_policy_records)) // if(is_array($original_emp_policy_records))
{ // {
// Kint::dump($original_emp_records); // // Kint::dump($original_emp_records);
$emp_data['policy_details'] = replace_original_data(original_data:$original_emp_policy_records,current_data:$emp_data['policy_details']); // $emp_data['policy_details'] = replace_original_data(original_data:$original_emp_policy_records,current_data:$emp_data['policy_details']);
// Kint::dump($policy_data); // // Kint::dump($policy_data);
} // }
}//end of fetching data from audit history table }//end of fetching data from audit history table
@ -1167,7 +1160,7 @@ if (!function_exists('premium_calculation_manager'))
{ {
if($temp_slab_rates[0]['si_or_bp'] == 2) if($temp_slab_rates[0]['si_or_bp'] == 2)
{ {
$temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['si_or_bp']; $temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['basic_multiplier'];
$temp_premium = ($temp_si * $temp_slab_rates[0]['multiplier']) / 1000; $temp_premium = ($temp_si * $temp_slab_rates[0]['multiplier']) / 1000;
$emp_data['policy_details']['basic_cover_si'] = $temp_si; $emp_data['policy_details']['basic_cover_si'] = $temp_si;
@ -1209,7 +1202,7 @@ if (!function_exists('premium_calculation_manager'))
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) ))
{ {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@ -1229,10 +1222,13 @@ if (!function_exists('premium_calculation_manager'))
//GMC - Employees Age band //GMC - Employees Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
// dd($employee_received_si); // dd($employee_received_si);
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{ {
// dd($slab_value); // dd($slab_value);
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1250,10 +1246,13 @@ if (!function_exists('premium_calculation_manager'))
case "5": case "5":
//GMC - Employees Age + SI //GMC - Employees Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) ))
{ {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@ -1270,10 +1269,12 @@ if (!function_exists('premium_calculation_manager'))
case "6": case "6":
//GMC - Employees + Dependent Age band //GMC - Employees + Dependent Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{ {
// echo $emp_data['name']; // echo $emp_data['name'];
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1292,10 +1293,12 @@ if (!function_exists('premium_calculation_manager'))
case "7": case "7":
//GMC - Employees + Dependent Age + SI //GMC - Employees + Dependent Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{ {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@ -1317,7 +1320,7 @@ if (!function_exists('premium_calculation_manager'))
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
if($slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && $slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && $slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{ {
// $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; // $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1339,7 +1342,7 @@ if (!function_exists('premium_calculation_manager'))
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{ {
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@ -1366,7 +1369,7 @@ if (!function_exists('premium_calculation_manager'))
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] &&
($slab_value['age_from'] <= $max_age && $slab_value['age_to'] >= $max_age) && ($slab_value['age_from'] <= $max_age && $slab_value['age_to'] >= $max_age) &&
(($slab_value['premium_type'] == 1 && (($slab_value['premium_type'] == 1 &&
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ) ) ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ) )
{ {
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si; $emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
$emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']; $emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date'];
@ -1391,7 +1394,7 @@ if (!function_exists('premium_calculation_manager'))
{ {
if($slab_value['si'] == $employee_received_si && $slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && if($slab_value['si'] == $employee_received_si && $slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 &&
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) )) ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{ {
//calculate premium based on count //calculate premium based on count
// echo $emp_data['name']; // echo $emp_data['name'];
@ -1420,7 +1423,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['basic_cover_si'] = null; $emp_data['policy_details']['basic_cover_si'] = null;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) ) if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
{ {
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si; $emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
@ -1442,10 +1445,11 @@ if (!function_exists('premium_calculation_manager'))
$employee_relationship = $slug->slugify($emp_data['relationship']); $employee_relationship = $slug->slugify($emp_data['relationship']);
$employee_relationship = ($employee_relationship == 'daughter' || $employee_relationship == 'son' ? $employee_relationship = 'child' : $employee_relationship); $employee_relationship = ($employee_relationship == 'daughter' || $employee_relationship == 'son' ? $employee_relationship = 'child' : $employee_relationship);
$emp_data['policy_details']['basic_cover_si'] = null; $emp_data['policy_details']['basic_cover_si'] = null;
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; $temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value) foreach ($temp_slab_rates as $skey => $slab_value)
{ {
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) ) if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
{ {
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si; $emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
@ -1466,9 +1470,17 @@ if (!function_exists('premium_calculation_manager'))
default: default:
$myLogger->logme('error',($emp_data['emp_code'].'-'.$emp_data['name'].' - grid type not found')); $myLogger->logme('error',($emp_data['emp_code'].'-'.$emp_data['name'].' - grid type not found'));
} }
//this if condition for premium calculated & premium type 3 (familiy floater but premium calculated every individual implemented later) then remove si amount only for dependents (not self)
if($is_match_found && strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 3)
{
//set dependent si to 0
$emp_data['policy_details']['basic_cover_si'] = 0;
}
if(!$is_match_found) if(!$is_match_found)
{ {
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y; $temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
$log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ', Age : '. $age.' ]'; $log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ', Age : '. $age.' ]';
if($temp_slab_rates[0]['premium_type'] == 1) if($temp_slab_rates[0]['premium_type'] == 1)
{ {
@ -1480,6 +1492,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['rata_premimum'] = 0; $emp_data['policy_details']['rata_premimum'] = 0;
$emp_data['policy_details']['gst'] = 0; $emp_data['policy_details']['gst'] = 0;
$emp_data['policy_details']['days'] = 0; $emp_data['policy_details']['days'] = 0;
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
} }
else { $log_message .= '- skipping, slab rate not found'; } else { $log_message .= '- skipping, slab rate not found'; }
$myLogger->logme('error',$log_message); $myLogger->logme('error',$log_message);
@ -1553,6 +1566,7 @@ if (!function_exists('transform_db_data_to_excel'))
$row['temp']['emp_status'] = $value['emp_status']; $row['temp']['emp_status'] = $value['emp_status'];
$row['temp']['policy_status'] = $value['status']; $row['temp']['policy_status'] = $value['status'];
$row['temp']['rata_premimum'] = $value['rata_premimum']; $row['temp']['rata_premimum'] = $value['rata_premimum'];
$row['temp']['file_id'] = $value['file_id'];
array_push($return_data, ($row)); array_push($return_data, ($row));
} }
@ -1719,6 +1733,21 @@ if(!function_exists('check_dup_mobileno'))
} }
} }
if(!function_exists('check_dup_email'))
{
function check_dup_email(array $row,array $existing_mobilenos)
{
foreach($existing_mobilenos as $k => $value)
{
if ($row['13'] == $value['email_corporate']) {
return array('status' => false,'error' => "Duplicate Email");
// break;
}
}
return array('status' => true);
}
}
if(!function_exists('generate_family_relationship_array')) if(!function_exists('generate_family_relationship_array'))
{ {
function generate_family_relationship_array($family_structure_from_policy_terms) { function generate_family_relationship_array($family_structure_from_policy_terms) {

View File

@ -17,11 +17,13 @@ class sendMailNotification
public static function sendMailNotification($action, $params) public static function sendMailNotification($action, $params)
{ {
$wholeData =[]; $wholeData =[];
if ($action == 'member_welcome_mail') { if ($action == 'member_welcome_mail') {
$dataToInsert = $params['dataToInsert']; $dataToInsert = $params['dataToInsert'];
$notification = $params['notification']; $notification = $params['notification'];
$client_data = $params['client_data']; $client_data = $params['client_data'];
$common = $params['common'];
$mailAttachmentModel = new MailAttachmentModel(); $mailAttachmentModel = new MailAttachmentModel();
$attachment_data = $mailAttachmentModel $attachment_data = $mailAttachmentModel
@ -42,6 +44,7 @@ class sendMailNotification
$subject = $notification['subject']; $subject = $notification['subject'];
$app_link = $_ENV['App_Url']; $app_link = $_ENV['App_Url'];
$employee_name =$dataToInsert['name']; $employee_name =$dataToInsert['name'];
$employee_mobile_no =$dataToInsert['mobile'];
$mail_content = $notification['mail_content']; $mail_content = $notification['mail_content'];
$nhance_logo = $_ENV['NHANCE_LOGO']; $nhance_logo = $_ENV['NHANCE_LOGO'];
$client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
@ -49,11 +52,12 @@ class sendMailNotification
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content); $mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content);
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') { if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') {
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments]; $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments, 'common' => $common];
} }
return $wholeData; return $wholeData;
@ -64,6 +68,7 @@ class sendMailNotification
$emp_data = $params['emp_data']; $emp_data = $params['emp_data'];
$notification_data = $params['notification_data']; $notification_data = $params['notification_data'];
$client_data = $params['client_data']; $client_data = $params['client_data'];
$common = $params['common'];
$subject = $notification_data['subject']; $subject = $notification_data['subject'];
$app_link = $_ENV['App_Url']; $app_link = $_ENV['App_Url'];
@ -76,68 +81,18 @@ class sendMailNotification
$mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content); $mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
if(isset($emp_data['relationship'])){
if ($emp_data['relationship'] == 'Self') {
if(count($emp_data) > 0){
$mail ='';
if ($emp_data['relationship'] == 'Self') {
$employee_name =$emp_data['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $emp_data['email_corporate'];
}
}
}else{
$mail ='';
}
}else{
$employee_name =$emp_data['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $emp_data['email_corporate'];
}
if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
}
}else{ $employee_name =$emp_data['name'];
$employee_mobile_no =$emp_data['mobile'];
foreach ($emp_data as $key => $value) { $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
if ($value['relationship'] != 'Self') { $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content);
$emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll(); $mail = $emp_data['email_corporate'];
if(count($emp_data) > 1){
$mail ='';
foreach ($emp_data as $key => $values) {
if ($value['relationship'] == 'Self') {
$employee_name =$values['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $values['email_corporate'];
}
}
}else{
$mail ='';
}
}else{
$employee_name =$value['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $value['email_corporate'];
}
if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
}
}
}
if (count($wholeData) < 1) { $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
$wholeData = [];
}
return $wholeData; return $wholeData;
// }else{
// return "false";
// }
} else if($action == 'member_ecard_mail'){ } else if($action == 'member_ecard_mail'){
@ -146,6 +101,7 @@ class sendMailNotification
$rand_string = $params['rand_string']; $rand_string = $params['rand_string'];
$client_data = $params['client_data']; $client_data = $params['client_data'];
$tpa_id = $params['tpa_id']; $tpa_id = $params['tpa_id'];
$common = $params['common'];
$mail_content = $notification['mail_content']; $mail_content = $notification['mail_content'];
@ -161,6 +117,7 @@ class sendMailNotification
$app_link = $_ENV['App_Url']; $app_link = $_ENV['App_Url'];
$name = $get_emp_email_and_other_details['name']; $name = $get_emp_email_and_other_details['name'];
$employee_mobile_no = $get_emp_email_and_other_details['mobile'];
$mail_content = $notification['mail_content']; $mail_content = $notification['mail_content'];
$nhance_logo = $_ENV['NHANCE_LOGO']; $nhance_logo = $_ENV['NHANCE_LOGO'];
@ -175,12 +132,13 @@ class sendMailNotification
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content); $mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[member_name]]", $name, $mail_content); $mail_content = str_replace("[[member_name]]", $name, $mail_content);
$mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
$mail_content = str_replace("[[post_enrollment_app_link]]", "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[post_enrollment_app_link]]", "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
// $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content); // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
$mail_content = str_replace("[[ecard_download_link]]", "<a href='$link/1'>Download Insurance Card</a>", $mail_content); $mail_content = str_replace("[[ecard_download_link]]", "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
return $wholeData; return $wholeData;
@ -190,6 +148,7 @@ class sendMailNotification
$client_policy_id = $params['client_policy_id']; $client_policy_id = $params['client_policy_id'];
$emp_code = $params['emp_code']; $emp_code = $params['emp_code'];
$client_id = $params['client_id']; $client_id = $params['client_id'];
$common = $params['common'];
$clientModel = new ClientModel(); $clientModel = new ClientModel();
$notificationModel = new NotificationModel(); $notificationModel = new NotificationModel();
@ -226,20 +185,25 @@ class sendMailNotification
$gst = 0; $gst = 0;
$Addon_list = []; $Addon_list = [];
$name = ''; $name = '';
$employee_mobile_no = '';
$emp_code = ''; $emp_code = '';
// echo '<pre>'; // echo '<pre>';
// print_r($array_list); die; // print_r($array_list); die;
foreach ($array_list as $item) {
foreach ($array_list as $item) {
$payable_employee_array = [];
if (count($item) != 0) { if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :'; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = ''; $temp_data = '';
$policy_name = ''; $policy_name = '';
$is_addon = ''; $is_addon = '';
$rowspan = count($item) ?? 2;
foreach ($item as $inner_item) { foreach ($item as $inner_item) {
@ -252,30 +216,55 @@ class sendMailNotification
} }
//end of getting policy premium data //end of getting policy premium data
// dd($policy_premium_data);
if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
$payable_employee_array['emp_data'][] = $inner_item;
}
// dd($policy_premium_data);
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
$emp_code = '(' . $inner_item['emp_code'] . ')'; $emp_code = '(' . $inner_item['emp_code'] . ')';
$mail = $inner_item['email_corporate']; $mail = $inner_item['email_corporate'];
$name = $inner_item['name']; $name = $inner_item['name'];
$employee_mobile_no = $inner_item['mobile'];
} }
$si = ''; $si = '';
$premium = ''; $premium = '';
$gst_forself = ''; $gst_forself = '';
if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['premium'])); if($policy_premium_data['premium_type'] == 2){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
}else{
if ($inner_item['relationship'] == 'Self') {
$payable_employee_array['si_amount'] = $inner_item['basic_cover_si'];
$payable_employee_array['self_premium'] = $inner_item['rata_premimum'];
$payable_employee_array['self_gst'] = $inner_item['gst'];
}
empty($inner_item['basic_cover_si']) ? $si = 0 : $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
}
$premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
} // }
$temp_data .= '<tr>'; $temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>'; $temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>'; $temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>'; $temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>' . $si . '</td>';
if($policy_premium_data['premium_type'] == 2){
$temp_data .= '<td>' . $si . '</td>';
}else{
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>') );
}
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '<td>' . $premium . '</td>'; $temp_data .= '<td>' . $premium . '</td>';
@ -334,6 +323,140 @@ class sendMailNotification
$addtional_premium = 0; $addtional_premium = 0;
$gst = 0; $gst = 0;
} }
// dd($payable_employee_array);
// dd(count($payable_employee_array['emp_data']));
if(isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0){
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = '';
$is_addon = '';
$rowspan = count($payable_employee_array['emp_data']) ?? 2;
$self_si_amount = $payable_employee_array['si_amount'] ?? 0;
$self_premium = $payable_employee_array['self_premium'] ?? 0;
$self_gst = $payable_employee_array['self_gst'] ?? 0;
// dd($payable_employee_array['si_amount'], $self_si_amount);
foreach ($payable_employee_array['emp_data'] as $inner_item) {
//getting policy premium data
$client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}
//end of getting policy premium data
// dd($policy_premium_data);
$si = '';
$premium = '';
$gst_forself = '';
if($policy_premium_data['premium_type'] == 2){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
}else{
empty($self_si_amount) ? $si = 0 : $si = '₹ ' .format_indian_number($self_si_amount);
}
if($policy_premium_data['premium_type'] == 1){
empty($self_premium) ? $premium = 0 : $premium = '₹ ' .format_indian_number($self_premium);
empty($self_gst) ? $gst_forself = 0 : $gst_forself = '₹ ' .format_indian_number($self_gst);
}else{
$premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
}
$temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
// dd($si);
if($policy_premium_data['premium_type'] == 2){
$temp_data .= '<td>' . $si . '</td>';
$temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>' . $gst_forself . '</td>';
}else{
if($policy_premium_data['premium_type'] == 1){
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>') );
$temp_data .= (($premium != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $premium . '</td>') : ($premium == 0 ? "" : '<td>' . $premium . '</td>') );
$temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $gst_forself . '</td>') : ($gst_forself == 0 ? "" : '<td>' . $gst_forself . '</td>') );
}else{
$temp_data .= (($si != 0 && count($item) != 1) ? ('<td rowspan='.$rowspan.'>' . $si . '</td>') : ($si == 0 ? "" : '<td>' . $si . '</td>') );
$temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>' . $gst_forself . '</td>';
}
$self_si_amount = 0;
$self_premium = 0;
$self_gst = 0;
}
$temp_data .= '</tr>';
$is_addon = $inner_item['is_addon'];
$addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
$gst = $inner_item['gst'] + $gst;
}
$policy_name_for_policy_type = $inner_item['policy_name'];
if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
}
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
// Add text-align: center to the table head
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
// Add text-align: center to the table body
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
$table_content .= '</table></div>';
$addon_list_array = [
'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
'addtional_premium' => round($addtional_premium),
'gst' => round($gst)
];
$Addon_list[] = $addon_list_array;
$temp_data = '';
$addtional_premium = 0;
$gst = 0;
}
} }
if (count($Addon_list) > 0) { if (count($Addon_list) > 0) {
@ -375,16 +498,18 @@ class sendMailNotification
// $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>'; // $table_content .= '<div style="width:100%; text-align:right; font-size: 12px;">' . $sum_total_words . '</div>';
} }
// dd($payable_employee_array, $Addon_list);
// print_r($table_content); die; // print_r($table_content); die;
$mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content);
$mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content);
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
// print_r($mail_content); die; // print_r($mail_content); die;
// $mail = "aadhavanvalli@gmail.com"; // $mail = "aadhavanvalli@gmail.com";
// if (isset($mail) && !empty($mail)) { // if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
// } // }
return $wholeData; return $wholeData;
@ -395,6 +520,7 @@ class sendMailNotification
$client_id = $params['client_id']; $client_id = $params['client_id'];
$client_policy_id = $params['client_policy_id']; $client_policy_id = $params['client_policy_id'];
$common = $params['common'];
$clientModel = new ClientModel(); $clientModel = new ClientModel();
$notificationModel = new NotificationModel(); $notificationModel = new NotificationModel();
@ -442,6 +568,9 @@ class sendMailNotification
$Addon_list = []; $Addon_list = [];
foreach ($array_list as $item) { foreach ($array_list as $item) {
$payable_employee_array = [];
if (count($item) != 0) { if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :'; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = ''; $temp_data = '';
@ -459,6 +588,10 @@ class sendMailNotification
} }
//end of getting policy premium data //end of getting policy premium data
if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
$payable_employee_array[] = $inner_item;
}
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
@ -470,11 +603,11 @@ class sendMailNotification
$si = ''; $si = '';
$premium = ''; $premium = '';
$gst_forself = ''; $gst_forself = '';
if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['premium'])); $premium = '₹ ' .format_indian_number(round($inner_item['premium']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
} // }
$temp_data .= '<tr>'; $temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>'; $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
@ -540,6 +673,90 @@ class sendMailNotification
$addtional_premium = 0; $addtional_premium = 0;
$gst = 0; $gst = 0;
} }
if(count($payable_employee_array) > 0){
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = '';
$is_addon = '';
foreach ($payable_employee_array as $inner_item) {
//getting policy premium data
$client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}
//end of getting policy premium data
$si = '';
$premium = '';
$gst_forself = '';
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
$temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>' . $si . '</td>';
$temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>' . $gst_forself . '</td>';
$temp_data .= '</tr>';
$is_addon = $inner_item['is_addon'];
$addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
$gst = $inner_item['gst'] + $gst;
}
$policy_name_for_policy_type = $inner_item['policy_name'];
if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
}
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
// Add text-align: center to the table head
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
// Add text-align: center to the table body
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
$table_content .= '</table></div>';
$addon_list_array = [
'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
'addtional_premium' => round($addtional_premium),
'gst' => round($gst)
];
$Addon_list[] = $addon_list_array;
$temp_data = '';
$addtional_premium = 0;
$gst = 0;
}
} }
if (count($Addon_list) > 0) { if (count($Addon_list) > 0) {
@ -590,7 +807,7 @@ class sendMailNotification
$full_name = $value['first_name'] .' ' .$value['last_name']; $full_name = $value['first_name'] .' ' .$value['last_name'];
$mail_content = str_replace("[[member_name]]", $full_name , $mail_content); $mail_content = str_replace("[[member_name]]", $full_name , $mail_content);
$wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common];
// $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
} }
return $wholeData; return $wholeData;
@ -600,6 +817,7 @@ class sendMailNotification
$client_id = $params['client_id']; $client_id = $params['client_id'];
$client_policy_id = $params['client_policy_id']; $client_policy_id = $params['client_policy_id'];
$common = $params['common'];
$clientModel = new ClientModel(); $clientModel = new ClientModel();
$clientPolicyModel = new ClientPolicyModel(); $clientPolicyModel = new ClientPolicyModel();
@ -646,8 +864,11 @@ class sendMailNotification
$gst = 0; $gst = 0;
$array_list = $params['array_list']; $array_list = $params['array_list'];
$Addon_list = []; $Addon_list = [];
foreach ($array_list as $item) { foreach ($array_list as $item) {
$payable_employee_array = [];
if (count($item) != 0) { if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :'; $table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = ''; $temp_data = '';
@ -665,6 +886,10 @@ class sendMailNotification
} }
//end of getting policy premium data //end of getting policy premium data
if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
$payable_employee_array[] = $inner_item;
}
$policy_name = $inner_item['policy_name']; $policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') { if ($inner_item['relationship'] == 'Self') {
@ -679,11 +904,11 @@ class sendMailNotification
// dd($policy_premium_data, $client_policy_data, $inner_item); // dd($policy_premium_data, $client_policy_data, $inner_item);
if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['premium'])); $premium = '₹ ' .format_indian_number(round($inner_item['premium']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
} // }
$temp_data .= '<tr>'; $temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>'; $temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
@ -749,6 +974,89 @@ class sendMailNotification
$addtional_premium = 0; $addtional_premium = 0;
$gst = 0; $gst = 0;
} }
if(count($payable_employee_array) > 0){
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = '';
$is_addon = '';
foreach ($payable_employee_array as $inner_item) {
//getting policy premium data
$client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
$policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}else{
$policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
}
//end of getting policy premium data
$si = '';
$premium = '';
$gst_forself = '';
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
$temp_data .= '<tr>';
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
$temp_data .= '<td>' . $si . '</td>';
$temp_data .= '<td>' . $premium . '</td>';
$temp_data .= '<td>' . $gst_forself . '</td>';
$temp_data .= '</tr>';
$is_addon = $inner_item['is_addon'];
$addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
$gst = $inner_item['gst'] + $gst;
}
$policy_name_for_policy_type = $inner_item['policy_name'];
if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
$policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
}
$table_content .= $policy_name_for_policy_type . ' ( Payable By Employee ) </h4></div>';
$table_content .= '<table border="1" cellpadding="5" cellspacing="0" style="width:100%; border-collapse: collapse; font-size: 12px;">';
// Add text-align: center to the table head
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>';
$table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>';
$table_content .= '<th>Premium</th>';
$table_content .= '<th>GST</th>';
$table_content .= '</tr>';
$table_content .= '</thead>';
// Add text-align: center to the table body
$table_content .= '<tbody style="text-align: center;">' . $temp_data . '</tbody>';
$table_content .= '</table></div>';
$addon_list_array = [
'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
'addtional_premium' => round($addtional_premium),
'gst' => round($gst)
];
$Addon_list[] = $addon_list_array;
$temp_data = '';
$addtional_premium = 0;
$gst = 0;
}
} }
if (count($Addon_list) > 0) { if (count($Addon_list) > 0) {
@ -798,7 +1106,7 @@ class sendMailNotification
$mail_array = array_map('trim', $mail_array); $mail_array = array_map('trim', $mail_array);
$wholeData = []; $wholeData = [];
foreach ($mail_array as $key => $value) { foreach ($mail_array as $key => $value) {
$wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common];
// $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; // $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
} }
@ -841,6 +1149,7 @@ class sendMailNotification
// print_r($attachments); die; // print_r($attachments); die;
$employee_name = 'John Doe'; $employee_name = 'John Doe';
$mobile = 9080706050;
$app_link = $_ENV['App_Url']; $app_link = $_ENV['App_Url'];
$nhance_logo = $_ENV['NHANCE_LOGO']; $nhance_logo = $_ENV['NHANCE_LOGO'];
@ -850,6 +1159,7 @@ class sendMailNotification
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content); $mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
@ -873,6 +1183,7 @@ class sendMailNotification
$app_link = $_ENV['App_Url']; $app_link = $_ENV['App_Url'];
$employee_name = 'John Doe'; $employee_name = 'John Doe';
$mobile = 9080706050;
$client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
@ -880,6 +1191,7 @@ class sendMailNotification
$mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content); $mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
$mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
if ((isset($notification_data) && $notification_data['enabled'] == 1)) { if ((isset($notification_data) && $notification_data['enabled'] == 1)) {
@ -905,6 +1217,7 @@ class sendMailNotification
$link = generate_download_link($rand_string); $link = generate_download_link($rand_string);
$name = 'John Doe'; $name = 'John Doe';
$mobile = 9080706050;
$nhance_logo = $_ENV['NHANCE_LOGO']; $nhance_logo = $_ENV['NHANCE_LOGO'];
$app_link = $_ENV['App_Url']; $app_link = $_ENV['App_Url'];
@ -916,6 +1229,7 @@ class sendMailNotification
$mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content); $mail_content = str_replace("[[client_logo]]", "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[member_name]]", $name, $mail_content); $mail_content = str_replace("[[member_name]]", $name, $mail_content);
$mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
$mail_content = str_replace("[[post_enrollment_app_link]]", "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[post_enrollment_app_link]]", "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
$mail_content = str_replace("[[ecard_download_link]]", "<a href='$link/1'>Download Insurance Card</a>", $mail_content); $mail_content = str_replace("[[ecard_download_link]]", "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
@ -937,7 +1251,8 @@ class sendMailNotification
'premium' => 12000, 'premium' => 12000,
'gst' => 2160, 'gst' => 2160,
'rata_premimum' => 12000, 'rata_premimum' => 12000,
'is_addon' => 2 'is_addon' => 2,
'mobile' => 9080706050
]; ];
@ -967,6 +1282,7 @@ class sendMailNotification
$gst = 0; $gst = 0;
$Addon_list = []; $Addon_list = [];
$name = $array_list['name']; $name = $array_list['name'];
$mobile = $array_list['mobile'];
$emp_code = ''; $emp_code = '';
if (!empty($array_list)) { if (!empty($array_list)) {
@ -987,9 +1303,9 @@ class sendMailNotification
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">'; $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<th>Name</th>'; $table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Sum Insured</th>';
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
@ -1003,14 +1319,14 @@ class sendMailNotification
// Table body with details // Table body with details
$table_content .= '<tbody style="text-align: center;">'; $table_content .= '<tbody style="text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td>' . $array_list['name'] . $emp_code . '</td>'; $table_content .= '<td>' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '</td>';
$table_content .= '<td>' . $array_list['relationship'] . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $array_list['relationship'] . '</td>';
$table_content .= '<td>' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
$table_content .= '<td>₹' . format_indian_number($array_list['basic_cover_si']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<td>₹' . format_indian_number(round($array_list['premium'])) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['premium'])) . '</td>';
$table_content .= '<td>₹' . format_indian_number(round($array_list['gst'])) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['gst'])) . '</td>';
} }
$table_content .= '</tr>'; $table_content .= '</tr>';
@ -1039,10 +1355,10 @@ class sendMailNotification
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">'; $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Policy Name</th>';
$table_content .= '<th>Additional Premium</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Additional Premium</th>';
$table_content .= '<th>GST</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
$table_content .= '<th>Total</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Total</th>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$table_content .= '</thead>'; $table_content .= '</thead>';
@ -1050,16 +1366,16 @@ class sendMailNotification
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td>' . $Addon_list[0]['policy_name'] . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $Addon_list[0]['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['gst']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$sum_total_words = numberToWords($total_addon); $sum_total_words = numberToWords($total_addon);
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>'; $table_content .= '<td></td><td></td><td><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$table_content .= '</tbody>'; $table_content .= '</tbody>';
$table_content .= '</table></div></div>'; $table_content .= '</table></div></div>';
@ -1067,6 +1383,7 @@ class sendMailNotification
} }
$mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content);
$mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
@ -1136,14 +1453,14 @@ class sendMailNotification
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">'; $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<th>Name</th>'; $table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Sum Insured</th>';
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<th>Premium</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Premium</th>';
$table_content .= '<th>GST</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
} }
$table_content .= '</tr>'; $table_content .= '</tr>';
@ -1152,14 +1469,14 @@ class sendMailNotification
// Table body with details // Table body with details
$table_content .= '<tbody style="text-align: center;">'; $table_content .= '<tbody style="text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td>' . $array_list['name'] . $emp_code . '</td>'; $table_content .= '<td>' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '</td>';
$table_content .= '<td>' . $array_list['relationship'] . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $array_list['relationship'] . '</td>';
$table_content .= '<td>' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
$table_content .= '<td>₹' . format_indian_number($array_list['basic_cover_si']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<td>₹' . format_indian_number(round($array_list['premium'])) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['premium'])) . '</td>';
$table_content .= '<td>₹' . format_indian_number(round($array_list['gst'])) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['gst'])) . '</td>';
} }
$table_content .= '</tr>'; $table_content .= '</tr>';
@ -1188,10 +1505,10 @@ class sendMailNotification
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">'; $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Policy Name</th>';
$table_content .= '<th>Additional Premium</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Additional Premium</th>';
$table_content .= '<th>GST</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
$table_content .= '<th>Total</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Total</th>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$table_content .= '</thead>'; $table_content .= '</thead>';
@ -1199,17 +1516,17 @@ class sendMailNotification
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td>' . $Addon_list[0]['policy_name'] . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $Addon_list[0]['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['gst']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$sum_total_words = numberToWords($total_addon); $sum_total_words = numberToWords($total_addon);
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>'; $table_content .= '<td></td><td></td><td><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>'; $table_content .= '</tr style="padding: 8px; white-space: nowrap;">';
$table_content .= '</tbody>'; $table_content .= '</tbody>';
$table_content .= '</table></div></div>'; $table_content .= '</table></div></div>';
} }
@ -1228,7 +1545,7 @@ class sendMailNotification
$array_list = [ $array_list = [
'policy_name' => 'Health Insurance Plan', 'policy_name' => 'Health Insurance Plan',
'emp_code' => 'E12345', 'emp_code' => 'E12345',
'name' => 'John Doe', 'name' => 'Ramakrishnaparamahamsar',
'relationship' => 'Self', 'relationship' => 'Self',
'dob' => '1985-05-15', 'dob' => '1985-05-15',
'basic_cover_si' => 500000, 'basic_cover_si' => 500000,
@ -1284,14 +1601,14 @@ class sendMailNotification
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">'; $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<th>Name</th>'; $table_content .= '<th>Name</th>';
$table_content .= '<th>Relation</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Relation</th>';
$table_content .= '<th style="width:15%">Date Of Birth</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Date Of Birth</th>';
$table_content .= '<th>Sum Insured</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Sum Insured</th>';
// Only Display SI Topup and Dependent Addon // Only Display SI Topup and Dependent Addon
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<th>Premium</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Premium</th>';
$table_content .= '<th>GST</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
} }
$table_content .= '</tr>'; $table_content .= '</tr>';
@ -1300,14 +1617,14 @@ class sendMailNotification
// Table body with details // Table body with details
$table_content .= '<tbody style="text-align: center;">'; $table_content .= '<tbody style="text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td>' . $array_list['name'] . $emp_code . '</td>'; $table_content .= '<td>' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '</td>';
$table_content .= '<td>' . $array_list['relationship'] . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $array_list['relationship'] . '</td>';
$table_content .= '<td>' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '</td>';
$table_content .= '<td>₹' . format_indian_number($array_list['basic_cover_si']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($array_list['basic_cover_si']) . '</td>';
if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
$table_content .= '<td>₹' . format_indian_number(round($array_list['premium'])) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['premium'])) . '</td>';
$table_content .= '<td>₹' . format_indian_number(round($array_list['gst'])) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number(round($array_list['gst'])) . '</td>';
} }
$table_content .= '</tr>'; $table_content .= '</tr>';
@ -1337,10 +1654,10 @@ class sendMailNotification
$table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">'; $table_content .= '<thead style="background-color: #02a8b5; color: #ffffff; text-align: center;">';
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<th>Policy Name</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Policy Name</th>';
$table_content .= '<th>Additional Premium</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Additional Premium</th>';
$table_content .= '<th>GST</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">GST</th>';
$table_content .= '<th>Total</th>'; $table_content .= '<th style="padding: 8px; white-space: nowrap;">Total</th>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$table_content .= '</thead>'; $table_content .= '</thead>';
@ -1348,16 +1665,16 @@ class sendMailNotification
$total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td>' . $Addon_list[0]['policy_name'] . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">' . $Addon_list[0]['policy_name'] . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($Addon_list[0]['gst']) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($Addon_list[0]['gst']) . '</td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$sum_total_words = numberToWords($total_addon); $sum_total_words = numberToWords($total_addon);
$table_content .= '<tr>'; $table_content .= '<tr>';
$table_content .= '<td></td><td></td><td><b>Total</b></td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;"></td style="padding: 8px; white-space: nowrap;"><td style="padding: 8px; white-space: nowrap;"></td><td style="padding: 8px; white-space: nowrap;"><b>Total</b></td>';
$table_content .= '<td>₹' . format_indian_number($total_addon) . '</td>'; $table_content .= '<td style="padding: 8px; white-space: nowrap;">₹' . format_indian_number($total_addon) . '</td>';
$table_content .= '</tr>'; $table_content .= '</tr>';
$table_content .= '</tbody>'; $table_content .= '</tbody>';
$table_content .= '</table></div></div>'; $table_content .= '</table></div></div>';

View File

@ -1,5 +1,39 @@
<?php <?php
use App\Models\UserModel;
if(!function_exists('check_cookie')){
function check_cookie(){
$UserModel = new UserModel();
if(isset($_COOKIE['session_data'])){
$value = (array)json_decode($_COOKIE['session_data']);
$user = $UserModel->getUserByEmail($value['userData']->email);
if($user){
if($user->is_active !== '0'){
$user_team = $UserModel->getUserTeamsByUserID($user->id);
// dd($user_team);
$session_data = [
'isLoggedIn' => True ,
'userid' => $user->id,
'userData' => $user,
'userProfile' => $value['userProfile'],
'user_team' => $user_team,
];
set_session_data($session_data);
// $this->getUserDeviceInfo($user->id, 'NhanceUser');
// return redirect()->to(base_url('/dashboard/view'));
return true;
}
// $session_data = (array)json_decode($_COOKIE['session_data']);
// set_session_data($session_data);
}
}else{
return false;
}
}
if (!function_exists('check_session')) { if (!function_exists('check_session')) {
function check_session() function check_session()
@ -150,7 +184,7 @@ if (!function_exists('user_team')) {
} }
}

View File

@ -24,9 +24,9 @@ if (!function_exists('generate_uuid')) {
} }
} }
if (!function_exists('change_date_format')) { if (!function_exists('change_date_format2')) {
function change_date_format($data, $source_format, $output_format) function change_date_format2($data, $source_format, $output_format)
{ {
$data = trim($data); $data = trim($data);
// echo $data, $source_format, $output_format;return true; // echo $data, $source_format, $output_format;return true;
@ -404,67 +404,68 @@ if(!function_exists('checkFamilyFloaters')){
} }
} }
if (!function_exists('numberToWords')) {
function numberToWords($number)
{
$words = array(
'0' => 'Zero',
'1' => 'One',
'2' => 'Two',
'3' => 'Three',
'4' => 'Four',
'5' => 'Five',
'6' => 'Six',
'7' => 'Seven',
'8' => 'Eight',
'9' => 'Nine',
'10' => 'Ten',
'11' => 'Eleven',
'12' => 'Twelve',
'13' => 'Thirteen',
'14' => 'Fourteen',
'15' => 'Fifteen',
'16' => 'Sixteen',
'17' => 'Seventeen',
'18' => 'Eighteen',
'19' => 'Nineteen',
'20' => 'Twenty',
'30' => 'Thirty',
'40' => 'Forty',
'50' => 'Fifty',
'60' => 'Sixty',
'70' => 'Seventy',
'80' => 'Eighty',
'90' => 'Ninety'
);
function numberToWords($number) if ($number < 21) {
{ return $words[$number];
$words = array(
'0' => 'Zero',
'1' => 'One',
'2' => 'Two',
'3' => 'Three',
'4' => 'Four',
'5' => 'Five',
'6' => 'Six',
'7' => 'Seven',
'8' => 'Eight',
'9' => 'Nine',
'10' => 'Ten',
'11' => 'Eleven',
'12' => 'Twelve',
'13' => 'Thirteen',
'14' => 'Fourteen',
'15' => 'Fifteen',
'16' => 'Sixteen',
'17' => 'Seventeen',
'18' => 'Eighteen',
'19' => 'Nineteen',
'20' => 'Twenty',
'30' => 'Thirty',
'40' => 'Forty',
'50' => 'Fifty',
'60' => 'Sixty',
'70' => 'Seventy',
'80' => 'Eighty',
'90' => 'Ninety'
);
if ($number < 21) {
return $words[$number];
}
if ($number < 100) {
$tens = (int)($number / 10) * 10;
$units = $number % 10;
return $words[$tens] . ($units ? ' ' . $words[$units] : '');
}
if ($number < 1000) {
$hundreds = (int)($number / 100);
$remainder = $number % 100;
return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : '');
}
$levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion');
for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) {
if ($number < $unit * 1000) {
$current = (int)($number / $unit);
$remainder = $number % $unit;
return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : '');
} }
}
return $number; // Fallback for numbers beyond the supported range if ($number < 100) {
$tens = (int)($number / 10) * 10;
$units = $number % 10;
return $words[$tens] . ($units ? ' ' . $words[$units] : '');
}
if ($number < 1000) {
$hundreds = (int)($number / 100);
$remainder = $number % 100;
return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : '');
}
$levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion');
for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) {
if ($number < $unit * 1000) {
$current = (int)($number / $unit);
$remainder = $number % $unit;
return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : '');
}
}
return $number; // Fallback for numbers beyond the supported range
}
} }
if (!function_exists('print_rr')) { if (!function_exists('print_rr')) {
@ -493,6 +494,7 @@ if (!function_exists('get_server_details')) {
]; ];
} }
} }
if (!function_exists('isJsonString')) { if (!function_exists('isJsonString')) {
function isJsonString($input) function isJsonString($input)
@ -501,3 +503,161 @@ if (!function_exists('isJsonString')) {
return (json_last_error() === JSON_ERROR_NONE); // Check if the last JSON error is "no error" return (json_last_error() === JSON_ERROR_NONE); // Check if the last JSON error is "no error"
} }
} }
if (!function_exists('isValidDate')) {
function isValidDate($date, $format) {
$parsed_date = DateTime::createFromFormat($format, $date);
return $parsed_date && $parsed_date->format($format) === $date;
}
}
if (!function_exists('change_date_format')) {
function change_date_format($date_str, $source_format = null, $output_format = 'Y-m-d') {
$date_str = trim($date_str);
// Allowed date formats
$allowed_formats = [
// Day Month Year (clear unambiguous formats)
'd M Y', // 01 Dec 2024
'd-M-Y', // 01-Dec-2024
'd/M/Y', // 01/Dec/2024
'd.M.Y', // 01.Dec.2024
'd,M,Y', // 01,Dec,2024
// Month Day Year (clear unambiguous formats)
'M d Y', // Dec 01 2024
'M-d-Y', // Dec-01-2024
'M/d/Y', // Dec/01/2024
'M.d.Y', // Dec.01.2024
'M,d,Y', // Dec,01,2024
// Year Month Day (clear unambiguous formats)
'Y M d', // 2024 Dec 01
'Y-M-d', // 2024-Dec-01
'Y/M/d', // 2024/Dec/01
'Y.M.d', // 2024.Dec.01
'Y,M,d', // 2024,Dec,01
// Year Numeric Month Numeric Day
'Y-m-d', // 2024-12-01
'Y/m/d', // 2024/12/01
'Y.m.d', // 2024.12.01
'Y,m,d', // 2024,12,01
];
try {
// Case 1: Source and Output formats are provided
if ($source_format !== null && $output_format !== null) {
$date = DateTime::createFromFormat($source_format, $date_str);
if (!$date) {
throw new Exception("Invalid date string for source format: $source_format");
}
return $date->format($output_format);
}
// Case 2: Source format is provided, Output format is null
if ($source_format !== null && $output_format === null) {
$date = DateTime::createFromFormat($source_format, $date_str);
if (!$date) {
throw new Exception("Invalid date string for source format: $source_format");
}
return $date->format('Y-m-d'); // MySQL default format
}
// Case 3: Source format is null, auto-detect format
if ($source_format === null) {
foreach ($allowed_formats as $format) {
if (isValidDate($date_str, $format)) {
$date = DateTime::createFromFormat($format, $date_str);
return $date->format($output_format); // Default is MySQL format
}
}
// If no format matches, throw an exception
$allowed_placeholders = implode(', ', $allowed_formats);
throw new Exception("Invalid date string format. Allowed formats: $allowed_placeholders");
}
} catch (Exception $e) {
return "Error: " . $e->getMessage();
}
return null;
}
}
// if (!function_exists('check_pay_by_employee_or_company'))
// {
// function check_pay_by_employee_or_company($is_payable_employee = null, $relationship = null) {
// $relationship = strtolower(str_replace(" ", "_", $relationship));
// $result = 0;
// if($relationship == 'self'){
// $result = $is_payable_employee['self'] == 1 ? 1 : 0;
// }else if($relationship == 'spouse'){
// $result = $is_payable_employee['spouse'] == 1 ? 1 : 0;
// }else if(in_array($relationship, ['son', 'daughter'])){
// $result = $is_payable_employee['childern'] == 1 ? 1 : 0;
// }else if(in_array($relationship, ['father', 'mother', 'father_in_law', 'mother_in_law'])){
// $result = $is_payable_employee['elders'] == 1 ? 1 : 0;
// }
// return $result;
// }
// }
if (!function_exists('check_pay_by_employee_or_company')) {
function check_pay_by_employee_or_company($policy_terms = null, $relationship = null)
{
// dd($policy_terms, $relationship);
if (!$policy_terms || !($policy_terms = json_decode($policy_terms, true))) {
return 0;
}
// dd($policy_terms, $relationship);
if (!isset($policy_terms['is_payable_employee'])) {
return 0;
}
$is_payable_employee = $policy_terms['is_payable_employee'];
$relationship = strtolower(str_replace(" ", "_", $relationship));
// dd($is_payable_employee, $relationship);
$relationshipMap = [
'self' => 'self',
'spouse' => 'spouse',
'son' => 'childern',
'daughter' => 'childern',
'father' => 'elders',
'mother' => 'elders',
'father_in_law' => 'elders',
'mother_in_law' => 'elders'
];
if (array_key_exists($relationship, $relationshipMap)) {
$key = $relationshipMap[$relationship];
return isset($is_payable_employee[$key]) && $is_payable_employee[$key] == 1 ? 1 : 0;
}
return 0;
}
}

View File

@ -21,7 +21,7 @@ class MyLogger extends Logger
$message = '{context} - {uuid} -' . $message; $message = '{context} - {uuid} -' . $message;
// /echo $message;//die(); // /echo $message;//die();
$context = array_merge($context,['uuid' => get_session_uuid()]); $context = array_merge($context,['uuid' => (null !== get_session_uuid()) ? get_session_uuid() : 'CLI']);
// print_r($context);die(); // print_r($context);die();
// echo isset($context['context']) ? $context['context'] : $this->context;die(); // echo isset($context['context']) ? $context['context'] : $this->context;die();
$context['context'] = isset($context['context']) ? $context['context'] : get_session_context(); $context['context'] = isset($context['context']) ? $context['context'] : get_session_context();

View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class AuditHistoryModel extends Model
{
protected $table = 'auditing_history';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"pk",
"table_name",
"field_name",
"old_value",
"new_value",
"created_by",
"created_at",
];
}
?>

View File

@ -65,28 +65,37 @@ class CDMasterModel extends Model
{ {
$query = $this->db->table('cd_master') $query = $this->db->table('cd_master')
->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count, IFNULL(cd_ac_counts_for_cdt.cd_ac_no_count_cd_tranction, 0) AS cd_ac_no_count_cd_tranction') ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count, IFNULL(cd_ac_counts_for_cdt.cd_ac_no_count_cd_tranction, 0) AS cd_ac_no_count_cd_tranction')
->join('clients', 'clients.id = cd_master.client_id') ->join('clients', 'clients.id = cd_master.client_id')
->join('insurers', 'insurers.id = cd_master.insurer_id') ->join('insurers', 'insurers.id = cd_master.insurer_id')
->join('user_profiles', 'user_profiles.id = cd_master.created_by') ->join('user_profiles', 'user_profiles.id = cd_master.created_by')
->join( ->join(
'(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count '(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
FROM cd_master
JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no FROM cd_master
WHERE client_policy.is_active = 1 JOIN client_policy ON client_policy.cd_ac_pk = cd_master.id
AND cd_master.is_active = 1 WHERE client_policy.is_active = 1
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts', AND cd_master.is_active = 1
'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no', GROUP BY cd_master.id
) AS cd_ac_counts',
'cd_ac_counts.id = cd_master.id',
'left' 'left'
) )
->join( ->join(
'(SELECT cd_master.cd_ac_no, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction '(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction
FROM cd_master
JOIN cash_deposit ON cash_deposit.cd_ac_no = cd_master.cd_ac_no FROM cd_master
WHERE cash_deposit.is_active = 1 JOIN cash_deposit ON cash_deposit.cd_ac_pk = cd_master.id
AND cd_master.is_active = 1 WHERE cash_deposit.is_active = 1
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts_for_cdt', AND cd_master.is_active = 1
'cd_ac_counts_for_cdt.cd_ac_no = cd_master.cd_ac_no', GROUP BY cd_master.id
) AS cd_ac_counts_for_cdt',
'cd_ac_counts_for_cdt.id = cd_master.id',
'left' 'left'
) )
->where('cd_master.is_active', 1) ->where('cd_master.is_active', 1)

View File

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class COShareStmtDetailsModel extends Model
{
protected $table = 'co_share_stmt_details';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
'id',
'co_share_id',
'statement_id',
'actual_bp_amt',
'actual_tp_amt',
'actual_tep_amt',
'actual_bp_per',
'actual_tp_per',
'actual_tep_per',
'actual_bp_brokerage_amt',
'actual_tp_brokerage_amt',
'actual_tep_brokerage_amt',
'reward',
'exp_amt',
'variance',
'created_by',
'updated_by',
'is_active'
];
}

View File

@ -27,6 +27,7 @@ class ClientDepositModel extends Model
"endorsement_no", "endorsement_no",
"event_name", "event_name",
"unit", "unit",
"cd_ac_pk"
]; ];

View File

@ -39,6 +39,7 @@ class ClientModel extends Model
"email", "email",
"reply_to", "reply_to",
"mail_domain", "mail_domain",
"addon_subheading",
]; ];

View File

@ -51,8 +51,43 @@ class ClientPolicyModel extends Model
"enrolment_visibility", "enrolment_visibility",
"disclaimer", "disclaimer",
"is_active", "is_active",
"is_member_modify_allowed",
"cd_ac_pk"
]; ];
// 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 getClientPolicyById($id){ public function getClientPolicyById($id){
return $this->db->table('client_policy') return $this->db->table('client_policy')
@ -135,13 +170,14 @@ class ClientPolicyModel extends Model
public function getinsurerswithclientid($id){ public function getinsurerswithclientid($id){
return $this->db->table('client_policy') return $this->db->table('client_policy')
->select('client_policy.*, cd_master.cd_ac_no') ->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('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('clients.client_name as client_name') ->select('clients.client_name as client_name')
->join('clients','clients.id=client_policy.client_id') ->join('clients','clients.id=client_policy.client_id')
->join('insurers', 'insurers.id = client_policy.insurer_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') ->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('client_policy.client_id', $id)
->where('cd_master.id = client_policy.cd_ac_pk')
->groupBy('client_policy.insurer_id') ->groupBy('client_policy.insurer_id')
->groupBy('client_policy.client_id', $id) // Group by insurer_id ->groupBy('client_policy.client_id', $id) // Group by insurer_id
->get() ->get()
@ -191,6 +227,7 @@ class ClientPolicyModel extends Model
->select('cash_deposit.*') ->select('cash_deposit.*')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short') ->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') ->select('clients.client_name as clientname, clients.short_name as clientshort, client_policy.policy_no')
->select('cd_master.cd_ac_no as cd_master_account_no')
// ->select('policies.name as policy_name') // ->select('policies.name as policy_name')
->select('policy_type.policy_type') ->select('policy_type.policy_type')
->select('user_profiles.first_name as username') ->select('user_profiles.first_name as username')
@ -198,11 +235,13 @@ class ClientPolicyModel extends Model
->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left') ->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left')
->join('clients', 'clients.id = cash_deposit.client_id', 'left') ->join('clients', 'clients.id = cash_deposit.client_id', 'left')
->join('client_policy', 'client_policy.id = cash_deposit.client_policy_id', 'left') ->join('client_policy', 'client_policy.id = cash_deposit.client_policy_id', 'left')
->join('cd_master', 'cd_master.id = cash_deposit.cd_ac_pk', 'left')
// ->join('policies', 'policies.id = client_policy.policy_id', 'left') // ->join('policies', 'policies.id = client_policy.policy_id', 'left')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
->where('cash_deposit.client_id', $clientId) ->where('cash_deposit.client_id', $clientId)
->where('cash_deposit.insurer_id', $insurerId) ->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') ->orderBy('cash_deposit.id', 'DESC')
->get() ->get()
->getResult(); ->getResult();
@ -389,21 +428,26 @@ public function getCliendDataForExcelFileName($client_policy_id){
} }
//for this using in CRONE JOB //for this using in CRONE JOB
public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null) public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null)
{ {
$builder = $this->table('client_policy') $builder = $this->table('client_policy')
->where('client_policy.is_addon', 1)
->where('client_policy.open_for_enrollment', 1)
->where('client_policy.inception_type', 2)
->where('client_policy.is_active', 1) ->where('client_policy.is_active', 1)
->where('client_policy.policy_status', 1) ->where('client_policy.policy_status', 1)
->whereIn('client_policy.policy_type_id', [2, 3]); // ->where('client_policy.is_addon', 1)
// ->where('client_policy.inception_type', 2)
->where('client_policy.open_for_enrollment', 1);
if ($client_id && $branch_id) { if ($client_id && $branch_id) {
$builder->where('client_policy.client_id', $client_id) $builder->where('client_policy.client_id', $client_id)
->where('client_policy.client_branch_id', $branch_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();
} }

View File

@ -106,7 +106,7 @@ class EmployeeModel extends Model
public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = []) public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = [])
{ {
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon']) $result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employees.file_id','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee'])
->join('employee_polices', 'employee_polices.employee_id = employees.id') ->join('employee_polices', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left')
@ -149,10 +149,12 @@ class EmployeeModel extends Model
{ {
return $this->db->table('employee_polices') return $this->db->table('employee_polices')
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables ->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.policy_status', 1) ->where('client_policy.policy_status', 1)
->where('employee_polices.status !=', 'truncated')
->where('employee_polices.is_active', 1)
->where('employee_polices.employee_id', $id) ->where('employee_polices.employee_id', $id)
->get() ->get()
->getResult(); ->getResult();
@ -210,4 +212,32 @@ class EmployeeModel extends Model
return $results; return $results;
} }
public function getTestEmployeeData(){
$query = "
SELECT
e.*,
(
SELECT
COUNT(ep.client_policy_id)
FROM
employee_polices ep
WHERE
ep.employee_id = e.id
) AS policy_count
FROM
employees e
WHERE
e.emp_code LIKE 'TEST%'
ORDER BY
e.emp_code,
CASE
WHEN e.relationship = 'self' THEN 1
WHEN e.relationship = 'spouse' THEN 2
ELSE 3
END;
";
$results = $this->db->query($query)->getResultArray();
return $results;
}
} }

View File

@ -32,6 +32,10 @@ class EmployeePolicyModel extends Model
"updated_at", "updated_at",
"rand_string", "rand_string",
"is_active", "is_active",
"claim_status",
'ecard_sent_status',
'payable_employee',
'file_id'
]; ];
// Callbacks // Callbacks
@ -111,6 +115,7 @@ class EmployeePolicyModel extends Model
'client_branch.branch_name as client_branch_name', 'client_branch.branch_name as client_branch_name',
'client_branch.branch_code as client_branch_code', 'client_branch.branch_code as client_branch_code',
'cp.policy_no', 'cp.policy_no',
'cp.policy_type_id',
]) ])
->join('employees emp', 'employee_polices.employee_id = emp.id') ->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
@ -124,7 +129,6 @@ class EmployeePolicyModel extends Model
->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master ->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
->orderBy('emp.emp_code', 'ASC') ->orderBy('emp.emp_code', 'ASC')
->orderBy('employee_polices.employee_id', 'ASC'); ->orderBy('employee_polices.employee_id', 'ASC');
// Conditionally add where clauses // Conditionally add where clauses
if ($client_id != 0 && !empty($client_id)) { if ($client_id != 0 && !empty($client_id)) {
$result->where('emp.client_id', $client_id); $result->where('emp.client_id', $client_id);
@ -177,7 +181,11 @@ class EmployeePolicyModel extends Model
$result->where('employee_polices.is_active', 1) $result->where('employee_polices.is_active', 1)
->where('emp.is_active', 1); ->where('emp.is_active', 1);
return $result->findAll(); $res = $result->findAll();
// dd($this->db->getLastQuery());
return $res;
} }
public function getEmployeePolicyForEcard($policy_id = 0) public function getEmployeePolicyForEcard($policy_id = 0)
@ -185,7 +193,7 @@ class EmployeePolicyModel extends Model
$result = $this->select([ $result = $this->select([
'employee_polices.id' 'employee_polices.id'
]) ])
->join('employees emp', 'employee_polices.employee_id = emp.id AND emp.relationship = "Self" '); ->join('employees emp', 'employee_polices.employee_id = emp.id');
if ($policy_id !=0 && !empty($policy_id)) { if ($policy_id !=0 && !empty($policy_id)) {
$result->where('employee_polices.client_policy_id', $policy_id); $result->where('employee_polices.client_policy_id', $policy_id);
} }
@ -193,7 +201,10 @@ class EmployeePolicyModel extends Model
$result->where('employee_polices.is_active', 1) $result->where('employee_polices.is_active', 1)
->where('employee_polices.status', 'active') ->where('employee_polices.status', 'active')
->where('employee_polices.tpa_id is not null') ->where('employee_polices.tpa_id is not null')
->where('emp.relationship','Self'); ->where('employee_polices.ecard_sent_status',0)
// ->where('emp.relationship','Self');
->where('emp.email_corporate !=','')
->where('emp.email_corporate is not null');
return $result->findAll(); return $result->findAll();
// $result->findAll(); // $result->findAll();
@ -214,6 +225,7 @@ class EmployeePolicyModel extends Model
public function getInceptionEmployeeDataForExportExcel($ref_data, $return_type = 0) public function getInceptionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{ {
$client_id = $ref_data['client_id'];
$client_policy_id = $ref_data['client_policy_id']; $client_policy_id = $ref_data['client_policy_id'];
$client_branch_id = $ref_data['client_branch_id']; $client_branch_id = $ref_data['client_branch_id'];
$insurer_or_tpa = $ref_data['insurer_or_tpa']; $insurer_or_tpa = $ref_data['insurer_or_tpa'];
@ -247,7 +259,6 @@ class EmployeePolicyModel extends Model
SELECT SELECT
employees.name AS emp_name, employees.name AS emp_name,
employees.emp_code AS emp_code, employees.emp_code AS emp_code,
employees.dob AS emp_dob,
employees.gender AS emp_gender, employees.gender AS emp_gender,
employees.relationship AS emp_relationship, employees.relationship AS emp_relationship,
employees.relationship_code AS emp_relationship_code, employees.relationship_code AS emp_relationship_code,
@ -255,7 +266,6 @@ class EmployeePolicyModel extends Model
employees.change_event AS change_event, employees.change_event AS change_event,
employees.doj AS emp_doj,
employees.mobile AS emp_mobile, employees.mobile AS emp_mobile,
employees.email_corporate AS emp_email_c, employees.email_corporate AS emp_email_c,
employees.email_personal AS emp_email_p, employees.email_personal AS emp_email_p,
@ -272,8 +282,6 @@ class EmployeePolicyModel extends Model
employee_polices.uhid, employee_polices.uhid,
employee_polices.pre_existing_alignments, employee_polices.pre_existing_alignments,
employee_polices.basic_cover_si, employee_polices.basic_cover_si,
employee_polices.date_coverage,
employee_polices.policy_end_date,
employee_polices.days as no_of_days, employee_polices.days as no_of_days,
employee_polices.premium, employee_polices.premium,
employee_polices.rata_premimum as pro_rata_premium, employee_polices.rata_premimum as pro_rata_premium,
@ -283,6 +291,12 @@ class EmployeePolicyModel extends Model
batch_data.bl AS batch_list_batch_code, batch_data.bl AS batch_list_batch_code,
batch_data.bf AS batch_files_batch_code, batch_data.bf AS batch_files_batch_code,
DATE_FORMAT(employees.dob, '%d-%b-%Y') AS emp_dob,
DATE_FORMAT(employees.doj, '%d-%b-%Y') AS emp_doj,
DATE_FORMAT(employee_polices.policy_end_date, '%d-%b-%Y') AS policy_end_date,
DATE_FORMAT(employee_polices.date_coverage, '%d-%b-%Y') AS date_of_coverage,
CASE CASE
WHEN client_branch.sez = 0 THEN 'NON-SEZ' WHEN client_branch.sez = 0 THEN 'NON-SEZ'
WHEN client_branch.sez = 1 THEN 'SEZ' WHEN client_branch.sez = 1 THEN 'SEZ'
@ -301,6 +315,9 @@ class EmployeePolicyModel extends Model
WHERE batch_files.event_type = '{$event}' WHERE batch_files.event_type = '{$event}'
AND batch_files.actions = 'export' AND batch_files.actions = 'export'
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}' AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
AND batch_files.client_policy_id = '{$client_policy_id}'
AND batch_files.client_policy_id = '{$client_id}'
) as batch_data ON employee_polices.id = batch_data.emp_policy_id ) as batch_data ON employee_polices.id = batch_data.emp_policy_id
WHERE employee_polices.client_policy_id = '{$client_policy_id}' WHERE employee_polices.client_policy_id = '{$client_policy_id}'
AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '') AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '')
@ -319,11 +336,14 @@ class EmployeePolicyModel extends Model
}else{ }else{
$results = $query->getResult(); $results = $query->getResult();
} }
// dd($this->db->getLastQuery());
return $results; return $results;
} }
public function getCorrectionEmployeesDataForExportExcel($ref_data) public function getCorrectionEmployeesDataForExportExcel($ref_data, $return_type = 0)
{ {
$client_id = $ref_data['client_id']; $client_id = $ref_data['client_id'];
@ -331,22 +351,19 @@ class EmployeePolicyModel extends Model
$client_branch_id = $ref_data['client_branch_id']; $client_branch_id = $ref_data['client_branch_id'];
$insurer_or_tpa = $ref_data['insurer_or_tpa']; $insurer_or_tpa = $ref_data['insurer_or_tpa'];
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (emp_endorsement.endorsement_id IS NOT NULL OR emp_endorsement.endorsement_id != '')" : "AND (emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')"; $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')" : "AND (emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')";
$sql = " $sql = "
SELECT DISTINCT SELECT DISTINCT
emp_endorsement.id, emp_endorsement.id,
emp_endorsement.pk, emp_endorsement.pk,
emp_endorsement.emp_code, emp_endorsement.emp_code,
emp_endorsement.endorsement_id, emp_endorsement.endorsement_id,
emp_endorsement.old_value,
emp_endorsement.new_value,
emp_endorsement.field_name, emp_endorsement.field_name,
emp_endorsement.remarks, emp_endorsement.remarks,
emp_endorsement.actions, emp_endorsement.actions,
employees.id AS primaryKey, employees.id AS primaryKey,
employees.name AS emp_name, employees.name AS emp_name,
employees.dob AS emp_dob,
employees.gender AS emp_gender, employees.gender AS emp_gender,
employees.client_id AS emp_client_id, employees.client_id AS emp_client_id,
employees.emp_type as emp_type, employees.emp_type as emp_type,
@ -356,7 +373,23 @@ class EmployeePolicyModel extends Model
employees.relationship as emp_relationship, employees.relationship as emp_relationship,
'C' as event_type_data, 'C' as event_type_data,
employees.doj AS emp_doj, CASE
WHEN emp_endorsement.field_name = 'dob' THEN
DATE_FORMAT(emp_endorsement.old_value, '%d-%b-%Y')
ELSE
emp_endorsement.old_value
END AS old_value,
CASE
WHEN emp_endorsement.field_name = 'dob' THEN
DATE_FORMAT(emp_endorsement.new_value, '%d-%b-%Y')
ELSE
emp_endorsement.new_value
END AS new_value,
DATE_FORMAT(employees.dob, '%d-%b-%Y') AS emp_dob,
DATE_FORMAT(employees.doj, '%d-%b-%Y') AS emp_doj,
employees.mobile AS emp_mobile, employees.mobile AS emp_mobile,
employees.email_corporate AS emp_email_c, employees.email_corporate AS emp_email_c,
employees.email_personal AS emp_email_p, employees.email_personal AS emp_email_p,
@ -396,19 +429,21 @@ class EmployeePolicyModel extends Model
AND employee_polices.status = 'active' AND employee_polices.status = 'active'
AND employees.is_active = 1 AND employees.is_active = 1
AND employees.emp_status = 'active' AND employees.emp_status = 'active'
AND (employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id != '')
AND (employee_polices.uhid IS NOT NULL AND employee_polices.uhid != '')
$endorsement_condition"; $endorsement_condition";
// Execute the raw query // Execute the raw query
$query = $this->db->query($sql); $query = $this->db->query($sql);
// Get the result set // Get the result set
$result = $query->getResult(); if($return_type == 1){
$results = $query->getResultArray();
}else{
$results = $query->getResult();
}
// dd($this->db->getLastQuery(), $result); // dd($this->db->getLastQuery(), $result);
return $result; return $results;
} }
@ -553,8 +588,177 @@ class EmployeePolicyModel extends Model
} }
// DO NOT DELETE this DELETION QUERY FUNCTION
public function getDeletionEmployeeDataForExportExcel($ref_data) // public function getDeletionEmployeeDataForExportExcel($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'];
// $get_insurer_id_from_client_policy = $this->db->table('client_policy')
// ->select('insurer_id')
// ->where('id', $client_policy_id)
// ->get()
// ->getRowArray();
// $add_one_day = 0;
// if (!empty($get_insurer_id_from_client_policy)) {
// $get_the_insurer_add_one_for_delete = $this->db->table('insurers')
// ->select('deletion_add_day')
// ->where('id', $get_insurer_id_from_client_policy['insurer_id'])
// ->get()
// ->getRowArray();
// if (!empty($get_the_insurer_add_one_for_delete) && $get_the_insurer_add_one_for_delete['deletion_add_day'] == 1) {
// $add_one_day = 1;
// }
// }
// $status_condition = "{$insurer_or_tpa}" === 'tpa'
// ? "employee_polices.status = 'inactive' AND employees.emp_status = 'inactive'"
// : "employee_polices.status = 'active' AND employees.emp_status = 'active'";
// $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
// 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 AS emp_relationship,
// employees.relationship_code AS emp_relationship_code,
// employees.emp_type as emp_type,
// 'D' as event_type_data,
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
// 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.basic_cover_si,
// employee_polices.uhid as uhid,
// employee_polices.policy_end_date,
// employee_polices.rata_premimum as premium,
// employee_polices.claim_status,
// batch_data.emp_policy_id AS emp_policy_id,
// batch_data.bl AS batch_list_batch_code,
// batch_data.bf AS batch_files_batch_code,
// deletiondata.empstatus,
// deletiondata.changeevent,
// deletiondata.dateofexit,
// deletiondata.reasonforexit,
// deletiondata.status,
// DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
// ELSE
// 0
// END AS pro_rata_premium,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
// ELSE
// 0
// END AS gst,
// CASE
// WHEN employee_polices.claim_status = 0 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)
// ELSE
// 0
// END AS total,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// 'No claim'
// ELSE
// 'Claim'
// END AS claim_status
// FROM
// emp_endorsement a
// LEFT JOIN
// employees ON a.emp_code = employees.emp_code
// LEFT JOIN
// employee_polices ON employees.id = employee_polices.employee_id
// LEFT JOIN(
// select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
// ( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
// left join
// ( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') 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 = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
// left join
// ( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
// left JOIN
// ( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
// ) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
// LEFT JOIN
// (
// SELECT
// 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 = 'deletion'
// 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 = 'd'
// AND a.status != 'truncated'
// AND employee_polices.is_active = 1
// AND employees.is_active = 1
// AND $status_condition
// group by group_key
// ");
// if($return_type == 1){
// $result = $query->getResultArray();
// }else{
// $result = $query->getResult();
// }
// // dd($this->db->getLastQuery(), $result);
// return $result;
// }
public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{ {
$client_id = $ref_data['client_id']; $client_id = $ref_data['client_id'];
@ -584,10 +788,10 @@ class EmployeePolicyModel extends Model
} }
$status_condition = "{$insurer_or_tpa}" === 'tpa' $status_condition = "{$insurer_or_tpa}" === 'tpa'
? "employee_polices.status = 'inactive' AND employees.emp_status = 'inactive'" ? "employee_polices.status = 'active' AND employees.emp_status = 'active'"
: "employee_polices.status = 'active' 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 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 NULL OR a.endorsement_id = '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
$query = $this->db->query(" $query = $this->db->query("
SELECT DISTINCT SELECT DISTINCT
@ -596,7 +800,6 @@ class EmployeePolicyModel extends Model
employee_polices.id as primaryKey, employee_polices.id as primaryKey,
employees.name AS emp_name, employees.name AS emp_name,
employees.emp_code AS emp_code, employees.emp_code AS emp_code,
employees.dob AS emp_dob,
employees.gender AS emp_gender, employees.gender AS emp_gender,
employees.relationship AS emp_relationship, employees.relationship AS emp_relationship,
employees.relationship_code AS emp_relationship_code, employees.relationship_code AS emp_relationship_code,
@ -604,7 +807,6 @@ class EmployeePolicyModel extends Model
'D' as event_type_data, 'D' as event_type_data,
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age, TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
employees.doj AS emp_doj,
employees.mobile AS emp_mobile, employees.mobile AS emp_mobile,
employees.email_corporate AS emp_email_c, employees.email_corporate AS emp_email_c,
employees.email_personal AS emp_email_p, employees.email_personal AS emp_email_p,
@ -614,9 +816,8 @@ class EmployeePolicyModel extends Model
employee_polices.basic_cover_si, employee_polices.basic_cover_si,
employee_polices.uhid as uhid, employee_polices.uhid as uhid,
employee_polices.policy_end_date, employee_polices.rata_premimum as premium,
employee_polices.premium, employee_polices.claim_status,
employee_polices.rata_premimum as pro_rata_premium,
batch_data.emp_policy_id AS emp_policy_id, batch_data.emp_policy_id AS emp_policy_id,
batch_data.bl AS batch_list_batch_code, batch_data.bl AS batch_list_batch_code,
@ -624,39 +825,77 @@ class EmployeePolicyModel extends Model
deletiondata.empstatus, deletiondata.empstatus,
deletiondata.changeevent, deletiondata.changeevent,
deletiondata.dateofexit,
deletiondata.reasonforexit, deletiondata.reasonforexit,
deletiondata.status, deletiondata.status,
deletiondata.claimstatus,
DATE_FORMAT(employees.dob, '%d-%b-%Y') AS emp_dob,
DATE_FORMAT(employees.doj, '%d-%b-%Y') AS emp_doj,
DATE_FORMAT(employee_polices.policy_end_date, '%d-%b-%Y') AS policy_end_date,
DATE_FORMAT(deletiondata.dateofexit, '%d-%b-%Y') AS dateofexit,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days, DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2) AS pro_rata_premium,
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2) AS gst, CASE
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) AS total 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)
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)
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)
ELSE
0
END AS total,
CASE
WHEN deletiondata.claimstatus = 0 OR deletiondata.claimstatus IS NULL THEN
'No claim'
ELSE
'Claim'
END AS claim_status
FROM FROM
emp_endorsement a emp_endorsement a
LEFT JOIN LEFT JOIN
employees ON a.emp_code = employees.emp_code and a.pk = employees.id employee_polices ON a.pk = employee_polices.id
LEFT JOIN LEFT JOIN
employee_polices ON employees.id = employee_polices.employee_id employees ON employee_polices.employee_id = employees.id
LEFT JOIN( LEFT JOIN (
SELECT
select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from emp_code,
group_key,
( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
left join MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
left join MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status,
left join MAX(CASE WHEN field_name = 'claim_status' THEN new_value END) AS claimstatus
( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code FROM
left JOIN emp_endorsement
( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code WHERE
status != 'truncated'
) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated' GROUP BY
group_key
) AS deletiondata
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
LEFT JOIN LEFT JOIN
( (
SELECT SELECT
batch_list.emp_policy_id, batch_list.emp_policy_id,
batch_list.batch_code AS bl, batch_list.batch_code AS bl,
@ -669,7 +908,7 @@ class EmployeePolicyModel extends Model
batch_files.event_type = 'deletion' batch_files.event_type = 'deletion'
AND batch_files.actions = 'export' AND batch_files.actions = 'export'
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}' AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id ) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
WHERE employee_polices.client_policy_id = {$client_policy_id} WHERE employee_polices.client_policy_id = {$client_policy_id}
AND employees.client_branch_id = {$client_branch_id} AND employees.client_branch_id = {$client_branch_id}
@ -682,9 +921,15 @@ class EmployeePolicyModel extends Model
group by group_key group by group_key
"); ");
$result = $query->getResult(); if($return_type == 1){
$result = $query->getResultArray();
}else{
$result = $query->getResult();
}
// dd($this->db->getLastQuery(), $result); // dd($this->db->getLastQuery(), $result);
// dd($result);
return $result; return $result;
} }
@ -706,6 +951,7 @@ class EmployeePolicyModel extends Model
ee.id as emp_endorsement_primarykey, ee.id as emp_endorsement_primarykey,
ep.id as emp_policy_primarykey, ep.id as emp_policy_primarykey,
e.id as employees_primarykey, e.id as employees_primarykey,
ee.file_id,
ee.group_key, ee.group_key,
( (
SELECT employees.id SELECT employees.id
@ -733,7 +979,12 @@ class EmployeePolicyModel extends Model
CASE CASE
WHEN ee.field_name = 'status' THEN ee.new_value WHEN ee.field_name = 'status' THEN ee.new_value
END END
) AS status ) AS status,
MAX(
CASE
WHEN ee.field_name = 'claim_status' THEN ee.new_value
END
) AS claim_status
FROM FROM
emp_endorsement AS ee emp_endorsement AS ee
JOIN employee_polices AS ep ON ep.id = ee.pk JOIN employee_polices AS ep ON ep.id = ee.pk
@ -743,7 +994,7 @@ class EmployeePolicyModel extends Model
AND ep.client_policy_id = '$client_policy_id' AND ep.client_policy_id = '$client_policy_id'
AND e.client_branch_id = '$client_branch_id' AND e.client_branch_id = '$client_branch_id'
AND ee.name = '$emp_name' AND ee.name = '$emp_name'
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status') AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status', 'claim_status')
AND ep.is_active = 1 AND ep.is_active = 1
AND ep.status = 'active' AND ep.status = 'active'
AND e.is_active = 1 AND e.is_active = 1
@ -801,7 +1052,6 @@ class EmployeePolicyModel extends Model
e.remarks, e.remarks,
e.endorsement_id, e.endorsement_id,
ep.client_policy_id, ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name, insurers.short_name as insurer_short_name,
client_policy.policy_no, client_policy.policy_no,
policy_type.policy_type policy_type.policy_type
@ -811,9 +1061,9 @@ class EmployeePolicyModel extends Model
$query1->join('employees', 'employees.id = ep.employee_id'); $query1->join('employees', 'employees.id = ep.employee_id');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id'); $query1->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query1->join('client_branch', 'client_branch.id = employees.client_branch_id'); $query1->join('client_branch', 'client_branch.id = employees.client_branch_id');
$query1->join('policies', 'policies.id = client_policy.policy_id'); // $query1->join('policies', 'policies.id = client_policy.policy_id');
$query1->join('policy_type', 'policy_type.id = policies.policy_type_id'); $query1->join('policy_type', 'policy_type.id = client_policy.policy_type_id');
$query1->join('insurers', 'insurers.id = policies.insurer_id'); $query1->join('insurers', 'insurers.id = client_policy.insurer_id');
$query1->whereIn('e.actions', ['c']); $query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $policy_id); $query1->where('ep.client_policy_id', $policy_id);
$query1->where('employees.client_id', $client_id); $query1->where('employees.client_id', $client_id);
@ -838,7 +1088,6 @@ class EmployeePolicyModel extends Model
e.endorsement_id, e.endorsement_id,
e.remarks, e.remarks,
ep.client_policy_id, ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name, insurers.short_name as insurer_short_name,
client_policy.policy_no, client_policy.policy_no,
policy_type.policy_type policy_type.policy_type
@ -847,10 +1096,10 @@ class EmployeePolicyModel extends Model
$query2->join('employees', 'employees.id = ep.employee_id'); $query2->join('employees', 'employees.id = ep.employee_id');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id'); $query2->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query2->join('client_branch', 'client_branch.id = employees.client_branch_id'); $query2->join('client_branch', 'client_branch.id = employees.client_branch_id');
$query2->join('policies', 'policies.id = client_policy.policy_id'); // $query2->join('policies', 'policies.id = client_policy.policy_id');
$query2->join('policy_type', 'policy_type.id = policies.policy_type_id'); $query2->join('policy_type', 'policy_type.id = client_policy.policy_type_id');
$query2->join('insurers', 'insurers.id = policies.insurer_id'); $query2->join('insurers', 'insurers.id = client_policy.insurer_id');
$query2->whereIn('e.actions', ['si', 'd']); $query2->whereIn('e.actions', ['si', 'd', 'a']);
$query2->where('ep.client_policy_id', $policy_id); $query2->where('ep.client_policy_id', $policy_id);
$query2->where('employees.client_id', $client_id); $query2->where('employees.client_id', $client_id);
$query2->where('employees.client_branch_id', $branch_id); $query2->where('employees.client_branch_id', $branch_id);
@ -864,6 +1113,8 @@ class EmployeePolicyModel extends Model
$results2 = $query2->get()->getResultArray(); $results2 = $query2->get()->getResultArray();
$results = array_merge($results1, $results2); $results = array_merge($results1, $results2);
// dd($this->db->getLastQuery());
return $results; return $results;
@ -1144,13 +1395,13 @@ class EmployeePolicyModel extends Model
return "WHEN group_key = $id THEN $endorsement_id"; return "WHEN group_key = $id THEN $endorsement_id";
}, $escapedIds, $escapedEndorsementIds); }, $escapedIds, $escapedEndorsementIds);
$caseStatus = array_map(function ($id, $status) { // $caseStatus = array_map(function ($id, $status) {
return "WHEN status = $id THEN $status"; // return "WHEN status = $id THEN $status";
}, $escapedIds, $escapedStatuses); // }, $escapedIds, $escapedStatuses);
// Convert cases to a string // Convert cases to a string
$caseEndorsementIdString = implode(' ', $caseEndorsementId); $caseEndorsementIdString = implode(' ', $caseEndorsementId);
$caseStatusString = implode(' ', $caseStatus); // $caseStatusString = implode(' ', $caseStatus);
// Convert ids to a string // Convert ids to a string
$idsString = implode(', ', $escapedIds); $idsString = implode(', ', $escapedIds);
@ -1160,10 +1411,12 @@ class EmployeePolicyModel extends Model
UPDATE emp_endorsement UPDATE emp_endorsement
SET SET
endorsement_id = CASE {$caseEndorsementIdString} END, endorsement_id = CASE {$caseEndorsementIdString} END,
status = CASE {$caseStatusString} END status = 'complete'
WHERE group_key IN ({$idsString}) WHERE group_key IN ({$idsString})
"; ";
// dd($sql);
// Begin a transaction // Begin a transaction
$this->db->transBegin(); $this->db->transBegin();
@ -1180,6 +1433,7 @@ class EmployeePolicyModel extends Model
// Otherwise, commit // Otherwise, commit
$this->db->transCommit(); $this->db->transCommit();
} }
// $this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
return $this->db->getLastQuery(); return $this->db->getLastQuery();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -1251,5 +1505,234 @@ class EmployeePolicyModel extends Model
} }
//for truncate get deletion data
public function getDeletionDataForTruncated($file_id)
{
// Fetch the necessary details in a single query using JOINs
$result = $this->db->table('files f')
->select('i.deletion_add_day')
->join('client_policy cp', 'cp.id = f.policy_id', 'left')
->join('insurers i', 'i.id = cp.insurer_id', 'left')
->where('f.id', $file_id)
->get()
->getRowArray();
// Determine if one day should be added for deletion
$add_one_day = (!empty($result) && $result['deletion_add_day'] == 1) ? 1 : 0;
$query = $this->db->query("
SELECT DISTINCT
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 AS emp_relationship,
employees.relationship_code AS emp_relationship_code,
employees.emp_type as emp_type,
'D' as event_type_data,
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
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.basic_cover_si,
employee_polices.uhid as uhid,
employee_polices.policy_end_date,
employee_polices.rata_premimum as premium,
employee_polices.claim_status,
deletiondata.empstatus,
deletiondata.changeevent,
deletiondata.dateofexit,
deletiondata.reasonforexit,
deletiondata.status,
deletiondata.claimstatus,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
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)
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)
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)
ELSE
0
END AS total,
CASE
WHEN deletiondata.claimstatus = 0 OR deletiondata.claimstatus IS NULL THEN
'No claim'
ELSE
'Claim'
END AS claim_status
FROM
emp_endorsement a
LEFT JOIN
employee_polices ON a.pk = employee_polices.id
LEFT JOIN
employees ON employee_polices.employee_id = employees.id
LEFT JOIN (
SELECT
emp_code,
group_key,
MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status,
MAX(CASE WHEN field_name = 'claim_status' THEN new_value END) AS claimstatus
FROM
emp_endorsement
WHERE
status != 'truncated'
GROUP BY
group_key
) AS deletiondata
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
WHERE a.file_id = {$file_id}
AND a.actions = 'd'
AND a.status != 'truncated'
AND employee_polices.is_active = 1
AND employees.is_active = 1
group by group_key
");
$result = $query->getResultArray();
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result;
}
//for truncate get addition data
public function getAdditionDataForTruncated($file_id, $event_type)
{
$action = "a";
if($event_type == "dependent_addition"){
$action = "da";
}
$query = $this->db->query("
SELECT
ROUND(SUM(ep.rata_premimum + ep.gst), 2) AS total
FROM
emp_endorsement ee
JOIN
employee_polices ep ON ee.pk = ep.id
WHERE
ee.file_id = $file_id
AND ee.actions = '$action'
AND ep.status != 'truncated'
AND ee.status != 'truncated'
AND ee.is_active = 1
AND ep.is_active = 1;
");
$result = $query->getResultArray();
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result[0];
}
// reverse the employee policy table data for the truncated the deletion file
public function updateEmployeePolicyTruncateReverse($file_id)
{
$this->db->query("
UPDATE employee_polices
SET
is_active = 1,
status = 'active',
date_of_exit = NULL,
reason_for_exit = NULL,
claim_status = 0,
WHERE
id IN (
SELECT pk
FROM emp_endorsement
WHERE file_id = $file_id
GROUP BY group_key
)
AND status = 'inactive'
");
}
//update employee policy table status truncated and is_active 0 for truncated to the addition file
public function updateEmpEndorsementAddition($array)
{
$caseStatus = "CASE ";
$caseEndorsementId = "CASE ";
$ids = [];
foreach ($array as $item) {
$caseStatus .= "WHEN id = {$item['id']} THEN '{$item['status']}' ";
$caseEndorsementId .= "WHEN id = {$item['id']} THEN '{$item['endorsement_id']}' ";
$ids[] = $item['id'];
}
$caseStatus .= "END";
$caseEndorsementId .= "END";
$ids = implode(',', $ids);
$query = "UPDATE emp_endorsement SET status = $caseStatus, endorsement_id = $caseEndorsementId WHERE id IN ($ids);"; // Execute the query
$this->db->query($query);
}
//calculate the CD Transaction sum of the amount for the inception, addition, dependent addition, missed inception
public function calculateCdTranctionAmount($file_id)
{
$query = $this->db->query("
SELECT
ROUND(SUM(ep.rata_premimum + ep.gst), 2) AS total
FROM
employee_polices ep
WHERE
ep.file_id = $file_id
AND ep.uhid IS NOT NULL'
AND ep.status != 'truncated'
AND ep.status != 'truncated'
AND ep.is_active = 1;
");
$result = $query->getResultArray();
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result[0];
}
} }

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class GmailSentHistoryModel extends Model{
protected $table = 'gmail_sent_history';
protected $primaryKey = 'id';
protected $allowedFields = ["id", "mail", "bcc", "cc", "message", "attachments", "client_id", "client_branch_id", "client_policy_id", "employee_policy_id", "employee_id", "mail_type", "gmail_api_status", "gmail_api_id", "created_by", "created_at", "updated_by", "updated_at", "isactive","received_message"];
}

View File

@ -41,11 +41,12 @@ class InsurerModel extends Model
{ {
// Fetch the insurer name based on the insurer ID // Fetch the insurer name based on the insurer ID
$query = $this->db->table('client_policy') $query = $this->db->table('client_policy')
->select('insurers.id, insurers.name, cd_master.cd_ac_no') ->select('insurers.id, insurers.name, cd_master.cd_ac_no as cd_master_account_no')
->join('insurers', 'insurers.id = client_policy.insurer_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') ->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
->where('client_policy.insurer_id', $insurerId) ->where('client_policy.insurer_id', $insurerId)
->where('client_policy.client_id', $client_id) ->where('client_policy.client_id', $client_id)
->where('cd_master.id = client_policy.cd_ac_pk')
->get(); ->get();
if ($query->resultID->num_rows > 0) { if ($query->resultID->num_rows > 0) {
@ -60,7 +61,7 @@ class InsurerModel extends Model
{ {
$insurer_data = $this->db->table('insurer_excel_export_template') $insurer_data = $this->db->table('insurer_excel_export_template')
->select('insurer_excel_export_template.*, insurers.name as insurer_name, insurers.is_multi_event') ->select('insurer_excel_export_template.*, insurers.name as insurer_name, insurers.is_multi_event')
->select('CASE WHEN insurers.is_multi_event = 1 THEN "All" ELSE insurer_excel_export_template.event_name END as event_name', false) // ->select('CASE WHEN insurers.is_multi_event = 1 THEN "All" ELSE insurer_excel_export_template.event_name END as event_name', false)
->select('insurer_excel_export_template.type_name, insurer_excel_export_template.jsoncolumns, policy_type.policy_type') ->select('insurer_excel_export_template.type_name, insurer_excel_export_template.jsoncolumns, policy_type.policy_type')
->join('insurers', 'insurers.id = insurer_excel_export_template.insurer_id') ->join('insurers', 'insurers.id = insurer_excel_export_template.insurer_id')
->join('policy_type', 'policy_type.id = insurer_excel_export_template.policy_type_id') ->join('policy_type', 'policy_type.id = insurer_excel_export_template.policy_type_id')

View File

@ -23,7 +23,11 @@ class InsurerStatements extends Model
"invoice_no", "invoice_no",
"invoice_amount", "invoice_amount",
"invoice_date", "invoice_date",
"updated_by" "updated_by",
"stmt_sno",
"gst_per",
"gst_value",
"invoice_value"
]; ];

View File

@ -16,6 +16,7 @@ class InvPaymentDetailsModel extends Model
'inv_amt', 'inv_amt',
'utr_no', 'utr_no',
'tds', 'tds',
'gst',
'received_date', 'received_date',
'created_by', 'created_by',
'is_active', 'is_active',

View File

@ -37,7 +37,7 @@ class LeadsModel extends Model
'policy_start_date', 'policy_start_date',
'policy_end_date', 'policy_end_date',
'no_of_lives', 'no_of_lives',
'claims', 'incurred_claims',
'location', 'location',
'proposed_insurer_id', 'proposed_insurer_id',
'proposed_insurer_branch_id', 'proposed_insurer_branch_id',
@ -52,6 +52,38 @@ class LeadsModel extends Model
'updated_by', 'updated_by',
'is_active', 'is_active',
'is_client_created', 'is_client_created',
'renewal_emp_count',
'renewal_dept_count',
'renewal_no_of_lives',
'incept_emp_count',
'incept_dept_count',
'incept_no_of_lives',
'exp_emp_count',
'exp_dept_count',
'exp_no_of_lives',
'file_name',
'incurred_claims_date',
'paid_claims',
'outstanding_claims',
'policy_run_days',
'premium_at_inception',
'premium_date',
'earned_premium',
'annualised_claims',
'incurred_claims_ratio',
'earned_claims_ratio',
'placement_date',
'utr_no',
'premium_amount',
'total_amount',
'cd_amount',
'total_si_at_incept',
'total_si_at_renewal',
'fin_years_claims',
]; ];

View File

@ -63,11 +63,15 @@ class PTCOShareDetailsModel extends Model
'amount', 'amount',
'stamp_duty', 'stamp_duty',
'cop_amt', 'cop_amt',
'statement_id' 'statement_id',
'follower_policy_no',
]; ];
public function getNonReconcileredPolicyTransactions(string $month,string $year,string $insurer_id,string $insurer_branch_id) public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
{ {
$currentDate = date('Y-m-d');
$sixMonthsAgo = date('Y-m-01', strtotime('-6 months'));
return $this->db->table('pt_co_share_details pt_co') return $this->db->table('pt_co_share_details pt_co')
->select(' ->select('
pt_co.id, pt_co.id,
@ -93,12 +97,15 @@ class PTCOShareDetailsModel extends Model
->join('policy_transaction pt', 'pt_co.pt_id = pt.id') ->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
->join('clients c', 'pt.client_id = c.id') ->join('clients c', 'pt.client_id = c.id')
->where('pt_co.is_active', 1) ->where('pt_co.is_active', 1)
->where('MONTH(pt.month)', $month) ->where('pt.is_active', 1)
->where('YEAR(pt.month)', $year) // ->where('MONTH(pt.month)', $month)
// ->where('YEAR(pt.month)', $year)
->where('pt_co.insurer_id', $insurer_id) ->where('pt_co.insurer_id', $insurer_id)
->where('pt_co.insurer_branch_id', $insurer_branch_id) ->where('pt_co.insurer_branch_id', $insurer_branch_id)
->where('pt_co.statement_id is null') // ->where('pt_co.statement_id is null')
->where('pt.status','completed') ->where('pt.status','completed')
->where('DATE(pt.created_at) >=', $sixMonthsAgo)
->where('DATE(pt.created_at) <=', $currentDate)
// ->where('pt_co.exp_amt', 0.00) // ->where('pt_co.exp_amt', 0.00)
// ->orWhere('pt_co.exp_amt is null') // ->orWhere('pt_co.exp_amt is null')
->get() ->get()

View File

@ -76,6 +76,7 @@ class PolicyTransactionModel extends Model
'ct_tran_id', 'ct_tran_id',
'remarks', 'remarks',
'month', 'month',
'cd_ac_pk'
]; ];
@ -113,8 +114,9 @@ class PolicyTransactionModel extends Model
return $data; return $data;
} }
// BDS Report OLD Functin for QUERY
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer) // public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0) public function getBDSReportListOld($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0)
{ {
$builder = $this->db->table('policy_transaction') $builder = $this->db->table('policy_transaction')
->select(" ->select("
@ -311,6 +313,257 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray(); return $builder->get()->getResultArray();
} }
// BDS Report NEW Functin for QUERY
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
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)
{
$date_condition = '';
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 ."'
";
}
$builder = $this->db->table('policy_transaction')
->select("
policy_transaction.*,
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
DATE_FORMAT(
IF(policy_transaction.month IS NULL,
policy_transaction.policy_issue_date,
policy_transaction.month),
'%b %Y') AS policy_issue_month,
CASE
WHEN clients.client_type = 1 THEN 'Group'
WHEN clients.client_type = 2 THEN 'Retail'
ELSE '-'
END AS client_type,
CASE
WHEN policy_transaction.revenue_type = 'NA' THEN 'Fresh'
ELSE 'Renewal'
END AS revenue_type,
CASE
WHEN policy_transaction.action_type = 'inception' THEN 'Policy'
ELSE 'Endorsement'
END AS action_type,
clients.client_name AS client_name,
clients.short_name AS client_short_name,
client_branch.branch_name AS client_branch_name,
client_branch.address1 AS client_address,
policy_type.policy_type,
policy_type.bap,
insurers.name AS insurer_name,
insurers.short_name AS insurer_short_name,
insurer_branch.branch_name AS insurer_branch_name,
insurer_branch.branch_code AS insurer_branch_code,
user_profiles.first_name as user_name,
vehicle.vehicle_no,
tpa.name as tpa_name,
pt_co_share_details.remark as remarks,
pt_co_share_details.reward,
pt_co_share_details.bp_amt,
pt_co_share_details.exp_amt,
pt_co_share_details.id as pt_id,
sales_user.first_name as salse_person_name,
service_user.first_name as service_person_name,
ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
(pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per,
pt_co_share_details.agreed_bp_per,
ROUND(
(
SELECT
(
SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tep_brokerage_amt) +
SUM(co_share_stmt_details.reward)
) AS total_irda_amt
FROM
co_share_stmt_details
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND insurer_statements.is_active = 1
$date_condition
),
2
) AS total_irda_amt,
ROUND(
(
SELECT
SUM(
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
COALESCE(co_share_stmt_details.reward, 0)
) AS total_irda_amt
FROM
co_share_stmt_details
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND pt_table.is_active = 1
AND insurer_statements.is_active = 1
AND insurer_statements.invoice_no IS NOT NULL
$date_condition
),
2
) AS billed_amt,
ROUND(
(
(
SELECT
SUM(
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.reward, 0)
)
FROM
co_share_stmt_details
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
$date_condition
)
-
(
SELECT
SUM(
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.reward, 0)
)
FROM
co_share_stmt_details
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND pt_table.is_active = 1
AND insurer_statements.is_active = 1
AND insurer_statements.invoice_no IS NULL
$date_condition
)
),
2
) AS unbilled_amt
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id')
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'policy_transaction.insurer_branch_id = insurer_branch.id', 'left')
->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
->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('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') {
$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);
}
if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
$builder->where('policy_transaction.month >=', $startDate)
->where('policy_transaction.month <=', $endDate);
}
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 ($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);
}
if ($client_policy_id != 0) {
$builder->where('policy_transaction.client_policy_id', $client_policy_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){
$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');
$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) 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)
{ {
@ -466,50 +719,74 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray(); return $builder->get()->getResultArray();
} }
public function getVarienceReportLIst($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 getVarienceReportLIst($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)
{ {
$builder = $this->db->table('policy_transaction') $builder = $this->db->table('policy_transaction')
->select(" ->select("
policy_transaction.id, policy_transaction.id,
clients.client_name, clients.client_name,
client_branch.branch_name as client_branch_name,
insurers.name AS insurer_name, insurers.name AS insurer_name,
insurer_branch.branch_name AS insurer_branch_name,
policy_type.policy_type, policy_type.policy_type,
policy_transaction.policy_no, policy_transaction.policy_no,
policy_transaction.endorsement_no, policy_transaction.endorsement_no,
CASE
WHEN policy_transaction.action_type = 'inception' THEN 'I'
ELSE 'E'
END AS action_type,
pt_co_share_details.exp_amt, pt_co_share_details.exp_amt,
pt_co_share_details.variance, pt_co_share_details.variance,
insurer_statements.invoice_amount,
insurer_statements.invoice_status,
ROUND((pt_co_share_details.actual_bp_brokerage_amt + pt_co_share_details.actual_tp_brokerage_amt + pt_co_share_details.actual_tep_brokerage_amt), 2) AS realization_amount2,
ROUND(
( (
SELECT SELECT
(SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)) AS realization_amount (
SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt)
) AS total_irda_amt
FROM FROM
inv_payment_details co_share_stmt_details
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE WHERE
inv_payment_details.statement_id = insurer_statements.id co_share_stmt_details.co_share_id = pt_co_share_details.id
AND inv_payment_details.is_active = 1 AND co_share_stmt_details.is_active = 1
),
) AS realization_amount, 2
) AS statement_amount,
ROUND(
pt_co_share_details.exp_amt -
(
SELECT
(
SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tep_brokerage_amt)
)
FROM co_share_stmt_details
JOIN insurer_statements
ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
),
2
) AS variance_amt
") ")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left') ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left') ->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
->join('inv_payment_details', 'insurer_statements.id = inv_payment_details.statement_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left') ->join('clients', 'clients.id = policy_transaction.client_id', 'left')
->join('client_branch', 'client_branch.id = policy_transaction.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('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
->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.is_active', 1)
->where('pt_co_share_details.variance IS NOT NULL') ->having('variance_amt IS NOT NULL');
->where('pt_co_share_details.variance !=', 0); // ->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) { if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
@ -543,9 +820,18 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.issuer', $issuer); $builder->where('policy_transaction.issuer', $issuer);
} }
if ($status != 0) { if ($client_branch_id != 0) {
$builder->where('policy_transaction.status', $status); $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);
}
if ($client_policy_id != 0) {
$builder->where('policy_transaction.client_policy_id', $client_policy_id);
}
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
@ -694,7 +980,7 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray(); return $builder->get()->getResultArray();
} }
public function getOutstandingReportList($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 getOutstandingReportList_OLD($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{ {
$builder = $this->db->table('policy_transaction') $builder = $this->db->table('policy_transaction')
->select(" ->select("
@ -791,5 +1077,53 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray(); return $builder->get()->getResultArray();
} }
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
{
$builder = $this->db->table('insurer_statements s')
->select('
s.id,
s.insurer_id,
s.branch_id,
ins.short_name,
ib.branch_name,
s.month,
s.line_items,
s.stmt_sno,
s.invoice_status,
s.invoice_date,
s.invoice_no,
s.invoice_amount,
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();
// 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) {
$builder->where('s.branch_id', $insurer_branch_id);
}
$builder->orderBy('s.id', 'desc');
return $builder->get()->getResultArray();
}
} }

View File

@ -60,14 +60,13 @@ class RFQModel extends Model
public function getRFQTableDataWithLeadIDAndType($lead_id, $type){ public function getRFQTableDataWithLeadIDAndType($lead_id, $type){
return $this->select(' return $this->select('
leads.client_name, leads.*,
leads.client_short_name,
insurers.name as insurer_name, insurers.name as insurer_name,
insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_name as insurer_branch_name,
tpa.name as tpa_name, tpa.name as tpa_name,
tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_name as tpa_branch_name,
policy_type.policy_type, policy_type.policy_type,
rfq.json rfq.json,
') ')
->join('leads', 'rfq.lead_id = leads.id') ->join('leads', 'rfq.lead_id = leads.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id')
@ -76,7 +75,7 @@ class RFQModel extends Model
->join('tpa', 'leads.tpa_id = tpa.id', 'left') ->join('tpa', 'leads.tpa_id = tpa.id', 'left')
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left') ->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left')
->where('rfq.lead_id', $lead_id) ->where('rfq.lead_id', $lead_id)
->where('rfq.type', $type) // ->where('rfq.type', $type)
->where('rfq.is_active', 1) ->where('rfq.is_active', 1)
->first(); ->first();

View File

@ -182,7 +182,9 @@ $(document).ready(function () {
$('#tickets-table').DataTable({ $('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" , dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + // Keep your original alignment for the search and buttons
"<'row'<'col-sm-12'tr>>" + // Table rows
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
buttons: [ buttons: [
{ {
extend: 'csv', extend: 'csv',

View File

@ -41,6 +41,7 @@
<th class="font-weight-medium">()Amount</th> <th class="font-weight-medium">()Amount</th>
<th class="font-weight-medium">User/Time</th> <th class="font-weight-medium">User/Time</th>
<th class="font-weight-medium">Status</th> <th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr> </tr>
</thead> </thead>
@ -69,77 +70,89 @@
<td class="reload"> <td class="reload">
<?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') ?> by <?php echo get_username($file['created_by']) ?> <?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') ?> by <?php echo get_username($file['created_by']) ?>
</td> </td>
<td> <td>
<?php if ($file['status'] == 'failed') { ?> <?php if ($file['status'] == 'failed') { ?>
<?php echo $file['status']; ?> <?php echo $file['status']; ?>
<a href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>" <a href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>"
class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank" class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to show the error"></a> data-toggle="tooltip" data-placement="top" title="Click to show the error"></a>
&nbsp; &nbsp;
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } else if ($file['status'] == 'partially success') { ?> <?php } else if ($file['status'] == 'partially success') { ?>
<?php echo $file['status']; ?> <?php echo $file['status']; ?>
<?php if ($file['error_data'] != 0) { ?> <?php if ($file['error_data'] != 0) { ?>
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="<?= $file['error_data'] ?>"></a> data-placement="top" title="<?= $file['error_data'] ?>"></a>
&nbsp; &nbsp;
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } ?> <?php } ?>
<?php } else if ($file['status'] == 'failed-1') { ?> <?php } else if ($file['status'] == 'failed-1') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" data-placement="top"
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the TPA ID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?> "></a> title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the TPA ID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?> "></a>
&nbsp;
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } else if ($file['status'] == 'failed-2') { ?> <?php } else if ($file['status'] == 'failed-2') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" data-placement="top"
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the UHID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?>"></a> title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the UHID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?>"></a>
&nbsp;
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } else if ($file['status'] == 'failed-3') { ?> <?php } else if ($file['status'] == 'failed-3') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" data-placement="top"
title="The Excel record count exceeds the DB record count."></a> title="The Excel record count exceeds the DB record count."></a>
&nbsp;
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } else if ($file['status'] == 'failed-4') { ?> <?php } else if ($file['status'] == 'failed-4') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="Physical File Not Found."></a> data-placement="top" title="Physical File Not Found."></a>
<?php } else if ($file['status'] == 'failed-5') { ?> <?php } else if ($file['status'] == 'failed-5') { ?>
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
data-placement="top" title="Wrong File Uploaded"></a> data-placement="top" title="Wrong File Uploaded"></a>
&nbsp;
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } else { ?> <?php } else { ?>
<?php echo $file['status']; ?>
&nbsp; <?php echo $file['status']; ?>
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>"
class="fa fa-download" style="color: #000;" aria-hidden="true" target="_blank"
data-toggle="tooltip" data-placement="top" title="Click to Download"></a>
<?php } ?> <?php } ?>
</td> </td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm"
data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<?php if (str_starts_with($file['status'], 'failed')) { ?>
<a href="#"
data-id="<?= $file['id'] ?>"
data-client_id="<?= $file['client_id'] ?>"
data-client_policy_id="<?= $file['client_policy_id'] ?>"
data-insurer_or_tpa="<?= $file['insurer_or_tpa'] ?>"
data-event_type="<?= $file['event_type'] ?>"
data-actions="<?= $file['actions'] ?>"
data-client_branch_id="<?= $file['client_branch_id'] ?>"
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')) { ?>
<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 } ?>
</div>
</div>
</td>
</tr> </tr>
<?php } <?php }
@ -153,73 +166,169 @@
</div><!-- end col --> </div><!-- end col -->
</div> </div>
</div> </div>
<script>
$(document).ready(function() {
$('#datatable-buttons').DataTable({ <!-- Center modal content for reupload file-->
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + <div class="modal fade" id="batch_file_upload_modal" tabindex="-1" role="dialog" aria-hidden="true">
"<'row'<'col-sm-12'tr>>" + <div class="modal-dialog modal-dialog-centered">
"<'row'<'col-sm-5'i><'col-sm-7'p>>", <div class="modal-content">
buttons: [{ <div class="modal-header">
extend: 'csv', <h4 class="modal-title" id="myCenterModalLabel">Re-Upload the file</h4>
text: 'CSV', <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
title: 'Batch List', </div>
className: 'my_class', <div class="modal-body">
}], <form class="parsley-examples" id="re_upload_import_export_excel_form" action="<?php echo base_url() . 'util/import-export' ?>" method="post" enctype="multipart/form-data">
initComplete: function(settings, json) { <input type="hidden" id="batch_file_client_id" name="client_id">
$('.my_class').css({ <input type="hidden" id="batch_file_policy_id" name="client_policy_id">
position: "relative", <input type="hidden" id="batch_file_branch_id" name="client_branch_id">
left: "50px" <input type="hidden" id="batch_file_insurer_or_tpa" name="insurer_or_tpa">
}); <input type="hidden" id="batch_file_action_type" name="action_type">
}, <input type="hidden" id="batch_file_event_type" name="event_type">
language: { <input type="file" id="import_file_data" name="import_file_data" required
search: "_INPUT_", accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
searchPlaceholder: "Search..."
}, <button type="submit" class="btn btn-primary">Upload</button>
paging: true
}); </form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$(document).ready(function() {
$('#datatable-buttons').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'Batch List',
className: 'my_class',
}],
initComplete: function(settings, json) {
$('.my_class').css({
position: "relative",
left: "50px"
});
},
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true
}); });
</script>
<script>
// Function to format a number in Indian Rupees format
function formatNumberInIndianRupees(number) {
const maxLength = 16; });
let value = number.toString().replace(/\D/g, ''); // Remove non-numeric characters
// Limit the number of digits // Function to format a number in Indian Rupees format
value = value.slice(0, maxLength); function formatNumberInIndianRupees(number) {
// Format the number with commas using Indian numbering system const maxLength = 16;
const formattedNumber = Number(value).toLocaleString('en-IN'); let value = number.toString().replace(/\D/g, ''); // Remove non-numeric characters
return formattedNumber; // Limit the number of digits
} value = value.slice(0, maxLength);
// Function to format numbers based on a class // Format the number with commas using Indian numbering system
function formatNumbersByClass(className) { const formattedNumber = Number(value).toLocaleString('en-IN');
const elements = document.querySelectorAll(`.${className}`);
console.log('element', elements)
elements.forEach(element => {
const number = parseFloat(element.innerText.replace(/,/g, ''));
console.log('number', number)
if (!isNaN(number)) { return formattedNumber;
console.log(formatNumberInIndianRupees(number)) }
element.innerText = formatNumberInIndianRupees(number);
}
});
}
// Format numbers when the DOM content is loaded // Function to format numbers based on a class
document.addEventListener("DOMContentLoaded", function() { function formatNumbersByClass(className) {
setTimeout(() => { const elements = document.querySelectorAll(`.${className}`);
console.log('element', elements)
elements.forEach(element => {
const number = parseFloat(element.innerText.replace(/,/g, ''));
console.log('number', number)
formatNumbersByClass('indian-number'); if (!isNaN(number)) {
console.log(formatNumberInIndianRupees(number))
}, 500); element.innerText = formatNumberInIndianRupees(number);
}
}); });
</script> }
// Format numbers when the DOM content is loaded
document.addEventListener("DOMContentLoaded", function() {
setTimeout(() => {
formatNumbersByClass('indian-number');
}, 500);
});
function getBatchFileData(input){
let client_id = $(input).data('client_id')
let client_policy_id = $(input).data('client_policy_id')
let client_branch_id = $(input).data('client_branch_id')
let insurer_or_tpa = $(input).data('insurer_or_tpa')
let event_type = $(input).data('event_type')
let actions = $(input).data('actions')
console.log('client_id', client_id);
console.log('client_policy_id', client_policy_id);
console.log('client_branch_id', client_branch_id);
console.log('insurer_or_tpa', insurer_or_tpa);
console.log('event_type', event_type);
console.log('actions', actions);
$('#batch_file_client_id').val(client_id);
$('#batch_file_policy_id').val(client_policy_id);
$('#batch_file_branch_id').val(client_branch_id);
$('#batch_file_insurer_or_tpa').val(insurer_or_tpa);
$('#batch_file_action_type').val(actions);
$('#batch_file_event_type').val(event_type);
var myModal = new bootstrap.Modal(document.getElementById('batch_file_upload_modal'));
myModal.show();
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// console.log('file_id', file_id);
// let url = '<?= base_url('util/getBatchFileData') ?>';
// // Data to send in the AJAX request
// let requestData = {
// file_id: file_id,
// };
// // Send AJAX request
// sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
// console.log('Data fetched successfully:', response);
// console.log('Data fetched successfully:', response.batch_file_data);
// console.log('response.batch_file_data.client_branch_id:', response.batch_file_data.client_branch_id);
// if (response.status == true) {
// } else {
// toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
// }
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, function(xhr, status, error) {
// console.error('Error fetching data:', error);
// console.error(xhr.responseText);
// toastr.error('An error occurred while checking the SI amount.', 'ERROR');
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// // addRow();
// });
}
</script>

View File

@ -16,6 +16,32 @@ table.dataTable tbody td {
.dataTables_filter { .dataTables_filter {
position: absolute; position: absolute;
} }
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style> </style>
<div class="row"> <div class="row">
@ -209,6 +235,97 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("scroll-horizontal-datatable");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Append the custom dropdown to the body
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
// Datatable document ready // Datatable document ready
$(document).ready(function() { $(document).ready(function() {

View File

@ -16,6 +16,32 @@ table.dataTable thead th {
max-width: 98% !important; max-width: 98% !important;
} }
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style> </style>
<div class="row" id="client_list"> <div class="row" id="client_list">
@ -57,28 +83,18 @@ table.dataTable thead th {
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by <td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by
<?php echo $row['user_name']; ?></td> <?php echo $row['user_name']; ?></td>
<td> <td>
<?php if($row['cd_ac_no_count'] > 0 && $row['cd_ac_no_count_cd_tranction'] > 1) {?> <div class="btn-group dropdown">
<div class="btn-group dropdown"> <a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<!-- <a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm"aria-expanded="false"></i></a> --> <div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php if($row['cd_ac_no_count'] == 0) { ?>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div> </div>
<?php } else { ?> </div>
<div class="btn-group dropdown">
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<?php if($row['cd_ac_no_count_cd_tranction'] <= 1) { ?>
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php } ?>
<?php if($row['cd_ac_no_count'] == 0) { ?>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
</div>
<?php } ?>
</td> </td>
<?php } ?>
</tr> </tr>
<?php } ?>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -168,9 +184,103 @@ table.dataTable thead th {
</div> </div>
</div> </div>
</div><!-- /.modal --> </div><!-- /.modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
row.customDropdown = customDropdown;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the last column (action column)
if (event.target.closest('td') === row.lastElementChild) {
return;
}
// Hide any active dropdown
if (activeDropdown && activeDropdown !== customDropdown) {
activeDropdown.style.display = 'none';
}
// Toggle the dropdown display
const isActive = customDropdown.style.display === 'block';
customDropdown.style.display = isActive ? 'none' : 'block';
// Set the position of the dropdown
const rect = event.target.closest('td').getBoundingClientRect();
customDropdown.style.position = 'absolute';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = isActive ? null : customDropdown;
event.stopPropagation();
});
// Preserve click handlers for modal actions
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const isModalAction = this.hasAttribute('data-toggle') && this.getAttribute('data-toggle') === 'modal';
if (isModalAction) {
return; // Allow modal to function normally
}
// Close the dropdown if it's not related to modal
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#tickets-table').DataTable({ $('#tickets-table').DataTable({
@ -195,7 +305,6 @@ table.dataTable thead th {
}) })
$(document).ready(function(){ $(document).ready(function(){
<?php if (session()->has('error')) : ?> <?php if (session()->has('error')) : ?>
@ -217,7 +326,6 @@ table.dataTable thead th {
}) })
$('#btnAdd').click(function(){ $('#btnAdd').click(function(){
$('#client_id').val(''); $('#client_id').val('');
$('#insurer_id').val(''); $('#insurer_id').val('');
@ -231,7 +339,6 @@ table.dataTable thead th {
}) })
$('.close').click(function(){ $('.close').click(function(){
$('#CD_Master_ID').val(''); $('#CD_Master_ID').val('');
$('#client_id').val('').change(); $('#client_id').val('').change();
@ -244,10 +351,10 @@ table.dataTable thead th {
$('#client_id').prop("disabled", false); $('#client_id').prop("disabled", false);
$('#insurer_id').prop("disabled", false); $('#insurer_id').prop("disabled", false);
$('#cd_ac_no').prop("disabled", false); $('#cd_ac_no').prop("disabled", false);
$('#opening_bal').prop("disabled", false)
}) })
$('body').on('click', '.btnEdit', function () { $('body').on('click', '.btnEdit', function () {
var cd_id = $(this).attr('data-id'); var cd_id = $(this).attr('data-id');
@ -270,8 +377,13 @@ table.dataTable thead th {
$('#insurer_id').prop("disabled", true); $('#insurer_id').prop("disabled", true);
$('#opening_date').val(res.data.opening_date); $('#opening_date').val(res.data.opening_date);
$('#cd_ac_no').val(res.data.cd_ac_no); $('#cd_ac_no').val(res.data.cd_ac_no);
$('#cd_ac_no').prop("disabled", true); //$('#cd_ac_no').prop("disabled", true);
$('#opening_bal').val(res.data.opening_bal); $('#opening_bal').val(res.data.opening_bal);
if(res.cd_transaction_count <= 1){
$('#opening_bal').prop("disabled", false)
}else{
$('#opening_bal').prop("disabled", true)
}
$('#btnSubmit').html('Update'); $('#btnSubmit').html('Update');
}, },
@ -282,7 +394,6 @@ table.dataTable thead th {
}); });
}); });
$('#cd_ac_no').change(function(){ $('#cd_ac_no').change(function(){
var cd_ac_no = $(this).val(); var cd_ac_no = $(this).val();
@ -311,57 +422,55 @@ table.dataTable thead th {
}) })
function removeCDMaster(element) {
function removeCDMaster(element) { Swal.fire({
title: "Are you sure?",
text: "You need to remove this CD.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
Swal.fire({ if (result.isConfirmed) {
title: "Are you sure?", var id = element.getAttribute('data-id');
text: "You need to remove this CD.", var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
icon: "info", $.ajax({
showCancelButton: true, url: form_action,
confirmButtonColor: "#3085d6", type: "GET",
confirmButtonText: "Yes", dataType: 'json',
}).then((result) => { processData: false,
contentType: false,
if (result.isConfirmed) { success: function(res) {
var id = element.getAttribute('data-id'); // console.log(res.status == true);
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id; if(res){
$.ajax({ if (res.status == true) {
url: form_action, toastr.success('CD removed successfully.', 'success');
type: "GET", location.reload();
dataType: 'json', } else {
processData: false, toastr.warning('Failed to remove CD.', 'warning');
contentType: false, }
success: function(res) { }
// console.log(res.status == true); },
if(res){ error: function (xhr, status, error) {
if (res.status == true) { console.error(xhr.responseText);
toastr.success('CD removed successfully.', 'success'); console.error(status, error);
location.reload(); $('.loader').fadeOut();
} else { $('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove CD.', 'warning'); console.log('Something Wrong!', 'warning');
} }
} });
}, }
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
}); });
} }
function onlyNumbers(event) {
function onlyNumbers(event) { var charcode;
var charcode; charcode = event.which || event.keyCode;
charcode = event.which || event.keyCode; if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true; return false;
return false; }
}
</script> </script>

View File

@ -33,7 +33,7 @@
<?php foreach ($clientData as $value): ?> <?php foreach ($clientData as $value): ?>
<td><?php echo $value->insurer_name;?></td> <td><?php echo $value->insurer_name;?></td>
<td><?php echo $value->cd_ac_no;?></td> <td><?php echo $value->cd_master_account_no;?></td>
<td> <td>
<?php <?php

View File

@ -16,6 +16,33 @@ table.dataTable thead th {
max-width: 98% !important; max-width: 98% !important;
} }
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style> </style>
<div class="row" id="client_list"> <div class="row" id="client_list">
@ -114,6 +141,123 @@ table.dataTable thead th {
</div> </div>
</div><!-- /.modal --> </div><!-- /.modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
// Add 'Open Client Details' option in the dropdown
const clientId = row.querySelector('.client_info').dataset.id;
const openDetailsOption = document.createElement('a');
openDetailsOption.href = "javascript:void(0);";
openDetailsOption.className = 'dropdown-item';
openDetailsOption.innerHTML = `<i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Open Client Details`;
openDetailsOption.addEventListener('click', function() {
openClientDetailsPage(clientId); // Open the client details page when clicked
});
customDropdown.appendChild(openDetailsOption);
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Show the action dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
const rect = event.target.getBoundingClientRect();
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // 5px gap
activeDropdown = customDropdown;
event.stopPropagation();
});
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
// Open client details page
function openClientDetailsPage(clientId) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: "<?= base_url('util/get-client-details/') ?>" + clientId,
type: "GET",
dataType: 'json',
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#append_client_info').empty().append(res.data);
$('#client_info').show();
$('#client_list').hide();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
});
</script>
<script> <script>

View File

@ -88,10 +88,16 @@ body {
<span class="d-none d-sm-inline-block">Policies</span> <span class="d-none d-sm-inline-block">Policies</span>
</a> </a>
</li> </li>
<li class="nav-item">
<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>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<?php include('client_others_tab.php'); ?>
<?php include('notification.php'); ?> <?php include('notification.php'); ?>
<?php include('client_basic_info.php'); ?> <?php include('client_basic_info.php'); ?>
<?php include('client_kyc.php'); ?> <?php include('client_kyc.php'); ?>
<?php include('client_rm.php'); ?> <?php include('client_rm.php'); ?>

View File

@ -0,0 +1,81 @@
<div class="tab-pane fade" id="others-tab">
<div class="row">
<div class="col-12">
<div class="card-body">
<form role="form" class="parsley-examples" method="post" id="others_form" enctype="multipart/form-data">
<input type="hidden" name="client_id" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="addon_subheading">Addon Sub-Heading</label>
<textarea class="form-control" id="addon_subheading" name="addon_subheading" rows="1" placeholder="Enter Text"><?= isset($client['addon_subheading']) ? $client['addon_subheading'] : '' ?></textarea>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary" id="others_form_submit">Submit</button>
</div>
</form>
</div>
</div> <!-- end col-->
</div>
<!-- end row -->
</div>
<!-- end -->
<script>
$(document).ready(function() {
//for Client Others Form Submit using AJAX
$("#others_form").submit(function(event) {
event.preventDefault();
var isValid = $('#others_form').parsley().validate();
if (!isValid) {
return;
}
if (isValid) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("client/others/create"); ?>';
var formData = new FormData($('#others_form')[0]);
$.ajax({
data: formData,
url: form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (res.status == true) {
toastr.success(res.message, 'SUCCESS');
} else {
toastr.warning(res.message, 'WARNING');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
});
});
</script>

View File

@ -37,12 +37,14 @@
<hr> <hr>
<form role="form" class="parsley-examples" method="post" id="policy_form" enctype="multipart/form-data"> <form role="form" class="parsley-examples" method="post" id="policy_form" enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" /> <input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" /> <input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
<input type="hidden" id="policy_form_action" /> <input type="hidden" id="policy_form_action" />
<input type="hidden" name="policy_type_id" id="policy_type_id" /> <input type="hidden" name="policy_type_id" id="policy_type_id" />
<input type="hidden" id="insurer_policy_id" /> <input type="hidden" id="insurer_policy_id" />
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" /> <input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
@ -56,7 +58,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="email"> Policy Type<span class="text-danger">*</span></label> <label for="policy_type"> Policy Type<span class="text-danger">*</span></label>
<select class="form-control" id="policy_type" name="policy_type_id" required> <select class="form-control" id="policy_type" name="policy_type_id" required>
<option value="0">Select Policy Type</option> <option value="0">Select Policy Type</option>
<?php foreach ($policy_types as $value) { ?> <?php foreach ($policy_types as $value) { ?>
@ -66,7 +68,7 @@
</div> </div>
<div class="form-group col-md-4" id="base_policy_id" style="display: none;"> <div class="form-group col-md-4" id="base_policy_id" style="display: none;">
<label for="addon_policy">Base Policy<span id="base_danger" class="text-danger">*</span></label> <label for="base_policy">Base Policy<span id="base_danger" class="text-danger">*</span></label>
<select class="form-control" id="base_policy" name="base_policy"> <select class="form-control" id="base_policy" name="base_policy">
<option value="" selected>Select Base Policy</option> <option value="" selected>Select Base Policy</option>
</select> </select>
@ -77,7 +79,7 @@
<div class="form-row" id="first" style="display: none;"> <div class="form-row" id="first" style="display: none;">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="email">Insurer<span class="text-danger">*</span></label> <label for="insurer">Insurer<span class="text-danger">*</span></label>
<select class="form-control" id="insurer" name="insurer" required> <select class="form-control" id="insurer" name="insurer" required>
<option value="">Select Insurer</option> <option value="">Select Insurer</option>
<?php foreach ($insurer as $value) { ?> <?php foreach ($insurer as $value) { ?>
@ -88,7 +90,7 @@
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="mobile">TPA<span id="tpa_danger" class="text-danger">*</span></label> <label for="tpa">TPA<span id="tpa_danger" class="text-danger">*</span></label>
<select class="form-control" id="tpa" name="tpa" required> <select class="form-control" id="tpa" name="tpa" required>
<option value="">Select TPA</option> <option value="">Select TPA</option>
<?php foreach ($tpa as $value) { ?> <?php foreach ($tpa as $value) { ?>
@ -123,14 +125,14 @@
<div class="form-row" id="third" style="display: none; position: relative;top: 22px;"> <div class="form-row" id="third" style="display: none; position: relative;top: 22px;">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="mobile">CD Account Number<span id="tpa_danger" class="text-danger">*</span></label> <label for="cd_ac_no">CD Account Number<span id="tpa_danger" class="text-danger">*</span></label>
<select class="form-control" id="cd_ac_no" name="cd_ac_no" required> <select class="form-control" id="cd_ac_no" name="cd_ac_no" required>
<option value="">Select CD Account Number</option> <option value="">Select CD Account Number</option>
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="mobile">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label> <label for="gst_no">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required> <input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required>
</div> </div>
@ -156,22 +158,31 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label> <label for="reminder_date">Reminder Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Reminder Date " name="reminder_date" id="reminder_date" > <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">
<label for="disclaimer">Disclaimer<span class="text-danger">*</span></label> <label for="disclaimer">Disclaimer<span class="text-danger">*</span></label>
<textarea class="form-control" placeholder="Enter Disclaimer" name="disclaimer" id="disclaimer" ></textarea> <textarea class="form-control" placeholder="Enter Disclaimer" name="disclaimer" id="disclaimer" ></textarea>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label class="switch" style="position: relative;top: 43px;left: 20px;"> <label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="policy_visibility" type="checkbox" name="enrolment_visibility" checked> <input id="policy_visibility" type="checkbox" name="enrolment_visibility" checked>
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="inception_type" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty</label> <label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty in Enrollment App</label>
</div> </div>
<!-- <div class="form-group col-md-4">
<label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="is_member_modify_allowed" type="checkbox" name="is_member_modify_allowed" checked>
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="is_member_modify_allowed" style="position: relative;bottom: 5px;left: 85px;"> In Enrollment Member Data Modification Allowed</label>
</div> -->
</div> </div>
<div id="policy_fields"></div> <div id="policy_fields"></div>
@ -182,7 +193,9 @@
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button> <button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack" id="btnBack">Cancel</button> <button type="button" class="btn btn-secondary waves-effect btnBack" id="btnBack">Cancel</button>
</div> </div>
</form> </form>
</div> </div>
</div> <!-- end col--> </div> <!-- end col-->
</div> </div>
@ -244,7 +257,6 @@
} }
}) })
var policy_PrimaryKey = $('#client_id_policy').val(); var policy_PrimaryKey = $('#client_id_policy').val();
var policy_client = $('#policy_PrimaryKey').val(); var policy_client = $('#policy_PrimaryKey').val();
@ -301,11 +313,11 @@
allowInput: false allowInput: false
}); });
var reminderDatePicker = flatpickr("#reminder_date", { // var reminderDatePicker = flatpickr("#reminder_date", {
dateFormat: "d-m-Y", // dateFormat: "d-m-Y",
defaultDate: today, // defaultDate: today,
allowInput: false // allowInput: false
}); // });
$('#add_form').hide(); $('#add_form').hide();
@ -521,7 +533,7 @@
var formData = new FormData($('#policy_form')[0]); var formData = new FormData($('#policy_form')[0]);
var policy_form_action = $('#policy_form_action').val(); var policy_form_action = $('#policy_form_action').val();
console.log(formData+'form data');
$.ajax({ $.ajax({
data: formData, data: formData,
url: policy_form_action, url: policy_form_action,
@ -690,8 +702,8 @@
$.get(url_for_cd, function(response){ $.get(url_for_cd, function(response){
//console.log(response) // console.log(response)
//console.log(response.data) // console.log(response.data)
if(response.status == false && response.insurer_id != 'undefined'){ if(response.status == false && response.insurer_id != 'undefined'){
toastr.warning('The CD Account Number not found.', 'Warning'); toastr.warning('The CD Account Number not found.', 'Warning');
@ -784,13 +796,14 @@
$('#open_date').val(rearrangeDateFormat(res.data.open_date)); $('#open_date').val(rearrangeDateFormat(res.data.open_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
$('#close_date').val(rearrangeDateFormat(res.data.close_date)); $('#close_date').val(rearrangeDateFormat(res.data.close_date));
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date)); $('#reminder_date').val(res.data.reminder_date);
$('#disclaimer').val(res.data.disclaimer); $('#disclaimer').val(res.data.disclaimer);
$('#gst_no').val(gst); $('#gst_no').val(gst);
$('#policy_status').val(checkDateStatus(res.data.policy_end_date)); $('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status_field').show(); $('#policy_status_field').show();
//Open for enrollment yes or no
if (res.data.inception_type == 2) { if (res.data.inception_type == 2) {
$('#inception_type').prop('checked', true); $('#inception_type').prop('checked', true);
$('#open_date').parent().show(); $('#open_date').parent().show();
@ -805,13 +818,20 @@
$('.dateofdata').attr('required', false); $('.dateofdata').attr('required', false);
} }
//Policy Visibility in Web App
if (res.data.enrolment_visibility == 1) { if (res.data.enrolment_visibility == 1) {
$('#policy_visibility').prop('checked', true); $('#policy_visibility').prop('checked', true);
} else { } else {
$('#policy_visibility').prop('checked', false); $('#policy_visibility').prop('checked', false);
} }
// Member Modify Data Enable or Disable
// if (res.data.is_member_modify_allowed == 1) {
// $('#is_member_modify_allowed').prop('checked', true);
// } else {
// $('#is_member_modify_allowed').prop('checked', false);
// }
// if (res.data.is_addon != '1' && res.data.is_addon != '0') { // if (res.data.is_addon != '1' && res.data.is_addon != '0') {
// $('#base_policy_id').show(); // $('#base_policy_id').show();
@ -874,14 +894,14 @@
if (res.data.is_addon == 2 || res.data.is_addon == 3) { if (res.data.is_addon == 2 || res.data.is_addon == 3) {
$("#insurer").next(".select2-container").css({ $("#insurer").next(".select2-container").css({
'pointer-events': 'none', 'pointer-events': 'auto',
}); });
$('#select2-insurer-container').css({ $('#select2-insurer-container').css({
'background-color': '#ebebe0', 'background-color': '#ebebe0',
}); });
$("#tpa").next(".select2-container").css({ $("#tpa").next(".select2-container").css({
'pointer-events': 'none', 'pointer-events': 'auto',
}); });
$('#select2-tpa-container').css({ $('#select2-tpa-container').css({
'background-color': '#ebebe0', 'background-color': '#ebebe0',
@ -1178,7 +1198,9 @@
} else if (input) { } else if (input) {
// console.log( 'input type step 2', typeof input); // console.log( 'input type step 2', typeof input);
// Handle the case where input is a string // Handle the case where input is a string
number = parseFloat(input.replace(/,/g, ''), 10); // number = parseFloat(input.replace(/,/g, ''), 10);
number = parseFloat(String(input).replace(/,/g, ''), 10);
} else { } else {
// Handle the case where input is undefined or null // Handle the case where input is undefined or null
number = NaN; // or handle as needed number = NaN; // or handle as needed
@ -1334,7 +1356,7 @@
if ($(this).val() == 4 || $(this).val() == 5) { if ($(this).val() == 4 || $(this).val() == 5) {
$("#insurer").next(".select2-container").css({ $("#insurer").next(".select2-container").css({
'pointer-events': 'none', 'pointer-events': 'auto',
}); });
$('#select2-insurer-container').css({ $('#select2-insurer-container').css({
@ -1342,7 +1364,7 @@
}); });
$("#tpa").next(".select2-container").css({ $("#tpa").next(".select2-container").css({
'pointer-events': 'none', 'pointer-events': 'auto',
}); });
$('#select2-tpa-container').css({ $('#select2-tpa-container').css({
@ -1627,7 +1649,7 @@
$.each(data, function(index, item) { $.each(data, function(index, item) {
const option = $('<option>', { const option = $('<option>', {
value: item.cd_ac_no, value: item.id,
text: item.cd_ac_no text: item.cd_ac_no
}); });
@ -1905,14 +1927,14 @@
if (res.data.is_addon == 2 || res.data.is_addon == 3) { if (res.data.is_addon == 2 || res.data.is_addon == 3) {
$("#insurer").next(".select2-container").css({ $("#insurer").next(".select2-container").css({
'pointer-events': 'none', 'pointer-events': 'auto',
}); });
$('#select2-insurer-container').css({ $('#select2-insurer-container').css({
'background-color': '#ebebe0', 'background-color': '#ebebe0',
}); });
$("#tpa").next(".select2-container").css({ $("#tpa").next(".select2-container").css({
'pointer-events': 'none', 'pointer-events': 'auto',
}); });
$('#select2-tpa-container').css({ $('#select2-tpa-container').css({
'background-color': '#ebebe0', 'background-color': '#ebebe0',

View File

@ -38,6 +38,12 @@
text-align: right; text-align: right;
} }
.readonly-select {
pointer-events: none;
background-color: #f0f0f0;
color: #666;
}
</style> </style>
<?php $pro_rata_total = 0; $gst_total = 0 ?> <?php $pro_rata_total = 0; $gst_total = 0 ?>
@ -141,15 +147,21 @@
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a> <a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right"> <div class="dropdown-menu dropdown-menu-right">
<?php if(($employee['emp_status'] == 'draft' || $employee['emp_status'] == 'enrolled') && ($employee['status'] == 'draft' || $employee['status'] == 'enrolled')) { ?> <?php
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_id'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a> if (
(in_array($employee['emp_status'], ['draft', 'enrolled']) && in_array($employee['status'], ['draft', 'enrolled'])) ||
($employee['status'] == 'active' && $employee['emp_status'] == 'active' && (empty($employee['email_corporate']) || empty($employee['mobile'])))
) {
?>
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_id'];?>', '<?= $employee['status'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php } ?> <?php } ?>
<?php if($employee['policy_type'] == 'GMC' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?> <?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a> <a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
<?php } ?> <?php } ?>
<?php if($employee['policy_type'] == 'GMC' && $employee['relationship'] == 'Self' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?> <?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
<a class="dropdown-item" onclick="send_mail_for_individual_employee_ecard('<?= $employee['id'];?>')" ><i class="mdi mdi-email-alert mr-2 text-muted font-18 vertical-middle"></i>Send E-Card Mail</a> <a class="dropdown-item" onclick="send_mail_for_individual_employee_ecard('<?= $employee['id'];?>')" ><i class="mdi mdi-email-alert mr-2 text-muted font-18 vertical-middle"></i>Send E-Card Mail</a>
<?php } ?> <?php } ?>
@ -217,7 +229,7 @@
<div class="form-group col-md-8"> <div class="form-group col-md-8">
<label for="name">Name<span class="text-danger">*</span></label> <label for="name">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="name" placeholder="Ente Name" readonly> <input type="text" class="form-control" name="name" id="name" placeholder="Ente Name">
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
@ -238,12 +250,12 @@
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="email">Email<span class="text-danger">*</span></label> <label for="email">Email<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" required> <input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" onchange="validateInput(this, 'employees', 'email_corporate')" required>
</div> </div>
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="mobile">Mobile Number<span class="text-danger">*</span></label> <label for="mobile">Mobile Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" required> <input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" onchange="validateInput(this, 'employees', 'mobile')" required>
</div> </div>
</div> </div>
@ -264,7 +276,7 @@
$(document).ready(function(){ $(document).ready(function(){
var dob = flatpickr("#dob", { var dob = flatpickr("#dob", {
dateFormat: "d/m/Y", dateFormat: "d/M/Y",
allowInput: false allowInput: false
}); });
}) })
@ -339,10 +351,21 @@
$('#email_corporate').val(data.email_corporate); $('#email_corporate').val(data.email_corporate);
$('#mobile').val(data.mobile); $('#mobile').val(data.mobile);
if(data.emp_status == "active"){
$('#name').prop('disabled', true);
$('#gender').prop('disabled', true);
$('#dob').prop('disabled', true);
}else{
$('#name').prop('disabled', false);
$('#gender').prop('disabled', false);
$('#dob').prop('disabled', false);
}
var myModal = new bootstrap.Modal(document.getElementById('emp_modal')); var myModal = new bootstrap.Modal(document.getElementById('emp_modal'));
myModal.show(); myModal.show();
}else{ }else{
$('#employee_primary_id').val(''); $('#employee_primary_id').val('');
$('#emp_code_for_edit').val(''); $('#emp_code_for_edit').val('');
$('#name').val(''); $('#name').val('');
@ -351,6 +374,10 @@
$('#email_corporate').val(''); $('#email_corporate').val('');
$('#mobile').val(''); $('#mobile').val('');
$('#name').prop('disabled', false);
$('#gender').prop('disabled', false);
$('#dob').prop('disabled', false);
toastr.warning(res.message, 'WARNING'); toastr.warning(res.message, 'WARNING');
} }
}, },
@ -489,4 +516,23 @@
}); });
} }
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('')
}
});
}
</script> </script>

View File

@ -18,6 +18,33 @@ table.dataTable tbody td {
color: white !important; color: white !important;
margin-right: 5px; margin-right: 5px;
} }
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style> </style>
<div class="row"> <div class="row">
@ -64,7 +91,7 @@ table.dataTable tbody td {
<?php foreach($status as $key => $value) { ?> <?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>" <option value="<?= $key ?>"
<?php <?php
if ((!isset($getData) || count($getData['status']) > 0) && $key == 'active') { if ((!isset($getData) || in_array('active', $getData['status'])) && $key == 'active') {
echo 'selected'; echo 'selected';
} }
?>> ?>>
@ -113,7 +140,94 @@ table.dataTable tbody td {
<!-- end row --> <!-- end row -->
<div id="loader" class="loader" style="display:none;">SPINNER</div> <div id="loader" class="loader" style="display:none;">SPINNER</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {

View File

@ -17,7 +17,7 @@
/* background-color: #eb7a76; */ /* background-color: #eb7a76; */
background-color: darkgrey; background-color: darkgrey;
/* padding-bottom: 1px; */ /* padding-bottom: 1px; */
padding-top: 10px; /* padding-top: 10px; */
} }
#tickets-table_filter { #tickets-table_filter {
@ -59,24 +59,31 @@
</div> </div>
<div class="col-3"> <div class="col-3">
<div id="categoryFilter_11"> <div id="categoryFilter_11">
<select name="branch_id" class="form-control" id="branch_id"> <select name="branch_id" class="form-control" id="branch_id" onchange="populatePolicies()">
<option value="0">Select Branch</option> <option value="0">Select Branch</option>
</select> </select>
</div> </div>
</div> </div>
<div class="col-3">
<div id="categoryFilter_14">
<select name="client_policy_id" class="form-control" id="client_policy_id">
<option value="0">Select Policy</option>
</select>
</div>
</div>
<div class="col-1"> <div class="col-1">
<div id="categoryFilter_11"> <div id="categoryFilter_11">
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);"><i class="fa fa-search" aria-hidden="true"></i></a> <a class="btn btn-primary waves-effect waves-light" onclick="fetchEmpolyeeList(event);" data-toggle="tooltip" data-placement="top" title="Search" id="get-emp-list"><i class="fa fa-search" aria-hidden="true"></i></a>
</div> </div>
</div> </div>
<div class="col-2"> <div class="col-0" style="margin-right: 15px; ">
<div id="categoryFilter_12"> <div id="categoryFilter_12">
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="sendManualReminder(this)">Send Reminder</a> <a class="btn btn-primary waves-effect waves-light" onclick="sendManualReminder(this)" data-toggle="tooltip" data-placement="top" title="Send Reminder"><i class="fa fa-bell" aria-hidden="true"></i></a>
</div> </div>
</div> </div>
<div class="col-1"> <div class="col-0">
<div id="categoryFilter_13"> <div id="categoryFilter_13">
<a class="btn btn-primary waves-effect waves-light" onclick="uploadEnrollmentFile(this)" ><i class="fas fa-file-upload" ></i></a> <a class="btn btn-primary waves-effect waves-light" onclick="uploadEnrollmentFile(this)" data-toggle="tooltip" data-placement="top" title="Enrollment File Upload"><i class="fas fa-file-upload" ></i></a>
</div> </div>
</div> </div>
@ -84,7 +91,7 @@
<!-- <div class="row" style="margin-bottom: 44px;"> --> <!-- <div class="row" style="margin-bottom: 44px;"> -->
<div class="col-1 text-right view-status-btn" style="position: relative;bottom: 7px;"> <div class="col-1 text-right view-status-btn" style="position: relative;bottom: 7px;">
<button type="button" class="btn btn-link visa_status_button" onclick="toggleContent()" style="color: #000;"> <button type="button" class="btn btn-link visa_status_button" onclick="toggleContent()" style="color: #000;" data-toggle="tooltip" data-placement="top" title="View Status Card">
Status <i id="toggleIcon" class="fas fa-minus"></i> Status <i id="toggleIcon" class="fas fa-minus"></i>
</button> </button>
</div> </div>
@ -180,6 +187,7 @@
<th class="font-weight-medium">SNO</th> <th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Name</th> <th class="font-weight-medium">Name</th>
<th class="font-weight-medium">Emp Code</th> <th class="font-weight-medium">Emp Code</th>
<th class="font-weight-medium">Relationship</th>
<th class="font-weight-medium">Enroled</th> <th class="font-weight-medium">Enroled</th>
<th class="font-weight-medium">Logged-In</th> <th class="font-weight-medium">Logged-In</th>
</tr> </tr>
@ -233,6 +241,7 @@
</div><!-- /.modal --> </div><!-- /.modal -->
<script> <script>
function populateBranches() function populateBranches()
{ {
var clientId = document.getElementById('clients').value; var clientId = document.getElementById('clients').value;
@ -256,6 +265,38 @@
}); });
} }
function populatePolicies()
{
console.log('populatePolicies function called');
var clientId = document.getElementById('clients').value;
var branchId = document.getElementById('branch_id').value;
var policyDropdown = document.getElementById('client_policy_id');
console.log('clientId', clientId);
console.log('branchId', branchId);
console.log('policyDropdown', policyDropdown);
policyDropdown.innerHTML = '<option value="0">Select Policy</option>';
if (clientId == 0 && branchId == 0) {
return;
}
var policies = <?= json_encode($policy_list) ?>;
console.log('policies', policies);
policies.forEach(policy => {
if (policy.client_id == clientId && policy.client_branch_id == branchId) {
var option = document.createElement('option');
option.value = policy.id;
option.textContent = policy.policy_type + ' - ' + policy.policy_no;
policyDropdown.appendChild(option);
}
});
}
function filterTable(columnIndex, filterValue) function filterTable(columnIndex, filterValue)
{ {
var table = $('#tickets-table').DataTable(); var table = $('#tickets-table').DataTable();
@ -336,6 +377,7 @@
index + 1, index + 1,
employee.employee_name, employee.employee_name,
employee.emp_code, employee.emp_code,
employee.relationship,
enrolled, enrolled,
loggedIn loggedIn
]); ]);
@ -406,6 +448,7 @@
$('#clients').select2(); $('#clients').select2();
$('#policy_id').select2(); $('#policy_id').select2();
$('#branch_id').select2(); $('#branch_id').select2();
$('#client_policy_id').select2();
var table = $('#tickets-table').DataTable({ var table = $('#tickets-table').DataTable({
dom: 'fBrtip', dom: 'fBrtip',
buttons: [ buttons: [
@ -702,20 +745,38 @@
var client_id = $('#clients').val() var client_id = $('#clients').val()
var client_branch_id = $('#branch_id').val() var client_branch_id = $('#branch_id').val()
var client_policy_id = $('#client_policy_id').val()
console.log('input', input); console.log('input', input);
console.log('client_id', client_id); console.log('client_id', client_id);
console.log('client_branch_id', client_branch_id); console.log('client_branch_id', client_branch_id);
console.log('client_policy_id', client_policy_id);
if(client_id == 0 && client_branch_id == 0) if (client_id == 0) {
{
Swal.fire({ Swal.fire({
title: "warning!", title: "Warning!",
text: 'Please select the Client and Client Branch.', text: 'Please select the Client.',
icon: "warning" icon: "warning"
}); });
return false;
}
return false if (client_branch_id == 0) {
Swal.fire({
title: "Warning!",
text: 'Please select the Client Branch.',
icon: "warning"
});
return false;
}
if (client_policy_id == 0) {
Swal.fire({
title: "Warning!",
text: 'Please select the Client Policy.',
icon: "warning"
});
return false;
} }
Swal.fire({ Swal.fire({
@ -729,7 +790,7 @@
if (result.isConfirmed) { if (result.isConfirmed) {
$.ajax({ $.ajax({
url: '<?= base_url("util/send_manual_reminder/") ?>' + client_id + '/' + client_branch_id, url: '<?= base_url("util/send_manual_reminder/") ?>' + client_id + '/' + client_branch_id + '/' + client_policy_id,
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function(res) { success: function(res) {

View File

@ -7,6 +7,7 @@
.reload:hover { .reload:hover {
cursor: pointer; cursor: pointer;
} }
</style> </style>
<div class="col-12"> <div class="col-12">

View File

@ -16,6 +16,32 @@ table.dataTable tbody td {
.dataTables_filter { .dataTables_filter {
position: absolute; position: absolute;
} }
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style> </style>
<div class="row" id="finance_filter"> <div class="row" id="finance_filter">
@ -209,6 +235,98 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("scroll-horizontal-datatable");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Append the custom dropdown to the body
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
// Datatable document ready // Datatable document ready
$(document).ready(function() { $(document).ready(function() {

View File

@ -91,7 +91,7 @@
<tr> <tr>
<td><?= $key+1; ?></td> <td><?= $key+1; ?></td>
<td><?= $value['policy_type']; ?></td> <td><?= $value['policy_type']; ?></td>
<td><?= $value['event_name']; ?></td> <td><?= $events[$value['event_name']]; ?></td>
<td><?= $value['type_name']; ?></td> <td><?= $value['type_name']; ?></td>
<td style="overflow: hidden;" class="truncate" ><?= $value['jsoncolumns']; ?></td> <td style="overflow: hidden;" class="truncate" ><?= $value['jsoncolumns']; ?></td>
<td> <td>
@ -209,6 +209,8 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<input type="hidden" id="insurer_id_for_dub_temp" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
<div class="form-row"> <div class="form-row">
<!-- <div class="form-group col-md-12"> <!-- <div class="form-group col-md-12">
@ -644,9 +646,11 @@
{ {
var template_id = $('#template_id_for_duplicate').attr('data-id'); var template_id = $('#template_id_for_duplicate').attr('data-id');
var event_name = $('#event_name_for_duplicate').val(); var event_name = $('#event_name_for_duplicate').val();
var insurer_id = $('#insurer_id_for_dub_temp').val();
console.log('template_id_for_duplicate', template_id) console.log('template_id_for_duplicate', template_id)
console.log('event_name_for_duplicate', event_name) console.log('event_name_for_duplicate', event_name)
console.log('insurer_id', insurer_id)
if(event_name == ""){ if(event_name == ""){
@ -659,7 +663,7 @@
return false return false
} }
var url = '<?= base_url('util/dublicate_template/') ?>' + template_id + '/' + event_name var url = '<?= base_url('util/dublicate_template/') ?>' + template_id + '/' + event_name + '/' +insurer_id
$.ajax({ $.ajax({
url: url, url: url,

View File

@ -1,3 +1,71 @@
<style>
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="insurer_list"> <div class="row" id="insurer_list">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
@ -45,6 +113,97 @@
</div> </div>
<!-- end row --> <!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){

View File

@ -103,6 +103,80 @@ table.dataTable tbody td {
.slider.round:before { .slider.round:before {
border-radius: 50%; border-radius: 50%;
} }
.disabled-option {
color: gray;
}
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style> </style>
<div class="row" id="inception_list"> <div class="row" id="inception_list">
@ -125,6 +199,7 @@ table.dataTable tbody td {
<th></th> <th></th>
<th><div class="column-header">Insurer</div></th> <th><div class="column-header">Insurer</div></th>
<th><div class="column-header">Month</div></th> <th><div class="column-header">Month</div></th>
<th><div class="column-header">Statement<br>sno</div></th>
<th><div class="column-header">Filename</div></th> <th><div class="column-header">Filename</div></th>
<th><div class="column-header">Line<br>items</div></th> <th><div class="column-header">Line<br>items</div></th>
<th><div class="column-header">File<br>status</div></th> <th><div class="column-header">File<br>status</div></th>
@ -140,6 +215,7 @@ table.dataTable tbody td {
<td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td> <td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td>
<td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td> <td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td>
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td> <td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
<td><?php echo $row['stmt_sno'] ?> </td>
<td><?php echo $row['file_name'] ?> </td> <td><?php echo $row['file_name'] ?> </td>
<td><?php echo $row['line_items'] ?></td> <td><?php echo $row['line_items'] ?></td>
<td><?php echo $row['file_status']; <td><?php echo $row['file_status'];
@ -172,6 +248,9 @@ table.dataTable tbody td {
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)"> <a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
</a> </a>
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>"onclick="deleteStatement(<?= $row['id'];?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div> </div>
</div> </div>
<?php } ?> <?php } ?>
@ -218,8 +297,24 @@ table.dataTable tbody td {
</div> </div>
<div class="form-group col-md-10"> <div class="form-group col-md-10">
<label for="statement_month">Statement month</label> <label for="statement_month">Statement month</label>
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly> <input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly onchange="getStatementNo()">
</div> </div>
<div class="form-group col-md-10">
<label for="statement_no">Statement no</label>
<select class="form-control" id="statement_no" name="statement_no" required >
<option value="" selected>Select statement no</option>
<?php
$stmt_no = [1,2,3,4,5,6,7];
if (isset($stmt_no) && count($stmt_no)) {
foreach ($stmt_no as $key => $value) {
echo "<option value=" . $value . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-10" > <div class="form-group col-md-10" >
<label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span> <label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span>
<input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet"> <input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
@ -255,7 +350,7 @@ table.dataTable tbody td {
<!-- Invoice status content modal--> <!-- Invoice status content modal-->
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg" style="max-width:1000px;">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" id="title">Update Invoice Status</h4> <h4 class="modal-title" id="title">Update Invoice Status</h4>
@ -286,32 +381,65 @@ table.dataTable tbody td {
<label for="addon_policy">Exp Amount</label> <label for="addon_policy">Exp Amount</label>
<input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled> <input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled>
</div> --> </div> -->
<div class="form-group col-md-4" id="modal_received_amt_div">
<label for="addon_policy">Total Received Amount</label>
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
</div>
</div> </div>
<!-- Invoice Number and Invoice Date in same row --> <!-- Invoice Number and Invoice Date in same row -->
<div class="row" id="invoice_no_div_modal" style="display: none;"> <!-- <div id="invoice_no_div_modal" style="display: none;"> -->
<div class="form-group col-md-4"> <div class="row" id="invoice_no_div_modal" style="display: none;">
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label> <div class="form-group col-md-4">
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required> <label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
</div>
<div class="form-group col-md-4">
<label for="invoice_date">Invoice Date</label>
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
</div>
<div class="form-group col-md-4">
<label for="invoice_value_modal">Invoice value<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="invoice_value_modal" name="invoice_value" placeholder="Enter Invoice Value" readonly>
</div>
</div> </div>
<div class="form-group col-md-4"> <div class="row" id="invoice_no_div_modal2" style="display: none;">
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required> <div class="form-group col-md-4">
<label for="gst_value_modal">GST %<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="gst_per_modal" name="invoice_gst_per" placeholder="Enter GST %" required onchange="calcGSTValue()">
</div>
<div class="form-group col-md-4">
<label for="gst_value_modal">GST Value<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="gst_value_modal" name="invoice_gst" placeholder="Enter Invoice Value" required readonly step="0.01">
</div>
<div class="form-group col-md-4">
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required readonly step="0.01">
</div>
<!-- <div class="form-group col-md-3" id="modal_received_amt_div">
<label for="addon_policy">Total Received Amount</label>
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
</div> -->
</div> </div>
<div class="form-group col-md-4">
<label for="invoice_date">Invoice Date</label> <div class="row" id="modal_received_amt_div">
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required> <div class="form-group col-md-4" >
</div> <label for="addon_policy">Total Received Amount</label>
</div> <input type="number" class="form-control" id="modal_received_amt" placeholder="" disabled>
</div>
</div>
<!-- </div> -->
</div> </div>
<!-- Payment Received Table --> <!-- Payment Received Table -->
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal"> <div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal" style="max-width: 800px;">
<button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button> <button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button>
@ -319,7 +447,8 @@ table.dataTable tbody td {
<thead> <thead>
<tr> <tr>
<th style="display: none;">pk</th> <th style="display: none;">pk</th>
<th>Received Amount</th> <th>Invoice value</th>
<th>GST</th>
<th>TDS</th> <th>TDS</th>
<th>UTR Number</th> <th>UTR Number</th>
<th>Date</th> <th>Date</th>
@ -330,9 +459,10 @@ table.dataTable tbody td {
<tr> <tr>
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td> <td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td> <td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" required step="0.01" onchange="checkInvAmont(event)"></td>
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td> <td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td> <td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d-m-Y'); ?>" placeholder="dd-mm-yyyy" required readonly></td> <td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d/m/Y'); ?>" placeholder="dd/mm/yyyy" required readonly></td>
<td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td> <td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
</tr> </tr>
</tbody> </tbody>
@ -351,19 +481,110 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
</div> </div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
document.getElementById('invoice_status').addEventListener('change', function () { document.getElementById('invoice_status').addEventListener('change', function () {
const invoiceStatus = this.value; const invoiceStatus = this.value;
console.log(invoiceStatus); console.log(invoiceStatus);
const invoiceNoDiv = document.getElementById('invoice_no_div_modal'); const invoiceNoDiv = document.getElementById('invoice_no_div_modal');
const invoiceNoDiv2 = document.getElementById('invoice_no_div_modal2');
// const invoiceDateDiv = document.getElementById('invoice_date_div_modal'); // const invoiceDateDiv = document.getElementById('invoice_date_div_modal');
const paymentTableDiv = document.getElementById('payment_table_div_modal'); const paymentTableDiv = document.getElementById('payment_table_div_modal');
const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div'); const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div');
// Hide everything initially // Hide everything initially
invoiceNoDiv.style.display = 'none'; invoiceNoDiv.style.display = 'none';
invoiceNoDiv2.style.display = 'none';
// invoiceDateDiv.style.display = 'none'; // invoiceDateDiv.style.display = 'none';
paymentTableDiv.style.display = 'none'; paymentTableDiv.style.display = 'none';
totalReceivedAmtDiv.style.display = 'none'; totalReceivedAmtDiv.style.display = 'none';
@ -371,6 +592,7 @@ table.dataTable tbody td {
// Show fields based on selected status // Show fields based on selected status
if (invoiceStatus === 'generated' || invoiceStatus === 'sent') { if (invoiceStatus === 'generated' || invoiceStatus === 'sent') {
invoiceNoDiv.style.display = 'flex'; invoiceNoDiv.style.display = 'flex';
invoiceNoDiv2.style.display = 'flex';
totalReceivedAmtDiv.style.display = 'none'; totalReceivedAmtDiv.style.display = 'none';
switchRequired('invoice_no_modal',true); switchRequired('invoice_no_modal',true);
switchRequired('invoice_date_modal',true); switchRequired('invoice_date_modal',true);
@ -378,12 +600,14 @@ table.dataTable tbody td {
switchRequired('received_amount',false,'name'); switchRequired('received_amount',false,'name');
switchRequired('tds',false,'name'); switchRequired('tds',false,'name');
switchRequired('gst_amount',false,'name');
switchRequired('utr_no',false,'name'); switchRequired('utr_no',false,'name');
switchRequired('payment_date',false,'name'); switchRequired('payment_date',false,'name');
switchRequired('pk',false,'name'); switchRequired('pk',false,'name');
// invoiceDateDiv.style.display = 'block'; // invoiceDateDiv.style.display = 'block';
} else if (invoiceStatus === 'payment_received') { } else if (invoiceStatus === 'payment_received') {
invoiceNoDiv.style.display = 'flex'; invoiceNoDiv.style.display = 'flex';
invoiceNoDiv2.style.display = 'flex';
paymentTableDiv.style.display = 'block'; paymentTableDiv.style.display = 'block';
totalReceivedAmtDiv.style.display = 'block'; totalReceivedAmtDiv.style.display = 'block';
switchRequired('invoice_no_modal',true); switchRequired('invoice_no_modal',true);
@ -394,11 +618,13 @@ table.dataTable tbody td {
switchRequired('received_amount',true,'name'); switchRequired('received_amount',true,'name');
switchRequired('utr_no',true,'name'); switchRequired('utr_no',true,'name');
switchRequired('tds',true,'name'); switchRequired('tds',true,'name');
switchRequired('gst_amount',true,'name');
switchRequired('payment_date',true,'name'); switchRequired('payment_date',true,'name');
switchRequired('pk',true,'name'); switchRequired('pk',true,'name');
}else if(invoiceStatus === 'pending') }else if(invoiceStatus === 'pending')
{ {
invoiceNoDiv.style.display = 'none'; invoiceNoDiv.style.display = 'none';
invoiceNoDiv2.style.display = 'none';
paymentTableDiv.style.display = 'none'; paymentTableDiv.style.display = 'none';
totalReceivedAmtDiv.style.display = 'none'; totalReceivedAmtDiv.style.display = 'none';
// switchRequired('modal_received_amt_div',false); // switchRequired('modal_received_amt_div',false);
@ -411,8 +637,11 @@ table.dataTable tbody td {
switchRequired('payment_date',false,'name'); switchRequired('payment_date',false,'name');
switchRequired('pk',false,'name'); switchRequired('pk',false,'name');
switchRequired('tds',false,'name'); switchRequired('tds',false,'name');
switchRequired('gst_amount',false,'name');
} }
calcGSTValue();
}); });
@ -435,6 +664,13 @@ table.dataTable tbody td {
$('#invoiceForm').on('submit', function (e) { $('#invoiceForm').on('submit', function (e) {
e.preventDefault(); // Prevent default form submission e.preventDefault(); // Prevent default form submission
var res = checkInvAmont();
if(!res)
{
return false;
}
var form = document.getElementById('invoiceForm'); var form = document.getElementById('invoiceForm');
// alert(form.checkValidity()); // alert(form.checkValidity());
// alert($('#invoice_date_modal').val()); // alert($('#invoice_date_modal').val());
@ -487,7 +723,7 @@ table.dataTable tbody td {
$('.close').click() $('.close').click()
// Reset the form data // Reset the form data
$('#invoiceForm')[0].reset(); // $('#invoiceForm')[0].reset();
alert('Invoice updated successfully!'); alert('Invoice updated successfully!');
location.reload(); location.reload();
@ -513,15 +749,16 @@ table.dataTable tbody td {
newRow.innerHTML = ` newRow.innerHTML = `
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td> <td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td> <td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" onchange="checkInvAmont(event)" required step="0.01"></td>
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td> <td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td> <td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
<td><input type="text" class="form-control payment_date" value="<?php echo date('d-m-Y'); ?>" name="payment_date[]" placeholder="Enter UTR No" required readonly></td> <td><input type="text" class="form-control payment_date" value="<?php echo date('d/m/Y'); ?>" name="payment_date[]" placeholder="dd/mm/yyyy" required readonly></td>
<td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td> <td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
`; `;
tableBody.appendChild(newRow); tableBody.appendChild(newRow);
$('.payment_date').datepicker({ $('.payment_date').datepicker({
format: 'dd-mm-yyyy', format: 'dd/mm/yyyy',
autoclose: true autoclose: true
}); });
}); });
@ -579,15 +816,16 @@ function formatDate(date) {
var day = ("0" + date.getDate()).slice(-2); var day = ("0" + date.getDate()).slice(-2);
var month = ("0" + (date.getMonth() + 1)).slice(-2); var month = ("0" + (date.getMonth() + 1)).slice(-2);
var year = date.getFullYear(); var year = date.getFullYear();
return day + "-" + month + "-" + year; return day + "/" + month + "/" + year;
} }
function formatDateToDMY(dateStr) { function formatDateToDMY(dateStr) {
// Split the date string by the hyphen // Split the date string by the hyphen
var parts = dateStr.split('-'); var parts = dateStr.split('-');
return parts[2] + '-' + parts[1] + '-' + parts[0]; // Rearrange to DD-MM-YYYY return parts[2] + '/' + parts[1] + '/' + parts[0]; // Rearrange to DD-MM-YYYY
} }
function showInvoiceStatusModal(event) function showInvoiceStatusModal(event)
{ {
console.log('############ showInvoiceStatusModal function called ##################');
var modal_received_amt_div = document.getElementById('modal_received_amt_div'); var modal_received_amt_div = document.getElementById('modal_received_amt_div');
modal_received_amt_div.style.display = 'none'; modal_received_amt_div.style.display = 'none';
// alert(); // alert();
@ -626,6 +864,15 @@ function showInvoiceStatusModal(event)
document.getElementById('invoice_no_modal').value = response.data.invoice_no; document.getElementById('invoice_no_modal').value = response.data.invoice_no;
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date; document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date;
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount; document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
document.getElementById('gst_per_modal').value = response.data.gst_per;
document.getElementById('gst_value_modal').value = response.data.gst_value;
console.log('response.data.gst_value - ' + response.data.gst_value);
if(response.data.gst_value == 0 || response.data.gst_value == '' || response.data.gst_value == null)
{
calcGSTValue();
}
if (!$('#invoice_date_modal').val()) { if (!$('#invoice_date_modal').val()) {
// alert('nope'); // alert('nope');
@ -635,7 +882,7 @@ function showInvoiceStatusModal(event)
// Clear existing rows in the payment table // Clear existing rows in the payment table
var paymentTableBody = document.querySelector('#payment_table_modal tbody'); var paymentTableBody = document.querySelector('#payment_table_modal tbody');
console.log('response.data.payments.length', response.data.payments.length)
// Populate payment table rows // Populate payment table rows
if(response.data.payments.length) if(response.data.payments.length)
{ {
@ -645,6 +892,7 @@ function showInvoiceStatusModal(event)
row.innerHTML = ` row.innerHTML = `
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td> <td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td> <td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td> <td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td> <td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td> <td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
@ -652,7 +900,7 @@ function showInvoiceStatusModal(event)
`; `;
}); });
} }
$('.payment_date').datepicker({ format: 'dd-mm-yyyy',autoclose: true}); $('.payment_date').datepicker({ format: 'dd/mm/yyyy',autoclose: true});
// Show the modal // Show the modal
var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); var myModal = new bootstrap.Modal(document.getElementById('invoice_modal'));
myModal.show(); myModal.show();
@ -690,7 +938,7 @@ $(document).ready(function(){
$('.payment_date').datepicker({ $('.payment_date').datepicker({
format: 'dd-mm-yyyy', format: 'dd/mm/yyyy',
autoclose: true autoclose: true
}); });
@ -705,7 +953,7 @@ minDate.setDate(today.getDate() - 180);
var maxDate = new Date(); var maxDate = new Date();
maxDate.setDate(today.getDate() + 180); maxDate.setDate(today.getDate() + 180);
$('#invoice_date_modal').datepicker({ $('#invoice_date_modal').datepicker({
format: 'dd-mm-yyyy', format: 'dd/mm/yyyy',
autoclose: true, autoclose: true,
startDate: minDate, startDate: minDate,
endDate: maxDate endDate: maxDate
@ -719,14 +967,16 @@ maxDate.setDate(today.getDate() + 180);
$('#insurer_statement_upload_form').submit(function(event) { $('#insurer_statement_upload_form').submit(function(event) {
event.preventDefault(); event.preventDefault();
var isValid = $('#insurer_statement_upload_form').parsley().validate(); var isValid = $('#insurer_statement_upload_form').parsley().validate();
if (!isValid) { if (!isValid) {
console.log('Form is Empty', 'Warning'); console.log('Form is Empty', 'Warning');
alert('choose all fileds'); // alert('choose all fileds');
return; return;
} }
$('#btnSubmit').prop('disabled', true).text('Submitting...');
// Create FormData object // Create FormData object
var formData = new FormData($(this)[0]); var formData = new FormData($(this)[0]);
for (var pair of formData.entries()) { for (var pair of formData.entries()) {
@ -768,6 +1018,11 @@ maxDate.setDate(today.getDate() + 180);
toastr.error('Something went wrong! Try later', 'Error'); toastr.error('Something went wrong! Try later', 'Error');
window.location.reload(true); window.location.reload(true);
} }
$('.close').click()
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
$('#btnSubmit').prop('disabled', false).text('Submit');
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
@ -775,11 +1030,13 @@ maxDate.setDate(today.getDate() + 180);
console.error("Request failed:", status, error); console.error("Request failed:", status, error);
toastr.error('Something went wrong! Try later', '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');
window.location.reload(true); window.location.reload(true);
} }
}); });
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
}); });
function fetchFileError(file_id) { function fetchFileError(file_id) {
@ -803,7 +1060,7 @@ maxDate.setDate(today.getDate() + 180);
var file_error_html = ""; var file_error_html = "";
if (file_error_data['error_code'] == 1) { if (file_error_data['error_code'] == 1) {
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">either already mapped / not found with policy transactions / duplicates.</span>'; file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">not found with policy transactions / duplicates.</span>';
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>'; file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
} }
@ -828,19 +1085,21 @@ maxDate.setDate(today.getDate() + 180);
} }
function checkInvAmont(event) { function checkInvAmont(event = null) {
var total = 0; var total = 0;
var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]'); var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]');
var receivedGST = document.querySelectorAll('input[name="gst_amount[]"]');
var tdsAmounts = document.querySelectorAll('input[name="tds[]"]'); var tdsAmounts = document.querySelectorAll('input[name="tds[]"]');
// console.log(); // console.log();
receivedAmounts.forEach(function(el, index) { receivedAmounts.forEach(function(el, index) {
// Get the received amount // Get the received amount
let receivedVal = parseFloat(el.value) || 0; let receivedVal = parseFloat(el.value) || 0;
// Get the corresponding tds amount (paired with the received amount) // Get the corresponding tds amount (paired with the received amount)
let gstVal = parseFloat(receivedGST[index].value) || 0;
let tdsVal = parseFloat(tdsAmounts[index].value) || 0; let tdsVal = parseFloat(tdsAmounts[index].value) || 0;
// Add received amount and tds amount // Add received amount and tds amount
// console.log(); // console.log();
total += (receivedVal + tdsVal); total += (receivedVal + tdsVal + gstVal);
}); });
// console.log(total); // console.log(total);
// Get the expected invoice amount // Get the expected invoice amount
@ -848,9 +1107,16 @@ function checkInvAmont(event) {
// Check if the total exceeds the expected amount // Check if the total exceeds the expected amount
if (exp_amt < total) { if (exp_amt < total) {
alert('Exceeds Invoice amount'); alert('Exceeds Invoice amount...Plz adjust numbers');
event.target.value = ''; // Reset the value of the element that triggered the event if(event != null)
{
event.target.value = '';
}
return false; // Reset the value of the element that triggered the event
} }
return true;
} }
@ -882,5 +1148,200 @@ function switchRequired(elementId, isRequired, type = 'id') {
} }
} }
function getStatementNo()
{
var insurer_id = $('#insurer').val();
var statement_month = $('#statement_month').val();
console.log(insurer_id+' / '+statement_month);
if(insurer_id == "")
{
alert('Choose insurer...!');
$('#statement_month').val('');
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = 'getInsurerStatementMonth?insurer_id=' +insurer_id+'&month='+statement_month ;
$.ajax({
url: apiURL,
type: "GET",
headers: {
// "Content-Type":"multipart/form-data",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
// $('#insurer_statement_upload_form')[0].reset();
if (response.code === 200 && response.dataStatus === true && response
.data !== "") {
disableStatementNo(response.data)
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
// alert(response.message);
// toastr.error(response.message, 'Failed');
// window.location.reload(true);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
} else {
console.error('Something went wrong!');
// alert('Something went wrong! Try later');
toastr.error('Something went wrong! Try later', 'Error');
// window.location.reload(true);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
}
},
error: function(xhr, status, error) {
// Request failed, handle error
console.error("Request failed:", status, error);
toastr.error('Something went wrong! Try later', 'Error');
// $('#uploadForm')[0].reset();
// window.location.reload(true);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
}
});
// $('.loader').fadeOut();
// $('.loader-mask').delay(10).fadeOut('slow');
}
function calcGSTValue()
{
// alert('calcGSTValue');
console.log('calcGSTValue called');
var inv_status_element = document.getElementById('invoice_status');
if(inv_status_element.value == 'generated' || inv_status_element.value == 'send' || inv_status_element.value == 'payment_received')
{
var gst_per = document.getElementById('gst_per_modal').value;
console.log('gst_per - ' + gst_per);
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
var invoice_value = invoice_value_dom_obj.value;
console.log('invoice_value - ' + invoice_value);
var gst_value_dom_obj = document.getElementById('gst_value_modal');
var gst_value = gst_value_dom_obj.value;
console.log('gst_value - ' + gst_value);
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
// var invoice_amount = invoice_amount_dom_obj.value();
gst_value_dom_obj.value = Math.round((parseFloat(gst_per) / 100 ) * invoice_value);
// gst_value_dom_obj.value = ((parseFloat(gst_per) / 100 ) * invoice_value);
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
if(inv_status_element.value == 'payment_received')
{
checkInvAmont();
}
}
}
function disableStatementNo(arr)
{
// JavaScript array with values to disable
// const disableValues = arr;
const disableIds = arr.map(item => item.stmt_sno);
console.log(disableIds);
// Get the select element
const selectElement = document.getElementById("statement_no");
// Variable to track if the first enabled option is selected
let firstEnabledOptionSelected = false;
// Iterate over the options in the select element
Array.from(selectElement.options).forEach(option => {
// If the option value is in the disableIds array, disable it
console.log(option.value);
option.disabled = false;
option.style.backgroundColor = "";
if (disableIds.includes((option.value))) {
option.disabled = true;
option.style.backgroundColor = "lightgray";
}
else if (!firstEnabledOptionSelected && option.value !== "") {
// Automatically select the first enabled option
option.selected = true;
firstEnabledOptionSelected = true;
}
});
}
function deleteStatement(id)
{
//alert(id);
Swal.fire({
title: "Do you want to delete statement & it's invoice data if any?",
showCancelButton: true,
confirmButtonText: "Delete",
confirmButtonColor: "#ff3333",
}).then((result) => {
console.log(result);
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = 'deleteStatement/' + id;
// console.log('Truncate API URL : ', apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log('Truncate Response', response)
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
if (response.code === 200 && response.dataStatus === true) {
Swal.fire({
title: "Deleted!",
icon: "success"
});
window.location.reload(true);
} else {
Swal.fire({
title: "Failed!",
text: 'Something went wrong! Try later',
icon: "error"
});
window.location.reload(true);
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
console.error('Error fetching data from API:', error);
toastr.error('Something went wrong! Try later', 'Error');
window.location.reload(true);
}
});
}
});
}
</script> </script>

View File

@ -1,3 +1,71 @@
<style>
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="kyc_list"> <div class="row" id="kyc_list">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
@ -42,7 +110,94 @@
</div><!-- end col --> </div><!-- end col -->
</div> </div>
<!-- end row --> <!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){

View File

@ -581,6 +581,9 @@
<li> <li>
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a> <a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
</li> </li>
<li>
<a href="<?= base_url('/employee/test_members_list') ?>">Test Members List</a>
</li>
</ul> </ul>
</div> </div>
</li> </li>

View File

@ -32,6 +32,7 @@
color: white !important; color: white !important;
margin-right: 5px; margin-right: 5px;
} }
</style> </style>
<div class="row" id="leads_form" style="display:none;"> <div class="row" id="leads_form" style="display:none;">
@ -383,7 +384,7 @@ function getLeadsDataForEdit(input) {
$('#contact_person_name').val(res.data.contact_person_name); $('#contact_person_name').val(res.data.contact_person_name);
$('#contact_person_mobile').val(res.data.contact_person_mobile); $('#contact_person_mobile').val(res.data.contact_person_mobile);
$('#contact_person_email').val(res.data.contact_person_email); $('#contact_person_email').val(res.data.contact_person_email);
$('#policy_type_id_1').val(res.data.policy_type_id).change();
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}, 1000) }, 1000)
@ -396,7 +397,6 @@ function getLeadsDataForEdit(input) {
var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id; var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id;
var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id; var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id;
$('#policy_type_id_1').val(res.data.policy_type_id).change();
$('#insurer_1').val(insurer).select2(); $('#insurer_1').val(insurer).select2();
$('#tpa_1').val(tpa).select2(); $('#tpa_1').val(tpa).select2();
$('#proposed_insurer_1').val(proposed_insurer).select2(); $('#proposed_insurer_1').val(proposed_insurer).select2();
@ -404,9 +404,37 @@ function getLeadsDataForEdit(input) {
$('#policy_start_date_1').val(res.data.policy_start_date); $('#policy_start_date_1').val(res.data.policy_start_date);
$('#policy_end_date_1').val(res.data.policy_end_date); $('#policy_end_date_1').val(res.data.policy_end_date);
$('#no_of_lives').val(res.data.no_of_lives); $('#no_of_lives').val(res.data.no_of_lives);
$('#claims').val(res.data.claims);
$('#location').val(res.data.location); $('#location').val(res.data.location);
let increment = 1;
// Other fields, set dynamically based on increment
$('#renewal_emp_count_' + increment).val(res.data.renewal_emp_count);
$('#renewal_dept_count_' + increment).val(res.data.renewal_dept_count);
$('#renewal_no_of_lives_' + increment).val(res.data.renewal_no_of_lives);
$('#incept_emp_count_' + increment).val(res.data.incept_emp_count);
$('#incept_dept_count_' + increment).val(res.data.incept_dept_count);
$('#incept_no_of_lives_' + increment).val(res.data.incept_no_of_lives);
$('#exp_emp_count_' + increment).val(res.data.exp_emp_count);
$('#exp_dept_count_' + increment).val(res.data.exp_dept_count);
$('#exp_no_of_lives_' + increment).val(res.data.exp_no_of_lives);
$('#incurred_claim_date_' + increment).val(res.data.incurred_claims_date);
$('#paid_claims_' + increment).val(res.data.paid_claims);
$('#outstanding_claims_' + increment).val(res.data.outstanding_claims);
$('#policy_run_days_' + increment).val(res.data.policy_run_days);
$('#premium_at_inception_' + increment).val(res.data.premium_at_inception);
$('#premium_date_' + increment).val(res.data.premium_date);
$('#earned_premium_' + increment).val(res.data.earned_premium);
$('#annualised_claims_' + increment).val(res.data.annualised_claims);
$('#incurred_claims_ratio_' + increment).val(res.data.incurred_claims_ratio);
$('#earned_claims_ratio_' + increment).val(res.data.earned_claims_ratio);
$('#incurred_claims_' + increment).val(res.data.incurred_claims);
$('#file_name_display').text('Upload File Name : ' + res.data.file_name);
// $('#file_name').val(res.data.file_name);
$('#total_si_at_incept_' + increment).val(res.data.total_si_at_incept);
$('#total_si_at_renewal_' + increment).val(res.data.total_si_at_renewal);
if (res.data.salse_person_id) { if (res.data.salse_person_id) {
selecSalsePerson(res.data.salse_person_id); selecSalsePerson(res.data.salse_person_id);
@ -419,12 +447,63 @@ function getLeadsDataForEdit(input) {
$('#freshDiv').hide(); $('#freshDiv').hide();
$('.proposed_div').show().find('select, input').attr('required', 'required'); $('.proposed_div').show().find('select, input').attr('required', 'required');
$('#policy_end_date, #policy_start_date, #claim').removeAttr('required'); $('#policy_end_date, #policy_start_date, #claim').removeAttr('required');
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
} else { } else {
$('#renewalDiv').find('select, input').removeAttr('required'); $('#renewalDiv').find('select, input').removeAttr('required');
$('#freshDiv').find('select, input').attr('required', 'required'); $('#freshDiv').find('select, input').attr('required', 'required');
$('#renewalDiv').hide(); $('#renewalDiv').hide();
$('#freshDiv').show(); $('#freshDiv').show();
$('.proposed_div').hide().find('select, input').removeAttr('required'); $('.proposed_div').hide().find('select, input').removeAttr('required');
if(res.data.lead_type == 1){
$('.freashDiv').hide()
$('.renewalDiv').show()
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
}
}
if(res.data.policy_type_id != 2){
$('.gpa_hide_div_'+increment).hide();
$('.gpa_show_div_'+increment).show();
$('.gpa_div_elements_'+increment).show();
$('.emp_title').text('No of Employees at Inception');
let claimExperience = JSON.parse(res.data.fin_years_claims);
claimExperience[0].finyear.forEach((data, index) => {
const year = document.querySelector(`#${["first", "second", "third"][index]}_year_${increment}`);
const claimAmount = document.querySelector(`#${["first", "second", "third"][index]}_claim_amount_${increment}`);
const claimStatus = document.querySelector(`#${["first", "second", "third"][index]}_claim_status_${increment}`);
const causeOfDeath = document.querySelector(`#${["first", "second", "third"][index]}_casue_of_death_${increment}`);
const deathDate = document.querySelector(`#${["first", "second", "third"][index]}_death_date_${increment}`);
if (year) year.value = data.year;
if (claimAmount) claimAmount.value = data.claim_amount;
if (claimStatus) claimStatus.value = data.status;
if (causeOfDeath) causeOfDeath.value = data.cause_of_death;
if (deathDate) deathDate.value = data.death_date;
});
}else{
$('.gpa_hide_div_'+increment).show();
} }
@ -575,8 +654,6 @@ function getPolicyData(client_policy_id, increment_count) {
} }
} }
// Salse team user list data // Salse team user list data
function selecSalsePerson(salse_person_ids) { function selecSalsePerson(salse_person_ids) {
@ -604,16 +681,50 @@ function addHTMLInput(check) {
const newRow = document.createElement('div'); const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row'; newRow.className = 'form-row dynamic-form-row';
const newRow2 = document.createElement('div');
newRow2.className = 'form-row dynamic-form-row freashDiv';
const newRow3 = document.createElement('div');
newRow3.className = 'form-row dynamic-form-row';
const newRow4 = document.createElement('div');
newRow4.className = 'form-row dynamic-form-row freashDiv';
const newRow5 = document.createElement('div');
newRow5.className = 'form-row dynamic-form-row';
const newRow7 = document.createElement('div');
newRow7.className = 'form-row dynamic-form-row';
const newRow8 = document.createElement('div');
newRow8.className = 'form-row dynamic-form-row';
const newRow6 = document.createElement('div');
newRow6.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow6.style.display = 'none';
const newRow9 = document.createElement('div');
newRow9.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow9.style.display = 'none';
const newRow10 = document.createElement('div');
newRow10.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow10.style.display = 'none';
const newRow11 = document.createElement('div');
newRow11.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow11.style.display = 'none';
// Add an <hr> element // Add an <hr> element
const hrElement = document.createElement('hr'); const hrElement = document.createElement('hr');
container.appendChild(hrElement); container.appendChild(hrElement);
// Set inner HTML with necessary input fields // Main div
newRow.innerHTML += ` newRow.innerHTML += `
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="policy_type_id">Policy Type <span class="text-danger">*</span></label> <label for="policy_type_id">Policy Type <span class="text-danger">*</span></label>
<select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" required> <select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" onchange="showGpaColumns(this)" required>
<option value="">Select Policy Type</option> <option value="">Select Policy Type</option>
<?php <?php
if (isset($policy_type) && count($policy_type)) { if (isset($policy_type) && count($policy_type)) {
@ -656,28 +767,77 @@ function addHTMLInput(check) {
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="no_of_lives">No of Lives <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="no_of_lives" name="no_of_lives[]" placeholder="Enter Lives" required>
</div>
<div class="form-group col-md-3 proposed_div">
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger"></span></label> <label for="policy_start_date_${increment}">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">
</div> </div>
<div class="form-group col-md-3 proposed_div"> <div class="form-group col-md-3">
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger"></span></label> <label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger"></span></label>
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE"> <input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
</div> </div>
`;
<div class="form-group col-md-3"> // Incured claim div
<label for="claims">Claims <span class="text-danger"></span></label> newRow8.innerHTML += `
<input type="text" class="form-control" id="claims" name="claims[]" placeholder="Enter Claims">
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="incurred_claim_date_${increment}">Incurred Claim Date<span class="text-danger"></span></label>
<input type="text" class="form-control incurred_claim" id="incurred_claim_date_${increment}" name="incurred_claim_date[]" placeholder="Enter DOE">
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="paid_claims_${increment}">Paid Claims<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="paid_claims_${increment}" name="paid_claims[]" placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="outstanding_claims_${increment}">Outstanding Claims<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="outstanding_claims_${increment}" name="outstanding_claims[]" placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="incurred_claims_${increment}">Incurred Claim<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incurred_claims_${increment}" name="incurred_claims[]" placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="policy_run_days_${increment}">Policy Run Days<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_run_days_${increment}" name="policy_run_days[]" placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="premium_at_inception_${increment}">Premium Paid at Inception<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="premium_at_inception_${increment}" name="premium_at_inception[]" placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="premium_date_${increment}">Premium Date<span class="text-danger"></span></label>
<input type="text" class="form-control" id="premium_date_${increment}" name="premium_date[]" placeholder="Enter Premium Date">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="earned_premium_${increment}">Earned Premium<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="earned_premium_${increment}" name="earned_premium[]" placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="annualised_claims_${increment}">Annualised Claims<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="annualised_claims_${increment}" name="annualised_claims[]" placeholder="Enter Annualised Claims" >
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="incurred_claims_ratio_${increment}">Incurred Claims Ratio<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incurred_claims_ratio_${increment}" name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio" >
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="earned_claims_ratio_${increment}">Earned Claims Ratio<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="earned_claims_ratio_${increment}" name="earned_claims_ratio[]" placeholder="Enter Earned Claims Ratio" >
</div>
<div class="form-group col-md-3 freashDiv">
<label for="location">Location <span class="text-danger">*</span></label> <label for="location">Location <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" required> <input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" >
</div> </div>
<div class="form-group col-md-3 proposed_div" style="display: none;"> <div class="form-group col-md-3 proposed_div" style="display: none;">
@ -708,23 +868,241 @@ function addHTMLInput(check) {
</select> </select>
</div> </div>
`;
//renewal div
newRow2.innerHTML += `
<div class="form-group col-md-3">
<label for="renewal_emp_count_${increment}"> No of Employees at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_emp_count_${increment}" name="renewal_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="renewal_dept_count_${increment}"> No of Dependents at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_dept_count_${increment}" name="renewal_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="renewal_no_of_lives_${increment}"> Total Lives at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_no_of_lives_${increment}" name="renewal_no_of_lives[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_show_div_${increment}" style="display:none;">
<label for="total_si_at_renewal_${increment}"> Total Sum Insured at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="total_si_at_renewal_${increment}" name="total_si_at_renewal[]" placeholder="Enter Lives" >
</div>
`;
//inception div
newRow3.innerHTML += `
<div class="form-group col-md-3">
<label for="incept_emp_count_${increment}" class="emp_title"> No of Employees at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_emp_count_${increment}" name="incept_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="incept_dept_count_${increment}" class="depnd_title"> No of Dependents at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_dept_count_${increment}" name="incept_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="incept_no_of_lives_${increment}" class="total_title"> Total Lives at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_no_of_lives_${increment}" name="incept_no_of_lives[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_show_div_${increment}" style="display:none;">
<label for="total_si_at_incept_${increment}" class="total_title"> Total Sum Insured at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="total_si_at_incept_${increment}" name="total_si_at_incept[]" placeholder="Enter Lives" >
</div>
`;
//expiry div
newRow4.innerHTML += `
<div class="form-group col-md-3">
<label for="exp_emp_count_${increment}"> No of Employees at Expiry <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="exp_emp_count_${increment}" name="exp_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<label for="exp_dept_count_${increment}"> No of Dependents at Expiry <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="exp_dept_count_${increment}" name="exp_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<label for="exp_no_of_lives_${increment}"> Total Lives at Expiry <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="exp_no_of_lives_${increment}" name="exp_no_of_lives[]" placeholder="Enter Lives" >
</div>
`;
//file upload div
newRow7.innerHTML += `
<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>
`;
newRow9.innerHTML +=`<div class="form-group col-md-3"><h5>Claims Experience for last 3 Years </h5></div>`;
//Last 3 years claims expirence div
newRow6.innerHTML += `
<div class="form-group col-md-3">
<label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_year_${increment}" name="first_year[]">
</div>
<div class="form-group col-md-3">
<label for="first_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
</div>
<div class="form-group col-md-3">
<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[]">
</div>
<div class="form-group col-md-3">
<label for="first_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_casue_of_death_${increment}" name="first_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_death_date_${increment}" name="first_death_date[]">
</div>
`;
//Last 3 years claims expirence div
newRow10.innerHTML += `
<div class="form-group col-md-3">
<label for="second_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_year_${increment}" name="second_year[]">
</div>
<div class="form-group col-md-3">
<label for="second_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_claim_amount_${increment}" name="second_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="second_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_claim_status_${increment}" name="second_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="second_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_casue_of_death_${increment}" name="second_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="second_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_death_date_${increment}" name="second_death_date[]">
</div>
`;
//Last 3 years claims expirence div
newRow11.innerHTML += `
<div class="form-group col-md-3">
<label for="third_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_year_${increment}" name="third_year[]">
</div>
<div class="form-group col-md-3">
<label for="third_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_claim_amount_${increment}" name="third_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="third_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_claim_status_${increment}" name="third_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="third_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_casue_of_death_${increment}" name="third_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="third_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_death_date_${increment}" name="third_death_date[]">
</div>
`;
//button div
newRow5.innerHTML += `
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;"> <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-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> <a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
</div> </div>
`; `;
container.appendChild(newRow); container.appendChild(newRow);
container.appendChild(newRow8);
const hrElement2 = document.createElement('hr');
container.appendChild(hrElement2);
//inception div
container.appendChild(newRow3);
//renewal div
container.appendChild(newRow2);
//expiry div
container.appendChild(newRow4);
const hrElement3 = document.createElement('hr');
hrElement3.className = "gpa_div_elements"; // Set class to hrElement3
container.appendChild(hrElement3); // Append hrElement3 to container
container.appendChild(newRow9);
//Last 3 years claims expirence div
container.appendChild(newRow6);
container.appendChild(newRow10);
container.appendChild(newRow11);
//file upload div
container.appendChild(newRow7);
//button div
container.appendChild(newRow5);
var lead_type = $('#lead_type').val(); var lead_type = $('#lead_type').val();
if (lead_type == 2) { if (lead_type == 2) {
// $('.proposed_div').show().find('select, input').attr('required', 'required'); // $('.proposed_div').show().find('select, input').attr('required', 'required');
$('.proposed_div').show(); $('.proposed_div').show();
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
} else { } else {
// $('.proposed_div').hide().find('select, input').removeAttr('required'); // $('.proposed_div').hide().find('select, input').removeAttr('required');
$('.proposed_div').hide() $('.proposed_div').hide()
$('.gpa_div_elements').hide();
if(lead_type == 1){
$('.freashDiv').hide()
$('.renewalDiv').show()
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
}
} }
// Scroll the newly added select into view and focus on it // Scroll the newly added select into view and focus on it
@ -747,6 +1125,24 @@ function addHTMLInput(check) {
policy_end_date.setFullYear(policy_end_date.getFullYear() + 1); policy_end_date.setFullYear(policy_end_date.getFullYear() + 1);
policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year
policy_end_datePicker.setDate(policy_end_date); 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);
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());
// 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);
}
} }
}); });
@ -755,6 +1151,32 @@ function addHTMLInput(check) {
allowInput: false allowInput: false
}); });
var incurred_claim_datepicker = flatpickr("#incurred_claim_date_" + increment, {
dateFormat: "d/m/Y",
allowInput: false,
onChange: function (selectedDates) {
console.log('Flatpickr instance:', this);
console.log('ID of this element:', this.input.id);
// Extract the increment value from the element's ID
let increment = this.input.id.split('_').pop();
console.log('Extracted increment:', increment);
console.log('Selected Dates:', selectedDates);
console.log('Policy Start Date:', $("#policy_start_date_" + increment).val());
// Recalculate policy_run_days if policy start date is already selected
if ($("#policy_start_date_" + increment).val()) {
calculatePolicyRunDays(increment);
}
}
});
var premium_date_datepicker = flatpickr("#premium_date_" + increment, {
dateFormat: "d/m/Y",
allowInput: false
});
$('#source_policy_id').on('change', function(){ $('#source_policy_id').on('change', function(){
let client_policy_id = $(this).val(); let client_policy_id = $(this).val();
console.log('client_policy_id', client_policy_id) console.log('client_policy_id', client_policy_id)
@ -771,8 +1193,7 @@ function addHTMLInput(check) {
increment++; // Increment after adding the input increment++; // Increment after adding the input
} }
function removeHTMLInput(element) function removeHTMLInput(element) {
{
const container = document.getElementById('dynamic-form-container'); const container = document.getElementById('dynamic-form-container');
const rows = container.querySelectorAll('.dynamic-form-row'); const rows = container.querySelectorAll('.dynamic-form-row');
@ -790,6 +1211,96 @@ function removeHTMLInput(element)
} }
} }
function calculatePolicyRunDays(increment) {
console.log('calculatePolicyRunDays function called');
console.log('increment', increment);
var policyStartDate = flatpickr.parseDate($("#policy_start_date_" + increment).val(), "d/m/Y");
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
console.log('policyStartDate', policyStartDate)
console.log('incurredClaimDate', 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
}
}
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);
// Prevent division by zero in annualised claims calculation
let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
console.log('annualised_claims', annualised_claims);
$('#annualised_claims_' + increment).val(annualised_claims);
// ------------------------------------------------------------------------------------------
// Prevent division by zero in incurred claim ratio calculation
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0;
console.log('incurred_claim_ratio', incurred_claim_ratio);
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio);
// ------------------------------------------------------------------------------------------
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;
console.log('earned_claims_ratio', earned_claims_ratio);
$('#earned_claims_ratio_' + increment).val(earned_claims_ratio);
}
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);
// Set the calculated value with two decimal places
$('#earned_premium_' + increment).val(earned_premium.toFixed(2));
}
//--------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------
$("#leads_form_id").submit(function(event) { $("#leads_form_id").submit(function(event) {
@ -826,6 +1337,11 @@ $("#leads_form_id").submit(function(event) {
// Append the JSON string to the FormData object // Append the JSON string to the FormData object
formData.append('salse_person_id', jsonString); formData.append('salse_person_id', jsonString);
// Convert the claim experience array to JSON
const finyearJsonString = gatherClaimExperienceData();
console.log('finyearJsonString', finyearJsonString);
formData.append('finyear', finyearJsonString);
$.ajax({ $.ajax({
data: formData, data: formData,
url: form_action, url: form_action,
@ -876,6 +1392,9 @@ $('#lead_type').change(function() {
$('#policy_start_date').removeAttr('required'); $('#policy_start_date').removeAttr('required');
$('#claims').removeAttr('required'); $('#claims').removeAttr('required');
$('#freshDiv').hide(); $('#freshDiv').hide();
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.gpa_div_elements').show();
$('#gst').val(''); $('#gst').val('');
$('#pan').val(''); $('#pan').val('');
@ -885,6 +1404,10 @@ $('#lead_type').change(function() {
$('#contact_person_mobile').val(''); $('#contact_person_mobile').val('');
$('#contact_person_email').val(''); $('#contact_person_email').val('');
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
} else { } else {
$('#renewalDiv').find('select, input').removeAttr('required'); $('#renewalDiv').find('select, input').removeAttr('required');
@ -905,6 +1428,26 @@ $('#lead_type').change(function() {
$('#client_name').val(''); $('#client_name').val('');
$('#client_short_name').val(''); $('#client_short_name').val('');
$('#entity_type_id').val(''); $('#entity_type_id').val('');
if(value == 1){
$('.freashDiv').hide()
$('.renewalDiv').show()
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
$('.gpa_div_elements').show();
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
}
} }
}) })
@ -929,6 +1472,85 @@ function tpaChange(input, unique_id) {
//----------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------
function sumOfLives(input){
}
function gatherClaimExperienceData() {
// Initialize an empty array for the claim experience data
let claimExperience = [];
// Loop through the rows and extract data for each year
$('input[name="first_year[]"]').each(function(index) {
// Extract values for the first, second, and third year claims
const firstYear = $(this).val();
const firstClaimAmount = $(`input[name="first_claim_amount[]"]`).eq(index).val();
const firstClaimStatus = $(`input[name="first_claim_status[]"]`).eq(index).val();
const firstCauseOfDeath = $(`input[name="first_casue_of_death[]"]`).eq(index).val() || null;
const firstDeathDate = $(`input[name="first_death_date[]"]`).eq(index).val() || null;
const secondYear = $(`input[name="second_year[]"]`).eq(index).val();
const secondClaimAmount = $(`input[name="second_claim_amount[]"]`).eq(index).val();
const secondClaimStatus = $(`input[name="second_claim_status[]"]`).eq(index).val();
const secondCauseOfDeath = $(`input[name="second_casue_of_death[]"]`).eq(index).val() || null;
const secondDeathDate = $(`input[name="second_death_date[]"]`).eq(index).val() || null;
const thirdYear = $(`input[name="third_year[]"]`).eq(index).val();
const thirdClaimAmount = $(`input[name="third_claim_amount[]"]`).eq(index).val();
const thirdClaimStatus = $(`input[name="third_claim_status[]"]`).eq(index).val();
const thirdCauseOfDeath = $(`input[name="third_casue_of_death[]"]`).eq(index).val() || null;
const thirdDeathDate = $(`input[name="third_death_date[]"]`).eq(index).val() || null;
// Push each year's data into the array
claimExperience.push({
"finyear": [
{
"year": firstYear,
"claim_amount": firstClaimAmount,
"status": firstClaimStatus,
"cause_of_death": firstCauseOfDeath,
"death_date": firstDeathDate
},
{
"year": secondYear,
"claim_amount": secondClaimAmount,
"status": secondClaimStatus,
"cause_of_death": secondCauseOfDeath,
"death_date": secondDeathDate
},
{
"year": thirdYear,
"claim_amount": thirdClaimAmount,
"status": thirdClaimStatus,
"cause_of_death": thirdCauseOfDeath,
"death_date": thirdDeathDate
}
]
});
});
return JSON.stringify(claimExperience);
}
function showGpaColumns(input){
let policy_type_id = $(input).val()
let increment = input.id.split("_").pop();
if(policy_type_id != 2){
$('.gpa_hide_div_'+increment).hide();
$('.gpa_show_div_'+increment).show();
$('.gpa_div_elements_'+increment).show();
$('.emp_title').text('No of Employees at Inception')
$('.total_title').text('Total Sum Insured at Inception')
}else{
$('.gpa_hide_div_'+increment).show();
}
}
//-----------------------------------------------------------------------------------------------------------
function getURLParamsForReport() { function getURLParamsForReport() {
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);

View File

@ -36,6 +36,73 @@ table.dataTable tbody td {
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style> </style>
@ -102,11 +169,11 @@ table.dataTable tbody td {
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 1; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>"> <a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 1; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>RFQ <i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>RFQ
</a> </a>
<?php if($row['qcr_count'] > 0) { ?> <!-- <?php if($row['qcr_count'] > 0) { ?>
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>"> <a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR <i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
</a> </a>
<?php } ?> <?php } ?> -->
</div> </div>
</div> </div>
</td> </td>
@ -132,6 +199,97 @@ table.dataTable tbody td {
<script> <script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
var client_list = ''; // local variable for storing the client branch list var client_list = ''; // local variable for storing the client branch list
var branch_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 policy_list = ''; // local variable for storing the client policy list

View File

@ -146,7 +146,7 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="branch_name">Account Maneger summary mail</label> <label for="branch_name">Account Manager summary mail</label>
<label class="switch"> <label class="switch">
<input id="account_maneger_summary_mail_btn" type="checkbox" name="account_maneger_summary_mail_btn" <?= $account_maneger_summary_mail ? 'checked' : '' ?>> <input id="account_maneger_summary_mail_btn" type="checkbox" name="account_maneger_summary_mail_btn" <?= $account_maneger_summary_mail ? 'checked' : '' ?>>
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
@ -237,7 +237,7 @@
<select id="member_welcome_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;"> <select id="member_welcome_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
<option value="">PlaceHolders</option> <option value="">PlaceHolders</option>
<?php foreach ($placeHolders as $value): ?> <?php foreach ($placeHolders as $value): ?>
<?php if($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?> <?php if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>member_mobile
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?> <?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option> <option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
<?php } ?> <?php } ?>
@ -329,7 +329,7 @@
<select id="member_reminder_mail_modal_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;"> <select id="member_reminder_mail_modal_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
<option value="">PlaceHolders</option> <option value="">PlaceHolders</option>
<?php foreach ($placeHolders as $value): ?> <?php foreach ($placeHolders as $value): ?>
<?php if($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?> <?php if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?> <?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option> <option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
<?php } ?> <?php } ?>
@ -405,7 +405,7 @@
<option value="">PlaceHolders</option> <option value="">PlaceHolders</option>
<?php foreach ($placeHolders as $value): ?> <?php foreach ($placeHolders as $value): ?>
<?php if($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'post_enrollment_app_link' || $value == 'client_name' || $value == 'ecard_download_link'){ ?> <?php if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'post_enrollment_app_link' || $value == 'client_name' || $value == 'ecard_download_link'){ ?>
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?> <?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option> <option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
<?php } ?> <?php } ?>
@ -492,7 +492,7 @@
<select id="member_review_and_summary_mail_modal_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;"> <select id="member_review_and_summary_mail_modal_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
<option value="">PlaceHolders</option> <option value="">PlaceHolders</option>
<?php foreach ($placeHolders as $value): ?> <?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 == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary'){ ?>
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?> <?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option> <option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
<?php } ?> <?php } ?>
@ -547,7 +547,7 @@
<label for="emp_code">Template Name</label> <label for="emp_code">Template Name</label>
</div> </div>
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<input type="text" id="template_name" name="template_name" value="Account Maneger Summary Mail" readonly class="form-control" placeholder="Template Name"> <input type="text" id="template_name" name="template_name" value="Account Manager Summary Mail" readonly class="form-control" placeholder="Template Name">
</div> </div>
</div> </div>
@ -1222,7 +1222,7 @@
console.log('get Mail Template Data', res); console.log('get Mail Template Data', res);
if (res) if (res)
{ {
$(`#${template_name}_form`).find('#template_name').val(snakeCaseToCamelCase(res.template_name)); // $(`#${template_name}_form`).find('#template_name').val(snakeCaseToCamelCase(res.template_name));
$(`#${template_name}_form`).find('#subject').val(res.subject); $(`#${template_name}_form`).find('#subject').val(res.subject);
$(`#${template_name}_form`).find('.jodit-wysiwyg').html(res.mail_content); $(`#${template_name}_form`).find('.jodit-wysiwyg').html(res.mail_content);

View File

@ -41,7 +41,7 @@ table.dataTable tbody td {
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger"></span></label> <label for="client_branch">Client<span class="text-danger"></span></label>
<select class="form-control" id="client_id" name="client_id"> <select class="form-control" id="client_id" name="client_id">
<option value="0">Select Client</option> <option value="0">Select Client</option>
@ -53,7 +53,7 @@ table.dataTable tbody td {
} }
?> ?>
</select> </select>
</div> </div> -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="addon_policy"> Insurer <span id="base_danger" <label for="addon_policy"> Insurer <span id="base_danger"
@ -69,6 +69,19 @@ table.dataTable tbody td {
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="addon_policy"> Insurer Branch<span id="base_danger"
class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id">
<option value="0" selected>Select Insurer</option>
<?php if(isset($insurer) && count($insurer)){ ?>
<?php foreach ($insurer as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['name']?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<!-- <div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger"></span></label> <label for="email"> Policy Type <span class="text-danger"></span></label>
<select class="form-control" id="policy_type_id" name="policy_type_id"> <select class="form-control" id="policy_type_id" name="policy_type_id">
<option value="0">Select Policy Type</option> <option value="0">Select Policy Type</option>
@ -80,9 +93,9 @@ table.dataTable tbody td {
} }
?> ?>
</select> </select>
</div> </div> -->
<div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger">*</span></label> <label for="client_branch">Issuer<span class="text-danger">*</span></label>
<select class="form-control" id="issuer" name="issuer" required> <select class="form-control" id="issuer" name="issuer" required>
<option value="0">Select Issure</option> <option value="0">Select Issure</option>
@ -94,13 +107,13 @@ table.dataTable tbody td {
} }
?> ?>
</select> </select>
</div> </div> -->
</div> <!-- </div>
<div class="form-row"> <div class="form-row"> -->
<div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label>Date Type<span class="text-danger"></span></label> <label>Date Type<span class="text-danger"></span></label>
<select class="form-control" id="date_type" name="date_type" <select class="form-control" id="date_type" name="date_type"
onchange="hideDateField()"> onchange="hideDateField()">
@ -113,10 +126,10 @@ table.dataTable tbody td {
} }
?> ?>
</select> </select>
</div> </div> -->
<div class="form-group col-md-3" style="display: none;" id="date_div"> <div class="form-group col-md-3" style="display: true;" id="date_div">
<label>Date<span class="text-danger"></span></label> <label>Statement Month<span class="text-danger"></span></label>
<div id="reportrange" class="form-control" <div id="reportrange" class="form-control"
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%"> style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="fa fa-calendar"></i>&nbsp; <i class="fa fa-calendar"></i>&nbsp;
@ -158,28 +171,36 @@ table.dataTable tbody td {
<thead class="bg-light"> <thead class="bg-light">
<tr> <tr>
<th>S.No</th> <th>S.No</th>
<th>Client Name</th> <!-- <th>Client Name</th> -->
<th>Insurer</th> <th>Insurer</th>
<th>Policy</th> <th>Insurer<br> Branch</th>
<th>Endorsement No</th> <th>Statement<br> Month</th>
<th>Statement<br> No</th>
<th>Invoice No</th>
<th>Invoice Status</th> <th>Invoice Status</th>
<th>Invoice Date</th>
<th>Invoice Amount</th> <th>Invoice Amount</th>
<th>Realization Amount</th> <th>Realization <br>Amount</th>
<th>Outstanding Amount</th> <th>Outstanding <br>Amount</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if (isset($outstanding_list)) { ?> <?php
<?php foreach($outstanding_list as $index => $row){ ?>
// dd($outstanting_list);
if (isset($outstanting_list)) { ?>
<?php foreach($outstanting_list as $index => $row){ ?>
<tr> <tr>
<td><?= $index + 1 ?></td> <td><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td> <td><?php echo $row['short_name']; ?></td>
<td><?php echo $row['insurer_name']; ?></td> <td><?php echo $row['branch_name']; ?></td>
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td> <td><?php echo change_date_format($row['month'],'Y-m-d','Y-m') ?></td>
<td><?php echo $row['endorsement_no']; ?></td> <td><?php echo $row['stmt_sno']; ?></td>
<td><?php echo $row['invoice_no']; ?></td>
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td> <td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
<td><?php echo change_date_format($row['invoice_date'],'Y-m-d','d-M-Y'); ?></td>
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td> <td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td> <td class="right-align-input"><?php echo isset($row['total_paid']) ? $row['total_paid'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td> <td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
@ -364,10 +385,6 @@ $(function() {
startDate: start, startDate: start,
endDate: end, endDate: end,
ranges: { ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')], 'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month') 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
.endOf('month') .endOf('month')

View File

@ -39,6 +39,7 @@
.form-group-client-policy-masters { .form-group-client-policy-masters {
display: -webkit-box; display: -webkit-box;
max-width: 100% !important; max-width: 100% !important;
margin-left: -23px;
} }
.flex-container { .flex-container {
@ -85,9 +86,9 @@
} }
.s { .s {
/* margin-left: 30px; margin-left: 50px;
width: 689px; */ /* width: 689px; */
margin-left: 141px; /* margin-left: 141px; */
width: 576px; width: 576px;
} }
</style> </style>
@ -107,7 +108,7 @@
<div class="form-group"> <div class="form-group">
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-4">
<label for="sumInsured">Sum Insured</label> <label for="sumInsured">Sum Insured</label>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
@ -116,9 +117,9 @@
<div class="col-md-2" style="position: relative;left: 88px;"> <div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button> <button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button>
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
<div id='numberToWordGMC' class="text-danger-2" ></div> <div id='numberToWordGMC' class="text-danger-2" ></div>
</div> </div>
</div> </div>
@ -126,16 +127,16 @@
<div id="gmc_si_add_more"></div> <div id="gmc_si_add_more"></div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-4">
<label for="totalSumInsured">Family Floater</label> <label for="totalSumInsured">Family Floater</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<input type="radio" name="family_floater" class="family_floater" value="1"> Yes <input type="radio" name="family_floater" class="family_floater" value="1"> Yes
<input type="radio" name="family_floater" class="family_floater" value="0" style="margin-left:10px"> No <input type="radio" name="family_floater" class="family_floater" value="0" style="margin-left:10px"> No
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
</div> </div>
<div class="col-md-6" style="margin-bottom:10px"> <div class="col-md-8" style="margin-bottom:10px">
<table> <table>
<tbody> <tbody>
<tr> <tr>
@ -143,12 +144,16 @@
<td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;" name="family_floaters[]" value="self" id="self" checked> </td> <td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;" name="family_floaters[]" value="self" id="self" checked> </td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo (isset($self_min_age) && $self_min_age > 0) ? $self_min_age : '18'; ?>" style="width: 35%;;" type="number" name="self_min_age" id="self_min_age" onchange="lowerIsEighteen(this)"></div></td> <td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo (isset($self_min_age) && $self_min_age > 0) ? $self_min_age : '18'; ?>" style="width: 35%;;" type="number" name="self_min_age" id="self_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 35%;;" type="number" name="self_max_age" id="self_max_age" onchange="lowerIsEighteen(this)"></div></td> <td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 35%;;" type="number" name="self_max_age" id="self_max_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 11%;"><span class="self-age" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td style="width: 11%;"><input class="self-age" type="checkbox" style="margin-right: 70px;" name="is_payable_employee_for_self" id="is_payable_employee_for_self"> </td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr> </tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr> <tr>
<td style="width: 11%;"><span style="margin-right: 20px;">Spouse:</span></td> <td style="width: 11%;"><span style="margin-right: 20px;">Spouse:</span></td>
<td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;"name="family_floaters[]" value="spouse" id="spouse"></td> <td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;"name="family_floaters[]" value="spouse" id="spouse"></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($spouse_min_age) ? $spouse_min_age : '18'; ?>" style="width: 35%;;" type="number" name="spouse_min_age" id="spouse_min_age" onchange="lowerIsEighteen(this)"></div></td> <td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($spouse_min_age) ? $spouse_min_age : '18'; ?>" style="width: 35%;;" type="number" name="spouse_min_age" id="spouse_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($spouse_max_age) ? $spouse_max_age : '60'; ?>" style="width: 35%;;" type="number" name="spouse_max_age" id="spouse_max_age" onchange="lowerIsEighteen(this)"></div></td> <td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($spouse_max_age) ? $spouse_max_age : '60'; ?>" style="width: 35%;;" type="number" name="spouse_max_age" id="spouse_max_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 11%;"><span class="spouse-age" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td style="width: 11%;"><input class="spouse-age" type="checkbox" style="margin-right: 70px;" name="is_payable_employee_for_spouse" id="is_payable_employee_for_spouse"> </td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr> </tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr> <tr>
<td style="width: 11%;"><span for="children">Children:</span></td> <td style="width: 11%;"><span for="children">Children:</span></td>
@ -162,6 +167,8 @@
</td> </td>
<td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($child_min_age) ? $child_min_age : '0'; ?>" style="width: 35%;;" type="number" name="child_min_age" id="child_min_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td> <td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($child_min_age) ? $child_min_age : '0'; ?>" style="width: 35%;;" type="number" name="child_min_age" id="child_min_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
<td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($child_max_age) ? $child_max_age : '25'; ?>" style="width: 35%;;" type="number" name="child_max_age" id="child_max_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td> <td style="width: 28%;" ><div class="child-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($child_max_age) ? $child_max_age : '25'; ?>" style="width: 35%;;" type="number" name="child_max_age" id="child_max_age" oninput="this.value = this.value.replace(/\D/g, '').substring(0, 2)"></div></td>
<td style="width: 11%;"><span class="child-age" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td style="width: 11%;"><input class="child-age" type="checkbox" style="margin-right: 70px;" name="is_payable_employee_for_child" id="is_payable_employee_for_child"> </td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr> </tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
</tbody> </tbody>
</table> </table>
@ -192,6 +199,8 @@
<td style="width: 22%;" ><div class="other-member-age"><span style="margin-right: 20px;">Elders Count:</span><input class="underline-input" id="member_count" style="width: 30%; width: 30%;background: lightgray;" type="number" name="elder_member_count" id="member_count" readonly></div></td> <td style="width: 22%;" ><div class="other-member-age"><span style="margin-right: 20px;">Elders Count:</span><input class="underline-input" id="member_count" style="width: 30%; width: 30%;background: lightgray;" type="number" name="elder_member_count" id="member_count" readonly></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 32px;"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($other_member_min_age) ? $other_member_min_age : '18'; ?>" style="width: 35%;;" type="number" class="underline-input min_age" name="other_member_min_age" id="other_member_min_age" onchange="lowerIsEighteen(this)"></div></td> <td style="width: 28%;" ><div class="other-member-age" style="margin-left: 32px;"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($other_member_min_age) ? $other_member_min_age : '18'; ?>" style="width: 35%;;" type="number" class="underline-input min_age" name="other_member_min_age" id="other_member_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 17px;"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($other_member_max_age) ? $other_member_max_age : '60'; ?>" style="width: 35%;;" type="number" class="underline-input max_age" name="other_member_max_age" id="other_member_max_age" onchange="lowerIsEighteen(this)"></div></td> <td style="width: 28%;" ><div class="other-member-age" style="margin-left: 17px;"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($other_member_max_age) ? $other_member_max_age : '60'; ?>" style="width: 35%;;" type="number" class="underline-input max_age" name="other_member_max_age" id="other_member_max_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 11%;"><span class="other-member-age" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td style="width: 11%;"><input class="other-member-age" type="checkbox" style="margin-right: 70px;" name="is_payable_employee_for_elders" id="is_payable_employee_for_elders"> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -202,7 +211,7 @@
<hr> <hr>
<!-- <div class="row" style="margin-bottom: 10px;display:none;"> <!-- <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-4">
<label for="totalSumInsured">Corporate Buffer</label> <label for="totalSumInsured">Corporate Buffer</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -213,7 +222,10 @@
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="waiverofpreexistingdiseases_display" id="waiverofpreexistingdiseases_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Waiver of Pre-existing Diseases</label> <label for="totalSumInsured">Waiver of Pre-existing Diseases</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -223,16 +235,22 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="maternitycoverage_display" id="maternitycoverage_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Maternity Coverage</label> <label for="totalSumInsured">Maternity Coverage</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
<input type="text" name="maternitycoverage" id="maternitycoverage" class="form-control"> <input type="text" name="maternitycoverage" id="maternitycoverage" class="form-control">
</div> </div>
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="twindelivery_display" id="twindelivery_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Twin Delivery</label> <label for="totalSumInsured">Twin Delivery</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -241,7 +259,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="preandpostnatal_display" id="preandpostnatal_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Pre and Post natal</label> <label for="totalSumInsured">Pre and Post natal</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -250,7 +271,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="babyday1cover_display" id="babyday1cover_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Baby Day 1 Cover</label> <label for="totalSumInsured">Baby Day 1 Cover</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -258,9 +282,11 @@
</div> </div>
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="9monthwaitingperiodwaived_display" id="9monthwaitingperiodwaived_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">9-month waiting Period waived</label> <label for="totalSumInsured">9-month waiting Period waived</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -270,7 +296,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="coverfromthedateofjoining_display" id="coverfromthedateofjoining_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Cover from the date of Joining</label> <label for="totalSumInsured">Cover from the date of Joining</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -279,7 +308,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="waiverof1234thyearexclusions_display" id="waiverof1234thyearexclusions_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Waiver of 1, 2, 3 & 4th year Exclusions</label> <label for="totalSumInsured">Waiver of 1, 2, 3 & 4th year Exclusions</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -290,7 +322,10 @@
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="waiverof30dayswaitingperiod_display" id="waiverof30dayswaitingperiod_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Waiver of 30 days waiting period</label> <label for="totalSumInsured">Waiver of 30 days waiting period</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -300,7 +335,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="prehospitalizationcover_display" id="prehospitalizationcover_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Pre Hospitalization Cover</label> <label for="totalSumInsured">Pre Hospitalization Cover</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -309,7 +347,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="posthospitalizationcover_display" id="posthospitalizationcover_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Post Hospitalization Cover</label> <label for="totalSumInsured">Post Hospitalization Cover</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -318,7 +359,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="congenitaldiseasesinternal_display" id="congenitaldiseasesinternal_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Congenital Diseases - Internal</label> <label for="totalSumInsured">Congenital Diseases - Internal</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -328,7 +372,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="congenitaldiseasesexternal_display" id="congenitaldiseasesexternal_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Congenital Diseases - External</label> <label for="totalSumInsured">Congenital Diseases - External</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -337,7 +384,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="copayzonewisecopay_display" id="copayzonewisecopay_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Co-Pay/Zone wise Co Pay</label> <label for="totalSumInsured">Co-Pay/Zone wise Co Pay</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -346,8 +396,11 @@
</div> </div>
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="co_pay_details_display" id="co_pay_details_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Co-pay Details</label> <label for="totalSumInsured">Co-pay Details</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -356,7 +409,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="bioabsorbablestenttoriclensmultifocallens_display" id="bioabsorbablestenttoriclensmultifocallens_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Bio absorbable stent / Toric lens/ Multi Focal lens</label> <label for="totalSumInsured">Bio absorbable stent / Toric lens/ Multi Focal lens</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -365,7 +421,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="roomrentlimit_display" id="roomrentlimit_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Room Rent Limit</label> <label for="totalSumInsured">Room Rent Limit</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -374,7 +433,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="proportionatedeductionclause_display" id="proportionatedeductionclause_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Proportionate Deduction Clause</label> <label for="totalSumInsured">Proportionate Deduction Clause</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -387,7 +449,7 @@
</div> </div>
<!-- <div class="row" style="margin-bottom: 10px;"> <!-- <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-4">
<label for="totalSumInsured">Nursing Allowance</label> <label for="totalSumInsured">Nursing Allowance</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -396,7 +458,10 @@
</div> --> </div> -->
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="ailmentcapping_display" id="ailmentcapping_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Ailment capping</label> <label for="totalSumInsured">Ailment capping</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -405,8 +470,11 @@
</div> </div>
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="ailment_capping_details_display" id="ailment_capping_details_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Ailment capping Details</label> <label for="totalSumInsured">Ailment capping Details</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -415,7 +483,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="corporatebuffer_display" id="corporatebuffer_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Corporate Buffer</label> <label for="totalSumInsured">Corporate Buffer</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -424,7 +495,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="sublimitofcorporatebuffer_display" id="sublimitofcorporatebuffer_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Sublimit of Corporate Buffer</label> <label for="totalSumInsured">Sublimit of Corporate Buffer</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -433,7 +507,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="ambulancecharges_display" id="ambulancecharges_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Ambulance Charges</label> <label for="totalSumInsured">Ambulance Charges</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -442,7 +519,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="airambulance_display" id="airambulance_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Air Ambulance</label> <label for="totalSumInsured">Air Ambulance</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -451,7 +531,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="familytransportationbenefit_display" id="familytransportationbenefit_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Family Transportation Benefit</label> <label for="totalSumInsured">Family Transportation Benefit</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -460,7 +543,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="reasonableandcustomarycharges_display" id="reasonableandcustomarycharges_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Reasonable and Customary Charges</label> <label for="totalSumInsured">Reasonable and Customary Charges</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -470,7 +556,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="daycaretreatment_display" id="daycaretreatment_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Day Care Treatment</label> <label for="totalSumInsured">Day Care Treatment</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -480,7 +569,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="ayudhtreatmentcover_display" id="ayudhtreatmentcover_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">AYUSH treatment cover</label> <label for="totalSumInsured">AYUSH treatment cover</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -489,8 +581,11 @@
</div> </div>
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="ayushTreatmentCoverData_display" id="ayushTreatmentCoverData_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">AYUSH treatment cover Limit</label> <label for="totalSumInsured">AYUSH treatment cover Limit</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -499,7 +594,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="armdcovered_display" id="armdcovered_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">ARMD Covered</label> <label for="totalSumInsured">ARMD Covered</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -508,7 +606,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="suminsuredenhancement_display" id="suminsuredenhancement_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Sum Insured enhancement</label> <label for="totalSumInsured">Sum Insured enhancement</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -518,7 +619,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="automaticsuminsuredreinstatement_display" id="automaticsuminsuredreinstatement_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Automatic Sum Insured reinstatement</label> <label for="totalSumInsured">Automatic Sum Insured reinstatement</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -527,7 +631,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="additionalsicknessbenefit_display" id="additionalsicknessbenefit_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Additional Sickness Benefit</label> <label for="totalSumInsured">Additional Sickness Benefit</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -536,7 +643,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="lasiksurgery_display" id="lasiksurgery_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Lasik Surgery</label> <label for="totalSumInsured">Lasik Surgery</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -545,7 +655,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="midterminclusion_display" id="midterminclusion_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Mid Term inclusion</label> <label for="totalSumInsured">Mid Term inclusion</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -554,7 +667,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="capd_display" id="capd_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">CAPD</label> <label for="totalSumInsured">CAPD</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -563,7 +679,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="organdonorexpenses_display" id="organdonorexpenses_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Organ donor expenses</label> <label for="totalSumInsured">Organ donor expenses</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -572,7 +691,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="moderntreatmentsasperirdai_display" id="moderntreatmentsasperirdai_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Modern treatments as per IRDAI</label> <label for="totalSumInsured">Modern treatments as per IRDAI</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -581,7 +703,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="Wellness_display" id="Wellness_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Wellness</label> <label for="totalSumInsured">Wellness</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -590,7 +715,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="days_of_discharge_display" id="days_of_discharge_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Claim Intimation Clause</label> <label for="totalSumInsured">Claim Intimation Clause</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -600,7 +728,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="days_from_dod_display" id="days_from_dod_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Claim Submission</label> <label for="totalSumInsured">Claim Submission</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -610,7 +741,10 @@
</div> </div>
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="cataract_display" id="cataract_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Cataract</label> <label for="totalSumInsured">Cataract</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -619,8 +753,11 @@
</div> </div>
</div> </div>
<div class="row" style="margin-bottom: 10px;display:none;"> <div class="row" style="margin-bottom: 10px;display:none;">
<div class="col-md-6"> <div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="cataractData_display" id="cataractData_display" checked>
</div>
<div class="col-md-4">
<label for="totalSumInsured">Cataract Limit</label> <label for="totalSumInsured">Cataract Limit</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -962,6 +1099,7 @@
} }
if (key.includes("family_floaters")) { if (key.includes("family_floaters")) {
let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`); let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`);
if (jsonObject[key]) { if (jsonObject[key]) {
@ -996,6 +1134,8 @@
$('#family_floaters').val('1PIL'); $('#family_floaters').val('1PIL');
} else if (jsonObject[key]['parents-in-law'] == 2) { } else if (jsonObject[key]['parents-in-law'] == 2) {
$('#family_floaters').val('2PIL'); $('#family_floaters').val('2PIL');
} else if (jsonObject[key]['either-parents-pil'] == 2) {
$('#family_floaters').val('4EPORPIL');
} }
} }
@ -1129,8 +1269,43 @@
$('#other_member_max_age').val(jsonObject[key].elders.max); $('#other_member_max_age').val(jsonObject[key].elders.max);
} }
if (key.includes("is_payable_employee")) {
if (jsonObject[key]) {
if (jsonObject[key].self == 0) {
$('#is_payable_employee_for_self').prop('checked', false);
}else {
$('#is_payable_employee_for_self').prop('checked', true);
}
if (jsonObject[key].spouse == 0) {
$('#is_payable_employee_for_spouse').prop('checked', false);
} else {
$('#is_payable_employee_for_spouse').prop('checked', true);
}
if (jsonObject[key].childern == 0) {
$('#is_payable_employee_for_child').prop('checked', false);
} else {
$('#is_payable_employee_for_child').prop('checked', true);
}
if (jsonObject[key].elders == 0) {
$('#is_payable_employee_for_elders').prop('checked', false);
} else {
$('#is_payable_employee_for_elders').prop('checked', true);
}
}
}
}); });
} }
$("#sum_insured").trigger("keyup"); $("#sum_insured").trigger("keyup");
$(".multiple_sum_insured").trigger("keyup"); $(".multiple_sum_insured").trigger("keyup");
@ -1308,6 +1483,9 @@
var index = $('.modifyclassinput').length; var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom"> var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="special_condition_display_input[]" id="special_condition_display_input" checked>
</div>
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;"> <label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 5px;"> <input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 5px;">
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span> <span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
@ -1446,7 +1624,7 @@
var html = ` var html = `
<div class="row" style="margin-bottom: 10px;"> <div class="row" style="margin-bottom: 10px;">
<div class="col-md-6"> <div class="col-md-4">
<label for="sumInsured">Additional Sum Insured</label> <label for="sumInsured">Additional Sum Insured</label>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
@ -1456,9 +1634,9 @@
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button> <button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
<button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button> <button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button>
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
<div class="text-danger-2 numberToWordSumInsured"></div> <div class="text-danger-2 numberToWordSumInsured"></div>
</div> </div>
</div>`; </div>`;

View File

@ -101,7 +101,7 @@
<div class="form-group"> <div class="form-group">
<div class="form-row" id="rac_rate_dropdown"> <div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-6"> <div class="form-group col-md-4">
<label for="emp_code">Policy Premium Type<span <label for="emp_code">Policy Premium Type<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" id="grid" name="policy_grid_id" <select class="form-control" id="grid" name="policy_grid_id"
@ -109,15 +109,16 @@
</select> </select>
</div> </div>
<div class="form-group col-md-4" <div class="form-group col-md-6"
style="position: relative; left: 45px; display:none" id="premium_type"> style="position: relative; left: 45px; display:none" id="premium_type">
<label for="css"> Premium Calculation </label> <label for="css"> Premium Calculation </label>
<div style="display: flex; align-items: center;"> <div style="display: flex; align-items: center;">
<input type="radio" id="individual" name="premium_type" value="2"> <input type="radio" id="individual" name="premium_type" value="2">
<label for="individual" style="position: relative;top: 5px;left: 5px;"> <label for="individual" style="position: relative;top: 5px;left: 5px;">Individual </label>&nbsp;
Individual </label>&nbsp;
<input type="radio" id="single" name="premium_type" value="1"> <input type="radio" id="single" name="premium_type" value="1">
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater </label> <label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater </label>
<input type="radio" id="single_and_individual" name="premium_type" value="3">
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater cum Individual </label>
</div> </div>
</div> </div>
</div> </div>
@ -1899,24 +1900,25 @@ function removebutton(index, type)
function checkDuplicate(unique_id = null) function checkDuplicate(unique_id = null)
{ {
console.log('checkDuplicate unique_id', unique_id) console.log('checkDuplicate function called')
// console.log('checkDuplicate unique_id', unique_id)
var id = $('#grid')[0]; var id = $('#grid')[0];
var container = $('#grid_content_input'); var container = $('#grid_content_input');
console.log('checkDuplicate id 1', id); // console.log('checkDuplicate id 1', id);
console.log('checkDuplicate container 1', container); // console.log('checkDuplicate container 1', container);
if (unique_id) { if (unique_id) {
id = $('#grid_'+unique_id)[0]; id = $('#grid_'+unique_id)[0];
container = $('#grid_content_input_for_additional_'+unique_id); container = $('#grid_content_input_for_additional_'+unique_id);
console.log('checkDuplicate id 2', id); // console.log('checkDuplicate id 2', id);
console.log('checkDuplicate container 2', container); // console.log('checkDuplicate container 2', container);
} }
console.log('checkDuplicate id 3', id); // console.log('checkDuplicate id 3', id);
console.log('checkDuplicate container 3', container); // console.log('checkDuplicate container 3', container);
// var highlightDuplicates = function(duplicateIndices) { // var highlightDuplicates = function(duplicateIndices) {
// duplicateIndices.forEach(index => { // duplicateIndices.forEach(index => {
@ -2328,7 +2330,7 @@ function checkDuplicate(unique_id = null)
} else if (id.value === '12'){ } else if (id.value === '12'){
var siInputs = container.find('input[name="12_si[]"]'); var siInputs = container.find('input[name="12_si[]"]');
var relationship = container.find('input[name="12_relationship[]"]'); var relationship = container.find('select[name="12_relationship[]"]');
var units = container.find('input[name="12_unit[]"]'); var units = container.find('input[name="12_unit[]"]');
var siValues = []; var siValues = [];
@ -2350,9 +2352,15 @@ function checkDuplicate(unique_id = null)
unitValues.push(value); unitValues.push(value);
}); });
// console.log('siInputs array', siInputs)
// console.log('relationship array', relationship)
// console.log('units array', units)
for (var i = 0; i < siValues.length; i++) { for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) { for (var j = i + 1; j < siValues.length; j++) {
if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && relationshipValue[i] === relationshipValue[j]) { if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && relationshipValue[i] === relationshipValue[j]) {
console.log('depulicate si :', siValues[i])
console.log('depulicate relation :', relationshipValue[i])
duplicatesFound = true; duplicatesFound = true;
} }
} }
@ -2364,10 +2372,11 @@ function checkDuplicate(unique_id = null)
} else { } else {
return false; return false;
} }
} else if (id.value === '13'){ } else if (id.value === '13'){
var siInputs = container.find('input[name="13_si[]"]'); var siInputs = container.find('input[name="13_si[]"]');
var relationship = container.find('input[name="13_relationship[]"]'); var relationship = container.find('select[name="13_relationship[]"]');
var units = container.find('input[name="13_unit[]"]'); var units = container.find('input[name="13_unit[]"]');
var ageFrom = container.find('input[name="13_age_from[]"]'); var ageFrom = container.find('input[name="13_age_from[]"]');
var ageTo = container.find('input[name="13_age_to[]"]'); var ageTo = container.find('input[name="13_age_to[]"]');
@ -2404,12 +2413,8 @@ function checkDuplicate(unique_id = null)
for (var i = 0; i < siValues.length; i++) { for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) { for (var j = i + 1; j < siValues.length; j++) {
if (unitValues[i] === unitValues[j] && if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && relationshipValue[i] === relationshipValue[j] && fromAgeValue[i] === fromAgeValue[j] && toAgeValue[i] === toAgeValue[j])
siValues[i] === siValues[j] && {
relationshipValue[i] === relationshipValue[j] &&
fromAgeValue[i] === fromAgeValue[j] &&
toAgeValue[i] === toAgeValue[j]
) {
duplicatesFound = true; duplicatesFound = true;
} }
} }
@ -3332,7 +3337,7 @@ function appendNewTab(tabNameData = null, data = null)
<div class="form-group"> <div class="form-group">
<div class="form-row" id="rac_rate_dropdown_${tabId}"> <div class="form-row" id="rac_rate_dropdown_${tabId}">
<div class="form-group col-md-6"> <div class="form-group col-md-4">
<label for="emp_code">Policy Premium Type<span <label for="emp_code">Policy Premium Type<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" id="grid_${tabId}" name="policy_grid_id" <select class="form-control" id="grid_${tabId}" name="policy_grid_id"
@ -3340,7 +3345,7 @@ function appendNewTab(tabNameData = null, data = null)
</select> </select>
</div> </div>
<div class="form-group col-md-4" <div class="form-group col-md-6"
style="position: relative; left: 45px; display:none" id="premium_type_${tabId}"> style="position: relative; left: 45px; display:none" id="premium_type_${tabId}">
<label for="css"> Premium Calculation </label> <label for="css"> Premium Calculation </label>
<div style="display: flex; align-items: center;"> <div style="display: flex; align-items: center;">
@ -3349,6 +3354,8 @@ function appendNewTab(tabNameData = null, data = null)
Individual </label>&nbsp; Individual </label>&nbsp;
<input type="radio" id="single_${tabId}" name="premium_type" value="1"> <input type="radio" id="single_${tabId}" name="premium_type" value="1">
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater </label> <label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater </label>
<input type="radio" id="single_and_individual_${tabId}" name="premium_type" value="3">
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater cum Individual </label>
</div> </div>
</div> </div>
</div> </div>
@ -3727,18 +3734,27 @@ function editPolicyPremiumCalculationSetValue(premium_type, unique_id = null)
// console.log('editPolicyPremiumCalculationSetValue step 1'); // console.log('editPolicyPremiumCalculationSetValue step 1');
if (premium_type === '2') { if (premium_type === '2') {
// console.log('editPolicyPremiumCalculationSetValue step 2'); // console.log('editPolicyPremiumCalculationSetValue step 2');
$('#individual_'+unique_id).prop('checked', true);
$('#single_'+unique_id).prop('checked', false); $('#single_'+unique_id).prop('checked', false);
$('#individual_'+unique_id).prop('checked', true);
$('#single_and_individual_'+unique_id).prop('checked', false);
} else if (premium_type === '1') { } else if (premium_type === '1') {
// console.log('editPolicyPremiumCalculationSetValue step 3'); // console.log('editPolicyPremiumCalculationSetValue step 3');
$('#single_'+unique_id).prop('checked', true); $('#single_'+unique_id).prop('checked', true);
$('#individual_'+unique_id).prop('checked', false); $('#individual_'+unique_id).prop('checked', false);
$('#single_and_individual_'+unique_id).prop('checked', false);
}else if (premium_type === '3') {
// console.log('editPolicyPremiumCalculationSetValue step 3');
$('#single_'+unique_id).prop('checked', false);
$('#individual_'+unique_id).prop('checked', false);
$('#single_and_individual_'+unique_id).prop('checked', true);
} else { } else {
// console.log('editPolicyPremiumCalculationSetValue step 4'); // console.log('editPolicyPremiumCalculationSetValue step 4');
$('#single_'+unique_id).prop('checked', false); $('#single_'+unique_id).prop('checked', false);
$('#individual_'+unique_id).prop('checked', true); $('#individual_'+unique_id).prop('checked', true);
$('#single_and_individual_'+unique_id).prop('checked', false);
} }
}else{ }else{
@ -3746,18 +3762,27 @@ function editPolicyPremiumCalculationSetValue(premium_type, unique_id = null)
// console.log('editPolicyPremiumCalculationSetValue step 5'); // console.log('editPolicyPremiumCalculationSetValue step 5');
if (premium_type === '2') { if (premium_type === '2') {
// console.log('editPolicyPremiumCalculationSetValue step 6'); // console.log('editPolicyPremiumCalculationSetValue step 6');
$('#individual').prop('checked', true);
$('#single').prop('checked', false); $('#single').prop('checked', false);
$('#individual').prop('checked', true);
$('#single_and_individual').prop('checked', false);
} else if (premium_type === '1') { } else if (premium_type === '1') {
// console.log('editPolicyPremiumCalculationSetValue step 7'); // console.log('editPolicyPremiumCalculationSetValue step 7');
$('#single').prop('checked', true); $('#single').prop('checked', true);
$('#individual').prop('checked', false); $('#individual').prop('checked', false);
$('#single_and_individual').prop('checked', false);
}else if (premium_type === '3') {
// console.log('editPolicyPremiumCalculationSetValue step 7');
$('#single').prop('checked', false);
$('#individual').prop('checked', false);
$('#single_and_individual').prop('checked', true);
} else { } else {
// console.log('editPolicyPremiumCalculationSetValue step 8'); // console.log('editPolicyPremiumCalculationSetValue step 8');
$('#single').prop('checked', false); $('#single').prop('checked', false);
$('#individual').prop('checked', true); $('#individual').prop('checked', true);
$('#single_and_individual').prop('checked', false);
} }

View File

@ -36,6 +36,73 @@ table.dataTable thead th {
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style> </style>
<div class="row" id="endorsement_filter"> <div class="row" id="endorsement_filter">
@ -232,7 +299,96 @@ table.dataTable thead th {
<!-- end table row --> <!-- end table row -->
<?php include('policy_transaction_endorsement_form.php'); ?> <?php include('policy_transaction_endorsement_form.php'); ?>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
var client_list = ''; // local variable for storing the client branch list var client_list = ''; // local variable for storing the client branch list

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,77 @@ table.dataTable tbody td {
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.addbtnStyle{
margin-left: 20px !important;
}
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style> </style>
<style> <style>
@ -240,7 +311,7 @@ table.dataTable tbody td {
</div> </div>
<div class="col-3" id="status_change" style="text-align: right; position: relative;top: 56px; left: 291px;"> <div class="col-3" id="status_change" style="text-align: right; position: relative;top: 56px; left: 291px;">
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add();">Add</button> <!-- <button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add();">Add</button> -->
</div> </div>
</div> </div>
<div> <div>
@ -335,6 +406,95 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
</div> </div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
@ -420,17 +580,27 @@ $(document).ready(function() {
if (ticketsTable.length) { if (ticketsTable.length) {
ticketsTable.DataTable({ ticketsTable.DataTable({
scrollX: true, scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{ buttons: [
extend: 'csv', {
text: 'CSV', extend: 'csv',
title: 'Policy-Tranction-Inception-List', text: 'CSV',
exportOptions: { title: 'Policy-Tranction-Inception-List',
columns: ':not(:last-child)' exportOptions: {
}, columns: ':not(:last-child)'
}, ], },
},
{
text: 'Add',
className: 'buttons-html5 addbtnStyle',
action: function (e, dt, node, config) {
hide_list_show_add();
}
}
],
language: { language: {
search: "_INPUT_", search: "_INPUT_",
searchPlaceholder: "Search..." searchPlaceholder: "Search..."

View File

@ -1,3 +1,71 @@
<style>
.custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="policy_list"> <div class="row" id="policy_list">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
@ -51,6 +119,90 @@
</div> </div>
<!-- end row --> <!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){

View File

@ -27,7 +27,7 @@ table.dataTable tbody td {
<div class="card-body"> <div class="card-body">
<div class="row" style="padding-bottom: 10px;"> <div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;"> <div class="col-6" style="align-self: center;">
<h4 style="position: relative;">BDS Report</h4> <h4 style="position: relative;">BDS Report <span id="bds_title"></span></h4>
</div> </div>
</div> </div>
@ -62,17 +62,9 @@ table.dataTable tbody td {
<th>Base <br> Revenue %</th> <th>Base <br> Revenue %</th>
<th>TP / Terrorism <br> Revenue %</th> <th>TP / Terrorism <br> Revenue %</th>
<th>Total IRDA <br> Revenue INR</th> <th>Total IRDA <br> Revenue INR</th>
<th>GST on Revenue</th> <th>Billed Amount</th>
<th>Total Amount <br> Receivable</th> <th>UnBilled Amount</th>
<th>Rewards</th> <th>Rewards</th>
<th>Invoice Number</th>
<th>Invoice Date</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Outstanding Amount</th>
<th>Payment Status</th>
<th>UTR</th>
<th>Payment Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -105,28 +97,11 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['total_premium']; ?></td> <td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?>&nbsp;%</td> <td class="right-align-input"><?php echo $row['agreed_bp_per']; ?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td> <td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['total_irda']; ?></td> <td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; ?></td>
<td class="right-align-input"><?php echo $row['gst_on_revenue']; ?></td> <td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
<td class="right-align-input"><?php echo $row['total_amt_received']; ?></td> <!-- <td class="right-align-input"><?php echo empty($row['unbilled_amt']) ? '0.00' : $row['unbilled_amt']?></td> -->
<td class="right-align-input"><?php echo number_format((float)$row['total_irda_amt'] - $row['billed_amt'],2, '.', '')?></td>
<td class="right-align-input"><?php echo $row['reward']; ?></td> <td class="right-align-input"><?php echo $row['reward']; ?></td>
<td><?php echo $row['invoice_no']; ?></td>
<td><?php echo empty($row['invoice_date']) ? '' : date('d/m/Y', strtotime($row['invoice_date'])); ?></td>
<td class="right-align-input"><?php echo $row['invoice_amount']; ?></td>
<td class="right-align-input"><?php echo $row['realization_amount']; ?></td>
<td class="right-align-input"><?php echo $row['outstanding_amount']; ?></td>
<td>
<?php
if($row['outstanding_amount'] == '0.00'){
echo 'Payment Received';
}else if($row['outstanding_amount'] == NULL){
echo '';
}else{
echo 'Partially Received';
}
?>
</td>
<td><?php echo $row['utr_numbers']; ?></td>
<td><?php echo $row['payment_dates']; ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -140,6 +115,38 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
<!-- modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Statement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="bg-light" id="table_head_data">
<tr>
<th>Statement No.</th>
<th>Statement Month</th>
<th>Actual Amount</th>
<th>Invoice No.</th>
<th>Invoice Date.</th>
<th>Invoice Status.</th>
</tr>
</thead>
<tbody id="table_data">
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-------------------------------------------------------------------------------------------------->
<script> <script>
// Datatable document ready // Datatable document ready
$(document).ready(function() { $(document).ready(function() {
@ -197,8 +204,68 @@ $(document).ready(function() {
ordering: false, ordering: false,
}); });
} else { } else {
console.error("Table not found."); console.error("Table atet found.");
} }
}); });
// ----------------------------------------------------------------------------------------------------
function showCoShareStatementDetails(input){
let pt_id = $(input).data('id');
console.log('pt_id', pt_id)
var myModal = new bootstrap.Modal(document.getElementById('centermodal'));
myModal.show();
getCoShareStatementDetails(pt_id)
}
function getCoShareStatementDetails(pt_id){
let url = '<?= base_url('util/getCoShareStatementDetails/') ?>' + pt_id;
sendAjaxRequestForGlobal(url, 'GET', {}, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendTableData(response.data)
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
function appendTableData(data) {
// Ensure the table body selector matches your table's structure
let tableBody = $("#table_data");
// Clear the table body before appending new rows
tableBody.empty();
// Loop through the data and append rows
data.forEach(row => {
let tableRow = `
<tr>
<td>${row.stmt_sno ?? '-'}</td>
<td>${row.month ?? '-'}</td>
<td>${row.sum_of_actual_amt ?? '-'}</td>
<td>${row.invoice_no ?? '-'}</td>
<td>${row.invoice_date ?? '-'}</td>
<td>${row.invoice_status ?? '-'}</td>
</tr>
`;
tableBody.append(tableRow);
});
}
</script> </script>

View File

@ -22,31 +22,35 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger"></span></label> <label for="client_branch">Client<span class="text-danger"></span></label>
<select class="form-control" id="client_id" name="client_id" > <select class="form-control" id="client_id" name="client_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client</option> <option value="0">Select Client</option>
<?php
if (isset($clients) && count($clients)) {
foreach ($clients as $key => $value) {
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
}
}
?>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="addon_policy"> Insurer <span id="base_danger" class="text-danger"></span></label> <label for="client_branch_id">Client Branch<span class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id" > <select class="form-control" id="client_branch_id" name="client_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="insurer_id"> Insurer <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()" >
<option value="0" selected>Select Insurer</option> <option value="0" selected>Select Insurer</option>
<?php foreach ($insurer as $value) { ?> </select>
<option value="<?= $value['id']?>"><?= $value['name']?></option> </div>
<?php } ?>
<div class="form-group col-md-3">
<label for="insurer_branch_id"> Insurer Branch <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_branch_id" name="insurer_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0" selected>Select Insurer Branch</option>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger"></span></label> <label for="email"> Policy Type <span class="text-danger"></span></label>
<select class="form-control" id="policy_type_id" name="policy_type_id" > <select class="form-control" id="policy_type_id" name="policy_type_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Policy Type</option> <option value="0">Select Policy Type</option>
<?php <?php
if (isset($policy_types) && count($policy_types)) { if (isset($policy_types) && count($policy_types)) {
@ -58,6 +62,13 @@
</select> </select>
</div> </div>
<div class="form-group col-md-3">
<label for="client_policy_id"> Client Policy <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="client_policy_id" name="client_policy_id" >
<option value="0" selected>Select client policy</option>
</select>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger">*</span></label> <label for="client_branch">Issuer<span class="text-danger">*</span></label>
<select class="form-control" id="issuer" name="issuer" required> <select class="form-control" id="issuer" name="issuer" required>
@ -72,13 +83,10 @@
</select> </select>
</div> </div>
</div>
<div class="form-row">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label>Date Type<span class="text-danger"></span></label> <label>Date Type<span class="text-danger"></span></label>
<select class="form-control" id="date_type" name="date_type" onchange="hideDateField()"> <select class="form-control" id="date_type" name="date_type" onchange="hideDateField(); changeTitle();">
<option value="0">Select Date Type</option> <option value="0">Select Date Type</option>
<?php <?php
if (isset($date_type) && count($date_type)) { if (isset($date_type) && count($date_type)) {
@ -100,7 +108,7 @@
<input type="hidden" id="endDate"> <input type="hidden" id="endDate">
</div> </div>
<div class="form-group col-md-3 text-right m-b-0" style="margin-top: 29px;"> <div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
<a href="<?= base_url("/policy_tranction/report/list"); ?>" class="btn btn-secondary" id="clear-filters">Clear</a> <a href="<?= base_url("/policy_tranction/report/list"); ?>" class="btn btn-secondary" id="clear-filters">Clear</a>
<a href="<?= base_url("/policy_tranction/report/list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a> <a href="<?= base_url("/policy_tranction/report/list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
</div> </div>
@ -130,11 +138,23 @@
<script> <script>
let client_list = [];
let branch_list = [];
let policy_list = [];
let insurer_list = [];
let insurer_branch_list = [];
$(document).ready(function() { $(document).ready(function() {
getClientAndBranchAndPolicy()
getURLParams() getURLParams()
$('#client_id').select2(); $('#client_id').select2();
$('#client_branch_id').select2();
$('#insurer_id').select2(); $('#insurer_id').select2();
$('#insurer_branch_id').select2();
$('#policy_type_id').select2(); $('#policy_type_id').select2();
$('#client_policy_id').select2();
}) })
function fetchEmpolyeeList(event) function fetchEmpolyeeList(event)
@ -148,6 +168,9 @@ function fetchEmpolyeeList(event)
var policy_type_id = $('#policy_type_id').val(); var policy_type_id = $('#policy_type_id').val();
var date_type = $('#date_type').val(); var date_type = $('#date_type').val();
var issuer = $('#issuer').val(); var issuer = $('#issuer').val();
var client_branch_id = $('#client_branch_id').val();
var insurer_branch_id = $('#insurer_branch_id').val();
var client_policy_id = $('#client_policy_id').val();
console.log(start_date + '-' + end_date); console.log(start_date + '-' + end_date);
@ -159,6 +182,9 @@ function fetchEmpolyeeList(event)
policy_type_id: policy_type_id, policy_type_id: policy_type_id,
date_type: date_type, date_type: date_type,
issuer: issuer, issuer: issuer,
client_branch_id: client_branch_id,
insurer_branch_id: insurer_branch_id,
client_policy_id: client_policy_id,
}; };
const queryString = objectToQueryString(queryParams); const queryString = objectToQueryString(queryParams);
@ -184,6 +210,9 @@ function getURLParams()
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found const issuer = params.get('issuer') || 0; // Default to 0 if not found
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
hideDateField(date_type) hideDateField(date_type)
@ -194,6 +223,9 @@ function getURLParams()
console.log('policy_type_id', policy_type_id) console.log('policy_type_id', policy_type_id)
console.log('date_type', date_type) console.log('date_type', date_type)
console.log('issuer', issuer) console.log('issuer', issuer)
console.log('client_branch_id', client_branch_id)
console.log('insurer_branch_id', insurer_branch_id)
console.log('client_policy_id', client_policy_id)
// Log the values or use them as needed // Log the values or use them as needed
console.log('Start Date:', startDate); console.log('Start Date:', startDate);
@ -203,11 +235,18 @@ function getURLParams()
setTimeout(function(){ setTimeout(function(){
$('#start_date').val(startDate) $('#start_date').val(startDate)
$('#end_date').val(endDate) $('#end_date').val(endDate)
$('#client_id').val(client_id).change() $('#client_id').val(client_id).select2()
$('#insurer_id').val(insurer_id).change() $('#insurer_id').val(insurer_id).select2()
$('#policy_type_id').val(policy_type_id).change() $('#policy_type_id').val(policy_type_id).select2()
$('#date_type').val(date_type) $('#date_type').val(date_type).trigger('change');
$('#issuer').val(issuer) $('#issuer').val(issuer)
setTimeout(function(){
$('#client_branch_id').val(client_branch_id).select2()
$('#insurer_branch_id').val(insurer_branch_id).select2()
setTimeout(function(){
$('#client_policy_id').val(client_policy_id).select2();
}, 1000);
}, 2000)
},1000) },1000)
} }
@ -283,4 +322,225 @@ function hideDateField(input = null)
} }
} }
// -----------------------------------------------------------------------------------------------
//featch client, client branch, insurer, insurer branch and client policy list data
function getClientAndBranchAndPolicy()
{
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
insurer_list = res.insurer_data;
insurer_branch_list = res.insurer_branch_data;
appendClients(res.client_data);
appendInsurer(res.insurer_data);
}else{
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
//append clients for filter
function appendClients(data)
{
$('#client_id').empty();
$('#client_id').append($('<option>', {
value: '',
text: 'Select Client'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
'data-cn': item.client_name,
'data-ct': item.client_type,
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
});
$('#client_id').append(option);
});
}
//append clients branch for filter
function appendBranch(data)
{
$('#client_branch_id').empty();
$('#client_branch_id').append($('<option>', {
value: '',
text: 'Select Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#client_branch_id').append(option);
});
}
//append insurer for filter
function appendInsurer(data)
{
$('#insurer_id').empty();
$('#insurer_id').append($('<option>', {
value: '',
text: 'Select Insurer'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.name,
});
$('#insurer_id').append(option);
});
}
//append insurer branch for filter
function appendInsurerBranch(data)
{
$('#insurer_branch_id').empty();
$('#insurer_branch_id').append($('<option>', {
value: '',
text: 'Select Insurer Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#insurer_branch_id').append(option);
});
}
//append client policy for filter
function appendPolicies(data)
{
// console.log('appendPolicies', data);
// console.log('appendPolicies', $('#client_policy_id'));
$('#client_policy_id').empty();
$('#client_policy_id').append($('<option>', {
value: '',
text: 'Select Policy',
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#client_policy_id').append(option);
});
}
// -------------------------------------------------------------------------------------------------
//client branch and insurer branch onchange document ready function
$(document).ready(function(){
$('#client_id').change(function(){
let client_id = $(this).val();
console.log('client_id', client_id);
if(branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch(data);
}
})
$('#insurer_id').change(function(){
let insurer_id = $(this).val();
console.log('insurer_id', insurer_id);
if(insurer_branch_list != '') {
// console.log(insurer_branch_list[insurer_id]);
let data = insurer_branch_list[insurer_id];
appendInsurerBranch(data);
}
})
});
//get policy list based on the client, client_branch, insurer, insurer_branch and policy type
function getClientPolicyDataBasedOnClientAndInsuer(){
let client_id = $('#client_id').val() ?? 0;
let client_branch_id = $('#client_branch_id').val() ?? 0;
let insurer_id = $('#insurer_id').val() ?? 0;
let insurer_branch_id = $('#insurer_branch_id').val() ?? 0;
let policy_type_id = $('#policy_type_id').val() ?? 0;
let url = '<?= base_url('util/getClientPolicyDataBasedOnClientAndInsuer/') ?>';
let requestData = {
client_id: client_id,
client_branch_id: client_branch_id,
insurer_id: insurer_id,
insurer_branch_id: insurer_branch_id,
policy_type_id: policy_type_id,
};
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendPolicies(response.data)
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
//for the change title
function changeTitle(input){
let val = $(input).val();
if(val == 'statement_month'){
$('#bds_title').text(' - Statement Month Wise List')
}else{
$('#bds_title').text(' - Policy Wise List')
}
}
</script> </script>

View File

@ -0,0 +1,204 @@
<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="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 Report</h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S. No</th>
<th>Month</th>
<th>Business Type</th>
<th>Client Type</th>
<th>Insured Name</th>
<th>Policy/<br>Endorsement</th>
<th>Policy Type</th>
<th>BAP Group</th>
<th>Vehicle Number</th>
<th>Policy No</th>
<th>Endorsement No</th>
<th>Insurer Name</th>
<th>Insurer Branch</th>
<th>TPA</th>
<th>Endorsement <br> Effective Date</th>
<th>Policy <br> Effective Date</th>
<th>Policy <br> Expiry Date</th>
<th>Reference</th>
<th>Remarks</th>
<th>Base Premium</th>
<th>Terrorism/TP</th>
<th>Premium <br> (without GST)</th>
<th>GST @ 18%</th>
<th>Total Premium</th>
<th>Base <br> Revenue %</th>
<th>TP / Terrorism <br> Revenue %</th>
<th>Total IRDA <br> Revenue INR</th>
<th>GST on Revenue</th>
<th>Total Amount <br> Receivable</th>
<th>Rewards</th>
<th>Invoice Number</th>
<th>Invoice Date</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Outstanding Amount</th>
<th>Payment Status</th>
<th>UTR</th>
<th>Payment Date</th>
</tr>
</thead>
<tbody>
<?php if (isset($report_list)) { ?>
<?php foreach($report_list as $index => $row){ ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['policy_issue_month']; ?></td>
<td><?php echo $row['revenue_type']; ?></td>
<td><?php echo $row['client_type']; ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['action_type']; ?></td>
<td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['bap']; ?></td>
<td><?php echo $row['vehicle_no'] ?? 'N.A'; ?></td>
<td><?php echo $row['policy_no']; ?></td>
<td><?php echo $row['endorsement_no']; ?></td>
<td><?php echo $row['insurer_name']; ?> </td>
<td><?php echo $row['insurer_branch_name']; ?></td>
<td><?php echo $row['tpa_name']; ?></td>
<td><?php echo empty($row['endorse_eff_date']) ? '' : date('d/m/Y', strtotime($row['endorse_eff_date'])) ?></td>
<td><?php echo empty($row['policy_start_date']) ? '' : date('d/m/Y', strtotime($row['policy_start_date'])); ?></td>
<td><?php echo empty($row['policy_end_date']) ? '' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
<td><?php echo $row['ref']; ?></td>
<td><?php echo $row['remarks']; ?></td>
<td class="right-align-input"><?php echo $row['bp_amt']; ?></td>
<td class="right-align-input"><?php echo $row['tp_or_ter']; ?></td>
<td class="right-align-input"><?php echo $row['premium_wo_gst']; ?></td>
<td class="right-align-input"><?php echo $row['gst_amount']; ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['total_irda']; ?></td>
<td class="right-align-input"><?php echo $row['gst_on_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['total_amt_received']; ?></td>
<td class="right-align-input"><?php echo $row['reward']; ?></td>
<td><?php echo $row['invoice_no']; ?></td>
<td><?php echo empty($row['invoice_date']) ? '' : date('d/m/Y', strtotime($row['invoice_date'])); ?></td>
<td class="right-align-input"><?php echo $row['invoice_amount']; ?></td>
<td class="right-align-input"><?php echo $row['realization_amount']; ?></td>
<td class="right-align-input"><?php echo $row['outstanding_amount']; ?></td>
<td>
<?php
if($row['outstanding_amount'] == '0.00'){
echo 'Payment Received';
}else if($row['outstanding_amount'] == NULL){
echo '';
}else{
echo 'Partially Received';
}
?>
</td>
<td><?php echo $row['utr_numbers']; ?></td>
<td><?php echo $row['payment_dates']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<script>
// Datatable document ready
$(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>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'Policy-Tranction-BDS-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'Policy-Tranction-BDS-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this).text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) + 2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex + '"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) + '</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table not found.");
}
});
</script>

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,71 @@
<style>
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="tpa_list"> <div class="row" id="tpa_list">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
@ -42,6 +110,94 @@
</div><!-- end col --> </div><!-- end col -->
</div> </div>
<!-- end row --> <!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>

View File

@ -27,6 +27,7 @@ table.dataTable tbody td {
</style> </style>
<div class="row" id="varience_filter"> <div class="row" id="varience_filter">
<div class="col-12" style="margin-top: -12px;"> <div class="col-12" style="margin-top: -12px;">
<div id="accordion" class="mb-3"> <div id="accordion" class="mb-3">
<div class="card mb-1"> <div class="card mb-1">
@ -43,34 +44,35 @@ table.dataTable tbody td {
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger"></span></label> <label for="client_branch">Client<span class="text-danger"></span></label>
<select class="form-control" id="client_id" name="client_id"> <select class="form-control" id="client_id" name="client_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client</option> <option value="0">Select Client</option>
<?php
if (isset($clients) && count($clients)) {
foreach ($clients as $key => $value) {
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
}
}
?>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="addon_policy"> Insurer <span id="base_danger" <label for="client_branch_id">Client Branch<span class="text-danger"></span></label>
class="text-danger"></span></label> <select class="form-control" id="client_branch_id" name="client_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<select class="form-control" id="insurer_id" name="insurer_id"> <option value="0">Select Client Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="insurer_id"> Insurer <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()" >
<option value="0" selected>Select Insurer</option> <option value="0" selected>Select Insurer</option>
<?php if(isset($insurer) && count($insurer)){ ?> </select>
<?php foreach ($insurer as $value) { ?> </div>
<option value="<?= $value['id']?>"><?= $value['name']?></option>
<?php } ?> <div class="form-group col-md-3">
<?php } ?> <label for="insurer_branch_id"> Insurer Branch <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_branch_id" name="insurer_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0" selected>Select Insurer Branch</option>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger"></span></label> <label for="email"> Policy Type <span class="text-danger"></span></label>
<select class="form-control" id="policy_type_id" name="policy_type_id"> <select class="form-control" id="policy_type_id" name="policy_type_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Policy Type</option> <option value="0">Select Policy Type</option>
<?php <?php
if (isset($policy_types) && count($policy_types)) { if (isset($policy_types) && count($policy_types)) {
@ -82,6 +84,13 @@ table.dataTable tbody td {
</select> </select>
</div> </div>
<div class="form-group col-md-3">
<label for="client_policy_id"> Client Policy <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="client_policy_id" name="client_policy_id" >
<option value="0" selected>Select client policy</option>
</select>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger">*</span></label> <label for="client_branch">Issuer<span class="text-danger">*</span></label>
<select class="form-control" id="issuer" name="issuer" required> <select class="form-control" id="issuer" name="issuer" required>
@ -96,10 +105,6 @@ table.dataTable tbody td {
</select> </select>
</div> </div>
</div>
<div class="form-row">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label>Date Type<span class="text-danger"></span></label> <label>Date Type<span class="text-danger"></span></label>
<select class="form-control" id="date_type" name="date_type" <select class="form-control" id="date_type" name="date_type"
@ -135,6 +140,7 @@ table.dataTable tbody td {
class="btn btn-primary" id="get-emp-list" class="btn btn-primary" id="get-emp-list"
onclick="fetchEmpolyeeList(event);">Submit</a> onclick="fetchEmpolyeeList(event);">Submit</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -158,17 +164,15 @@ table.dataTable tbody td {
<thead class="bg-light"> <thead class="bg-light">
<tr> <tr>
<th>S.No</th> <th>S.No</th>
<th>Client Name</th> <th>Client</th>
<th>Client Branch</th>
<th>Insurer</th> <th>Insurer</th>
<th>Insurer Branch</th>
<th>Policy</th> <th>Policy</th>
<!-- <th>Policy No</th> -->
<th>Endorsement No</th> <th>Endorsement No</th>
<th>Expected Amount</th> <th>Expected Amount</th>
<th>Invoice Status</th> <th>Statement Amount</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Variance</th> <th>Variance</th>
<!-- <th>Action</th> -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -177,34 +181,14 @@ table.dataTable tbody td {
<tr> <tr>
<td><?= $index + 1 ?></td> <td><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td> <td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['client_branch_name']; ?></td>
<td><?php echo $row['insurer_name']; ?></td> <td><?php echo $row['insurer_name']; ?></td>
<td><?php echo $row['insurer_branch_name']; ?></td>
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td> <td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
<!-- <td><?php echo $row['policy_no']; ?></td> -->
<td><?php echo $row['endorsement_no']; ?></td> <td><?php echo $row['endorsement_no']; ?></td>
<td class="right-align-input"><?php echo $row['exp_amt']; ?></td> <td class="right-align-input"><?php echo $row['exp_amt']; ?></td>
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td> <td class="right-align-input"><?php echo $row['statement_amount']; ?></td>
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td> <td class="right-align-input"><?php echo $row['variance_amt']; ?></td>
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['variance']; ?></td>
<!-- <td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="
<?php
if ($row['action_type'] == 'I') {
echo base_url("/policy_tranction/inception/list") . '?pt_id=' . $row['id'];
} else {
echo base_url("/policy_tranction/endorsement/list") . '?pt_id=' . $row['id'];
}
?>" id="get-policy-list" class="dropdown-item btnEdit">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
</div>
</div>
</td> -->
</tr> </tr>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -219,6 +203,13 @@ table.dataTable tbody td {
</div> </div>
<script> <script>
let client_list = [];
let branch_list = [];
let policy_list = [];
let insurer_list = [];
let insurer_branch_list = [];
// Datatable document ready // Datatable document ready
$(document).ready(function() { $(document).ready(function() {
@ -282,13 +273,18 @@ $(document).ready(function() {
}); });
$(document).ready(function() { $(document).ready(function() {
getClientAndBranchAndPolicy()
getURLParams() getURLParams()
$('#client_id').select2(); $('#client_id').select2();
$('#client_branch_id').select2();
$('#insurer_id').select2(); $('#insurer_id').select2();
$('#insurer_branch_id').select2();
$('#client_policy_id').select2();
$('#policy_type_id').select2(); $('#policy_type_id').select2();
}) })
function fetchEmpolyeeList(event) { function fetchEmpolyeeList(event)
{
event.preventDefault(); // Prevent default action event.preventDefault(); // Prevent default action
var start_date = $('#startDate').val(); var start_date = $('#startDate').val();
@ -298,6 +294,9 @@ function fetchEmpolyeeList(event) {
var policy_type_id = $('#policy_type_id').val(); var policy_type_id = $('#policy_type_id').val();
var date_type = $('#date_type').val(); var date_type = $('#date_type').val();
var issuer = $('#issuer').val(); var issuer = $('#issuer').val();
var client_branch_id = $('#client_branch_id').val();
var insurer_branch_id = $('#insurer_branch_id').val();
var client_policy_id = $('#client_policy_id').val();
console.log(start_date + '-' + end_date); console.log(start_date + '-' + end_date);
@ -309,6 +308,9 @@ function fetchEmpolyeeList(event) {
policy_type_id: policy_type_id, policy_type_id: policy_type_id,
date_type: date_type, date_type: date_type,
issuer: issuer, issuer: issuer,
client_branch_id: client_branch_id,
insurer_branch_id: insurer_branch_id,
client_policy_id: client_policy_id,
}; };
const queryString = objectToQueryString(queryParams); const queryString = objectToQueryString(queryParams);
@ -321,7 +323,8 @@ function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
} }
function getURLParams() { function getURLParams()
{
const url = new URL(window.location.href); const url = new URL(window.location.href);
const params = new URLSearchParams(url.search); const params = new URLSearchParams(url.search);
@ -332,6 +335,9 @@ function getURLParams() {
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found const issuer = params.get('issuer') || 0; // Default to 0 if not found
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
hideDateField(date_type) hideDateField(date_type)
@ -339,16 +345,19 @@ function getURLParams() {
console.log('endDate', endDate) console.log('endDate', endDate)
console.log('client_id', client_id) console.log('client_id', client_id)
console.log('insurer_id', insurer_id) console.log('insurer_id', insurer_id)
console.log('policy_type_id', policy_type_id) console.log('policy_type_id', policy_type_id)
console.log('date_type', date_type) console.log('date_type', date_type)
console.log('issuer', issuer) console.log('issuer', issuer)
console.log('client_branch_id', client_branch_id)
console.log('insurer_branch_id', insurer_branch_id)
console.log('client_policy_id', client_policy_id)
// Log the values or use them as needed // Log the values or use them as needed
console.log('Start Date:', startDate); console.log('Start Date:', startDate);
console.log('End Date:', endDate); console.log('End Date:', endDate);
if (startDate != 0 && endDate != 0) { if (startDate != 0 && endDate != 0) {
setTimeout(function() { setTimeout(function(){
$('#start_date').val(startDate) $('#start_date').val(startDate)
$('#end_date').val(endDate) $('#end_date').val(endDate)
$('#client_id').val(client_id).change() $('#client_id').val(client_id).change()
@ -356,7 +365,14 @@ function getURLParams() {
$('#policy_type_id').val(policy_type_id).change() $('#policy_type_id').val(policy_type_id).change()
$('#date_type').val(date_type) $('#date_type').val(date_type)
$('#issuer').val(issuer) $('#issuer').val(issuer)
}, 1000) setTimeout(function(){
$('#client_branch_id').val(client_branch_id).change()
$('#insurer_branch_id').val(insurer_branch_id).change()
setTimeout(function(){
$('#client_policy_id').val(client_policy_id).change();
}, 1000);
}, 2000)
},2000)
} }
@ -432,7 +448,6 @@ function hideDateField(input = null) {
} }
} }
function sendPolicyTransactionID(event, pt_id) { function sendPolicyTransactionID(event, pt_id) {
event.preventDefault(); // Prevent default action event.preventDefault(); // Prevent default action
@ -447,4 +462,214 @@ function sendPolicyTransactionID(event, pt_id) {
console.log(apiURL); console.log(apiURL);
window.location.href = apiURL; window.location.href = apiURL;
} }
// -------------------------------------------------------------------------------------------------
//featch client, client branch, insurer, insurer branch and client policy list data
function getClientAndBranchAndPolicy()
{
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
insurer_list = res.insurer_data;
insurer_branch_list = res.insurer_branch_data;
appendClients(res.client_data);
appendInsurer(res.insurer_data);
}else{
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
//append clients for filter
function appendClients(data)
{
$('#client_id').empty();
$('#client_id').append($('<option>', {
value: '',
text: 'Select Client'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
'data-cn': item.client_name,
'data-ct': item.client_type,
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
});
$('#client_id').append(option);
});
}
//append clients branch for filter
function appendBranch(data)
{
$('#client_branch_id').empty();
$('#client_branch_id').append($('<option>', {
value: '',
text: 'Select Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#client_branch_id').append(option);
});
}
//append insurer for filter
function appendInsurer(data)
{
$('#insurer_id').empty();
$('#insurer_id').append($('<option>', {
value: '',
text: 'Select Insurer'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.name,
});
$('#insurer_id').append(option);
});
}
//append insurer branch for filter
function appendInsurerBranch(data)
{
$('#insurer_branch_id').empty();
$('#insurer_branch_id').append($('<option>', {
value: '',
text: 'Select Insurer Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#insurer_branch_id').append(option);
});
}
//append client policy for filter
function appendPolicies(data)
{
// console.log('appendPolicies', data);
// console.log('appendPolicies', $('#client_policy_id'));
$('#client_policy_id').empty();
$('#client_policy_id').append($('<option>', {
value: '',
text: 'Select Policy',
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#client_policy_id').append(option);
});
}
// -------------------------------------------------------------------------------------------------
//client branch and insurer branch onchange document ready function
$(document).ready(function(){
$('#client_id').change(function(){
let client_id = $(this).val();
console.log('client_id', client_id);
if(branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch(data);
}
})
$('#insurer_id').change(function(){
let insurer_id = $(this).val();
console.log('insurer_id', insurer_id);
if(insurer_branch_list != '') {
// console.log(insurer_branch_list[insurer_id]);
let data = insurer_branch_list[insurer_id];
appendInsurerBranch(data);
}
})
});
//get policy list based on the client, client_branch, insurer, insurer_branch and policy type
function getClientPolicyDataBasedOnClientAndInsuer(){
let client_id = $('#client_id').val() ?? 0;
let client_branch_id = $('#client_branch_id').val() ?? 0;
let insurer_id = $('#insurer_id').val() ?? 0;
let insurer_branch_id = $('#insurer_branch_id').val() ?? 0;
let policy_type_id = $('#policy_type_id').val() ?? 0;
let url = '<?= base_url('util/getClientPolicyDataBasedOnClientAndInsuer/') ?>';
let requestData = {
client_id: client_id,
client_branch_id: client_branch_id,
insurer_id: insurer_id,
insurer_branch_id: insurer_branch_id,
policy_type_id: policy_type_id,
};
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendPolicies(response.data)
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
</script> </script>

View File

@ -21,6 +21,33 @@ table.dataTable tbody td {
background-color: #f0f0f0; background-color: #f0f0f0;
color: #666; color: #666;
} }
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style> </style>
<div class="row" id="client_list"> <div class="row" id="client_list">
@ -323,6 +350,98 @@ table.dataTable tbody td {
</div> </div>
<!-- end of Client form content modal --> <!-- end of Client form content modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("scroll-horizontal-datatable");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown menu
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown menu with the same content
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy content of the original dropdown
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Append custom dropdown to the body
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Prevent opening dropdown if clicking on the action column (button)
if (event.target.closest('td:last-child') || event.target.closest('.dropdown-toggle')) {
return;
}
// Close any existing active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get the position of the clicked cell
const rect = event.target.getBoundingClientRect();
// Position the dropdown based on where you click in the row (excluding action column)
customDropdown.style.display = 'block';
customDropdown.style.position = 'absolute';
customDropdown.style.left = `${rect.left + window.scrollX}px`; // Align with the clicked position
customDropdown.style.top = `${rect.bottom + window.scrollY + 5}px`; // 5px gap below the row
// Set this dropdown as the active one
activeDropdown = customDropdown;
event.stopPropagation(); // Prevent event from bubbling up
});
// Add click event to handle dropdown item actions
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation(); // Prevent event from bubbling up
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function(event) {
if (activeDropdown && !event.target.closest('.custom-dropdown-menu')) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script> <script>
var client_list = ''; // local variable for storing the client list var client_list = ''; // local variable for storing the client list

View File

@ -8,7 +8,7 @@
<div class="col-md-4"></div> <div class="col-md-4"></div>
<div class="col-md-4"> <div class="col-md-4">
<i class="font-24"></i> <i class="font-24"></i>
<h4>CD Account No : <?php echo isset($insurerName->cd_ac_no) && !empty($insurerName->cd_ac_no) ? $insurerName->cd_ac_no : 'N/A' ?></h4> <h4>CD Account No : <?php echo isset($insurerName->cd_master_account_no) && !empty($insurerName->cd_master_account_no) ? $insurerName->cd_master_account_no : 'N/A' ?></h4>
</div> </div>
</div> </div>
</div> </div>
@ -265,11 +265,13 @@ $(document).ready(function() {
$(document).ready(function() { $(document).ready(function() {
$('#tickets-table').DataTable({ $('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>", dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{ buttons: [{
extend: 'csv', extend: 'csv',
text: 'CSV', text: 'CSV',
title: 'TransactionDetails', title: 'CD TransactionDetails',
exportOptions: { exportOptions: {
columns: '' columns: ''
} }
@ -283,17 +285,15 @@ $(document).ready(function() {
} }
} }
], ],
language: { language: {
search: "_INPUT_", search: "_INPUT_",
searchPlaceholder: "Search..." searchPlaceholder: "Search..."
}, },
ordering: false,
paging: true ,
}); });
}); });
</script> </script>
<!-- Include jQuery library (if not already included) -->
<script> <script>

File diff suppressed because it is too large Load Diff

View File

@ -17,15 +17,15 @@
"dompdf/dompdf": "^2.0", "dompdf/dompdf": "^2.0",
"firebase/php-jwt": "^6.10", "firebase/php-jwt": "^6.10",
"google/apiclient": "^2.15.0", "google/apiclient": "^2.15.0",
"kreait/firebase-php": "^7.0",
"laminas/laminas-escaper": "^2.9", "laminas/laminas-escaper": "^2.9",
"php-amqplib/php-amqplib": "^2.8", "php-amqplib/php-amqplib": "^2.8",
"phpmailer/phpmailer": "^6.9", "phpmailer/phpmailer": "^6.9",
"phpoffice/phpspreadsheet": "^2.1", "phpoffice/phpspreadsheet": "^2.1",
"psr/http-message": "^1.0",
"psr/log": "^1.1", "psr/log": "^1.1",
"slim/slim": "^4.13", "slim/slim": "^4.13",
"zircote/swagger-php": "^4.8", "zircote/swagger-php": "^4.8"
"psr/http-message": "^1.0",
"kreait/firebase-php":"^7.0"
}, },
"require-dev": { "require-dev": {
"codeigniter/coding-standard": "^1.7", "codeigniter/coding-standard": "^1.7",
@ -33,6 +33,7 @@
"friendsofphp/php-cs-fixer": "^3.47.1", "friendsofphp/php-cs-fixer": "^3.47.1",
"kint-php/kint": "^5.0.4", "kint-php/kint": "^5.0.4",
"mikey179/vfsstream": "^1.6", "mikey179/vfsstream": "^1.6",
"mockery/mockery": "^1.6",
"nexusphp/cs-config": "^3.6", "nexusphp/cs-config": "^3.6",
"phpunit/phpunit": "^9.1", "phpunit/phpunit": "^9.1",
"predis/predis": "^1.1 || ^2.0" "predis/predis": "^1.1 || ^2.0"

56
phpqueue.sh Executable file
View File

@ -0,0 +1,56 @@
!/bin/bash
while true; do
echo "Running job at $(date)"
/usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
!/bin/bash
!/bin/bash
# Read the Job_Queue variable from the temporary file
#!/bin/bash
#!/bin/bash
#!/bin/bash
# Define the root directory for the project and PID file path
#!/bin/bash
# Define paths
# ROOT_DIR=$(dirname "$(realpath "$0")")
# JOB_QUEUE_FILE="$ROOT_DIR/job_queue"
# PID_FILE="$ROOT_DIR/phpqueue.pid"
# # Check if the script is already running
# if [[ -f "$PID_FILE" ]] && kill -0 "$(cat $PID_FILE)" 2>/dev/null; then
# echo "phpqueue.sh is already running. Exiting."
# exit 1
# fi
# # Write the current process ID (PID) to the PID file
# echo $$ > "$PID_FILE"
# # Ensure the PID file is removed on script exit
# trap "rm -f $PID_FILE" EXIT
# # Main loop
# while true; do
# # Check if the Job_Queue file exists
# if [[ ! -f "$JOB_QUEUE_FILE" ]]; then
# echo "Job Queue file not found."
# exit 1
# fi
# # Read the value of Job_Queue from the file
# Job_Queue=$(cat "$JOB_QUEUE_FILE")
# if [[ "$Job_Queue" -eq 1 ]]; then
# /usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
# else
# echo "No job to process."
# fi
# # Sleep for 1 second before the next iteration
# sleep 1
# done

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

View File

@ -0,0 +1,38 @@
<?php
require_once 'vendor/autoload.php';
use PHPUnit\Framework\TestCase;
use App\Helpers\ExcelMergeHelper;
class ExcelMergeHelperTest extends TestCase
{
public function testMergeExcelFiles_Success()
{
// Use the paths you provided
$filePaths = [
['file_path' =>WRITEPATH.'uploads/lead_files/Member_Data.xlsx','sheets' => []],
['file_path' =>WRITEPATH.'/tmp/RFQ_ABC_GMC_20241220140640.xlsx','sheets' => []],
// ['file_path' =>'/home/venba/Downloads/Employee_data.xlsx','sheets' => []],
];
$outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file
// Call the mergeExcelFiles function
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
echo('result is -> '.$result);
// Check if the result is true (indicating success)
$this->assertFileExists($result);
$this->assertTrue(filesize($result) > 0);
}
}
// $temp_file_path = WRITEPATH.'tmp/RFQ_ABC_GMC_20241219172307.xlsx';
// $temp_file_name = 'RFQ_ABC_GMC_20241219172307.xlsx';
// $lead_file_path = WRITEPATH.'uploads/lead_files/Member_Data.xlsx';
// $filePaths = [
// ['file_path' => $temp_file_path,'sheets' =>[]],
// ['file_path' =>$lead_file_path ,'sheets' =>[]]
// ];
// $outputPath = dirname($temp_file_path).'/'.$temp_file_name.'_merged';

View File

@ -0,0 +1,183 @@
<?php
namespace Tests\unit;
use Exception;
use CodeIgniter\Test\CIUnitTestCase;
use App\Controllers\LeadsController;
class LeadsControllerTest extends CIUnitTestCase
{
protected $leadsController;
protected function setUp(): void
{
parent::setUp();
$this->leadsController = new LeadsController();
}
public function testGetDemographyDataBasicScenario()
{
echo('passed 0');
// Arrange
$members = [
// Header row
['Name', 'Age', 'Relationship', 'SI Enhancement'],
// Data rows
['John', '25', 'Self', '100000'],
['Jane', '23', 'Spouse', '100000'],
['Kid', '5', 'Child', '50000']
];
echo('passed 1');
$age_band_data = [
['0-17', '18-35', '36-45', 'Above 46']
];
echo('passed 2');
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
$available_col = 'age';print_rr($available_col);
$col_index = 1;
echo('passed 3');
try{
echo('Inside try');
// Act
echo('passed 3.5');
$result = $this->leadsController->getDemographyData($members,$age_band_data,$members_heading,$available_col,$col_index);
echo('passed 4');
} catch (Exception $e) {
echo "Message: " . $e->getMessage() . "\n";
echo "File: " . $e->getFile() . "\n";
echo "Line: " . $e->getLine() . "\n";
// Optionally, print the full stack trace
echo "Stack trace: " . $e->getTraceAsString() . "\n";
}
var_dump($result);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('general', $result);
$this->assertArrayHasKey('100000', $result);
$this->assertArrayHasKey('50000', $result);
// Check counts for general category
$this->assertEquals(1, $result['general']['Self']['18-35']);
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
$this->assertEquals(1, $result['general']['Child']['0-17']);
}
public function testGetDemographyDataWithDOB()
{
// Arrange
$members = [
// Header row
['Name', 'DOB', 'Relationship', 'SI Enhancement'],
// Data rows
['John', '01-Jan-1995', 'Self', '100000'],
['Jane', '01-Jan-1998', 'Spouse', '100000']
];
$age_band_data = [
['18-35', '36-45', '46+']
];
$members_heading = ['Name', 'DOB', 'Relationship', 'SI Enhancement'];
$available_col = 'dob';
$col_index = 1;
// Act
$result = $this->leadsController->getDemographyData(
$members,
$age_band_data,
$members_heading,
$available_col,
$col_index
);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('general', $result);
$this->assertArrayHasKey('100000', $result);
// Both members should be in 18-35 age band
$this->assertEquals(1, $result['general']['Self']['18-35']);
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
}
public function testGetDemographyDataWithEmptyMembers()
{
// Arrange
$members = [
// Only header row
['Name', 'Age', 'Relationship', 'SI Enhancement']
];
$age_band_data = [
['0-17', '18-35', '36-45', '46+']
];
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
$available_col = 'age';
$col_index = 1;
// Act
$result = $this->leadsController->getDemographyData(
$members,
$age_band_data,
$members_heading,
$available_col,
$col_index
);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('general', $result);
// Check that all totals are zero
$this->assertEquals(0, $result['general']['Grand Total']['Grand Total']);
}
public function testGetDemographyDataWithMultipleSIBands()
{
// Arrange
$members = [
// Header row
['Name', 'Age', 'Relationship', 'SI Enhancement'],
// Data rows with different SI amounts
['John', '25', 'Self', '100000'],
['Jane', '23', 'Spouse', '200000'],
['Kid1', '5', 'Child', '100000'],
['Kid2', '7', 'Child', '200000']
];
$age_band_data = [
['0-17', '18-35', '36-45', '46+']
];
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
$available_col = 'age';
$col_index = 1;
// Act
$result = $this->leadsController->getDemographyData(
$members,
$age_band_data,
$members_heading,
$available_col,
$col_index
);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('100000', $result);
$this->assertArrayHasKey('200000', $result);
// Check counts for different SI bands
$this->assertEquals(1, $result['100000']['Self']['18-35']);
$this->assertEquals(1, $result['200000']['Spouse']['18-35']);
$this->assertEquals(1, $result['100000']['Child']['0-17']);
$this->assertEquals(1, $result['200000']['Child']['0-17']);
// Check general category totals
$this->assertEquals(2, $result['general']['Child']['0-17']);
$this->assertEquals(2, $result['general']['Child']['Grand Total']);
}
}