FIX_KYC_DOCS : RV
This commit is contained in:
parent
f526204087
commit
0eb65b9a1b
@ -772,6 +772,8 @@ class ClientController extends AdminController
|
||||
|
||||
$editData['client'] = $this->clientModel->where(['id' => $id])->first();
|
||||
$editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll();
|
||||
$editData['client_kyc_primary_table'] = $this->generateKycPrimaryTable($id);
|
||||
$editData['client_kyc_other_table'] = $this->generateKycOthersTable($id);
|
||||
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
||||
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
||||
$editData['client_branch']['role'] = get_role_id();
|
||||
@ -870,6 +872,8 @@ class ClientController extends AdminController
|
||||
{
|
||||
$this->myLogger->logme('error', 'create Client kyc function called');
|
||||
$data = $this->request->getPost();
|
||||
$form_type = $this->request->getPost('form_type') ?? null;
|
||||
|
||||
// print_r($data); die;
|
||||
unset($data['file_name']);
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
@ -885,8 +889,12 @@ class ClientController extends AdminController
|
||||
$data['created_by'] = get_session_userid();
|
||||
$insert = $this->clientKYCDocsModel->insert($data);
|
||||
if ($insert) {
|
||||
|
||||
$kycDocs = $this->clientKYCDocsModel->where('client_id', $this->request->getPost('client_id'))->findAll();
|
||||
// $kycDocs = $this->clientKYCDocsModel->where('client_id', $this->request->getPost('client_id'))->findAll();
|
||||
if($form_type == "others"){
|
||||
$kycDocs = $this->generateKycOthersTable($this->request->getPost('client_id'));
|
||||
}else{
|
||||
$kycDocs = $this->generateKycPrimaryTable($this->request->getPost('client_id'));
|
||||
}
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs, 'file_name' => $File], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
@ -899,6 +907,8 @@ class ClientController extends AdminController
|
||||
$this->myLogger->logme('error', 'edit client kyc function called');
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
$File = file_Upload($this->request->getFile('file_name'), $uploadFilePath);
|
||||
$form_type = $this->request->getPost('form_type') ?? null;
|
||||
|
||||
if (!empty($File)) {
|
||||
$data['file_name'] = $File;
|
||||
}
|
||||
@ -907,8 +917,14 @@ class ClientController extends AdminController
|
||||
$data['kyc_doc_type_id'] = $this->request->getPost('kyc_doc_id');
|
||||
$data['updated_by'] = get_session_userid();
|
||||
$insert = $this->clientKYCDocsModel->insert($data);
|
||||
|
||||
if ($insert) {
|
||||
$kycDocs = $this->clientKYCDocsModel->getKycDocsName($id);
|
||||
// $kycDocs = $this->clientKYCDocsModel->getKycDocsName($id);
|
||||
if($form_type == "others"){
|
||||
$kycDocs = $this->generateKycOthersTable($this->request->getPost('client_id'));
|
||||
}else{
|
||||
$kycDocs = $this->generateKycPrimaryTable($this->request->getPost('client_id'));
|
||||
}
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
@ -2163,11 +2179,32 @@ class ClientController extends AdminController
|
||||
$builder->groupBy(['kd.id', 'ck.file_name']);
|
||||
|
||||
$query = $builder->get();
|
||||
$result['data'] = $query->getResult();
|
||||
$result['data'] = $query->getResultArray();
|
||||
$result['client_id'] = $client_id;
|
||||
|
||||
$table = view('client_kyc_primary_table', $result);
|
||||
|
||||
print_r($table);
|
||||
return $table;
|
||||
// print_r($table); die;
|
||||
|
||||
}
|
||||
|
||||
public function generateKycOthersTable($client_id){
|
||||
|
||||
$result['data'] = $this->clientKYCDocsModel
|
||||
->where('is_active', 1)
|
||||
->where('client_id', $client_id)
|
||||
->groupStart()
|
||||
->where('kyc_doc_type_id', null)
|
||||
->orWhere('kyc_doc_type_id', 0)
|
||||
->groupEnd()
|
||||
->findAll();
|
||||
|
||||
$result['client_id'] = $client_id;
|
||||
$table = view('client_kyc_other_table', $result);
|
||||
|
||||
return $table;
|
||||
// print_r($table); die;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3423,7 +3423,7 @@ class EmployeeRestController extends AdminController
|
||||
$client_policy_id = $received_data['client_policy_id'];
|
||||
$insured_emp_id = $received_data['insured_emp_id'];
|
||||
|
||||
$file_data = "";
|
||||
$file_data = [];
|
||||
if(isset($get_file_data) && !empty($get_file_data)){
|
||||
$file_path = WRITEPATH . 'uploads/claim_files/';
|
||||
$file_data = multi_file_Upload($get_file_data, $file_path);
|
||||
|
||||
@ -383,7 +383,12 @@ class PolicyTransactionController extends BaseController
|
||||
}
|
||||
|
||||
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
|
||||
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
|
||||
$data['entity_type_id'] = $client_data['entity_type_id'];
|
||||
|
||||
return $this->respondSuccess($insert, "Policy transaction created successfully", $data);
|
||||
@ -433,6 +438,11 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
|
||||
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
|
||||
$data['entity_type_id'] = $client_data['entity_type_id'];
|
||||
|
||||
return $this->respondSuccess($id, "Policy transaction updated successfully", $data);
|
||||
@ -977,7 +987,12 @@ class PolicyTransactionController extends BaseController
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
|
||||
->where('employees.client_id', $data['client_id'])
|
||||
->where('employees.is_active', 1)->findAll();
|
||||
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
// $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
|
||||
$data['vehicle_docs'] = $this->clientKYCDocsModel
|
||||
->where('client_id', $data['client_id'])
|
||||
->where('vehicle_id', $data['vehicle_id'])
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
|
||||
<?= isset($client_kyc_primary_table) ? $client_kyc_primary_table : "" ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
@ -71,7 +71,7 @@
|
||||
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" name="PrimaryKey" id="kyc_PrimaryKey" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
|
||||
<input type="hidden" name="client_id" id="client_id_kyc" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
|
||||
<input type="hidden" name="kyc_doc_type_id" value="0" />
|
||||
<input type="hidden" name="kyc_doc_type_id" value="" />
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
@ -113,10 +113,10 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="other_docs">
|
||||
<?= isset($client_kyc_other_table) ? $client_kyc_other_table : "" ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col -->
|
||||
@ -131,10 +131,6 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
kycPrimaryKey = $('#kyc_PrimaryKey').val();
|
||||
|
||||
$('#others').hide()
|
||||
$('#other_docs_table').hide();
|
||||
|
||||
$(document).on('click', '.submit', function(e) {
|
||||
|
||||
e.preventDefault();
|
||||
@ -145,7 +141,6 @@
|
||||
var fileInputs = form.find('input[type="file"]');
|
||||
var allowedExtensions = ['pdf', 'png', 'jpeg', 'jpg'];
|
||||
|
||||
|
||||
if (kycPrimaryKey === '') {
|
||||
toastr.error('Client is required', 'Error');
|
||||
form.trigger('reset')
|
||||
@ -175,7 +170,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
@ -186,94 +180,32 @@
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
// res = JSON.parse(res)
|
||||
console.log(res);
|
||||
|
||||
if(res){
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.success('File Uploaded successfully', 'Success');
|
||||
}, 500);
|
||||
console.log('KYC PRIMARY SUBMIT', res);
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.data);
|
||||
toastr.success('File uploaded successfully', 'Success');
|
||||
}else{
|
||||
toastr.warning('File uploaded failed', 'WARNING');
|
||||
}
|
||||
|
||||
form.trigger('reset')
|
||||
$.each(res.data, function (index, item) {
|
||||
|
||||
$('#name_'+item.kyc_doc_type_id).show();
|
||||
$('#name_'+item.kyc_doc_type_id).html(item.file_name);
|
||||
$('#form_'+item.kyc_doc_type_id).hide();
|
||||
|
||||
// var url = "<?= base_url('/downloadGdriveFile'); ?>" +
|
||||
// "?client_id=" + item.client_id +
|
||||
// "&file_type=kyc" +
|
||||
// "&file_name=" + item.file_name +
|
||||
// "&client_policy_id=client_policy_id";
|
||||
|
||||
var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
|
||||
|
||||
// console.log('step 1')
|
||||
|
||||
if(item.file_name != null && item.file_name != ""){
|
||||
// console.log('step 2')
|
||||
|
||||
$('#download_'+item.kyc_doc_type_id).show();
|
||||
$('#download_' + item.kyc_doc_type_id).attr('href', url);
|
||||
$('#delete_'+item.kyc_doc_type_id).show();
|
||||
|
||||
}
|
||||
else{
|
||||
// console.log('step 3')
|
||||
|
||||
$('#download_'+item.kyc_doc_type_id).hide();
|
||||
$('#download_' + item.kyc_doc_type_id).attr('href', '#');
|
||||
$('#delete_'+item.kyc_doc_type_id).hide();
|
||||
|
||||
}
|
||||
// console.log('step 4')
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
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);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if(kycPrimaryKey !== ''){
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var entity_type_id = '<?= isset($client['entity_type_id']) ? $client['entity_type_id'] : '' ?>'
|
||||
var client_id = '<?= isset($client['id']) ? $client['id'] : '' ?>'
|
||||
getKYCEntityDocument(entity_type_id, client_id);
|
||||
|
||||
var data = <?= isset($client_kyc) ? json_encode($client_kyc) : '[]' ?>;
|
||||
appendKycTableListData(data)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$('#btn_other_docs').click(function(){
|
||||
$('#others').toggle();
|
||||
$('#other_docs_table').toggle();
|
||||
});
|
||||
|
||||
/*** for Others documents form submit ***/
|
||||
$("#kyc_form").submit(function(event) {
|
||||
event.preventDefault();
|
||||
@ -289,6 +221,7 @@
|
||||
form_action = '<?= base_url("client/kyc/edit"); ?>';
|
||||
}
|
||||
var formData = new FormData($('#kyc_form')[0]);
|
||||
formData.append("form_type", "others");
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
@ -302,74 +235,27 @@
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
setTimeout(function() {
|
||||
console.log('KYC OTHERS SUBMIT', res);
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
// console.log(res);
|
||||
$('#kyc_form').trigger('reset');
|
||||
if(res){
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
var message = (kycPrimaryKey === '') ? 'KYC Other Docs Uploaded successfully' : 'KYC Other Docs Uploaded successfully';
|
||||
toastr.success(message, 'Success');
|
||||
}, 500);
|
||||
|
||||
if(res.status == true){
|
||||
$('#other_docs').empty();
|
||||
$('#other_docs').append(res.data);
|
||||
toastr.success('File uploaded successfully', 'Success');
|
||||
}else{
|
||||
toastr.warning('File uploaded failed', 'WARNING');
|
||||
}
|
||||
|
||||
var other_docs_count = 0;
|
||||
|
||||
$('#other_docs tr').remove();
|
||||
$.each(res.data, function(index, item) {
|
||||
|
||||
if(item.other_docs_name != ""){
|
||||
|
||||
other_docs_count++;
|
||||
}
|
||||
|
||||
// var url = "<?= base_url('/downloadGdriveFile'); ?>" +
|
||||
// "?client_id=" + item.client_id +
|
||||
// "&file_type=kyc" +
|
||||
// "&file_name=" + item.file_name +
|
||||
// "&client_policy_id=client_policy_id";
|
||||
|
||||
|
||||
var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
|
||||
|
||||
// console.log("Current item:", item);
|
||||
if (item.kyc_doc_type_id == '0') {
|
||||
// console.log("Appending item:", item);
|
||||
var rowHtml = `
|
||||
<tr id="kyc-${item.id}">
|
||||
<td>${item.other_docs_name}</td>
|
||||
<td>${item.file_name}</td>
|
||||
<td>
|
||||
<a href = "${url}" data-id="${item.id}" class="mdi mdi-download" style="font-size:18px;" download></a>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
$('#other_docs').append(rowHtml);
|
||||
|
||||
//<i data-id="${item.id}" class="mdi mdi-delete btnKycOtherDelete" style="font-size:18px;"></i>
|
||||
|
||||
|
||||
if(other_docs_count > 0){
|
||||
$('#others').show()
|
||||
$('#other_docs_table').show();
|
||||
}
|
||||
});
|
||||
$('#kyc_form').trigger('reset');
|
||||
},
|
||||
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);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -436,6 +322,8 @@
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
|
||||
console.log("KYC DOCUMENTS TABLE RSPONSE", res);
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -519,9 +407,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
}
|
||||
// <i data-id="${item.id}" class="mdi mdi-delete btnKycOtherDelete" style="font-size:18px;"></i>
|
||||
// <i data-id="${item.id}" class="mdi mdi-delete btnKycOtherDelete" style="font-size:18px;"></i>
|
||||
|
||||
});
|
||||
|
||||
|
||||
14
app/Views/client_kyc_other_table.php
Normal file
14
app/Views/client_kyc_other_table.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php if (isset($data) && !empty($data)): ?>
|
||||
<?php foreach ($data as $index => $item): ?>
|
||||
<tr id="kyc-<?= $item['id'] ?>">
|
||||
<!-- <td><?= $index + 1; ?></td> -->
|
||||
<td><?= esc($item['file_name']); ?></td>
|
||||
<td><?= esc($item['other_docs_name']); ?></td>
|
||||
<td><a id="download_<?= esc($item['id']); ?>" data-id="<?= esc($item['id']); ?>" class="mdi mdi-download" style="font-size:18px;" download></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">No records found</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
28
app/Views/client_kyc_primary_table.php
Normal file
28
app/Views/client_kyc_primary_table.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php if (isset($data) && !empty($data)): ?>
|
||||
<?php foreach ($data as $index => $item): ?>
|
||||
<tr>
|
||||
<td><?= $index + 1; ?></td>
|
||||
<td><?= esc($item['file_name']); ?></td>
|
||||
|
||||
<?php if(empty($item['upload_doc_name'])) { ?>
|
||||
<td id="form_<?= esc($item['id']); ?>">
|
||||
<form class="ajax" enctype="multipart/form-data" method="post">
|
||||
<input class="file-input__input" type="file" name="file_name">
|
||||
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>">
|
||||
<input type="hidden" class="form-control" value="<?= esc($item['id']); ?>" name="kyc_doc_type_id">
|
||||
<input type="hidden" name="client_id" value="<?= esc($client_id); ?>">
|
||||
<button type="submit" class="btn btn-sm btn-primary submit" style="position: relative; right: 80px;">Submit</button>
|
||||
</form>
|
||||
</td>
|
||||
<td></td>
|
||||
<?php } else { ?>
|
||||
<td><?= esc($item['upload_doc_name']); ?></td>
|
||||
<td><a id="download_<?= esc($item['id']); ?>" data-id="<?= esc($item['id']); ?>" class="mdi mdi-download" style="font-size:18px;" download></a></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">No records found</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
@ -1741,8 +1741,16 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
$('#cd_ac_pk_for_leader').val(res.data.cd_ac_pk);
|
||||
|
||||
// $('#entity_type_id').val(res.data.entity_type_id);
|
||||
getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||||
appendKycTableListData(res.data.client_kyc);
|
||||
// getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||||
// appendKycTableListData(res.data.client_kyc);
|
||||
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.data.client_kyc_primary_table);
|
||||
|
||||
$('#other_docs').empty();
|
||||
$('#other_docs').append(res.data.client_kyc_other_table);
|
||||
|
||||
|
||||
|
||||
|
||||
// Setting values to correct fields
|
||||
@ -3351,8 +3359,14 @@ $("#inception_form_id").submit(function(event) {
|
||||
$('#client_id_for_vehicle_file_upload').val(res.data.client_id);
|
||||
$('#vehicle_id_for_file_upload').val(res.data.vehicle_id);
|
||||
|
||||
getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||||
appendKycTableListData(res.data.client_kyc);
|
||||
// getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||||
// appendKycTableListData(res.data.client_kyc);
|
||||
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.data.client_kyc_primary_table);
|
||||
|
||||
$('#other_docs').empty();
|
||||
$('#other_docs').append(res.data.client_kyc_other_table);
|
||||
|
||||
//setTimeout(function(){
|
||||
//}, 1000)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user