diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6c454276..007d80c1 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -16,6 +16,7 @@ $routes->get('/login', 'LoginController::index');///auth/google $routes->get('/logout', 'LoginController::logout'); $routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse'); $routes->get('/auth/google', 'LoginController::initiateGoogleOAuth'); +$routes->get('/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus'); $routes->group("/user", ["filter" => "authMVC"], function($routes){ @@ -209,6 +210,8 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("download-excel/(:any)", "EmployeeController::downloadSampleExcelFile/$1"); $routes->get("get-emp-endorsement/(:any)", "EmployeeController::getEmpEndoresmentEntry/$1"); $routes->post("import-export", "EmployeeController::importExport"); + $routes->get("featch-client-policy-list/(:any)", "ClientController::getClientPolicyList/$1"); + }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Config/Session.php b/app/Config/Session.php index e077df64..591aefdc 100644 --- a/app/Config/Session.php +++ b/app/Config/Session.php @@ -40,7 +40,8 @@ class Session extends BaseConfig * The number of SECONDS you want the session to last. * Setting to 0 (zero) means expire when the browser is closed. */ - public int $expiration = 7200; + // public int $expiration = 7200; + public int $expiration = 86400; //24 Hours /** * -------------------------------------------------------------------------- diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 44768c63..7a2b274e 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -29,6 +29,8 @@ use App\Models\PolicyGridModel; use App\Models\PolicyPremium1Model; use App\Models\PolicyPremium2Model; use App\Models\EmployeeModel; +use App\Models\EmployeePolicyModel; + @@ -57,6 +59,7 @@ class ClientController extends AdminController protected $policyPremium2Model; protected $clientDepositModel; protected $employeeModel; + protected $employeePolicyModel; public function __construct() { @@ -83,6 +86,9 @@ class ClientController extends AdminController $this->policyPremium1Model = new PolicyPremium1Model(); $this->policyPremium2Model = new PolicyPremium2Model(); $this->employeeModel = new EmployeeModel(); + $this->employeePolicyModel = new EmployeePolicyModel(); + + } @@ -103,6 +109,14 @@ class ClientController extends AdminController } + public function updateEmpAndPolicyStatus(){ + + $return = $this->clientPolicyModel->updateStatus(); + $this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]); + $this->myLogger->logme('error', 'Employee Policy Status Update Count: {data}', ['data' => $return['emp']]); + + } + public function removeClient($id = null) { @@ -248,10 +262,21 @@ class ClientController extends AdminController $editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll(); $editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); $editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); - $editData['client_policy'] = $this->clientPolicyModel->getClientPolicyByClientId($id); + + $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id); + + foreach ($clientPoliceData as $key => $value) { + + $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date)); + $clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date)); + } + + $editData['client_policy'] = $clientPoliceData; + + // echo "
";
- // print_r($editData); die;
+ // print_r($clientPoliceData); die;
echo view('layout/header', $headerData);
echo view('client_onboarding', $editData);
@@ -577,6 +602,7 @@ class ClientController extends AdminController
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
$data['is_addon'] = $this->request->getPost('is_addon');
+ $data['base_policy'] = $this->request->getPost('base_policy');
if (!isset($data['is_addon'])) {
$data['is_addon'] = 0;
@@ -594,6 +620,11 @@ class ClientController extends AdminController
$insert = $this->clientPolicyModel->insert($data);
if($insert){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
+ foreach ($clientPoliceData as $key => $value) {
+
+ $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
+ $clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
+ }
return $this->respond(['status' => true,'code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE'], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
@@ -637,6 +668,8 @@ class ClientController extends AdminController
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
$data['is_addon'] = $this->request->getPost('is_addon');
+ $data['base_policy'] = $this->request->getPost('base_policy');
+
if (!isset($data['is_addon'])) {
@@ -654,6 +687,11 @@ class ClientController extends AdminController
if($insert){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
+ foreach ($clientPoliceData as $key => $value) {
+
+ $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
+ $clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
+ }
return $this->respond(['status' => true,'code' => 200,'data' => $clientPoliceData, 'method' => 'EDIT'], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
@@ -903,8 +941,13 @@ class ClientController extends AdminController
if($id){
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
$insurer_id = $client_policy_data['insurer_id'];
+ $client_id = $client_policy_data['client_id'];
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
- return $this->respond(['status' => true,'code' => 200,'data' => $client_policy_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
+ $client_policy_list = $this->clientPolicyModel->select('policies.*')
+ ->join('policies', 'policies.id = client_policy.policy_id')
+ ->where('client_id', $client_id)
+ ->findAll();
+ return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
}
@@ -1393,4 +1436,19 @@ class ClientController extends AdminController
}
+
+ public function getClientPolicyList($client_id = null){
+
+ $record = $this->clientPolicyModel->select('policies.*')
+ ->join('policies', 'policies.id = client_policy.policy_id')
+ ->where('client_id', $client_id)
+ ->findAll();
+
+ if ($record) {
+ return $this->respond(['Status' => true,'code' => 200,'data' => $record], 200);
+ } else {
+ return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.'], 200);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index ef969731..5aa1b072 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -250,7 +250,11 @@ class EmployeeController extends AdminController
// echo '';
// print_r($result); die;
- echo view('excel_errors', $result);
+ if($result){
+ echo view('excel_errors', $result);
+ }else{
+ echo view('errors/html/production');
+ }
}
@@ -272,13 +276,17 @@ class EmployeeController extends AdminController
$filePath = '';
// Path to your file
if($actionType == 'inception'){
- $filePath = ROOTPATH . 'public/sample_excel/inception.xls';
-
+ $filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls';
}else if($actionType == 'correction'){
- $filePath = ROOTPATH . 'public/sample_excel/inception_1.xls';
-
+ $filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls';
}else if($actionType == 'si_enhancement'){
- $filePath = ROOTPATH . 'public/sample_excel/inception_2.xls';
+ $filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls';
+ }else if($actionType == 'dependent_addtion'){
+ $filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls';
+ }else if($actionType == 'addition'){
+ $filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls';
+ }else if($actionType == 'deletion'){
+ $filePath = ROOTPATH . 'public/sample_excel/sample_deletion.xls';
}
// Check if the file exists
@@ -291,7 +299,7 @@ class EmployeeController extends AdminController
return $this->response->download($filePath, null, $mimeType);
} else {
// File not found, show an error message or redirect
- return redirect()->back()->with('error', 'File not found.');
+ echo view('errors/html/production');
}
}
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 1334c2b2..fbe7bd89 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -932,6 +932,7 @@ class EmployeeServiceController extends AdminController
public function getExcelErrorData($file_id){
+ try {
$file = $this->fileModel->find($file_id);
$error_data = json_decode($file['reason']);
@@ -1018,6 +1019,13 @@ class EmployeeServiceController extends AdminController
}
+ }catch (\Exception $e) {
+ // Handle any exceptions
+ $errorMessage = $e->getMessage();
+ $this->myLogger->logme('error', $errorMessage);
+ return false; // You can return an error response here
+ }
+
}
diff --git a/app/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php
index e840fded..ffb72f4c 100644
--- a/app/Helpers/excel_import_export_helper.php
+++ b/app/Helpers/excel_import_export_helper.php
@@ -77,7 +77,7 @@ if (!function_exists('generate_excel')) {
if($totals == 1){
// Call the helper function for Calculate GST, Pro Rata Premium, and Total sums for inception
- add_totals_row($spreadsheet, $data);
+ add_totals_row($spreadsheet, $data, $headers);
}else if($totals == 2){
add_totals_for_deletion($spreadsheet, $data);
}
@@ -268,25 +268,39 @@ if (! function_exists('transform_objects_to_array_for_deletion')) {
if (!function_exists('add_totals_row')) {
- function add_totals_row(Spreadsheet $spreadsheet, array $data)
- {
+ function add_totals_row(Spreadsheet $spreadsheet, array $data, array $headers)
+ {
+
+ //find the index value
+ $rata = array_search('PRO RATA PREMIUM', $headers);
+ $gst = array_search('GST', $headers);
+ $total = array_search('TOTAL', $headers);
+
+
// Calculate GST, Pro Rata Premium, and Total sums
$gstSum = 0;
$proRataPremiumSum = 0;
$totalSum = 0;
foreach ($data as $row) {
- $gstSum += $row[18];
- $proRataPremiumSum += $row[19];
- $totalSum += $row[20];
+ $gstSum += $row[$gst];
+ $proRataPremiumSum += $row[$rata];
+ $totalSum += $row[$total];
}
+ $cellValue = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
+ $prev_index = $rata - 1;
+ $cellValueTotal = $cellValue[$prev_index];
+ $cellValueRata = $cellValue[$rata];
+ $cellValueGST = $cellValue[$gst];
+ $cellValueTotalSum = $cellValue[$total];
+
// Add a new row with sums
$lastRow = count($data) + 1; // To get the last row number
- $spreadsheet->getActiveSheet()->setCellValue('R' . ($lastRow + 1), 'TOTALS');
- $spreadsheet->getActiveSheet()->setCellValue('S' . ($lastRow + 1), $gstSum);
- $spreadsheet->getActiveSheet()->setCellValue('T' . ($lastRow + 1), $proRataPremiumSum);
- $spreadsheet->getActiveSheet()->setCellValue('U' . ($lastRow + 1), $totalSum);
+ $spreadsheet->getActiveSheet()->setCellValue($cellValueTotal . ($lastRow + 1), 'TOTALS');
+ $spreadsheet->getActiveSheet()->setCellValue($cellValueRata . ($lastRow + 1), $proRataPremiumSum);
+ $spreadsheet->getActiveSheet()->setCellValue($cellValueGST . ($lastRow + 1), $gstSum);
+ $spreadsheet->getActiveSheet()->setCellValue($cellValueTotalSum . ($lastRow + 1), $totalSum);
}
}
@@ -405,6 +419,19 @@ if (!function_exists('remove_underscore_capitalize_first_letter')) {
}
if (!function_exists('formatDateOrReturn')) {
+
+ /**
+ * Formats a given value as a date or returns the original value if it's not a valid date.
+ *
+ * This function checks if the provided value is a valid date. If it is, it formats
+ * the date as 'd-M-Y' (day-month-year) format and returns it. If the value is not
+ * a valid date, it returns the original value unchanged.
+ *
+ * @param mixed $value The value to be formatted as a date or returned unchanged.
+ * @return string|mixed The formatted date if the value is a valid date, otherwise the original value.
+ */
+
+
function formatDateOrReturn($value)
{
// Check if the value is a valid date
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 8008ad8d..8ca450a4 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -34,6 +34,7 @@ class ClientPolicyModel extends Model
"policy_terms",
"open_for_enrollment",
"is_addon",
+ "base_policy",
"created_by",
"updated_by",
"Is_active",
@@ -249,4 +250,21 @@ public function getDepositlistsummary($id)
->getResult();
}
+
+public function updateStatus(){
+
+ // Update client_policy table
+ $client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
+ $client_count = $this->db->affectedRows();
+ // Update employee_polices table
+ $employee = $this->db->query("UPDATE employee_polices SET status = 'expired' WHERE policy_end_date < CURDATE()");
+ $emp_count = $this->db->affectedRows();
+
+ return ['client'=>$client_count, 'emp' => $emp_count];
+
+
}
+
+
+}
+
diff --git a/app/Models/InsurerModel.php b/app/Models/InsurerModel.php
index 77ad5d49..c23804c1 100644
--- a/app/Models/InsurerModel.php
+++ b/app/Models/InsurerModel.php
@@ -11,6 +11,7 @@ class InsurerModel extends Model
protected $allowedFields = [
"id",
"type",
+ "category",
"name",
"short_name",
"created_by",
diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php
index 2e31acd9..31b16548 100644
--- a/app/Views/batch_list.php
+++ b/app/Views/batch_list.php
@@ -12,6 +12,7 @@
SNO
Batch Code
+ File Name
Client
Client Policy
Event Type
@@ -31,6 +32,7 @@
+
diff --git a/app/Views/client_deposit_list.php b/app/Views/client_deposit_list.php
index a0956ff9..fb1adc40 100644
--- a/app/Views/client_deposit_list.php
+++ b/app/Views/client_deposit_list.php
@@ -75,12 +75,21 @@ $(document).ready(function() {
buttons: [{
extend: 'csv',
text: 'CSV',
- title: 'Client_Deposit',
+ title: 'Client Deposit Details - ' + ' ',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
- }],
+ },
+ {
+ extend: 'pdf',
+ text: 'PDF',
+ title: 'Client Deposit Details - ' + ' ',
+ exportOptions: {
+ columns: ':not(:last-child)'
+ },
+ }
+ ],
language: {
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php
index 668cbb35..bca575d2 100644
--- a/app/Views/client_onboarding.php
+++ b/app/Views/client_onboarding.php
@@ -28,6 +28,10 @@ body {
}
+.navtab-bg .nav-link {
+ margin: 0 5px 10px!important;
+}
+
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 45b5cd9d..27da989b 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -2,11 +2,12 @@
-
+
-
+
@@ -26,75 +27,91 @@
-
+
-
+
-
+
-
@@ -116,85 +133,208 @@
\ No newline at end of file
diff --git a/app/Views/employee_upload.php b/app/Views/employee_upload.php
index 16e5d66d..f068f4cc 100644
--- a/app/Views/employee_upload.php
+++ b/app/Views/employee_upload.php
@@ -297,8 +297,8 @@ function fetchFileError(file_id) {
var file_error_html = "";
for (var key in file_error_data['error_summary']) {
- console.log(key);
- var err_id = key;
+ // console.log(key);
+ var err_id = parseInt(key);
var err_count = file_error_data['error_summary'][key];
switch (err_id) {
case 1:
@@ -345,21 +345,26 @@ function fetchFileError(file_id) {
file_error_html += "";
break;
}
- file_error_html += (err_id == 1 ?
- "Mandatory values missing " +
- err_count + "" : (err_id == 2 ?
- "Values not in expected format " +
- err_count + "" : (err_id == 3 ?
- "Field contains not allowed values " +
- err_count + "" : (err_id == 4 ?
- "Rule Conflict " +
- err_count + "" : (err_id == 5 ? "" +
- file_error_data['error_data'] + "" : (err_id ==
- 6 ?
- "" + file_error_data['error_data'] +
- "" : ""))))));
+
+ // console.log('file_error_html_1', file_error_html)
+
+ // file_error_html += (err_id == 1 ?
+ // "Mandatory values missing " +
+ // err_count + "" : (err_id == 2 ?
+ // "Values not in expected format " +
+ // err_count + "" : (err_id == 3 ?
+ // "Field contains not allowed values " +
+ // err_count + "" : (err_id == 4 ?
+ // "Rule Conflict " +
+ // err_count + "" : (err_id == 5 ? "" +
+ // file_error_data['error_data'] + "" : (err_id ==
+ // 6 ?
+ // "" + file_error_data['error_data'] +
+ // "" : ""))))));
file_error_html += '
';
- // }
+ // // }
+
+ // console.log('file_error_html_2', file_error_html)
}
if (err_id != 5 && err_id != 6) {
@@ -369,7 +374,7 @@ function fetchFileError(file_id) {
"' target=_blank>click here to more details..." : "");
}
- console.log(file_error_html);
+ // console.log(file_error_html);
$('#file-err-modal').find(".modal-body").html(file_error_html);
return file_error_html;
} catch (error) {
diff --git a/app/Views/insurer_basic_info.php b/app/Views/insurer_basic_info.php
index b350522c..52421c87 100644
--- a/app/Views/insurer_basic_info.php
+++ b/app/Views/insurer_basic_info.php
@@ -2,38 +2,56 @@
-