diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 80babc57..ab02ddd4 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -271,6 +271,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1"); $routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1"); $routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1"); + $routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ab571f53..e113a8c0 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2823,4 +2823,38 @@ class ClientController extends AdminController } + + public function removeRackRate($rack_rate_name = null, $client_policy_id = null) + { + $this->myLogger->logme('error', 'Rack Rate Remove function called'); + + $data = [ + 'updated_by' => get_session_userid(), + 'is_active' => 0 + ]; + + $rackRateData = $this->policyPremium2Model + ->where('rack_rate_name', $rack_rate_name) + ->where('client_policy_id', $client_policy_id) + ->where('is_active',1) + ->countAllResults(); + + if($rackRateData > 0){ + $update = $this->policyPremium2Model + ->where('rack_rate_name', $rack_rate_name) + ->where('client_policy_id', $client_policy_id) + ->set($data)->update(); + + if ($update) { + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Rack Rate removed successfully', 'rr_count' => $rackRateData], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy', 'rr_count' => $rackRateData], 200); + } + }else{ + + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Rack Rate not available', 'rr_count' => $rackRateData], 200); + } + + } + } \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 12104d31..0110412c 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -3062,7 +3062,7 @@ function appendNewTab(tabNameData = null, data = null)
`; @@ -3173,19 +3173,18 @@ function hideShowSubmitButton(emp_count, unique_id = null) } -function removeTab(input) -{ - console.log(input) - secondaryValue = '' - if(input.id){ - var unique_id = input.id.split('_'); - if (unique_id.length > 1) { - secondaryValue = unique_id[2]; - } - } +function removeTab(input, tabID, tabName) +{ + var client_policy_id = $('#client_policy_id_'+tabID).val(); + console.log('removeTab input', input) + console.log('removeTab tabID', tabID) + console.log('removeTab tabName', tabName) + console.log('removeTab client_policy_id', client_policy_id) + + Swal.fire({ title: "Are you sure?", - text: "You need to remove this Tab.", + text: "You want to remove this Rack Rate.", icon: "info", showCancelButton: true, confirmButtonColor: "#3085d6", @@ -3194,9 +3193,63 @@ function removeTab(input) if (result.isConfirmed) { - $('#'+secondaryValue).remove(); - $('#list_'+secondaryValue).remove(); + $('#'+tabID).remove(); + $('#list_'+tabID).remove(); $('#rack_rate_one').click(); + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + var form_action = '= base_url("util/remove_rack_rate/") ?>' + tabName + '/' + client_policy_id; + console.log(form_action) + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + console.log(res) + + if(res){ + if (res.status == true) { + Swal.fire({ + title: "Success", + text: res.message, + icon: "success" + }); + // toastr.success('Policy removed successfully.', 'success'); + } else { + if(res.rr_count > 0){ + Swal.fire({ + title: "warning!", + text: res.message, + icon: "warning" + }); + }else{ + Swal.fire({ + title: "Success", + text: 'Rack Rate removed successfully', + icon: "success" + }); + } + + // 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'); + console.log('Something Wrong!', 'warning'); + } + }); } }); @@ -3232,7 +3285,7 @@ function renameRackRateTab(input) { console.log(input) console.log(input.id) - var newTabName = prompt('Enter the tab name') + var newTabName = prompt('Enter rack rate name:') console.log(newTabName) secondaryValue = ''; if(input.id){