FEAT_HR_FILE_UPLOAD_STATUS_CHANGE_AND_REUPLOAD_THE_FILE_TO_THE_FILES_TABLE : RV
This commit is contained in:
parent
99987910e9
commit
45cdf71db3
@ -4055,10 +4055,25 @@ class ClientController extends AdminController
|
|||||||
{
|
{
|
||||||
// ---------for client-----------------------------------------------------------------------------
|
// ---------for client-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$role_id = get_role_id();
|
||||||
|
$user_id = get_session_userid();
|
||||||
|
|
||||||
|
|
||||||
|
if ($role_id == 2 || $role_id == 3) {
|
||||||
|
|
||||||
$clients = $this->clientModel
|
$clients = $this->clientModel
|
||||||
->select("*, DATE_FORMAT(dob, '%d-%m-%Y') as dob")
|
->select("clients.*, DATE_FORMAT(clients.dob, '%d-%m-%Y') as dob")
|
||||||
->where('is_active', 1)
|
->join('client_rm', 'client_rm.client_id = clients.id')
|
||||||
->findAll();
|
->where('client_rm.user_id', $user_id)
|
||||||
|
->where('clients.is_active', 1)
|
||||||
|
->findAll();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$clients = $this->clientModel
|
||||||
|
->select("*, DATE_FORMAT(dob, '%d-%m-%Y') as dob")
|
||||||
|
->where('is_active', 1)
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
$clientIds = array_column($clients, 'id');
|
$clientIds = array_column($clients, 'id');
|
||||||
|
|
||||||
@ -5064,6 +5079,10 @@ class ClientController extends AdminController
|
|||||||
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '1681']);
|
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '1681']);
|
||||||
// dd( $res);
|
// dd( $res);
|
||||||
|
|
||||||
|
// $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
|
||||||
|
// $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1056']);
|
||||||
|
// dd($res);
|
||||||
|
|
||||||
// ---------- POLICY TRANSACTION CONTROLLER --------------------------------------------------------------------------------
|
// ---------- POLICY TRANSACTION CONTROLLER --------------------------------------------------------------------------------
|
||||||
|
|
||||||
$policyTransactionController = new PolicyTransactionController();
|
$policyTransactionController = new PolicyTransactionController();
|
||||||
@ -5181,6 +5200,7 @@ class ClientController extends AdminController
|
|||||||
// $data['data'] = $BDSReportController->getBAPClientData();
|
// $data['data'] = $BDSReportController->getBAPClientData();
|
||||||
// return $this->loadLayout('irda_bap_client_report_list', $data);
|
// return $this->loadLayout('irda_bap_client_report_list', $data);
|
||||||
|
|
||||||
|
|
||||||
// $data['data'] = $BDSReportController->getClientData(1);
|
// $data['data'] = $BDSReportController->getClientData(1);
|
||||||
// return $this->loadLayout('irda_client_report_list', $data);
|
// return $this->loadLayout('irda_client_report_list', $data);
|
||||||
|
|
||||||
|
|||||||
@ -270,10 +270,11 @@ class EmployeeController extends AdminController
|
|||||||
$client_id = $this->request->getPost('client_id');
|
$client_id = $this->request->getPost('client_id');
|
||||||
$policy_id = $this->request->getPost('policy_id');
|
$policy_id = $this->request->getPost('policy_id');
|
||||||
$branch_id = $this->request->getPost('branch_id');
|
$branch_id = $this->request->getPost('branch_id');
|
||||||
|
$hr_file_id = $this->request->getPost('hr_file_id') ?? null;
|
||||||
$action = $this->request->getPost('upload-action-type');
|
$action = $this->request->getPost('upload-action-type');
|
||||||
$status = 'inprogress';
|
$status = 'inprogress';
|
||||||
|
|
||||||
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id,'uploaded_by' => 1]); //here field policy_id have client_policy_id and not policy id from policy master
|
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id,'uploaded_by' => 1, 'hr_file_id' => $hr_file_id]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||||
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
|
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
|
||||||
|
|
||||||
//start validation process
|
//start validation process
|
||||||
|
|||||||
@ -3960,11 +3960,46 @@ class EmployeeRestController extends AdminController
|
|||||||
$request = service('request');
|
$request = service('request');
|
||||||
|
|
||||||
// Start builder from model
|
// Start builder from model
|
||||||
|
// $builder = $this->hrFileUploadModel
|
||||||
|
// ->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name')
|
||||||
|
// ->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
||||||
|
// ->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
||||||
|
// ->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
|
||||||
|
|
||||||
$builder = $this->hrFileUploadModel
|
$builder = $this->hrFileUploadModel
|
||||||
->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name')
|
->select('
|
||||||
|
hr_file_upload.id,
|
||||||
|
hr_file_upload.client_id,
|
||||||
|
hr_file_upload.client_branch_id,
|
||||||
|
hr_file_upload.policy_id,
|
||||||
|
hr_file_upload.policy_no,
|
||||||
|
hr_file_upload.file_name,
|
||||||
|
hr_file_upload.file_action,
|
||||||
|
hr_file_upload.created_at,
|
||||||
|
hr_file_upload.created_by,
|
||||||
|
hr_file_upload.updated_at,
|
||||||
|
hr_file_upload.updated_by,
|
||||||
|
c.short_name,
|
||||||
|
cb.branch_name,
|
||||||
|
lc.name as first_name,
|
||||||
|
CASE
|
||||||
|
WHEN f.status IS NULL
|
||||||
|
THEN hr_file_upload.status
|
||||||
|
ELSE CONCAT(UCASE(LEFT(f.status, 1)), LCASE(SUBSTRING(f.status, 2)))
|
||||||
|
END AS status
|
||||||
|
', false)
|
||||||
->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
||||||
->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
||||||
->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
|
->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left')
|
||||||
|
->join(
|
||||||
|
'(SELECT f1.*
|
||||||
|
FROM files f1
|
||||||
|
WHERE f1.is_active = 1
|
||||||
|
ORDER BY f1.id DESC
|
||||||
|
LIMIT 1) f',
|
||||||
|
'f.hr_file_id = hr_file_upload.id',
|
||||||
|
'left'
|
||||||
|
);
|
||||||
|
|
||||||
// Allowed filter keys
|
// Allowed filter keys
|
||||||
$filters = [
|
$filters = [
|
||||||
|
|||||||
@ -997,10 +997,10 @@ class PolicyTransactionController extends BaseController
|
|||||||
$data['is_active'] = 0;
|
$data['is_active'] = 0;
|
||||||
$policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first();
|
$policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first();
|
||||||
if($policy_transaction_data['policy_type_id'] > 7){
|
if($policy_transaction_data['policy_type_id'] > 7){
|
||||||
|
|
||||||
$this->policyTransactionModel->where('id', $id)->set($data)->update();
|
$this->policyTransactionModel->where('id', $id)->set($data)->update();
|
||||||
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
|
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
|
||||||
$this->clientPolicyModel->where('id', $policy_transaction_data['client_policy_id'])->set($data)->update();
|
$this->clientPolicyModel->where('id', $policy_transaction_data['client_policy_id'])->set($data)->update();
|
||||||
|
$this->policyTransactionModel->where('client_policy_id', $policy_transaction_data['client_policy_id'])->set($data)->update();
|
||||||
}else{
|
}else{
|
||||||
$this->policyTransactionModel->where('id', $id)->set($data)->update();
|
$this->policyTransactionModel->where('id', $id)->set($data)->update();
|
||||||
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
|
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
|
||||||
|
|||||||
@ -20,7 +20,8 @@ class FileModel extends Model
|
|||||||
"policy_id",
|
"policy_id",
|
||||||
"client_branch_id",
|
"client_branch_id",
|
||||||
"uploaded_by",
|
"uploaded_by",
|
||||||
"updated_by"
|
"updated_by",
|
||||||
|
"hr_file_id",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,29 @@
|
|||||||
<style>
|
<style>
|
||||||
|
|
||||||
.reload:hover {
|
.reload:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table th,
|
||||||
|
.table td {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.dataTable tbody td {
|
||||||
|
padding: 4px 4px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addbtnStyle{
|
||||||
|
margin-left: 20px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataTables_filter {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="row">
|
<!-- <div class="row">
|
||||||
<div class="col-xl-12" style="margin-left: 14px;max-width: 98%;">
|
<div class="col-xl-12" style="margin-left: 14px;max-width: 98%;">
|
||||||
<div id="accordion1" class="mb-3">
|
<div id="accordion1" class="mb-3">
|
||||||
<div class="card mb-1">
|
<div class="card mb-1">
|
||||||
@ -21,7 +40,6 @@
|
|||||||
<div class="form-row" id="file_upload">
|
<div class="form-row" id="file_upload">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label>Upload file</label>
|
<label>Upload file</label>
|
||||||
<!-- [ <a href="#" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ] -->
|
|
||||||
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center justify-content-start">
|
<div class="d-flex align-items-center justify-content-start">
|
||||||
@ -39,7 +57,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -121,6 +139,34 @@
|
|||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
</div><!-- /.modal -->
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
|
<!-- Center modal content for upload file-->
|
||||||
|
<div class="modal fade" id="claim-file-upload-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="myCenterModalLabel">Claim Dump Upload</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form class="parsley-examples" id="claim-upload-form" enctype="multipart/form-data">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-row" id="file_upload">
|
||||||
|
<div class="form-group col-md-9">
|
||||||
|
<label>Upload file</label>
|
||||||
|
<!-- [ <a href="#" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ] -->
|
||||||
|
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-3" style="margin-top: 18px;">
|
||||||
|
<button id="claim_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -176,6 +222,7 @@
|
|||||||
|
|
||||||
// Reset form
|
// Reset form
|
||||||
$('#claim-upload-form')[0].reset();
|
$('#claim-upload-form')[0].reset();
|
||||||
|
$('.close').click();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -225,6 +272,38 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Datatable document ready
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
var ticketsTable = $('#tickets-table');
|
||||||
|
|
||||||
|
if (ticketsTable.length) {
|
||||||
|
ticketsTable.DataTable({
|
||||||
|
scrollX: true,
|
||||||
|
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||||
|
"<'row'<'col-sm-12'tr>>" +
|
||||||
|
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: 'Add',
|
||||||
|
className: 'buttons-html5 addbtnStyle',
|
||||||
|
action: function (e, dt, node, config) {
|
||||||
|
openDumpUploadModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
language: {
|
||||||
|
search: "_INPUT_",
|
||||||
|
searchPlaceholder: "Search..."
|
||||||
|
},
|
||||||
|
paging: true, // Enable pagination
|
||||||
|
pageLength: 15, // Set default number of rows per page (optional)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("Table not found.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function fetchFileError(file_id) {
|
function fetchFileError(file_id) {
|
||||||
|
|
||||||
var url = '<?php echo base_url('util/getClaimDumpFileErrorData/'); ?>';
|
var url = '<?php echo base_url('util/getClaimDumpFileErrorData/'); ?>';
|
||||||
@ -326,5 +405,11 @@
|
|||||||
let html = `<div class="spinner-border text-primary" role="status" style="position: relative; left: 200px;"></div>`
|
let html = `<div class="spinner-border text-primary" role="status" style="position: relative; left: 200px;"></div>`
|
||||||
$('#modal_body').append(html);
|
$('#modal_body').append(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function openDumpUploadModal() {
|
||||||
|
|
||||||
|
var myModal = new bootstrap.Modal(document.getElementById('claim-file-upload-modal'));
|
||||||
|
myModal.show();
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -129,7 +129,6 @@ option:disabled {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="full-width-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
|
<div id="full-width-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
|
||||||
aria-hidden="true">
|
aria-hidden="true">
|
||||||
<div class="modal-dialog modal-full-width">
|
<div class="modal-dialog modal-full-width">
|
||||||
@ -148,8 +147,6 @@ option:disabled {
|
|||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
</div><!-- /.modal -->
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Center modal content -->
|
<!-- Center modal content -->
|
||||||
<div class="modal fade" id="file-err-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
<div class="modal fade" id="file-err-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
@ -167,6 +164,11 @@ option:disabled {
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
var client_id_param = 0;
|
||||||
|
var client_branch_id_param = 0;
|
||||||
|
var client_policy_param = 0;
|
||||||
|
|
||||||
$('#file_upload').hide();
|
$('#file_upload').hide();
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -181,15 +183,6 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Declare a global variable to store API response data
|
|
||||||
var clientPolicies = [];
|
|
||||||
var clientPoliciesWithBranch = {
|
|
||||||
policies: []
|
|
||||||
};
|
|
||||||
var client_id_param = 0;
|
|
||||||
var client_branch_id_param = 0;
|
|
||||||
var client_policy_param = 0;
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
// console.log("document loaded");
|
// console.log("document loaded");
|
||||||
@ -330,8 +323,6 @@ $(document).ready(function() {
|
|||||||
$(window).on("load", function() {
|
$(window).on("load", function() {
|
||||||
|
|
||||||
console.log("window loaded");
|
console.log("window loaded");
|
||||||
fetchClientPolicies();
|
|
||||||
|
|
||||||
// Get the current page URL
|
// Get the current page URL
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
|
|
||||||
@ -368,87 +359,88 @@ $(window).on("load", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function 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);
|
// $('#loader').show();
|
||||||
// console.log(response.dataStatus);
|
// var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
|
||||||
// console.log(response.data);
|
// // console.log('fetchClientPolicies');
|
||||||
|
// // console.log(apiURL);
|
||||||
|
// $.ajax({
|
||||||
|
// url: apiURL,
|
||||||
|
// method: 'GET',
|
||||||
|
// headers: {
|
||||||
|
// "Content-Type": "application/json",
|
||||||
|
// "X-Requested-With": "XMLHttpRequest"
|
||||||
|
// },
|
||||||
|
// success: function(response) {
|
||||||
|
|
||||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
// console.log(response);
|
||||||
try {
|
// // console.log(response.dataStatus);
|
||||||
clientPolicies = (response.data)
|
// // console.log(response.data);
|
||||||
// console.log(clientPolicies);
|
|
||||||
|
|
||||||
response.data.forEach(policy => {
|
// if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||||
// console.log('policies', policy.policies);
|
// try {
|
||||||
policy.policies.forEach(p => {
|
// clientPolicies = (response.data)
|
||||||
clientPoliciesWithBranch.policies.push(p);
|
// // console.log(clientPolicies);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log(clientPoliciesWithBranch);
|
// response.data.forEach(policy => {
|
||||||
|
// // console.log('policies', policy.policies);
|
||||||
|
// policy.policies.forEach(p => {
|
||||||
|
// clientPoliciesWithBranch.policies.push(p);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
appendClients(clientPolicies);
|
// // console.log(clientPoliciesWithBranch);
|
||||||
|
|
||||||
|
// appendClients(clientPolicies);
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function() {
|
// setTimeout(function() {
|
||||||
if (client_id_param != null ) {
|
// if (client_id_param != null ) {
|
||||||
var foundPolicies = clientPolicies.find(function(item) {
|
// var foundPolicies = clientPolicies.find(function(item) {
|
||||||
// console.log(typeof item.id)
|
// // console.log(typeof item.id)
|
||||||
return item.id == client_id_param;
|
// return item.id == client_id_param;
|
||||||
});
|
// });
|
||||||
appendBranch(foundPolicies.branchs);
|
// appendBranch(foundPolicies.branchs);
|
||||||
}
|
// }
|
||||||
}, 500);
|
// }, 500);
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function() {
|
// setTimeout(function() {
|
||||||
if (client_branch_id_param != null ) {
|
// if (client_branch_id_param != null ) {
|
||||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
// var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||||
// console.log('item', item);
|
// // console.log('item', item);
|
||||||
return item.branch_id === client_branch_id_param;
|
// return item.branch_id === client_branch_id_param;
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
if (foundPolicies) {
|
// if (foundPolicies) {
|
||||||
// console.log('foundPolicies', foundPolicies);
|
// // console.log('foundPolicies', foundPolicies);
|
||||||
appendPolicies(foundPolicies);
|
// appendPolicies(foundPolicies);
|
||||||
} else {
|
// } else {
|
||||||
console.log('No policies found for the selected client');
|
// console.log('No policies found for the selected client');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, 500);
|
// }, 500);
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('Error parsing API response data:', error);
|
// console.error('Error parsing API response data:', error);
|
||||||
}
|
// }
|
||||||
} else if (response.code === 404 && response.dataStatus === false) {
|
// } else if (response.code === 404 && response.dataStatus === false) {
|
||||||
console.error('no data found', response);
|
// console.error('no data found', response);
|
||||||
} else {
|
// } else {
|
||||||
console.error('Something went wrong!');
|
// console.error('Something went wrong!');
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
error: function(xhr, status, error) {
|
// error: function(xhr, status, error) {
|
||||||
console.error('Error fetching data from API:', error);
|
// console.error('Error fetching data from API:', error);
|
||||||
console.error(xhr.responseText);
|
// console.error(xhr.responseText);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
$('#loader').hide();
|
// $('#loader').hide();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
function fetchFileError(file_id) {
|
function fetchFileError(file_id) {
|
||||||
@ -593,7 +585,6 @@ function fetchFileError(file_id) {
|
|||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function appendClients(data) {
|
function appendClients(data) {
|
||||||
|
|
||||||
// console.log('client_id_param', client_id_param)
|
// console.log('client_id_param', client_id_param)
|
||||||
@ -610,7 +601,6 @@ function appendClients(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function appendBranch(data) {
|
function appendBranch(data) {
|
||||||
|
|
||||||
$('#branch_id').empty();
|
$('#branch_id').empty();
|
||||||
@ -630,7 +620,6 @@ function appendBranch(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function appendPolicies(data) {
|
function appendPolicies(data) {
|
||||||
|
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
@ -645,14 +634,11 @@ function appendPolicies(data) {
|
|||||||
|
|
||||||
$.each(data, function(index, item) {
|
$.each(data, function(index, item) {
|
||||||
|
|
||||||
// console.log(item)
|
|
||||||
|
|
||||||
var option = $('<option>', {
|
var option = $('<option>', {
|
||||||
value: item.client_policy_id,
|
value: item.id,
|
||||||
// text:`${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
|
|
||||||
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
|
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
|
||||||
});
|
});
|
||||||
if (client_policy_param == item.client_policy_id) {
|
if (client_policy_param == item.id) {
|
||||||
option.attr('selected', true);
|
option.attr('selected', true);
|
||||||
}
|
}
|
||||||
$('#policy_id').append(option);
|
$('#policy_id').append(option);
|
||||||
@ -664,51 +650,25 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('#client_id').on('change', function() {
|
$('#client_id').on('change', function() {
|
||||||
|
|
||||||
$('#policy_id').empty();
|
let client_id = $(this).val();
|
||||||
|
console.log('client_id', client_id);
|
||||||
|
|
||||||
$('#policy_id').append($('<option>', {
|
if(branch_list != '') {
|
||||||
value: '',
|
// console.log(branch_list[client_id]);
|
||||||
text: 'Select'
|
let data = branch_list[client_id];
|
||||||
}));
|
appendBranch(data);
|
||||||
|
}
|
||||||
var selectedClient = $(this).val();
|
|
||||||
|
|
||||||
// console.log('selectedClient', selectedClient);
|
|
||||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
|
||||||
|
|
||||||
// Check if the selected option exists in apiData
|
|
||||||
var foundPolicies = clientPolicies.find(function(item) {
|
|
||||||
return item.id === selectedClient;
|
|
||||||
});
|
|
||||||
console.log('foundPolicies.branchs', foundPolicies.branchs);
|
|
||||||
appendBranch(foundPolicies.branchs);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
$('#branch_id').on('change', function() {
|
$('#branch_id').on('change', function() {
|
||||||
var selectedClient = $(this).val();
|
|
||||||
|
|
||||||
// console.log('selectedBranch', selectedClient);
|
let branch_id = $(this).val();
|
||||||
// console.log('clientPolicies', clientPoliciesWithBranch);
|
console.log("branch_id", branch_id);
|
||||||
|
|
||||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
if(policy_list != '' && branch_id != '') {
|
||||||
// console.log('item', item);
|
let data = policy_list[branch_id];
|
||||||
return item.branch_id === selectedClient;
|
appendPolicies(data);
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
|
|
||||||
|
|
||||||
appendPolicies(foundPolicies);
|
|
||||||
toastr.warning('No policies found for the selected client branch.');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// console.log('foundPolicies', foundPolicies);
|
|
||||||
appendPolicies(foundPolicies);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,9 @@
|
|||||||
<?php
|
<?php
|
||||||
if (isset($events) && count($events)) {
|
if (isset($events) && count($events)) {
|
||||||
foreach ($events as $key => $action) {
|
foreach ($events as $key => $action) {
|
||||||
echo "<option value='$key'" . ($key == "si_enhancement" ? " class='si-enhancement-option'" : "") . ">$action</option>";
|
if($key != "inception"){
|
||||||
|
echo "<option value='$key'" . ($key == "si_enhancement" ? " class='si-enhancement-option'" : "") . ">$action</option>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -143,19 +145,35 @@
|
|||||||
<!-- end row -->
|
<!-- end row -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Center modal content for reupload file-->
|
||||||
|
<div class="modal fade" id="hr-file-upload-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="myCenterModalLabel">Endorsement Upload</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form class="parsley-examples" id="hrUploadForm" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" id="hr_file_client_id" name="client_id">
|
||||||
|
<input type="hidden" id="hr_file_policy_id" name="policy_id">
|
||||||
|
<input type="hidden" id="hr_file_branch_id" name="branch_id">
|
||||||
|
<input type="hidden" id="hr_file_hr_file_id" name="hr_file_id">
|
||||||
|
<input type="hidden" id="hr_file_upload_actions" name="upload-action-type">
|
||||||
|
<input type="file" id="fileInput" name="emplist" required
|
||||||
|
accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
|
||||||
|
<button type="submit" class="btn btn-primary">Upload</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
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 = '';
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
//initialize the get client, branch, and policy
|
|
||||||
getClientAndBranchAndPolicy();
|
|
||||||
|
|
||||||
//client change to get the Client Branch
|
//client change to get the Client Branch
|
||||||
$('#client2').change(function(){
|
$('#client2').change(function(){
|
||||||
let client_id = $(this).val();
|
let client_id = $(this).val();
|
||||||
@ -217,18 +235,18 @@
|
|||||||
<td>${file.short_name ?? ""}</td>
|
<td>${file.short_name ?? ""}</td>
|
||||||
<td>${file.branch_name ?? ""}</td>
|
<td>${file.branch_name ?? ""}</td>
|
||||||
<td>${file.policy_no ?? ""}</td>
|
<td>${file.policy_no ?? ""}</td>
|
||||||
<td>${file.file_action ?? ""}</td>
|
<td>${formatTextToCamelCase(file.file_action) ?? ""}</td>
|
||||||
<td>${file.created_at} by <strong>${file.first_name ?? ""}</strong></td>
|
<td>${file.created_at} by <strong>${file.first_name ?? ""}</strong></td>
|
||||||
<td>${file.status}</td>
|
<td>${file.status}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
|
|
||||||
<div class="btn-group dropdown">
|
<div class="btn-group dropdown">
|
||||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm"
|
<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>
|
data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<a href="${baseurl}/hrFileDownload?id=${file.id}" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
<a href="${baseurl}/hrFileDownload?id=${file.id}" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||||
|
<a class="dropdown-item" onclick="uploadEndorsementFile(${file.client_id}, ${file.client_branch_id}, ${file.policy_id}, ${file.id}, '${file.file_action}')" style="color: #000;" aria-hidden="true"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Initiate Endorsement</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -252,36 +270,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//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;
|
|
||||||
vehicle_list = res.vehicle_data;
|
|
||||||
unit_list = res.unit_data;
|
|
||||||
appendClients3(res.client_data);
|
|
||||||
}else{
|
|
||||||
console.log('No data found');
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.error(xhr.responseText);
|
|
||||||
console.error(status, error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------ Append Functions are Below ----------------------------------------------------------------------------------
|
// ------------ Append Functions are Below ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
function appendClients3(data)
|
function appendClients3(data)
|
||||||
@ -332,10 +320,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function appendPolicy3(data)
|
function appendPolicy3(data)
|
||||||
{
|
{
|
||||||
console.log('policy2', data);
|
|
||||||
console.log('policy2', $('#policy2'));
|
|
||||||
|
|
||||||
$('#policy2').empty();
|
$('#policy2').empty();
|
||||||
$('#policy2').append($('<option>', {
|
$('#policy2').append($('<option>', {
|
||||||
value: '',
|
value: '',
|
||||||
@ -344,7 +329,7 @@
|
|||||||
|
|
||||||
$.each(data, function(index, item) {
|
$.each(data, function(index, item) {
|
||||||
var option = $('<option>', {
|
var option = $('<option>', {
|
||||||
value: item.policy_id,
|
value: item.id,
|
||||||
text: item.policy_type + '-' + item.policy_no,
|
text: item.policy_type + '-' + item.policy_no,
|
||||||
});
|
});
|
||||||
$('#policy2').append(option);
|
$('#policy2').append(option);
|
||||||
@ -353,7 +338,7 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// for datatable
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#hr_tickets_table').DataTable({
|
$('#hr_tickets_table').DataTable({
|
||||||
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
|
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
|
||||||
@ -382,4 +367,85 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//for initialize the file upload for the files table
|
||||||
|
function uploadEndorsementFile(client_id, branch_id, policy_id, file_id, event){
|
||||||
|
|
||||||
|
console.log(client_id, branch_id, policy_id, file_id, event);
|
||||||
|
|
||||||
|
$('#hr_file_client_id').val(client_id);
|
||||||
|
$('#hr_file_branch_id').val(branch_id);
|
||||||
|
$('#hr_file_policy_id').val(policy_id);
|
||||||
|
$('#hr_file_upload_actions').val(event);
|
||||||
|
$('#hr_file_hr_file_id').val(file_id);
|
||||||
|
|
||||||
|
var myModal = new bootstrap.Modal(document.getElementById('hr-file-upload-modal'));
|
||||||
|
myModal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
//hr file upload reupload to the files table
|
||||||
|
$('#hrUploadForm').submit(function(e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var isValid = $('#hrUploadForm').parsley().validate();
|
||||||
|
if (!isValid) {
|
||||||
|
console.log('Form is Empty', 'Warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create FormData object
|
||||||
|
var formData = new FormData($(this)[0]);
|
||||||
|
for (var pair of formData.entries()) {
|
||||||
|
console.log(pair[0] + ', ' + pair[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return false;
|
||||||
|
$.ajax({
|
||||||
|
url: `<?= base_url('employee/upload') ?>`,
|
||||||
|
type: "POST",
|
||||||
|
data: formData,
|
||||||
|
processData: false, // Prevent jQuery from automatically processing the data
|
||||||
|
contentType: false, // Let jQuery handle the content type
|
||||||
|
headers: {
|
||||||
|
// "Content-Type":"multipart/form-data",
|
||||||
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
$('#hrUploadForm')[0].reset();
|
||||||
|
|
||||||
|
if (response.code === 200 && response.dataStatus === true && response
|
||||||
|
.data !== "") {
|
||||||
|
toastr.success(
|
||||||
|
'File upload successs, Data validation is in-progress',
|
||||||
|
'success');
|
||||||
|
$('.close').click()
|
||||||
|
window.location.reload(true);
|
||||||
|
} else if (response.code === 404 && response.dataStatus === false) {
|
||||||
|
console.error('no data found', response);
|
||||||
|
// alert(response.message);
|
||||||
|
toastr.error(response.message, 'Failed');
|
||||||
|
window.location.reload(true);
|
||||||
|
} else {
|
||||||
|
console.error('Something went wrong!');
|
||||||
|
// alert('Something went wrong! Try later');
|
||||||
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.close').click();
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Request failed, handle error
|
||||||
|
console.error("Request failed:", status, error);
|
||||||
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
|
$('#hrUploadForm')[0].reset();
|
||||||
|
$('.close').click();
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -9,6 +9,51 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
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 = '';
|
||||||
|
|
||||||
|
$(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;
|
||||||
|
|
||||||
|
appendClients(res.client_data);
|
||||||
|
appendClients2(res.client_data);
|
||||||
|
appendClients3(res.client_data);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
console.log('No data found');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="row" id="client_add" style="position: relative; bottom: 25px;">
|
<div class="row" id="client_add" style="position: relative; bottom: 25px;">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -27,7 +72,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="#HR-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="hr_tab">
|
<a href="#HR-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="hr_tab">
|
||||||
<span class="mr-1"><i class="fa fa-file"></i></span>
|
<span class="mr-1"><i class="mdi mdi-file"></i></span>
|
||||||
<span class="d-none d-sm-inline-block">HR Uploaded Files</span>
|
<span class="d-none d-sm-inline-block">HR Uploaded Files</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -41,9 +86,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
@ -59,6 +101,10 @@
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function formatTextToCamelCase(str) {
|
||||||
|
return str
|
||||||
|
.replace(/_/g, ' ') // replace underscores with spaces
|
||||||
|
.toLowerCase() // convert everything to lowercase
|
||||||
|
.replace(/\b\w/g, char => char.toUpperCase()); // capitalize each word
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -131,6 +131,11 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
var client_id_param2 = 0;
|
||||||
|
var client_branch_id_param2 = 0;
|
||||||
|
var client_policy_param2 = 0;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Initialize select2
|
// Initialize select2
|
||||||
$("#client").select2();
|
$("#client").select2();
|
||||||
@ -139,16 +144,6 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Declare a global variable to store API response data
|
|
||||||
var clientPolicies = [];
|
|
||||||
var clientPoliciesWithBranch2 = {
|
|
||||||
policies: []
|
|
||||||
};
|
|
||||||
|
|
||||||
var client_id_param2 = 0;
|
|
||||||
var client_branch_id_param2 = 0;
|
|
||||||
var client_policy_param2 = 0;
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
<?php if (session()->has('error')) : ?>
|
<?php if (session()->has('error')) : ?>
|
||||||
@ -231,9 +226,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(window).on("load", function() {
|
$(window).on("load", function() {
|
||||||
|
|
||||||
fetchClientPolicies2();
|
|
||||||
|
|
||||||
// Get the current page URL
|
// Get the current page URL
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
|
|
||||||
@ -284,82 +277,82 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchClientPolicies2() {
|
// function fetchClientPolicies2() {
|
||||||
|
|
||||||
$('#loader').show();
|
// $('#loader').show();
|
||||||
|
|
||||||
var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
// var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
||||||
$.ajax({
|
// $.ajax({
|
||||||
url: apiURL,
|
// url: apiURL,
|
||||||
method: 'GET',
|
// method: 'GET',
|
||||||
headers: {
|
// headers: {
|
||||||
"Content-Type": "application/json",
|
// "Content-Type": "application/json",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
// "X-Requested-With": "XMLHttpRequest"
|
||||||
},
|
// },
|
||||||
success: function(response) {
|
// success: function(response) {
|
||||||
// console.log(response.code);
|
// // console.log(response.code);
|
||||||
// console.log(response.dataStatus);
|
// // console.log(response.dataStatus);
|
||||||
// console.log(response.data);
|
// // console.log(response.data);
|
||||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
// if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||||
try {
|
// try {
|
||||||
clientPolicies = (response.data);
|
// clientPolicies = (response.data);
|
||||||
// console.log(clientPolicies);
|
// // console.log(clientPolicies);
|
||||||
|
|
||||||
|
|
||||||
response.data.forEach(policy => {
|
// response.data.forEach(policy => {
|
||||||
// console.log('policies', policy.policies);
|
// // console.log('policies', policy.policies);
|
||||||
policy.policies.forEach(p => {
|
// policy.policies.forEach(p => {
|
||||||
clientPoliciesWithBranch2.policies.push(p);
|
// clientPoliciesWithBranch2.policies.push(p);
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
appendClients2(clientPolicies);
|
// appendClients2(clientPolicies);
|
||||||
|
|
||||||
setTimeout(function() {
|
// setTimeout(function() {
|
||||||
if (client_branch_id_param2 != null) {
|
// if (client_branch_id_param2 != null) {
|
||||||
var foundPolicies = clientPolicies.find(function(item) {
|
// var foundPolicies = clientPolicies.find(function(item) {
|
||||||
// console.log(typeof item.id)
|
// // console.log(typeof item.id)
|
||||||
return item.id == client_id_param2;
|
// return item.id == client_id_param2;
|
||||||
});
|
// });
|
||||||
appendBranch2(foundPolicies.branchs);
|
// appendBranch2(foundPolicies.branchs);
|
||||||
}
|
// }
|
||||||
}, 500);
|
// }, 500);
|
||||||
|
|
||||||
setTimeout(function() {
|
// setTimeout(function() {
|
||||||
if (client_id_param2 != null) {
|
// if (client_id_param2 != null) {
|
||||||
|
|
||||||
var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
|
// var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
|
||||||
// console.log('item', item);
|
// // console.log('item', item);
|
||||||
return item.branch_id === client_branch_id_param2;
|
// return item.branch_id === client_branch_id_param2;
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
if (foundPolicies) {
|
// if (foundPolicies) {
|
||||||
// console.log('foundPolicies', foundPolicies);
|
// // console.log('foundPolicies', foundPolicies);
|
||||||
appendPolicies2(foundPolicies);
|
// appendPolicies2(foundPolicies);
|
||||||
} else {
|
// } else {
|
||||||
console.log('No policies found for the selected client');
|
// console.log('No policies found for the selected client');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, 500);
|
// }, 500);
|
||||||
|
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('Error parsing API response data:', error);
|
// console.error('Error parsing API response data:', error);
|
||||||
}
|
// }
|
||||||
} else if (response.code === 404 && response.dataStatus === false) {
|
// } else if (response.code === 404 && response.dataStatus === false) {
|
||||||
console.error('no data found', response);
|
// console.error('no data found', response);
|
||||||
} else {
|
// } else {
|
||||||
// console.error('Something went wrong!');
|
// // console.error('Something went wrong!');
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
error: function(xhr, status, error) {
|
// error: function(xhr, status, error) {
|
||||||
console.error('Error fetching data from API:', error);
|
// console.error('Error fetching data from API:', error);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
$('#loader').hide();
|
// $('#loader').hide();
|
||||||
}
|
// }
|
||||||
|
|
||||||
function appendClients2(data) {
|
function appendClients2(data) {
|
||||||
|
|
||||||
@ -408,11 +401,10 @@
|
|||||||
|
|
||||||
$.each(data, function(index, item) {
|
$.each(data, function(index, item) {
|
||||||
var option = $('<option>', {
|
var option = $('<option>', {
|
||||||
value: item.client_policy_id,
|
value: item.id,
|
||||||
// text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
|
|
||||||
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
|
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
|
||||||
});
|
});
|
||||||
if (client_policy_param2 == item.client_policy_id) {
|
if (client_policy_param2 == item.id) {
|
||||||
option.attr('selected', true);
|
option.attr('selected', true);
|
||||||
}
|
}
|
||||||
$('#policy').append(option);
|
$('#policy').append(option);
|
||||||
@ -423,50 +415,25 @@
|
|||||||
|
|
||||||
$('#client').on('change', function() {
|
$('#client').on('change', function() {
|
||||||
|
|
||||||
$('#policy').empty();
|
let client_id = $(this).val();
|
||||||
$('#policy').append($('<option>', {
|
console.log('client_id', client_id);
|
||||||
value: '0',
|
|
||||||
text: 'Select'
|
|
||||||
}));
|
|
||||||
|
|
||||||
var selectedClient = $(this).val();
|
if(branch_list != '') {
|
||||||
// console.log(selectedClient);
|
// console.log(branch_list[client_id]);
|
||||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
let data = branch_list[client_id];
|
||||||
|
appendBranch2(data);
|
||||||
// Check if the selected option exists in apiData
|
}
|
||||||
var foundPolicies = clientPolicies.find(function(item) {
|
|
||||||
return item.id === selectedClient;
|
|
||||||
});
|
|
||||||
// console.log(foundPolicies.branchs);
|
|
||||||
appendBranch2(foundPolicies.branchs);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
$('#client_branch_id').on('change', function() {
|
$('#client_branch_id').on('change', function() {
|
||||||
|
|
||||||
var selectedClient = $(this).val();
|
let branch_id = $(this).val();
|
||||||
|
console.log("branch_id", branch_id);
|
||||||
|
|
||||||
// console.log('selectedBranch', selectedClient);
|
if(policy_list != '' && branch_id != '') {
|
||||||
// console.log('clientPolicies', clientPoliciesWithBranch2);
|
let data = policy_list[branch_id];
|
||||||
|
appendPolicies2(data);
|
||||||
var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
|
|
||||||
return item.branch_id === selectedClient;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
|
|
||||||
|
|
||||||
appendPolicies2(foundPolicies);
|
|
||||||
toastr.warning('No policies found for the selected client branch.');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// console.log('foundPolicies', foundPolicies);
|
|
||||||
appendPolicies2(foundPolicies);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -791,7 +791,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPendingAction()
|
// fetchPendingAction()
|
||||||
|
|
||||||
$('#messages-list-2').on('click', 'li', function(event) {
|
$('#messages-list-2').on('click', 'li', function(event) {
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user