diff --git a/.env.sample b/.env.sample index 6af188a4..b3f6111e 100644 --- a/.env.sample +++ b/.env.sample @@ -14,13 +14,14 @@ # ENVIRONMENT #-------------------------------------------------------------------- -CI_ENVIRONMENT = development +# CI_ENVIRONMENT = development #-------------------------------------------------------------------- # APP #-------------------------------------------------------------------- -app.baseURL = 'http://localhost/nhance/' +app.baseURL = 'http://localhost/client_changes/nhance/' +app.appTimezone = 'Asia/Kolkata' # If you have trouble with `.`, you could also use `_`. # app_baseURL = '' # app.forceGlobalSecureRequests = false @@ -31,19 +32,74 @@ app.baseURL = 'http://localhost/nhance/' #-------------------------------------------------------------------- +# Dev DB Connection database.default.hostname = 119.18.54.85 database.default.database = venbaehn_nhance database.default.username = venbaehn_nhance_user1 database.default.password = 'iM~X7(cR+}A-' +database.default.DBDriver = MySQLi +database.default.DBPrefix = +database.default.port = 3306 + +database.tests.hostname = 119.18.54.85 +database.tests.database = venbaehn_nhance +database.tests.username = venbaehn_nhance_user1 +database.tests.password = 'iM~X7(cR+}A-' +database.tests.DBDriver = MySQLi +database.tests.DBPrefix = +database.tests.port = 3306 + +# Test DB Connection + +# database.default.hostname = 119.18.54.85 +# database.default.database = venbaehn_nhance_test +# database.default.username = venbaehn_nhance_user1 +# database.default.password = 'iM~X7(cR+}A-' # database.default.DBDriver = MySQLi # database.default.DBPrefix = # database.default.port = 3306 -database.default.hostname = 119.18.54.85 -database.default.database = venbaehn_nhance -database.default.username = venbaehn_nhance_user1 -database.default.password = 'iM~X7(cR+}A-' +# database.tests.hostname = 119.18.54.85 +# database.tests.database = venbaehn_nhance_test +# database.tests.username = venbaehn_nhance_user1 +# database.tests.password = 'iM~X7(cR+}A-' +# database.tests.DBDriver = MySQLi +# database.tests.DBPrefix = +# database.tests.port = 3306 + +# UAT DB Connection + +# database.default.hostname = 119.18.54.85 +# database.default.database = venbaehn_nhance_uat +# database.default.username = venbaehn_nhance_user1 +# database.default.password = 'iM~X7(cR+}A-' +# database.default.DBDriver = MySQLi +# database.default.DBPrefix = +# database.default.port = 3306 + +# database.tests.hostname = 119.18.54.85 +# database.tests.database = venbaehn_nhance_uat +# database.tests.username = venbaehn_nhance_user1 +# database.tests.password = 'iM~X7(cR+}A-' +# database.tests.DBDriver = MySQLi +# database.tests.DBPrefix = +# database.tests.port = 3306 + +# Local PhpMyAdmin DB Connection + +# database.default.hostname = localhost +# database.default.database = nhance +# database.default.username = root +# database.default.password = '' +# database.default.DBDriver = MySQLi +# database.default.DBPrefix = +# database.default.port = 3306 + +# database.tests.hostname = localhost +# database.tests.database = nhance +# database.tests.username = root +# database.tests.password = '' # database.tests.DBDriver = MySQLi # database.tests.DBPrefix = # database.tests.port = 3306 @@ -125,12 +181,12 @@ database.default.password = 'iM~X7(cR+}A-' #-------------------------------------------------------------------- # session.driver = 'CodeIgniter\Session\Handlers\FileHandler' -# session.cookieName = 'ci_session' -# session.expiration = 7200 +session.cookieName = 'ci_session_dev' +session.expiration = 86400 # session.savePath = null # session.matchIP = false -# session.timeToUpdate = 300 -# session.regenerateDestroy = false +session.timeToUpdate = 300 +session.regenerateDestroy = true #-------------------------------------------------------------------- # LOGGER @@ -151,5 +207,10 @@ database.default.password = 'iM~X7(cR+}A-' GOOGLE_OAUTH_APP_NAME = 'OAuth' GOOGLE_OAUTH_CLIENT_ID = '696241936560-m2mr272ge7vr2n4q36c22l3d2gdgi90l.apps.googleusercontent.com' GOOGLE_OAUTH_CLIENT_SECRET = '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' -GOOGLE_OAUTH_REDIRECT_URI = 'http://localhost/nhance/oauth2callback' +GOOGLE_OAUTH_REDIRECT_URI = 'http://localhost/client_changes/nhance/oauth2callback' GOOGLE_OAUTH_SCOPES = "https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile" + + +App_Url = https://venbait.in/nhance/app/dev/ +POST_ENROLLMENT_APP_LINK = https://venbait.in/nhance/employee/dev/ +NHANCE_LOGO = https://venbait.in/nhance/dev/public/assets/images/Nhance_Favi.png \ No newline at end of file diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 80babc57..3e79d7a7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -49,7 +49,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) { - $routes->get("view", "DashboardController::dashboard"); + $routes->match(['get','post'],'view','DashboardController::dashboard'); $routes->get('get-notification', 'DashboardController::getDashboardNotifications'); $routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1'); $routes->get('get-pending-action', 'PendingActionsController::getPendingActions'); @@ -146,6 +146,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1"); $routes->get("test-rack-rate", "EmployeeController::testRackRate"); $routes->post("test-rack-rate", "EmployeeController::testRackRate"); + $routes->post("test-dependent", "EmployeeController::testCheckDependentConflict"); }); @@ -271,11 +272,12 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1"); $routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1"); $routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1"); + $routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjobs', 'JobWorker::processJobs'); -$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status'); +$routes->cli('cli/enrollment_status', 'DashboardController::enrollment_status'); $routes->get("processjob", "JobWorker::processJob"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 77bd79e8..2c6111af 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -415,7 +415,9 @@ class ClientController extends AdminController foreach ($clientPoliceData as $key => $value) { $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date)); + $clientPoliceData[$key]->open_date = date('d-M-Y', strtotime($value->open_date)); $clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date)); + $clientPoliceData[$key]->close_date = date('d-M-Y', strtotime($value->close_date)); } $editData['client_policy'] = $clientPoliceData; @@ -766,8 +768,8 @@ class ClientController extends AdminController $data['no_of_lives'] = $this->request->getPost('no_of_lives'); $data['policy_status'] = $this->request->getPost('policy_status'); $data['no_of_employees'] = $this->request->getPost('no_of_employees'); - $data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d'); - $data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d'); + $data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d') ?? null; + $data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d') ?? null; $data['incurred_claims_ratio'] = $this->request->getPost('incurred_claims_ratio'); $data['no_lives_at_inception'] = $this->request->getPost('no_lives_at_inception'); $data['premium_paid_at_inception'] = $this->request->getPost('premium_paid_at_inception'); @@ -823,16 +825,17 @@ class ClientController extends AdminController // } // } - + $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_no'] = $this->request->getPost('policy_no'); if($data['inception_type'] == 2){ - $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['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['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); }else{ - $data['policy_start_date'] = null; - $data['policy_end_date'] = null; + $data['open_date'] = null; + $data['closedate'] = null; $data['reminder_date'] = null; } @@ -879,8 +882,8 @@ class ClientController extends AdminController $data['no_of_lives'] = $this->request->getPost('no_of_lives'); $data['policy_status'] = $this->request->getPost('policy_status'); $data['no_of_employees'] = $this->request->getPost('no_of_employees'); - $data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d'); - $data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d'); + $data['earned_premium_date'] = change_date_format($this->request->getPost('earned_premium_date'), 'd-m-Y', 'Y-m-d') ?? null; + $data['claims_incurred_date'] = change_date_format($this->request->getPost('claims_incurred_date'), 'd-m-Y', 'Y-m-d') ?? null; $data['incurred_claims_ratio'] = $this->request->getPost('incurred_claims_ratio'); $data['no_lives_at_inception'] = $this->request->getPost('no_lives_at_inception'); $data['premium_paid_at_inception'] = $this->request->getPost('premium_paid_at_inception'); @@ -894,14 +897,16 @@ class ClientController extends AdminController $data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['gst'] = $this->request->getPost('gst'); - + $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'); + if($data['inception_type'] == 2){ - $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['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['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); }else{ - $data['policy_start_date'] = null; - $data['policy_end_date'] = null; + $data['open_date'] = null; + $data['close_date'] = null; $data['reminder_date'] = null; } @@ -944,7 +949,7 @@ class ClientController extends AdminController // dd($data); $data['updated_by'] = get_session_userid(); - // print_r($data);die; + // print_r(json_encode($data));die; $insert = $this->clientPolicyModel->update($id,$data); $lastQuery = $this->clientPolicyModel->getLastQuery(); @@ -1021,28 +1026,28 @@ class ClientController extends AdminController $policy_grid_id = $this->request->getPost('policy_grid_id'); $rack_rate_name = $this->request->getPost('rack_rate_name'); - $self = $this->request->getPost('self') ? 1 : 0; - $spouse = $this->request->getPost('spouse'); - $childrens = $this->request->getPost('childrens'); - $parents = $this->request->getPost('parents'); - $parents_in_law = $this->request->getPost('parents-in-law'); + $relation_data = [ + 'self' => $this->request->getPost('self'), + 'spouse' => $this->request->getPost('spouse'), + 'childrens' => $this->request->getPost('childrens'), + 'parents' => $this->request->getPost('parents'), + 'parents-in-law'=> $this->request->getPost('parents-in-law'), + ]; - if($policy_grid_id == 1 || $policy_grid_id == 2){ - $self = 1; - $spouse = 'NA'; - $childrens = 'NA'; - $parents = 'NA'; - $parents_in_law = 'NA'; + if ($policy_grid_id == 1 || $policy_grid_id == 2 || $policy_grid_id == 6 || $policy_grid_id == 7) { + $relation_data = [ + 'self' => 1, + 'spouse' => 'NA', + 'childrens' => 'NA', + 'parents' => 'NA', + 'parents-in-law'=> 'NA', + ]; } - $relation_data['self'] = $self; - $relation_data['spouse'] = $spouse; - $relation_data['childrens'] = $childrens; - $relation_data['parents'] = $parents; - $relation_data['parents-in-law'] = $parents_in_law; - + // Convert to JSON $jsonDataForRelation = json_encode($relation_data); + $si_or_bp = $this->request->getPost('si_or_bp'); $basic_multiplier = str_replace(',', '', $this->request->getPost('basic_multiplier')); $premium_multiplier = str_replace(',', '', $this->request->getPost('premium_multiplier')); @@ -2161,7 +2166,8 @@ class ClientController extends AdminController } } - public function getClientBranch($client_id){ + public function getClientBranch($client_id) + { $branchs = $this->clientBranchModel ->select('*') @@ -2822,4 +2828,38 @@ class ClientController extends AdminController } + + public function removeRackRate($rack_rate_name = null, $client_policy_id = null) + { + $this->myLogger->logme('error', 'Rack Rate Remove function called'); + + $data = [ + 'updated_by' => get_session_userid(), + 'is_active' => 0 + ]; + + $rackRateData = $this->policyPremium2Model + ->where('rack_rate_name', $rack_rate_name) + ->where('client_policy_id', $client_policy_id) + ->where('is_active',1) + ->countAllResults(); + + if($rackRateData > 0){ + $update = $this->policyPremium2Model + ->where('rack_rate_name', $rack_rate_name) + ->where('client_policy_id', $client_policy_id) + ->set($data)->update(); + + if ($update) { + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Rack Rate removed successfully', 'rr_count' => $rackRateData], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy', 'rr_count' => $rackRateData], 200); + } + }else{ + + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Rack Rate not available', 'rr_count' => $rackRateData], 200); + } + + } + } \ No newline at end of file diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 16a4d50f..79a90517 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -6,6 +6,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Helpers\sendMailNotification; use CodeIgniter\API\ResponseTrait; @@ -13,6 +14,10 @@ use App\Models\MessageModel; use App\Models\UserMessageModel; use App\Models\ClientModel; +use App\Models\JobModel; +use App\Models\ClientPolicyModel; +use App\Models\NotificationModel; +use App\Models\EmployeePolicyModel; use App\Controllers\PendingActionsContrller; class DashboardController extends AdminController @@ -35,23 +40,26 @@ class DashboardController extends AdminController public function dashboard() { - $data = []; + $data = []; + + $results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, + client_branch.id as client_branch_id, client_branch.branch_name, + client_branch.branch_code, employees.id as employee_id, + employees.name as employee_name, employees.relationship, + employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id') + ->join('client_branch', 'clients.id = client_branch.client_id', 'left') + ->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left') + ->join('employees', 'client_branch.id = employees.client_branch_id', 'left') + ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') + ->findAll(); + $pendingActionsController = new PendingActionsController; $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); - $results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, - client_branch.id as client_branch_id, client_branch.branch_name, - client_branch.branch_code, employees.id as employee_id, - employees.name as employee_name, employees.relationship, - employees.emp_code, employees.emp_status, auth_history.user_type') - ->join('client_branch', 'clients.id = client_branch.client_id', 'left') - ->join('employees', 'client_branch.id = employees.client_branch_id', 'left') - ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') - ->findAll(); $groupedData = []; - $employeeId = ''; + foreach ($results as $row) { $clientId = $row['client_id']; $clientName = $row['client_name']; @@ -59,6 +67,10 @@ class DashboardController extends AdminController $branchId = $row['client_branch_id']; $branchName = $row['branch_name']; $branchCode = $row['branch_code']; + + $clientPolicyId = $row['client_policy_id']; + $policyTypeId = $row['policy_type_id']; + $employeeId =''; if ($employeeId != $row['employee_id']) { $employeeId = $row['employee_id']; } else { @@ -88,12 +100,23 @@ class DashboardController extends AdminController 'branch_code' => $branchCode, 'emp_login' => 0, 'emp_enroll' => 0, + 'client_policies' => [], 'employees' => [] ]; } - if ($employeeId !== null && $employeeRelationship == 'Self') { - // Append employee info to the branch's employees list - $groupedData[$clientId]['branches'][$branchId]['employees'][] = [ + + // Add the client policy to the branch's policies list if it exists, not already added, and policyTypeId is not equal to 1 + if ($clientPolicyId !== null && $policyTypeId != 1 && !in_array(['client_policy_id' => $clientPolicyId, 'policy_type_id' => $policyTypeId], $groupedData[$clientId]['branches'][$branchId]['client_policies'])) { + $groupedData[$clientId]['branches'][$branchId]['client_policies'][] = [ + 'client_policy_id' => $clientPolicyId, + 'policy_type_id' => $policyTypeId + ]; + } + + // Append employee info to the branch's employees list if relationship is 'Self' and not already added + $employeeKey = $employeeId . '-' . $employeeName; // unique key to identify an employee + if ($employeeId !== null && $employeeRelationship == 'Self' && !isset($groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey])) { + $groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey] = [ 'employee_id' => $employeeId, 'employee_name' => $employeeName, 'relationship' => $employeeRelationship, @@ -110,22 +133,32 @@ class DashboardController extends AdminController $groupedData[$clientId]['branches'][$branchId]['emp_enroll']++; } } - $employeeId = $row['employee_id']; } // Re-index the arrays to match the expected structure foreach ($groupedData as &$client) { + foreach ($client['branches'] as &$branch) { + $branch['employees'] = array_values($branch['employees']); + } $client['branches'] = array_values($client['branches']); } - // echo "
";
+    
         $data['client_branch_emp_list'] = $groupedData;
+        $session = \Config\Services::session();
+        $session->set('enrollment_data', json_encode($data));
+        // echo "
";
         $data['pendingActionsData'] = $pendingActionsData;
         // print_r($data);die;
 
+        
         echo view('layout/header');
         echo view('DashBoard', $data);
         echo view('layout/footer');
     }
+    
+    
+    
+    
 
     public function getDashboardNotifications()
     {
@@ -154,6 +187,90 @@ class DashboardController extends AdminController
     }
 
 
+    public static function enrollment_status() {
+        $clientModel = new ClientModel();
+        $clientPolicyModel = new ClientPolicyModel();
+        $notificationModel = new NotificationModel();
+        $employeePolicyModel = new EmployeePolicyModel();
+        $myLogger = \Config\Services::mylogger();
+    
+        $client_policy_data = $clientPolicyModel->findAll();
+        $currentDate = date('d');
+    
+        // Update policy status based on start and end dates
+        foreach ($client_policy_data as $client_policy) {
+            $id = $client_policy['id'];
+            $openDate = date('d', strtotime($client_policy['open_date']));
+            $closeDate = date('d', strtotime($client_policy['close_date']));
+            if ($currentDate == $openDate) {
+                $clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
+            } 
+            
+            if ($closeDate < $currentDate) {
+                $clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
+            }
+        }
+    
+        $reminder_whole_mail = [];
+
+        foreach ($client_policy_data as $client_policy) {
+            // Fetch client data
+            $client_data = $clientModel->find($client_policy['client_id']);
+            
+            // Fetch notification settings
+            $notification_data = $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 && $currentDate == date('d', strtotime($client_policy['reminder_date'])) ) {
+                // Fetch all employees related to the client policy
+                $employees = $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('employee_polices.status', 'draft')
+                                                 ->where('employees.relationship', 'Self')
+                                                 ->findAll();
+                // Process each employee
+                foreach ($employees as $employee) {
+                    if($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self'){
+                        $params['emp_data'] = $employee;
+                        $params['client_data'] = $client_data;
+                        $params['notification_data'] = $notification_data;
+                        
+                        // Send the mail notification
+                        $reminder_whole_mail[] = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
+                    }
+                }
+            }
+        }
+        
+        // Process and queue bulk emails
+        $temp_whole_data = [];
+        $count = 0;
+
+        foreach ($reminder_whole_mail as $whole_index => $values) {
+            foreach ($values as $index => $value) {
+                $temp_whole_data[] = $value;
+                $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]);
+                        $temp_whole_data = [];
+                        $count = 0;
+                    }
+                }
+            }
+        }
+        if(count($temp_whole_data) > 0){
+            Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
+        }
+    
+        return json_encode(true);
+    }
+
     public function featch_dashboard_data($type)
     {
         $pendingActionsController = new PendingActionsController;
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 2df33a79..c59195a3 100644
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -1816,7 +1816,6 @@ class EmpDataServiceController extends BaseController
 
 
     //Endorsement Correction
-
     public function importCorrectionValidation($params)
     {
 
@@ -2232,7 +2231,6 @@ class EmpDataServiceController extends BaseController
 
 
     //Endorsement SIEnhancement
-
     public function importSIEnhancementValidation($params)
     {
         $file_id = $params['file_id'];
@@ -2844,12 +2842,14 @@ class EmpDataServiceController extends BaseController
 
 
     //Endorsement Deletion
-
     public function importDeletionValidation($params)
-    {
+    {   
+
         $file_id = $params['file_id'];
         $file = $this->batchFileModel->where('id', $file_id)->first();
 
+        // dd($file);
+
         $client_id = $file['client_id'];
         $client_policy_id = $file['client_policy_id'];
         $client_branch_id = $file['client_branch_id'];
@@ -2954,6 +2954,7 @@ class EmpDataServiceController extends BaseController
         $query = $db->query($sql);
         $endorsement_data = $query->getResultArray();
 
+        // dd($endorsement_data);
 
         if ($endorsement_data == null || empty($endorsement_data)) {
 
@@ -3255,7 +3256,7 @@ class EmpDataServiceController extends BaseController
         $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
         $excel_data = $this->readExcelFileToArray($file_name_with_path);
         unset($excel_data[0]);
-        array_pop($excel_data);
+        // array_pop($excel_data);
 
         $emp_count = count($excel_data); //excel file count
 
@@ -3279,6 +3280,7 @@ class EmpDataServiceController extends BaseController
             $fetch_data = [
                 'client_policy_id' => $client_policy_id,
                 'client_branch_id' => $client_branch_id,
+                'client_id' => $client_id,
                 'emp_name' => $emp_name,
                 'emp_code' => $emp_code
             ];
@@ -3289,8 +3291,8 @@ class EmpDataServiceController extends BaseController
             if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) {
 
                 $employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite
-                $employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status'], 'is_active' => 0);
-                $employees_table_data[] = array('id' => $result['employees_primarykey'], 'emp_status' => $result['status'], 'is_active' => 0);
+                $employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status']);
+                $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
                 $emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete');
             }
           
@@ -3843,7 +3845,7 @@ class EmpDataServiceController extends BaseController
                     FROM employee_polices
                     JOIN employees ON employees.id = employee_polices.employee_id
                     WHERE employees.unit = '$unit'
-                    AND id IN (" . implode(',', $arrayData['employeeIds']) . ")
+                    AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
                 ")->getRow();
 
                 if($amount){
@@ -3903,7 +3905,7 @@ class EmpDataServiceController extends BaseController
                         FROM employee_polices
                         JOIN employees ON employees.id = employee_polices.employee_id
                         WHERE employees.unit = '$unit'
-                        AND id IN (" . implode(',', $arrayData['employeeIds']) . ")
+                        AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
                     ")->getRow();
                 
                 if($amount){
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 42bd37bd..82328ba1 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -98,6 +98,7 @@ class EmployeeController extends AdminController
                 emp_name : $filterData['emp_name'],
                 status   : $filterData['status'], 
             );
+            // dd($this->employeePolicyModel->getLastQuery());
 
             $data['getData'] = $filterData;
         }
@@ -162,7 +163,7 @@ class EmployeeController extends AdminController
         // dd($res);
 
         // $empServiceController = new EmployeeServiceController();
-        // $res = $empServiceController->excelFileDataValidation(['file_id' => '38']);
+        // $res = $empServiceController->employeeDisembark(['file_id' => '586']);
         // dd($res);
         // $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: '2');
         // dd($existing_famility_details);
@@ -1163,21 +1164,8 @@ class EmployeeController extends AdminController
 
         // $this->loadLayout('ecard_template/default_ecard');
 
-      $data =  [
-                    'employeeIds' => [6,8,10],
-                    'client_id' => 12,
-                    'client_policy_id' => 12,
-                    'client_branch_id' => 1,
-                    'cd_ac_no' => '34567834567892',
-                    'endorsement_no' =>  null,
-                    'count' => 3,
-                    'event_name' =>'inception',
-                    'policy_name' => 'new policy',
-                    'user_id' => 1,
-                ];
-
-                $empDataServiceController = new EmpDataServiceController();
-                $empData= $empDataServiceController->cashDepositCalculationForInception($data);
+        $empDataServiceController = new EmpDataServiceController();
+        $return = $empDataServiceController->importDeletionValidation(['file_id' => 130]);
         
     }
     
@@ -1507,6 +1495,7 @@ class EmployeeController extends AdminController
 
     public function testRackRate()
     {
+        helper('excel_util_helper');
         if ($this->request->getMethod() == 'get') {
         $filterData = $this->request->getGet('client_policy_id');
             //just load UI only
@@ -1557,26 +1546,99 @@ class EmployeeController extends AdminController
          }
 
          // print_r($family_details);
-                  return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
+                  // return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
         //get policy details
-         $policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
+         $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id);
+         $policy_details = (array)$policy_details[0];
+         // ~dd($policy_details[0]->policy_start_date);
         //get rack rates
-          $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
+          $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($policy_id,$client_id);
         //get file array or construnct dummy file array here
-          $file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception','client_branch_id' => 1,'created_by' => 1];
+          $file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1];
+         //get existing units in the current branch
+        $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $branch_id);
         //get familiy details in inception file format array from post method
-            $family_details = [  
-                            [2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', NULL, '', '', 'G', '', '', '', '', '', '',''],
-                              [1,'TEST001','Jane Doe', '01-Jan-1985', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', '0', '', '', ''],
-                            
-                          // [3,'TEST001','Peter Doe', '01-Jan-1955', 'M', 'Father', '', NULL, '', '', '', '', '', '', '', '', '',''],
-                              [4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '',''],
-                              [5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
-                          //[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
-                               [7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', '',''],
-                                 [6,'TEST001','Bob Doe', '01-Jan-1993', 'M', 'son', '50000', NULL, '', '', '', '', '', '', '', '', '',''],
-                         ];
-          $data = calculate_premimum_new($family_details,$policy_details,$all_rack_rates,$file);
+          $data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units);
+
+          foreach($data as $key => $member )
+          {
+            // ~dd($member);
+            $data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
+          }
+
+          return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
+         }
+    }
+
+
+    public function testCheckDependentConflict()
+    {
+        helper('excel_util_helper');
+        if ($this->request->getMethod() == 'get') {
+        $filterData = $this->request->getGet('client_policy_id');
+            //just load UI only
+        $this->loadLayout('rack_rate_test');
+        }
+
+
+         if ($this->request->getMethod() == 'post') {
+        $json = $this->request->getJSON();
+         // return $this->respond(['dataStatus' => false, 'code' => 200, 'data' => $data], 200);
+         // $data = (json_decode(json_encode($data),true));
+         $client_id = $json->client_id;
+         $policy_id = $json->policy_id;
+         $branch_id = $json->branch_id;
+         $tabledata = $json->data;
+         
+         if(count($tabledata))
+         {
+             $family_details = [];
+             foreach($tabledata as $key => $row)
+             {
+                $row = (array)$row;
+                if(!$row['column12'])
+                {
+                    
+                    $temp[0] = $row['column1'];//sno
+                    $temp[1] = $row['column2'];//emp code
+                    $temp[2] = $row['column3'];//name
+                    $temp[3] = $row['column4'];//DOB
+                    $temp[4] = strtoupper($row['column5']);//Gender
+                    $temp[5] = $row['column6'];//relation
+                    $temp[6] = $row['column7'];//SI
+                    $temp[7] = $row['column8'];//DOC
+                    $temp[8] = '';//DOJ
+                    $temp[9] = $row['column9'];//BP
+                    $temp[10] = $row['column10'];//band
+                    $temp[11] = '';//designation
+                    $temp[12] = '';//mobile
+                    $temp[13] = '';//EMail
+                    $temp[14] = '';//CE
+                    $temp[15] = '';//RFE
+                    $temp[16] = '';//DOE
+                    $temp[17] = '';//Unit
+                    $temp[18] = $row['column11'];//unit
+                    $family_details[] = $temp;
+                }
+             }
+         }
+
+         // print_r($family_details);
+                  // return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
+        //get policy details
+         $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id);
+         $policy_terms = (array)$policy_details[0];
+        // dd($policy_terms);
+         $policy_terms = json_decode($policy_terms['policy_terms']);
+         $policy_terms = (array) $policy_terms;// convert obj to array
+        
+        //get file array or construnct dummy file array here
+          $file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1]; 
+        //get familiy details in inception file format array from post method
+          $result = check_dependent_conflict($family_details, $policy_terms, $file['action']);
+
+
+          return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['policy_terms' => $policy_terms['family_floaters'],'result' => $result] ], 200);
          }
     }
 
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 2b2e017c..01735912 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -954,7 +954,7 @@ class EmployeeRestController extends AdminController
 
     public function getEmployeePolicy()
     {            
-        // try {
+        try {
 
             $id = $this->request->getGet('id');
             $emp_code = $this->request->getGet('emp_code');
@@ -1114,21 +1114,21 @@ class EmployeeRestController extends AdminController
 
                         // Add family floter buttons placement data for FE validation
                         if(count($floters)){
-                        foreach ($floters as $familyFloatesValue) {
+                            foreach ($floters as $familyFloatesValue) {
 
-                            $temp2['is_value_exist'] = false;
-                            $temp2['data']['family_floater_key'] = $familyFloatesValue;
-                            $temp2['data']['client_policy_id'] = $array->ClientPolicyId; 
-                            $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); 
-                            $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
-                        
-            
-                            $temp2['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue);   
+                                $temp2['is_value_exist'] = false;
+                                $temp2['data']['family_floater_key'] = $familyFloatesValue;
+                                $temp2['data']['client_policy_id'] = $array->ClientPolicyId; 
+                                $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); 
+                                $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
+                            
+                
+                                $temp2['data']['age_validation'] = $this->getAgeRange($decodedArray,$familyFloatesValue);   
 
-                            array_push($data,$temp2);
+                                array_push($data,$temp2);
 
+                            }
                         }
-                    }
 
                         $array->mapped_family_floaters = $data;
                         $array->type = "Group Medical Coverage";
@@ -1164,9 +1164,9 @@ class EmployeeRestController extends AdminController
             }else{
                 return $this->respond(['status' => 'failed','code' => 404,'data' => []], 200);
             }
-        // } catch (\Exception $e) {
-        //     return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
-        // }
+        } catch (\Exception $e) {
+            return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
+        }
     }
 
 
@@ -1178,6 +1178,7 @@ class EmployeeRestController extends AdminController
                                             ->where('client_branch_id',$client_branch_id)
                                             ->where('is_active', 1 )
                                             ->where('is_addon_value',0)->findAll();
+        // return  $employeeData;
         foreach ($GmcParrentsPolicy as $key => $array) {
 
         
@@ -1241,6 +1242,7 @@ class EmployeeRestController extends AdminController
 
             // Convert familyFloaters terms data to plain array 
             $floters = $this->FloterConvertion($familyFloates);
+            
             $data = [];
             foreach ($floters as $familyFloatesValue) { 
                 $dependent =   preg_replace('/\d/', '', $familyFloatesValue);
@@ -1386,8 +1388,18 @@ class EmployeeRestController extends AdminController
                 
             }
         }
+
+        $first_two_chars = substr($result, 0, 3);
+       
+        if($first_two_chars == "  +"){
+            $modified_string = substr($result, 3);
+            return "Can Add ".$modified_string;
+        }else{
+            return $result;
+        }
+           return substr($result, 0, 2) !== " +";
         
-        return $result;
+       
     }
 
     public function getClientDetails()
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 4ddd51e6..f31460b2 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -906,8 +906,8 @@ class EmployeeServiceController extends AdminController
                      }
 
                      //proceed next data level validation in JOB queue
-                     // $job_details  = new Jobs();
-                     // $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
+                     $job_details  = new Jobs();
+                     $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
                      // $jobWorker = new JobWorker();
                      // JobWorker::processJob($r);
                      
@@ -1024,7 +1024,7 @@ class EmployeeServiceController extends AdminController
                                 }
                             }
 
-                             if(($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0 && ($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)) // 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']);
                                 if(!$res['is_self_found'])
@@ -1248,12 +1248,11 @@ class EmployeeServiceController extends AdminController
 
             $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
 
-            //get existing units in the current branch
-             $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
-
-
             // $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
             $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid(),'client_branch_id' => $params['client_branch_id']];
+
+            //get existing units in the current branch
+            $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
             // dd($this->employeeModel->getLastQuery());
             // Kint::dump($existing_famility_details);die();
              $employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
@@ -1273,7 +1272,7 @@ class EmployeeServiceController extends AdminController
 
 
         // die();
-        return (($employee_data_group_by_family));
+        return (count($employee_data_group_by_family));
 
     }
 
@@ -1500,14 +1499,14 @@ class EmployeeServiceController extends AdminController
                 //get applicable slab rate for current member relation
                 $pre_rack_rate_name = '';
                 $applicable_rack_rate_name = '';
-                $applicable_rack_rate_master = '';
+                $applicable_rack_rate_master = [];
                 foreach ($slab_details['slab_rates'] as $skey => $slab_value) 
                 {
                     if($pre_rack_rate_name != $slab_value['rack_rate_name'])
                     {
                         $pre_rack_rate_name = $slab_value['rack_rate_name'];
                         $rack_rate_json = json_decode($slab_value['additional_relationship']);
-                        if(in_array(strtolower($employee['relationship']), $rack_rate_json) && $rack_rate_json[ strtolower($employee['relationship']) ] != 0 && $rack_rate_json[ strtolower($employee['relationship']) ] != NA)
+                        if(in_array(strtolower($employee['relationship']), $rack_rate_json) && $rack_rate_json[ strtolower($employee['relationship']) ] != 0 && $rack_rate_json[ strtolower($employee['relationship']) ] != 'NA')
                         {
                             $applicable_rack_rate_name = $slab_value['rack_rate_name'];
                             $applicable_rack_rate_master = $slab_value['grid_master'];
diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php
index eb9f96e2..5c099fe8 100644
--- a/app/Controllers/JobWorker.php
+++ b/app/Controllers/JobWorker.php
@@ -3,14 +3,9 @@
 namespace App\Controllers;
 
 
+
+
 use App\Models\JobModel;
-use App\Models\ClientModel;
-use App\Models\ClientPolicyModel;
-use App\Models\NotificationModel;
-use App\Models\EmployeePolicyModel;
-
-use App\Helpers\sendMailNotification;
-
 class JobWorker extends AdminController
 {
     const STATUS_DONE = 'done';
@@ -330,70 +325,7 @@ class JobWorker extends AdminController
     }
 
 
-    public static function enrollment_status() {
-        $clientModel = new ClientModel();
-        $clientPolicyModel = new ClientPolicyModel();
-        $notificationModel = new NotificationModel();
-        $employeePolicyModel = new EmployeePolicyModel();
-        $myLogger = \Config\Services::mylogger();
-    
-        $client_policy_data = $clientPolicyModel->where('is_active', 1)
-                                                ->where('policy_status', 1)
-                                                ->where('inception_type', 2)
-                                                ->findAll();
-        $currentDate = date('Y-m-d');
-    
-        // Update policy status based on start and end dates
-        foreach ($client_policy_data as $client_policy) {
-            $id = $client_policy['id'];
-            
-            if ($currentDate == $client_policy['policy_start_date']) {
-                $clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
-            } 
-            if ($client_policy['policy_end_date'] < $currentDate) {
-                $clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
-            }
-        }
-    
-        $reminder_whole_mail = [];
-        foreach ($client_policy_data as $client_policy) {
-            $employee = $employeePolicyModel->select('employees.*')
-                                            ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
-                                            ->where('employee_polices.client_policy_id', $client_policy['id'])
-                                            ->first();
-            $client_data = $clientModel->find($client_policy['client_id']);
-            $notification_data = $notificationModel->where('client_id', $client_policy['client_id'])
-                                                   ->where('template_name', 'member_reminder_mail')
-                                                   ->first();
-            
-            if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == $client_policy['reminder_date']) {
-                $params['emp_data'] = $employee;
-                $params['client_data'] = $client_data;
-                $params['notification_data'] = $notification_data;
-                $reminder_whole_mail[] = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
 
-            }
-        }
-        // Process and queue bulk emails
-        $temp_whole_data = [];
-        $count = 0;
-        foreach ($reminder_whole_mail as $whole_index => $values) {
-            foreach ($values as $index => $value) {
-                $temp_whole_data[] = $value;
-                $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]);
-                        $temp_whole_data = [];
-                        $count = 0;
-                    }
-                }
-            }
-        }
-    
-        return json_encode(true);
-    }
     
     
 
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index f364d1de..603f9e51 100644
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1086,6 +1086,7 @@ class MasterController extends AdminController
             'insurer_id' => $data['insurer_id'],
             'description' => 'opening Amount',
             'transaction_type' => 'Credit',
+            'event_name' => null,
             'updated_by' => 1,
         ];
 
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index 4f81d9d3..0f3fd7d0 100644
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -227,11 +227,14 @@ if(!function_exists('check_si'))
 {
     function check_si($row,$policy_details,$slab_details)
     {
+        // Kint::dump($policy_details);
+        $policy_details = (array)$policy_details[0];
+        // dd($policy_details);
         $return_array = array('status' => true,'error' => '');
         $is_si_found = false;
         $is_age_slab_found = false;
 
-        if($policy_details[0]['policy_type_id'] == 1 && $slab_details[0]['policy_grid_id'] == 1 && $slab_details[0]['si_or_bp'] == 2) // GPA && grid type 1 for GPA && sub type is basic pay
+        if($policy_details['policy_type_id'] == 1 && $slab_details[0]['policy_grid_id'] == 1 && $slab_details[0]['si_or_bp'] == 2) // GPA && grid type 1 for GPA && sub type is basic pay
         {
              $is_si_found = true;
              $is_age_slab_found = true;
@@ -1008,7 +1011,7 @@ if (!function_exists('transform_excel_data_to_db'))
             // $policy['reason_for_exit'] = $memArr[17];
             
             $policy['client_policy_id'] = $actionArr['policy_id'];
-            $policy['date_coverage'] = isset($memArr[7]) ? convert_string_to_date($memArr[7],'Y-m-d') : NULL;
+            $policy['date_coverage'] = isset($memArr[7]) && $memArr[7] != '' ? convert_string_to_date($memArr[7],'Y-m-d') : NULL;
             $policy['policy_end_date'] = null;
             $policy['days'] = null;
             $policy['premium'] = null;
@@ -1986,13 +1989,14 @@ if(!function_exists('check_unit'))
 {
     function check_unit($row,$existing_units)
     {
-        
+        $temp = $row[18];
+        $temp = empty($row[18]) ? $row[18] : trim($row[18]);
         
         if(in_array($row['current_action'], ['I','A','MI']) )
         {
             if(count($existing_units) == 1)
             {
-                if(empty(trim($row[18])))
+                if(empty($temp))
                 {
                     return array('status' => true);
                 }
@@ -2000,11 +2004,11 @@ if(!function_exists('check_unit'))
 
             if(strtolower($row[5]) == 'self')
             {
-                if(in_array(trim($row[18]),$existing_units)) //18 is unit name
+                if(in_array($temp,$existing_units)) //18 is unit name
                 {
                     return array('status' => true);
                 }
-                else if(!empty(trim($row[18])))
+                else if(!empty($temp))
                 {
                     return array('status' => false,'error' => 'wrong unit name');
                 }
@@ -2015,13 +2019,13 @@ if(!function_exists('check_unit'))
             }
             else
             {
-                 if(empty(trim($row[18])))
+                 if(empty($temp))
                 {
                     return array('status' => true);
                 }
                 else
                 {
-                    if(in_array(trim($row[18]),$existing_units)) //18 is unit name
+                    if(in_array($temp,$existing_units)) //18 is unit name
                     {
                         return array('status' => true);
                     }
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index a43c1812..b6101356 100644
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -82,7 +82,7 @@ class ClientModel extends Model
                 $client['policies'] = $clientPolicies; 
 
                 $clientBranchModel = new ClientBranchModel();
-                $clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id'])
+                $clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id','client_branch.units'])
                                   ->where('client_branch.client_id',$client['id'])
                                   ->findAll();
 
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index f6d8b942..29027630 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -20,6 +20,9 @@ class ClientPolicyModel extends Model
         "policy_start_date",
         "policy_end_date",
         "reminder_date",
+        "open_date",
+        "close_date",
+        "close_date",
         "insured",
         "no_of_employees",
         "no_of_lives",
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index bd6a5e6f..e0e29c14 100644
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -109,7 +109,7 @@ class EmployeeModel extends Model
         $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','policies.name as policy_name','client_policy.is_addon'])
                         ->join('employee_polices', 'employee_polices.employee_id = employees.id')
                         ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
-                        ->join('policies', 'policies.id = client_policy.policy_id')
+                        ->join('policies', 'policies.id = client_policy.policy_id','left')
                         ->where('employees.is_active',1)
                          ->when($client_policy_id, function($query) use ($client_policy_id){
                             return $query->where('employee_polices.client_policy_id',$client_policy_id);
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 52ffe324..6a668532 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -81,7 +81,7 @@ class EmployeePolicyModel extends Model
        
         $result = $this->select([
             'employee_polices.*',
-            'pm.name as policy_name',
+            'policy_type.policy_type as policy_name',
             'im.short_name as insurer_short_name',
             'ib.branch_name as insurer_branch_name',
             'ib.branch_code as insurer_branch_code',
@@ -109,8 +109,8 @@ class EmployeePolicyModel extends Model
         ])
         ->join('employees emp', 'employee_polices.employee_id = emp.id')
         ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
-        ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
-        ->join('policy_type', 'policy_type.id = pm.policy_type_id')
+        ->join('policies pm', 'cp.policy_id = pm.id', 'left') //pm - policy master
+        ->join('policy_type', 'policy_type.id = cp.policy_type_id')
         ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master
         ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch
         ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
@@ -511,6 +511,7 @@ class EmployeePolicyModel extends Model
                 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,
@@ -604,6 +605,7 @@ class EmployeePolicyModel extends Model
 
         $client_policy_id = $fetch_data['client_policy_id'];
         $client_branch_id = $fetch_data['client_branch_id'];
+        $client_id = $fetch_data['client_id'];
         $emp_name = $fetch_data['emp_name'];
         $emp_code = $fetch_data['emp_code'];
 
@@ -614,6 +616,18 @@ class EmployeePolicyModel extends Model
                     ep.id as emp_policy_primarykey,
                     e.id as employees_primarykey,
                     ee.group_key,
+                    (
+                        SELECT employees.id
+                        FROM employees
+                        WHERE client_id = '$client_id'
+                            AND client_branch_id = '$client_branch_id'
+                            AND is_active = 1
+                            AND emp_status = 'active'
+                            AND emp_code = '$emp_code'
+                            AND name = '$emp_name'
+                        LIMIT 1
+                    ) AS employees_id,
+
                     MAX(
                     CASE
                         WHEN ee.field_name = 'date_of_exit' THEN ee.new_value
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 6250897f..1553e365 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -112,10 +112,7 @@
                                 
                                 
                             
-                            
- - -
+
@@ -146,7 +143,18 @@
- +
+ + +
+
+ + +
+
+ + +