372 lines
14 KiB
PHP
Executable File
372 lines
14 KiB
PHP
Executable File
<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="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add KYC Docs</button>
|
|
</div>
|
|
|
|
<div class="table-responsive" id="branch_table" >
|
|
|
|
<table class="table table-borderless table-nowrap mb-0" id="table-kyc-docs">
|
|
<thead class="thead-light">
|
|
<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="fa fa-list" 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 -->
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
var kyc_Docs_PrimaryKey = $('#kyc_General_PrimaryKey').val();
|
|
var kyc_docs_form_action = '';
|
|
|
|
$('#add_branch').hide();
|
|
$('.btnBack').hide();
|
|
|
|
loadKYCDocsList();
|
|
|
|
|
|
$('#btnBranchAdd').click(function(){
|
|
|
|
kyc_docs_form_action = '<?= base_url("master/kyc/kycdocs/createpost"); ?>';
|
|
|
|
$('#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(){
|
|
|
|
$('#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);
|
|
$('#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.........");
|
|
$('#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: false
|
|
});
|
|
}, 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>
|