diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2b5354d5..600d054e 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -921,6 +921,39 @@ class ClientController extends AdminController } $data = $this->request->getPost(); $insert = true; + }else if($policy_grid_id == '12'){ + + $premium=$this->request->getPost('12_premium[]'); + $sum_insure =$this->request->getPost('12_si[]'); + $relationship =$this->request->getPost('12_relationship[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['relationship'] = $relationship[$i]; + + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '13'){ + + $premium=$this->request->getPost('13_premium[]'); + $sum_insure =$this->request->getPost('13_si[]'); + $age_from =$this->request->getPost('13_age_from[]'); + $age_to =$this->request->getPost('13_age_to[]'); + $relationship =$this->request->getPost('13_relationship[]'); + + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $data['relationship'] = $relationship[$i]; + + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; } if($insert){ @@ -1003,6 +1036,12 @@ class ClientController extends AdminController $family_floater=json_decode($record['policy_terms'])->family_floater; } + $policy_terms_data = json_decode($record['policy_terms']); + $self = ""; + if ($policy_terms_data !== null && isset($policy_terms_data->family_floaters)) { + $self = $policy_terms_data->family_floaters; + } + $emp_count = $this->employeeModel ->join('client_policy cp',"employees.client_id = cp.client_id") ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id") ->where("employees.client_id",$record['client_id']) @@ -1054,26 +1093,25 @@ class ClientController extends AdminController if($search_term === 'GMC'){ $resultss = []; - if ($family_floater == 1) { + try { foreach ($results as $index => $record) { - if ($index == '8' || $index == '7') { - // Clearing the $results array - $resultss[$index] = $record; + if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0) { + if ($index == '0' || $index == '1' || $index == '2') { + $resultss[$index] = $record; + } + } else { + if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6' || $index == '8' || $index == '7' || $index == '9' || $index == '10') { + $resultss[$index] = $record; + } } } - }else if($family_floater == 0){ - foreach ($results as $index => $record) { - if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') { - // Clearing the $results array - $resultss[$index] = $record; - } - } - }else{ - foreach ($results as $index => $record) { - $resultss[$index] = $record; - } + } catch (\Exception $e) { + $resultss = $results; // Reset $resultss to an empty array if an exception occurs } + + + $premiumDataa =''; if ($family_floater == 0) { // print_r($premiumData);die; @@ -1086,7 +1124,7 @@ class ClientController extends AdminController else if($family_floater == 1){ if(count($premiumData) == 0){ $premiumDataa = $premiumData; - }else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11') { + }else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11' ) { $premiumDataa = $premiumData; } }else{ @@ -1103,15 +1141,15 @@ class ClientController extends AdminController // echo "hello"; // return json_encode($premiumData); - return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name,], 200); + 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], 200); }else if($search_term === 'GPA'){ - return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200); + 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], 200); }else{ - return $this->respond(['status' => false,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200); + return $this->respond(['status' => false,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); } } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 9e0e0517..36e3690c 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -24,6 +24,10 @@ use App\Controllers\Jobs; use PhpOffice\PhpSpreadsheet\Spreadsheet; // use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; +use PhpOffice\PhpSpreadsheet\IOFactory; +use PhpOffice\PhpSpreadsheet\Reader\Exception as SpreadsheetReaderException; + +use function PHPUnit\Framework\returnSelf; class EmpDataServiceController extends BaseController { @@ -479,6 +483,12 @@ class EmpDataServiceController extends BaseController $file = $import_data['file']; $data = $this->readExcelToArray($file); + + if (!$data) { + + return 0; + } + unset($data[0]); array_pop($data); $count = count($data); @@ -490,8 +500,17 @@ class EmpDataServiceController extends BaseController try { - if ($value[15] === null || $value[16] === null) { - $missing_id[] = $key + 1; + + if ($import_data['insurer_or_tpa'] == 'tpa') { + + if ($value[15] === null) { + $missing_id[] = $key + 1; + } + } else if ($import_data['insurer_or_tpa'] == 'insurer') { + + if ($value[16] === null) { + $missing_id[] = $key + 1; + } } $emp_code = $value[2]; @@ -501,26 +520,30 @@ class EmpDataServiceController extends BaseController $db = \Config\Database::connect(); // Execute the query - $query = $db->table('employee_polices') - ->select('employee_polices.id') - ->join('employees', 'employees.id = employee_polices.employee_id') - ->where('employee_polices.client_policy_id', $client_policy_id) - ->where('employees.client_id', $client_id) - ->where('employees.name', $name) - ->where('employees.emp_code', $emp_code) - ->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")') - ->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")') - ->where('employee_polices.is_active', 1) - ->limit(1) - ->get(); + $query = $db->table('employee_polices'); + $query->select('employee_polices.id'); + $query->join('employees', 'employees.id = employee_polices.employee_id'); + $query->where('employee_polices.client_policy_id', $client_policy_id); + $query->where('employees.client_id', $client_id); + $query->where('employees.name', $name); + $query->where('employees.emp_code', $emp_code); + if ($import_data['insurer_or_tpa'] == 'tpa') { + + $query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")'); + } else if ($import_data['insurer_or_tpa'] == 'insurer') { + + $query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")'); + } + $query->where('employee_polices.is_active', 1); + $query->limit(1); // Get the result - $result = $query->getRowArray(); + $result = $query->get()->getRowArray(); if (isset($result['id']) && $result['id'] !== null) { $empty_emp_tpa_uh_ids[] = $result['id']; } } catch (\Exception $e) { - // Handle the exception here + return 0; } } @@ -529,17 +552,43 @@ class EmpDataServiceController extends BaseController $missing_id_count = count($missing_id); $empty_id_count = count($empty_emp_tpa_uh_ids); - // dd($count, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids); - if ($missing_id_count != $count && $missing_id_count != 0) { + if ($import_data['insurer_or_tpa'] == 'tpa') { - return 2; + if ($empty_id_count == 0) { + + return 3; + } + + if ($missing_id_count != 0) { + + return 2; + } + } else if ($import_data['insurer_or_tpa'] == 'insurer') { + + if ($empty_id_count == 0) { + + return 5; + } + + if ($missing_id_count != 0) { + + return 4; + } } - if ($empty_emp_tpa_uh_ids != $count && $empty_id_count == 0) { + // if ($missing_id_count != $count) { + + // return 2; + // } + + + // if ($empty_emp_tpa_uh_ids != $count) { + + // return 3; + // } + - return 3; - } // dd($empty_emp_tpa_uh_ids); @@ -559,19 +608,26 @@ class EmpDataServiceController extends BaseController foreach ($data as $key => $value) { - if (!empty($value) && (isset($value[15]) || isset($value[16]))) { + if (!empty($value)) { - $tpa_id = $value[15] !== null ? $value[15] : ''; - $uhid = $value[16] !== null ? $value[16] : ''; - foreach ($empty_emp_tpa_uh_ids as $id) { - // Update employee policies based on the ID - $this->employeePolicyModel->where('id', $id)->set(['tpa_id' => $tpa_id, 'uhid' => $uhid])->update(); + if ($import_data['insurer_or_tpa'] == 'tpa') { + + $tpa_id = $value[15] !== null ? $value[15] : ''; + $uhid = $value[16] !== null ? $value[16] : ''; + + $data = ['tpa_id' => $tpa_id, 'uhid' => $uhid]; + } else if ($import_data['insurer_or_tpa'] == 'insurer') { + + $tpa_id = $value[15] !== null ? $value[15] : ''; + $uhid = $value[16] !== null ? $value[16] : ''; + $data = ['tpa_id' => $tpa_id, 'uhid' => $uhid]; } - // $query = $this->employeePolicyModel->getLastQuery(); - // echo $query . "
"; + foreach ($empty_emp_tpa_uh_ids as $id) { + $this->employeePolicyModel->where('id', $id)->set($data)->update(); + } } else { return 0; @@ -580,17 +636,23 @@ class EmpDataServiceController extends BaseController - $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id); - $depositeData = [ - 'employeeIds' => $empty_emp_tpa_uh_ids, - 'client_id' => $client_id, - 'client_policy_id' => $client_policy_id, - 'count' => $count, - 'event' => $import_data['event_type'], - 'policy_name' => $policy_name['policy_name'], - ]; + if($import_data['insurer_or_tpa'] == 'tpa'){ + + $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id); + $depositeData = [ + 'employeeIds' => $empty_emp_tpa_uh_ids, + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'count' => $count, + 'event' => $import_data['event_type'], + 'policy_name' => $policy_name['policy_name'], + ]; + + $this->cashDepositCalculationForInception($depositeData); + + } + - $this->cashDepositCalculationForInception($depositeData); return 1; } @@ -1470,34 +1532,42 @@ class EmpDataServiceController extends BaseController + public function readExcelToArray($file) { - if ($file->isValid() && !$file->hasMoved()) { $file = $file; + + try { - $reader = new Xlsx(); - $spreadsheet = $reader->load($file->getPathname()); - - // Get the active sheet - $sheet = $spreadsheet->getActiveSheet(); - - // Iterate through rows to read data - $data = []; - foreach ($sheet->getRowIterator() as $row) { - $rowData = []; - foreach ($row->getCellIterator() as $cell) { - $rowData[] = $cell->getValue(); + $reader = IOFactory::createReaderForFile($file->getPathname()); + $spreadsheet = $reader->load($file->getPathname()); + + // Get the active sheet + $sheet = $spreadsheet->getActiveSheet(); + + // Iterate through rows to read data + $data = []; + foreach ($sheet->getRowIterator() as $row) { + $rowData = []; + foreach ($row->getCellIterator() as $cell) { + $rowData[] = $cell->getValue(); + } + $data[] = $rowData; } - $data[] = $rowData; + + return $data; + + } catch (SpreadsheetReaderException $e) { + + error_log('PhpSpreadsheet reader exception: ' . $e->getMessage()); + return false; } - - return $data; } else { - return false; } } + public function insertBatchFileAndBatchListForImportExcel($data, $ids) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 6a3ba065..1871fab0 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -401,16 +401,28 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 2){ - session()->setFlashdata('error', 'The TPA ID or UHID columns are empty.'); + session()->setFlashdata('error', 'The TPA ID column is either partially or entirely empty.'); return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file.'); return redirect()->to(base_url('employee/upload')); + }else if($return == 3){ - session()->setFlashdata('error', 'File already uploaded'); + session()->setFlashdata('error', 'The list of employees provided has already been updated with the TPA ID, or this is not the correct file'); return redirect()->to(base_url('employee/upload')); - } }else if($event_type == 'correction'){ + + }else if($return == 4){ + session()->setFlashdata('error', 'The UHID column is either partially or entirely empty.'); + return redirect()->to(base_url('employee/upload')); + + }else if($return == 5){ + session()->setFlashdata('error', 'The list of employees provided has already been updated with the UHID, or this is not the correct file'); + return redirect()->to(base_url('employee/upload')); + + } + + }else if($event_type == 'correction'){ $return = $empDataServiceController->importExcelDataForCorrection($batch_data); if($return == 1){ @@ -422,7 +434,7 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file'); return redirect()->to(base_url('employee/upload')); }else if($return == 3){ session()->setFlashdata('error', 'File already uploaded'); @@ -441,7 +453,7 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file'); return redirect()->to(base_url('employee/upload')); }else if($return == 3){ session()->setFlashdata('error', 'File already uploaded'); @@ -460,7 +472,7 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file'); return redirect()->to(base_url('employee/upload')); }else if($return == 3){ session()->setFlashdata('error', 'File already uploaded'); @@ -704,9 +716,9 @@ class EmployeeController extends AdminController $file_data = $this->fileModel->find($file_id); $error = json_decode($file_data['reason']); - // echo '
';
-    //    print_r($error); die;
-    //    dd($error);
+        //    echo '
';
+        //    print_r($error); die;
+        //    dd($error);
     
         // Check if the file exists
         if (!$file_data) {
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 71ebec43..e1814d9f 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -183,7 +183,7 @@ class EmployeeRestController extends AdminController
                         $item->family_floater_key = $this->RelationshipMap($item->relationship);
                         $item->gender = $this->GenderMap($item->relationship , $item->emp_code);
                         $item->dob = $this->convertDateFormatYMD($item->dob);
-                        $item->emp_status = 'Draft';
+                        $item->emp_status = 'draft';
                         $employee = $this->employeeModel->where('is_active', 1 )->update($id, (array)$item);
                         if ($employee) {
                             $Count++;
@@ -193,7 +193,7 @@ class EmployeeRestController extends AdminController
                         $item->family_floater_key = $this->RelationshipMap($item->relationship);
                         $item->gender = $this->GenderMap($item->relationship , $item->emp_code);
                         $item->dob = $this->convertDateFormatYMD($item->dob);
-                        $item->emp_status = 'Draft';
+                        $item->emp_status = 'draft';
                         $employee = $this->employeeModel->insert($item);
                    
                         if ($employee) {
@@ -209,7 +209,12 @@ class EmployeeRestController extends AdminController
                 }
     
                 if ($Count > 0) {
-                    $this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
+
+                    if(!isset($data[0]->is_addon_value))
+                    {
+                        $this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
+                    }
+                    
                     $result = [];
                     return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
                 } else {
@@ -230,12 +235,28 @@ class EmployeeRestController extends AdminController
             $policy_terms = json_decode($client_policy['policy_terms']);
             $basic_cover_si = $policy_terms->sum_insured;
 
-            $data['employee_id']= $employee_id;
-            $data['client_policy_id']= $client_policy_id;
-            $data['basic_cover_si']= $basic_cover_si;
-            $data['status']= 'draft';
-    
-            $this->employeePolicyModel->insert($data);
+            $checkDataExist = $this->employeePolicyModel->where('employee_id',$employee_id)->where('client_policy_id',$client_policy_id)->first();
+
+            if($checkDataExist){
+
+                $this->employeePolicyModel
+                    ->where('client_policy_id',$client_policy_id )
+                    ->where('employee_id' , $employee_id )
+                    ->where('is_active', 1 )
+                    ->set(array('basic_cover_si'=> $basic_cover_si ))
+                    ->update();     
+
+            }else{
+
+                $data['employee_id']= $employee_id;
+                $data['client_policy_id']= $client_policy_id;
+                $data['basic_cover_si']= $basic_cover_si;
+                $data['status']= 'draft';
+
+                $this->employeePolicyModel->insert($data);
+
+            }
+            
             return true;             
     }
 
@@ -245,7 +266,7 @@ class EmployeeRestController extends AdminController
 
         if(count($response[$emp_code]))
         {
-            print_r($response[$emp_code]);
+            
             foreach ($response[$emp_code] as $key => $value) 
             {
                
@@ -259,7 +280,7 @@ class EmployeeRestController extends AdminController
                     ->where('client_policy_id',$value['policy_details']['client_policy_id'] )
                     ->where('employee_id' , $value['temp']['emp_id'] )
                     ->where('is_active', 1 )
-                    ->set(array('premium'=> $value['policy_details']['premium'] ))
+                    ->set(array('premium'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
                     ->update();        
                    
                 }
@@ -374,9 +395,9 @@ class EmployeeRestController extends AdminController
             foreach ($ClientPolicyData as $key => $value) {
                 $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']);
                 if($value['is_addon'] == "2"){
-                    $value['type'] = 'SI-TopUp';
+                    $value['type'] = 'SI TopUp';
                 }else if($value['is_addon'] == "3"){
-                    $value['type'] = 'Dependent-AddOn';
+                    $value['type'] = 'Dependent AddOn';
                 }else{
                     $value['type'] = $getSlabAndGridData['grid_master']['policy_type'];
                 }
@@ -543,27 +564,27 @@ class EmployeeRestController extends AdminController
                                                    ->where('client_policy_id', $value->client_policy_id)
                                                    ->where('is_active', 1 )
                                                    ->findAll();
-            $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($value->client_policy_id,$value->client_id);
-            $SlabRatesArray = $getSlabAndGridData['slab_rates'];
-            $premium = $this->findPremiumAmount($SlabRatesArray, $value->basic_cover_si);
+           
 
             // dd($checkIfExist);
             if ($checkIfExist) {
 
-                    $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id,  $value->employee_id, $value->basic_cover_si,$premium);
+                    $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id,  $value->employee_id, $value->basic_cover_si);
 
                 }else{
 
                     $data['employee_id']= $value->employee_id;
                     $data['client_policy_id']= $value->client_policy_id;
                     $data['basic_cover_si']= $value->basic_cover_si;
-                    $data['premium']= $premium;
-                    $data['status'] = 'Draft';
+                    $data['status'] = 'draft';
             
                     $this->employeePolicyModel->insert($data);
                 }
             }
-                return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);             
+
+            $this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code);
+
+            return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);             
            
         } catch (\Exception $e) {
             return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
@@ -658,8 +679,8 @@ class EmployeeRestController extends AdminController
                 $file_data =$this->fileModel->insert($extractData);
 
                 $extra = [];
-                if (count($data[0]) == 10) {
-                    $value = ['S.No','Emp Code','Name','DOJ','Gender','Relation','DOB','Mail','Mobile','SI'];
+                if (count($data[0]) == 11) {
+                    $value = ['Sno','Emp_Code','Name','DOJ','Gender','Relation','DOB','Mail','Mobile','SI','Grade'];
                     $check_miss_match = [];
                     for ($i=0; $i respond(['status' => 'failed', 'code' => 404, 'message' => "Uploaded file row count is Not Match!" ], 200);
                 }
 
@@ -754,13 +775,14 @@ class EmployeeRestController extends AdminController
                             'email_corporate' => $extra['7'][$index],
                             'mobile'=> $extra['8'][$index],
                             'client_id' => $client_id,
-                            'emp_status'=>'draft'
+                            'emp_status'=>'draft',
+                            'band'=> $extra['10'][$index],
                             
                         ];
                         $basic_cover_si_value = null;
                         
                         //Grid id is 10 and 11 sum insure value add only for self other grid type self sum insure is for the dependence
-                            if ($policy_permium_2['policy_grid_id'] == 10 || $policy_permium_2['policy_grid_id'] == 11) {
+                            if (isset($policy_permium_2['policy_grid_id']) == 10 || isset($policy_permium_2['policy_grid_id']) == 11) {
                                 if (strtolower($extra['5'][$index]) == 'self') {
                                     $basic_cover_si_value = $extra['9'][$index];
                                 }else{
@@ -890,7 +912,7 @@ class EmployeeRestController extends AdminController
                     // $return_log = json_decode($return_log);
                     // $this->myLogger->logme('info', "Email Status : {mail_status}, Sender Email:{email}", ['mail_status' => $return_log->status, 'email'=> $return_log->data]);
                 }
-            return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 404);
+            return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 200);
             }else{
                 return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "Client id and Client Policy id is Not Match!" ], 404);
             }
@@ -1162,8 +1184,9 @@ public function getAddOnPolicy()
 
 
                     $data = [];
-                    $dependent_and_si_value = null;
-                    $dependent_and_si_premium_value = null;
+                    $dependent_and_si_value = 0;
+                    $dependent_and_si_premium_value = 0;
+                    $dependent_and_si_gst_value = 0;
                     foreach ($floters as $familyFloatesValue) { 
                         $dependent =   preg_replace('/\d/', '', $familyFloatesValue);
                         if(count($addOnEmployeeData)){
@@ -1171,7 +1194,8 @@ public function getAddOnPolicy()
                                 if ($value['family_floater_key'] === $dependent) {
                                     $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
                                     if(isset($employee_policy->basic_cover_si)){  $dependent_and_si_value = $employee_policy->basic_cover_si; }
-                                    if(isset($employee_policy->premium)){   $dependent_and_si_premium_value = $employee_policy->premium;}
+                                    if(isset($employee_policy->premium)){   $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->premium;}
+                                    if(isset($employee_policy->gst)){   $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
                                     
                                     $temp['is_value_exist'] = true;
                                     $temp['data']['family_floater_key'] = $familyFloatesValue;
@@ -1248,6 +1272,7 @@ public function getAddOnPolicy()
                     $responce['family_floaters_of_dependent_and_si_array'] = $data;
                     $responce['family_floaters_of_dependent_and_si_value'] = $dependent_and_si_value;
                     $responce['family_floaters_of_dependent_and_si_premium_value'] = $dependent_and_si_premium_value;
+                    $responce['family_floaters_of_dependent_and_gst_value'] = $dependent_and_si_gst_value;
 
 
                     
@@ -1262,13 +1287,15 @@ public function getAddOnPolicy()
 
 
             $only_si_array = [];
-            $only_si_value = null;
-            $only_si_premium_value = null;
+            $only_si_value = 0;
+            $only_si_premium_value = 0;
+            $only_si_gst_value = 0;
             foreach ($GMCEmployeeData as $key => $value) {
 
                     $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
                     if(isset($employee_policy->basic_cover_si)){  $only_si_value = $employee_policy->basic_cover_si; }
-                    if(isset($employee_policy->premium)){   $only_si_premium_value = $employee_policy->premium;}
+                    if(isset($employee_policy->premium)){   $only_si_premium_value = $only_si_premium_value + $employee_policy->premium;}
+                    if(isset($employee_policy->gst)){   $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
                     $temp3['is_value_exist'] = true;
                     $temp3['data']['employee_id'] = $value['id'];
                     $temp3['data']['relationship'] = $value['relationship'];
@@ -1284,6 +1311,7 @@ public function getAddOnPolicy()
             $responce['family_floaters_of_only_si_array'] = $only_si_array;
             $responce['family_floaters_of_only_si_value'] = $only_si_value;
             $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
+            $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
 
             if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){
             return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200);
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index b283bc5a..4b14a8bd 100644
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -130,6 +130,7 @@ class RestAuthenticationController extends AdminController
         try {
             $mobile_number = $this->request->getJSON()->mobile_number;
             $randomNumber = rand(100000, 999999);
+            $randomNumber = 123456;
             $HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
             
             if ($HrData) {
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 17f1c3f2..82706219 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -107,6 +107,15 @@ class EmployeePolicyModel extends Model
         $client_policy_id = $ref_data['client_policy_id'];
         $insurer_or_tpa = $ref_data['insurer_or_tpa'];
 
+        if($insurer_or_tpa == 'tpa'){
+
+            $id = 'tpa_id';
+
+        }else if($insurer_or_tpa == 'insurer'){
+
+            $id = 'uhid';
+        }
+
         $sql = "
                 SELECT 
                 employees.name AS emp_name,
@@ -148,8 +157,7 @@ class EmployeePolicyModel extends Model
             WHERE batch_data.bf IS NULL
                 AND batch_data.bl IS NULL
                 AND employee_polices.client_policy_id = '{$client_policy_id}'
-                AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = '')
-                AND (employee_polices.uhid IS NULL OR employee_polices.uhid = '')
+                AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '')
                 AND employee_polices.is_active = 1";
 
             // Get the result set
@@ -555,7 +563,7 @@ class EmployeePolicyModel extends Model
     // }
 
 
-    public function updateSiAndPremium( $client_policy_id, $employee_id,$basic_cover_si,$premium)
+    public function updateSiAndPremium( $client_policy_id, $employee_id,$basic_cover_si,$premium = 0)
     {
 
       
diff --git a/app/Models/PolicyPremium2Model.php b/app/Models/PolicyPremium2Model.php
index e390dcc7..85ee9972 100644
--- a/app/Models/PolicyPremium2Model.php
+++ b/app/Models/PolicyPremium2Model.php
@@ -24,6 +24,7 @@ class PolicyPremium2Model extends Model
         "updated_by",
         'is_active',  
         'premium_type',  
+        'relationship',  
         
     ];
 
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php
index 89946fec..4a5a8f6c 100644
--- a/app/Views/policy_grid.php
+++ b/app/Views/policy_grid.php
@@ -27,12 +27,13 @@
                                 
                             
 
-                            
+ @@ -66,7 +67,7 @@ $('#btnGridSubmit').hide(); $('.close').click(function() { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -92,7 +93,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa if (dataIdValue == '1') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -164,7 +165,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
`; } else if (dataIdValue == '2') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -186,7 +187,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '3') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -211,7 +212,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '4') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } grid_html = ` @@ -245,7 +246,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '5') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -278,7 +279,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '6') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -313,7 +314,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '7') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -346,7 +347,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '8') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -376,7 +377,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '9') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -406,7 +407,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '10') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -438,7 +439,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '11') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -469,8 +470,91 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa `; + } else if (dataIdValue == '12') { + + for (var i = 1; i <= 13; i++) { + $('#grid_' + i).remove(); + } + + grid_html = ` + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
`; + + } else if (dataIdValue == '13') { + + for (var i = 1; i <= 13; i++) { + $('#grid_' + i).remove(); + } + + grid_html = ` + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
`; + } else { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } grid_html = ''; @@ -597,6 +681,7 @@ $('body').on('click', '.btnPolicyModel', function() { $('.loader').fadeIn(); $('.loader-mask').fadeIn(); + $.ajax({ url: '', type: "GET", @@ -608,6 +693,12 @@ $('body').on('click', '.btnPolicyModel', function() { $('#GridForm')[0].reset(); + if(res.family_floater == 1){ + $('#premium_type').show(); + }else{ + $('#premium_type').hide(); + } + setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -634,7 +725,8 @@ $('body').on('click', '.btnPolicyModel', function() { } var policy_grid_id_value = ''; - if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0].policy_grid_id) { + if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0] + .policy_grid_id) { policy_grid_id_value = res.premiumData[0].policy_grid_id; } @@ -649,23 +741,26 @@ $('body').on('click', '.btnPolicyModel', function() { }); $('#grid').html(policeGridOptionHTML); - if(res.premiumData[0].hasOwnProperty('premium_type')){ + if (res.premiumData[0].hasOwnProperty('premium_type')) { if (res.premiumData[0].premium_type == '2') { $('#individual').prop('checked', true) $('#single').prop('checked', false) - } else if (res.premiumData[0].premium_type == '1') { + } else if (res.premiumData[0].premium_type == '1') { $('#single').prop('checked', true) $('#individual').prop('checked', false) + + } else { + $('#single').prop('checked', false) + $('#individual').prop('checked', false) } } - var si_or_bp_value = ''; if (res.premiumData && res.premiumData.length > 0) { @@ -1101,6 +1196,78 @@ function appendGridtHtml(ui_type = false, data = false, ) { `; + } else if (ui_type == '12') { + + html = ` +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
`; + } else if (ui_type == '13') { + + html = ` +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
`; } @@ -1113,8 +1280,6 @@ function appendGridtHtml(ui_type = false, data = false, ) { Count++ - - // Number to word $(document).keyup(function(event) { if (event.target) {