diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4bf4b954..061ef3c4 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -428,6 +428,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation'); $routes->get('checkTpaApiEnable', 'EmployeeRestController::checkTpaApiEnable'); $routes->get('generateDemographyDataTable', 'LeadsController::generateDemographyDataTable'); + $routes->post('insufficientCdBalanceHrMailSend', 'EmployeeController::insufficientCdBalanceHrMailSend'); }); $routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 1bd71ed6..36b7cf7f 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -6638,23 +6638,23 @@ class ClientController extends AdminController // ----------EMP DATA SERVICE CONTROLLER-------------------------------------------------------------------------------- - $batch_data = [ - 'client_id' => 51, - 'client_branch_id' => 40, - 'client_policy_id' => 63, - 'insurer_or_tpa' => "insurer", - 'event_type' => "correction", - 'actions' => "export", - 'file_name' => "deletion_enhancement_test_file.xlsx", - ]; + // $batch_data = [ + // 'client_id' => 51, + // 'client_branch_id' => 40, + // 'client_policy_id' => 63, + // 'insurer_or_tpa' => "insurer", + // 'event_type' => "correction", + // 'actions' => "export", + // 'file_name' => "deletion_enhancement_test_file.xlsx", + // ]; // $batch_data = [ - // 'client_id' => 20, - // 'client_policy_id' => 77, - // 'client_branch_id' => 72, + // 'client_id' => 12, + // 'client_policy_id' => 8063, + // 'client_branch_id' => 1, // 'insurer_or_tpa' => "insurer", // // 'insurer_or_tpa' => "tpa", - // 'event_type' => "si_enhancement", + // 'event_type' => "inception", // 'file_name' => "si_enhancement_test_file.xlsx", // 'actions' => "export", // ]; @@ -6713,6 +6713,19 @@ class ClientController extends AdminController // $EmpDataServiceController->cashDepositCalculationForDeletion($array); // $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data); + // $totals = 0; + // foreach ($result as $item) { + // $totals = $totals + $item->total; + // } + + // $data = [ + // session()->get('cd_balance'), + // session()->get('cd_amount'), + // session()->get('hr_data'), + // session()->has('cd_balance'), + // get_cd_balance() + // ]; + // dd($data); // $result = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($batch_data); // dd(db_connect()->getLastQuery()); diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index ff86177d..70709383 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -33,6 +33,8 @@ use App\Models\LeadsModel; use App\Models\LeadInstallmentPaymentDetails; use App\Models\PolicyTransactionModel; use App\Models\PTCOShareDetailsModel; +use App\Models\LevelContactModel; + use App\Controllers\Jobs; use App\Controllers\JobWorker; @@ -71,6 +73,8 @@ class EmpDataServiceController extends BaseController protected $leadInstallmentPaymentDetailesModel; protected $policyTransactionModel; protected $PTCOShareDetailsModel; + protected $LevelContactModel; + public function __construct() @@ -99,6 +103,7 @@ class EmpDataServiceController extends BaseController $this->leadInstallmentPaymentDetailesModel = new LeadInstallmentPaymentDetails(); $this->policyTransactionModel = new PolicyTransactionModel(); $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); + $this->LevelContactModel = new LevelContactModel(); } @@ -208,14 +213,19 @@ class EmpDataServiceController extends BaseController if ((int) $cash_balance['balance'] < (int) $totals) { $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); - session()->set('cd_balance', false); - session()->set('cd_amount', $cash_balance['balance']); - session()->set('excel_file_amt', $totals); + + $cd_session_data = json_encode(['cd_balance' => false, 'cd_amount' => $cash_balance['balance'], 'excel_file_amt' => $totals]); + session()->set('cd_balance_info', $cd_session_data); + session()->set('cd_balance', false); + + $hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']); + $session_data = json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]); + session()->set('hr_data', $session_data); + }else{ session()->set('cd_balance', true); session()->set('cd_amount', $cash_balance['balance']); session()->set('excel_file_amt', $totals); - } } } @@ -5858,4 +5868,16 @@ class EmpDataServiceController extends BaseController 'gst' => round($amount['gst'] ?? 0, 2) ]; } + + public function getHrdataForInsufficientMailSend($ref_id) + { + $data = $this->LevelContactModel + ->select('id, name, email') + ->where('ref_id', $ref_id) + ->where('is_active', 1) + ->where('contact_type', 'client') + ->findAll(); + + return $data; + } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b662d8b1..f63052f4 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -8,6 +8,7 @@ use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; use App\Helpers\DepositHelper; +use App\Helpers\MailHelper; use App\Models\EmployeeModel; @@ -29,6 +30,7 @@ use App\Models\AuditHistoryModel; use App\Models\UserModel; use App\Models\PartnerEndorsementRequestModel; use App\Models\TpaApiDataModel; +use App\Models\LevelContactModel; use App\Controllers\Jobs; @@ -74,6 +76,7 @@ class EmployeeController extends AdminController protected $auditHistory; protected $userModel; protected $partnerEndorsementRequestModel; + protected $LevelContactModel; public function __construct() { @@ -97,6 +100,7 @@ class EmployeeController extends AdminController $this->auditHistory = new AuditHistoryModel(); $this->userModel = new userModel(); $this->partnerEndorsementRequestModel = new PartnerEndorsementRequestModel(); + $this->LevelContactModel = new LevelContactModel(); } public function list() @@ -4453,5 +4457,46 @@ class EmployeeController extends AdminController } + public function insufficientCdBalanceHrMailSend() + { + $post_data = $this->request->getJson(true); + + if(empty($post_data) || (!isset($post_data['mails']) && !empty($post_data['mails'])) || (!isset($post_data['client_id']) && !empty($post_data['client_id']))){ + return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data send mail'], 200); + } + + $client_data = $this->clientModel->where('is_active', 1)->where('id', $post_data['client_id'])->first(); + + $common['mail_type'] = "insufficient_cd_balance_by_hr"; + $common['client_id'] = $post_data['client_id']; + $subject = 'Insufficient CD Balance Notification'; + $mail_content = ' + Dear {{HR_NAME}}, + + Greetings from Nhance. + + We would like to inform you that the CD balance for {{CLIENT_NAME}} is currently low / insufficient, which may impact further processing of insurance-related activities. + + Kindly request you to credit the required amount at the earliest to avoid any service disruption. + + Please let us know once the amount is credited, or if you need any clarification from our end. + + Thank you for your support and cooperation. + '; + + + foreach ($post_data['mails'] as $hr_id => $hr_data) { + + $mail_content = str_ireplace('{{HR_NAME}}', $hr_data['name'], $mail_content); + $mail_content = str_ireplace('{{CLIENT_NAME}}', $client_data['client_name'], $mail_content); + + $res = MailHelper::send_email(['mail' => $hr_data['mail'], 'subject' => $subject, 'message' => $mail_content, 'common' => $common]); + } + + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail send successfully'], 200); + + } + + } diff --git a/app/Controllers/LoginController.php b/app/Controllers/LoginController.php index fb073f21..0e118e10 100755 --- a/app/Controllers/LoginController.php +++ b/app/Controllers/LoginController.php @@ -62,7 +62,7 @@ class LoginController extends BaseController set_session_data($session_data); // Bind session to device - set_session_data(['fingerprint' => generateFingerprint()]); + // set_session_data(['fingerprint' => generateFingerprint()]); log_message('error', 'Set The UserId : `'. $user->id .'` in Session'); log_message('error', 'User Login Sucessfully'); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index db769589..5b5d6b7b 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -3173,6 +3173,13 @@ if (!function_exists('check_rto_data')) { $vehicle_no = strtoupper(trim($row[2])); // Example: TN10AB1234 $new_vehicle = strtolower(trim($row[2])); + if(!validate_indian_vehicle_number($vehicle_no)['status']){ + return [ + 'status' => false, + 'error' => 'Invalid Vehicle Number. Format should be like TN82AX2024 (no spaces or special characters).' + ]; + }; + // BH Series: 22BH1234AA $bhPattern = '/^[0-9]{2}BH[0-9]{4}[A-Z]{2}$/'; diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 79e4ddf9..12e54b6f 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -1101,3 +1101,33 @@ if (!function_exists('convertGoogleDriveToDownloadLink')) { } } +if (!function_exists('get_cd_balance')) { + function get_cd_balance(): array + { + $session = session(); + + return [ + 'has_cd_balance' => $session->has('cd_balance'), + 'hr_data' => $session->get('hr_data') ?? [], + 'cd_balance_info' => $session->get('cd_balance_info') ?? [], + ]; + } +} + +if (!function_exists('clear_cd_balance_session')) { + function clear_cd_balance_session(): void + { + $session = session(); + + $session->remove([ + 'cd_balance', + 'hr_data', + 'cd_balance_info' + ]); + } +} + + + + + diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 70f0485c..7df0e021 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -494,7 +494,6 @@ class EmployeePolicyModel extends Model ) as batch_data ON employee_polices.id = batch_data.emp_policy_id WHERE employee_polices.client_policy_id = :client_policy_id: - AND (employee_polices.:id: IS NULL OR employee_polices.:id: = '') AND employees.client_branch_id = :client_branch_id: AND employee_polices.is_active = 1 AND employee_polices.status = 'active' @@ -502,6 +501,14 @@ class EmployeePolicyModel extends Model AND employees.emp_status = 'active' "; + if($insurer_or_tpa == 'insurer'){ + $sql .= "AND (employee_polices.uhid IS NULL OR employee_polices.uhid <> '')"; + } + + if($insurer_or_tpa == 'tpa'){ + $sql .= "AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id <> '')"; + } + $binds = ["datas" => $datas,"event" => $event ,"insurer_or_tpa" => $insurer_or_tpa ,"client_policy_id" => $client_policy_id diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index 55c49153..2380d342 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -5,6 +5,513 @@ } + +
@@ -146,6 +653,10 @@
+ + + +
@@ -159,12 +670,57 @@ + + + + + \ No newline at end of file