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-----------------------------------------------------------------------------
|
||||
|
||||
$role_id = get_role_id();
|
||||
$user_id = get_session_userid();
|
||||
|
||||
|
||||
if ($role_id == 2 || $role_id == 3) {
|
||||
|
||||
$clients = $this->clientModel
|
||||
->select("*, DATE_FORMAT(dob, '%d-%m-%Y') as dob")
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
->select("clients.*, DATE_FORMAT(clients.dob, '%d-%m-%Y') as dob")
|
||||
->join('client_rm', 'client_rm.client_id = clients.id')
|
||||
->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');
|
||||
|
||||
@ -5064,6 +5079,10 @@ class ClientController extends AdminController
|
||||
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '1681']);
|
||||
// dd( $res);
|
||||
|
||||
// $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
|
||||
// $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1056']);
|
||||
// dd($res);
|
||||
|
||||
// ---------- POLICY TRANSACTION CONTROLLER --------------------------------------------------------------------------------
|
||||
|
||||
$policyTransactionController = new PolicyTransactionController();
|
||||
@ -5181,6 +5200,7 @@ class ClientController extends AdminController
|
||||
// $data['data'] = $BDSReportController->getBAPClientData();
|
||||
// return $this->loadLayout('irda_bap_client_report_list', $data);
|
||||
|
||||
|
||||
// $data['data'] = $BDSReportController->getClientData(1);
|
||||
// return $this->loadLayout('irda_client_report_list', $data);
|
||||
|
||||
|
||||
@ -270,10 +270,11 @@ class EmployeeController extends AdminController
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$policy_id = $this->request->getPost('policy_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');
|
||||
$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]);
|
||||
|
||||
//start validation process
|
||||
|
||||
@ -3960,11 +3960,46 @@ class EmployeeRestController extends AdminController
|
||||
$request = service('request');
|
||||
|
||||
// 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
|
||||
->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('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
|
||||
$filters = [
|
||||
|
||||
@ -997,10 +997,10 @@ class PolicyTransactionController extends BaseController
|
||||
$data['is_active'] = 0;
|
||||
$policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first();
|
||||
if($policy_transaction_data['policy_type_id'] > 7){
|
||||
|
||||
$this->policyTransactionModel->where('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->policyTransactionModel->where('client_policy_id', $policy_transaction_data['client_policy_id'])->set($data)->update();
|
||||
}else{
|
||||
$this->policyTransactionModel->where('id', $id)->set($data)->update();
|
||||
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
|
||||
|
||||
@ -20,7 +20,8 @@ class FileModel extends Model
|
||||
"policy_id",
|
||||
"client_branch_id",
|
||||
"uploaded_by",
|
||||
"updated_by"
|
||||
"updated_by",
|
||||
"hr_file_id",
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,29 @@
|
||||
<style>
|
||||
|
||||
.reload:hover {
|
||||
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>
|
||||
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="col-xl-12" style="margin-left: 14px;max-width: 98%;">
|
||||
<div id="accordion1" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
@ -21,7 +40,6 @@
|
||||
<div class="form-row" id="file_upload">
|
||||
<div class="form-group col-md-4">
|
||||
<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="d-flex align-items-center justify-content-start">
|
||||
@ -39,7 +57,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
@ -121,6 +139,34 @@
|
||||
</div><!-- /.modal-dialog -->
|
||||
</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>
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -176,6 +222,7 @@
|
||||
|
||||
// Reset form
|
||||
$('#claim-upload-form')[0].reset();
|
||||
$('.close').click();
|
||||
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) {
|
||||
|
||||
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>`
|
||||
$('#modal_body').append(html);
|
||||
});
|
||||
|
||||
function openDumpUploadModal() {
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('claim-file-upload-modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -129,7 +129,6 @@ option:disabled {
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="full-width-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-full-width">
|
||||
@ -148,8 +147,6 @@ option:disabled {
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="file-err-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
@ -167,6 +164,11 @@ option:disabled {
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
var client_id_param = 0;
|
||||
var client_branch_id_param = 0;
|
||||
var client_policy_param = 0;
|
||||
|
||||
$('#file_upload').hide();
|
||||
|
||||
$(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() {
|
||||
|
||||
// console.log("document loaded");
|
||||
@ -330,8 +323,6 @@ $(document).ready(function() {
|
||||
$(window).on("load", function() {
|
||||
|
||||
console.log("window loaded");
|
||||
fetchClientPolicies();
|
||||
|
||||
// Get the current page URL
|
||||
const url = window.location.href;
|
||||
|
||||
@ -368,87 +359,88 @@ $(window).on("load", function() {
|
||||
});
|
||||
|
||||
|
||||
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) {
|
||||
// function fetchClientPolicies() {
|
||||
|
||||
console.log(response);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
// $('#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) {
|
||||
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
clientPolicies = (response.data)
|
||||
// console.log(clientPolicies);
|
||||
// console.log(response);
|
||||
// // console.log(response.dataStatus);
|
||||
// // console.log(response.data);
|
||||
|
||||
response.data.forEach(policy => {
|
||||
// console.log('policies', policy.policies);
|
||||
policy.policies.forEach(p => {
|
||||
clientPoliciesWithBranch.policies.push(p);
|
||||
});
|
||||
});
|
||||
// if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
// try {
|
||||
// clientPolicies = (response.data)
|
||||
// // 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() {
|
||||
if (client_id_param != null ) {
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
// console.log(typeof item.id)
|
||||
return item.id == client_id_param;
|
||||
});
|
||||
appendBranch(foundPolicies.branchs);
|
||||
}
|
||||
}, 500);
|
||||
// setTimeout(function() {
|
||||
// if (client_id_param != null ) {
|
||||
// var foundPolicies = clientPolicies.find(function(item) {
|
||||
// // console.log(typeof item.id)
|
||||
// return item.id == client_id_param;
|
||||
// });
|
||||
// appendBranch(foundPolicies.branchs);
|
||||
// }
|
||||
// }, 500);
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_branch_id_param != null ) {
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === client_branch_id_param;
|
||||
});
|
||||
// setTimeout(function() {
|
||||
// if (client_branch_id_param != null ) {
|
||||
// var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// // console.log('item', item);
|
||||
// return item.branch_id === client_branch_id_param;
|
||||
// });
|
||||
|
||||
|
||||
if (foundPolicies) {
|
||||
// console.log('foundPolicies', foundPolicies);
|
||||
appendPolicies(foundPolicies);
|
||||
} else {
|
||||
console.log('No policies found for the selected client');
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
// if (foundPolicies) {
|
||||
// // console.log('foundPolicies', foundPolicies);
|
||||
// appendPolicies(foundPolicies);
|
||||
// } else {
|
||||
// console.log('No policies found for the selected client');
|
||||
// }
|
||||
// }
|
||||
// }, 500);
|
||||
|
||||
|
||||
} 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);
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
// } 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);
|
||||
// console.error(xhr.responseText);
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
// $('#loader').hide();
|
||||
// }
|
||||
|
||||
|
||||
function fetchFileError(file_id) {
|
||||
@ -593,7 +585,6 @@ function fetchFileError(file_id) {
|
||||
$('#loader').hide();
|
||||
}
|
||||
|
||||
|
||||
function appendClients(data) {
|
||||
|
||||
// console.log('client_id_param', client_id_param)
|
||||
@ -610,7 +601,6 @@ function appendClients(data) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function appendBranch(data) {
|
||||
|
||||
$('#branch_id').empty();
|
||||
@ -630,7 +620,6 @@ function appendBranch(data) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function appendPolicies(data) {
|
||||
|
||||
// console.log(data)
|
||||
@ -645,14 +634,11 @@ function appendPolicies(data) {
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
// console.log(item)
|
||||
|
||||
var option = $('<option>', {
|
||||
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 (client_policy_param == item.client_policy_id) {
|
||||
if (client_policy_param == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#policy_id').append(option);
|
||||
@ -664,51 +650,25 @@ $(document).ready(function() {
|
||||
|
||||
$('#client_id').on('change', function() {
|
||||
|
||||
$('#policy_id').empty();
|
||||
let client_id = $(this).val();
|
||||
console.log('client_id', client_id);
|
||||
|
||||
$('#policy_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
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);
|
||||
if(branch_list != '') {
|
||||
// console.log(branch_list[client_id]);
|
||||
let data = branch_list[client_id];
|
||||
appendBranch(data);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#branch_id').on('change', function() {
|
||||
var selectedClient = $(this).val();
|
||||
|
||||
// console.log('selectedBranch', selectedClient);
|
||||
// console.log('clientPolicies', clientPoliciesWithBranch);
|
||||
let branch_id = $(this).val();
|
||||
console.log("branch_id", branch_id);
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === selectedClient;
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
if(policy_list != '' && branch_id != '') {
|
||||
let data = policy_list[branch_id];
|
||||
appendPolicies(data);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -55,7 +55,9 @@
|
||||
<?php
|
||||
if (isset($events) && count($events)) {
|
||||
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 -->
|
||||
</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>
|
||||
|
||||
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(){
|
||||
|
||||
//initialize the get client, branch, and policy
|
||||
getClientAndBranchAndPolicy();
|
||||
|
||||
//client change to get the Client Branch
|
||||
$('#client2').change(function(){
|
||||
let client_id = $(this).val();
|
||||
@ -217,18 +235,18 @@
|
||||
<td>${file.short_name ?? ""}</td>
|
||||
<td>${file.branch_name ?? ""}</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.status}</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="${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>
|
||||
|
||||
@ -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 ----------------------------------------------------------------------------------
|
||||
|
||||
function appendClients3(data)
|
||||
@ -332,10 +320,7 @@
|
||||
}
|
||||
|
||||
function appendPolicy3(data)
|
||||
{
|
||||
console.log('policy2', data);
|
||||
console.log('policy2', $('#policy2'));
|
||||
|
||||
{
|
||||
$('#policy2').empty();
|
||||
$('#policy2').append($('<option>', {
|
||||
value: '',
|
||||
@ -344,7 +329,7 @@
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.policy_id,
|
||||
value: item.id,
|
||||
text: item.policy_type + '-' + item.policy_no,
|
||||
});
|
||||
$('#policy2').append(option);
|
||||
@ -353,7 +338,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// for datatable
|
||||
$(document).ready(function() {
|
||||
$('#hr_tickets_table').DataTable({
|
||||
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>
|
||||
@ -9,6 +9,51 @@
|
||||
}
|
||||
</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="col-12">
|
||||
<div class="card-body">
|
||||
@ -27,7 +72,7 @@
|
||||
</li>
|
||||
<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">
|
||||
<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>
|
||||
</a>
|
||||
</li>
|
||||
@ -41,9 +86,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(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>
|
||||
@ -131,6 +131,11 @@
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
var client_id_param2 = 0;
|
||||
var client_branch_id_param2 = 0;
|
||||
var client_policy_param2 = 0;
|
||||
|
||||
$(document).ready(function() {
|
||||
// Initialize 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() {
|
||||
|
||||
<?php if (session()->has('error')) : ?>
|
||||
@ -231,9 +226,7 @@
|
||||
});
|
||||
|
||||
$(window).on("load", function() {
|
||||
|
||||
fetchClientPolicies2();
|
||||
|
||||
|
||||
// Get the current page URL
|
||||
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';
|
||||
$.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);
|
||||
// console.log(clientPolicies);
|
||||
// var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
||||
// $.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);
|
||||
// // console.log(clientPolicies);
|
||||
|
||||
|
||||
response.data.forEach(policy => {
|
||||
// console.log('policies', policy.policies);
|
||||
policy.policies.forEach(p => {
|
||||
clientPoliciesWithBranch2.policies.push(p);
|
||||
});
|
||||
});
|
||||
// response.data.forEach(policy => {
|
||||
// // console.log('policies', policy.policies);
|
||||
// policy.policies.forEach(p => {
|
||||
// clientPoliciesWithBranch2.policies.push(p);
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
appendClients2(clientPolicies);
|
||||
// appendClients2(clientPolicies);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_branch_id_param2 != null) {
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
// console.log(typeof item.id)
|
||||
return item.id == client_id_param2;
|
||||
});
|
||||
appendBranch2(foundPolicies.branchs);
|
||||
}
|
||||
}, 500);
|
||||
// setTimeout(function() {
|
||||
// if (client_branch_id_param2 != null) {
|
||||
// var foundPolicies = clientPolicies.find(function(item) {
|
||||
// // console.log(typeof item.id)
|
||||
// return item.id == client_id_param2;
|
||||
// });
|
||||
// appendBranch2(foundPolicies.branchs);
|
||||
// }
|
||||
// }, 500);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_id_param2 != null) {
|
||||
// setTimeout(function() {
|
||||
// if (client_id_param2 != null) {
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === client_branch_id_param2;
|
||||
});
|
||||
// var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
|
||||
// // console.log('item', item);
|
||||
// return item.branch_id === client_branch_id_param2;
|
||||
// });
|
||||
|
||||
|
||||
if (foundPolicies) {
|
||||
// console.log('foundPolicies', foundPolicies);
|
||||
appendPolicies2(foundPolicies);
|
||||
} else {
|
||||
console.log('No policies found for the selected client');
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
// if (foundPolicies) {
|
||||
// // console.log('foundPolicies', foundPolicies);
|
||||
// appendPolicies2(foundPolicies);
|
||||
// } else {
|
||||
// console.log('No policies found for the selected client');
|
||||
// }
|
||||
// }
|
||||
// }, 500);
|
||||
|
||||
} 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 appendClients2(data) {
|
||||
|
||||
@ -408,11 +401,10 @@
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
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 (client_policy_param2 == item.client_policy_id) {
|
||||
if (client_policy_param2 == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#policy').append(option);
|
||||
@ -423,50 +415,25 @@
|
||||
|
||||
$('#client').on('change', function() {
|
||||
|
||||
$('#policy').empty();
|
||||
$('#policy').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
let client_id = $(this).val();
|
||||
console.log('client_id', client_id);
|
||||
|
||||
var selectedClient = $(this).val();
|
||||
// console.log(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);
|
||||
appendBranch2(foundPolicies.branchs);
|
||||
if(branch_list != '') {
|
||||
// console.log(branch_list[client_id]);
|
||||
let data = branch_list[client_id];
|
||||
appendBranch2(data);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(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);
|
||||
// console.log('clientPolicies', clientPoliciesWithBranch2);
|
||||
|
||||
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);
|
||||
if(policy_list != '' && branch_id != '') {
|
||||
let data = policy_list[branch_id];
|
||||
appendPolicies2(data);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -791,7 +791,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
fetchPendingAction()
|
||||
// fetchPendingAction()
|
||||
|
||||
$('#messages-list-2').on('click', 'li', function(event) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user