Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
89c97c24dc
@ -32,6 +32,8 @@ $routes->get("update-policy-terms-for-corrections", "ClientController::updatePol
|
||||
$routes->get("update_rack_rate_json", "ClientController::updateRackRateJson");
|
||||
$routes->get("updatajson", "EmpDataServiceController::updatajson");
|
||||
$routes->get("view", "EmployeeController::viewECard/$1");
|
||||
$routes->get("checkWellnessOnboardStatus/(:any)", "EmployeeController::checkWellnessOnboardStatus/$1");
|
||||
$routes->get("initiateWellnessOnboard/(:any)", "EmployeeController::initiateWellnessOnboard/$1");
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
$routes->get("smapletest", "ClientController::smapletest");
|
||||
$routes->get("testMailAttachments", "ClientController::testMailAttachments");
|
||||
@ -162,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) {
|
||||
@ -566,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');
|
||||
|
||||
@ -3213,4 +3213,367 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
public function checkWellnessOnboardStatus($client_policy_id)
|
||||
{
|
||||
// echo $client_policy_id;die();
|
||||
$data = $this->employeePolicyModel->select('employee_polices.*,emp.name,emp.relationship,emp.emp_code,emp.name,emp.email_corporate,emp.mobile,emp.dob,cp.policy_no,cp.wellness_plan_id,cp.wellness_vendor_id,cp.policy_start_date as cp_policy_start_date,cp.policy_end_date,cls.short_name')
|
||||
->join('client_policy cp', 'cp.id = employee_polices.client_policy_id')
|
||||
->join('clients cls', "cp.client_id = cls.id")
|
||||
->join('employees emp', "emp.id = employee_polices.employee_id")
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employee_polices.tpa_id is not null')
|
||||
->where('employee_polices.wellness_onboard', '0')
|
||||
->where('emp.emp_status', 'active')
|
||||
->where('emp.is_active', 1)
|
||||
->where('cp.wellness_plan_id is not null')
|
||||
->where('cp.wellness_vendor_id is null')
|
||||
// ->where('cp.policy_status',1)
|
||||
// ->where('cp.is_active',1)
|
||||
->findAll();
|
||||
// echo count($data);die();
|
||||
// if(is_array($data) && count($data))
|
||||
// {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => count($data)], 200);
|
||||
// }
|
||||
// return $this->respond(['status' => true, 'code' => 200, 'message' => 'Inception and Member data comparision skiped successfully!'], 200);
|
||||
}
|
||||
|
||||
public function initiateWellnessOnboard($client_policy_id)
|
||||
{
|
||||
$r = Jobs::addJob(['job_name' => 'initiateWellnessOnboardJob','payload' => ['client_policy_id' => $client_policy_id]]);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Process started'], 200);
|
||||
}
|
||||
|
||||
public function initiateWellnessOnboardJob($arr)
|
||||
{
|
||||
|
||||
$client_policy_id = $arr['client_policy_id'];
|
||||
// $this->updateWellnessOnboardResponseToDB();die();
|
||||
// echo $client_policy_id;die();
|
||||
$data = $this->employeePolicyModel->select('employee_polices.*,emp.name,emp.relationship,emp.emp_code,emp.name,emp.email_corporate,emp.mobile,emp.dob,cp.policy_no,cp.wellness_plan_id,cp.wellness_vendor_id,cp.policy_start_date as cp_policy_start_date,cp.policy_end_date,cls.short_name')
|
||||
->join('client_policy cp', 'cp.id = employee_polices.client_policy_id')
|
||||
->join('clients cls', "cp.client_id = cls.id")
|
||||
->join('employees emp', "emp.id = employee_polices.employee_id")
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employee_polices.tpa_id is not null')
|
||||
->where('employee_polices.wellness_onboard', '0')
|
||||
->where('emp.emp_status', 'active')
|
||||
->where('emp.is_active', 1)
|
||||
->where('cp.wellness_plan_id is not null')
|
||||
->where('cp.wellness_vendor_id is null')
|
||||
// ->where('cp.policy_status',1)
|
||||
// ->where('cp.is_active',1)
|
||||
->findAll();
|
||||
// print_r($this->employeePolicyModel->getLastQuery());
|
||||
// print_r($data);
|
||||
// echo '==============================';die();
|
||||
// $data = '[{"id":12847,"employee_id":"TEST_EMP_001","client_policy_id":null,"tpa_id":null,"uhid":null,"batch_code":null,"status":"active","pre_existing_alignments":null,"age_band":null,"basic_cover_si":"0","date_coverage":"2025-01-01","policy_end_date":"2025-12-31","days":"0","premium":"0","rata_premimum":"0","gst":"0","si_enhancement_date":null,"date_of_exit":null,"reason_for_exit":null,"claim_status":"0","created_by":null,"created_at":null,"updated_by":null,"updated_at":null,"is_active":"1","rand_string":null,"ecard_sent_status":"0","payable_employee":"0","file_id":null,"wellness_onboard":"0","name":"test name","relationship":"SELF","emp_code":"TEST_EMP_001","email_corporate":"test@gmail.com","mobile":"9797976565","dob":"1975-08-09"},{"id":12846,"employee_id":"TEST_EMP_001","client_policy_id":null,"tpa_id":null,"uhid":null,"batch_code":null,"status":"active","pre_existing_alignments":null,"age_band":null,"basic_cover_si":"0","date_coverage":"2025-01-01","policy_end_date":"2025-12-31","days":"0","premium":"0","rata_premimum":"0","gst":"0","si_enhancement_date":null,"date_of_exit":null,"reason_for_exit":null,"claim_status":"0","created_by":null,"created_at":null,"updated_by":null,"updated_at":null,"is_active":"1","rand_string":null,"ecard_sent_status":"0","payable_employee":"0","file_id":null,"wellness_onboard":"0","name":"dependent 1","relationship":"SON","emp_code":"TEST_EMP_001","email_corporate":"dependent1@gmail.com","mobile":"9898989898","dob":"2001-08-09"}]';
|
||||
// $data = (array)json_decode($data,true);
|
||||
// print_r($data);
|
||||
// echo '==============================';die();
|
||||
if(is_array($data) && count($data))
|
||||
{
|
||||
// $data = $input['data'] ?? [];
|
||||
|
||||
// ------------------ GROUP BY FAMILY (emp_code) ------------------
|
||||
$families = []; // [emp_code => [rows...]]
|
||||
|
||||
foreach ($data as $row) {
|
||||
if (empty($row['emp_code'])) {
|
||||
// If emp_code is missing, you can skip or handle separately
|
||||
continue;
|
||||
}
|
||||
|
||||
$empCode = $row['emp_code'];
|
||||
if (!isset($families[$empCode])) {
|
||||
$families[$empCode] = [];
|
||||
}
|
||||
$families[$empCode][] = $row;
|
||||
}
|
||||
|
||||
// ------------------ BUILD PAYLOAD FOR ALL FAMILIES ------------------
|
||||
$familiesPayload = [];
|
||||
|
||||
foreach ($families as $empCode => $members) {
|
||||
$familiesPayload[$empCode] = $this->buildFamilyPayload($empCode, $members);
|
||||
}
|
||||
|
||||
// print_r($familiesPayload);die();
|
||||
$apiResponse = $this->sendFamiliesToWellnessApi($familiesPayload);
|
||||
// print_r($apiResponse);
|
||||
$updatedData = $this->updateWellnessOnboardResponseToDB($apiResponse);
|
||||
// print_r($updatedData);die();
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->respond(['status' => false, 'code' => 200, 'message' => 'No employees found for wellness onboard!'], 200);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ------------------ FUNCTION TO BUILD FAMILY PAYLOAD ------------------
|
||||
/**
|
||||
* Build the required payload for a single family.
|
||||
*
|
||||
* @param string $empCode
|
||||
* @param array $members Array of rows for this emp_code
|
||||
* @return array
|
||||
*/
|
||||
private function buildFamilyPayload(string $empCode, array $members): array
|
||||
{
|
||||
// Use the first member as primary reference for policy level data
|
||||
$primary = $members[0];
|
||||
|
||||
// Map DB fields to your required "policyDetails" structure
|
||||
$policyStartDate = $primary['cp_policy_start_date'] ?? null;
|
||||
// $policyStartDate = '2025-01-01';
|
||||
$policyEndDate = $primary['policy_end_date'] ?? null;
|
||||
// $policyEndDate = '2025-12-31';
|
||||
|
||||
$payload = [
|
||||
"policyDetails" => [
|
||||
"policyNumber" => $primary["policy_no"] ?? null,
|
||||
"employeeId" => $empCode,
|
||||
"policyName" => "GMC", // Static or from DB
|
||||
"policyStartDate" => $policyStartDate,
|
||||
"policyEndDate" => $policyEndDate,
|
||||
"plan" => $primary["wellness_plan_id"] ?? null,
|
||||
"source" => $primary['short_name'] ?? null,
|
||||
"employer" => $primary['short_name'] ?? null,
|
||||
"employeeCode" => $empCode,
|
||||
"accountNumber" => "", // Fill from DB if available
|
||||
"ifsc" => "", // Fill from DB if available
|
||||
"accountType" => "" // Fill from DB if available
|
||||
],
|
||||
"memberDetails" => []
|
||||
];
|
||||
|
||||
// Build "memberDetails" for each member in this family
|
||||
foreach ($members as $index => $row) {
|
||||
|
||||
// You don't have gender in data, so put null or default
|
||||
$gender = null; // or "MALE" / "FEMALE" if you infer from somewhere
|
||||
|
||||
$payload["memberDetails"][] = [
|
||||
"memberId" => $row["id"], // or custom ID (e.g. employee_id.'-'.$index)
|
||||
"name" => $row["name"],
|
||||
"phone" => $row["mobile"],
|
||||
"email" => $row["email_corporate"],
|
||||
"relationshipName" => strtoupper($row["relationship"] ?? ''),
|
||||
"gender" => $gender,
|
||||
"dob" => $row["dob"]
|
||||
];
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Send each family payload to API and attach the response
|
||||
*
|
||||
* @param array $familiesPayload [emp_code => ['policyDetails' => ..., 'memberDetails' => [...]]]
|
||||
* @return array Same array but with ['apiResponse'] added for each family
|
||||
*/
|
||||
public function sendFamiliesToWellnessApi(array $familiesPayload): array
|
||||
{
|
||||
// CI4 HTTP client
|
||||
$client = \Config\Services::curlrequest();//die();
|
||||
$endpointUrl = getenv('WELLNESS_ONBOARD_ENDPOINT_URL');
|
||||
// Custom headers
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => 'Basic ' . getenv('WELLNESS_ONBOARD_AUTHORIZATION')
|
||||
];
|
||||
|
||||
foreach ($familiesPayload as $empCode => &$family) {
|
||||
|
||||
try {
|
||||
$response = $client->post($endpointUrl, [
|
||||
'headers' => $headers,
|
||||
'body' => json_encode($family),
|
||||
'http_errors' => false, // so we can handle non-2xx manually
|
||||
'timeout' => 30,
|
||||
]);
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
$body = (string) $response->getBody();
|
||||
$decoded = json_decode($body, true);
|
||||
|
||||
$family['apiResponse'] = [
|
||||
'statusCode' => $statusCode,
|
||||
'rawBody' => $body,
|
||||
'data' => $decoded,
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
// In case of exception, store error info
|
||||
$family['apiResponse'] = [
|
||||
'statusCode' => 0,
|
||||
'rawBody' => null,
|
||||
'data' => null,
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
unset($family); // break reference
|
||||
|
||||
return $familiesPayload;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Batch update wellness_onboard for each family using referenceId from API response.
|
||||
*
|
||||
* @param array $familiesWithResponse // output of sendFamiliesToApi()
|
||||
* @return void
|
||||
*/
|
||||
public function updateWellnessOnboardResponseToDB(array $familiesWithResponse = []): void
|
||||
{
|
||||
// echo 'START';
|
||||
// Collect all rows to update in a single big batch (optional but efficient)
|
||||
$allUpdates = [];
|
||||
|
||||
// $apiResponse = [
|
||||
// "message" => "success",
|
||||
// "body" => "The policy details are posted successfully",
|
||||
// "policyDetails" => [
|
||||
// [
|
||||
// "memberId" => "12847",
|
||||
// "name" => "test name",
|
||||
// "phone" => 9797976565,
|
||||
// "email" => "test@gmail.com",
|
||||
// "relationshipName" => "SELF",
|
||||
// "gender" => "MALE",
|
||||
// "dob" => "1975-08-09"
|
||||
// ],
|
||||
// [
|
||||
// "memberId" => "12846",
|
||||
// "name" => "dependent 1",
|
||||
// "phone" => 9898989898,
|
||||
// "email" => "dependent1@gmail.com",
|
||||
// "relationshipName" => "SON",
|
||||
// "gender" => "MALE",
|
||||
// "dob" => "2001-08-09"
|
||||
// ]
|
||||
// ],
|
||||
// "referenceId" => "TESTPOL001-client1-1764914537069"
|
||||
// ];
|
||||
|
||||
// $familiesWithResponse = [
|
||||
|
||||
// "TEST_EMP_001" => [
|
||||
// "policyDetails" => [
|
||||
// "policyNumber" => "TESTPOL001",
|
||||
// "employeeId" => "TEST_EMP_001",
|
||||
// "policyName" => "Client Policy Name",
|
||||
// "policyStartDate" => "2025-01-01",
|
||||
// "policyEndDate" => "2025-12-31",
|
||||
// "plan" => "plan-A",
|
||||
// "source" => "client1",
|
||||
// "employer" => "employeer1",
|
||||
// "employeeCode" => "TEST_EMP_001",
|
||||
// "accountNumber" => "",
|
||||
// "ifsc" => "",
|
||||
// "accountType" => ""
|
||||
// ],
|
||||
// "memberDetails" => [
|
||||
// [
|
||||
// "memberId" => "12847",
|
||||
// "name" => "test name",
|
||||
// "phone" => 9797976565,
|
||||
// "email" => "test@gmail.com",
|
||||
// "relationshipName" => "SELF",
|
||||
// "gender" => "MALE",
|
||||
// "dob" => "1975-08-09"
|
||||
// ],
|
||||
// [
|
||||
// "memberId" => "12846",
|
||||
// "name" => "dependent 1",
|
||||
// "phone" => 9898989898,
|
||||
// "email" => "dependent1@gmail.com",
|
||||
// "relationshipName" => "SON",
|
||||
// "gender" => "MALE",
|
||||
// "dob" => "2001-08-09"
|
||||
// ]
|
||||
// ],
|
||||
|
||||
// "apiResponse" => [ 'statusCode' => 200 ,"rawBody" => "", "data" => $apiResponse]
|
||||
// ]
|
||||
// ];
|
||||
|
||||
|
||||
|
||||
foreach ($familiesWithResponse as $empCode => $family) {
|
||||
|
||||
$apiResponse = $family['apiResponse'] ?? null;
|
||||
if (!$apiResponse || !isset($apiResponse['data'])) {
|
||||
// No valid API data for this family
|
||||
$this->myLogger->logme('error', "Wellness Onboard API error for emp_code {$empCode} No apiResponse found:");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Your endpoint response
|
||||
$statusCode = $apiResponse['statusCode'] ?? null;
|
||||
if (empty($statusCode) || $statusCode == 400 || $statusCode == 500) {
|
||||
$this->myLogger->logme('error', "Wellness Onboard API error for emp_code {$empCode} {}: " . ($apiResponse['rawBody'] ?? 'No response'));
|
||||
|
||||
// No referenceId, nothing to update
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = $apiResponse['data'];
|
||||
|
||||
// Your endpoint response
|
||||
$referenceId = $data['referenceId'] ?? null;
|
||||
if (empty($referenceId)) {
|
||||
// No referenceId, nothing to update
|
||||
$this->myLogger->logme('error', "Wellness Onboard API error for emp_code {$empCode} No referenceId found:");
|
||||
continue;
|
||||
}
|
||||
|
||||
// All members in this family share the same referenceId
|
||||
if (empty($family['memberDetails']) || !is_array($family['memberDetails'])) {
|
||||
$this->myLogger->logme('error', "Wellness Onboard API error for emp_code {$empCode} No memberDetails found:");
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($family['memberDetails'] as $member) {
|
||||
$memberPk = $member['memberId'] ?? null; // This is employee_policy.id
|
||||
|
||||
if (empty($memberPk)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$allUpdates[] = [
|
||||
'id' => $memberPk, // PK column of your table
|
||||
'wellness_onboard' => $referenceId,
|
||||
// uncomment if you have updated_at column
|
||||
// 'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
// print_r($allUpdates);die();
|
||||
// Do a single batch update for all families/members
|
||||
if (!empty($allUpdates)) {
|
||||
// 2nd param is the key to match on; here it's 'id'
|
||||
$this->employeePolicyModel->updateBatch($allUpdates, 'id');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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(
|
||||
@ -4736,7 +4795,7 @@ class EmployeeRestController extends AdminController
|
||||
$data = $db->table('employees e')
|
||||
->select('pt.policy_type,
|
||||
e.name, e.email_corporate as email, e.mobile as phone, e.emp_code as memberId, e.gender, e.dob, e.relationship as relation,
|
||||
cp.policy_no as policyNumber, cp.policy_no as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate , cp.wellness_plan_id as planId')
|
||||
cp.policy_no as policyNumber, ep.employee_id as employeeId, cp.policy_start_date as policyStartDate, cp.policy_end_date as policyEndDate , cp.wellness_plan_id as planId')
|
||||
->join('employee_polices ep', 'e.id = ep.employee_id')
|
||||
->join('client_policy cp', 'ep.client_policy_id = cp.id')
|
||||
->join('policy_type pt', 'cp.policy_type_id = pt.id')
|
||||
|
||||
@ -187,6 +187,10 @@ class JobWorker extends AdminController
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\PolicyTransactionController',
|
||||
],
|
||||
'initiateWellnessOnboardJob' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeController',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -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,
|
||||
@ -1776,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([
|
||||
@ -2043,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",
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -2477,6 +2477,12 @@
|
||||
pt.id AS id,
|
||||
pt.endorsement_no,
|
||||
pt.ref,
|
||||
|
||||
pt.data_received_date,
|
||||
pt.renewal_date,
|
||||
pt.installment,
|
||||
nhance_branch.branch_name as nhance_branch,
|
||||
|
||||
DATE_FORMAT(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||
DATE_FORMAT(pcsd.pt_policy_issue_date, '%b %Y') AS policy_issue_month,
|
||||
pt.month as statement_month,
|
||||
@ -2559,6 +2565,7 @@
|
||||
LEFT JOIN user_profiles su ON pt.sales_generated_by = su.id
|
||||
LEFT JOIN user_profiles se ON pt.serviced_by = se.id
|
||||
LEFT JOIN user_profiles created_user ON pt.created_by = created_user.id
|
||||
LEFT JOIN nhance_branch ON pt.issuer_branch = nhance_branch.id
|
||||
|
||||
WHERE pt.is_active = 1
|
||||
AND pcsd.is_active = 1
|
||||
@ -2573,6 +2580,12 @@
|
||||
pt.id AS id,
|
||||
pt.endorsement_no,
|
||||
pt.ref,
|
||||
|
||||
pt.data_received_date,
|
||||
pt.renewal_date,
|
||||
pt.installment,
|
||||
nhance_branch.branch_name as nhance_branch,
|
||||
|
||||
DATE_FORMAT(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||
DATE_FORMAT(IF(insq.month IS NULL, pcsd.pt_policy_issue_date, insq.month),'%b %Y') AS policy_issue_month,
|
||||
insq.month as statement_month,
|
||||
@ -2694,6 +2707,7 @@
|
||||
LEFT JOIN user_profiles su ON pt.sales_generated_by = su.id
|
||||
LEFT JOIN user_profiles se ON pt.serviced_by = se.id
|
||||
LEFT JOIN user_profiles created_user ON pt.created_by = created_user.id
|
||||
LEFT JOIN nhance_branch ON pt.issuer_branch = nhance_branch.id
|
||||
|
||||
WHERE pt.is_active = 1
|
||||
AND pcsd.is_active = 1
|
||||
|
||||
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; ?>
|
||||
@ -1071,6 +1071,128 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
|
||||
|
||||
}
|
||||
|
||||
function checkWellnessOnboardStatus(event)
|
||||
{
|
||||
// console.log(event.target.id);
|
||||
var policy_id = (event.target.value);
|
||||
console.log('checkWellnessOnboardStatus called ' + policy_id);
|
||||
if(policy_id != 0 && policy_id != " " && policy_id != undefined)
|
||||
{
|
||||
var apiURL = '<?php echo base_url();?>' + 'checkWellnessOnboardStatus/' + policy_id;
|
||||
// console.log(apiURL);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 300);
|
||||
|
||||
console.log('check wellness response', response);
|
||||
if(response.data && response.data != 0)
|
||||
{
|
||||
var btn_txt = 'click here to onboard ('+ response.data +') employees to Visit wellness';
|
||||
$("#on_board_btn_txt").attr("data-id", response.data);
|
||||
$('#on_board_btn_txt').text(btn_txt);
|
||||
$('#onboard_div').show();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('wellness button remains disabled');
|
||||
$('#onboard_div').hide();
|
||||
$('#on_board_btn_txt').text("");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 300);
|
||||
// toastr.error('Something went wrong! Try Later', 'Error');
|
||||
console.error('Error fetching data from checkPolicyTermsAndRackRatesHasDefiend API:', error);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function initiateWellnessOnboard(e)
|
||||
{
|
||||
|
||||
var empCount = $("#on_board_btn_txt").data("id");
|
||||
if (confirm("Are you sure? You are about to onboard " + empCount + " employees to Visit wellness program.")) {
|
||||
|
||||
// user clicked OK
|
||||
console.log("onboard Confirmed");
|
||||
} else {
|
||||
// user clicked Cancel
|
||||
console.log("onboard Cancelled");
|
||||
return false;
|
||||
}
|
||||
|
||||
// return false;
|
||||
|
||||
// console.log(event.target.id);
|
||||
var policy_id = document.getElementById('policy').value;
|
||||
console.log('initiateWellnessOnboard called ' + policy_id);
|
||||
if(policy_id != 0 && policy_id != " " && policy_id != undefined)
|
||||
{
|
||||
var apiURL = '<?php echo base_url();?>' + 'initiateWellnessOnboard/' + policy_id;
|
||||
// console.log(apiURL);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 300);
|
||||
|
||||
console.log('initiate wellness response', response);
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
$('#onboard_div').hide();
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 300);
|
||||
// toastr.error('Something went wrong! Try Later', 'Error');
|
||||
console.error('Error initiate data from initiateWellnessOnboard API:', error);
|
||||
toastr.error(error, 'Error');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
||||
toastr.error('Please select policy to initiate wellness onboard', 'Error');
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function checkValues() {
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Policy<span class="text-danger" id="policy_danger">*</span></label> <br />
|
||||
<select name="client_policy_id" class="form-control" id="policy" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)" required>
|
||||
<select name="client_policy_id" class="form-control" id="policy" onchange="checkPolicyTermsAndRackRatesHasDefiend(event); checkWellnessOnboardStatus(event);" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -129,6 +129,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-row" id="export_excel_btn">
|
||||
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
||||
<div class="form-group col-md-3">
|
||||
@ -136,6 +138,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row" id="onboard_div" style="display:none;">
|
||||
<a href="#"><span id="on_board_btn_txt" onclick="initiateWellnessOnboard(this)"></span></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -346,9 +346,11 @@ table.dataTable thead th {
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getPolicyTransactionDataForEndorsementEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php if(get_role_id() == 5): ?>
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -337,9 +337,12 @@ table.dataTable tbody td {
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
|
||||
<?php if(get_role_id() == 5): ?>
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@ -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>
|
||||
@ -337,9 +337,11 @@ table.dataTable tbody td {
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php if(get_role_id() == 5): ?>
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -575,7 +577,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 +690,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 +714,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 +723,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();
|
||||
|
||||
|
||||
@ -109,13 +109,19 @@ table.dataTable tbody td {
|
||||
<th>Agreed Amount</th>
|
||||
<th>Invoiced Amount</th>
|
||||
<th>Outstanding Amount</th>
|
||||
<th style="display: none;">Salse Person</th>
|
||||
<th style="display: none;">Service Person</th>
|
||||
<th style="display: none;">Nhance Branch</th>
|
||||
<th style="display: none;">Installment</th>
|
||||
<th style="display: none;">Data Received Date</th>
|
||||
<th style="display: none;">Renewal Date</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($report_list)) { ?>
|
||||
<?php foreach($report_list as $index => $row){ ?>
|
||||
<tr>
|
||||
<tr data-id="<?= $row['pt_id'] ?>">
|
||||
<td><?= $index + 1 ?> <a href="<?php
|
||||
if(strtolower($row['action_type']) == "policy"){
|
||||
echo base_url('policy_tranction/inception/list') . '?pt_id=' . $row['id'] ;
|
||||
@ -142,9 +148,9 @@ table.dataTable tbody td {
|
||||
<td style="display: none;"><?php echo empty($row['policy_end_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
|
||||
<td style="display: none;"><?php echo $row['ref'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo $row['remarks'] ?: 'N/A'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['bp_amt'] ?: '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['bp_amt'] ?: '0.00') : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['tp_or_ter'] ?: '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['premium_wo_gst']; ?></td>
|
||||
<td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['premium_wo_gst'] ?: '0.00') : '0.00'; ?></td>
|
||||
<!-- <td class="right-align-input" style="display: none;"><?php echo $row['gst_amount']; ?></td> -->
|
||||
<td class="right-align-input" style="display: none;"><?php echo $row['total_premium'] ?: '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?>%</td>
|
||||
@ -186,6 +192,12 @@ table.dataTable tbody td {
|
||||
number_format((float)$row['unbilled_amount'],2, '.', '');
|
||||
?>
|
||||
</td>
|
||||
<td style="display: none;"><?php echo $row['salse_person_name'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo $row['service_person_name'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo $row['nhance_branch'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo $row['installment'] ?: 'N/A'; ?></td>
|
||||
<td style="display: none;"><?php echo empty($row['data_received_date']) ? 'N/A' : date('d/m/Y', strtotime($row['data_received_date'])) ?></td>
|
||||
<td style="display: none;"><?php echo empty($row['renewal_date']) ? 'N/A' : date('d/m/Y', strtotime($row['renewal_date'])) ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -546,6 +558,33 @@ $(document).ready(function() {
|
||||
// $('#total_billed').text(totalBilled.toFixed(2));
|
||||
// $('#total_unbilled').text(totalUnbilled.toFixed(2));
|
||||
|
||||
var getUniqueUnbilled = function(colIndex) {
|
||||
|
||||
var rows = api.rows({ search: 'applied' }).nodes(); // get filtered nodes
|
||||
var maxRowPerId = {}; // store only the greatest row
|
||||
|
||||
$(rows).each(function() {
|
||||
var rowId = $(this).data('id'); // read data-id
|
||||
var rowIndex = $(this).index(); // row index
|
||||
|
||||
// Keep only the greatest row index per data-id
|
||||
if (!maxRowPerId[rowId] || rowIndex > maxRowPerId[rowId]) {
|
||||
maxRowPerId[rowId] = rowIndex;
|
||||
}
|
||||
});
|
||||
|
||||
var total = 0;
|
||||
|
||||
// Now sum only the selected rows
|
||||
$.each(maxRowPerId, function(id, rowIndex) {
|
||||
var value = api.cell(rowIndex, colIndex).data();
|
||||
value = parseFloat((typeof value === 'string') ? value.replace(/[^0-9.\-]+/g, '') : value) || 0;
|
||||
total += value;
|
||||
});
|
||||
|
||||
return total;
|
||||
};
|
||||
|
||||
// Helper to sum numeric values safely
|
||||
var getTotal = function(colIndex) {
|
||||
return api.column(colIndex, { search: 'applied' }).data()
|
||||
@ -563,17 +602,16 @@ $(document).ready(function() {
|
||||
var totalRewards = getTotal(24);
|
||||
var totalIrda = getTotal(25);
|
||||
var totalBilled = getTotal(26);
|
||||
var totalUnbilled = getTotal(27);
|
||||
// var totalUnbilled = getTotal(27);
|
||||
|
||||
// Update the totals section above the table
|
||||
$('#total_premium').text(totalPremium.toFixed(2));
|
||||
$('#total_rewards').text(totalRewards.toFixed(2));
|
||||
$('#total_irda').text(totalIrda.toFixed(2));
|
||||
$('#total_billed').text(totalBilled.toFixed(2));
|
||||
// $('#total_unbilled').text(totalUnbilled.toFixed(2));
|
||||
var totalUnbilled = getUniqueUnbilled(27);
|
||||
$('#total_unbilled').text(totalUnbilled.toFixed(2));
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -641,9 +679,9 @@ function appendTableData(data) {
|
||||
}
|
||||
|
||||
$('table tbody').on('click', 'td', function () {
|
||||
var index = $(this).index();
|
||||
console.log('Clicked TD index:', index);
|
||||
var colIndex = $(this).index();
|
||||
var rowIndex = $(this).closest('tr').index();
|
||||
console.log('Row:', rowIndex, 'Column:', colIndex);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user