From a2ebc9bea7b00f2452959bf858a022e643379746 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 30 May 2024 15:17:05 +0530 Subject: [PATCH] CHANGE_SI_ENHANCEMENT_HIDE_SHOW_IN_DROP_DOWN_DELETE_ADDITIONAL_RACK_RATE_DATE : RV --- app/Config/Routes.php | 10 +- app/Config/Session.php | 3 +- app/Controllers/ClientController.php | 37 +++++- app/Controllers/DashboardController.php | 18 ++- app/Controllers/EmployeeController.php | 41 +++++- app/Helpers/sendMailNotification.php | 4 +- app/Helpers/session_helper.php | 31 +++++ app/Models/ClientModel.php | 13 +- app/Views/client_branch.php | 2 +- app/Views/client_policy.php | 9 +- app/Views/employee_upload.php | 22 ++-- app/Views/insurer_or_tpa_data.php | 2 +- app/Views/layout/footer.php | 22 ++-- app/Views/notification.php | 3 +- app/Views/policy_grid.php | 159 +++++++++++++++++++++--- 15 files changed, 317 insertions(+), 59 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a32b6788..7e69c587 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -23,12 +23,6 @@ $routes->get('download-e-card/(:any)', 'EmployeeController::generateIDCardForEmp $routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1'); -$routes->get('get-notification', 'DashboardController::getDashboardNotifications'); -$routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1'); -$routes->get('get-pending-action', 'PendingActionsController::getPendingActions'); - - - $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "UserController::create"); $routes->get("create", "UserController::create"); @@ -42,6 +36,9 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) { $routes->get("view", "DashboardController::dashboard"); + $routes->get('get-notification', 'DashboardController::getDashboardNotifications'); + $routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1'); + $routes->get('get-pending-action', 'PendingActionsController::getPendingActions'); }); @@ -236,6 +233,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("has_policy_config_completed/(:any)", "EmployeeController::hasPolicyConfigCompleted/$1"); $routes->get("get-client-branch/(:any)", "ClientController::getClientBranch/$1"); $routes->get("get-client-details/(:any)", "ClientController::getClientAllDetailsByUsingClientID/$1"); + $routes->get("delete-additional-rack-rate/(:any)", "ClientController::deleteAdditionalRackRate/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Config/Session.php b/app/Config/Session.php index 591aefdc..e077df64 100644 --- a/app/Config/Session.php +++ b/app/Config/Session.php @@ -40,8 +40,7 @@ class Session extends BaseConfig * The number of SECONDS you want the session to last. * Setting to 0 (zero) means expire when the browser is closed. */ - // public int $expiration = 7200; - public int $expiration = 86400; //24 Hours + public int $expiration = 7200; /** * -------------------------------------------------------------------------- diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7a9e9263..033300aa 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -169,8 +169,9 @@ class ClientController extends AdminController // echo "
";
         // print_r($data); die;
-        $data['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'client_name'];
+        $data['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($data['placeHolders']);
 
         echo view('layout/header', $headerData);
         echo view('client_onboarding', $data);
@@ -283,7 +284,7 @@ class ClientController extends AdminController
         
 
         $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', 'client_name'];
+        $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'];
 
 
         echo view('layout/header', $headerData);
@@ -591,7 +592,7 @@ class ClientController extends AdminController
         $policyCount = $this->clientPolicyModel
         ->where('policy_id', $policy_id) 
         ->where('client_branch_id', $client_branch_id)
-        ->countAllResult(); 
+        ->countAllResults(); 
 
         if($policyCount > 0 ){
             $clientPoliceData =  $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
@@ -809,8 +810,8 @@ class ClientController extends AdminController
             $relation_data['spouse'] = $spouse;
             $relation_data['childrens'] = $childrens;
             $relation_data['parents'] = $parents;
-            $relation_data['parents_in_law'] = $parents_in_law;
-            $relation_data['either_parents_pil'] = $either_parents_pil;
+            $relation_data['parents-in-law'] = $parents_in_law;
+            $relation_data['either-parents-pil'] = $either_parents_pil;
 
 
             $jsonDataForRelation = json_encode($relation_data);
@@ -2094,5 +2095,31 @@ class ClientController extends AdminController
     }
 
 
+    public function deleteAdditionalRackRate($client_id, $client_policy_id, $rack_rate_type)
+    {
+        try {
+            $result = $this->policyPremium2Model
+                ->where('client_id', $client_id)
+                ->where('client_policy_id', $client_policy_id)
+                ->where('rack_rate_type', $rack_rate_type)
+                ->set('is_active', 0)
+                ->update();
+    
+            if (!$result) {
+
+                return $this->respond(['status' => false,'code' => 200, 'message' => 'Failed to update the record.'], 200);
+            }
+        } catch (\Exception $e) {
+
+            log_message('error', $e->getMessage());
+            return $this->respond(['status' => false,'code' => 200, 'message' => 'Failed to update the record.'], 200);
+
+        }
+    
+        return $this->respond(['status' => true,'code' => 200, 'message' => 'Additionaly Rack Rate Data Remove Successfully'], 200);
+    }
+    
+
+
 
 }
\ No newline at end of file
diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php
index 1378abbf..8642c0a5 100644
--- a/app/Controllers/DashboardController.php
+++ b/app/Controllers/DashboardController.php
@@ -18,11 +18,14 @@ class DashboardController extends AdminController
     use ResponseTrait;
     protected $messageModel;
     protected $userMessageModel;
+    protected $myLogger;
     
     public function __construct()
     {
+        set_session_context('Dashboard');
         $this->messageModel        = new MessageModel();
         $this->userMessageModel    = new UserMessageModel();
+        $this->myLogger = \Config\Services::mylogger();
     }
 
     public function dashboard()
@@ -34,15 +37,20 @@ class DashboardController extends AdminController
 
     public function getDashboardNotifications()
     {
-        //pull notofications to dashboard especially for file upload cases
+        // Pull notifications for the dashboard, especially for file upload cases.
         $userId = get_session_userid();
         $roleId = 5;
         $teamId = 1;
-
-        $messages = $this->messageModel->getMessagesForUser($userId, $roleId, $teamId);
-
-        return $this->respond($messages);
+    
+        if ($userId != null && $roleId != null && $teamId != null) {
+            $messages = $this->messageModel->getMessagesForUser($userId, $roleId, $teamId);
+            return $this->respond(['status' => true, 'code' => 200, 'message' => $messages], 200);
+        } else {
+            $this->myLogger->logme('error', 'The session is not set correctly. USER_ID : {user_id},  ROLE_ID : {role_id},  TEAM_ID : {team_id}', ['user_id' => $userId, 'role_id' => $roleId, 'team_id' => $teamId]);
+            return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data found'], 200);
+        }
     }
+    
 
     public function acknowledgeMessage($messageId)
     {
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 77a14554..3e73f9a8 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -1040,6 +1040,34 @@ class EmployeeController extends AdminController
     {
 
         $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";
+        }
+        
     }
 
 
@@ -1253,9 +1281,18 @@ class EmployeeController extends AdminController
     {
         $client_policy_id = $this->request->uri->getSegment(3);
         $policy_details = $this->clientPolicyModel->find($client_policy_id);
-        // print_r($policy_details);die();
         $policy_terms = isset($policy_details['policy_terms']) ? true : false;
 
+        $si_enhancement_true_or_false = 1;
+        if($policy_terms){
+            $policyTermsData = json_decode($policy_details['policy_terms']);
+
+            if (isset($policyTermsData->suminsuredenhancement) && $policyTermsData->suminsuredenhancement !== null) {
+                $si_enhancement_true_or_false = $policyTermsData->suminsuredenhancement;
+            }        
+        }
+        
+
         $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$policy_details['client_id']);
 
         $message = null;
@@ -1270,7 +1307,7 @@ class EmployeeController extends AdminController
         }
         $message  = isset($message) ? ($message . ' not defined for choosed policy') : null;
 
-            return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message], 200);
+        return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false], 200);
         
     }
 
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
index cfc96b17..0c8c7067 100644
--- a/app/Helpers/sendMailNotification.php
+++ b/app/Helpers/sendMailNotification.php
@@ -105,6 +105,7 @@ class sendMailNotification
             $name =  $get_emp_email_and_other_details['name'];
             $mail_content = $notification['mail_content'];
             $nhance_logo = $_ENV['NHANCE_LOGO'];
+            $post_enrollment_app_link = $_ENV['POST_ENROLLMENT_APP_LINK'];
             
             $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
             // $client_logo = $nhance_logo;
@@ -114,8 +115,9 @@ class sendMailNotification
 
             $mail_content = str_replace("[[member_name]]", $name, $mail_content);
             $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
+            $mail_content = str_replace("[[post_enrollment_app_link]]", "Review Details", $mail_content);
             // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
-            $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content);
+            $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content);
             $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
 
             $wholeData =  ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']];
diff --git a/app/Helpers/session_helper.php b/app/Helpers/session_helper.php
index 6e879e4b..ce6a0f56 100644
--- a/app/Helpers/session_helper.php
+++ b/app/Helpers/session_helper.php
@@ -10,6 +10,37 @@ if (!function_exists('check_session')) {
     }
 }
 
+if (!function_exists('set_last_visited_time')) {
+    function set_last_visited_time()
+    {
+        $session = \Config\Services::session();
+        $session->set('last_visited', date("Y-m-d H:i:s"));
+    }
+}
+
+if (!function_exists('get_last_visited_time')) {
+    function get_last_visited_time()
+    {
+        // Get the session service
+        $session = \Config\Services::session();
+
+        // Get the last visited time from session
+        $lastVisitTime = $session->get('last_visited');
+
+        // Check if the last visited time is set
+        if ($lastVisitTime) {
+            // Calculate the time five minutes ago
+            $fiveMinutesBefore = date("YmdHi", strtotime('-5 minutes'));
+
+            // Compare the last visited time with the time five minutes ago
+            return date("YmdHi", strtotime($lastVisitTime)) > $fiveMinutesBefore ? 1 : 0;
+        }
+
+        // If last visited time is not set, return 0
+        return 0;
+    }
+}
+
 if (!function_exists('get_session_userid')) {
     function get_session_userid()
     {
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index 35beeb4c..fd1e8510 100644
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -42,7 +42,18 @@ class ClientModel extends Model
 
             foreach ($clients as &$client) {
                 $clientPolicyModel = new ClientPolicyModel();
-                $clientPolicies = $clientPolicyModel->select(['client_branch.id as branch_id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id', 'client_policy.id as client_policy_id','p.name','pt.policy_type',])
+                $clientPolicies = $clientPolicyModel
+                                  ->select(['
+
+                                        client_branch.id as branch_id',
+                                        'client_branch.branch_name',
+                                        'client_branch.branch_code', 
+                                        'client_branch.client_id', 
+                                        'client_policy.id as client_policy_id',
+                                        'client_policy.policy_terms',
+                                        'p.name',
+                                        'pt.policy_type',
+                                    ])
                                   ->join('client_branch', 'client_branch.id = client_policy.client_branch_id') 
                                   ->join('policies p', 'p.id = client_policy.policy_id') 
                                   ->join('policy_type pt','client_policy.policy_type_id = pt.id')
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php
index c788731c..93ea7137 100644
--- a/app/Views/client_branch.php
+++ b/app/Views/client_branch.php
@@ -234,7 +234,7 @@ $(document).ready(function () {
     $("#branch_form").submit(function(event) {
 
         event.preventDefault(); 
-        branch_PrimaryKey = $('#client_id_for_client_branch').val();
+        branch_PrimaryKey = $('#client_id_branch').val();
 
         console.log('branch_PrimaryKey', branch_PrimaryKey)
         
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index bb844432..ab4e17f4 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -47,7 +47,7 @@
                             
@@ -1468,6 +1468,13 @@ $('#client_branch').empty(); + + $('#client_branch').append($('"; + echo ""; } } ?> @@ -351,9 +351,10 @@ function fetchClientPolicies() { }, success: function(response) { - // console.log(response); + console.log(response); // console.log(response.dataStatus); // console.log(response.data); + if (response.code === 200 && response.dataStatus === true && response.data !== "") { try { clientPolicies = (response.data) @@ -910,7 +911,7 @@ function checkPolicyTermsAndRackRatesHasDefiend(event) { // console.log(event.target.id); var policy_id = (event.target.value); - // console.log('checkPolicyTermsAndRackRatesHasDefiend called ' + policy_id); + console.log('checkPolicyTermsAndRackRatesHasDefiend called ' + policy_id); if(policy_id != 0 && policy_id != " " && policy_id != undefined) { var apiURL = '' + 'util/has_policy_config_completed/' + policy_id; @@ -930,11 +931,18 @@ function checkPolicyTermsAndRackRatesHasDefiend(event) success: function(response) { setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - }, 1000); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); + + console.log('check policy responce', response); + + if (response.hasOwnProperty('si_enhancement') && response.si_enhancement == 0) { + $('.si-enhancement-option').hide(); + } else { + $('.si-enhancement-option').show(); + } - // console.log('check policy responce', response); if (response.code === 200 && response.dataStatus === true && response.message !== null) { toastr.error(response.message, 'Error'); diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index 48cc73a1..c068ec39 100644 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -76,7 +76,7 @@ $action) { - echo ""; + echo ""; } } ?> diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 114184f7..35093e66 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -155,27 +155,28 @@ function fetchMessages() { $.ajax({ - url: '', + url: '', method: 'GET', success: function(response) { - // $(document).ready(function() { - // $("#playMusic").get(0).play(); - // }); + console.log('responce', response) - - //console.log('responce', response) + if(response.status == false){ + $('#notification_count').html('0') + console.log('The session is not set correctly. ') + return; + } let messagesList = $('#messages-list'); messagesList.empty(); var html = ""; - pullNotificationCount = response.length + pullNotificationCount = response.message.length localStorage.setItem('pullNotificationCount', pullNotificationCount) - response.forEach(message => { + response.message.forEach(message => { // if (!message.is_read) { // unreadCount++; @@ -183,7 +184,6 @@ var jasonDecodeData = JSON.parse(message.message_text) - var toast_body_css = 'background : #bfd7eb !important;'; var toast_head_css = 'background-color : rgb(2, 168, 181) !important; color :#000; border-bottom: 0;'; var toast_icon = 'mdi mdi-checkbox-marked-circle mr-auto'; @@ -247,7 +247,7 @@ function acknowledgeMessage(messageId) { $.ajax({ - url: '' + messageId, + url: '' + messageId, method: 'GET', success: function(response) { fetchMessages(); @@ -300,7 +300,7 @@ $.ajax({ - url: '', + url: '', method: 'GET', success: function(response) { diff --git a/app/Views/notification.php b/app/Views/notification.php index 124094f5..feffdae3 100644 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -370,7 +370,8 @@ - - +
@@ -110,7 +110,7 @@
@@ -130,9 +130,19 @@
-

+ - Copy from excel +
+ + + + + +

@@ -861,7 +871,10 @@ $("#GridForm").submit(function(event) { $('.loader-mask').delay(350).fadeOut('slow'); var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully'; toastr.success(message, 'Success'); - // $('.close').click(); + + if($('#grid').val() == 1 || $('#grid').val() == 2){ + $('.close').click(); + } }, error: function(xhr, status, error) { @@ -887,6 +900,10 @@ $("#AdditionalGridForm").submit(function(event) { return; } + if (!checkCheckboxes()) { + event.preventDefault(); + } + var isValid = $('#AdditionalGridForm').parsley().validate(); if (!isValid) { console.log('Form is Empty', 'Warning'); @@ -987,10 +1004,14 @@ $('body').on('click', '.btnPolicyModel', function() { dataType: 'json', success: function(res) { - if (res.self == "") { - $('.close').click(); - toastr.warning('Unable to create rack rate due to the absence of policy terms.', - 'Warning'); + if(policy_type_string == 'GMC'){ + + if (res.self == "") { + $('.close').click(); + toastr.warning('Unable to create rack rate due to the absence of policy terms.', + 'Warning'); + } + } $('#GridForm')[0].reset(); @@ -998,7 +1019,7 @@ $('body').on('click', '.btnPolicyModel', function() { if (policy_type_string == 'GMC') { $('#premium_type').show(); - $('#individual').prop('checked', true) + $('#individual').prop('checked', true) } else { $('#premium_type').hide(); $('#individual').prop('checked', true) @@ -1047,10 +1068,10 @@ $('body').on('click', '.btnPolicyModel', function() { if (res.premiumData && res.premiumData.length > 0) { $.each(res.premiumData, function(index, item) { - if (item.rack_rate_type == 0) { + if (item.rack_rate_type == 0 || policy_type_string == 'GPA') { policy_grid_id_value = item.policy_grid_id; secondary = item.policy_grid_id; - premium_type_for_sec_rr.push(item.premium_type); + premium_type_for_primary_rr.push(item.premium_type); } else if (item.rack_rate_type == 1) { @@ -1063,6 +1084,14 @@ $('body').on('click', '.btnPolicyModel', function() { } + console.log('premium_type_for_sec_rr', premium_type_for_sec_rr) + + if(premium_type_for_sec_rr.length > 0){ + $('#del_btn_col').show(); + }else{ + $('#del_btn_col').hide(); + } + if (premium_type_for_sec_rr.length > 0) { @@ -1081,6 +1110,10 @@ $('body').on('click', '.btnPolicyModel', function() { $('#single_2').prop('checked', false) $('#individual_2').prop('checked', true) } + }else{ + + $('#single_2').prop('checked', false) + $('#individual_2').prop('checked', true) } @@ -1129,6 +1162,9 @@ $('body').on('click', '.btnPolicyModel', function() { $('#single').prop('checked', false); $('#individual').prop('checked', true); } + }else{ + $('#single').prop('checked', false); + $('#individual').prop('checked', true); } @@ -2616,7 +2652,7 @@ function createCheckboxes(obj, additional_relationship) { console.log('isChecked', isChecked); html += `
- +
`; // console.log(html); @@ -2627,8 +2663,101 @@ function createCheckboxes(obj, additional_relationship) { } - function formatString(str) { return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); } + + +$('#del_btn').click(function() { + console.log('delete btn clicked'); + + Swal.fire({ + title: "Are you sure?", + text: "You need to Delete this!", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + console.log('after then entered'); + + if (result.isConfirmed) { + console.log('isConfirmed entered'); + + var client_policy_id = $('#client_policy_id_2').val(); + console.log('client_policy_id', client_policy_id) + + var rack_rate_type = $('#rack_rate_type_2').val(); + console.log('rack_rate_type', rack_rate_type) + + var client_id = $('#Client_id_2').val(); + console.log('client_id', client_id) + + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + $.ajax({ + url: '' + client_id + '/' + client_policy_id + '/' + rack_rate_type, + type: 'GET', + success: function(res) { + + console.log('ajax success entered'); + console.log(res); + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + if (res.status === true) { + + $('#additional_grid_content_input').empty(); + $('#additional_grid').val(''); + $('#individual_2').prop('checked', true) + $('#single_2').prop('checked', false) + $('input[type="checkbox"]').prop('checked', false); + + + toastr.success(res.message, 'Success'); + + } else if (res.status === false) { + toastr.warning(res.message, 'Warning'); + return; + } + }, + error: function(xhr, status, error) { + console.log('ajax error entered'); + console.error(xhr.responseText); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }); + + // Removed the duplicated loader hiding code here + } + + console.log('after then entered end or cancel'); + }); + + console.log('delete btn clicked end'); +}); + + +function checkCheckboxes() { + var checkboxes = $('input.relation_checkbox'); + var checkedCount = checkboxes.filter(':checked').length; + var uncheckedCount = checkboxes.not(':checked').length; + + console.log('Checked count:', checkedCount); // Debugging + console.log('unchecked Count', uncheckedCount); + + if (checkedCount < 1) { + toastr.warning('You must select at least one checkbox.', 'Warning'); + return false; + } else if (checkedCount != uncheckedCount) { + toastr.warning('You can not select all of the checkboxes', 'Waraning'); + return false; + } + return true; +} + \ No newline at end of file