Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
729d1a0dad
@ -164,6 +164,11 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("edit", "ClientController::editClientKYCInfo");
|
||||
$routes->get("list/(:any)", "ClientController::getKycDocsById/$1");
|
||||
$routes->get("delete/(:any)", "ClientController::deleteClientKycDocs/$1");
|
||||
|
||||
$routes->post("create_2", "ClientController::createClientKYCInfo_2");
|
||||
$routes->post("edit_2", "ClientController::editClientKYCInfo_2");
|
||||
$routes->post("delete_2", "ClientController::deleteClientKycDocs_2/$1");
|
||||
|
||||
});
|
||||
|
||||
$routes->group("premimum", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -568,10 +573,15 @@ $routes->group("employeeRest", ['filter' => ["appSignature"] ], function ($route
|
||||
$routes->get("getHRAccessData", "RestAuthenticationController::getHRAccessData");
|
||||
|
||||
$routes->post("getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth");
|
||||
$routes->post("getRetailUserData", "RestAuthenticationController::getRetailUserData");
|
||||
|
||||
$routes->get("getClientDetails", "EmployeeRestController::getClientDetails");
|
||||
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
||||
|
||||
//retail user apis
|
||||
$routes->post("getVerifiedRetailUserData", "RestAuthenticationController::getVerifiedRetailUserData");
|
||||
$routes->post("updateRetailUserAuthDetails", "RestAuthenticationController::updateRetailUserAuthDetails");
|
||||
|
||||
});
|
||||
|
||||
$routes->group("employeeRest", ["filter" => ["authJWT"]], function ($routes) {
|
||||
|
||||
@ -1005,6 +1005,153 @@ class ClientController extends AdminController
|
||||
|
||||
|
||||
|
||||
public function createClientKYCInfo_2()
|
||||
{
|
||||
$this->myLogger->logme('error', 'create Client kyc function called');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$uploadedFile = $this->request->getFile('file_name');
|
||||
|
||||
if ($uploadedFile && $uploadedFile->isValid() && !$uploadedFile->hasMoved()) {
|
||||
$this->myLogger->logme('info', 'File is valid and ready to move.');
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'File failed validation or was not uploaded.');
|
||||
}
|
||||
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
|
||||
$File = file_Upload($uploadedFile, $uploadFilePath);
|
||||
$this->myLogger->logme('info', 'Result of file_Upload: ' . $File);
|
||||
unset($data['file_name']);
|
||||
|
||||
if (!empty($File)) { $data['file_name'] = $File; }
|
||||
|
||||
$data['created_by'] = get_session_userid();
|
||||
$insert = $this->clientKYCDocsModel->insert($data);
|
||||
|
||||
if ($insert) {
|
||||
$html = $this->generateKycSingleTable($data['client_id']);
|
||||
$dropdown = $this->fetch_dropdown($data['client_id']);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'file_name' => $File, 'html' => $html,'dropdown'=>$dropdown], 200);
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'Database insert failed.');
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to add document'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function editClientKYCInfo_2()
|
||||
{
|
||||
|
||||
$kyc_id = $this->request->getPost('id');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$old_file_name = $this->request->getPost('old_file_name');
|
||||
$uploadedFile = $this->request->getFile('file_name');
|
||||
$new_file_name = null;
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
|
||||
|
||||
if ($uploadedFile && $uploadedFile->isValid() && !$uploadedFile->hasMoved()) {
|
||||
|
||||
|
||||
$new_file_name = file_Upload($uploadedFile, $uploadFilePath);
|
||||
|
||||
if (!empty($new_file_name)) {
|
||||
|
||||
$updateData['file_name'] = $new_file_name;
|
||||
|
||||
// Delete the old file from the storage if it exists
|
||||
// if (!empty($old_file_name)) {
|
||||
// $old_file_path = $uploadFilePath . '/' . $old_file_name;
|
||||
// if (file_exists($old_file_path)) {
|
||||
// unlink($old_file_path);
|
||||
// // Optionally delete from G-Drive here if applicable
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
// New file upload failed
|
||||
return $this->respond(['status' => false, 'code' => 500, 'message' => 'New file upload failed on server.'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Perform the database update
|
||||
if (!empty($updateData)) {
|
||||
|
||||
$updateData['updated_by'] = get_session_userid();
|
||||
$update = $this->clientKYCDocsModel->update($kyc_id, $updateData);
|
||||
$html = $this->generateKycSingleTable($client_id);
|
||||
$dropdown = $this->fetch_dropdown($client_id);
|
||||
|
||||
if ($update) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Document updated successfully.','html' => $html,'dropdown' => $dropdown], 200);
|
||||
}
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'No changes detected. Document remains the same.'], 200);
|
||||
}
|
||||
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Database update failed or record not found.'], 200);
|
||||
}
|
||||
|
||||
|
||||
public function deleteClientKycDocs_2()
|
||||
{
|
||||
|
||||
$kyc_id = $this->request->getPost('id');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
|
||||
if (empty($kyc_id)) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Missing document ID.'], 200);
|
||||
}
|
||||
$updateData['updated_by'] = get_session_userid();
|
||||
$updateData['is_active'] = $this->request->getPost('is_active');
|
||||
|
||||
$delete = $this->clientKYCDocsModel->update($kyc_id, $updateData);
|
||||
|
||||
if ($delete) {
|
||||
$html = $this->generateKycSingleTable($client_id);
|
||||
$dropdown = $this->fetch_dropdown($client_id);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'id' => $kyc_id, 'message' => 'Document successfully deactivated.','html' => $html,'dropdown' => $dropdown], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update record (ID not found or DB error).'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function fetch_dropdown($client_id){
|
||||
|
||||
$db = db_connect();
|
||||
|
||||
|
||||
$submitted_ids_subquery = $db->table('client_kyc_documents ckd')
|
||||
->select('ckd.kyc_doc_type_id')
|
||||
->where('ckd.client_id', $client_id)
|
||||
->where('ckd.is_active', 1)
|
||||
->getCompiledSelect();
|
||||
|
||||
|
||||
$result = $db->table('kyc_docs kd')
|
||||
->select('kd.*')
|
||||
->join('clients c', 'kd.kyc_type_id = c.entity_type_id')
|
||||
->where('c.id', $client_id)
|
||||
->where("kd.kyc_type_id NOT IN ({$submitted_ids_subquery})")
|
||||
->groupBy('kd.id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
$dropdown = '<option value="">Select Document</option>';
|
||||
$dropdown .= '<option value="other">Additional Document</option>';
|
||||
|
||||
foreach ($result as $row) {
|
||||
$dropdown .= '<option value="' . esc($row['kyc_type_id']) . '">'
|
||||
. esc($row['file_name']) .
|
||||
'</option>';
|
||||
}
|
||||
|
||||
return $dropdown;
|
||||
}
|
||||
|
||||
|
||||
public function createClientRelation()
|
||||
{
|
||||
|
||||
@ -2361,6 +2508,36 @@ class ClientController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function generateKycSingleTable($client_id)
|
||||
{
|
||||
|
||||
|
||||
$result['ckdlist'] = db_connect()->table('client_kyc_documents ckd')
|
||||
->select("ckd.id,ckd.client_id,ckd.kyc_doc_type_id,ckd.file_name,kd.file_name AS kd_docs_name,ckd.other_docs_name,ckd.vehicle_id,ckd.is_active,
|
||||
CASE
|
||||
WHEN ckd.kyc_doc_type_id IS NULL
|
||||
OR ckd.kyc_doc_type_id = 0
|
||||
OR ckd.kyc_doc_type_id = ''
|
||||
THEN ckd.other_docs_name
|
||||
ELSE kd.file_name
|
||||
END AS ui_docs_name")
|
||||
->join('kyc_docs kd','ckd.kyc_doc_type_id = kd.kyc_type_id','left')
|
||||
->where('ckd.client_id',$client_id)
|
||||
->where('ckd.is_active',1)
|
||||
->groupBy('ckd.id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
$result['client_id'] = $client_id;
|
||||
$table = view('client_kyc_single_table', $result);
|
||||
|
||||
return $table;
|
||||
// print_r($table); die;
|
||||
|
||||
}
|
||||
|
||||
public function getPolicesByInsurerId($id = null)
|
||||
{
|
||||
$this->myLogger->logme('error', 'getPolicesByInsurerId function called');
|
||||
|
||||
@ -5301,6 +5301,15 @@ class EmpDataServiceController extends BaseController
|
||||
$salse_person_id = $lead_data['created_by'] ?? null;
|
||||
}
|
||||
|
||||
// get the policy transaction id for client policy id
|
||||
$policy_transaction_data = $this->policyTransactionModel->where('is_active', 1)->where('TRIM(policy_no)', $policy_data['policy_no'])->where('action_type', 'inception')->first();
|
||||
$client_policy_id = null;
|
||||
if(!empty($policy_transaction_data) && $params['action_type'] != "inception"){
|
||||
$client_policy_id = $policy_transaction_data['id'] ?? null;
|
||||
}else{
|
||||
$client_policy_id = $policy_data['id'] ?? null;
|
||||
}
|
||||
|
||||
$policyTransactionData = [
|
||||
|
||||
'issuer' => 2,
|
||||
@ -5312,7 +5321,7 @@ class EmpDataServiceController extends BaseController
|
||||
'tpa_id' => $policy_data['tpa_id'] ?? null,
|
||||
'tpa_branch_id' => $policy_data['tpa_branch_id'] ?? null,
|
||||
'policy_type_id' => $policy_data['policy_type_id'] ?? null,
|
||||
'client_policy_id' => $policy_data['id'] ?? null,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'policy_no' => $policy_data['policy_no'] ?? null,
|
||||
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
|
||||
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
|
||||
|
||||
@ -548,8 +548,7 @@ class EmployeeController extends AdminController
|
||||
'file_name' => $file_name,
|
||||
];
|
||||
|
||||
|
||||
$batch_data['policy_issue_date'] = (!empty($policy_issue_date) && strtotime($policy_issue_date) !== false) ? change_date_format($policy_issue_date, 'd/m/Y', 'Y-m-d') : null;
|
||||
$batch_data['policy_issue_date'] = !empty($policy_issue_date) ? change_date_format($policy_issue_date, 'd/m/Y', 'Y-m-d') : null;
|
||||
|
||||
if ($actions == 'export') {
|
||||
|
||||
|
||||
@ -2820,7 +2820,43 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
|
||||
function getEmployeeActiveOrInactivePolicy()
|
||||
{
|
||||
{
|
||||
|
||||
// for retail user policy only
|
||||
$receviedPayload = $this->request->getGet();
|
||||
|
||||
if(
|
||||
empty($receviedPayload['client_id']) &&
|
||||
empty($receviedPayload['client_branch_id']) &&
|
||||
empty($receviedPayload['emp_code'])
|
||||
){
|
||||
|
||||
if(!empty($receviedPayload['mobile_no']) || !empty($receviedPayload['email_id'])){
|
||||
|
||||
$retailUserData = (object) [
|
||||
'id' => null,
|
||||
'mobile' => $receviedPayload['mobile_no'],
|
||||
'email_id' => $receviedPayload['email_id']
|
||||
];
|
||||
|
||||
$emp_reatail_policy_data = $this->getEmpRetailPolicy($retailUserData);
|
||||
|
||||
$query = $this->clientModel
|
||||
->where('is_active', 1)
|
||||
->where('client_type', 2);
|
||||
|
||||
if (!empty($receviedPayload['mobile_no'])) {
|
||||
$query->where('phone', $receviedPayload['mobile_no']);
|
||||
} else {
|
||||
$query->where('email', $receviedPayload['email_id'] ?? null);
|
||||
}
|
||||
|
||||
$retailClientData = $query->first();
|
||||
$wellness_data = ['status' => 'failed','message' => 'Coming soon........!'];
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => [], 'emp_name' => $retailClientData['client_name'] ?? "", 'pre_policy_count' => 0, 'retail_policy_data' => $emp_reatail_policy_data, 'wellness_data' => $wellness_data], 200);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->request->getGet('type') == 'Active') {
|
||||
$policy_status = 1;
|
||||
$policy_status_key = "Active";
|
||||
@ -4648,6 +4684,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
$emp_id = $employeeData->id ?? null;
|
||||
$mobile_number = $employeeData->mobile ?? null;
|
||||
$email_id = $employeeData->email_id ?? null;
|
||||
|
||||
$emp_retail_policy_data = [];
|
||||
if ($emp_id != null) {
|
||||
@ -4678,7 +4715,7 @@ class EmployeeRestController extends AdminController
|
||||
if (!empty($mobile_number)) {
|
||||
$emp_retail_client_data = $this->clientModel
|
||||
->select("
|
||||
$emp_id as emp_id,
|
||||
'{$emp_id}' AS emp_id,
|
||||
policy_transaction.insurer_id,
|
||||
policy_transaction.policy_type_id,
|
||||
policy_transaction.policy_no,
|
||||
@ -4696,9 +4733,31 @@ class EmployeeRestController extends AdminController
|
||||
->where('clients.is_active', 1)
|
||||
->where('clients.phone', $mobile_number)
|
||||
->findAll();
|
||||
}else {
|
||||
$emp_retail_client_data = $this->clientModel
|
||||
->select("
|
||||
'{$emp_id}' AS emp_id,
|
||||
policy_transaction.insurer_id,
|
||||
policy_transaction.policy_type_id,
|
||||
policy_transaction.policy_no,
|
||||
DATE_FORMAT(policy_transaction.policy_start_date, '%d-%b-%Y') as policy_start_date,
|
||||
DATE_FORMAT(policy_transaction.policy_end_date, '%d-%b-%Y') as policy_end_date,
|
||||
policy_type.policy_type,
|
||||
policy_type.long_name as policy_type_long_name,
|
||||
insurers.name as insurer_name,
|
||||
insurers.short_name as insurer_short_name
|
||||
")
|
||||
->join('policy_transaction', 'policy_transaction.client_id = clients.id')
|
||||
->join('insurers', 'policy_transaction.insurer_id = insurers.id')
|
||||
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('clients.is_active', 1)
|
||||
->where('clients.email IS NOT NULL')
|
||||
->where('clients.email', $email_id)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
// print_r($emp_retail_policy_data); die;
|
||||
// print_r($this->clientModel->getLastQuery()); die;
|
||||
|
||||
$complete_emp_retail_policy_data = array_values(
|
||||
array_column(
|
||||
|
||||
@ -375,7 +375,7 @@ class NotificationController extends AdminController
|
||||
// Insert file attachment record
|
||||
if ($this->MailAttachmentModel->insert($data)) {
|
||||
// Retrieve active attachments to return in response
|
||||
$attachment_data = $this->MailAttachmentModel->where('is_active', 1)->findAll();
|
||||
$attachment_data = $this->MailAttachmentModel->where('notification_id', $find_notification['id'])->where('is_active', 1)->findAll()??[];
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
|
||||
@ -994,6 +994,7 @@
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
// $data['client_kyc_single_table'] = $clientController->generateKycSingleTable($data['client_id']);
|
||||
$data['entity_type_id'] = $client_data['entity_type_id'];
|
||||
|
||||
return $this->respondSuccess($insert, "Policy transaction created successfully", $data);
|
||||
@ -1056,6 +1057,7 @@
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
// $data['client_kyc_single_table'] = $clientController->generateKycSingleTable($data['client_id']);
|
||||
|
||||
$data['entity_type_id'] = $client_data['entity_type_id'];
|
||||
|
||||
@ -1624,6 +1626,8 @@
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
$data['client_kyc_single_table'] = $clientController->generateKycSingleTable($data['client_id']);
|
||||
$data['client_kyc_dd_data'] = $clientController->fetch_dropdown($data['client_id']);
|
||||
|
||||
$data['vehicle_docs'] = $this->clientKYCDocsModel
|
||||
->where('client_id', $data['client_id'])
|
||||
@ -1894,6 +1898,7 @@
|
||||
$clientController = new ClientController();
|
||||
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
|
||||
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
|
||||
$data['client_kyc_single_table'] = $clientController->generateKycSingleTable($data['client_id']);
|
||||
|
||||
$data['vehicle_docs'] = $this->clientKYCDocsModel
|
||||
->where('client_id', $data['client_id'])
|
||||
|
||||
@ -339,7 +339,7 @@ class RestAuthenticationController extends AdminController
|
||||
public function updateEmpMPIN()
|
||||
{
|
||||
try {
|
||||
log_message('info', 'MPIN update request received.');
|
||||
log_message('error', 'MPIN update request received.');
|
||||
|
||||
$requestData = $this->request->getJSON();
|
||||
log_message('debug', 'Request data: ' . json_encode($requestData));
|
||||
@ -361,7 +361,7 @@ class RestAuthenticationController extends AdminController
|
||||
$updated = $this->employeeModel->where('id', $employee_id)->set(['mpin' => $mpin])->update();
|
||||
|
||||
if ($updated) {
|
||||
log_message('info', "MPIN updated successfully for employee ID: {$employee_id}");
|
||||
log_message('error', "MPIN updated successfully for employee ID: {$employee_id}");
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'MPIN updated successfully.'
|
||||
@ -1283,7 +1283,7 @@ class RestAuthenticationController extends AdminController
|
||||
// Step 2: Fetch employee data
|
||||
if ($mobile_number) {
|
||||
|
||||
log_message('info', 'Looking up employee by mobile number: ' . $mobile_number);
|
||||
log_message('error', 'Looking up employee by mobile number: ' . $mobile_number);
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
@ -1302,7 +1302,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
} else {
|
||||
|
||||
log_message('info', 'Looking up employee by email: ' . $email_id);
|
||||
log_message('error', 'Looking up employee by email: ' . $email_id);
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
@ -1343,7 +1343,7 @@ class RestAuthenticationController extends AdminController
|
||||
->update();
|
||||
|
||||
if ($updated) {
|
||||
log_message('info', 'MPIN reset successful for employee ID: ' . $employeeData['id']);
|
||||
log_message('error', 'MPIN reset successful for employee ID: ' . $employeeData['id']);
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
@ -1416,7 +1416,7 @@ class RestAuthenticationController extends AdminController
|
||||
'status' => 'failed',
|
||||
'message' => 'Mobile number or Email ID is required.',
|
||||
'data' => [],
|
||||
], 400);
|
||||
], 200);
|
||||
}
|
||||
|
||||
if (!empty($mobile_number)) {
|
||||
@ -1477,8 +1477,9 @@ class RestAuthenticationController extends AdminController
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'message' => 'No employee found.',
|
||||
'code' => 404,
|
||||
'data' => [],
|
||||
], 404);
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function logHrActivity()
|
||||
@ -1775,7 +1776,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Verified employee found");
|
||||
|
||||
// ✅ Log authentication info
|
||||
// ✅ Log authentication error
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$this->authHistoryModel->insert([
|
||||
@ -2042,4 +2043,247 @@ class RestAuthenticationController extends AdminController
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRetailUserData()
|
||||
{
|
||||
$params = $this->request->getJSON(true);
|
||||
// print_r( $params); die;
|
||||
|
||||
$mobile_number = $params['mobile_number'] ?? null;
|
||||
$email_id = $params['email_id'] ?? null;
|
||||
$otp = $params['otp'] ?? null;
|
||||
$old_mpin = $params['old_mpin'] ?? null;
|
||||
|
||||
if (empty($mobile_number) && empty($email_id)) {
|
||||
return $this->respond(['status' => 'failed', 'message' => 'Mobile number or Email ID is required.', 'data' => [],], 200);
|
||||
}
|
||||
|
||||
if (!empty($mobile_number)) {
|
||||
|
||||
$builder = $this->clientModel
|
||||
->select('clients.*')
|
||||
->join('policy_transaction', 'policy_transaction.client_id = clients.id')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('clients.is_active', 1)
|
||||
->where('clients.phone', $mobile_number);
|
||||
|
||||
if (!empty($otp)) {
|
||||
$builder->where('clients.otp', $otp);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$builder->where('clients.mpin', $old_mpin);
|
||||
}
|
||||
|
||||
$retailUserData = $builder->orderBy('clients.id', 'desc')->first();
|
||||
} else {
|
||||
|
||||
$builder = $this->clientModel
|
||||
->select('clients.*')
|
||||
->join('policy_transaction', 'policy_transaction.client_id = clients.id')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('clients.is_active', 1)
|
||||
->where('clients.email', $email_id);
|
||||
|
||||
if (!empty($otp)) {
|
||||
$builder->where('clients.otp', $otp);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$builder->where('clients.mpin', $old_mpin);
|
||||
}
|
||||
|
||||
$retailUserData = $builder->orderBy('clients.id', 'desc')->first();
|
||||
}
|
||||
|
||||
if ($retailUserData) {
|
||||
return $this->respond(['status' => 'success', 'data' => $retailUserData,], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'failed', 'message' => 'No employee found.', 'code' => 404, 'data' => [],], 200);
|
||||
}
|
||||
|
||||
public function updateRetailUserAuthDetails()
|
||||
{
|
||||
try {
|
||||
|
||||
log_message('error', 'Retail Auth Update Request Received');
|
||||
|
||||
$requestData = $this->request->getJSON();
|
||||
|
||||
$client_id = $requestData->client_id ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$otp = $requestData->otp ?? null;
|
||||
$mpin = $requestData->mpin ?? null;
|
||||
$password = $requestData->password ?? null;
|
||||
|
||||
/** Check if at least one identification exists */
|
||||
if (!$client_id && !$email_id && !$mobile_number) {
|
||||
log_message('error', 'Identification missing: Need client_id or mobile/email.');
|
||||
return $this->respond(['status' => false,'message' => 'client_id, email or mobile number is required.']);
|
||||
}
|
||||
|
||||
/** Find client by ID or Email or Mobile */
|
||||
$clientQuery = $this->clientModel->where('is_active', 1);
|
||||
|
||||
if ($client_id) {
|
||||
$clientQuery->where('id', $client_id);
|
||||
} elseif ($email_id) {
|
||||
$clientQuery->where('email', $email_id);
|
||||
} elseif ($mobile_number) {
|
||||
$clientQuery->where('phone', $mobile_number);
|
||||
}
|
||||
|
||||
$clientData = $clientQuery->get()->getRowArray();
|
||||
|
||||
/** If no client found, return error */
|
||||
if (!$clientData) {
|
||||
log_message('error', 'Client not found for given identifier.');
|
||||
return $this->respond(['status' => false,'message' => 'Client not found.']);
|
||||
}
|
||||
|
||||
/** Now update fields that exist in request */
|
||||
$updateData = [];
|
||||
|
||||
if ($otp) {
|
||||
$updateData['otp'] = $otp;
|
||||
}
|
||||
|
||||
if ($mpin) {
|
||||
$updateData['mpin'] = password_hash($mpin, PASSWORD_DEFAULT); // Secure MPIN Hash
|
||||
}
|
||||
|
||||
if ($password) {
|
||||
$updateData['password'] = password_hash($password, PASSWORD_DEFAULT); // Secure Password Hash
|
||||
}
|
||||
|
||||
/** If nothing to update */
|
||||
if (empty($updateData)) {
|
||||
log_message('error', 'No valid fields to update (OTP/MPIN/Password missing)');
|
||||
return $this->respond(['status' => false,'message' => 'No valid credentials provided for update.']);
|
||||
}
|
||||
|
||||
/** Update */
|
||||
$updated = $this->clientModel->where('id', $clientData['id'])->set($updateData)->update();
|
||||
|
||||
if ($updated) {
|
||||
log_message('error', "Credentials updated successfully for Client ID: {$clientData['id']}");
|
||||
return $this->respond(['status' => true,'message' => 'Credentials updated successfully.']);
|
||||
} else {
|
||||
log_message('error', "Failed updating credentials for Client ID: {$clientData['id']}");
|
||||
return $this->respond(['status' => false,'message' => 'Failed to update credentials.']);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
log_message('error', 'Exception in updateRetailAuthDetails: ' . $e->getMessage());
|
||||
return $this->respond(['status' => false,'message' => 'Unexpected error occurred.','error' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getVerifiedRetailUserData()
|
||||
{
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedRetailUserData: Received payload = " . json_encode($this->request->getJSON() ?? []));
|
||||
|
||||
try {
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
|
||||
if(empty($otp)){
|
||||
return $this->respond(['status' => 'OTP is required','code' => 400,'message' => 'OTP is required'], 200);
|
||||
}
|
||||
|
||||
if (empty($mobile_number) && empty($email_id)) {
|
||||
return $this->respond(['status' => 'failed','code' => 400,'message' => 'Mobile number or Email ID is required'], 200);
|
||||
}
|
||||
|
||||
if (!empty($mobile_number)) {
|
||||
|
||||
$builder = $this->clientModel
|
||||
->select('clients.*')
|
||||
->join('policy_transaction', 'policy_transaction.client_id = clients.id')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('clients.is_active', 1)
|
||||
->where('clients.phone', $mobile_number);
|
||||
|
||||
if (!empty($otp)) {
|
||||
$builder->where('clients.otp', $otp);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$builder->where('clients.mpin', $old_mpin);
|
||||
}
|
||||
|
||||
$retailUserData = $builder->orderBy('clients.id', 'desc')->first();
|
||||
} else {
|
||||
|
||||
$builder = $this->clientModel
|
||||
->select('clients.*')
|
||||
->join('policy_transaction', 'policy_transaction.client_id = clients.id')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('clients.is_active', 1)
|
||||
->where('clients.email', $email_id);
|
||||
|
||||
if (!empty($otp)) {
|
||||
$builder->where('clients.otp', $otp);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$builder->where('clients.mpin', $old_mpin);
|
||||
}
|
||||
|
||||
$retailUserData = $builder->orderBy('clients.id', 'desc')->first();
|
||||
}
|
||||
|
||||
$lastQuery = $this->clientModel->db->getLastQuery();
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedRetailUserData: Last Executed Query: " . $lastQuery);
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedRetailUserData: retailUserData: " . json_encode($retailUserData ?? []));
|
||||
|
||||
|
||||
if ($retailUserData && isset($this->request->getJSON()->otp) )
|
||||
{
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
'user_id' => $retailUserData['id'],
|
||||
'user_type' => 'retail_user',
|
||||
'ip' => $auth['ip'],
|
||||
'platform' => $auth['platform'],
|
||||
'broswer' => $auth['browser'],
|
||||
];
|
||||
$this->authHistoryModel->insert($data);
|
||||
}
|
||||
|
||||
$retailUserData['client_id'] = null;
|
||||
$retailUserData['client_branch_id'] = null;
|
||||
$retailUserData['emp_code'] = null;
|
||||
$retailUserData['emp_status'] = null;
|
||||
$retailUserData['name'] = $retailUserData['client_name'];
|
||||
$retailUserData['email_corporate'] = $retailUserData['email'];
|
||||
$retailUserData['mobile'] = $retailUserData['phone'];
|
||||
$retailUserData['token_type'] = "retail";
|
||||
$result = JWTToken::encode($retailUserData);
|
||||
|
||||
if(isset($this->request->getJSON()->otp)){
|
||||
$this->clientModel->where('id', $retailUserData['id'])->where('otp', $otp)->set(['otp'=>null])->update();
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedRetailUserData: Reset the otp to null");
|
||||
}
|
||||
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedRetailUserData: Employee not verified POST");
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "", 'message' => 'Invalid OTP'],200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedRetailUserData: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString());
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => "Invalid OTP", 'error' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -41,6 +41,7 @@ class ClientModel extends Model
|
||||
"mail_domain",
|
||||
"addon_subheading",
|
||||
"parent_client_id",
|
||||
"otp",
|
||||
];
|
||||
|
||||
|
||||
|
||||
322
app/Views/client_kyc_2.php
Executable file
322
app/Views/client_kyc_2.php
Executable file
@ -0,0 +1,322 @@
|
||||
<style> .card-body{ margin-top: 0px !important; } </style>
|
||||
|
||||
<div class="tab-pane fade" id="KYC-DOC-tab">
|
||||
|
||||
<div id="others">
|
||||
<div class="col-lg-12 col-sm-12 col-md-12">
|
||||
<div class="card" style="margin-bottom: unset">
|
||||
<div class="card-body"
|
||||
style="margin-top: 0px !important;
|
||||
margin-bottom: 0px !important;
|
||||
padding-top: 0px !important;
|
||||
padding-bottom: 0px !important;">
|
||||
<h3>Documents</h3>
|
||||
<form role="form" class="parsley-examples" method="post" id="kyc_form_add"
|
||||
enctype="multipart/form-data">
|
||||
<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="">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="document_select">Document Name<span class="text-danger">*</span></label>
|
||||
<select class="form-control document-select" id="docs_type_id" name="docs_type_id" required onchange="handleDocumentSelectChange(this)">
|
||||
<option value="">Select Document</option>
|
||||
<option value="other">Additional Document</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 other-docs-name-group" style="display:none;">
|
||||
<label for="other_docs_name">Enter Document Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control other-docs-name-input" name="other_docs_name" placeholder="Enter file name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 file-input-group">
|
||||
<label for="file_input">Browser File<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control file-input" id="kyc_docs_file" name="file_name" required accept=".pdf, .jpeg, .jpg, .png"
|
||||
style="box-shadow: none !important; outline: none !important; border: none; height: unset !important;padding: 0px !important;background: transparent !important;">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" style="<?= isset($client['id']) ? 'margin-top: 41px;' : 'margin-top: 30px;' ?>">
|
||||
<button type="submit" class="btn btn-sm waves-effect waves-light mr-1"id="btnSubmit">Save</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end col-->
|
||||
</div> <!-- end row -->
|
||||
<div class="col-lg-12">
|
||||
<div class="card" id="collapseOne">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="second-table" id="kyc_table" class="table table-sm mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>S. No</th>
|
||||
<th>Document Name</th>
|
||||
<th>File Name</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
<?= isset($client_kyc_single_table) ? $client_kyc_single_table : "" ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col -->
|
||||
|
||||
</div>
|
||||
<!-- end -->
|
||||
|
||||
|
||||
<script>
|
||||
var kycPrimaryKey = $('#client_id_kyc').val();
|
||||
|
||||
function handleDocumentSelectChange(selectElement) {
|
||||
var $row = $(selectElement).closest('.form-row');
|
||||
var $otherDocsGroup = $row.find('.other-docs-name-group');
|
||||
var $otherDocsInput = $row.find('.other-docs-name-input');
|
||||
var $fileInputGroup = $row.find('.file-input-group');
|
||||
if (selectElement.value === 'other') {
|
||||
$otherDocsGroup.removeClass('d-none').show();
|
||||
$otherDocsInput.prop('required', true);
|
||||
$fileInputGroup.removeClass('col-md-3 col-md-4').addClass('col-md-3');
|
||||
} else {
|
||||
$otherDocsGroup.addClass('d-none').hide();
|
||||
$otherDocsInput.prop('required', false).val('');
|
||||
$fileInputGroup.removeClass('col-md-3 col-md-4').addClass('col-md-4');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Attach the change handler to all dropdowns
|
||||
$(document).on('change', '.document-select', function() {
|
||||
handleDocumentSelectChange(this);
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#kyc_form_add")[0].reset();
|
||||
kycPrimaryKey = $('#kyc_PrimaryKey').val();
|
||||
$('.document-select').each(function() {
|
||||
handleDocumentSelectChange(this);
|
||||
});
|
||||
})
|
||||
|
||||
// ADD BUTTON---
|
||||
$('#kyc_form_add').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var docSelect = $('#docs_type_id');
|
||||
var fileInput = $('#kyc_docs_file');
|
||||
|
||||
if (docSelect.val() === '' || fileInput[0].files.length === 0) {
|
||||
toastr.error("Please select a document name and browser a file.");
|
||||
return;
|
||||
}
|
||||
addKycDoc();
|
||||
});
|
||||
|
||||
// ADD Functionality ---
|
||||
function addKycDoc() {
|
||||
|
||||
var form = document.getElementById('kyc_form_add');
|
||||
var formData = new FormData(form);
|
||||
|
||||
var docTypeVal = $('#docs_type_id').val();
|
||||
|
||||
// ✅ Correct handling
|
||||
if (docTypeVal === 'other') {
|
||||
formData.set('kyc_doc_type_id', '');
|
||||
formData.set('other_docs_name', $('.other-docs-name-input').val());
|
||||
} else {
|
||||
formData.set('kyc_doc_type_id', docTypeVal);
|
||||
formData.set('other_docs_name', '');
|
||||
}
|
||||
|
||||
formData.set('client_id', $('#client_id_kyc').val());
|
||||
formData.set('is_active', 1);
|
||||
|
||||
var fileInput = $('#kyc_docs_file')[0].files[0];
|
||||
if (fileInput) {
|
||||
formData.set('file_name', fileInput);
|
||||
}
|
||||
|
||||
$('.loader').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/kyc/create_2"); ?>',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
|
||||
success: function (res) {
|
||||
$('.loader').fadeOut();
|
||||
|
||||
if (res.status) {
|
||||
$('#other_docs').html(res.data);
|
||||
toastr.success('Document added successfully');
|
||||
$('.other-docs-name-group').addClass('d-none');
|
||||
$('.other-docs-name-input').val('');
|
||||
$('#docs_type_id').empty();
|
||||
$('#docs_type_id').append(res.dropdown);
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.html);
|
||||
$('#kyc_form_add')[0].reset();
|
||||
|
||||
|
||||
} else {
|
||||
toastr.warning('Failed to add document');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('.loader').fadeOut();
|
||||
toastr.error('Upload error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// EDIT BUTTON---
|
||||
$(document).on('click', '.btn-edit-kyc', function() {
|
||||
let id = $(this).data('id');
|
||||
$(`#data_row_${id}`).addClass('d-none');
|
||||
$(`#edit_row_${id}`).removeClass('d-none');
|
||||
});
|
||||
|
||||
// CANCEL BUTTON IN EDIT ---
|
||||
$(document).on('click', '.btn-cancel-kyc', function() {
|
||||
let id = $(this).data('id');
|
||||
$(`#edit_row_${id}`).addClass('d-none');
|
||||
$(`#data_row_${id}`).removeClass('d-none');
|
||||
$(`#kyc_form_${id}`)[0].reset();
|
||||
});
|
||||
|
||||
// UPDATE CLICK HANDLER ---
|
||||
$(document).on('click', '.btn-update-kyc', function() {
|
||||
let id = $(this).data('id');
|
||||
var client_id = $(this).data('client_id');
|
||||
var formElement = $(this).closest('form')[0]; // Fails if button isn't inside the form
|
||||
updateKycDocWithForm(formElement, client_id);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// UPDATE Functionality ---
|
||||
function updateKycDocWithForm(formElement, client_id) {
|
||||
|
||||
var formData = new FormData(formElement); // Use the element directly
|
||||
formData.set('client_id', client_id);
|
||||
let id = formData.get('id');
|
||||
|
||||
let fileInput = $(`#kyc_docs_file_${id}`)[0].files[0];
|
||||
if (!fileInput) { console.log("file input not available here"); }
|
||||
|
||||
$('.loader').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/kyc/edit_2"); ?>',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
|
||||
success: function (res) {
|
||||
$('.loader').fadeOut();
|
||||
|
||||
if (res.status) {
|
||||
|
||||
$(`#edit_row_${id}`).addClass('d-none');
|
||||
$(`#data_row_${id}`).removeClass('d-none');
|
||||
|
||||
$('#docs_type_id').empty();
|
||||
$('#docs_type_id').append(res.dropdown);
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.html);
|
||||
toastr.success('Document updated successfully');
|
||||
} else {
|
||||
toastr.warning('Update failed: ' + (res.message || 'Server did not return a status message'));
|
||||
}
|
||||
},
|
||||
|
||||
error: function (xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
toastr.error('Server error: Check server logs for details.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// SOFT DELETE CLICK HANDLER ---
|
||||
$(document).on('click', '.btn-delete-kyc', function () {
|
||||
|
||||
var kyc_id = $(this).attr('data-id');
|
||||
var client_id = $(this).attr('data-client_id');
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, delete it!"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
deleteKycDoc(kyc_id, client_id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// SOFT DELETE Functionality ---
|
||||
function deleteKycDoc(kyc_id,client_id) {
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('is_active', 0);
|
||||
formData.append('id', kyc_id);
|
||||
formData.append('client_id', client_id);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/kyc/delete_2"); ?>',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
|
||||
success: function (res) {
|
||||
$('.loader').fadeOut();
|
||||
if (res.status) {
|
||||
$('#docs_type_id').empty();
|
||||
$('#docs_type_id').append(res.dropdown);
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.html);
|
||||
toastr.success('Document deleted successfully');
|
||||
} else {
|
||||
toastr.warning('Delete failed: ' + (res.message || 'Server error.'));
|
||||
}
|
||||
},
|
||||
|
||||
error: function () {
|
||||
$('.loader').fadeOut();
|
||||
toastr.error('Server error!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
70
app/Views/client_kyc_single_table.php
Normal file
70
app/Views/client_kyc_single_table.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php if (empty($ckdlist)) : ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted">No data found</td>
|
||||
</tr>
|
||||
<?php else : ?>
|
||||
<?php foreach ($ckdlist as $index => $value) :
|
||||
$sno = $index + 1;
|
||||
$fileName = !empty($value['file_name']) ? $value['file_name'] : '-';
|
||||
?>
|
||||
<tr id="data_row_<?= $value['id'] ?>">
|
||||
<td><?= $sno ?></td>
|
||||
<td><?= esc($value['ui_docs_name']) ?></td>
|
||||
<td><?= esc($fileName) ?></td>
|
||||
<td>
|
||||
<a id="download_<?= esc($value['id']); ?>" data-id="<?= esc($value['id']); ?>" data-file="<?= $fileName ?>"
|
||||
class="mdi mdi-download mr-1 btn-download-kyc" style="font-size:18px;" download></a>
|
||||
|
||||
<a class="mdi mdi-pencil mr-1 btn-edit-kyc"
|
||||
data-id="<?= $value['id'] ?>"
|
||||
data-client_id="<?= $value['client_id'] ?>"
|
||||
data-old_file_name="<?= $fileName ?>"
|
||||
data-kyc_doc_type_id="<?= $value['kyc_doc_type_id'] ?>"
|
||||
style="font-size:18px;"></a>
|
||||
|
||||
<a class="mdi mdi-delete mr-1 btn-delete-kyc"
|
||||
data-id="<?= $value['id'] ?>"
|
||||
style="font-size:18px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- ✅ EDIT ROW -->
|
||||
<tr id="edit_row_<?= $value['id'] ?>" class="d-none">
|
||||
<td colspan="4">
|
||||
<form id="kyc_form_<?= $value['id'] ?>" class="kyc-edit-form">
|
||||
<input type="hidden" name="id" value="<?= $value['id'] ?>">
|
||||
<input type="hidden" name="client_id" value="<?= $value['client_id'] ?>">
|
||||
<input type="hidden" name="old_file_name" value="<?= $fileName ?>">
|
||||
|
||||
<div class="row align-items-end">
|
||||
<div class="col-md-8">
|
||||
<label>
|
||||
Change File - <?= esc($value['ui_docs_name']) ?>
|
||||
(<?= esc($fileName) ?>)
|
||||
</label>
|
||||
<input type="file"
|
||||
name="file_name"
|
||||
id="kyc_docs_file_<?= $value['id'] ?>"
|
||||
class="form-control"
|
||||
style="box-shadow:none!important; outline:none!important; border:none; height:unset!important;padding: 0px !important;background: transparent !important;">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-primary btn-sm btn-update-kyc w-100"
|
||||
data-id="<?= $value['id'] ?>"
|
||||
data-client_id="<?= $value['client_id'] ?>">Update</button>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button"
|
||||
class="btn btn-secondary btn-sm btn-cancel-kyc w-100"
|
||||
data-id="<?= $value['id'] ?>">
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
@ -1890,9 +1890,9 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy</a>
|
||||
</li>
|
||||
<li>
|
||||
<!-- <li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list2') ?>">Policy 2</a>
|
||||
</li>
|
||||
</li> -->
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/endorsement/list') ?>">Endorsement</a>
|
||||
</li>
|
||||
@ -2040,6 +2040,14 @@
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
<?php if (in_array(get_role_id(), [1, 5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list2') ?>">
|
||||
<i class="ri-barcode-line"></i>
|
||||
<span> Policy 2</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -873,8 +873,8 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
<div class="form-group d-flex justify-content-end m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -1788,7 +1788,7 @@
|
||||
|
||||
if (res.status == true) {
|
||||
|
||||
hide_list_show_add();
|
||||
hide_list_show_add_2();
|
||||
|
||||
var page_title = 'Edit Policy' + (res.data.client_short_name || res.data.policy_type || res.data.policy_no ?
|
||||
' - ' + [res.data.client_short_name, res.data.policy_type, res.data.policy_no]
|
||||
@ -1811,12 +1811,140 @@
|
||||
// getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||||
// appendKycTableListData(res.data.client_kyc);
|
||||
|
||||
|
||||
// please don't forgot this ==> look at here please don't don't forgot
|
||||
$('#docs_type_id').empty(); // ✅ clear old options
|
||||
$('#docs_type_id').append(res.data.client_kyc_dd_data);
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(res.data.client_kyc_primary_table);
|
||||
$('#tbody').append(res.data.client_kyc_single_table);
|
||||
|
||||
$('#other_docs').empty();
|
||||
$('#other_docs').append(res.data.client_kyc_other_table);
|
||||
|
||||
// let tbody = $('#tbody');
|
||||
// tbody.empty(); // ✅ Always clear first
|
||||
|
||||
// let ckdlist = res.data.client_kyc_document_list;
|
||||
|
||||
// if (!ckdlist || ckdlist.length === 0) {
|
||||
|
||||
// // ✅ Show single merged row when no data
|
||||
// let emptyRow = `
|
||||
// <tr>
|
||||
// <td colspan="4" class="text-center text-muted">
|
||||
// No data found
|
||||
// </td>
|
||||
// </tr>
|
||||
// `;
|
||||
|
||||
// tbody.append(emptyRow);
|
||||
// // return; // ✅ Stop further execution
|
||||
// }
|
||||
// else{
|
||||
// $.each(ckdlist, function (index, value) {
|
||||
|
||||
// let sno = index + 1;
|
||||
|
||||
// // ✅ If kyc_doc_type_id is null → use other_docs_name
|
||||
// let docName = (value.kyc_doc_type_id === null || value.kyc_doc_type_id === '')
|
||||
// ? value.other_docs_name
|
||||
// : value.kyc_doc_type_id;
|
||||
|
||||
// let fileName = value.file_name ? value.file_name : '-';
|
||||
|
||||
// let downloadBtn = `
|
||||
// <a id="download_${value.id}"
|
||||
// data-id="${value.id}"
|
||||
// data-file="${value.file_name}"
|
||||
// class="mdi mdi-download mr-1 btn-download-kyc"
|
||||
// style="font-size:18px;">
|
||||
// </a>
|
||||
// `;
|
||||
|
||||
// // Inside your $.each(list, function (index, value) { ... }) loop
|
||||
// let editBtn = `<a href="javascript:void(0);"
|
||||
// id="edit_${value.id}"
|
||||
// class="mdi mdi-pencil mr-1 btn-edit-kyc"
|
||||
// style="font-size:18px;"
|
||||
// data-id="${value.id}"
|
||||
// data-client_id="${value.client_id}"
|
||||
// data-old_file_name="${value.file_name}"
|
||||
// data-kyc_doc_type_id="${value.kyc_doc_type_id}">
|
||||
// </a>`;
|
||||
|
||||
// // The edit UI block to be toggled
|
||||
// let editUI = `
|
||||
// <tr id="edit_row_${value.id}" class="d-none">
|
||||
// <td colspan="4">
|
||||
// <form id="kyc_form_${value.id}" class="kyc-edit-form">
|
||||
// <input type="hidden" id="kyc_id_${value.id}" name="id" value="${value.id}">
|
||||
// <input type="hidden" id="client_id_${value.id}" name="client_id" value="${value.client_id}">
|
||||
// <input type="hidden" id="old_file_name_${value.id}" name="old_file_name" value="${value.file_name}">
|
||||
|
||||
// <div class="row align-items-end">
|
||||
|
||||
// <div class="col-md-8">
|
||||
// <label for="kyc_docs_file_${value.id}">Change File - ${value.ui_docs_name} (${fileName}) </label>
|
||||
// <input type="file"
|
||||
// id="kyc_docs_file_${value.id}"
|
||||
// name="file_name"
|
||||
// class="form-control"
|
||||
// style="box-shadow:none!important;
|
||||
// outline:none!important;
|
||||
// border:none;
|
||||
// height:unset!important;
|
||||
// padding:0!important;
|
||||
// background:transparent!important;">
|
||||
// </div>
|
||||
|
||||
// <div class="col-md-2">
|
||||
// <button type="button"
|
||||
// class="btn btn-primary btn-sm btn-update-kyc w-100"
|
||||
// data-id="${value.id}">
|
||||
// Update
|
||||
// </button>
|
||||
// </div>
|
||||
|
||||
// <div class="col-md-2">
|
||||
// <button type="button"
|
||||
// class="btn btn-secondary btn-sm btn-cancel-kyc w-100"
|
||||
// data-id="${value.id}">
|
||||
// Cancel
|
||||
// </button>
|
||||
// </div>
|
||||
|
||||
// </div>
|
||||
|
||||
// </form>
|
||||
// </td>
|
||||
// </tr>
|
||||
// `;
|
||||
|
||||
|
||||
|
||||
// let deleteBtn = `
|
||||
// <a id="delete_${value.id}"
|
||||
// data-id="${value.id}"
|
||||
// class="mdi mdi-delete mr-1 btn-delete-kyc"
|
||||
// style="font-size:18px;"
|
||||
// download>
|
||||
// </a>`;
|
||||
|
||||
// let row = `
|
||||
// <tr id="data_row_${value.id}"> <td>${sno}</td>
|
||||
// <td>${value.ui_docs_name}</td>
|
||||
// <td>${fileName}</td>
|
||||
// <td>
|
||||
// ${downloadBtn}
|
||||
// ${editBtn}
|
||||
// ${deleteBtn}
|
||||
// </td>
|
||||
// </tr>
|
||||
// ${editUI} `;
|
||||
|
||||
// tbody.append(row);
|
||||
// });
|
||||
// }
|
||||
// // docs_type_id
|
||||
// // res.data.client_kyc_dd_data
|
||||
|
||||
// Setting values to correct fields
|
||||
$('#policy_tranction_primarykey').val(res.data.id);
|
||||
@ -1888,6 +2016,7 @@
|
||||
|
||||
|
||||
if (res.data.pt_co_share_details) {
|
||||
if (!res.data.pt_co_share_details[0].follower_policy_no) {res.data.pt_co_share_details[0].follower_policy_no = res.data.policy_no;}
|
||||
setTimeout(function() {
|
||||
// populateTable(res.data.pt_co_share_details, res.data.cd_ac_pk);
|
||||
populateCards(res.data.pt_co_share_details, res.data.cd_ac_pk);
|
||||
@ -1985,7 +2114,7 @@
|
||||
$('#cop_yes').prop('checked', true);
|
||||
$('.add-insurer-button').removeClass('d-none');
|
||||
$('.payby').removeClass('d-none');
|
||||
$('.card_group_2').removeClass('d-none');
|
||||
$('.card_group_2').show();
|
||||
$('.card_group_3').removeClass('d-none');
|
||||
$('.card_group_7').removeClass('d-none');
|
||||
$('.card_group_35').removeClass('d-none');
|
||||
@ -1993,7 +2122,7 @@
|
||||
$('#cop_yes').prop('checked', false);
|
||||
$('.add-insurer-button').addClass('d-none');
|
||||
$('.payby').addClass('d-none');
|
||||
$('.card_group_2').addClass('d-none');
|
||||
$('.card_group_2').hide();
|
||||
$('.card_group_3').addClass('d-none');
|
||||
$('.card_group_7').addClass('d-none');
|
||||
$('.card_group_35').addClass('d-none');
|
||||
@ -3202,7 +3331,6 @@
|
||||
}
|
||||
});
|
||||
}else{
|
||||
console.error('Client type Not found')
|
||||
console.log('client_type', client_type);
|
||||
}
|
||||
}else{
|
||||
@ -3547,7 +3675,7 @@
|
||||
|
||||
if (res.data.pt_co_share_details && res.data.pt_co_share_details.length > 0) {
|
||||
|
||||
$('#tab_content').empty()
|
||||
// $('#tab_content').empty()
|
||||
count = 0
|
||||
$.each(res.data.pt_co_share_details, function(index, item) {
|
||||
// appendNewTab(item);
|
||||
@ -3743,7 +3871,7 @@
|
||||
$('.card_group_2').show()
|
||||
$('.card_group_3').show()
|
||||
$('.card_group_7').show()
|
||||
$('.card_group_35').show()
|
||||
$('.card_group_35').removeClass('d-none');
|
||||
|
||||
var selectedOption = $('#policy_type_id').find('option:selected');
|
||||
var bap = selectedOption.data('bap');
|
||||
@ -3804,7 +3932,7 @@
|
||||
$('.card_group_2').hide()
|
||||
$('.card_group_3').hide()
|
||||
$('.card_group_7').hide()
|
||||
$('.card_group_35').hide()
|
||||
$('.card_group_35').addClass('d-none');
|
||||
$('.hidecoter').hide()
|
||||
$('.hidecotp').hide()
|
||||
|
||||
@ -4427,21 +4555,21 @@
|
||||
<div class="col-4"><label class="card_label_14">Agreed (%)</label></div>
|
||||
<div class="col-4 card_group_14">
|
||||
<div class="input-wrap mr-2">
|
||||
<span class="input-prefix">BP </span>
|
||||
<span class="input-prefix">BP </span>
|
||||
<input type="text" class="form-control right-align-input input-content" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="validateRange(this);" onkeypress="return onlyNumbers(event)">
|
||||
<span class="input-symbol">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 card_group_15 hidetp">
|
||||
<div class="input-wrap mr-2">
|
||||
<span class="input-prefix">TP </span>
|
||||
<span class="input-prefix">TP </span>
|
||||
<input type="text" class="form-control right-align-input input-content" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="validateRange(this);" onkeypress="return onlyNumbers(event)">
|
||||
<span class="input-symbol">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 card_group_16 hideter" style="display:none;">
|
||||
<div class="input-wrap">
|
||||
<span class="input-prefix">TEP </span>
|
||||
<span class="input-prefix">TEP </span>
|
||||
<input type="text" class="form-control right-align-input input-content" id="agreed_ter_${insurerCount}" name="agreed_ter[]" oninput="validateRange(this);" onkeypress="return onlyNumbers(event)">
|
||||
<span class="input-symbol">%</span>
|
||||
</div>
|
||||
@ -4504,21 +4632,21 @@
|
||||
<div class="col-4 card_group_24">
|
||||
<div class="input-wrap mr-2">
|
||||
<span class="input-prefix">BP </span>
|
||||
<input type="text" class="form-control readonly-select right-align-input input-content" id="actual_bp_amt_${insurerCount}" name="actual_bp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_amt_for_calc')" onkeypress="return onlyNumbers(event)">
|
||||
<input type="text" class="form-control readonly-select right-align-input input-content" id="actual_bp_per_${insurerCount}" name="actual_bp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_per')" onkeypress="return onlyNumbers(event)">
|
||||
<span class="input-symbol">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 card_group_22 hidetp">
|
||||
<div class="input-wrap mr-2">
|
||||
<span class="input-prefix">TP </span>
|
||||
<input type="text" class="form-control readonly-select right-align-input input-content" id="actual_tp_amt_${insurerCount}" name="actual_tp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_amt_for_calc')" onkeypress="return onlyNumbers(event)">
|
||||
<input type="text" class="form-control readonly-select right-align-input input-content" id="actual_tp_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_per')" onkeypress="return onlyNumbers(event)">
|
||||
<span class="input-symbol">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 card_group_23 hideter" style="display:none;">
|
||||
<div class="input-wrap">
|
||||
<span class="input-prefix">TEP </span>
|
||||
<input type="text" class="form-control readonly-select right-align-input input-content" id="actual_tep_amt_${insurerCount}" name="actual_tep_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_amt_for_calc')" onkeypress="return onlyNumbers(event)">
|
||||
<input type="text" class="form-control readonly-select right-align-input input-content" id="actual_tep_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_per')" onkeypress="return onlyNumbers(event)">
|
||||
<span class="input-symbol">%</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -4631,7 +4759,7 @@
|
||||
$('.card_group_2').show();
|
||||
$('.card_group_3').show();
|
||||
$('.card_group_7').show();
|
||||
$('.card_group_35').show();
|
||||
$('.card_group_35').removeClass('d-none');
|
||||
}
|
||||
|
||||
insurer_count_array.push(insurerCount);
|
||||
@ -4793,7 +4921,7 @@
|
||||
.change()
|
||||
.toggleClass('readonly-select', disable_td);
|
||||
|
||||
if (data.co_share_type == 1) {
|
||||
if ($('#cop_yes').is(':checked')) {
|
||||
$('.card_group_2').show();
|
||||
getCdAmount(cd_ac_pk, cardIndex);
|
||||
}
|
||||
@ -4932,7 +5060,7 @@
|
||||
console.log("Previous Page URL:", previousUrl);
|
||||
|
||||
if (pt_id != 0) {
|
||||
hide_list_show_add();
|
||||
hide_list_show_add_2();
|
||||
setTimeout(() =>
|
||||
getPolicyTransactionDataForEditPolicy(pt_id),
|
||||
1500); // Reduced timeout
|
||||
|
||||
@ -286,7 +286,7 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
|
||||
<div class="col-3" id="status_change" style="text-align: right; position: relative;top: 56px; left: 291px;">
|
||||
<!-- <button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add();">Add</button> -->
|
||||
<!-- <button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add_2();">Add</button> -->
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@ -575,7 +575,7 @@ $(document).ready(function() {
|
||||
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function (e, dt, node, config) {
|
||||
hide_list_show_add();
|
||||
hide_list_show_add_2();
|
||||
addInsurerColumn() ;
|
||||
}
|
||||
},
|
||||
@ -688,8 +688,9 @@ $(document).ready(function(){
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
function hide_list_show_add()
|
||||
{
|
||||
function hide_list_show_add_2()
|
||||
{
|
||||
$('#pt_onboarding2').show();
|
||||
$('#page_title').text('Add Policy')
|
||||
$('#inception_form_id')[0].reset();
|
||||
$('#client_id').val('').change().prop('disabled', false);
|
||||
@ -711,7 +712,7 @@ function hide_list_show_add()
|
||||
$('.current_date').hide()
|
||||
$('#invoice_no').attr('required', false)
|
||||
|
||||
$('#pt_onboarding').show()
|
||||
|
||||
$('#inception_list').hide()
|
||||
$('#inception_filter').hide()
|
||||
$('#policyholdernamediv').hide();
|
||||
@ -720,11 +721,12 @@ function hide_list_show_add()
|
||||
|
||||
function show_list_hide_add()
|
||||
{
|
||||
$('#pt_onboarding').hide()
|
||||
$('#pt_onboarding2').hide();
|
||||
$('#inception_list').show()
|
||||
$('#inception_filter').show();
|
||||
$('#nav_pills').empty()
|
||||
$('#tab_content').empty()
|
||||
$('#nav_pills').empty();
|
||||
// $('#tab_content').empty();
|
||||
|
||||
count = 0
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<div class="row" id="pt_onboarding" style="position: relative; bottom: 25px; display:none;">
|
||||
<div class="row" id="pt_onboarding2" style="position: relative; bottom: 25px;">
|
||||
<div class="col-xl-12">
|
||||
<div class="card-body">
|
||||
<div class="tab-wrapper position-relative">
|
||||
@ -38,10 +38,10 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-content">
|
||||
<?php include('policy_transaction_inception_form_2.php'); ?>
|
||||
<?php include('drive_file_upload.php'); ?>
|
||||
<?php include('client_kyc.php'); ?>
|
||||
<?php include('vehicle_docs.php'); ?>
|
||||
<?php include('drive_file_upload.php'); ?>
|
||||
<?php include('client_kyc_2.php'); ?>
|
||||
<?php include('policy_transaction_inception_form_2.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -49,8 +49,12 @@
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// $('#pt_onboarding2').show();
|
||||
// $('#general_tab').tab('show');
|
||||
|
||||
$('#kyc_tab').on('click', function(e) {
|
||||
var ptId = $('#policy_tranction_primarykey').val();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user