CHANGE_CD_ACC_RESTRICT
This commit is contained in:
parent
807399a564
commit
2d2533d178
@ -399,8 +399,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster');
|
||||
|
||||
|
||||
$routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount');
|
||||
});
|
||||
|
||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||
|
||||
@ -1350,6 +1350,16 @@ class MasterController extends AdminController
|
||||
// === INSERT ===
|
||||
if (empty($id)) {
|
||||
|
||||
$cd_acc_count = $this->CDMasterModel->where('is_active', 1)
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('insurer_id', $data['insurer_id'])
|
||||
->where('insurer_branch_id', $data['insurer_branch_id'])
|
||||
->countAllResults();
|
||||
|
||||
if($cd_acc_count > 0){
|
||||
return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", 'Performing INSERT operation.');
|
||||
$insert = $this->CDMasterModel->insert($data);
|
||||
$this->myLogger->logme("error", 'Insert result: ' . json_encode($insert));
|
||||
@ -1574,6 +1584,15 @@ class MasterController extends AdminController
|
||||
|
||||
$data['insurer_branch_id'] = $insurer_branch_id;
|
||||
|
||||
$cd_acc_count = $this->CDMasterModel->where('is_active', 1)
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('insurer_id', $data['insurer_id'])
|
||||
->where('insurer_branch_id', $data['insurer_branch_id'])
|
||||
->countAllResults();
|
||||
|
||||
if($cd_acc_count > 0){
|
||||
return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
|
||||
}
|
||||
|
||||
// array with data for CD Traction table
|
||||
$cd_tranction_data = [
|
||||
@ -1617,6 +1636,24 @@ class MasterController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function checkDuplicateCdAccount()
|
||||
{
|
||||
$data = $this->request->getGet();
|
||||
|
||||
$cd_acc_count = $this->CDMasterModel
|
||||
->where('is_active', 1)
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('insurer_id', $data['insurer_id'])
|
||||
->where('insurer_branch_id', $data['insurer_branch_id'])
|
||||
->countAllResults();
|
||||
|
||||
if($cd_acc_count > 0){
|
||||
return $this->respond(['status' => false, 'message' => 'A CD account has already been created for this client, insurer, and insurer branch combination.'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => true], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Vehicle Master data Function
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="insurer_branch_id">Insurer Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control <?= !isset($CD_Master_Data) ? 'readonly-select' : '' ?>" id="insurer_branch_id" name="insurer_branch_id" required>
|
||||
<select class="form-control <?= !isset($CD_Master_Data) ? 'readonly-select' : '' ?>" id="insurer_branch_id" name="insurer_branch_id" onchange="checkDuplicateCdAccount(this)" required>
|
||||
<option value="">Select Insurer Branch</option>
|
||||
<?php if(isset($insurer_branch) && !empty($insurer_branch))
|
||||
{ foreach($insurer_branch as $branch) { ?>
|
||||
@ -229,11 +229,11 @@
|
||||
$('#opening_bal').prop("disabled", false);
|
||||
|
||||
if(isCdMasterPage == true){
|
||||
$('#client_id').val('').change();
|
||||
$('#insurer_id_for_cd').val('').change();
|
||||
$('#insurer_branch_id').val('').change();
|
||||
$('#cd_client_id').val('').select2();
|
||||
$('#insurer_id_for_cd').val('').select2();
|
||||
$('#insurer_branch_id').val('').select2();
|
||||
|
||||
$('#client_id').prop("disabled", false);
|
||||
$('#cd_client_id').prop("disabled", false);
|
||||
$('#insurer_id_for_cd').prop("disabled", false);
|
||||
$('#insurer_branch_id').prop("disabled", false);
|
||||
|
||||
@ -266,7 +266,7 @@
|
||||
);
|
||||
});
|
||||
|
||||
$branchSelect.val('').trigger('change.select2');
|
||||
$branchSelect.val('').select2();
|
||||
}
|
||||
|
||||
function showCdMasterAddModal(){
|
||||
@ -301,5 +301,43 @@
|
||||
$('#cd_ac_no_for_cd_master').append(option);
|
||||
}
|
||||
|
||||
function checkDuplicateCdAccount(){
|
||||
|
||||
let url = '<?= base_url('util/checkDuplicateCdAccount') ?>';
|
||||
let client_id = $('#cd_client_id').val();
|
||||
let insurer_id = $('#insurer_id_for_cd').val();
|
||||
let insurer_branch_id = $('#insurer_branch_id').val();
|
||||
console.log({client_id, insurer_id, insurer_branch_id});
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
client_id: client_id,
|
||||
insurer_id: insurer_id,
|
||||
insurer_branch_id: insurer_branch_id,
|
||||
};
|
||||
|
||||
if(client_id != "" && insurer_id != "" && insurer_branch_id != ""){
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
console.log('No dublicate found');
|
||||
} else {
|
||||
|
||||
$('#cd_client_id').val('').select2();
|
||||
$('#insurer_id_for_cd').val('').select2();
|
||||
$('#insurer_branch_id').val('').select2();
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -323,7 +323,7 @@ table.dataTable thead th {
|
||||
$('#cd_client_id').prop("disabled", true);
|
||||
$('#insurer_id_for_cd').val(res.data.insurer_id).change();
|
||||
$('#insurer_id_for_cd').prop("disabled", true);
|
||||
$('#insurer_branch_id').val(res.data.insurer_id).change();
|
||||
$('#insurer_branch_id').val(res.data.insurer_branch_id).select2();
|
||||
$('#insurer_branch_id').prop("disabled", true);
|
||||
$('#opening_date').val(res.data.opening_date);
|
||||
$('#cd_ac_no_for_cd_master').val(res.data.cd_ac_no);
|
||||
|
||||
@ -842,6 +842,17 @@ input:checked + .slider::before {
|
||||
|
||||
if(response.status == false && response.insurer_id != 'undefined'){
|
||||
toastr.warning('The CD Account Number not found.', 'Warning');
|
||||
|
||||
$('#cd_ac_no').empty();
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select CD Account Number'
|
||||
}));
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add New CD'
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
appendCDACNO(response.data)
|
||||
@ -1806,15 +1817,18 @@ input:checked + .slider::before {
|
||||
//console.log('appendCDACNO', select);
|
||||
|
||||
$('#cd_ac_no').empty();
|
||||
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select CD Account Number'
|
||||
}));
|
||||
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add New CD'
|
||||
}));
|
||||
if(data.length == 0){
|
||||
$('#cd_ac_no').append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add New CD'
|
||||
}));
|
||||
}
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
const option = $('<option>', {
|
||||
@ -2381,140 +2395,135 @@ input:checked + .slider::before {
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#chk-show-expired').on('change', function () {
|
||||
|
||||
$('#chk-show-expired').on('change', function () {
|
||||
const showExpired = $(this).is(':checked');
|
||||
|
||||
const showExpired = $(this).is(':checked');
|
||||
let policyTable = '';
|
||||
let data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||
let role = data.role
|
||||
delete data.role;
|
||||
|
||||
let policyTable = '';
|
||||
let data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||
let role = data.role
|
||||
delete data.role;
|
||||
console.log("checkbox working");
|
||||
|
||||
console.log("checkbox working");
|
||||
$.each(data, function(index, item) {
|
||||
// console.log('step 1');
|
||||
let patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
|
||||
let patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
|
||||
let subject = item.policy_type_name;
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
// console.log('step 1');
|
||||
let patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
|
||||
let patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
|
||||
let subject = item.policy_type_name;
|
||||
//console.log('search terms subject', subject);
|
||||
|
||||
//console.log('search terms subject', subject);
|
||||
if (patternGMC.test(subject)) {
|
||||
search_term = 'GMC';
|
||||
} else if (patternGPA.test(subject)) {
|
||||
search_term = 'GPA';
|
||||
} else {
|
||||
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
|
||||
}
|
||||
|
||||
if (patternGMC.test(subject)) {
|
||||
search_term = 'GMC';
|
||||
} else if (patternGPA.test(subject)) {
|
||||
search_term = 'GPA';
|
||||
} else {
|
||||
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
|
||||
}
|
||||
|
||||
let tpaValue = 'TPA Unavailable';
|
||||
let tpaValue = 'TPA Unavailable';
|
||||
|
||||
if (item.tpa_short && item.tpa_branch_code) {
|
||||
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
|
||||
if (item.tpa_short && item.tpa_branch_code) {
|
||||
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
|
||||
}
|
||||
|
||||
let policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`;
|
||||
|
||||
if(showExpired == true && checkDateStatus(item.policy_end_date) == 'Expired'){
|
||||
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
|
||||
let policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`;
|
||||
|
||||
if(showExpired == true && checkDateStatus(item.policy_end_date) == 'Expired'){
|
||||
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
if(showExpired == false && checkDateStatus(item.policy_end_date) != 'Expired'){
|
||||
|
||||
}
|
||||
|
||||
if(showExpired == false && checkDateStatus(item.policy_end_date) != 'Expired'){
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role != 3 && role != 4) {
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
</div>
|
||||
policyTable += `
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
const table = $('#table-client-policy').DataTable();
|
||||
table.clear().destroy();
|
||||
|
||||
$('#table-client-policy tbody').html(policyTable); // replace tbody content
|
||||
|
||||
$('#table-client-policy').DataTable({
|
||||
paging: true,
|
||||
searching: true,
|
||||
autoWidth: false,
|
||||
responsive: true,
|
||||
});
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
const table = $('#table-client-policy').DataTable();
|
||||
table.clear().destroy();
|
||||
|
||||
$('#table-client-policy tbody').html(policyTable); // replace tbody content
|
||||
|
||||
$('#table-client-policy').DataTable({
|
||||
paging: true,
|
||||
searching: true,
|
||||
autoWidth: false,
|
||||
responsive: true,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -3398,10 +3398,12 @@
|
||||
text: 'Select CD No',
|
||||
}));
|
||||
|
||||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add CD'
|
||||
}));
|
||||
if(data.length == 0){
|
||||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||||
value: 'add_cd',
|
||||
text: '+ Add CD'
|
||||
}));
|
||||
}
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user