FEAT_ENDORSEMENT_FILE_UPLOAD_IMPLEMENTATION

This commit is contained in:
VENKATESHWARAN 2026-02-03 14:20:15 +05:30
parent 800faddc31
commit 3e0311b27b
4 changed files with 575 additions and 404 deletions

View File

@ -2273,6 +2273,9 @@
// print_r($data);
// die;
$file_data = $this->request->getFiles() ?? null;
$data['file_data'] = $file_data ?? null;
if (!isset($data['policy_with_corr'])) {
$data['policy_with_corr'] = 0;
} elseif ($data['policy_with_corr']) {
@ -2416,6 +2419,11 @@
$this->handleCompletedStatus($data, $insert);
$this->insertOrUpdateCoShareDetails($data, $insert);
// policy file upload
if(isset($data['doc_name']) && isset($data['file_data']) && !empty($data['doc_name']) && !empty($data['file_data'])){
$this->uploadFile($data['doc_name'], $data['file_data'], $insert);
}
return $this->respond(['status' => true, 'message' => 'Endorsement transaction created successfully'], 200);
}
@ -2688,6 +2696,20 @@
// dd(db_connect()->getLastQuery() ,$pt_bp_amt);
$data['base_cd_amount'] = $pt_bp_amt['amount'] ?? null;
$ptFileQuery = $this->PTFileModel
->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
->where('pt_files.pt_id', $id)
->where('pt_files.is_active', 1);
if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
$ptFileQuery->where('pt_files.created_by', get_session_userid());
}
}
$data['pt_files'] = $ptFileQuery->findAll();
if ($data) {
return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200);
} else {

View File

@ -151,7 +151,8 @@
</style>
<div class="row" id="endorsement_form" style="display: none;">
<div class="tab-pane fade active show" id="form">
<div class="row" id="endorsement_form">
<div class="col-12">
<div class="card">
<div class="card-body">
@ -386,6 +387,27 @@
</div>
</div>
<!-- Policy Docs Row -->
<div class="row" id="policy_docs" style="display: none;">
<div class="col-md-12">
<div id="accordion_23" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Policy Docs</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwentyTwo"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</label>
<div class="card mb-1">
<div id="collapseTwentyTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_23">
<div class="card-body" id="policy_docs_div" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Premium Details -->
<div class="row">
<div class="col-md-12">
@ -576,6 +598,7 @@
</div>
</div>
</div>
</div>
<!-- end form row -->
<script>
@ -1017,6 +1040,8 @@
$('#cop_yes').val(0);
}
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
$('#policy_tranction_primarykey').val(res.data.id);
$('#client_type').val(res.data.client_type).trigger('change');
$('#client_id').val(res.data.client_id).change();
@ -1067,12 +1092,16 @@
$('#cd_ac_no').val(res.data.cd_ac_no);
$('#ct_type').val(res.data.ct_type);
$('#hide_file_upload').show()
if (res.data.policy_with_corr == 1) {
$('#policy_with_corr').prop('checked', true);
} else {
$('#policy_with_corr').prop('checked', false);
}
appendFileTableBody(res.data.pt_files);
// if (res.data.is_cd_reduce_from_bds == 1) {
// $('#is_cd_reduce_from_bds').prop('checked', true).prop('checked', false);
// } else {

View File

@ -363,10 +363,9 @@ table.dataTable thead th {
</div><!-- end col -->
</div>
<!-- end table row -->
<?php include('pt_endorsement_form_file_upload_tab.php'); ?>
<?php include('policy_transaction_endorsement_form.php'); ?>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("tickets-table");
@ -448,6 +447,7 @@ table.dataTable thead th {
});
});
</script>
<script>
var client_list = '';
var branch_list = '';
@ -461,6 +461,7 @@ table.dataTable thead th {
$(document).ready(function() {
getClientAndBranchAndPolicy()
addHTMLInput();
<?php if (session()->has('create_failed')) : ?>
toastr.error('<?= session()->getFlashdata('create_failed') ?>', 'Failed');
@ -506,6 +507,8 @@ table.dataTable thead th {
className: 'btn app-btn-primary mr-2',
action: function (e, dt, node, config) {
hide_list_show_add();
addHTMLInput(null, 'policy_docs_div');
$('#policy_docs').show()
},
attr: { id: 'btnAdd' }
},
@ -614,15 +617,16 @@ table.dataTable thead th {
$('#endorsement_form_id')[0].reset();
$('#client_id').val('').change();
$('#client_policy_id').val('').change();
$('#endorsement_form').show();
$('#endorsement_list').hide();
$('#endorsement_filter').hide();
$('#invoice_no_div').hide();
$('#invoice_no').attr('required', false)
$('#pt_onboarding').show();
$('#endorsement_list').hide();
$('#endorsement_filter').hide();
}
function show_list_hide_add() {
$('#endorsement_form').hide()
$('#pt_onboarding').hide()
$('#endorsement_list').show()
$('#endorsement_filter').show()
@ -836,7 +840,6 @@ table.dataTable thead th {
})
</script>
<script>
$(document).ready(function() {
getURLParams()
@ -1034,4 +1037,87 @@ table.dataTable thead th {
});
}
function addHTMLInput(data = null, container_id = 'dynamic-form-container')
{
console.log('container_id', container_id);
const container = document.getElementById(container_id);
let required = ''
let required_star = ''
if(container_id == 'dynamic-form-container'){
required = 'required';
required_star = '*';
}
console.log('container', container);
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" ${required}>
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
<input type="file" class="form-control" id="file_name" name="file[]" ${required} accept=".pdf,.jpg,.jpeg,.png">
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this, '${container_id}')">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(null, '${container_id}')">+</a>
</div>
`;
container.appendChild(newRow);
if (data !== null && data.db_column_name !== undefined) {
const selectElement = newRow.querySelector('.db-column-name-select');
selectElement.value = data.db_column_name;
}
}
function removeHTMLInput(element, container_id)
{
const container = document.getElementById(container_id);
const rows = container.querySelectorAll('.dynamic-form-row');
if (rows.length > 1) {
const row = element.closest('.dynamic-form-row');
row.remove();
}
}
function appendFileTableBody(data)
{
console.log(data);
$('#table_bd').empty();
$.each(data, function(index, item) {
var row = $('<tr>');
row.append($('<td>').text(index+1));
row.append($('<td>').text(item.doc_name));
row.append($('<td>').text(item.file_name));
// var url = "<?= base_url('/downloadGdriveFile'); ?>" +
// "?client_id=" + item.client_id +
// "&file_type=policy" +
// "&file_name=" + item.file_name +
// "&client_policy_id=" + item.client_policy_id;
var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
var link = $('<a>')
.attr('href', url)
.attr('target', '_blank') // Open in a new tab
.attr('style', 'font-size:18px;')
.attr('data-id', item.id)
.addClass('mdi mdi-download')
// Append the <a> tag inside the <td>
row.append($('<td>').append(link));
$('#table_bd').append(row);
});
}
</script>

View File

@ -0,0 +1,34 @@
<div class="row" id="pt_onboarding" style="position: relative; bottom: 25px; display:none;">
<div class="col-xl-12">
<div class="card-body">
<div class="tab-wrapper position-relative">
<ul class="nav nav-pills navtab-bg" id="myTab">
<li class="nav-item d-flex justify-content-center align-items-center">
<button class="scroll-btn left-btn" type="button">&#9664;</button>
</li>
<li class="nav-item">
<a href="#form" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2 active-tab active" id="general_tab">
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
<span class="d-none d-sm-inline-block">Policy</span>
</a>
</li>
<li class="nav-item" id="hide_file_upload" style="display: none;">
<a href="#fileupload" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
<span class="mr-1"><i class="mdi mdi-file"></i></span>
<span class="d-none d-sm-inline-block">Policy Docs</span>
</a>
</li>
<li class="nav-item d-flex justify-content-center align-items-center">
<!-- Right Arrow -->
<button class="scroll-btn right-btn" type="button">&#9654;</button>
</li>
</ul>
</div>
<div class="tab-content">
<?php include('policy_transaction_endorsement_form.php'); ?>
<?php include('drive_file_upload.php'); ?>
</div>
</div>
</div>
</div>