FIX_RACK_RATE_DELETE : RV

This commit is contained in:
VENKATESHWARAN 2024-07-29 15:07:37 +05:30
parent cfb932c3ee
commit bd4be72890
3 changed files with 103 additions and 15 deletions

View File

@ -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');

View File

@ -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);
}
}
}

View File

@ -3062,7 +3062,7 @@ function appendNewTab(tabNameData = null, data = null)
<div class="form-group text-right m-b-0" id="hide_smbt_btn_${tabId}">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnGridSubmit_2_${tabId}">Submit</button>
<a class="btn btn-danger waves-effect waves-light mr-1" id="btnGridremove_2_${tabId}" onclick="removeTab(this)">Delete</a>
<a class="btn btn-danger waves-effect waves-light mr-1" id="btnGridremove_2_${tabId}" onclick="removeTab(this, '${tabId}', '${tabName}')">Delete</a>
<a class="btn btn-secondary waves-effect waves-light mr-1" id="btnGridrename_${tabId}" onclick="renameRackRateTab(this)">Rename</a>
</div>
</form>`;
@ -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){