nhance/app/Views/kyc_docs.php
venba-Inspriron-3558 9682865454 FIX_UI support
2025-09-03 14:53:33 +05:30

427 lines
16 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="tab-pane fade" id="branch-tab">
<div class="row float-right" style="padding-bottom: 10px;position: relative;right: 13px;">
<button type="button" id="btnBranchAdd" class="btn btn-primary waves-effect waves-light btn-sm"><span class="mdi mdi-plus-box-outline" aria-hidden="true" style="padding: 5px 10px;"></span>Add KYC Docs</button>
</div>
<div class="table-responsive" id="branch_table" >
<table data-custom-table-css="table" class="table table-borderless table-nowrap mb-0" id="table-kyc-docs">
<thead class="">
<tr>
<th>File Name</th>
<th>Action</th>
</tr>
</thead>
<tbody id="kyc_docs_list">
</tbody>
</table>
</div>
<!-- <div class="row" id="add_branch">
<div class="col-12">
<div class="card-body">
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
<button type="button" id="btnBranchBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack"><span class="mdi mdi-format-list-bulleted" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
</div>
<hr>
<form role="form" class="parsley-examples" method="post" id="kyc_docs_form"
enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="kyc_Docs_PrimaryKey" />
<input type="hidden" name="kyc_type_id" id="kyc_type_id" value="<?= isset($kyc['id']) ? $kyc['id'] : '' ?>"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="file_name">KYC Docs File Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="file_name"
placeholder="Enter File Name" name="file_name" required>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack"
id="btnBack">Cancel</button>
</div>
</form>
</div>
</div>
</div> end col -->
</div>
<!-- end -->
<div class="modal fade" id="kycdocsModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header flex-column">
<div class="d-flex w-100 justify-content-between align-items-center">
<h4 class="modal-title mb-0" id="modalLabel">KYC Docs</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<!-- Modal Body -->
<div class="modal-body" style="overflow-y:auto; max-height:80vh;">
<form role="form" class="parsley-examples" method="post" id="kyc_docs_form" enctype="multipart/form-data">
<!-- CSRF + hidden inputs -->
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="kyc_Docs_PrimaryKey" />
<input type="hidden" name="kyc_type_id" id="kyc_type_id" value="<?= isset($kyc['id']) ? $kyc['id'] : '' ?>"/>
<!-- Form fields -->
<div class="form-row">
<div class="form-group col-md-12">
<label for="file_name">KYC Docs File Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="file_name" name="file_name" placeholder="Enter File Name" required>
</div>
</div>
<!-- Form Actions -->
<div class="form-group text-right mb-0">
<button type="button" class="btn app-btn-outline-secondary waves-effect btnBack" id="btnBack" data-dismiss="modal">
Cancel
</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">
Submit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
var kyc_Docs_PrimaryKey = $('#kyc_General_PrimaryKey').val();
var kyc_docs_form_action = '';
var myModal = new bootstrap.Modal(document.getElementById('kycdocsModal'));
myModal.hide();
// $('#add_branch').hide();
// $('.btnBack').hide();
loadKYCDocsList();
$('#btnBranchAdd').click(function(){
kyc_docs_form_action = '<?= base_url("master/kyc/kycdocs/createpost"); ?>';
var myModal = new bootstrap.Modal(document.getElementById('kycdocsModal'));
myModal.show();
// $('#add_branch').show();
// $('#branch_table').hide();
// $('.btnBack').show();
// $('#btnBranchAdd').hide();
$('#file_name').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#name0').val('');
$('#email0').val('');
$('#mobile0').val('');
$('#designation0').val('');
$('#name1').val('');
$('#email1').val('');
$('#mobile1').val('');
$('#designation1').val('');
$('#name2').val('');
$('#email2').val('');
$('#mobile2').val('');
$('#designation2').val('');
})
$('.btnBack').click(function(){
var myModal = new bootstrap.Modal(document.getElementById('kycdocsModal'));
myModal.hide();
// $('#add_branch').hide();
// $('#branch_table').show();
// $('.btnBack').hide();
// $('#btnBranchAdd').show();
$('#file_name').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#name0').val('');
$('#email0').val('');
$('#mobile0').val('');
$('#designation0').val('');
$('#name1').val('');
$('#email1').val('');
$('#mobile1').val('');
$('#designation1').val('');
$('#name2').val('');
$('#email2').val('');
$('#mobile2').val('');
$('#designation2').val('');
})
if(kyc_Docs_PrimaryKey !== ''){
var branchTable = '';
var data = <?= isset($insurer_branch) ? json_encode($insurer_branch) : '[]' ?>;
$.each(data, function(index, item) {
branchTable += `
<tr>
<td>${item.file_name}</td>
<td>
<a class="btnBranchEdit" data-id="${item.id}" href="#"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnBranchEdit" style="font-size:18px;"></i></a>
<a style="color:#02a8b5" data-id="${item.id}" onclick="removeKYCDocs(this)"><i data-id="${item.id}" class="mdi mdi-delete" style="font-size:18px;"></i></a>
</td>
</tr>
`;
});
$('#insurer_branch_list').append(branchTable);
}
$("#kyc_docs_form").submit(function(events) {
events.preventDefault();
var isValid = $('#kyc_docs_form').parsley().validate();
if (isValid) {
var formData = new FormData($('#kyc_docs_form')[0]);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
console.log("kyc_docs_form_action");
console.log(kyc_docs_form_action);
$.ajax({
data: formData,
url: kyc_docs_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
console.log(res);
$('#kyc_docs_list tr').remove();
var insurerBranchTableInsert = ''
$.each(res.data, function(index, item) {
insurerBranchTableInsert += `
<tr>
<td>${item.file_name}</td>
<td>
<a class="btnBranchEdit" data-id="${item.id}" href="#"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnBranchEdit" style="font-size:18px;"></i></a>
<a style="color:#02a8b5" data-id="${item.id}" onclick="removeKYCDocs(this)"><i data-id="${item.id}" class="mdi mdi-delete" style="font-size:18px;"></i></a>
</td>
</tr>
`;
});
$('#kyc_docs_list').append(insurerBranchTableInsert);
var myModal = new bootstrap.Modal(document.getElementById('kycdocsModal'));
myModal.hide();
// $('#add_branch').hide();
// $('#branch_table').show();
// $('.btnBack').hide();
// $('#btnBranchAdd').show();
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}
});
$('body').on('click', '.btnBranchEdit', function () {
var branch_id = $(this).attr('data-id');
kyc_docs_form_action = '<?= base_url("master/kyc/kycdocs/edit"); ?>';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?php echo base_url('master/kyc/kycdocs/editget/');?>'+branch_id,
type: "GET",
dataType: 'json',
success: function (res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
console.log("right.........");
var myModal = new bootstrap.Modal(document.getElementById('kycdocsModal'));
myModal.show();
// $('#add_branch').show();
// $('#branch_table').hide();
// $('.btnBack').show();
// $('#btnBranchAdd').hide();
$('#file_name').val(res.policies.file_name);
$('#kyc_Docs_PrimaryKey').val(res.policies.id);
// $('#kyc_docs_list').html(" ");
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
});
$('body').on('click', '#btnSubmit', function() {
$('#kyc_docs_list').html("");
console.log($('#kyc_docs_list')[0]);
setTimeout(function() {
console.log("hjknjkhiulhjulihj----------------------");
// loadKYCDocsList();
}, 1000) });
function loadKYCDocsList() {
var base_url = '<?= base_url("master/kyc/kycdocs/list/"); ?>';
var kyc_Docs_PrimaryKey_1 = $('#kyc_General_PrimaryKey').val();
// console.log("kyc_Docs_PrimaryKey_1");
// console.log(kyc_Docs_PrimaryKey_1);
var kyc_docs_action = base_url + kyc_Docs_PrimaryKey_1;
// console.log(kyc_docs_action);
if (kyc_Docs_PrimaryKey != '') {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: kyc_docs_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log("response in", res);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
var insurerBranchTableInsert = '';
$.each(res.kyc_docs, function(index, item) {
insurerBranchTableInsert += `
<tr>
<td>${item.file_name}</td>
<td>
<a class="btnBranchEdit" data-id="${item.id}"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnBranchEdit" style="font-size:18px;"></i></a>
<a style="color:#02a8b5" data-id="${item.id}" onclick="removeKYCDocs(this)"><i data-id="${item.id}" class="mdi mdi-delete" style="font-size:18px;"></i></a>
</td>
</tr>
`;
});
console.log($('#kyc_docs_list')[0]);
$('#kyc_docs_list').append(insurerBranchTableInsert);
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning'); }, 1000);
}
});
}
}
setTimeout(() => {
$('#table-kyc-docs').DataTable({
paging: true ,
searching: true
});
}, 2000);
});
function removeKYCDocs(element) {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this!.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var kyc_docs_id_for_reload = $('#kyc_type_id').val();
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/kyc/kycdocs/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('KYC docs removed successfully');
// location.reload();
window.location.href = '<?= base_url("master/kyc/list/") ?>' + kyc_docs_id_for_reload;
} else {
toastr.warning('Failed to remove KYC docs', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Failed to remove KYC docs', 'warning');
}
});
}
});
}
</script>