Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
37e03d9eeb
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ use App\Models\ClientDepositModel;
|
||||
use App\Models\PolicyPremium2Model;
|
||||
use App\Models\AuditHistoryModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\PartnerEndorsementRequestModel;
|
||||
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
@ -68,6 +69,7 @@ class EmployeeController extends AdminController
|
||||
protected $PolicyPremium2Model;
|
||||
protected $auditHistory;
|
||||
protected $userModel;
|
||||
protected $partnerEndorsementRequestModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -90,6 +92,7 @@ class EmployeeController extends AdminController
|
||||
$this->PolicyPremium2Model = new PolicyPremium2Model();
|
||||
$this->auditHistory = new AuditHistoryModel();
|
||||
$this->userModel = new userModel();
|
||||
$this->partnerEndorsementRequestModel = new PartnerEndorsementRequestModel();
|
||||
}
|
||||
|
||||
public function list()
|
||||
@ -3007,11 +3010,31 @@ class EmployeeController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Below function displays the endorsement list page.
|
||||
*
|
||||
* This method retrieves filter data from the request and fetches the endorsement list
|
||||
* based on the provided filters such as client ID, policy ID, and status.
|
||||
*/
|
||||
|
||||
public function retailendorsementList()
|
||||
{
|
||||
$data['message'] = 'File Not Found';
|
||||
echo view('errors/404', $data);
|
||||
|
||||
$data = [];
|
||||
$data['status'] = ['open' => 'Open', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
|
||||
if (count($this->request->getGet())) {
|
||||
$filterData = $this->request->getGet();
|
||||
$data['employees'] = $this->partnerEndorsementRequestModel->getRetailEndorsementList(
|
||||
client_id: $filterData['client_id'],
|
||||
insurer_id: $filterData['insurer_id'],
|
||||
status: $filterData['status']
|
||||
);
|
||||
$data['getData'] = $filterData;
|
||||
// echo "<pre>";
|
||||
// print_r($data); die;
|
||||
}
|
||||
$this->myLogger->logme('error', 'list called');
|
||||
$this->loadLayout('retail_endorsement_list', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1702,6 +1702,15 @@ class EmployeeServiceController extends AdminController
|
||||
$value['relationship'] = ucfirst(trim($value['relationship']));
|
||||
if(count($employee))
|
||||
{
|
||||
if (isset($employee[0]['email_corporate']) && $employee[0]['email_corporate'] != '')
|
||||
{
|
||||
unset($value['email_corporate']);
|
||||
}
|
||||
|
||||
if (isset($employee[0]['mobile']) && $employee[0]['mobile'] != '')
|
||||
{
|
||||
unset($value['mobile']);
|
||||
}
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee[0]['id'];
|
||||
$value['emp_status'] = 'active';
|
||||
|
||||
@ -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'])
|
||||
|
||||
@ -676,12 +676,17 @@ class UserController extends AdminController
|
||||
$fileId = $this->request->getPost('id');
|
||||
|
||||
if ($file && $file->isValid() && !$file->hasMoved()) {
|
||||
$fileName = $file->getName();
|
||||
$path = WRITEPATH.'uploads/incentives';
|
||||
|
||||
$originalName = $file->getClientName();
|
||||
$extension = $file->getExtension();
|
||||
|
||||
$fileName = pathinfo($originalName, PATHINFO_FILENAME) . '_' . date('Ymd_His') . '.' . $extension;
|
||||
|
||||
$path = WRITEPATH . 'uploads/incentives';
|
||||
$file->move($path, $fileName);
|
||||
$data = [
|
||||
'manager_id' => $managerId,
|
||||
'incentive_month' => date('Y-m-d', strtotime($month)),
|
||||
'incentive_month' => date('M Y', strtotime($month)),
|
||||
'incentive_file_name' => $fileName,
|
||||
'created_by' => get_session_userid()
|
||||
];
|
||||
@ -757,23 +762,33 @@ class UserController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadIncentivesFile($file_name)
|
||||
public function downloadIncentivesFile($file_id)
|
||||
{
|
||||
$file_name = basename($file_name);
|
||||
$filePath = WRITEPATH . 'uploads/incentives/' . $file_name;
|
||||
try {
|
||||
$result = $this->partnerManagerIncentiveFileModel->where('id', $file_id)->first();
|
||||
|
||||
if (!$result || empty($result['incentive_file_name'])) {
|
||||
throw new \Exception("File Name Not Found");
|
||||
}
|
||||
|
||||
$incentive_file_name = $result['incentive_file_name'];
|
||||
$file_name = basename($incentive_file_name);
|
||||
$filePath = WRITEPATH . 'uploads/incentives/' . $file_name;
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
return $this->response->download($filePath, null);
|
||||
} else {
|
||||
$data['message'] = 'File Not Found';
|
||||
echo view('errors/404', $data);
|
||||
throw new \Exception("File Not Found");
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Handle any exceptions
|
||||
$errorMessage = $e->getMessage();
|
||||
$this->myLogger->logme('error', $errorMessage);
|
||||
// You can return an error response here
|
||||
echo $errorMessage;
|
||||
|
||||
$this->myLogger->logme('error', $e->getMessage());
|
||||
|
||||
// Show 404 error view
|
||||
$data['message'] = $e->getMessage();
|
||||
return view('errors/404', $data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -37,4 +37,53 @@ class PartnerEndorsementRequestModel extends Model
|
||||
'status',
|
||||
];
|
||||
|
||||
public function getRetailEndorsementList($client_id, $insurers_id, $status)
|
||||
{
|
||||
$query = $this->db->table('partner_endorsement_request per')
|
||||
->distinct()
|
||||
->select('
|
||||
per.id,
|
||||
per.client_id,
|
||||
per.client_policy_id,
|
||||
per.insurer_id,
|
||||
per.insurer_branch_id,
|
||||
per.policy_number,
|
||||
per.endorsement_no,
|
||||
per.endorsement_type,
|
||||
per.endorsement_description,
|
||||
per.created_at,
|
||||
per.updated_by,
|
||||
per.updated_at,
|
||||
per.is_active,
|
||||
per.created_by,
|
||||
per.manager_id,
|
||||
per.agent_id,
|
||||
per.status,
|
||||
i.name as insurer_name,
|
||||
i.short_name as insurer_short_name,
|
||||
c.client_name,
|
||||
c.short_name as client_short_name,
|
||||
ps.name as manager_name,
|
||||
pa.name as agent_name
|
||||
')
|
||||
->join('insurers as i', 'i.id = per.insurer_id', 'left')
|
||||
->join('clients as c', 'c.id = per.client_id AND c.client_type = 2', 'left')
|
||||
->join('partner_staff as ps', 'ps.id = per.manager_id AND ps.role_id = 1', 'left')
|
||||
->join('partner_agent as pa', 'pa.id = per.agent_id', 'left');
|
||||
|
||||
if (!empty($status)) {
|
||||
$query->where('per.status', $status);
|
||||
}
|
||||
if (!empty($client_id)) {
|
||||
$query->where('per.client_id', $client_id);
|
||||
}
|
||||
if (!empty($insurers_id)) {
|
||||
$query->where('per.insurer_id', $insurers_id);
|
||||
}
|
||||
|
||||
$query->orderBy('per.id', 'desc');
|
||||
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -542,7 +542,7 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
<div id="nhance-partner-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
|
||||
<div id="nhance-partner-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -594,7 +594,7 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
<div id="upload-incentive-file-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
|
||||
<div id="upload-incentive-file-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -797,7 +797,7 @@ table.dataTable tbody td {
|
||||
var incentiveMonthPicker = flatpickr("#incentive_month", {
|
||||
dateFormat: "Y-m-d", // real value stored (hidden)
|
||||
altInput: true, // show a user-friendly display
|
||||
altFormat: "M-Y", // what you want to display (Aug-2025)
|
||||
altFormat: "M Y", // what you want to display (Aug 2025)
|
||||
allowInput: false,
|
||||
});
|
||||
|
||||
@ -1413,7 +1413,10 @@ table.dataTable tbody td {
|
||||
// let container = modal.find(".container");
|
||||
|
||||
let container = $("#container");
|
||||
container.html(`<div class="text-muted small">Loading...</div>`); // temporary loading msg
|
||||
container.html(`<div class="col-md-12 mt-2">
|
||||
<div class="d-flex align-items-center justify-content-center p-2 bg-white">
|
||||
<div class="text-muted small">Loading...</div>
|
||||
</div></div>`);
|
||||
|
||||
|
||||
$.ajax({
|
||||
@ -1436,7 +1439,8 @@ table.dataTable tbody td {
|
||||
};
|
||||
let uploaded = date.toLocaleString('en-GB', options).replace(',', '');
|
||||
let color = file.incentive_file_name ? "app-text-success" : "app-text-black";
|
||||
let download_url = "<?= base_url('user/download-incentive-file/') ?>" + encodeURIComponent(file.incentive_file_name);
|
||||
let download_url = "<?= base_url('user/download-incentive-file/') ?>" + encodeURIComponent(file.id);
|
||||
let im = file.incentive_month;
|
||||
|
||||
|
||||
let card = `<div class="col-md-6 mt-2 file-card"
|
||||
@ -1448,8 +1452,12 @@ table.dataTable tbody td {
|
||||
<i class="mdi mdi-file-document-outline app-text-black" style="font-size: 24px;"></i>
|
||||
</div>
|
||||
<div class="ml-2">
|
||||
<div class="font-weight-bold app-text-black small">${file.incentive_file_name}</div>
|
||||
<div class="text-muted small">Uploaded ${uploaded}</div>
|
||||
<div class="font-weight-bold app-text-black small text-truncate"
|
||||
title="${file.incentive_file_name}"
|
||||
style="max-width: 265px;">
|
||||
${file.incentive_file_name}
|
||||
</div>
|
||||
<div class="text-muted small">Uploaded : ${im}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@ -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').show()
|
||||
$('#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)
|
||||
|
||||
@ -0,0 +1,610 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
|
||||
position: relative;
|
||||
left: 79px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
<h2>Retail Endorsement</h2>
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div id="accordion" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
<h5 class="m-1">
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</h5>
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
<!-- <div class="text-center"> -->
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>Client</label> <br />
|
||||
<select class="form-control" id="clients">
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Insurer</label> <br />
|
||||
<select class="form-control" id="insurer">
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Status</label> <br />
|
||||
<select class="form-control" id="status1">
|
||||
<option value="0">Select</option>
|
||||
<?php foreach ($status as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
|
||||
<?= $value ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12" style="text-align: right;">
|
||||
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="client_list">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Endorsement List</h4>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<table data-custom-table-css="table" class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">SNO</th>
|
||||
<th class="font-weight-medium">Policy number</th>
|
||||
<th class="font-weight-medium">Endorsement Number</th>
|
||||
<th class="font-weight-medium">Description</th>
|
||||
<th class="font-weight-medium">Client</th>
|
||||
<th class="font-weight-medium">Insurer name</th>
|
||||
<th class="font-weight-medium">Agent</th>
|
||||
<th class="font-weight-medium">Mananger</th>
|
||||
<th class="font-weight-medium">Created At</th>
|
||||
<th class="font-weight-medium">Status</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php
|
||||
if (isset($employees)) {
|
||||
foreach ($employees as $key => $employee) { ?>
|
||||
<tr>
|
||||
<td><b><?php echo ($key + 1) ?></b></td>
|
||||
<td><?php echo $employee['policy_number'] ?></td>
|
||||
<td><?php echo $employee['endorsement_no'] ?></td>
|
||||
<td><?php echo $employee['endorsement_description'] ?></td>
|
||||
<td><?php echo $employee['insurer_name'] .' ( '. $employee['insurer_short_name'] .' ) ' ?></td>
|
||||
<td><?php echo $employee['client_name'] .' ( '. $employee['client_short_name'] .' ) ' ?></td>
|
||||
<td><?php echo $employee['agent_name'] ?></td>
|
||||
<td><?php echo $employee['manager_name'] ?></td>
|
||||
<td><?php echo $employee['created_at'] ?></td>
|
||||
<td><?php if ($employee['status'] == 'open') {
|
||||
echo '<span class="badge badge-primary">' . $employee['status'] . '</span>';
|
||||
} elseif ($employee['status'] == 'inprogress') {
|
||||
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
|
||||
} elseif ($employee['status'] == 'complete') {
|
||||
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td class="text-center"><a href="#" data-id="<?php echo $employee['id'] ?>" data-eno="<?php echo $employee['endorsement_no'] ?>" data-status="<?php echo $employee['status'] ?>"
|
||||
class="mdi mdi-eye emp_data_model" aria-hidden="true" data-toggle="modal" data-target="#centermodal"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: gainsboro;">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Edit Endorsement Details <span id="heading"></span></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modal_body">
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Initialize select2
|
||||
$("#clients").select2();
|
||||
$("#insurer").select2();
|
||||
});
|
||||
|
||||
// Declare a global variable to store API response data
|
||||
var clientPolicies = [];
|
||||
|
||||
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
|
||||
var insurer_id = '<?= isset($getData) ? $getData['insurer_id'] : '0' ?>';
|
||||
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("window loaded");
|
||||
fetchClientPolicies();
|
||||
});
|
||||
|
||||
|
||||
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) {
|
||||
// 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);
|
||||
|
||||
|
||||
response.data.forEach(policy => {
|
||||
// console.log('policies', policy.policies);
|
||||
policy.policies.forEach(p => {
|
||||
clientPoliciesWithBranch.policies.push(p);
|
||||
});
|
||||
});
|
||||
|
||||
// console.log(clientPolicies);
|
||||
appendClients(clientPolicies);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_id) {
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
// console.log(typeof item.id)
|
||||
return item.id == client_id;
|
||||
});
|
||||
appendBranch(foundPolicies.branchs);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
setTimeout(function() {
|
||||
if (client_branch_id) {
|
||||
|
||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||
// console.log('item', item);
|
||||
return item.branch_id === client_branch_id;
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
|
||||
|
||||
function appendClients(data) {
|
||||
|
||||
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
});
|
||||
if (clientID == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#clients').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function appendBranch(data) {
|
||||
|
||||
$('#branch_id').empty();
|
||||
$('#branch_id').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.branch_name
|
||||
});
|
||||
if (client_branch_id == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#branch_id').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function appendPolicies(data) {
|
||||
|
||||
$('#policies').empty();
|
||||
$('#policies').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
|
||||
// console.log(PolicyID)
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.client_policy_id,
|
||||
// text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
|
||||
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
|
||||
});
|
||||
if (PolicyID == item.client_policy_id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
$('#policies').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#clients').on('change', function() {
|
||||
|
||||
$('#policies').empty();
|
||||
$('#policies').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
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);
|
||||
appendBranch(foundPolicies.branchs);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#branch_id').on('change', function() {
|
||||
|
||||
var selectedClient = $(this).val();
|
||||
|
||||
// console.log('selectedBranch', selectedClient);
|
||||
// console.log('clientPolicies', clientPoliciesWithBranch);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Function to convert object to query parameters
|
||||
function objectToQueryString(obj) {
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function fetchEmpolyeeList(event) {
|
||||
event.preventDefault(); // Prevent default action
|
||||
|
||||
var client_id = $('#clients').val();
|
||||
var policy_id = $('#policies').val();
|
||||
var status = $('#status1').val();
|
||||
var branch_id = $('#branch_id').val();
|
||||
// console.log(client_id + '-' + policy_id);
|
||||
if (client_id == '0' || policy_id == '0') {
|
||||
alert('Please select values in both dropdowns.');
|
||||
return;
|
||||
}
|
||||
|
||||
var queryParams = {
|
||||
client_id: client_id,
|
||||
policy_id: policy_id,
|
||||
branch_id: branch_id,
|
||||
status: status,
|
||||
};
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||
// console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
|
||||
}
|
||||
|
||||
document.getElementById('toggleIcon').addEventListener('click', function() {
|
||||
var icon = document.getElementById('icon');
|
||||
icon.classList.toggle('mdi-chevron-down');
|
||||
icon.classList.toggle('mdi-chevron-up');
|
||||
});
|
||||
|
||||
|
||||
$('.emp_data_model').click(function() {
|
||||
var id = $(this).data('id');
|
||||
var eno = $(this).data('eno');
|
||||
var status = $(this).data('status');
|
||||
// console.log(val);
|
||||
fetchEmpEndorsementData(id,eno,status)
|
||||
|
||||
});
|
||||
|
||||
|
||||
function fetchEmpEndorsementData(id,eno,status) {
|
||||
|
||||
alert("id");
|
||||
alert(id);
|
||||
alert(eno);
|
||||
alert(status);
|
||||
// $('.loader').fadeIn();
|
||||
// $('.loader-mask').fadeIn();
|
||||
|
||||
// var apiURL = '<?php echo base_url(); ?>' + 'util/get-emp-endorsement/' + id;
|
||||
// console.log('fetchEmpEndorsementData');
|
||||
// // console.log(apiURL);
|
||||
// $.ajax({
|
||||
// url: apiURL,
|
||||
// method: 'GET',
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// "X-Requested-With": "XMLHttpRequest"
|
||||
// },
|
||||
// success: function(response) {
|
||||
// // console.log(response);
|
||||
// if (response.code === 200 && response.dataStatus === true) {
|
||||
// try {
|
||||
// endorsementData = (response.data);
|
||||
// endorsementData2 = (response.data2);
|
||||
|
||||
// e_actions = endorsementData2[0]['actions'];
|
||||
|
||||
|
||||
// var heading = "";
|
||||
// if (endorsementData2[0]['actions'] == 'si') {
|
||||
// heading = ' - ' + 'SI Enhancement';
|
||||
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
|
||||
// } else if (endorsementData2[0]['actions'] == 'd') {
|
||||
// heading = ' - ' + 'Deletion';
|
||||
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
|
||||
// } else if (endorsementData2[0]['actions'] == 'c') {
|
||||
// heading = ' - ' + 'Correction';
|
||||
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
|
||||
// }
|
||||
|
||||
// $('#heading').html(heading);
|
||||
|
||||
// $('#table_data').empty();
|
||||
// $('#table_head_data').empty();
|
||||
|
||||
|
||||
// if (e_actions == 'd') {
|
||||
|
||||
// $.each(endorsementData, function(index, item) {
|
||||
// var tableHtml = `
|
||||
// <tr>
|
||||
// <td>${item.field_name}</td>
|
||||
// <td>${formatNumberToIndianLocale(item.data, item.field_name, e_actions)}</td>
|
||||
// </tr>
|
||||
// `;
|
||||
// $('#table_data').append(tableHtml);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
// } else {
|
||||
|
||||
// var table_head = `
|
||||
// <tr>
|
||||
// <th class="font-weight-medium"></th>
|
||||
// <th class="font-weight-medium">Old Value</th>
|
||||
// <th class="font-weight-medium">New Value</th>
|
||||
// </tr>
|
||||
// `;
|
||||
// $('#table_head_data').append(table_head);
|
||||
|
||||
// $.each(endorsementData, function(index, item) {
|
||||
// var tableHtml = `
|
||||
// <tr>
|
||||
// <td>${item.field_name}</td>
|
||||
// <td>${formatNumberToIndianLocale(item.old_value, item.field_name)}</td>
|
||||
// <td>${formatNumberToIndianLocale(item.new_value, item.field_name, e_actions)}</td>
|
||||
// </tr>
|
||||
// `;
|
||||
// $('#table_data').append(tableHtml);
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// } 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);
|
||||
// }
|
||||
// });
|
||||
|
||||
// setTimeout(function() {
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }, 200);
|
||||
}
|
||||
|
||||
function formatNumberToIndianLocale(value, field_name, action) {
|
||||
|
||||
// Check if the value is a valid number (either as a number or as a string)
|
||||
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
|
||||
|
||||
// Convert the value to a number and format it using Indian English locale
|
||||
var return_val = parseFloat(value).toLocaleString('en-IN');
|
||||
|
||||
if (field_name == 'Period of non coverage') {
|
||||
|
||||
return value + ' days';
|
||||
}
|
||||
|
||||
if (field_name == 'Total Amount') {
|
||||
|
||||
return '₹ ' + return_val + ' ( To be Refunded )';
|
||||
}
|
||||
|
||||
if (field_name == 'Total') {
|
||||
|
||||
if (action == 'd') {
|
||||
|
||||
return '₹ ' + return_val + ' ( To be Refunded )';
|
||||
|
||||
} else if (action == 'si') {
|
||||
|
||||
return '₹ ' + return_val + ' ( To be paid )';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return '₹ ' + return_val;
|
||||
|
||||
} else {
|
||||
// Return the original value if it's not a valid number
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
$('.close').click(function() {
|
||||
|
||||
$('#table_data').empty();
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Endorsement-List',
|
||||
className: 'my_class',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)',
|
||||
format: {
|
||||
body: function (data, row, column, node) {
|
||||
// Convert data to string to avoid scientific notation in CSV
|
||||
if (!isNaN(data) && parseFloat(data) > 1e20) {
|
||||
return `'${data}`;
|
||||
}
|
||||
return data.toString();// Ensures all data is treated as strings
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
initComplete: function(settings, json) {
|
||||
$('.my_class').css({
|
||||
"position": "relative",
|
||||
"left": "79px"
|
||||
});
|
||||
},
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true,
|
||||
// pagingType: 'full_numbers'
|
||||
columnDefs: [
|
||||
{ type: 'scientific', targets: 0 } // Apply custom sorting type to the first column
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user