diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 95cbabf3..d1edddc5 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -114,6 +114,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->group("terms", ["filter" => "authMVC"], function ($routes) { $routes->post("gpa_create", "ClientController::policyGPATerms"); $routes->post("edit", "ClientController::editClientPolicyPremium"); + $routes->post("other_terms", "ClientController::otherPolicyTermsFormSubmit"); }); }); @@ -244,6 +245,10 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("delete-additional-rack-rate/(:any)", "ClientController::deleteAdditionalRackRate/$1"); $routes->get("check_cd_ac_no/(:any)", "MasterController::checkUniqueCDAccountNumber/$1"); $routes->get("get_cd_ac/(:any)", "ClientController::get_cd_ac/$1"); + $routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1"); + $routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1"); + $routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1"); + $routes->get("checkHRNumber/(:any)", "ClientController::checkHRNumber/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2dbe4d60..02269a95 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -32,6 +32,8 @@ use App\Models\EmployeeModel; use App\Models\EmployeePolicyModel; use App\Models\NotificationModel; use App\Models\CDMasterModel; +use App\Models\PolicyTypeModel; + @@ -65,13 +67,14 @@ class ClientController extends AdminController protected $employeePolicyModel; protected $notificationModel; protected $CDMasterModel; + protected $policyTypeModel; public function __construct() { set_session_context('Client'); $this->myLogger = \Config\Services::mylogger(); - + $this->clientModel = new ClientModel(); $this->userModel = new UserModel(); $this->clientBranchModel = new ClientBranchModel(); @@ -93,8 +96,10 @@ class ClientController extends AdminController $this->policyPremium2Model = new PolicyPremium2Model(); $this->employeeModel = new EmployeeModel(); $this->employeePolicyModel = new EmployeePolicyModel(); - $this->notificationModel = new NotificationModel(); - $this->CDMasterModel = new CDMasterModel(); + $this->notificationModel = new NotificationModel(); + $this->CDMasterModel = new CDMasterModel(); + $this->policyTypeModel = new PolicyTypeModel(); + @@ -613,22 +618,13 @@ class ClientController extends AdminController $policy_type_id = $this->request->getPost('policy_type_id'); $client_branch_id = $this->request->getPost('client_branch_id'); - - $policyCount = $this->clientPolicyModel - ->where('policy_type_id', $policy_type_id) - ->where('client_branch_id', $client_branch_id) - ->countAllResults(); - - if($policyCount > 0 ){ - $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id')); - return $this->respond(['status' => 'policy_exist','code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE'], 200); - } - - $insurerValue = (string) $this->request->getPost('insurer'); - list($insurerBranchId, $insurerId) = explode('-', $insurerValue); $client_id = $this->request->getPost('client_id'); + $insurerValue = (string) $this->request->getPost('insurer'); + list($insurerBranchId, $insurerId) = explode('-', $insurerValue); + + $data['insurer_branch_id'] = $insurerBranchId; $data['insurer_id'] = $insurerId; @@ -911,6 +907,24 @@ class ClientController extends AdminController $policyPremium = $this->policyPremium1Model->insert($data); } + }else if ($si_or_bp == '2') { + + $premium = str_replace(',', '', $this->request->getPost('gpa_basic_premium[]')); + $sum_insure = str_replace(',', '', $this->request->getPost('gpa_basic_si[]')); + $basic_pay = str_replace(',', '', $this->request->getPost('basic_pay[]')); + + for ($i = 0; $i < count($premium); $i++) { + + $data['si_or_bp'] = $this->request->getPost('si_or_bp'); + $data['basic_multiplier'] = str_replace(',', '', $this->request->getPost('basic_multiplier')); + $data['multiplier'] = $this->request->getPost('premium_multiplier'); + $data['basic_pay'] = $basic_pay[$i]; + $data['si'] = $sum_insure[$i]; + $data['premium'] = $premium[$i]; + + $policyPremium = $this->policyPremium1Model->insert($data); + } + }else { $data['premium'] = str_replace(',', '', $this->request->getPost('gpa_basic_premium')); @@ -1205,19 +1219,11 @@ class ClientController extends AdminController $emp_count = $this->employeePolicyModel - ->join('client_policy cp', "cp.id = employee_polices.client_policy_id") - ->where("employee_polices.client_policy_id", $client_policy_id) - ->where("employee_polices.status", 'active') - ->where("employee_polices.is_active", 1) - ->countAllResults(); - - // $emp_count = count($data); - - // if($emp_count == 0){ - // $emp_count = true; - // }else{ - // $emp_count = false; - // } + ->join('client_policy cp', "cp.id = employee_polices.client_policy_id") + ->where("employee_polices.client_policy_id", $client_policy_id) + ->where("employee_polices.status", 'active') + ->where("employee_polices.is_active", 1) + ->countAllResults(); $data = $this->policesModel->getPolicyPremium($record['policy_id']); @@ -1225,9 +1231,11 @@ class ClientController extends AdminController $gmc_pattern = '/gmc/i'; $gpa_pattern = '/gpa/i'; $subject = $data[0]->policy_type; + $policy_type_id = $data[0]->id; + if (preg_match($gmc_pattern, $subject)) { $search_term = 'GMC'; - } else if (preg_match($gpa_pattern, $subject)) { + } else if (preg_match($gpa_pattern, $subject) || $policy_type_id == 6 || $policy_type_id == 7) { $search_term = 'GPA'; } else { $search_term = ""; @@ -1235,7 +1243,7 @@ class ClientController extends AdminController $results = $this->policyGridModel->like('policy_type', $search_term)->findAll(); - if ($search_term === 'GPA') { + if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) { $premiumData = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); } else if ($search_term === 'GMC') { @@ -1246,9 +1254,6 @@ class ClientController extends AdminController $premiumData = ""; } - - - // echo '
';
         // print_r($premiumData); die;
@@ -1322,7 +1327,7 @@ class ClientController extends AdminController
 
             return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
 
-        } else if ($search_term === 'GPA') {
+        } else if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) {
 
             return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
         } else {
@@ -1343,7 +1348,7 @@ class ClientController extends AdminController
 
             $data['sum_insured']   =str_replace(',', '',$this->request->getPost("sum_insured"));
             $data['family_floater']   =$this->request->getPost("family_floater") ? $this->request->getPost("family_floater") : 0;
-            $data['corporatebuffer'] = $this->request->getPost("corporatebuffer") ? $this->request->getPost("corporatebuffer") : 0;
+            // $data['corporatebuffer'] = $this->request->getPost("corporatebuffer") ? $this->request->getPost("corporatebuffer") : 0;
             $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];        
             
             $data['age_ratio']['self']['min'] =  $this->request->getPost("self_min_age") ? $this->request->getPost("self_min_age") :0;
@@ -1427,7 +1432,7 @@ class ClientController extends AdminController
                         }
                     }
 
-                    $data['family_floaters']['elders_count'] =$this->request->getPost("member_count") ? $this->request->getPost("member_count") : 0;
+                    $data['family_floaters']['elders_count'] =$this->request->getPost("elder_member_count") ? $this->request->getPost("elder_member_count") : 0;
 
                     // print_r($data);die;
 
@@ -1455,7 +1460,7 @@ class ClientController extends AdminController
             $data['bioabsorbablestenttoriclensmultifocallens'] =$this->request->getPost("bioabsorbablestenttoriclensmultifocallens");
             $data['roomrentlimit'] =str_replace(',', '',$this->request->getPost("roomrentlimit"));
             $data['proportionatedeductionclause'] =str_replace(',', '',$this->request->getPost("proportionatedeductionclause"));
-            $data['nursingallowance'] =str_replace(',', '',$this->request->getPost("nursingallowance"));
+            // $data['nursingallowance'] =str_replace(',', '',$this->request->getPost("nursingallowance"));
             $data['ailmentcapping'] =str_replace(',', '',$this->request->getPost("ailmentcapping"));
             $data['ambulancecharges'] =str_replace(',', '',$this->request->getPost("ambulancecharges"));
             $data['airambulance'] =str_replace(',', '',$this->request->getPost("airambulance"));
@@ -1463,6 +1468,12 @@ class ClientController extends AdminController
             $data['reasonableandcustomarycharges'] =str_replace(',', '',$this->request->getPost("reasonableandcustomarycharges"));
             $data['ayudhtreatmentcover'] =str_replace(',', '',$this->request->getPost("ayudhtreatmentcover"));
 
+            $data['congenitaldiseasesexternal'] =str_replace(',', '',$this->request->getPost("congenitaldiseasesexternal"));
+            $data['optionalparentalcopay'] =str_replace(',', '',$this->request->getPost("optionalparentalcopay"));
+            $data['posthospitalizationcover'] =str_replace(',', '',$this->request->getPost("posthospitalizationcover"));
+            $data['corporatebuffer'] =str_replace(',', '',$this->request->getPost("corporatebuffer"));
+            $data['sublimitofcorporatebuffer'] =str_replace(',', '',$this->request->getPost("sublimitofcorporatebuffer"));
+
             if ($data['ayudhtreatmentcover'] == 1) {
                 $data['ayushTreatmentCoverData']   = str_replace(',', '',$this->request->getPost("ayushTreatmentCoverData"));
             }else{
@@ -1483,6 +1494,7 @@ class ClientController extends AdminController
             $data['days_from_dod'] =str_replace(',', '',$this->request->getPost("days_from_dod"));
             $data['special_condition_label'] = str_replace(',', '',$this->request->getPost("special_condition_label")) ?? [];
             $data['special_condition_input'] = str_replace(',', '',$this->request->getPost("special_condition_input")) ?? [];
+            $data['multiple_sum_insured'] = str_replace(',', '',$this->request->getPost("multiple_sum_insured")) ?? [];
 
             $data['cataract'] =str_replace(',', '',$this->request->getPost("cataract"));
 
@@ -1537,16 +1549,22 @@ class ClientController extends AdminController
         //     ->where("employees.emp_status",'active')
         //     ->countAllResults();
 
-        $emp_count_by_policy = $this->employeePolicyModel->where('client_policy_id',$client_policy_id)->where('is_active',1)->countAllResults();
+        $emp_count_by_policy = $this->employeePolicyModel
+                        ->where('client_policy_id',$client_policy_id)
+                        ->where("status", 'active')
+                        ->where('is_active',1)
+                        ->countAllResults();
         
-        // if($emp_count == 0){
-        //     $emp_count = true;
-        // }else{
-        //     $emp_count = false;
-        // }
 
         if ($record) {
-            return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'],  'policy_name' => $policy_name,'policy_addon' => $record['is_addon'], 'emp_count_by_policy'=>$emp_count_by_policy], 200);
+            return $this->respond([
+                'Status' => true,
+                'code' => 200,        
+                'data' => $record['policy_terms'],  
+                'policy_name' => $policy_name,
+                'policy_addon' => $record['is_addon'], 
+                'emp_count_by_policy'=>$emp_count_by_policy],
+            200);
         } else {
             return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.',  'policy_name' => $policy_name], 200);
         }
@@ -1612,6 +1630,8 @@ class ClientController extends AdminController
             $data['worldwideCover']        = $this->request->getPost("worldwideCover");
             $data['gpa_special_condition_label'] = str_replace(',', '',$this->request->getPost("gpa_special_condition_label")) ?? [];
             $data['gpa_special_condition_input'] = str_replace(',', '',$this->request->getPost("gpa_special_condition_input")) ?? [];
+            $data['multiple_sum_insured'] = str_replace(',', '',$this->request->getPost("multiple_sum_insured")) ?? [];
+
 
 
             $jsonData = json_encode($data);
@@ -1887,7 +1907,7 @@ class ClientController extends AdminController
             "sum_insured" => "Sum Insured",
             "family_floater" => "Family Floater",
             "family_floaters" => "Family Floaters",
-            "member_count" => "Elders Count:",
+            "elders_count" => "Elders Count:",
             "other_member_min_age" => "Min Age:",
             "other_member_max_age" => "Min Age:",
             "waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases",
@@ -1952,8 +1972,6 @@ class ClientController extends AdminController
         ];
           
 
-
-
         foreach ($client_policy as $key => $value) {
 
             $policy_terms = json_decode($value['policy_terms'], true);
@@ -2049,19 +2067,27 @@ class ClientController extends AdminController
             } else if (array_key_exists($key, $mapping)) {
                 $transformedData[$mapping[$key]] = $value;
             } else if ($key == 'special_condition_label') {
-
-                foreach ($value as $key => $value) {
-                    $transformedData[$value] = $data['special_condition_input'][$key];
+            
+                if (is_array($value)) {
+                    foreach ($value as $key => $value) {
+                        $transformedData[$value] = $data['special_condition_input'][$key];
+                    }
                 }
-            } else if ($key == 'gpa_special_condition_label') {
 
-                foreach ($value as $key => $value) {
-                    $transformedData[$value] = $data['gpa_special_condition_input'][$key];
+            } else if ($key == 'gpa_special_condition_label') {
+                if (is_array($value)) {
+                    foreach ($value as $key => $value) {
+                        $transformedData[$value] = $data['gpa_special_condition_input'][$key];
+                    }
+                }
+            } else if ($key == 'other_special_condition_label') {
+                if (is_array($value)) {
+                    foreach ($value as $key => $value) {
+                        $transformedData[$value] = $data['other_special_condition_label'][$key];
+                    }
                 }
             } else if ($key == 'age_ratio') {
-
                 if (isset($data['sumInsured2'])) {
-
                     $transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")";
                 }
             } else {
@@ -2157,4 +2183,124 @@ class ClientController extends AdminController
     }
 
 
+    public function otherPolicyTermsFormSubmit()
+    {
+
+        $client_policy_id = $this->request->getPost("client_policy_id");
+        $policy_terms = $this->request->getPost("policy_terms");
+
+        $record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
+
+        if ($record) {
+
+            $update = $this->clientPolicyModel->where('id', $client_policy_id)->set('policy_terms',  $policy_terms)->update();
+
+            if ($update) {
+                return $this->respond(['status' => true, 'code' => 200, 'message' => 'Data updated successfully', 'client_policy_id' => $client_policy_id], 200);
+            } else {
+                return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update data', 'formdata' => $this->request->getPost()], 200);
+            }
+        } else {
+
+            return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to store data. The client policy does not exist', 'formdata' => $this->request->getPost()], 200);
+        }
+    }
+
+
+    public function checkPolicyType($client_policy_id, $policy_type_id, $client_branch_id, $client_id){
+
+        $policyCount = $this->clientPolicyModel
+        ->where('policy_type_id', $policy_type_id) 
+        ->where('client_branch_id', $client_branch_id)
+        ->where('client_id', $client_id)
+        ->countAllResults(); 
+
+        if($policyCount > 0 ){
+            $clientPoliceData =  $this->clientPolicyModel->getClientPolicyByClientId($client_id);
+            return $this->respond(['status' => true,'code' => 200, 'count' =>  $policyCount, 'data' => $clientPoliceData, 'method' => 'CERATE' ,'client_id' => $client_id, 'client_branch_id' => $client_branch_id, 'policy_type_id' => $policy_type_id], 200);
+        }else{
+            return $this->respond(['status' => false,'code' => 200,'client_id' => $client_id, 'client_branch_id' => $client_branch_id, 'policy_type_id' => $policy_type_id], 200);
+        }
+
+    }
+
+
+    public function getPolicyTerms($client_policy_id)
+    {
+        $policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first();
+    
+        if (!$policy_terms) {
+            return $this->respond(['status' => false, 'error' => 'Policy not found'], 404);
+        }
+    
+        if (is_array($policy_terms)) {
+            if (!isset($policy_terms['policy_terms'])) {
+                return $this->respond(['status' => false, 'error' => 'Policy terms not found in array'], 500);
+            }
+            $JSON = json_decode($policy_terms['policy_terms']);
+        } elseif (is_object($policy_terms)) {
+            if (!isset($policy_terms->policy_terms)) {
+                return $this->respond(['status' => false, 'error' => 'Policy terms not found in object'], 500);
+            }
+            $JSON = json_decode($policy_terms->policy_terms);
+        } else {
+            return $this->respond(['status' => false, 'error' => 'Unexpected data type for policy terms'], 500);
+        }
+    
+        if (!$JSON) {
+            return $this->respond(['status' => false, 'error' => 'Invalid JSON format in policy terms'], 500);
+        }
+    
+        $multi_si = [];
+    
+        if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) {
+            $multi_si[] = $JSON->sum_insured;
+        } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) {
+            $multi_si[] = $JSON->sumInsured2;
+        }
+    
+        if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) {
+            foreach ($JSON->multiple_sum_insured as $msi) {
+                if (!empty($msi)) {
+                    $multi_si[] = $msi;
+                }
+            }
+        }
+    
+        return $this->respond(['status' => true, 'data' => $multi_si], 200);
+    }
+    
+    
+
+    public function getPolicyTermsFormJson($policy_type_id){
+
+        $JSON = $this->policyTypeModel->where('id', $policy_type_id)->first();
+        return $this->respond(['status' => true, 'data' => $JSON], 200);
+    }
+
+    public function createPolicyTermsHtmlAsJSON(){
+
+        
+    }
+
+    public function checkHRNumber($mobileNumber)
+    {
+        try {
+            $mobileNumberCount = $this->levelContactModel
+                            ->join('client_branch', 'client_branch.id = level_contacts.ref_id')
+                            ->join('clients', 'clients.id = client_branch.client_id')
+                            ->where('clients.is_active', 1)
+                            ->where('client_branch.is_active', 1)
+                            ->where('level_contacts.is_active', 1)
+                            ->where('level_contacts.contact_type', 'client')
+                            ->where('level_contacts.mobile', $mobileNumber)
+                            ->countAllResults();
+            return $this->respond(['status' => true, 'data' => $mobileNumberCount, 'message' => "try"], 200);
+        } catch (\Exception $e) {
+            log_message('error', 'Error checking mobile number: ' . $e->getMessage());
+            return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500);
+        }
+    }
+    
+
 }
\ No newline at end of file
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 2d0febe4..3cb36091 100644
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -145,7 +145,8 @@ class EmpDataServiceController extends BaseController
 
         if($cash_balance == null){
 
-            $cash_balance = $this->CDMasterModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
+            $balance = $this->CDMasterModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
+            $cash_balance['balance'] = $balance['opening_bal'];
         }
 
 
@@ -198,7 +199,7 @@ class EmpDataServiceController extends BaseController
             'NAME OF EMP/DEP',
             'EMP ID',
             'EMP/DEP TYPE',
-            'RELATION',
+            'RELATIONSHIP CODE',
             'DOB',
             'GENDER',
             'PRE EXISTING AILMENTS',
@@ -683,7 +684,7 @@ class EmpDataServiceController extends BaseController
         unset($excel_data[0]);
         array_pop($excel_data);
 
-        $inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATION','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL'];
+        $inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATIONSHIP CODE','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL'];
 
         foreach ($inceptionHeader as $key => $value) {
             if($excel_header[$key] != $value){
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 61c66278..c2447397 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -79,13 +79,16 @@ class EmployeeController extends AdminController
             $data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
                 client_id: $filterData['client_id'], 
                 policy_id: $filterData['policy_id'], 
-                status: $filterData['status'], 
-                branch_id: $filterData['branch_id']
+                branch_id: $filterData['branch_id'],
+                emp_code : $filterData['emp_code'],
+                emp_name : $filterData['emp_name'],
+                status   : $filterData['status'], 
             );
 
             $data['getData'] = $filterData;
         }
 
+        // dd($this->request->getGet());
         $this->myLogger->logme('error', 'list called');
         $this->loadLayout('employee_list', $data);
     }
@@ -772,13 +775,9 @@ class EmployeeController extends AdminController
             ->findAll();
 
         $emp_count = count($data);
-
-        if ($data) {
-            return $this->respond(['dataStatus' => true, 'code' => 200, 'emp_count' => $emp_count], 200);
-        } else {
-
-            return $this->respond(['dataStatus' => false, 'code' => 404], 404);
-        }
+        $events = ['inception' => 'Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
+        return $this->respond(['dataStatus' => true, 'code' => 200,  'emp_count' => $emp_count, 'events' => $events, 'client_policy_id' => $id], 200);
+       
     }
 
 
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index ed6bf76e..25b4f08d 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -36,7 +36,7 @@ class EmployeeServiceController extends AdminController
     protected $empEndorsementModel;
     protected $messageModel;
     protected $general_relationships = ['self' => ['name' => 'Self', 'gender' => 'M','age_min' => 18,'age_max' => null], 'spouse' => ['name' => 'Spouse', 'gender' => 'F','age_min' => 18,'age_max' => null], 'son' => ['name' => 'Son', 'gender' => 'M','age_min' => null,'age_max' => 25], 'daughter' => ['name' => 'Daughter', 'gender' => 'F','age_min' => null,'age_max' => 25], 'father' => ['name' => 'Father', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother' => ['name' => 'Mother', 'gender' => 'F','age_min' => 18,'age_max' => null], 'father-in-law' => ['name' => 'Father in Law', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother-in-law' => ['name' => 'Mother in Law', 'gender' => 'F','age_min' => 18,'age_max' => null]];
-    protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
+    protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>null,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom' => 'check_doc','params' => ['row','policy_details']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
 
     protected $deletion_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'change_event'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Change event','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
 
@@ -350,7 +350,7 @@ class EmployeeServiceController extends AdminController
         $relationship = $this->general_relationships;
 
 
-        if(in_array($file['action'],['inception','addition','dependent_addition']))// the below funcitons are only for I,DA,A
+        if(in_array($file['action'],['inception','addition','dependent_addition','deletion','correction','si_enhancement']))// the below funcitons are only for I,DA,A
         {
                 $employee_data_group_by_family = data_group_by_family($excel_data);
 
@@ -359,7 +359,10 @@ class EmployeeServiceController extends AdminController
                     {
                         $temp = $policy_terms['family_floaters'];
                         $temp = is_array($temp) ? $temp : (is_object($temp) ? (array)$temp : []);
-                        $is_self_available_in_policy_terms = isset($temp['self']) ? true : false;
+
+                        $is_self_available_in_policy_terms = isset($temp['self']) &&  $temp['self'] == 1 ? true : false;
+                        // Kint::dump($temp['self']);
+                        // dd($is_self_available_in_policy_terms);
                     }
                     // dd($employee_data_group_by_family);
                         foreach ($employee_data_group_by_family as $emp_id => $family) 
@@ -415,7 +418,7 @@ class EmployeeServiceController extends AdminController
                                 if(!count($self_details))
                                 {
                                         array_push($result['error_summary'],14); // Self not found
-                                        $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in System";
+                                        $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found in Database";
                                 }
                             }
                            
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index ca88b7f1..90d74c3d 100644
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -143,6 +143,28 @@ if(!function_exists('check_doj'))
     }
 }
 
+if(!function_exists('check_doc'))
+{
+
+    function check_doc($row,$policy_details)
+    {
+        if($row['current_action'] != null &&  $row[7] != null && $row[7] != '' && in_array(strtoupper($row['current_action']), ['A','DA']))// check rule only of action column data available
+        {
+            // dd($policy_details);
+            $date = new DateTime($row[7]);
+            $startDate = new DateTime($policy_details[0]->policy_start_date);
+            $endDate = new DateTime($policy_details[0]->policy_end_date);
+
+            if ($date >= $startDate && $date <= $endDate) {
+               return array('status' => true);
+            } else {
+               return array('status' => false,'error' => 'the given date of coverage is not between policy start/end date');
+            }
+        }
+        else {  return array('status' => true); } // in else condition no need to check rule, just return true
+    }
+}
+
 
 if(!function_exists('check_employee_band'))
 {
@@ -206,7 +228,7 @@ if(!function_exists('check_si'))
                     }
 
                     // check age slab 
-                    if(in_array(strtoupper($row['current_action']), ['I','A','DA']))
+                    if(in_array(strtoupper($row['current_action']), ['I','A','DA']) && strtolower($row['5']) == 'self')
                     {
                         if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
                         {
@@ -236,6 +258,7 @@ if(!function_exists('check_si'))
                     else
                     {
                         $is_age_slab_found = true;// send true if age conditin is not applicable
+                       $is_si_found = true;
                     }//end of check age slab 
                 }// end of for loop
 
@@ -252,6 +275,12 @@ if(!function_exists('check_si'))
             $return_array['error'] = !empty($return_array['error']) ? ($return_array['error'].', '.'Sum insured not configured for this age slab') : 'Sum insured not configured for this age slab';
         }
 
+        if(empty($received_si))
+        {
+            $return_array['status'] = false;
+            $return_array['error'] = "Sum insured value mandantory";
+        }
+
         return $return_array;
     }
 }
@@ -417,6 +446,7 @@ if (!function_exists('name_and_empid_check_in_db'))
         $result = ['del' => [],'i' => []];
         $client_id = $actionArr['client_id'];
         $policy_id = $actionArr['policy_id'];
+        $client_branch_id = $actionArr['client_branch_id'];
         $current_action = $actionArr['action'];
 
         foreach ($family_data as $rkey => $row) 
@@ -428,6 +458,7 @@ if (!function_exists('name_and_empid_check_in_db'))
                         ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
                         ->where("cp.id",$policy_id)
                         ->where("employees.client_id",$client_id)
+                        ->where("employees.client_branch_id",$client_branch_id)
                         ->where("employees.is_active",1)
                         ->where("employees.emp_status",'active')
                         ->where("ep.is_active",1)
@@ -572,10 +603,8 @@ if (!function_exists('check_dependent_conflict'))
                     $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
                 }
             }
-
-            // var_dump($allowed_adults == 0);
-            // dd($allowed_adults == 0 && (($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count)));
-            if($allowed_adults == 0 && (($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count) ))
+            //check for any cross parents but not more than two
+            if($allowed_adults == 0 && $allowed_parents_count == 1 && $allowed_parent_in_laws_count == 1 && (2 < ($received_parents_count + $received_parent_in_laws_count)))
             {
                  // dd($allowed_adults);
                  $result['status'] = false;
@@ -956,7 +985,7 @@ if (!function_exists('premium_calculation_manager'))
                 $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
                 foreach ($temp_slab_rates as $skey => $slab_value) 
                 {
-                    if($slab_value['si'] == $employee_received_si)
+                    if($slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
                     {
                         $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
                         $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); 
@@ -979,7 +1008,7 @@ if (!function_exists('premium_calculation_manager'))
                 foreach ($temp_slab_rates as $skey => $slab_value) 
                 {
                     $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
-                    if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age))
+                    if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
                     {
                         // dd($slab_value);
                         $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@@ -1000,7 +1029,7 @@ if (!function_exists('premium_calculation_manager'))
                 foreach ($temp_slab_rates as $skey => $slab_value) 
                 {
                     $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
-                    if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age))
+                    if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['additional_rack_rate_acting_self']) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
                     {
                        $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
                         $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); 
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 5d8a2070..15bf295d 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -76,31 +76,68 @@ class EmployeePolicyModel extends Model
     }
 
 // -----------------------------------------------------------------------------------------------------
-   public function getEmployeePolicy($client_id,$policy_id,$status, $branch_id)
+   public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="")
    {
-        $result =  $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile'])
-                        ->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('insurers im', 'cp.insurer_id = im.id') //im - insurar master
-                        ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch
-                        ->join('tpa tpam', 'cp.tpa_id = tpam.id','left') //tpam - tpa master
-                        ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id','left') //tpab - tpa brach
-                        ->join('clients cm', 'cp.client_id = cm.id') //cm - client master
-                        ->where('emp.client_id',$client_id)
-                        ->where('emp.client_branch_id',$branch_id)
-                        ->where('employee_polices.is_active',1)
-                        ->where('emp.is_active',1)
-                        ->where('employee_polices.client_policy_id',$policy_id)
-                        ->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC');
-                        
-                        
-        if($status != 0 && !empty($status)){
+       
+        $result = $this->select([
+            'employee_polices.*',
+            'pm.name as policy_name',
+            'im.short_name as insurer_short_name',
+            'ib.branch_name as insurer_branch_name',
+            'ib.branch_code as insurer_branch_code',
+            'tpam.name as tpa_name',
+            'tpam.short_name as tpa_short_name',
+            'tpab.branch_code as tpa_branch_code',
+            'cm.client_name',
+            'cm.short_name as client_short_name',
+            'emp.relationship',
+            'emp.relationship_code',
+            'emp.change_event',
+            'emp.emp_code',
+            'emp.name',
+            'emp.email_corporate',
+            'emp.dob',
+            'emp.gender',
+            'emp.emp_status',
+            'emp.is_active as emp_is_active',
+            'emp.mobile as mobile'
+        ])
+        ->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('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
+        ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch
+        ->join('clients cm', 'cp.client_id = cm.id') //cm - client master
+        ->orderBy('emp.emp_code', 'ASC')
+        ->orderBy('employee_polices.employee_id', 'ASC');
+        
+        // Conditionally add where clauses
+        if ($client_id !=0 && !empty($client_id)) {
+            $result->where('emp.client_id', $client_id);
+        }
+        if ($branch_id !=0 && !empty($branch_id)) {
+            $result->where('emp.client_branch_id', $branch_id);
+        }
+        if ($policy_id !=0 && !empty($policy_id)) {
+            $result->where('employee_polices.client_policy_id', $policy_id);
+        }
+        if ($status !=0 && !empty($status)) {
             $result->where('employee_polices.status', $status);
         }
+        if (!empty($emp_code)) {
+            $result->where('emp.emp_code', $emp_code);
+        }
+        if (!empty($emp_name)) {
+            $result->like('emp.name', $emp_name);
+        }
         
-        $result = $result->findAll();  
-        return ($result);
+        // Always check these conditions
+        $result->where('employee_polices.is_active', 1)
+               ->where('emp.is_active', 1);
+        
+        return $result->findAll();
    }
 
 
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php
index 93ea7137..213f47c2 100644
--- a/app/Views/client_branch.php
+++ b/app/Views/client_branch.php
@@ -89,7 +89,7 @@
                         
- +
@@ -423,7 +423,7 @@ $(document).ready(function () {
- +
@@ -563,6 +563,33 @@ $(document).ready(function () { + function checkMobileNumber(input){ + + console.log('function called') + console.log(input); + console.log('Input Value', input.value); + + var mobileNumber = input.value; + var url = '' + mobileNumber; + + $.get(url, function(response){ + + console.log(response) + console.log(response.data) + + if(response.data > 0){ + toastr.warning('The Mobile Number Already Exist.', 'Warning'); + input.value = ""; + return; + } + + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); + + } + \ No newline at end of file diff --git a/app/Views/client_info.php b/app/Views/client_info.php index f029a2b0..94bc56ee 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -16,7 +16,8 @@
- +
-
+
@@ -204,7 +205,7 @@
-
+
@@ -253,7 +254,7 @@ - @@ -270,50 +271,71 @@ $(document).ready(function() { $(document).on('click', '.policy_terms', function() { var terms = $(this).data('id'); console.log(terms); + console.log(terms.length); + console.log(JSON.stringify(terms)); + + // terms = JSON.parse(terms); $('#modal_body').empty(); function createListItems(obj) { + + if (obj.length == 0) { + const message = document.createElement('div'); + message.textContent = 'Policy Terms Not Available'; + message.style.display = 'flex'; + message.style.justifyContent = 'center'; + message.style.alignItems = 'center'; + message.style.height = '100%'; // Adjust as necessary to fit the context + message.style.textAlign = 'center'; + return message; + } + const fragment = document.createDocumentFragment(); for (const key in obj) { - if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key != - 'family_floater' && key != 'gpa_special_condition_input' && key != - 'gpa_special_condition_label' && key != 'special_condition_label' && key != - 'special_condition_input' && key != 'age_ratio') { - + if ( + obj.hasOwnProperty(key) && + obj[key] !== null && + obj[key] !== '' && + key !== 'family_floater' && + key !== 'gpa_special_condition_input' && + key !== 'gpa_special_condition_label' && + key !== 'special_condition_label' && + key !== 'special_condition_input' && + key !== 'age_ratio' && + key !== 'multiple_sum_insured' && + key !== 'other_special_condition_label' && + key !== 'other_special_condition_input' + ) { const listItem = document.createElement('li'); + let formattedKey = key.replace(/_/g, ' '); - var formattedKey = ''; - formattedKey = key.replace(/_/g, ' '); - obj[key] = obj[key].replace(/<\/?[^>]+>/gi, ''); + console.log('type', typeof obj[key]) + // Strip HTML tags from values + if (typeof obj[key] === 'string') { + console.log('before', obj[key]) + obj[key] = obj[key].replace(/<\/?[^>]+>/gi, ''); + console.log('after', obj[key]) + } + + // Convert 0 and 1 to 'No' and 'Yes' if (obj[key] == 0) { obj[key] = 'No'; } - if (obj[key] == 1) { obj[key] = 'Yes'; } - console.log(formattedKey) - - if (key == 'burnExpenses' && obj[key] == 'Yes') { - - listItem.innerHTML = - `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}: ${obj['burnExpensesData']}`; - - } else if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { - + // Handle nested objects + if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { listItem.innerHTML = `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}:`; const nestedList = document.createElement('ul'); - nestedList.appendChild(createListItems(obj[key])); - listItem.appendChild(nestedList); - } else { listItem.innerHTML = `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}: ${Array.isArray(obj[key]) ? JSON.stringify(obj[key]) : obj[key]}`; @@ -325,7 +347,8 @@ $(document).on('click', '.policy_terms', function() { return fragment; } - $('#modal_body').append(createListItems(terms)); -}); + $('#modal_body').append(createListItems(terms)); + +}); \ No newline at end of file diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 00cb1960..e5626a3a 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -7,8 +7,8 @@
-
- +
+ @@ -157,6 +157,7 @@ + \ No newline at end of file diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index a4458cb1..f43042ed 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -136,6 +136,7 @@ + + + + \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 2b710321..28ff4417 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -110,9 +110,12 @@
-
- +
+
+
+ +
@@ -120,6 +123,8 @@
+
+
@@ -136,14 +141,14 @@
- - + + - - + + @@ -155,8 +160,8 @@ - - + +
Insurer Policy
Self:
Min Age:
Max Age:
Min Age:
Max Age:
Spouse:
Min Age:
Max Age:
Min Age:
Max Age:
Children:
Min Age:
Max Age:
Min Age:
Max Age:
@@ -184,21 +189,19 @@ - - - + + + -
Elders Count:
Min Age:
Max Age:
Elders Count:
Min Age:
Max Age:
-

- +
+
+ +
+
+ +
+
+
@@ -315,6 +327,15 @@
+
+
+ +
+
+ +
+
+
@@ -323,6 +344,29 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
@@ -445,7 +507,7 @@