FIX_Velmurugan told me to add postDB[encrypt] in DataBase.php config Folder And View Member Client dropdown fixes and Dashbaord SSession Enrollment_data removed
This commit is contained in:
parent
5e3c7c4f33
commit
64ac479c30
@ -134,6 +134,10 @@ class Database extends Config
|
||||
'ssl_ca' => ROOTPATH . 'ca.pem',
|
||||
'ssl_verify' => true,
|
||||
];
|
||||
$this->preDB['encrypt'] = [
|
||||
'ssl_ca' => ROOTPATH . 'ca.pem',
|
||||
'ssl_verify' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -238,7 +238,7 @@ class DashboardController extends AdminController
|
||||
|
||||
$data['client_branch_emp_list'] = $results;
|
||||
$session = \Config\Services::session();
|
||||
$session->set('enrollment_data', json_encode($data));
|
||||
// $session->set('enrollment_data', json_encode($data));
|
||||
|
||||
$data['pendingActionsData'] = $pendingActionsData;
|
||||
$data['businessTeamCount'] = count($businessTeamData) ?? 0;
|
||||
|
||||
@ -355,11 +355,54 @@
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
var client_list = ''; // local variable for storing the client branch list
|
||||
var branch_list = ''; // local variable for storing the client branch list
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
var branch_policy = '';
|
||||
var policy_list_by_client = '';
|
||||
|
||||
$(document).ready(function() {
|
||||
getClientAndBranchAndPolicy();
|
||||
})
|
||||
|
||||
//featch client and branch and policy
|
||||
function getClientAndBranchAndPolicy() {
|
||||
$.ajax({
|
||||
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('getClientAndBranchAndPolicy', res);
|
||||
if (res.status == true) {
|
||||
|
||||
client_list = res.client_data;
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
policy_list_by_client = res.policyListByClient;
|
||||
|
||||
appendClients(client_list);
|
||||
// appendBranch(branch_list);
|
||||
// appendPolicies(policy_list);
|
||||
|
||||
} else {
|
||||
console.log('No data found');
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Declare a global variable to store API response data
|
||||
var clientPolicies = [];
|
||||
var clientPoliciesWithBranch = {
|
||||
policies: []
|
||||
};
|
||||
// var clientPolicies = [];
|
||||
// var clientPoliciesWithBranch = {
|
||||
// policies: []
|
||||
// };
|
||||
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
|
||||
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
|
||||
|
||||
@ -376,91 +419,91 @@
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log("document loaded");
|
||||
//fetchClientPolicies();
|
||||
});
|
||||
// $(document).ready(function() {
|
||||
// console.log("document loaded");
|
||||
// //fetchClientPolicies();
|
||||
// });
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("window loaded");
|
||||
fetchClientPolicies();
|
||||
});
|
||||
// $(window).on("load", function() {
|
||||
// console.log("window loaded");
|
||||
// fetchClientPolicies();
|
||||
// });
|
||||
|
||||
function fetchClientPolicies() {
|
||||
$('#loader').show();
|
||||
var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
||||
console.log('fetchClientPolicies');
|
||||
// console.log(apiURL);
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
clientPolicies = (response.data);
|
||||
// function fetchClientPolicies() {
|
||||
// $('#loader').show();
|
||||
// var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
||||
// console.log('fetchClientPolicies');
|
||||
// // console.log(apiURL);
|
||||
// $.ajax({
|
||||
// url: apiURL,
|
||||
// method: 'GET',
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// "X-Requested-With": "XMLHttpRequest"
|
||||
// },
|
||||
// success: function(response) {
|
||||
// // console.log(response.code);
|
||||
// // console.log(response.dataStatus);
|
||||
// // console.log(response.data);
|
||||
// if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
// try {
|
||||
// clientPolicies = (response.data);
|
||||
|
||||
response.data.forEach(policy => {
|
||||
// console.log('policies', policy.policies);
|
||||
policy.policies.forEach(p => {
|
||||
clientPoliciesWithBranch.policies.push(p);
|
||||
});
|
||||
});
|
||||
// response.data.forEach(policy => {
|
||||
// // console.log('policies', policy.policies);
|
||||
// policy.policies.forEach(p => {
|
||||
// clientPoliciesWithBranch.policies.push(p);
|
||||
// });
|
||||
// });
|
||||
|
||||
// console.log('1',clientPolicies);
|
||||
appendClients(clientPolicies);
|
||||
// // console.log('1',clientPolicies);
|
||||
// appendClients(clientPolicies);
|
||||
|
||||
//this function for reselect the policy
|
||||
setTimeout(function() {
|
||||
if (client_id != 0) {
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
// console.log(typeof item.id)
|
||||
return item.id == client_id;
|
||||
});
|
||||
appendBranch(foundPolicies.branchs);
|
||||
}
|
||||
}, 500);
|
||||
// //this function for reselect the policy
|
||||
// setTimeout(function() {
|
||||
// if (client_id != 0) {
|
||||
// var foundPolicies = clientPolicies.find(function(item) {
|
||||
// // console.log(typeof item.id)
|
||||
// return item.id == client_id;
|
||||
// });
|
||||
// appendBranch(foundPolicies.branchs);
|
||||
// }
|
||||
// }, 500);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_branch_id != 0) {
|
||||
// setTimeout(function() {
|
||||
// if (client_branch_id != 0) {
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === client_branch_id;
|
||||
});
|
||||
// var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// // console.log('item', item);
|
||||
// return item.branch_id === client_branch_id;
|
||||
// });
|
||||
|
||||
if (foundPolicies) {
|
||||
// console.log('foundPolicies', foundPolicies);
|
||||
appendPolicies(foundPolicies);
|
||||
} else {
|
||||
console.log('No policies found for the selected client');
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
//end
|
||||
// if (foundPolicies) {
|
||||
// // console.log('foundPolicies', foundPolicies);
|
||||
// appendPolicies(foundPolicies);
|
||||
// } else {
|
||||
// console.log('No policies found for the selected client');
|
||||
// }
|
||||
// }
|
||||
// }, 500);
|
||||
// //end
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
});
|
||||
// } catch (error) {
|
||||
// console.error('Error parsing API response data:', error);
|
||||
// }
|
||||
// } else if (response.code === 404 && response.dataStatus === false) {
|
||||
// console.error('no data found', response);
|
||||
// } else {
|
||||
// console.error('Something went wrong!');
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// console.error('Error fetching data from API:', error);
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
// $('#loader').hide();
|
||||
// }
|
||||
|
||||
function appendClients(data) {
|
||||
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
|
||||
@ -507,8 +550,9 @@
|
||||
// console.log(PolicyID)
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.client_policy_id,
|
||||
// value: item.client_policy_id,
|
||||
// text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
|
||||
value: item.id,
|
||||
text: `${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
|
||||
});
|
||||
if (PolicyID == item.client_policy_id) {
|
||||
@ -522,6 +566,9 @@
|
||||
|
||||
$('#clients').on('change', function() {
|
||||
|
||||
$('#branch_id').empty();
|
||||
$('#branch_id').append($('<option>', { value: '0', text: 'Select'}));
|
||||
|
||||
$('#policies').empty();
|
||||
$('#policies').append($('<option>', {
|
||||
value: '0',
|
||||
@ -529,15 +576,16 @@
|
||||
}));
|
||||
|
||||
var selectedClient = $(this).val();
|
||||
// console.log('selectedClient', selectedClient);
|
||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
||||
// alert(selectedClient);
|
||||
// console.log(branch_list);
|
||||
var filteredBranch = branch_list[selectedClient];
|
||||
|
||||
// Check if the selected option exists in apiData
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
return item.id === selectedClient;
|
||||
});
|
||||
// console.log(foundPolicies.branchs);
|
||||
appendBranch(foundPolicies.branchs);
|
||||
if (filteredBranch) {
|
||||
console.log("Found Data for Client " + selectedClient, filteredBranch);
|
||||
appendBranch(filteredBranch);
|
||||
} else {
|
||||
console.warn("No data found for client ID: " + selectedClient);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -545,26 +593,23 @@
|
||||
|
||||
$('#branch_id').on('change', function() {
|
||||
|
||||
var selectedClient = $(this).val();
|
||||
|
||||
// console.log('selectedBranch', selectedClient);
|
||||
// console.log('clientPolicies', clientPoliciesWithBranch);
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
var selectedBranch = $(this).val();
|
||||
var selectedClient = $('#clients').val();
|
||||
var filteredPoliciesByClient = policy_list_by_client[selectedClient];
|
||||
|
||||
var filteredPoliciesByBranch = filteredPoliciesByClient.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === selectedClient;
|
||||
return item.client_branch_id === selectedBranch;
|
||||
});
|
||||
|
||||
console.log("filteredPoliciesByClient => ",filteredPoliciesByClient);
|
||||
console.log("filteredPoliciesByBranch => ",filteredPoliciesByBranch);
|
||||
|
||||
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
|
||||
|
||||
appendPolicies(foundPolicies);
|
||||
if (Array.isArray(filteredPoliciesByBranch) && filteredPoliciesByBranch.length === 0) {
|
||||
appendPolicies(filteredPoliciesByBranch);
|
||||
toastr.warning('No policies found for the selected client branch.');
|
||||
|
||||
} else {
|
||||
|
||||
// console.log('foundPolicies', foundPolicies);
|
||||
appendPolicies(foundPolicies);
|
||||
appendPolicies(filteredPoliciesByBranch);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -412,7 +412,7 @@
|
||||
|
||||
function appendBranch2(data) {
|
||||
|
||||
// console.log(data)
|
||||
// console.log(data)
|
||||
|
||||
$('#client_branch_id').empty();
|
||||
$('#client_branch_id').append($('<option>', {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user