diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6c454276..5ed7d6d8 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-policy', 'ClientController::checkPolicyEndDateUpdateClientPolicyStatusExpired'); $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..7fe814d8 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 checkPolicyEndDateUpdateClientPolicyStatusExpired(){ + + $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/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php
index e840fded..0c415da5 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);
     }
 }
 
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/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..7a1c92aa 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -2,11 +2,12 @@
- +
- + @@ -26,75 +27,91 @@
- +
- +
- +
-
- - - - - + + + + + +
- +
- +
- + -
+
- - + +
- +
- -
-
- - +
-
+
+
+ + +
+ + +
+ +
@@ -116,105 +133,110 @@ \ No newline at end of file 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 @@
- - - + + +
+
- - -
-
- + -
-
- - + placeholder="Enter Insurer Name" + value="" name="name" required> +
+
+ +
+
+ + +
+
+ +
+
+
+
+ > +   + > + +
+
+
+ +
+
+
+
+ > +   + > + +
-
@@ -50,30 +68,29 @@ \ No newline at end of file diff --git a/app/Views/view_deposit.php b/app/Views/view_deposit.php index c3d40f84..e004bb33 100644 --- a/app/Views/view_deposit.php +++ b/app/Views/view_deposit.php @@ -111,11 +111,10 @@
- + - + @@ -229,7 +228,16 @@ $(document).ready(function() { exportOptions: { columns: '' } - }], + }, + { + extend: 'pdf', + text: 'PDF', + title: 'TransactionDetails', + exportOptions: { + columns: '' + } + } + ], language: { diff --git a/tests/unit/CheckFormateDataTest.php b/tests/unit/CheckFormateDataTest.php new file mode 100644 index 00000000..d1fa2c01 --- /dev/null +++ b/tests/unit/CheckFormateDataTest.php @@ -0,0 +1,40 @@ + 12, + 'client_policy_id' => 12, + 'insurer_or_tpa' => 'insurer', + 'event_type' => 'inception', + 'actions' => 'export', + 'file_name' => 'TCS_HealthFlex_Advantage_Policy_IEI_06-04-2024_17-42-31.xlsx', + ]; + + $empServiceController = new EmpDataServiceController(); + $result = $empServiceController->generateExcelForAdditionAndInception($batch_data); + + // You can add assertions here to verify the result if needed + $this->assertTrue($result); + } +}
created_at)); ?>created_at)); ?> username; ?> description; ?>sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?> - sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?> transaction_type == 'Credit') ? $row->amount : ''; ?> transaction_type == 'Debit') ? $row->amount : ''; ?> balance; ?>