diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 041caaa3..ba34cea6 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "MasterController::createCDMasterData"); $routes->post("edit", "MasterController::editCDMasterData"); $routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1"); - // $routes->get("remove/(:any)", "MasterController::policyTypeRemove/$1"); + $routes->get("remove/(:any)", "MasterController::removeCDMaster/$1"); }); }); @@ -248,6 +248,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $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'); @@ -271,9 +272,9 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { - +$routes->get("getChatResponse", "ChatBotController::getChatResponse"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { - + $routes->get("getChatResponse", "ChatBotController::getChatResponse"); $routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile"); $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->get("relationshipList", "EmployeeRestController::relationshipList"); @@ -304,6 +305,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); }); + + + $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/ChatBotController.php b/app/Controllers/ChatBotController.php new file mode 100644 index 00000000..d048ada7 --- /dev/null +++ b/app/Controllers/ChatBotController.php @@ -0,0 +1,118 @@ +myLogger = \Config\Services::mylogger(); + $this->employeeModel = new EmployeeModel(); + $this->employeePolicyModel = new EmployeePolicyModel(); + $this->clientModel = new ClientModel(); + $this->clientRMModel = new ClientRMModel(); + $this->policesModel = new PolicesModel(); + $this->relationshipModel = new RelationshipModel(); + $this->fileModel= new FileModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + $this->policyPremium1Model = new PolicyPremium1Model(); + $this->policyPremium2Model = new PolicyPremium2Model(); + $this->policyTypeModel = new PolicyTypeModel(); + $this->notificationModel = new NotificationModel(); + $this->userModel = new UserModel(); + $this->feContentModel = new FEContentModel(); + $this->addImgModel = new AddImgModel(); + $this->ChatBotModel = new ChatBotModel(); + } + + + public function getChatResponse() + { + // try { + $request_for = $this->request->getGet('request_for'); + $option = $this->request->getGet('option'); + + $requestData = $this->ChatBotModel->where('request', $request_for) + ->where('is_active', 1 ) + ->first(); + + if ($requestData) { + + + + if($option != 0){ + + $decodedData = json_decode($requestData['options'],true); + + $requestFor = $decodedData[$request_for][$option]; + + $requestData = $this->ChatBotModel->where('request', $requestFor) + ->where('is_active', 1 ) + ->first(); + } + + + $result = ['request_for'=>$requestData['request'],'options'=>json_decode($requestData['options'],true)]; + return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); + + + + + } else { + + return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404); + } + // } catch (\Throwable $th) { + // return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); + // } + } + + + +} + diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 86556e52..01f35d7c 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -301,9 +301,9 @@ class ClientController extends AdminController $editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll(); $editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); $editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); - // dd('Hi'); + $editData['client_branch']['role'] = get_role_id(); $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id); - // dd($this->clientPolicyModel->getLastQuery()); + foreach ($clientPoliceData as $key => $value) { $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date)); @@ -311,12 +311,10 @@ class ClientController extends AdminController } $editData['client_policy'] = $clientPoliceData; - - $editData['notification'] =$this->notificationModel->select('template_name,enabled')->where('client_id',$id)->findAll(); $editData['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; - + // dd($editData); echo view('layout/header', $headerData); echo view('client_onboarding', $editData); echo view('layout/footer'); @@ -565,6 +563,7 @@ class ClientController extends AdminController if($insert){ $branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll(); + $branchData['role'] = get_role_id(); return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200); }else{ return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200); @@ -1907,7 +1906,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", @@ -2067,19 +2066,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 { @@ -2199,7 +2206,7 @@ class ClientController extends AdminController } - public function checkPolicyType($client_policy_id, $policy_type_id, $client_branch_id, $client_id){ + public function checkPolicyType($policy_type_id, $client_branch_id, $client_id){ $policyCount = $this->clientPolicyModel ->where('policy_type_id', $policy_type_id) @@ -2217,23 +2224,52 @@ class ClientController extends AdminController } - public function getPolicyTerms($client_policy_id){ - + public function getPolicyTerms($client_policy_id) + { $policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first(); - - if(isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null){ - - $JSON = json_decode($policy_terms['policy_terms']); - $si = $JSON->sum_insured ?? $JSON->sumInsured2; - $multi_si = $JSON->multiple_sum_insured; - $multi_si[] = $si; - }else{ - $$multi_si = []; + + if (!$policy_terms) { + return $this->respond(['status' => false, 'error' => 'Policy not found'], 404); } - - return $this->respond(['status' => true, 'data'=>$multi_si], 200); + + 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){ @@ -2246,4 +2282,24 @@ class ClientController extends AdminController } + 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 3cb36091..96537b76 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -140,15 +140,30 @@ class EmpDataServiceController extends BaseController // Fetch employee data for export from the database $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); - $insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - $cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first(); + $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - if($cash_balance == null){ + // dd($export_data, $policy_details['cd_ac_no']); + + if ($policy_details['cd_ac_no'] == null) { + // dd("The policy does not have a CD account number"); + $this->myLogger->logme('error', 'The policy does not have a CD account number.'); + return 5; + } + + $cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first(); + + if ($cash_balance == null) { + + $balance = $this->CDMasterModel + ->where('client_id', $export_data['client_id']) + ->where('insurer_id', $policy_details['insurer_id']) + ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->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']; } + // dd($cash_balance); // Calculate the total amount from the objects $totals = array_reduce($objects, function ($carry, $item) { @@ -158,9 +173,8 @@ class EmpDataServiceController extends BaseController $totals = round($totals, 2); if (!empty($cash_balance)) { - + if ((int) $cash_balance['balance'] < (int) $totals) { - $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); return 0; @@ -363,6 +377,26 @@ class EmpDataServiceController extends BaseController $ids = []; $objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data); + $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); + + if ($policy_details['cd_ac_no'] == null) { + $this->myLogger->logme('error', 'The policy does not have a CD account number.'); + return 1; + } + + $cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first(); + + if ($cash_balance == null) { + + $balance = $this->CDMasterModel + ->where('client_id', $export_data['client_id']) + ->where('insurer_id', $policy_details['insurer_id']) + ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->first(); + + $cash_balance['balance'] = $balance['opening_bal']; + } + $totals = 0; foreach ($objects as $obj) { @@ -374,6 +408,14 @@ class EmpDataServiceController extends BaseController // echo '
';
         // print_r($ids); die;
 
+        if (!empty($cash_balance)) {
+            if ((int) $cash_balance['balance']  < (int) $rounded_totals) {
+                $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
+                $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.  CASH BALANCE : {balance}  and  TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
+                return 0;
+            }
+        }
+
         $count = count($objects);
         $export_data['count'] = $count;
         $export_data['amount'] = $rounded_totals;
@@ -545,7 +587,7 @@ class EmpDataServiceController extends BaseController
     }
 
 
-
+    //not in use
     public function generateExcelForAdditionAndDependentAddition($export_data)
     {
         $ids = [];
@@ -628,7 +670,7 @@ class EmpDataServiceController extends BaseController
             }
         }
     }
-
+    //end not in use
 
     /**
      * The below functions are Imports data from an Excel file for :
@@ -2788,7 +2830,7 @@ class EmpDataServiceController extends BaseController
 
     //Endorsement Addition and Dependent Addition
 
-
+    //not in use
     public function AdditionAndDependentAddition($params)
     {
 
@@ -3179,6 +3221,7 @@ class EmpDataServiceController extends BaseController
 
     }
 
+    //end not in use
 
     /**
      * The below functions are Calculates and records cash deposits for employee policies at inception.
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 80571810..ae32b9a4 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);
     }
@@ -408,10 +411,15 @@ class EmployeeController extends AdminController
 
                 $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
 
-                if ($return == 0) {
+                if ($return === 0) {
 
                     session()->setFlashdata('error', "Insufficient deposit amount.");
                     return redirect()->to(base_url('employee/upload'));
+
+                }else if($return === 5){
+
+                    session()->setFlashdata('error', "The policy does not have a CD account number.");
+                    return redirect()->to(base_url('employee/upload'));
                 }
 
                 if (!$return) {
@@ -439,10 +447,14 @@ class EmployeeController extends AdminController
 
                 $return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
 
-                if ($return == 0) {
+                if ($return === 0) {
 
                     session()->setFlashdata('error', "Insufficient deposit amount.");
                     return redirect()->to(base_url('employee/upload'));
+                }else if($return === 5){
+
+                    session()->setFlashdata('error', "The policy does not have a CD account number.");
+                    return redirect()->to(base_url('employee/upload'));
                 }
 
                 if (!$return) {
@@ -1056,33 +1068,34 @@ class EmployeeController extends AdminController
     public function viewECard()
     {
 
-        $this->loadLayout('ecard_template/default_ecard');
+        // $this->loadLayout('ecard_template/default_ecard');
         
-        // Load the session library if it's not autoloaded
-        // $session = \Config\Services::session();
-        
-        // Access session data
-        $sessionData = session()->get();
-        
-        // Check if session data exists and if expiration time is set
-        if (!empty($sessionData) && isset($sessionData['isLoggedIn']) && isset($sessionData['session_expiration'])) {
-            // Get the session expiration timestamp
-            $expirationTimestamp = $sessionData['session_expiration'];
-        
-            // Get the current timestamp
-            $currentTimestamp = time();
-        
-            // Check if the current time is greater than the expiration time
-            if ($currentTimestamp > $expirationTimestamp) {
-                // Session has expired
-                echo "Session has expired";
-            } else {
-                // Session is active
-                echo "Session is active";
-            }
-        } else {
-            // Session data is not set or session is not started
-            echo "Session is not started or data is not set";
+        $empDataServiceController = new EmpDataServiceController();
+        $file_name = generate_filename("TCS", 'inception', 'export', 'insurer', 'policy', 'branch');
+
+        $batch_data = [
+            'client_id' => 12,
+            'client_policy_id' => 12,
+            'client_branch_id' => 1,
+            'insurer_or_tpa' => 'insurer',
+            'event_type' => 'inception',
+            'actions' => 'export',
+            'file_name' => $file_name,
+        ];
+
+        $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
+
+        if ($return == 0) {
+
+           dd('error', "Insufficient deposit amount.");
+
+        }else if($return == 1){
+
+            dd('error', "The policy does not have a CD account number.");
+        }
+
+        if (!$return) {
+            dd('error', "No data was found");
         }
         
     }
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 04f1e336..5d6ec3b9 100644
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1123,13 +1123,7 @@ class MasterController extends AdminController
     public function CDMasterList()
     {
 
-        $data['CD_Master_Data'] = $this->CDMasterModel
-            ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name as insurer_name, user_profiles.first_name as user_name')
-            ->join('clients', 'clients.id = cd_master.client_id')
-            ->join('insurers', 'insurers.id = cd_master.insurer_id')
-            ->join('user_profiles', 'user_profiles.id = cd_master.created_by')
-            ->where('cd_master.is_active', 1)
-            ->findAll();
+        $data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList();
         $data['insurers'] = $this->insurerModel->findAll();
         $data['clients'] = $this->clientModel->findAll();
         $this->loadLayout('cd_master_list', $data);
@@ -1217,4 +1211,18 @@ class MasterController extends AdminController
         }
     }
 
+
+    public function removeCDMaster($id){
+
+        $this->myLogger->logme('error','CDMaster Remove function called');
+        $data['updated_by'] = get_session_userid();
+        $data['is_active'] = 0;
+        $update             = $this->CDMasterModel->where('id', $id)->set($data)->update();
+        if($update){
+            return $this->respond(['status' => true,'code' => 200], 200);
+        }else{
+            return $this->respond(['status' => false,'code' => 404], 200);
+        }
+    }
+
 }
\ No newline at end of file
diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php
index 7d3c713d..f6d14a7c 100644
--- a/app/Helpers/DepositHelper.php
+++ b/app/Helpers/DepositHelper.php
@@ -33,7 +33,7 @@ class DepositHelper
     public static function saveDeposit(array $data, int $loggedInUserID): array
     {
         // Retrieve the last known balance
-        $lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id']);
+        $lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id'], $data['cd_ac_no']);
 
         // Calculate the new balance based on the transaction type
         $newBalance = self::calculateBalance(
@@ -87,24 +87,26 @@ class DepositHelper
      *
      * @return float The last known balance.
      */
-    public static function calculateLastBalance(int $clientId, int $insurerId): float
+    public static function calculateLastBalance(int $clientId, int $insurerId, $cd_ac_no): float
     {
         $model = new ClientDepositModel();
 
-        $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
-        $getLastBalanceParams = [$clientId, $insurerId];
+        // $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
+        // $getLastBalanceParams = [$clientId, $insurerId];
 
-        $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance;
+        $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
+        $getLastBalanceParams = [$cd_ac_no];
 
-        if(!$lastBalance){
+        $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? null;
+
+        if(empty($lastBalance) && $lastBalance == null){
 
             $cd_model = new ClientDepositModel();
 
-            $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
-            $getLastBalanceParams = [$clientId, $insurerId];
+            $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
+            $getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
     
             $lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
-    
         }
 
         return $lastBalance;
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index 2dbcb1ce..87945e48 100644
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -239,3 +239,12 @@ if (!function_exists('get_username')) {
 }
 
 
+if (!function_exists('get_role_id')) {
+    function get_role_id() {
+
+        $role_id = get_session_userdata()->role;
+        return $role_id;
+    }
+}
+
+
diff --git a/app/Models/CDMasterModel.php b/app/Models/CDMasterModel.php
index 491d1007..0e5c39a1 100644
--- a/app/Models/CDMasterModel.php
+++ b/app/Models/CDMasterModel.php
@@ -61,4 +61,26 @@ class CDMasterModel extends Model
         return $data;
     }
 
+    public function getCDMasterList(){
+
+        $query = $this->db->table('cd_master')
+            ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count')
+            ->join('clients', 'clients.id = cd_master.client_id')
+            ->join('insurers', 'insurers.id = cd_master.insurer_id')
+            ->join('user_profiles', 'user_profiles.id = cd_master.created_by')
+            ->join(
+                '(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
+                FROM cd_master
+                JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no
+                GROUP BY cd_master.cd_ac_no) AS cd_ac_counts',
+                'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no',
+                'left'
+            )
+            ->where('cd_master.is_active', 1)
+            ->get();
+
+        $result = $query->getResultArray();
+        return $result;
+    }
+
 }
diff --git a/app/Models/ChatBotModel.php b/app/Models/ChatBotModel.php
new file mode 100644
index 00000000..caae27a5
--- /dev/null
+++ b/app/Models/ChatBotModel.php
@@ -0,0 +1,22 @@
+
\ No newline at end of file
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index a339b142..a69cf852 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -77,12 +77,14 @@ class ClientPolicyModel extends Model
         ->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
         ->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
         ->select('policy_type.policy_type as policy_type_name')
+        ->select('client_branch.branch_name as branch_name')
         ->join('insurers', 'insurers.id = client_policy.insurer_id')
         ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
         ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
         ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')        
         ->join('policies', 'policies.id = client_policy.policy_id')
         ->join('policy_type', 'policy_type.id = policies.policy_type_id')
+        ->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
         ->where('client_policy.client_id', $client_id)
         ->where('client_policy.policy_status', 1)
         ->where('client_policy.is_active', 1)
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 2dcac592..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/cd_master_list.php b/app/Views/cd_master_list.php
index 7a001b39..21e599ce 100644
--- a/app/Views/cd_master_list.php
+++ b/app/Views/cd_master_list.php
@@ -58,12 +58,12 @@ table.dataTable thead th {
                                 
                             
                                 
                             
@@ -290,4 +290,50 @@ table.dataTable thead th {
 
     })
 
+
+function removeCDMaster(element) {
+
+    Swal.fire({
+        title: "Are you sure?",
+        text: "You need to remove this CD.",
+        icon: "info",
+        showCancelButton: true,
+        confirmButtonColor: "#3085d6",
+        confirmButtonText: "Yes",
+    }).then((result) => {
+
+        if (result.isConfirmed) {
+            var id = element.getAttribute('data-id');
+            var form_action = '' + id; 
+            $.ajax({
+                url: form_action,
+                type: "GET",
+                dataType: 'json',
+                processData: false,
+                contentType: false,
+                success: function(res) {
+                // console.log(res.status == true);
+                    if(res){
+                    if (res.status == true) {
+                        toastr.success('CD removed successfully.', 'success');
+                        location.reload();
+                    } else {
+                        toastr.warning('Failed to remove CD.', 'warning');
+                    }
+                    }
+                },
+                error: function (xhr, status, error) {
+                    console.error(xhr.responseText);
+                    console.error(status, error);
+                    $('.loader').fadeOut();
+                    $('.loader-mask').delay(350).fadeOut('slow');
+                    console.log('Something Wrong!', 'warning');
+                }
+            });
+        }
+
+    });
+
+}
+
 
\ No newline at end of file
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php
index 93ea7137..81b308e4 100644
--- a/app/Views/client_branch.php
+++ b/app/Views/client_branch.php
@@ -1,11 +1,12 @@
 
- +
- +
-
- +
+ @@ -23,52 +24,51 @@
- +
- +
-
- - - + + + +
- +
- - + +
- +
- - + +
- - + +
@@ -79,26 +79,37 @@
- +
- +
- +
- +
- - + +
@@ -119,168 +130,196 @@ \ 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 @@
@@ -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_list.php b/app/Views/client_list.php index 4548631a..2d84afdf 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -59,7 +59,9 @@ table.dataTable thead th { @@ -111,38 +113,47 @@ table.dataTable thead th { function removeClient(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this client.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Client removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove client.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } - }); - + + }); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index e5626a3a..611fadd3 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -7,14 +7,15 @@
-
+
+ - + @@ -39,6 +40,7 @@ +
@@ -258,13 +260,13 @@ tpaValue = item.tpa_short + '-' + item.tpa_branch_code; } - policyTable += `
+ - + + - + - - + + - - + + @@ -190,8 +190,8 @@ - - + +
Insurer PolicyClient Branch TPA DateEnrollment
Status
Enrollment Status Status Action
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name ? item.branch_name : ' - '} ${tpaValue}${(item.policy_start_date)} /
${(item.policy_end_date)}
${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -314,6 +316,8 @@ $('#policy_form_action').val(''); $('#policy_status_field').hide() $('#base_policy_id').hide(); + $('#policy_PrimaryKey').val(""); + $('#insurer_policy_id').val(""); $('#first').hide(); @@ -481,8 +485,9 @@
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${rearrangeDateFormat(item.policy_start_date)} /
${rearrangeDateFormat(item.policy_end_date)}
${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -632,6 +637,7 @@ }); + }); $(document).ready(function() { @@ -646,28 +652,35 @@ console.log('client_id', client_id) console.log('branch_id', branch_id) console.log('policy_type_id', dataId) + console.log('client_policy_id', $('#policy_PrimaryKey').val()) + + $('#policy_type_id').val(dataId); - var url = '' + id + '/' + dataId + '/' + branch_id + '/' + client_id + var url = '' + dataId + '/' + branch_id + '/' + client_id; - $.get(url, function(response){ + if (dataId && branch_id && client_id) { // Check if all parameters exist + if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) { + $.get(url, function(response) { + console.log(response); + console.log(response.count); - console.log(response) - //console.log(response.data) + if (response.count > 0) { + console.log('Policy already exist in the branch'); + toastr.error('Policy already exist in the branch', 'Error'); + $('#policy').val('').change(); + } + console.log('outer'); - if(response.count > 0){ - console.log('Policy already exist in the branch') - toastr.error('Policy already exist in the branch', 'Error'); - $('#policy').val('').change(); + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); } - console.log('outer') - - - }).fail(function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - }); + } else { + console.log('Missing parameter(s): dataId, branch_id, or client_id'); + } if (dataId == 1) { @@ -738,7 +751,7 @@ dataType: 'json', success: function(res) { - //console.log('client_policy_res', res) + console.log('client_policy_res', res) setTimeout(function() { $('.loader').fadeOut(); @@ -771,6 +784,7 @@ $('#policy_type_id').val(res.data.policy_type_id); $('#policy_PrimaryKey').val(res.data.id); + $('#insurer_policy_id').val(res.data.policy_id); $('#policy_no').val(res.data.policy_no); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); @@ -1302,8 +1316,6 @@ }); } - - if ($(this).val() == 3) { toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO'); } @@ -1437,54 +1449,58 @@ contentType: false, success: function(res) { - //console.log(res) + console.log(res) setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }, 500); + + if(res.status == true){ - $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) - .change(); - $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); - $('#policy_no').val(res.data.policy_no).change(); - $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)) - .change(); - $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change(); + $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) + .change(); + $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); + $('#policy_no').val(res.data.policy_no).change(); + $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)) + .change(); + $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change(); - var policeOptionHTML = ''; - $policy_type_value = $('#policy_type').val(); - $.each(res.policy, function(index, item) { + var policeOptionHTML = ''; + $policy_type_value = $('#policy_type').val(); + $.each(res.policy, function(index, item) { - // //console.log(item); + // //console.log(item); - policeOptionHTML += ''; + policeOptionHTML += ''; - }); + }); - $('#policy').html(policeOptionHTML); + $('#policy').html(policeOptionHTML); - if (dataId == 3 || policy_type == 1) { + if (dataId == 3 || policy_type == 1) { - // //console.log('step 1') + // //console.log('step 1') + + setTimeout(function() { + // //console.log('step 2') + var $option = $('#policy').find('option[data-id="3"]'); + if ($option.length > 0) { + // //console.log('step 3') + $option.prop('selected', true).change(); + } else { + // //console.log('step 4'); + toastr.warning( + 'The insurer does not have a GMC-Parents policy.', + 'Warning'); + } + }, 1500); + } - setTimeout(function() { - // //console.log('step 2') - var $option = $('#policy').find('option[data-id="3"]'); - if ($option.length > 0) { - // //console.log('step 3') - $option.prop('selected', true).change(); - } else { - // //console.log('step 4'); - toastr.warning( - 'The insurer does not have a GMC-Parents policy.', - 'Warning'); - } - }, 1500); } }, diff --git a/app/Views/client_rm.php b/app/Views/client_rm.php index a47280ee..73ad031c 100644 --- a/app/Views/client_rm.php +++ b/app/Views/client_rm.php @@ -16,7 +16,7 @@
- +
- +
+
+
+ +
+ +
+
+ +
+
@@ -318,18 +328,22 @@ function fetchEmpolyeeList(event) { var policy_id = $('#policies').val(); var status = $('#status2').val(); var branch_id = $('#branch_id').val(); + var emp_code = $('#emp_code').val(); + var emp_name = $('#emp_name').val(); // console.log(client_id + '-' + policy_id); - if (client_id == '0' || policy_id == '0') { - alert('Please select values in both dropdowns.'); - return; - } + // if (client_id == '0' || policy_id == '0') { + // alert('Please select values in both dropdowns.'); + // return; + // } var queryParams = { client_id: client_id, policy_id: policy_id, branch_id: branch_id, + emp_code : emp_code, + emp_name : emp_name, status : status, }; diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php index 4fa12d55..45f7423b 100644 --- a/app/Views/endorsement_list.php +++ b/app/Views/endorsement_list.php @@ -587,16 +587,25 @@ dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - "buttons": [{ - "extend": 'csv', - "text": 'CSV', - "title": 'Endorsement-List', - "className": 'my_class', - "exportOptions": { - "columns": ':not(:last-child)' - }, + buttons: [{ + extend: 'csv', + text: 'CSV', + title: 'Endorsement-List', + className: 'my_class', + exportOptions: { + columns: ':not(:last-child)', + format: { + body: function (data, row, column, node) { + // Convert data to string to avoid scientific notation in CSV + if (!isNaN(data) && parseFloat(data) > 1e20) { + return `'${data}`; + } + return data.toString();// Ensures all data is treated as strings + } + } + } }], - "initComplete": function(settings, json) { + initComplete: function(settings, json) { $('.my_class').css({ "position": "relative", "left": "79px" @@ -608,7 +617,12 @@ }, paging: true, // pagingType: 'full_numbers' + columnDefs: [ + { type: 'scientific', targets: 0 } // Apply custom sorting type to the first column + ], }); + + }); \ No newline at end of file diff --git a/app/Views/insurer_branch.php b/app/Views/insurer_branch.php index dd2e5a6f..0398cc44 100644 --- a/app/Views/insurer_branch.php +++ b/app/Views/insurer_branch.php @@ -473,38 +473,48 @@ function removeInsurerBranch(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this insurer branch.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Insurer branch removed successfully', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove insurer branch', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove insurer branch', 'warning'); + } + }); - } else { - toastr.warning('Remove Not Done!', 'warning'); - } - } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); } - }); - - } + }); + + } \ No newline at end of file diff --git a/app/Views/insurer_list.php b/app/Views/insurer_list.php index 0487ca37..4d048546 100644 --- a/app/Views/insurer_list.php +++ b/app/Views/insurer_list.php @@ -134,38 +134,47 @@ class csvExport { function removeInsurer(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this insurer.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Insurer removed successfully', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove insurer', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove insurer', 'warning'); + } + }); } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } + }); - } diff --git a/app/Views/kyc_docs.php b/app/Views/kyc_docs.php index 8d347e78..56a0bac9 100644 --- a/app/Views/kyc_docs.php +++ b/app/Views/kyc_docs.php @@ -323,38 +323,49 @@ $(document).ready(function () { function removeKYCDocs(element) { - var kyc_docs_id_for_reload = $('#kyc_type_id').val(); - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - // location.reload(); - window.location.href = '' + kyc_docs_id_for_reload; + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this!.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } - } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); + if (result.isConfirmed) { + var kyc_docs_id_for_reload = $('#kyc_type_id').val(); + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('KYC docs removed successfully'); + // location.reload(); + window.location.href = '' + kyc_docs_id_for_reload; + + } else { + toastr.warning('Failed to remove KYC docs', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove KYC docs', 'warning'); + } + }); } + }); } diff --git a/app/Views/kyc_list.php b/app/Views/kyc_list.php index ec460a28..19ec6370 100644 --- a/app/Views/kyc_list.php +++ b/app/Views/kyc_list.php @@ -133,39 +133,49 @@ class csvExport { function removeKYC(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this!", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('KYC entity removed successfully', 'success'); - } else { - toastr.warning('Remove Not Done!', 'warning'); + location.reload(); + + } else { + toastr.warning('Failed to remove KYC entity', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Something Wrong!', 'warning'); + }, 1000); } - } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } + }); + } }); - - } diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 11e7405f..f43042ed 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -136,6 +136,7 @@ + @@ -395,13 +422,14 @@ $(document).on('click', '#otherPolicyTermsClose', function() { }); -$("#sumInsured2").on("keyup", function() { +$("#sum_insured_others").on("keyup", function() { var inputNumber = $(this).val(); + console.log('sum_insured_others keyup', inputNumber) if (inputNumber) { var result = convertCommaNumberToWords(inputNumber); - $("#numberToWordSumInsured").text(result); + $("#numberToWordOthers").text(result); } else { - $("#numberToWordSumInsured").text(""); + $("#numberToWordOthers").text(""); } }); @@ -417,6 +445,20 @@ $("#totalSumInsured").on("keyup", function() { }); +function si_keup_num_to_word2(input) { + + console.log('keyup sum insured'); + var inputNumber = $(input).val(); + console.log(inputNumber) + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + + $("#numberToWordOthers").text(result); + } else { + $("#numberToWordOthers").text(""); + } +}; + function appendPolicyTermsHTML(policy_type) { @@ -429,6 +471,25 @@ function appendPolicyTermsHTML(policy_type) {
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
@@ -523,11 +584,30 @@ function appendPolicyTermsHTML(policy_type) { ` } else if (policy_type == 6) { - + termsHTML = `
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
@@ -592,28 +672,31 @@ function appendPolicyTermsHTML(policy_type) { } -function appendOtherTermsSIAddMore(data = null){ +function appendOtherSIAddMore(data = null) { - console.log('function called') + const addMoreContainer = document.getElementById('sum_insured_add_more'); - var html = ` -
-
- -
-
- -
-
- - -
-
-
-
-
`; + console.log(addMoreContainer) - $('#other_si_add_more').append(html); + const html = ` +
+
+ +
+
+ +
+
+ + +
+
+
+
+
+
+
`; + + addMoreContainer.insertAdjacentHTML('beforeend', html); } - \ No newline at end of file diff --git a/app/Views/policies.php b/app/Views/policies.php index 0ea4ed10..02f81ef5 100644 --- a/app/Views/policies.php +++ b/app/Views/policies.php @@ -396,42 +396,52 @@ $(document).ready(function () { function removePolicies(element) { - var policy_id_for_reload = $('#policy_type_id').val() - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - // $('#branch_table').empty(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this Policy.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - // location.reload(); - window.location.href = '' + policy_id_for_reload; + if (result.isConfirmed) { + var policy_id_for_reload = $('#policy_type_id').val() + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Policy removed successfully', 'success'); + // $('#branch_table').empty(); + // location.reload(); + window.location.href = '' + policy_id_for_reload; - } else { - toastr.warning('Remove Not Done!', 'warning'); - } - } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); + } else { + toastr.warning('Failed to remove policy', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove policy', 'warning'); + } + }); } + }); - } +} \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index f64b7f4b..28ff4417 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -111,9 +111,9 @@
- +
-
+
@@ -141,14 +141,14 @@
Self:
Min Age:
Max Age:
Min Age:
Max Age:
Spouse:
Min Age:
Max Age:
Min Age:
Max Age:
Children:
Elders Count:
Min Age:
Max Age:
Min Age:
Max Age:
@@ -507,7 +507,7 @@
@@ -827,12 +825,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa }; -$("#GridForm").submit(async function(event) { +$("#GridForm").submit(function(event) { + + event.preventDefault(); var check = checkDuplicate(0); console.log(check) + if(check){ + return; + } - event.preventDefault(); if ($('#grid_emp_count').val() == 'false') { toastr.warning('Client has active employees', 'Warning'); @@ -854,9 +856,16 @@ $("#GridForm").submit(async function(event) { checkPolicyTermsSI(function(result) { + + console.log('checkPolicyTermsSI callback') + console.log(result); + if (!result) { - if (check) { + console.log('after result'); + + + if (check = false) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); } else { @@ -901,15 +910,14 @@ $("#GridForm").submit(async function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning(`Value does not exist in the Policy Terms.`); - + toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`); } -}).catch(function(error) { - console.error('Error checking policy terms:', error); - // Handle error if necessary - toastr.error(`Error checking policy terms: ${error}`); - }); + }).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + console.log(`Error checking policy terms: ${error}`); + }); }); @@ -941,46 +949,61 @@ $("#AdditionalGridForm").submit(function(event) { var formData = new FormData($('#AdditionalGridForm')[0]); var policy_form_action = ''; + checkPolicyTermsSI(function(result) { - if (check) { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - } else { - $.ajax({ - data: formData, - url: policy_form_action, - type: "POST", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - - //console.log("Response", res); - - if (res.status === false) { - toastr.error('Policy Dose Not Create', 'Error'); - return; - } + if (!result) { + if (check) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + } else { + $.ajax({ + data: formData, + url: policy_form_action, + type: "POST", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { - var message = (policy_PrimaryKey === '') ? - 'Policy Additional Rack Rate Added successfully' : - 'Policy Additional Rack Rate Added Successfully'; - toastr.success(message, 'Success'); - $('.close').click(); + //console.log("Response", res); - }, - error: function(xhr, status, error) { + if (res.status === false) { + toastr.error('Policy Dose Not Create', 'Error'); + return; + } - console.error(xhr.responseText); - console.error(status, error); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + var message = (policy_PrimaryKey === '') ? + 'Policy Additional Rack Rate Added successfully' : + 'Policy Additional Rack Rate Added Successfully'; + toastr.success(message, 'Success'); + $('.close').click(); + + }, + error: function(xhr, status, error) { + + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }); } - }); - } + + }else{ + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`); + } + + }).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + console.log(`Error checking policy terms: ${error}`); + }); }); @@ -2574,6 +2597,8 @@ function si_orbp_change_function() { // $('.gpa_sum_insure_remove').remove(); var selectedValue = $('#si_or_bp').val(); + console.log('selectedValue', selectedValue) + if (selectedValue == 2) { $('.gpa_sum_insure_remove').hide(); @@ -2659,8 +2684,8 @@ function si_orbp_change_function() { $('#basic_multiplier').removeAttr('required', false); $('#premium_multiplier').removeAttr('required', false); $('#basic_pay').removeAttr('required', false); - $('#gpa_basic_si').removeAttr('required', false); - $('#gpa_basic_premium').removeAttr('required', false); + $('#gpa_basic_si_first').removeAttr('required', false); + $('#gpa_basic_premium_first').removeAttr('required', false); $('#gpa_sum_multiplier2').removeAttr('required', false); $('#gpa_sum_si2').removeAttr('required', false); @@ -2711,8 +2736,8 @@ function si_orbp_change_function() { $('#basic_multiplier').removeAttr('required', false); $('#premium_multiplier').removeAttr('required', false); $('#basic_pay').removeAttr('required', false); - $('#gpa_basic_si').removeAttr('required', false); - $('#gpa_basic_premium').removeAttr('required', false); + $('#gpa_basic_si_first').removeAttr('required', false); + $('#gpa_basic_premium_first').removeAttr('required', false); $('#gpa_sum_multiplier').attr('required', false); $('#gpa_sum_si').attr('required'); @@ -2936,126 +2961,130 @@ function checkTermsSISameAsRackRateSI(input) { } - function checkPolicyTermsSI(callback) { +function checkPolicyTermsSI(callback) { + console.log('checkPolicyTermsSI function called'); - console.log('r function called'); - - var id = $('#additional_grid')[0]; + var id = $('#additional_grid')[0]; var container = $('#additional_grid_content_input'); - var val = 0; + var val = 0; if (val == 0) { id = $('#grid')[0]; container = $('#grid_content_input'); } - console.log(id); console.log(container); - var siInputs = 0; + var siInputs = null; - if (id.value === '2') { - siInputs = container.find('input[name="gpa_si"]'); - } else if (id.value === '3') { - siInputs = container.find('input[name="3_si[]"]'); - } else if (id.value === '4') { - siInputs = container.find('input[name="4_si[]"]'); - } else if (id.value === '5') { - siInputs = container.find('input[name="5_si[]"]'); - } else if (id.value === '6') { - siInputs = container.find('input[name="6_si[]"]'); - } else if (id.value === '7') { - siInputs = container.find('input[name="7_si[]"]'); - } else if (id.value === '8') { - siInputs = container.find('input[name="8_si[]"]'); - } else if (id.value === '9') { - siInputs = container.find('input[name="9_si[]"]'); - } else if (id.value === '10') { - siInputs = container.find('input[name="10_si[]"]'); - } else if (id.value === '11') { - siInputs = container.find('input[name="11_si[]"]'); - } else if (id.value === '1') { - var selectedValue = $('#si_or_bp').val(); - - if (selectedValue == 1) { - siInputs = container.find('input[name="gpa_sum_si[]"]'); - } else if (selectedValue == 3) { - siInputs = container.find('input[name="gpa_sum_si2[]"]'); - } + switch (id.value) { + case '1': + var selectedValue = $('#si_or_bp').val(); + if (selectedValue == 1) { + siInputs = container.find('input[name="gpa_sum_si[]"]'); + } else if (selectedValue == 3) { + siInputs = container.find('input[name="gpa_sum_si2[]"]'); + } + break; + case '2': + siInputs = container.find('input[name="gpa_si"]'); + break; + case '3': + siInputs = container.find('input[name="3_si[]"]'); + break; + case '4': + siInputs = container.find('input[name="4_si"]'); + break; + case '5': + siInputs = container.find('input[name="5_si[]"]'); + break; + case '6': + siInputs = container.find('input[name="6_si"]'); + break; + case '7': + siInputs = container.find('input[name="7_si[]"]'); + break; + case '8': + siInputs = container.find('input[name="8_si[]"]'); + break; + case '9': + siInputs = container.find('input[name="gpa_si"]'); + break; + case '10': + siInputs = container.find('input[name="10_si[]"]'); + break; + case '11': + siInputs = container.find('input[name="11_si[]"]'); + break; + case '12': + siInputs = container.find('input[name="12_si[]"]'); + break; + case '13': + siInputs = container.find('input[name="13_si[]"]'); + break; + default: + siInputs = []; } + console.log('siInputs', siInputs); + var client_policy_id = $('#client_policy_id').val(); - console.log('client_policy_id', client_policy_id) + console.log('client_policy_id', client_policy_id); var url = '' + client_policy_id; - var arrayLength = 0; + console.log('url', url); $.ajax({ url: url, type: 'GET', dataType: 'json', success: function(response) { + console.log(response); console.log(response.data); - var array1 = response.data; - var array2 = []; + var policy_terms_si = response.data; + var rack_rate_si = []; siInputs.each(function() { var input = $(this).val(); - array2.push(input.replace(/,/g, '')); + console.log('input value', input); + rack_rate_si.push(input.replace(/,/g, '')); }); - console.log('array1', array1) - console.log('array2', array2) + console.log('policy_terms_si', policy_terms_si); + console.log('rack_rate_si', rack_rate_si); + let new_array = []; - function intersection(arr1, arr2) { - return arr1.filter(value => arr2.includes(value)); + rack_rate_si.forEach(element => { + if (!policy_terms_si.includes(element)) { + new_array.push(element); + } + }); + + console.log('filtered array', new_array); + + var arrayLength = new_array.length; + console.log('arrayLength', arrayLength); + + if (arrayLength > 0) { + callback(true); + } else { + callback(false); } - - var commonElements = intersection(array1, array2); - - function removeCommonElements(arr, common) { - return arr.filter(value => !common.includes(value)); - } - - array1 = removeCommonElements(array1, commonElements); - array2 = removeCommonElements(array2, commonElements); - - console.log('array1', array1) - console.log('array2', array2) - - - // var result = array1.concat(array2); - var result = array1; - - console.log('result', result) - - arrayLength = result.length; - - console.log('arrayLength', arrayLength) - - if (arrayLength > 0) { - callback(true); - } else { - callback(false); - } - }, error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - toastr.error(`Failed to retrieve Policy Terms. Error: ${error}`); + console.log(xhr.responseText); + console.log(status, error); + console.log(`Failed to retrieve Policy Terms. Error: ${error}`); callback(false); } }); - - } \ No newline at end of file diff --git a/app/Views/policy_grid_excel.php b/app/Views/policy_grid_excel.php index b5cf2531..ee8a1aeb 100644 --- a/app/Views/policy_grid_excel.php +++ b/app/Views/policy_grid_excel.php @@ -377,13 +377,18 @@ function generateTable(rack_rate_type) { $('#excel_table').html(table); } - if ($('.duplicate').length > 0) { - //console.log('test'); - toastr.warning("Duplicates found!", "warning"); - $('.excel_table_class').empty(); - $('.excel_textarea').val(''); + + if(secondKey != 2){ + console.log(secondKey) + if ($('.duplicate').length > 0) { + //console.log('test'); + toastr.warning("Duplicates found!", "warning"); + $('.excel_table_class').empty(); + $('.excel_textarea').val(''); + } } + if (emptyCellCount > 0) { toastr.warning('Number of empty cells: ' + emptyCellCount); $('.excel_table_class').empty(); @@ -566,4 +571,5 @@ function submitData(rack_rate_type) { } + \ No newline at end of file diff --git a/app/Views/policy_type_list.php b/app/Views/policy_type_list.php index 2318324f..b6e87e3a 100644 --- a/app/Views/policy_type_list.php +++ b/app/Views/policy_type_list.php @@ -138,38 +138,47 @@ class csvExport { function removePolciyType(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this!", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } - } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Policy type removed successfully', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove policy type', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove policy type', 'warning'); + } + }); } + }); - } diff --git a/app/Views/tpa_branch.php b/app/Views/tpa_branch.php index 1015d36e..9c41e358 100644 --- a/app/Views/tpa_branch.php +++ b/app/Views/tpa_branch.php @@ -507,36 +507,46 @@ function validateForm() { function removeTPABranch(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); + + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this TPA branch.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - location.reload(); - - } else { - toastr.warning('Remove Not Done!', 'warning'); - } - } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('TPA branch removed successfully', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove TPA branch', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove TPA branch', 'warning'); + } + }); } + }); } \ No newline at end of file diff --git a/app/Views/tpa_list.php b/app/Views/tpa_list.php index 9df0a1c0..83abeb08 100644 --- a/app/Views/tpa_list.php +++ b/app/Views/tpa_list.php @@ -132,39 +132,47 @@ class csvExport { function removeTPA(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this TPA", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('TPA removed successfully', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove TPA', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Failed to remove TPA', 'warning'); + } + }); } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } - }); - + }); } diff --git a/composer.json b/composer.json index 2dd9d301..9f2ec667 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "laminas/laminas-escaper": "^2.9", "php-amqplib/php-amqplib": "^2.8", "phpmailer/phpmailer": "^6.9", - "phpoffice/phpspreadsheet": "^2.0", + "phpoffice/phpspreadsheet": "^2.1", "psr/log": "^1.1", "slim/slim": "^4.13", "zircote/swagger-php": "^4.8"