diff --git a/app/Config/Routes.php b/app/Config/Routes.php index bbddfdec..efec8a5d 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -42,6 +42,7 @@ $routes->post("add_advertise_image", "AppContentManagementController::add_advert $routes->get("add_image_index", "AppContentManagementController::add_image_index"); $routes->get("getAdvertiseImage/(:any)", "AppContentManagementController::getAdvertiseImage/$1"); $routes->get("frontend_content", "AppContentManagementController::frontend_content"); +$routes->get('showAdvertiseImage/(:any)', 'AdvertiseController::showAdvertiseImage/$1'); // $routes->get('/', 'LoginController::index'); @@ -506,6 +507,7 @@ $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController $routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId"); $routes->post("/employeeRest/updateEmpOTP", "RestAuthenticationController::updateEmpOTP"); +// MPIN api's $routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); $routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); $routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); @@ -513,8 +515,13 @@ $routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpi $routes->post("/employeeRest/updateEmpMPIN", "RestAuthenticationController::updateEmpMPIN"); $routes->post("employeeRest/forgotMPIN", "RestAuthenticationController::forgotMPIN"); $routes->post("employeeRest/updateMobileNumber", "RestAuthenticationController::updateMobileNumber"); -// $routes->post("/employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); +// PASSWORD api's +$routes->post("employeeRest/savePassword", "RestAuthenticationController::savePassword"); +$routes->post("employeeRest/changePassword", "RestAuthenticationController::changePassword"); +$routes->post("employeeRest/verifyPassword", "RestAuthenticationController::verifyPassword"); +$routes->post("employeeRest/verifyOtp", "RestAuthenticationController::verifyOtp"); +$routes->post("employeeRest/checkPassword", "RestAuthenticationController::checkPassword"); //HR login api's $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); @@ -540,6 +547,7 @@ $routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationCont // $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity"); $routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails"); +$routes->get("employeeRest/getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); @@ -547,6 +555,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("ecardRequest", "ApiServiceController::ecardRequest"); + $routes->get("getWellnessURL", "ApiServiceController::getWellnessURL"); + $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity"); $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); @@ -582,7 +592,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("getFEContent", "EmployeeRestController::getFEContent"); $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); - $routes->get("getWellnessURL", "EmployeeRestController::getWellnessURL"); + $routes->get("getEcardURL", "EmployeeRestController::getEcardURL"); //$routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket"); @@ -693,12 +703,14 @@ $routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBa $routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails'); //Third party Vidal Api Call - +$routes->get('fileUpload','VidalApiController::fileUpload'); $routes->post('hospitalNetwork','VidalApiController::hospitalNetwork'); $routes->post('eCardService','VidalApiController::eCardService'); $routes->post('claimStatusCheck','VidalApiController::claimStatusCheck'); -$routes->post('newClaim','VidalApiController::newClaim'); +$routes->get('newClaim','VidalApiController::SubmitClaim'); $routes->post('enrollment','VidalApiController::enrollment'); +$routes->get('fileUploadToVidal','VidalApiController::fileUploadToVidal'); +$routes->get('claimStatus','VidalApiController::claimStatus'); //Third party MediAssist Api Call diff --git a/app/Controllers/ApiServiceController.php b/app/Controllers/ApiServiceController.php index 5b32cec1..ad6a114c 100644 --- a/app/Controllers/ApiServiceController.php +++ b/app/Controllers/ApiServiceController.php @@ -213,6 +213,101 @@ class ApiServiceController extends BaseController } + public function getWellnessUrl() + { + + $emp_id = $this->request->getGet('emp_id'); + $client_policy_id = $this->request->getGet('client_policy_id'); + + $db = \Config\Database::connect(); + + // $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') + // ->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') + // ->where('e.id', $emp_id) + // ->where('e.emp_status', 'active') + // ->where('ep.status', 'active') + // ->where('e.is_active', 1) + // ->where('ep.is_active', 1) + // ->get() + // ->getResultArray(); + + $data = $db->table('employee_polices ep') + ->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') + ->join('employees e', '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') + ->where('ep.employee_id', $emp_id) + ->where('ep.client_policy_id', $client_policy_id) + ->where('ep.status', 'active') + ->where('ep.is_active', 1) + ->get() + ->getRow(); + + + + $userParams = []; + if(!empty($data)) + { + $userParams['name'] = $data->name; + $userParams['email'] = $data->email; + $userParams['phone'] = $data->phone; + $userParams['memberId'] = $data->memberId; + $userParams['gender'] = $data->gender; + $userParams['dob'] = $data->dob; + $userParams['relation'] = $data->relation; + $userParams['policyNumber'] = $data->policyNumber; + $userParams['employeeId'] = $data->employeeId; + $userParams['policyStartDate']= $data->policyStartDate; + $userParams['policyEndDate'] = $data->policyEndDate; + $userParams['policyName'] = 'Nhance ' . $data->policy_type; + $userParams['planId'] = $data->planId; + $userParams['moduleName'] = 'home'; + + } + + // dd($userParams); + + if (empty($userParams)) { + return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200); + } + + // Derive 32-byte key from SHA256 + $derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true); + + // Build query string like Node.js + $plainText = ''; + foreach ($userParams as $k => $v) { + $plainText .= "&{$k}={$v}"; + } + $plainText = ltrim($plainText, '&'); + + // Encrypt + $algorithm = "aes-256-cbc"; + $encrypted = openssl_encrypt($plainText, $algorithm, $derivedKey, OPENSSL_RAW_DATA, env('VISIT_IV')); + + // Base64URL encode (same as Node.js output) + $output = rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '='); + + $baseURL = env('VISIT_BASE_URL'); + $clientId = env('VISIT_CLIENT_ID'); + $finalUrl = $baseURL . '/sso?userParams=' . $output . '&clientId=' . $clientId; + + if (!empty($finalUrl)) { + log_message('error', 'VISIT SSO | emp_id: '.$emp_id.' | URL: '.$finalUrl); + return $this->respond(['status' => 'success','data' => $finalUrl], 200); + } else { + return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200); + } + } + + diff --git a/app/Controllers/AppContentManagementController.php b/app/Controllers/AppContentManagementController.php index 33d6ce1d..f9e1d356 100755 --- a/app/Controllers/AppContentManagementController.php +++ b/app/Controllers/AppContentManagementController.php @@ -40,36 +40,58 @@ class AppContentManagementController extends AdminController // $this->loadLayout('client_onboarding', $data); } - public function add_advertise_image(){ + public function add_advertise_image() { + try { + $file = $this->request->getFile('advertise_image'); + //1) original file name for vaildations + $fileName = $file->getClientName(); //original file name for vaildations + $existing = $this->addImgModel->where('name', $fileName)->where('is_active', 1)->first(); + if($existing){ return $this->respond(['status' => false, 'message' => 'This file has already been uploaded in active state.'], 400); } - // print_r($this->request->getPost());die; - $uploadFilePath = ROOTPATH . 'public/uploads/advertiseImage/'; - $file_name = file_Upload($this->request->getFile('advertise_image'), $uploadFilePath); - $data['id'] = $this->request->getPost('add_image_id'); - // $data['created_by'] = get_session_userid(); - $data['name'] = $file_name; + //skip 1) and use this + // $fileName = $file->getRandomName(); // Same Name Multiple time upload means different name - if($data['id'] == 0){ - $insert = $this->addImgModel->insert($data); - if($insert){ - return $this->respond(['status' => true,'code' => 200,'data' => "success"], 200); + if (!$file || !$file->isValid()) { + return $this->respond(['status' => false, 'message' => 'No file uploaded or invalid file.'], 400); + } - }else{ - return $this->respond(['status' => false,'code' => 404,'message' => 'no data found'], 200); + $uploadPath = WRITEPATH . 'uploads/advertiseImage/'; + if (!is_dir($uploadPath)) mkdir($uploadPath, 0755, true); - } - }else{ - $id = $data['id']; - $update = $this->addImgModel->update($id,$data); - if($update){ - return $this->respond(['status' => true,'code' => 200,'data' => "success"], 200); + + $file->move($uploadPath, $fileName); - }else{ - return $this->respond(['status' => false,'code' => 404,'message' => 'no data found'], 200); - } + $id = $this->request->getPost('add_image_id'); + $data = ['name' => $fileName]; + + if ($id == 0) { + $this->addImgModel->insert($data); + } else { + $this->addImgModel->update($id, $data); + } + + return $this->respond(['status' => true, 'message' => 'Image saved successfully.']); + } catch (\Exception $e) { + return $this->respond(['status' => false, 'message' => $e->getMessage()], 500); } } + public function showAdvertiseImage($fileName) + { + + $filePath = WRITEPATH . 'uploads/advertiseImage/' . $fileName; + + if (!file_exists($filePath)) { + return $this->response->setStatusCode(404, 'File not found'); + } + + $mimeType = mime_content_type($filePath); + header('Content-Type: ' . $mimeType); + readfile($filePath); + exit; + } + + public function getAdvertiseImage($image_id){ $image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first(); diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index b9844e96..d0dd5ac9 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -181,8 +181,8 @@ class BDSReportController extends AdminController 'Client' => 'client' ]; + $data['tab_name'] = "IRDA Reports"; $data['page_name'] = "IRDA Report"; - return $this->loadLayout('irba_report', $data); } else { @@ -926,7 +926,7 @@ class BDSReportController extends AdminController $data['default_end'] = $default_start->format('d-m-Y'); $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; - $data['tab_name'] = "Renewal Report"; + $data['tab_name'] = "Renewal Reports"; $data['page_name'] = "Renewal Report"; return $this->loadLayout('renewal_search', $data); } else { @@ -1152,21 +1152,23 @@ class BDSReportController extends AdminController public function getMultiReport($report_type){ - $data['tab_name'] = "BDS Report"; - $data['page_name'] = "BDS Report"; + $data['tab_name'] = "BDS Reports"; if ($report_type == 1){ - $data['page_title'] = "BDS TAT Report"; + $data['page_name'] = "BDS TAT Report"; + $data['page_title'] = ""; $data['data'] = $this->bdsTATReport(true); // Functional Based called means True }else if ($report_type == 2){ - $data['page_title'] = "Account Manager Status Report"; + $data['page_name'] = "Account Manager Status Report"; + $data['page_title'] = ""; $data['data'] = $this->accountMangerStatusBDSReport(); }else{ - $data['page_title'] = "Account Manager TAT Report"; + $data['page_name'] = "Account Manager TAT Report"; + $data['page_title'] = ""; $data['data'] = $this->accountManagerTatBDSReport(); } diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 73149423..0bed75f5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -478,7 +478,7 @@ class ClientController extends AdminController public function index() { $this->myLogger->logme('error', 'Client list function called'); - $headerData['tab_name'] = 'Client List'; + $headerData['tab_name'] = 'Clients'; $headerData['page_name'] = 'Clients'; // Both Browser Tab name And Page name are same. $data['clientList'] = $this->clientModel->getCreatedByUserName(1); // passing client_type $data['client_rm'] = $this->clientRMModel->getAllClientRM(); @@ -5644,7 +5644,7 @@ class ClientController extends AdminController } public function sendextraparam() - { + { // $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray(); // // dd($data); // $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true)); @@ -5661,6 +5661,7 @@ class ClientController extends AdminController // $employeeController = new EmployeeController(); // $employeeController->truncateFileData('633'); + // $res = $this->getHrAccessData(4075); dd($res); // ---------- TICKET SERVICE CONTROLLER -------------------------------------------------------------------------------- @@ -5701,8 +5702,8 @@ class ClientController extends AdminController // ---------- POLICY TRANSACTION CONTROLLER -------------------------------------------------------------------------------- $policyTransactionController = new PolicyTransactionController(); - // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '57']); - // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']); + // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '62']); + // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '62']); // dd('-----', $res); // ----------EMP DATA SERVICE CONTROLLER-------------------------------------------------------------------------------- @@ -7024,182 +7025,440 @@ class ClientController extends AdminController return $combinedHrAccessData; } + // do not remove this commented items + // public function constructHrAccessData($data, $client_id , $pre_client_id) + // { + // // print_rr($data);die; + + // $preHrs = $data['pre_hr_data']; + // $postHrs = $data['post_hr_data']; + // $hrAccessTableData = $data['hr_access_table_data']; + // $merged = []; + + // // Merge based on mobile and email + // foreach ($postHrs as $post) { + // $found = false; + // foreach ($preHrs as $index => $pre) { + + // if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) { + + // $merged[] = [ + // 'pre_hr_id' => $pre['pre_hr_id'], + // 'post_hr_id' => $post['post_hr_id'], + // 'hr_name' => $post['hr_name'], + // 'hr_mobile' => $post['hr_mobile'], + // 'hr_mail' => $post['hr_mail'], + // 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + // 'post_branch_id' => $post['post_branch_id'] ?? null, + // 'post_branch_name' => $post['post_branch_name'] ?? null + // ]; + // unset($preHrs[$index]); // remove matched pre_hr + // $found = true; + // break; + // } + // } + + // if (!$found) { + // $merged[] = [ + // 'pre_hr_id' => null, + // 'post_hr_id' => $post['post_hr_id'], + // 'hr_name' => $post['hr_name'], + // 'hr_mobile' => $post['hr_mobile'], + // 'hr_mail' => $post['hr_mail'], + // 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + // 'post_branch_id' => $post['post_branch_id'] ?? null , + // 'post_branch_name' => $post['post_branch_name'] ?? null + // ]; + // } + // } + + // // Remaining preHrs (not matched) + // foreach ($preHrs as $pre) { + + // foreach ($merged as $value) { + // if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) { + // continue 2; // Skip adding this pre_hr as it's already matched + // } + // } + + // $merged[] = [ + // 'pre_hr_id' => $pre['pre_hr_id'], + // 'post_hr_id' => null, + // 'hr_name' => $pre['hr_name'], + // 'hr_mobile' => $pre['hr_mobile'], + // 'hr_mail' => $pre['hr_mail'], + // 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + // 'post_branch_id' => $post['post_branch_id'] ?? null , + // 'post_branch_name' => $post['post_branch_name'] ?? null + // ]; + // } + + // // dd($merged); + + // $result = []; + + // if (empty($hrAccessTableData)) { + + // // No access data — fill result with hr data and other fields as null + // foreach ($merged as $hr) { + // $result[] = [ + // 'hr_access_table_pk' => null, + // 'post_client_id' => $client_id ?? null, + // 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + // 'post_hr_id' => $hr['post_hr_id'] ?? null, + // 'allowed_pre_modules' => [], + // 'allowed_post_modules' => [], + // 'allowed_pre_policies' => [], + // 'allowed_active_policies' => [], + // 'allowed_cd' => [], + // 'hr_name' => $hr['hr_name'] ?? null, + // 'hr_mobile' => $hr['hr_mobile'] ?? null, + // 'hr_mail' => $hr['hr_mail'] ?? null, + // 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + // 'post_branch_id' => $hr['post_branch_id'] ?? null , + // 'post_branch_name' => $hr['post_branch_name'] ?? null , + // 'pre_client_id' => $pre_client_id ?? null + // ]; + // } + // } else { + // // First create a map of HR data by post_hr_id for quick lookup + // $hrMap = []; + // foreach ($merged as $hr) { + // $hrMap[$hr['post_hr_id']] = $hr; + // } + + // // Process access data first + // foreach ($hrAccessTableData as $access) { + // $post_hr_id = $access['post_hr_id']; + + // // Check if this HR exists in our merged data + // if (isset($hrMap[$post_hr_id])) { + // $hr = $hrMap[$post_hr_id]; + // $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + + // // Parse allowed modules + // $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + // $allowed_pre_modules = $allowed_modules['pre'] ?? []; + // $allowed_post_modules = $allowed_modules['post'] ?? []; + + // $result[$temp_arr_key] = [ + // 'hr_access_table_pk' => $access['id'] ?? null, + // 'post_client_id' => $access['post_client_id'] ?? null, + // 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + // 'post_hr_id' => $hr['post_hr_id'] ?? null, + // 'allowed_pre_modules' => $allowed_pre_modules, + // 'allowed_post_modules' => $allowed_post_modules, + // 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + // 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + // 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + // 'hr_name' => $hr['hr_name'], + // 'hr_mobile' => $hr['hr_mobile'], + // 'hr_mail' => $hr['hr_mail'], + // 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + // 'post_branch_id' => $hr['post_branch_id'] ?? null , + // 'post_branch_name' => $hr['post_branch_name'] ?? null , + // 'pre_client_id' => $pre_client_id ?? null + // ]; + + // // Remove from map so we know it's been processed + // unset($hrMap[$post_hr_id]); + // } + // } + + // // Now process any remaining HRs that didn't have access records + // foreach ($hrMap as $hr) { + // $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + + // $result[$temp_arr_key] = [ + // 'hr_access_table_pk' => null, + // 'post_client_id' => $client_id ?? null, + // 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + // 'post_hr_id' => $hr['post_hr_id'] ?? null, + // 'allowed_pre_modules' => [], + // 'allowed_post_modules' => [], + // 'allowed_pre_policies' => [], + // 'allowed_active_policies' => [], + // 'allowed_cd' => [], + // 'hr_name' => $hr['hr_name'] ?? null, + // 'hr_mobile' => $hr['hr_mobile'] ?? null, + // 'hr_mail' => $hr['hr_mail'] ?? null, + // 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + // 'post_branch_id' => $hr['post_branch_id'] ?? null , + // 'post_branch_name' => $hr['post_branch_name'] ?? null , + // 'pre_client_id' => $pre_client_id ?? null + // ]; + // } + // } + + + // $resultData['hr_access_data'] = array_values($result); + // $resultData['pre_policy_data'] = $data['pre_policy_data']; + // $resultData['post_policy_data'] = $data['post_policy_data']; + // $resultData['post_cd_data'] = $data['post_cd_data']; + + // return $resultData; + // } + public function constructHrAccessData($data, $client_id , $pre_client_id) - { - // print_rr($data);die; + { + try{ - $preHrs = $data['pre_hr_data']; - $postHrs = $data['post_hr_data']; - $hrAccessTableData = $data['hr_access_table_data']; - $merged = []; + $preHrs = $data['pre_hr_data']; + $postHrs = $data['post_hr_data']; + $hrAccessTableData = $data['hr_access_table_data']; + $merged = []; - // Merge based on mobile and email - foreach ($postHrs as $post) { - $found = false; - foreach ($preHrs as $index => $pre) { + // Merge based on mobile and email + foreach ($postHrs as $post) { + $found = false; + foreach ($preHrs as $index => $pre) { - if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) { + if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) { + $merged[] = [ + 'pre_hr_id' => $pre['pre_hr_id'], + 'post_hr_id' => $post['post_hr_id'], + 'hr_name' => $post['hr_name'], + 'hr_mobile' => $post['hr_mobile'], + 'hr_mail' => $post['hr_mail'], + 'pre_branch_id' => $pre['pre_branch_id'] ?? null, + 'post_branch_id' => $post['post_branch_id'] ?? null, + 'post_branch_name' => $post['post_branch_name'] ?? null + ]; + unset($preHrs[$index]); // remove matched pre_hr + $found = true; + break; + } + } + + if (!$found) { $merged[] = [ - 'pre_hr_id' => $pre['pre_hr_id'], + 'pre_hr_id' => null, 'post_hr_id' => $post['post_hr_id'], 'hr_name' => $post['hr_name'], 'hr_mobile' => $post['hr_mobile'], 'hr_mail' => $post['hr_mail'], 'pre_branch_id' => $pre['pre_branch_id'] ?? null, - 'post_branch_id' => $post['post_branch_id'] ?? null, - 'post_branch_name' => $post['post_branch_name'] ?? null + 'post_branch_id' => $post['post_branch_id'] ?? null , + 'post_branch_name' => $post['post_branch_name'] ?? null ]; - unset($preHrs[$index]); // remove matched pre_hr - $found = true; - break; } } - if (!$found) { + // Remaining preHrs (not matched) + foreach ($preHrs as $pre) { + + foreach ($merged as $value) { + if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) { + continue 2; // Skip adding this pre_hr as it's already matched + } + } + $merged[] = [ - 'pre_hr_id' => null, - 'post_hr_id' => $post['post_hr_id'], - 'hr_name' => $post['hr_name'], - 'hr_mobile' => $post['hr_mobile'], - 'hr_mail' => $post['hr_mail'], + 'pre_hr_id' => $pre['pre_hr_id'], + 'post_hr_id' => null, + 'hr_name' => $pre['hr_name'], + 'hr_mobile' => $pre['hr_mobile'], + 'hr_mail' => $pre['hr_mail'], 'pre_branch_id' => $pre['pre_branch_id'] ?? null, 'post_branch_id' => $post['post_branch_id'] ?? null , 'post_branch_name' => $post['post_branch_name'] ?? null ]; } - } - // Remaining preHrs (not matched) - foreach ($preHrs as $pre) { + $result = []; - foreach ($merged as $value) { - if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) { - continue 2; // Skip adding this pre_hr as it's already matched - } - } - - $merged[] = [ - 'pre_hr_id' => $pre['pre_hr_id'], - 'post_hr_id' => null, - 'hr_name' => $pre['hr_name'], - 'hr_mobile' => $pre['hr_mobile'], - 'hr_mail' => $pre['hr_mail'], - 'pre_branch_id' => $pre['pre_branch_id'] ?? null, - 'post_branch_id' => $post['post_branch_id'] ?? null , - 'post_branch_name' => $post['post_branch_name'] ?? null - ]; - } + if (empty($hrAccessTableData)) { - // dd($merged); - - $result = []; - - if (empty($hrAccessTableData)) { - - // No access data — fill result with hr data and other fields as null - foreach ($merged as $hr) { - $result[] = [ - 'hr_access_table_pk' => null, - 'post_client_id' => $client_id ?? null, - 'pre_hr_id' => $hr['pre_hr_id'] ?? null, - 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => [], - 'allowed_post_modules' => [], - 'allowed_pre_policies' => [], - 'allowed_active_policies' => [], - 'allowed_cd' => [], - 'hr_name' => $hr['hr_name'] ?? null, - 'hr_mobile' => $hr['hr_mobile'] ?? null, - 'hr_mail' => $hr['hr_mail'] ?? null, - 'pre_branch_id' => $hr['pre_branch_id'] ?? null, - 'post_branch_id' => $hr['post_branch_id'] ?? null , - 'post_branch_name' => $hr['post_branch_name'] ?? null , - 'pre_client_id' => $pre_client_id ?? null - ]; - } - } else { - // First create a map of HR data by post_hr_id for quick lookup - $hrMap = []; - foreach ($merged as $hr) { - $hrMap[$hr['post_hr_id']] = $hr; - } - - // Process access data first - foreach ($hrAccessTableData as $access) { - $post_hr_id = $access['post_hr_id']; - - // Check if this HR exists in our merged data - if (isset($hrMap[$post_hr_id])) { - $hr = $hrMap[$post_hr_id]; - $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; - - // Parse allowed modules - $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; - $allowed_pre_modules = $allowed_modules['pre'] ?? []; - $allowed_post_modules = $allowed_modules['post'] ?? []; - - $result[$temp_arr_key] = [ - 'hr_access_table_pk' => $access['id'] ?? null, - 'post_client_id' => $access['post_client_id'] ?? null, + // No access data — fill result with hr data and other fields as null + foreach ($merged as $hr) { + $result[] = [ + 'hr_access_table_pk' => null, + 'post_client_id' => $client_id ?? null, 'pre_hr_id' => $hr['pre_hr_id'] ?? null, 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => $allowed_pre_modules, - 'allowed_post_modules' => $allowed_post_modules, - 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], - 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], - 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], - 'hr_name' => $hr['hr_name'], - 'hr_mobile' => $hr['hr_mobile'], - 'hr_mail' => $hr['hr_mail'], + 'allowed_pre_modules' => [], + 'allowed_post_modules' => [], + 'allowed_pre_policies' => [], + 'allowed_active_policies' => [], + 'allowed_cd' => [], + 'hr_name' => $hr['hr_name'] ?? null, + 'hr_mobile' => $hr['hr_mobile'] ?? null, + 'hr_mail' => $hr['hr_mail'] ?? null, 'pre_branch_id' => $hr['pre_branch_id'] ?? null, 'post_branch_id' => $hr['post_branch_id'] ?? null , 'post_branch_name' => $hr['post_branch_name'] ?? null , 'pre_client_id' => $pre_client_id ?? null ]; + } - // Remove from map so we know it's been processed - unset($hrMap[$post_hr_id]); + } else { + + // First create a map of HR data by post_hr_id for quick lookup + $hrMap = []; + foreach ($merged as $hr) { + if(!empty($hr['post_hr_id'])){ + $hrMap['post_hr_id_' . $hr['post_hr_id']] = $hr; + }else{ + $hrMap['pre_hr_id_' . $hr['pre_hr_id']] = $hr; + } + } + + // Process access data first + foreach ($hrAccessTableData as $access) { + + $post_hr_id = $access['post_hr_id']; + $pre_hr_id = $access['pre_hr_id']; + + if (empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "PRE"; + } elseif (!empty($post_hr_id) && empty($pre_hr_id)) { + $type_of_access_data = "POST"; + } elseif (!empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "POST&PRE"; + } else { + $type_of_access_data = "UNKNOWN"; + } + + // Check if this HR exists in our merged data + if (isset($hrMap['post_hr_id_' . $post_hr_id])) { + + $hr = $hrMap['post_hr_id_' . $post_hr_id]; + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'] . $post_hr_id; + + // Parse allowed modules + $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + $allowed_pre_modules = $allowed_modules['pre'] ?? []; + $allowed_post_modules = $allowed_modules['post'] ?? []; + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => $access['id'] ?? null, + 'post_client_id' => $access['post_client_id'] ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => $allowed_pre_modules, + 'allowed_post_modules' => $allowed_post_modules, + 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + 'hr_name' => $hr['hr_name'], + 'hr_mobile' => $hr['hr_mobile'], + 'hr_mail' => $hr['hr_mail'], + 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + 'post_branch_id' => $hr['post_branch_id'] ?? null , + 'post_branch_name' => $hr['post_branch_name'] ?? null , + 'pre_client_id' => $pre_client_id ?? null, + 'type_of_access_data' => $type_of_access_data ?? null + ]; + + // Remove from map so we know it's been processed + unset($hrMap['post_hr_id_' . $post_hr_id]); + + }else if (isset($hrMap['pre_hr_id_' . $pre_hr_id])){ + + $hr = $hrMap['pre_hr_id_' . $pre_hr_id]; + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'] . $post_hr_id; + + // Parse allowed modules + $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + $allowed_pre_modules = $allowed_modules['pre'] ?? []; + $allowed_post_modules = $allowed_modules['post'] ?? []; + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => $access['id'] ?? null, + 'post_client_id' => $access['post_client_id'] ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => $allowed_pre_modules, + 'allowed_post_modules' => $allowed_post_modules, + 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + 'hr_name' => $hr['hr_name'], + 'hr_mobile' => $hr['hr_mobile'], + 'hr_mail' => $hr['hr_mail'], + 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + 'post_branch_id' => $hr['post_branch_id'] ?? null , + 'post_branch_name' => $hr['post_branch_name'] ?? null , + 'pre_client_id' => $pre_client_id ?? null, + 'type_of_access_data' => $type_of_access_data ?? null + ]; + + // Remove from map so we know it's been processed + unset($hrMap['pre_hr_id_' . $pre_hr_id]); + + } + } + + // Now process any remaining HRs that didn't have access records + foreach ($hrMap as $hr) { + + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + $post_hr_id = $hr['post_hr_id']; + $pre_hr_id = $hr['pre_hr_id']; + + if (empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "PRE"; + } elseif (!empty($post_hr_id) && empty($pre_hr_id)) { + $type_of_access_data = "POST"; + } elseif (!empty($post_hr_id) && !empty($pre_hr_id)) { + $type_of_access_data = "POST&PRE"; + } else { + $type_of_access_data = "UNKNOWN"; + } + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => null, + 'post_client_id' => $client_id ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => [], + 'allowed_post_modules' => [], + 'allowed_pre_policies' => [], + 'allowed_active_policies' => [], + 'allowed_cd' => [], + 'hr_name' => $hr['hr_name'] ?? null, + 'hr_mobile' => $hr['hr_mobile'] ?? null, + 'hr_mail' => $hr['hr_mail'] ?? null, + 'pre_branch_id' => $hr['pre_branch_id'] ?? null, + 'post_branch_id' => $hr['post_branch_id'] ?? null , + 'post_branch_name' => $hr['post_branch_name'] ?? null , + 'pre_client_id' => $pre_client_id ?? null, + 'type_of_access_data' => $type_of_access_data ?? null + ]; } } - // Now process any remaining HRs that didn't have access records - foreach ($hrMap as $hr) { - $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + // dd($result); + $resultData['hr_access_data'] = array_values($result); + $resultData['pre_policy_data'] = $data['pre_policy_data']; + $resultData['post_policy_data'] = $data['post_policy_data']; + $resultData['post_cd_data'] = $data['post_cd_data']; - $result[$temp_arr_key] = [ - 'hr_access_table_pk' => null, - 'post_client_id' => $client_id ?? null, - 'pre_hr_id' => $hr['pre_hr_id'] ?? null, - 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => [], - 'allowed_post_modules' => [], - 'allowed_pre_policies' => [], - 'allowed_active_policies' => [], - 'allowed_cd' => [], - 'hr_name' => $hr['hr_name'] ?? null, - 'hr_mobile' => $hr['hr_mobile'] ?? null, - 'hr_mail' => $hr['hr_mail'] ?? null, - 'pre_branch_id' => $hr['pre_branch_id'] ?? null, - 'post_branch_id' => $hr['post_branch_id'] ?? null , - 'post_branch_name' => $hr['post_branch_name'] ?? null , - 'pre_client_id' => $pre_client_id ?? null - ]; - } + return $resultData; + + } catch (\Throwable $th) { + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); + return []; + $errorData = [ + 'message' => $th->getMessage(), + 'file' => $th->getFile(), + 'line' => $th->getLine(), + 'code' => $th->getCode(), + 'trace' => $th->getTraceAsString(), + 'trace_array' => $th->getTrace(), // full array version (optional) + 'function' => $th->getTrace()[0]['function'] ?? null, + 'class' => $th->getTrace()[0]['class'] ?? null, + ]; + return ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData]; } - - - $resultData['hr_access_data'] = array_values($result); - $resultData['pre_policy_data'] = $data['pre_policy_data']; - $resultData['post_policy_data'] = $data['post_policy_data']; - $resultData['post_cd_data'] = $data['post_cd_data']; - - return $resultData; } public function saveHrAccessData() { try { + // Step 1: Fetch and decode the JSON data $client_id = $this->request->getPost('client_id'); $jsonData = $this->request->getPost('json'); @@ -7207,11 +7466,7 @@ class ClientController extends AdminController if (!$data || !is_array($data)) { log_message('error', 'Invalid or empty JSON in saveHrAccessData: ' . $jsonData); - return $this->respond([ - 'status' => false, - 'code' => 400, - 'message' => 'Invalid JSON data provided.', - ], 400); + return $this->respond(['status' => false,'code' => 400,'message' => 'Invalid JSON data provided.',], 400); } $success = []; @@ -7237,16 +7492,13 @@ class ClientController extends AdminController $post_branch_id = $value['post_branch_id']; $post_hr_id = $value['post_hr_id']; - $preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id); - - if (!empty($preBranchId)) { - $value['pre_branch_id'] = $preBranchId; - $value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId); - $value["pre_hr_id"] = $this->getPreHrIdByPreBranchId($preBranchId); - } + // $preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id); + // if (!empty($preBranchId)) { + // $value['pre_branch_id'] = $preBranchId; + // $value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId); + // $value["pre_hr_id"] = $this->getPreHrIdByPreBranchId($preBranchId); + // } - - // INSERT or UPDATE if (empty($value['pk']) || (int)$value['pk'] === 0) { @@ -7264,6 +7516,7 @@ class ClientController extends AdminController } $success[] = "Updated row with ID {$value['pk']}."; } + } catch (\Exception $e) { log_message('error', 'HRAccess Save Error at index ' . $index . ': ' . $e->getMessage()); $errors[] = "Error at index {$index}: " . $e->getMessage(); @@ -7654,84 +7907,84 @@ class ClientController extends AdminController return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200); } - private function getClientlistFromPre (){ + private function getClientlistFromPre() + { $db2 = \Config\Database::connect('preDB'); $auto_fetch_client_list = $db2->table('clients') - ->select('id,client_name') - ->where('is_active',1) - ->get()->getResultArray()??[]; + ->select('id,client_name') + ->where('is_active', 1) + ->get()->getResultArray() ?? []; return $auto_fetch_client_list; - } - public function auto_fetch_branch(){ + public function auto_fetch_branch() + { $data = $this->request->getPost(); $db2 = \Config\Database::connect('preDB'); $auto_fetch_branch_list = $db2->table('client_branch') - ->select('id,branch_name') - ->where('client_id',$data['client_id']) - ->where('is_active',1) - ->get()->getResultArray()??[]; + ->select('id,branch_name') + ->where('client_id', $data['client_id']) + ->where('is_active', 1) + ->get()->getResultArray() ?? []; - return + return - empty($auto_fetch_branch_list) + empty($auto_fetch_branch_list) - ? $this->response->setJSON([ + ? $this->response->setJSON([ 'status' => false, 'message' => 'branch list is empty', 'data' => [] ])->setStatusCode(400) - - : $this->response->setJSON([ + + : $this->response->setJSON([ 'status' => true, - 'message' => 'branch list is found' , - 'data' => $auto_fetch_branch_list + 'message' => 'branch list is found', + 'data' => $auto_fetch_branch_list ])->setStatusCode(200); } - public function auto_fetch_branch_details(){ + public function auto_fetch_branch_details() + { $data = $this->request->getPost(); $db2 = \Config\Database::connect('preDB'); $auto_fetch_branch_details = $db2->table('client_branch') - ->where('client_id',$data['client_id']) - ->where('id',$data['branch_id']) - ->where('is_active',1) - ->get()->getResultArray()??[]; + ->where('client_id', $data['client_id']) + ->where('id', $data['branch_id']) + ->where('is_active', 1) + ->get()->getResultArray() ?? []; return empty($auto_fetch_branch_details) - ? $this->response->setJSON([ - 'status' => false, - 'message' => 'branch details is empty', - 'data' => [] - ])->setStatusCode(400) - - : $this->response->setJSON([ - 'status' => true, - 'message' => 'branch details found' , - 'data' => $auto_fetch_branch_details - ])->setStatusCode(200); + ? $this->response->setJSON([ + 'status' => false, + 'message' => 'branch details is empty', + 'data' => [] + ])->setStatusCode(400) + : $this->response->setJSON([ + 'status' => true, + 'message' => 'branch details found', + 'data' => $auto_fetch_branch_details + ])->setStatusCode(200); } - - private function updatePreClientBranch($pre_branch_id,$post_branch_id ,$operation) + private function updatePreClientBranch($pre_branch_id, $post_branch_id, $operation) { $preDB = \Config\Database::connect('preDB'); - if($operation != 'create'){ + if ($operation != 'create') { $builder = $preDB->table('client_branch'); $builder->where('post_branch_id', $post_branch_id); @@ -7745,87 +7998,88 @@ class ClientController extends AdminController return true; } - public function createDefaultMailTemplate($client_id , $client_data){ + public function createDefaultMailTemplate($client_id, $client_data) + { - $member_welcome_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_welcome_mail')->get()->getResultArray()[0]??[]; + $member_welcome_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_welcome_mail')->get()->getResultArray()[0] ?? []; - $member_remainder_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_reminder_mail')->get()->getResultArray()[0]??[]; + $member_remainder_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_reminder_mail')->get()->getResultArray()[0] ?? []; - $member_review_and_summary_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_review_and_summary_mail')->get()->getResultArray()[0]??[]; + $member_review_and_summary_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_review_and_summary_mail')->get()->getResultArray()[0] ?? []; - $member_ecard_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_ecard_mail')->get()->getResultArray()[0]??[]; + $member_ecard_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_ecard_mail')->get()->getResultArray()[0] ?? []; - $member_common_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_common_mail')->get()->getResultArray()[0]??[]; + $member_common_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_common_mail')->get()->getResultArray()[0] ?? []; - $default_member_welcome_mail_template = [ + $default_member_welcome_mail_template = [ 'client_id' => $client_id, 'template_name' => 'member_welcome_mail', - 'subject' => $member_welcome_mail_template['subject']??'', - 'mail_content' => $member_welcome_mail_template['mail_content']??'', - 'mail_content_json'=> $member_welcome_mail_template['mail_content_json']??'', - + 'subject' => $member_welcome_mail_template['subject'] ?? '', + 'mail_content' => $member_welcome_mail_template['mail_content'] ?? '', + 'mail_content_json' => $member_welcome_mail_template['mail_content_json'] ?? '', + 'created_by' => get_session_userid(), 'created_at' => date('Y-m-d H:i:s'), 'updated_by' => null, 'updated_at' => date('Y-m-d H:i:s'), - 'mail_content_copy'=> null - ]; + 'mail_content_copy' => null + ]; - $default_member_remainder_mail_template = [ + $default_member_remainder_mail_template = [ 'client_id' => $client_id, 'template_name' => 'member_reminder_mail', - 'subject' => $member_remainder_mail_template['subject']??'', - 'mail_content' => $member_remainder_mail_template['mail_content']??'', - 'mail_content_json'=> $member_remainder_mail_template['mail_content_json']??'', - + 'subject' => $member_remainder_mail_template['subject'] ?? '', + 'mail_content' => $member_remainder_mail_template['mail_content'] ?? '', + 'mail_content_json' => $member_remainder_mail_template['mail_content_json'] ?? '', + 'created_by' => get_session_userid(), 'created_at' => date('Y-m-d H:i:s'), 'updated_by' => null, 'updated_at' => date('Y-m-d H:i:s'), - 'mail_content_copy'=> null - ]; + 'mail_content_copy' => null + ]; - $default_member_review_and_summary_mail_template = [ + $default_member_review_and_summary_mail_template = [ 'client_id' => $client_id, 'template_name' => 'member_review_and_summary_mail', - 'subject' => $member_review_and_summary_mail_template['subject']??'', - 'mail_content' => $member_review_and_summary_mail_template['mail_content']??'', - 'mail_content_json'=> $member_review_and_summary_mail_template['mail_content_json']??'', - + 'subject' => $member_review_and_summary_mail_template['subject'] ?? '', + 'mail_content' => $member_review_and_summary_mail_template['mail_content'] ?? '', + 'mail_content_json' => $member_review_and_summary_mail_template['mail_content_json'] ?? '', + 'created_by' => get_session_userid(), 'created_at' => date('Y-m-d H:i:s'), 'updated_by' => null, 'updated_at' => date('Y-m-d H:i:s'), - 'mail_content_copy'=> null - ]; + 'mail_content_copy' => null + ]; $default_member_ecard_mail_template = [ 'client_id' => $client_id, 'template_name' => 'member_ecard_mail', - 'subject' => $member_ecard_mail_template['subject']??'', - 'mail_content' => $member_ecard_mail_template['mail_content']??'', - 'mail_content_json'=> $member_ecard_mail_template['mail_content_json']??'', - + 'subject' => $member_ecard_mail_template['subject'] ?? '', + 'mail_content' => $member_ecard_mail_template['mail_content'] ?? '', + 'mail_content_json' => $member_ecard_mail_template['mail_content_json'] ?? '', + 'created_by' => get_session_userid(), 'created_at' => date('Y-m-d H:i:s'), 'updated_by' => null, 'updated_at' => date('Y-m-d H:i:s'), - 'mail_content_copy'=> null - ]; + 'mail_content_copy' => null + ]; $default_member_common_mail_template = [ 'client_id' => $client_id, 'template_name' => 'member_common_mail', - 'subject' => $member_common_mail_template['subject']??'', - 'mail_content' => $member_common_mail_template['mail_content']??'', - 'mail_content_json'=> $member_common_mail_template['mail_content_json']??'', - + 'subject' => $member_common_mail_template['subject'] ?? '', + 'mail_content' => $member_common_mail_template['mail_content'] ?? '', + 'mail_content_json' => $member_common_mail_template['mail_content_json'] ?? '', + 'created_by' => get_session_userid(), 'created_at' => date('Y-m-d H:i:s'), 'updated_by' => null, 'updated_at' => date('Y-m-d H:i:s'), - 'mail_content_copy'=> null - ]; + 'mail_content_copy' => null + ]; $this->myLogger->logme('error', 'Default Mail Template Data ' . json_encode([ $default_member_welcome_mail_template, @@ -7835,23 +8089,18 @@ class ClientController extends AdminController - $default_templates_inserted = $this->notificationModel->insertBatch([ + $default_templates_inserted = $this->notificationModel->insertBatch([ $default_member_welcome_mail_template, $default_member_remainder_mail_template, $default_member_review_and_summary_mail_template, $default_member_ecard_mail_template, $default_member_common_mail_template - ]); - - - return $default_templates_inserted ? true : false; + ]); + return $default_templates_inserted ? true : false; } - - - } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 57a05395..0da7f5a7 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -136,7 +136,7 @@ class EmployeeController extends AdminController // dd($this->request->getGet()); $this->myLogger->logme('error', 'list called'); - + $data['tab_name'] = 'Members'; $data['page_name'] = "Members"; $this->loadLayout('employee_list', $data); @@ -795,7 +795,8 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'list called'); - $data['page_name'] = "Endorsement"; + $data['tab_name'] = "Endorsements"; + $data['page_name'] = "Endorsements"; $this->loadLayout('endorsement_list', $data); } @@ -2810,6 +2811,9 @@ class EmployeeController extends AdminController $data['employees'] = $employee_data; $data['clients'] = $this->clientModel->findAll(); // dd($data); + $data['tab_name'] = "Employees"; + $data['page_name'] = "Employees"; + return $this->loadLayout('test_members_list',$data); } @@ -3107,6 +3111,7 @@ class EmployeeController extends AdminController // print_r($data); die; // } + $data['tab_name'] = "Retail Endorsement"; $data['page_name'] = "Retail Endorsement"; $this->loadLayout('retail_endorsement_list', $data); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index e0ea1eb5..a77a10cb 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -506,7 +506,8 @@ class EmployeeRestController extends AdminController if ($dateTime instanceof \DateTime) { return $dateTime->format('Y-m-d'); } else { - return null; + // return null; + return change_date_format($dateString); } } @@ -1714,7 +1715,7 @@ class EmployeeRestController extends AdminController try { $client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first(); - if($client) { + if(!empty($client)) { $client['client_logo'] = base_url().'public/uploads/logo/'.$client['client_logo']; $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id')) ->where('client_branch_id',$this->request->getGet('client_branch_id'))->findAll(); @@ -3874,90 +3875,6 @@ class EmployeeRestController extends AdminController return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200); } - public function getWellnessUrl() - { - - $emp_id = $this->request->getGet('emp_id'); - - $db = \Config\Database::connect(); - $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') - ->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') - ->where('e.id', $emp_id) - ->where('e.emp_status', 'active') - ->where('ep.status', 'active') - ->where('e.is_active', 1) - ->where('ep.is_active', 1) - ->get() - ->getResultArray(); - - // print_r($db->getLastQuery());die(); - // print_r($data);die(); - // Loop through $data and check for policy_type = GMC - $userParams = []; - foreach ($data as $row) { - // if ($row['policy_type'] === 'GMC') { - $userParams['name'] = $row['name']; - $userParams['email'] = $row['email']; - $userParams['phone'] = $row['phone']; - $userParams['memberId'] = $row['memberId']; - $userParams['gender'] = $row['gender']; - $userParams['dob'] = $row['dob']; - $userParams['relation'] = $row['relation']; - $userParams['policyNumber'] = $row['policyNumber']; - $userParams['employeeId'] = $row['employeeId']; - $userParams['policyStartDate']= $row['policyStartDate']; - $userParams['policyEndDate'] = $row['policyEndDate']; - // $userParams['policyName'] = 'Nhance ' . $row['policy_type']; - // $userParams['planId'] = 'NHANCE-PLAN-' . $row['policy_type']; - $userParams['policyName'] = $row['policy_type']; - $userParams['planId'] = env('VISIT_PLAN_ID'); - - $userParams['moduleName'] = 'home'; - break; // stop after first GMC match - // } - } - - if (empty($userParams)) { - return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200); - } - - // echo 'coming';die(); - // Derive 32-byte key from SHA256 - $derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true); - - // Build query string like Node.js - $plainText = ''; - foreach ($userParams as $k => $v) { - $plainText .= "&{$k}={$v}"; - } - $plainText = ltrim($plainText, '&'); - - // Encrypt - $algorithm = "aes-256-cbc"; - $encrypted = openssl_encrypt($plainText, $algorithm, $derivedKey, OPENSSL_RAW_DATA, env('VISIT_IV')); - - // Base64URL encode (same as Node.js output) - $output = rtrim(strtr(base64_encode($encrypted), '+/', '-_'), '='); - - $baseURL = env('VISIT_BASE_URL'); - $clientId = env('VISIT_CLIENT_ID'); - $finalUrl = $baseURL . '/sso?userParams=' . $output . '&clientId=' . $clientId; - - if (!empty($finalUrl)) { - log_message('error', 'VISIT SSO | emp_id: '.$emp_id.' | URL: '.$finalUrl); - return $this->respond(['status' => 'success','data' => $finalUrl], 200); - } else { - return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200); - } - } - - - // not in use did for testing function encrypt_for_sso(): string { diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 4b71694c..690e9c08 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -2471,7 +2471,7 @@ class EmployeeServiceController extends AdminController $member_data_count = count($member_data); if ($inception_data_count !== $member_data_count) { - $result['error_summary'][] = 15; + $result['error_summary'][] = 101; $result['error_message'] = " Inception Data Count: {$inception_data_count}   @@ -2504,7 +2504,7 @@ class EmployeeServiceController extends AdminController } if (!$match_found) { - array_push($result['error_summary'], 14); + array_push($result['error_summary'], 100); $result['error_data'][$inception_key]['sno']['error'][] = "This inception row was not found in the member data list."; } } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 6191007c..76bd1a5a 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -110,7 +110,7 @@ class MasterController extends AdminController public function insurerList() { $this->myLogger->logme('error','Insurer list function called'); - $headerData['tab_name'] = 'Insurer List'; + $headerData['tab_name'] = 'Insurer Masters'; $headerData['page_name'] = 'Insurers'; $data['insurerList'] = $this->insurerModel->where('is_active',1)->findAll(); $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM(); @@ -250,7 +250,7 @@ class MasterController extends AdminController { $this->myLogger->logme('error','Insurer Onboarding function called'); - $headerData['tab_name'] = 'Insurer Master'; + $headerData['tab_name'] = 'Insurer Masters'; $headerData['page_name'] = 'Insurers'; $types = array( @@ -519,7 +519,7 @@ class MasterController extends AdminController public function tpaList() { $this->myLogger->logme('error','TPA list function called'); - $headerData['tab_name'] = 'TPA List'; + $headerData['tab_name'] = 'TPA Masters'; $headerData['page_name'] = 'TPA'; $data['tpaList'] = $this->tpaModel->where('is_active',1)->findAll(); // $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM(); @@ -566,7 +566,7 @@ class MasterController extends AdminController { $this->myLogger->logme('error','TPA Onboarding function called'); - $headerData['tab_name'] = 'TPA Master'; + $headerData['tab_name'] = 'TPA Masters'; $headerData['page_name'] = 'TPA'; @@ -851,7 +851,7 @@ class MasterController extends AdminController public function kycList() { $this->myLogger->logme('error','KYC list function called'); - $headerData['tab_name'] = 'KYC List'; + $headerData['tab_name'] = 'KYC Masters'; $headerData['page_name'] = 'KYC'; $data['kycList'] = $this->kycEntityTypeModel->where('is_active',1)->findAll(); // $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM(); @@ -898,7 +898,7 @@ class MasterController extends AdminController { $this->myLogger->logme('error','KYC Onboarding function called'); - $headerData['tab_name'] = 'KYC Master'; + $headerData['tab_name'] = 'KYC Masters'; $headerData['page_name'] = 'KYC'; @@ -1043,7 +1043,7 @@ class MasterController extends AdminController public function policyTypeList() { $this->myLogger->logme('error','Policy Type list function called'); - $headerData['tab_name'] = 'Policy Type List'; + $headerData['tab_name'] = 'Policy Type Masters'; $headerData['page_name'] = 'Policy Type'; $data['policyList'] = $this->policyTypeModel->where('is_active',1)->findAll(); // $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM(); @@ -1090,7 +1090,7 @@ class MasterController extends AdminController { $this->myLogger->logme('error','Policy Type Onboarding function called'); - $headerData['tab_name'] = 'Policy Type Master'; + $headerData['tab_name'] = 'Policy Type Masters'; $headerData['page_name'] = 'Policy Type'; @@ -1246,7 +1246,7 @@ class MasterController extends AdminController //start CD Master list public function CDMasterList() { - $data['tab_name'] = 'CD Master List'; + $data['tab_name'] = 'CD Masters'; $data['page_name'] = 'CD Master'; $data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList(); $data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll(); @@ -1668,7 +1668,7 @@ class MasterController extends AdminController public function VehicleMasterList() { - $data['tab_name'] = 'Vehicle Master'; + $data['tab_name'] = 'Vehicle Masters'; $data['page_name'] = 'Vehicles'; $data['vehicle_type'] = [ 'two_wheeler' => 'Two Wheeler', @@ -2076,9 +2076,7 @@ class MasterController extends AdminController { $nhanceBranchModel = new NhanceBranchModel(); $method = $this->request->getMethod(); - $data['tab_name'] = 'Nhance Branch'; - $data['page_name'] = 'Nhance Branchs'; - + if ($method === 'post') { $id = $this->request->getPost('pk') ?? null; @@ -2120,7 +2118,7 @@ class MasterController extends AdminController } $data = $nhanceBranchModel->where('is_active', 1)->orderBy('id', 'DESC')->findAll(); - return $this->loadLayout('nhance_branch_list', ['data' => $data]); + return $this->loadLayout('nhance_branch_list', ['data' => $data,'tab_name' => 'Nhance Branchs','page_name' => 'Nhance Branchs']); } elseif ($method === 'delete') { @@ -2160,8 +2158,7 @@ class MasterController extends AdminController { $vehicleTypeModel = new VehicleTypeModel(); $method = $this->request->getMethod(); - $data['tab_name'] = 'Vehicle Type'; - $data['page_name'] = 'Vehicle Types'; + if ($method === 'post') { $id = $this->request->getPost('pk') ?? null; @@ -2203,7 +2200,7 @@ class MasterController extends AdminController } $data = $vehicleTypeModel->where('is_active', 1)->orderBy('id', 'DESC')->findAll(); - return $this->loadLayout('vehicle_type_master_list', ['data' => $data]); + return $this->loadLayout('vehicle_type_master_list', ['data' => $data,'tab_name' => 'Vehicle Types','page_name' => 'Vehicle Types']); } elseif ($method === 'delete') { @@ -2242,8 +2239,6 @@ class MasterController extends AdminController { $rtoModel = new RTOModel(); $method = $this->request->getMethod(); - $data['tab_name'] = 'RTO'; - $data['page_name'] = 'RTO'; if ($method === 'post') { @@ -2286,7 +2281,7 @@ class MasterController extends AdminController } $data = $rtoModel->where('is_active', 1)->orderBy('id', 'DESC')->findAll(); - return $this->loadLayout('rto_master_list', ['data' => $data]); + return $this->loadLayout('rto_master_list', ['data' => $data,'tab_name' => 'RTO Masters','page_name' => 'RTO']); } elseif ($method === 'delete') { diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 6e721f81..a2f88d5f 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -115,8 +115,8 @@ public function viewInception() { $bds_edit_pt_id = $this->request->getGet('pt_id') ?? null; - $data['tab_name'] = 'Policy'; - $data['page_name'] = 'Policy'; + $data['tab_name'] = 'Policies'; + $data['page_name'] = 'Policies'; // Static arrays for dropdowns $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; @@ -2187,6 +2187,8 @@ ->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id') ->join('user_profiles', 'insurer_statements.created_by = user_profiles.id') ->where('insurer_statements.is_active', 1) + ->where('insurers.is_active', 1) + ->where('insurer_branch.is_active', 1) // ->where('insurer_statements.file_status','success') ->where('date(insurer_statements.created_at) >= ', $from_date) ->where('date(insurer_statements.created_at) <= ', $today) @@ -2382,7 +2384,7 @@ $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); unset($excel_data[0]); $excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data); - // Kint::dump($excel_data);die(); + // Kint::dump($excel_data); // die(); //get no of line items and update in DB $line_items = 0; // get uploaded month transactions data @@ -2508,89 +2510,105 @@ // check policy no,insurer and etc in DB for this month // if all good return true, otherwise return false with messssage $data_to_update = []; - foreach ($excel_data as $excel_key => $excel_row) { - $is_row_empty = check_row_is_empty_or_null($excel_row); - if (!$is_row_empty) { + try{ + foreach ($excel_data as $excel_key => $excel_row) { + $is_row_empty = check_row_is_empty_or_null($excel_row); + if (!$is_row_empty) { - $is_source_found = 0; - // $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel - // $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel - $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel - $policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); // - // $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel - $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel + $is_source_found = 0; + // $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel + // $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel + $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel + $policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); // + // $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel + $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel - foreach ($source_data as $source_key => $source_row) { - // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); - $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; - // if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { - if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { - $is_source_found = 1; + foreach ($source_data as $source_key => $source_row) { + // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); + $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; + // if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { + if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { + $is_source_found = 1; - //calculate percentage first - $total_amt = 0; + //calculate percentage first + $total_amt = 0; - // $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file - $actual_bp_per = 0; //set default value 0 for maintaining existing code flow - $actual_bp_brokerage = trim($excel_row[5]); - $actual_bp_amt = trim($excel_row[3]); + // $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file + $actual_bp_per = 0; //set default value 0 for maintaining existing code flow + $actual_bp_brokerage = (int) trim($excel_row[5]); + $actual_bp_amt = (int) trim($excel_row[3]); - if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) { - $total_amt += $actual_bp_brokerage; - //percentage reverse calculation - if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) { - $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2); + if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) { + $total_amt += $actual_bp_brokerage; + //percentage reverse calculation + if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) { + $actual_bp_per = (int) round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2); + } + } else { + $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100); + $total_amt += $actual_bp_brokerage; } - } else { - $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100); - $total_amt += $actual_bp_brokerage; - } - // $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file - $actual_tp_per = 0;//set default value 0 for maintaining existing code flow - $actual_tp_brokerage = trim($excel_row[6]); - $actual_tp_amt = trim($excel_row[4]); + // $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file + $actual_tp_per = 0;//set default value 0 for maintaining existing code flow + $actual_tp_brokerage = (int) trim($excel_row[6]); + $actual_tp_amt = (int) trim($excel_row[4]); - if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") { - $total_amt += $actual_tp_brokerage; - //percentage reverse calculation - if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) { - $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100; + if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") { + $total_amt += $actual_tp_brokerage; + //percentage reverse calculation + if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) { + $actual_tp_per = (int) round(($actual_tp_brokerage / $actual_tp_amt) * 100, 2); + } + } else { + $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100); + $total_amt += $actual_tp_brokerage; } - } else { - $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100); - $total_amt += $actual_tp_brokerage; - } - // $actual_tep_per = trim($excel_row[11]); - // $actual_tep_brokerage = trim($excel_row[14]); - // $actual_tep_amt = trim($excel_row[8]); + // $actual_tep_per = trim($excel_row[11]); + // $actual_tep_brokerage = trim($excel_row[14]); + // $actual_tep_amt = trim($excel_row[8]); - $actual_tep_per = 0; - $actual_tep_brokerage = 0; - $actual_tep_amt = 0; + $actual_tep_per = 0; + $actual_tep_brokerage = 0; + $actual_tep_amt = 0; - if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") { - $total_amt += $actual_tep_brokerage; - //percentage reverse calculation - if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) { - $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; + if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") { + $total_amt += $actual_tep_brokerage; + //percentage reverse calculation + if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) { + $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; + } + } else { + $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100); + $total_amt += $actual_tep_brokerage; } - } else { - $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100); - $total_amt += $actual_tep_brokerage; + + //find variance + $variance_amt = $source_row['exp_amt'] - $total_amt; + + $data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[7]), 'statement_id' => $file_id]; + + unset($source_data[$source_key]); + continue 2; } - - //find variance - $variance_amt = $source_row['exp_amt'] - $total_amt; - - $data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[7]), 'statement_id' => $file_id]; - - unset($source_data[$source_key]); - continue 2; } } } + }catch (\Throwable $th) { + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); + $errorData = [ + 'message' => $th->getMessage(), + 'file' => $th->getFile(), + 'line' => $th->getLine(), + 'code' => $th->getCode(), + 'trace' => $th->getTraceAsString(), + 'trace_array' => $th->getTrace(), // full array version (optional) + 'function' => $th->getTrace()[0]['function'] ?? null, + 'class' => $th->getTrace()[0]['class'] ?? null, + ]; + return ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData]; } // dd($data_to_update); $this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id'); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 11b1a8fc..761ceffa 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -546,11 +546,11 @@ class RestAuthenticationController extends AdminController } public function verifyHrWithEmail() - { + { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyHrWithEmail: Received payload = " . json_encode($this->request->getJSON() ?? [])); try { $data = $this->request->getJSON(); - $email = $data->email; $otp = $data->otp; @@ -604,7 +604,17 @@ class RestAuthenticationController extends AdminController return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); } } catch (\Throwable $th) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); + $errorData = [ + 'message' => $th->getMessage(), + 'file' => $th->getFile(), + 'line' => $th->getLine(), + 'code' => $th->getCode(), + 'trace' => $th->getTraceAsString(), + 'trace_array' => $th->getTrace(), // full array version (optional) + 'function' => $th->getTrace()[0]['function'] ?? null, + 'class' => $th->getTrace()[0]['class'] ?? null, + ]; + return $this->respond(['status' => 'failed','code' => 500,'data' => $th, 'error_data' => $errorData],500); } } @@ -648,9 +658,9 @@ class RestAuthenticationController extends AdminController if (isset($mobile_number)) { - $hrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->where('otp', $otp)->first(); + $hrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->where('is_active', 1)->where('otp', $otp)->first(); }else{ - $hrData = $this->hrModel->where('email', $email)->where('contact_type', 'client')->where('otp', $otp)->first(); + $hrData = $this->hrModel->where('email', $email)->where('contact_type', 'client')->where('is_active', 1)->where('otp', $otp)->first(); } if ($hrData) @@ -678,6 +688,9 @@ class RestAuthenticationController extends AdminController ->join('clients', 'client_branch.client_id = clients.id', 'left') ->where('level_contacts.mobile', $mobile_number ) ->where('level_contacts.contact_type', 'client') + ->where('level_contacts.is_active', 1) + ->where('clients.is_active', 1) + ->where('client_branch.is_active', 1) ->findAll(); //set otp value null $this->hrModel->where('mobile', $mobile_number)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update(); @@ -689,6 +702,9 @@ class RestAuthenticationController extends AdminController ->join('clients', 'client_branch.client_id = clients.id', 'left') ->where('level_contacts.email', $email ) ->where('level_contacts.contact_type', 'client') + ->where('level_contacts.is_active', 1) + ->where('clients.is_active', 1) + ->where('client_branch.is_active', 1) ->findAll(); //set otp value null $this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update(); @@ -1502,12 +1518,7 @@ class RestAuthenticationController extends AdminController public function savePassword() { - log_message('error', ' '); - log_message('error', ' ************************************* POST START **************************************** '); - log_message('error', ' '); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Function called"); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); - try { $payload = $this->request->getJSON(); @@ -1515,9 +1526,116 @@ class RestAuthenticationController extends AdminController $email_id = $payload->email_id ?? null; $client_id = $payload->client_id ?? null; $plain_password = $payload->password ?? null; + $confirm_password = $payload->confirm_password ?? null; - if (empty($plain_password)) { - return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Password cannot be empty'], 400); + if (empty($plain_password) || empty($confirm_password)) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Both password cannot be empty'], 400); + } + + if($plain_password !== $confirm_password){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Password and confirm password not matched'], 400); + } + + // Build employee query + if ($mobile_number) { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active', 'expired']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active', 'expired']); + if (!empty($client_id)) $builder->where('employees.client_id', $client_id); + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.email_corporate', $email_id) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active', 'expired']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active', 'expired']); + if (!empty($client_id)) $builder->where('employees.client_id', $client_id); + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } + + $lastQuery = $this->employeeModel->db->getLastQuery(); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Last Executed Query: " . $lastQuery); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: employeeData: " . json_encode($employeeData ?? [])); + + + if ($employeeData) { + $id = $employeeData['id']; + $hashedPassword = password_hash($plain_password, PASSWORD_DEFAULT); + + $updateData = [ + 'password' => $hashedPassword, + ]; + + $updated = $this->employeeModel->where('id', $id)->set($updateData)->update(); + + if ($updated) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password saved successfully"); + $result = ['user_verification' => true, 'message' => "Password saved successfully"]; + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + } else { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password save failed"); + $result = ['user_verification' => true, 'message' => "Password not saved"]; + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $result], 200); + } + } else { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Employee not found"); + $result = ['user_verification' => false, 'message' => "User not found"]; + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); + } + } catch (\Throwable $th) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); + $errorData = [ + 'message' => $th->getMessage(), + 'file' => $th->getFile(), + 'line' => $th->getLine(), + 'code' => $th->getCode(), + 'trace' => $th->getTraceAsString(), + 'trace_array' => $th->getTrace(), // full array version (optional) + 'function' => $th->getTrace()[0]['function'] ?? null, + 'class' => $th->getTrace()[0]['class'] ?? null, + ]; + return $this->respond(['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'errorData' => $errorData], 500); + } + } + + public function changePassword() + { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); + + try { + + $payload = $this->request->getJSON(true); + $mobile_number = $payload['mobile_number'] ?? null; + $email_id = $payload['email_id'] ?? null; + $client_id = $payload['client_id'] ?? null; + $old_password = $payload['old_password'] ?? null; + $new_password = $payload['new_password'] ?? null; + $confirm_password = $payload['confirm_password'] ?? null; + + if (!$mobile_number && !$email_id) { + return $this->respond(['status' => 'failed','code' => 400,'message' => 'Mobile number or Email ID is required'], 400); + } + + if (empty($new_password) || empty($confirm_password) || empty($old_password)) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'old_password , New password and Confirm password are required' ], 400); + } + + if($new_password !== $confirm_password){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'New password and confirm password not matched'], 400); } // Build employee query @@ -1555,161 +1673,56 @@ class RestAuthenticationController extends AdminController $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Last Executed Query: " . $lastQuery); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: employeeData: " . json_encode($employeeData ?? [])); - if ($employeeData) { - $id = $employeeData['id']; - $hashedPassword = password_hash($plain_password, PASSWORD_DEFAULT); + if ($employeeData && password_verify($old_password, $employeeData['password'])) { - $updateData = [ - 'password' => $hashedPassword, - ]; + // Hash new password + $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); - $updated = $this->employeeModel->where('id', $id)->set($updateData)->update(); + // Update password and clear OTP + $updated = $this->employeeModel->update($employeeData['id'], [ + 'password' => $newHashedPassword, + ]); if ($updated) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password saved successfully"); - $result = ['user_verification' => true, 'message' => "Password saved successfully"]; - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Password updated successfully"); + return $this->respond(['status' => 'success','code' => 200,'message' => 'Password changed successfully'], 200); } else { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Password save failed"); - $result = ['user_verification' => true, 'message' => "Password not saved"]; - return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $result], 200); + return $this->respond(['status' => 'failed','code' => 500,'message' => 'Failed to update password' ], 500); } - } else { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Employee not found"); - $result = ['user_verification' => false, 'message' => "User not found"]; - return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); - } - } catch (\Throwable $th) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - savePassword: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString()); - return $this->respond(['status' => 'failed', 'code' => 500, 'message' => $th->getMessage()], 500); - } - } - public function changePassword() - { - log_message('error', ' '); - log_message('error', ' ************************************* CHANGE PASSWORD START **************************************** '); - log_message('error', ' '); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Function called"); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); - - try { - $payload = $this->request->getJSON(true); - - $mobile_number = $payload['mobile_number'] ?? null; - $email_id = $payload['email_id'] ?? null; - $client_id = $payload['client_id'] ?? null; - $otp = $payload['otp'] ?? null; - $new_password = $payload['new_password'] ?? null; - - if (empty($otp) || empty($new_password)) { - return $this->respond([ - 'status' => 'failed', - 'code' => 400, - 'message' => 'OTP and new password are required' - ], 400); - } - - // Fetch employee details - $builder = $this->employeeModel - ->select('employees.*') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.relationship', 'Self') - ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active']) - ->where('employee_polices.is_active', 1) - ->whereIn('employee_polices.status', ['active']); - - if (!empty($client_id)) $builder->where('employees.client_id', $client_id); - - if ($mobile_number) { - $builder->where('employees.mobile', $mobile_number); - } elseif ($email_id) { - $builder->where('employees.email_corporate', $email_id); - } else { - return $this->respond([ - 'status' => 'failed', - 'code' => 400, - 'message' => 'Mobile number or Email ID is required' - ], 400); - } - - $employeeData = $builder->orderBy('employees.id', 'desc')->first(); - - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: employeeData: " . json_encode($employeeData ?? [])); - - if (!$employeeData) { - return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'User not found'], 404); - } - - // Check OTP validity (assuming fields: otp, otp_expiry exist) - if (empty($employeeData['otp']) || $employeeData['otp'] != $otp) { - return $this->respond(['status' => 'failed', 'code' => 401, 'message' => 'Invalid OTP'], 200); - } - - if (!empty($employeeData['otp_expiry']) && strtotime($employeeData['otp_expiry']) < time()) { - return $this->respond(['status' => 'failed', 'code' => 401, 'message' => 'OTP expired'], 200); - } - - // Hash new password - $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); - - // Update password and clear OTP - $updated = $this->employeeModel->update($employeeData['id'], [ - 'password' => $newHashedPassword, - 'otp' => null, - ]); - - if ($updated) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Password updated successfully"); - log_message('error', ' '); - log_message('error', ' ************************************* CHANGE PASSWORD END **************************************** '); - log_message('error', ' '); - - return $this->respond([ - 'status' => 'success', - 'code' => 200, - 'message' => 'Password changed successfully' - ], 200); - } else { - return $this->respond([ - 'status' => 'failed', - 'code' => 500, - 'message' => 'Failed to update password' - ], 500); + }else{ + return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'Old password is incorrect'], 404); } } catch (\Throwable $th) { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - changePassword: Exception: " . $th->getMessage()); - log_message('error', ' '); - log_message('error', ' ************************************* CHANGE PASSWORD END **************************************** '); - log_message('error', ' '); return $this->respond(['status' => 'failed', 'code' => 500, 'message' => $th->getMessage()], 500); } } public function verifyPassword() { - log_message('error', ' '); - log_message('error', ' ************************************* POST START **************************************** '); - log_message('error', ' '); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - Verify Password: Function called"); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Received payload = " . json_encode($this->request->getJSON() ?? [])); try { - $requestData = $this->request->getJSON(true); + $requestData = $this->request->getJSON(true); $mobile_number = $requestData['mobile_number'] ?? null; $email_id = $requestData['email_id'] ?? null; $password = $requestData['password'] ?? null; $client_id = $requestData['client_id'] ?? null; + if(!$mobile_number && !$email_id){ + return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Mobile number or Email ID is required'], 400); + } + if (!$password) { return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Password is required'], 400); } // 🔹 Fetch employee data if ($mobile_number) { + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') @@ -1725,7 +1738,9 @@ class RestAuthenticationController extends AdminController } $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } elseif ($email_id) { + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') @@ -1741,9 +1756,8 @@ class RestAuthenticationController extends AdminController } $employeeData = $builder->orderBy('employees.id', 'desc')->first(); - } else { - return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Mobile number or Email ID is required'], 400); - } + + } $lastQuery = $this->employeeModel->db->getLastQuery(); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Last Executed Query: " . $lastQuery); @@ -1770,11 +1784,8 @@ class RestAuthenticationController extends AdminController $employeeData['token_type'] = "post"; $token = JWTToken::encode($employeeData); - log_message('error', ' '); - log_message('error', ' ************************************* POST END **************************************** '); - log_message('error', ' '); - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $token], 200); + } else { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Invalid password or employee not found"); log_message('error', ' '); @@ -1783,6 +1794,7 @@ class RestAuthenticationController extends AdminController return $this->respond(['status' => 'failed', 'code' => 404, 'data' => "", 'message' => 'Invalid password'], 200); } + } catch (\Exception $e) { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine()); log_message('error', ' '); @@ -1792,89 +1804,162 @@ class RestAuthenticationController extends AdminController } } - public function sendChangePasswordOTP() + public function verifyOtp() { - log_message('error', ' '); - log_message('error', ' ************************************* SEND OTP START **************************************** '); - log_message('error', ' '); - - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Function called"); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Received payload = " . json_encode($this->request->getJSON() ?? [])); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: Received payload = " . json_encode($this->request->getJSON() ?? [])); try { - $requestData = $this->request->getJSON(true); + $requestData = $this->request->getJSON(true); + $mobile_number = $requestData['mobile_number'] ?? null; $email_id = $requestData['email_id'] ?? null; $client_id = $requestData['client_id'] ?? null; + $otp = $requestData['otp'] ?? null; - if (!$email_id) { - return $this->respond(['status' => 'failed', 'code' => 400, 'data' => "", 'message' => 'Email ID is required'], 400); + if(!$mobile_number && !$email_id){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Mobile number or Email ID is required'], 400); } - // Get employee details - $builder = $this->employeeModel - ->select('employees.id, employees.mobile, employees.email_corporate, employees.client_id') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active']) - ->where('employee_polices.is_active', 1) - ->whereIn('employee_polices.status', ['active']) - ->where('employees.relationship', 'Self'); - - if (!empty($client_id)) { - $builder->where('employees.client_id', $client_id); + if (!$otp) { + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'OTP is required'], 400); } - if ($email_id) { - $builder->where('employees.email_corporate', $email_id); + // 🔹 Fetch employee data + if ($mobile_number) { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.email_corporate', $email_id) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } + + $lastQuery = $this->employeeModel->db->getLastQuery(); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Last Executed Query: " . $lastQuery); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: employeeData: " . json_encode($employeeData ?? [])); + + // 🔹 Verify otp + if ($employeeData && $employeeData['otp'] == $otp) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: OTP Verified employee found"); + $this->employeeModel->where('id', $employeeData['id'])->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update(); + return $this->respond(['status' => 'success', 'code' => 200, 'message' => "OTP verified succesfully"], 200); + } else { + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: OTP verification failed, OTP not found in the post db"); + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => "OTP verification failed"], 200); } - - $employeeData = $builder->orderBy('employees.id', 'desc')->first(); - - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Employee Data: " . json_encode($employeeData ?? [])); - - if (!$employeeData) { - return $this->respond(['status' => 'failed', 'code' => 404, 'data' => "", 'message' => 'Employee not found'], 404); - } - - // Generate 6-digit OTP - $otp = rand(100000, 999999); - - // Save OTP to DB (assuming 'otp' and 'otp_expiry' columns exist) - $this->employeeModel->update($employeeData['id'], [ - 'otp' => $otp, - ]); - - // Send OTP via SMS or Email (you can replace with your actual helper) - if ($email_id) { - // Example: MailHelper::sendMail($email_id, 'Password Change OTP', "Your OTP is {$otp}"); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: OTP {$otp} sent to email {$email_id}"); - } - - log_message('error', ' '); - log_message('error', ' ************************************* SEND OTP END **************************************** '); - log_message('error', ' '); - - return $this->respond(['status' => 'success', 'code' => 200, 'data' => ['otp_sent_to' => $email_id], 'message' => 'OTP sent successfully'], 200); + } catch (\Exception $e) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - sendChangePasswordOTP: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine()); - log_message('error', ' '); - log_message('error', ' ************************************* SEND OTP END **************************************** '); - log_message('error', ' '); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyOtp: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine()); return $this->respond(['status' => 'failed', 'code' => 500, 'data' => "", 'message' => $e->getMessage()], 500); } } + public function checkPassword() + { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Request payload = " . json_encode($this->request->getJSON() ?? [])); + + try { + + $payload = $this->request->getJSON() ?? []; + $mobile_number = $payload->mobile_number ?? null; + $email_id = $payload->email_id ?? null; + + if(!$mobile_number && !$email_id){ + return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Mobile number or Email ID is required'], 400); + } + + // 🔹 Fetch employee data + if ($mobile_number) { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.email_corporate', $email_id) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } + + $lastQuery = $this->employeeModel->db->getLastQuery(); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: Last Executed Query: " . $lastQuery); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyPassword: employeeData: " . json_encode($employeeData ?? [])); + + if ($employeeData && $employeeData["password"] != null) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Mpin - Exist"); + return $this->respond(['status' => 'success','code' => 200,'data' => "", 'message' => "Password - exist"],200); + } else { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Password - not found in PRE so call the thirdpartapi to the POST to check the MPIN"); + return $this->respond(['status' => 'failed','code' => 200,'data' => "", 'message' => "Password - not exist"],200); + } + + } catch (\Exception $e) { + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString()); + return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $e->getMessage()],500); + } + } + // -------------- EMP MOBILE NUMBER UPDATE API'S ------------------------------------------------------------------------------------------------------------- public function updateMobileNumber() { - log_message('error', ' '); - log_message('error', ' ************************************* UPDATE MOBILE START **************************************** '); - log_message('error', ' '); - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateMobileNumber: Function called"); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateMobileNumber: Received payload = " . json_encode($this->request->getJSON() ?? [])); - try { $payload = $this->request->getJSON(true); @@ -1943,9 +2028,6 @@ class RestAuthenticationController extends AdminController } } catch (\Throwable $th) { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateMobileNumber: Exception: " . $th->getMessage()); - log_message('error', ' '); - log_message('error', ' ************************************* UPDATE MOBILE END **************************************** '); - log_message('error', ' '); return $this->respond([ 'status' => 'failed', 'code' => 500, diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index b0c893da..29f89df4 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -102,8 +102,6 @@ class ThzController extends BaseController public function ticketList() { - $data['tab_name'] = "Tickets"; - $data['page_name'] = "Tickets"; try { $returnType = strtolower($this->request->getGet('return_type') ?? 'api'); @@ -130,7 +128,8 @@ class ThzController extends BaseController // 3,4 remain person varannum. $data['client_list'] = $this->clientModel->getCreatedByUserName(); $data['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll(); - + $data['tab_name'] = "Tickets"; + $data['page_name'] = "Tickets"; return $this->loadLayout('thz_list', $data); } @@ -267,6 +266,8 @@ class ThzController extends BaseController $result['policy_terms'] = $toGetPolicyId ? $this->getPolicyTerms($toGetPolicyId) : ''; $result['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll(); + $result['tab_name'] = "Tickets"; + $result['page_name'] = "Ticket Details"; return $this->loadLayout('thz_notes', $result); } diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index b7418dbf..3a6e8b56 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -12,6 +12,209 @@ class VidalApiController extends BaseController // } + + function fileUploadToVidal() + { + $apiUrl = "https://devapigw.vidalhealthtpa.com/partner-integration/api/files/upload-url"; + $subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY'); + + // Step 1: Get signed URL from Vidal API + $filePath = '/opt/lampp/htdocs/nhance/writable/uploads/claim_files/1760013019_73d94af7b96ddc2e3d51.png'; + $payload = json_encode(["scope" => 'document type' , 'fileName' => '1760013019_73d94af7b96ddc2e3d51.png']); + $headers = [ + "Content-Type: application/json", + "Ocp-Apim-Subscription-Key: $subscriptionKey" + ]; + + $ch = curl_init($apiUrl); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + $response = curl_exec($ch); + if (curl_errno($ch)) { + die("Curl error while requesting signed URL: " . curl_error($ch)); + } + curl_close($ch); + + $responseData = json_decode($response, true); + + if (!isset($responseData['data']['signedUrl'])) { + die("Failed to get signed URL. Response: " . $response); + } + + $signedUrl = $responseData['data']['signedUrl']; + $fileId = $responseData['data']['fileId']; + + // Step 2: Upload file to signed URL using PUT (Azure Blob) + $fileSize = filesize($filePath); + $fileContent = fopen($filePath, 'r'); + + $ch2 = curl_init($signedUrl); + curl_setopt($ch2, CURLOPT_PUT, true); + curl_setopt($ch2, CURLOPT_INFILE, $fileContent); + curl_setopt($ch2, CURLOPT_INFILESIZE, $fileSize); + curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch2, CURLOPT_HTTPHEADER, [ + "x-ms-blob-type: BlockBlob", + "Content-Length: $fileSize" + ]); + + $uploadResponse = curl_exec($ch2); + + $httpCode = curl_getinfo($ch2, CURLINFO_HTTP_CODE); + if (curl_errno($ch2)) { + die("Curl error while uploading file: " . curl_error($ch2)); + } + fclose($fileContent); + curl_close($ch2); + + if ($httpCode !== 201 && $httpCode !== 200) { + die("File upload failed. HTTP Code: $httpCode\nResponse: $uploadResponse"); + } + + // Step 3: Return File ID for reference + return $this->response->setJSON( [ + "status" => true, + "message" => "File uploaded successfully", + "fileId" => $fileId, + "signedUrl" => $signedUrl, + "uploadResponse" => json_decode($uploadResponse, true) + ]); + } + + public function fileUpload() + { + + helper('api'); + $url = getenv('VIDAL_API_BASE_URL') . '/files/upload-url'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'x-ms-blob-type: BlockBlob', + 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', + ]; + + $body = [ + 'scope' => 'application/pdf', + 'fileName' => '1760013019_73d94af7b96ddc2e3d51.png', + 'file' => '/opt/lampp/htdocs/nhance/writable/uploads/claim_files/1760013019_73d94af7b96ddc2e3d51.png', + ]; + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != true){ + return $this->response->setJSON([ + 'status' => false, + 'message' => 'failed.', + 'data' => $response + ]); + } + + return $this->response->setJSON($response); + + // { + // "status": true, + // "data": { + // "status": "SUCCESS", + // "data": { + // "signedUrl": "https://devapigw.vidalhealthtpa.com/doc-storage/api/deeplink/6912d37a9f09fc3f6be4cd9c/56fb8e76-39a4-4e4b-99f2-4748e224e4a7?se=2025-11-18T06:11:06.304Z", + // "expiresAt": "2025-11-18T06:11:06.304Z", + // "fileId": "https://devapigw.vidalhealthtpa.com/doc-storage/api/private/6912d37a9f09fc3f6be4cd9c" + // }, + // "trace": "T_ID_a09327df-ea34-4874-9e3f-05ac5c0a2c68", + // "successful": true + // }, + // "code": 200 + // } + + } + + public function SubmitClaim ($claimId = null) + { + helper('api'); + + $url = getenv('VIDAL_API_BASE_URL').'/claims/submit'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', + ]; + + $body = [ + 'policyNo' => "351500/D0534/PP/20-20/PC", + 'enrollmentId' => "BLR-NC-D0534-004-0000033-A", + 'typeOfClaim' => "Main hospitalization claim", + 'claimSubType' => "Hospitalization", + 'requestedAmount' => "3500", + 'ailmentType' => "Non covid", + 'admissionDate' => "20-07-2023", + 'dischargeDate' => "23-07-2023", + 'hospitalName' => "DELL HOSPITAL PVT LTD", + 'empanelmentNo' => "HOS-BLR-021280", + 'documentType' => "Claim", + 'ailmentName' => "Cold", + 'hospitalAddress' => "abc", + 'hospitalState' => "karnataka", + 'hospitalCity' => "bangalore", + 'hospitalPinCode' => "560036", + 'hospitalPhoneNo' => "7656879899", + 'fileId' => "https://devapigw.vidalhealthtpa.com/doc-storage/api/private/69130dfad1414b35a775480f", + ]; + + + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != true){ + return $this->response->setJSON([ + 'status' => false, + 'message' => 'failed.', + 'data' => $response + ]); + } + + return $this->response->setJSON($response); + } + + public function claimStatus ($claimId = null) + { + helper('api'); + + $url = getenv('VIDAL_API_BASE_URL').'/claims/claim-dependent-info'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', + ]; + + $body = [ + 'empNO' => "", + 'tpaCardID' => "", + 'claimID' => "BLR-0284-CL-9349459", + 'emailID' => "", + 'mobileNO' => "", + ]; + + + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != true){ + return $this->response->setJSON([ + 'status' => false, + 'message' => 'failed.', + 'data' => $response + ]); + } + + return $this->response->setJSON($response); + } + public function hospitalNetwork(){ $postData = $this->request->getJSON(true); @@ -123,74 +326,6 @@ class VidalApiController extends BaseController } - public function newClaim() - { - $postData = $this->request->getPost(); - - if (empty($postData)) { - return $this->response->setJSON([ - 'status' => false, - 'message' => 'Empty Data Given.', - 'data' => $postData - ]); - } - - helper('api'); - - $url = getenv('VIDAL_API_BASE_URL') . '/submitClaim'; - $method = 'POST'; - - $headers = [ - 'Content-Type: multipart/form-data', - 'Authorization:' .getenv('VIDAL_API_KEY').'', - ]; - - $body = [ - 'username' => getenv('VIDAL_API_USERNAME'), - 'password' => getenv('VIDAL_API_PASSWORD'), - 'policyNo' => $postData['policyNo'] ?? '', - 'enrollmentId' => $postData['enrollmentId'] ?? '', - 'typeOfClaim' => $postData['typeOfClaim'] ?? '', - 'claimSubType' => $postData['claimSubType'] ?? '', - 'requestedAmount' => $postData['requestedAmount'] ?? '', - 'ailmentType' => $postData['ailmentType'] ?? '', - 'admissionDate' => $postData['admissionDate'] ?? '', - 'dischargeDate' => $postData['dischargeDate'] ?? '', - 'hospitalName' => $postData['hospitalName'] ?? '', - 'empanelmentNo' => $postData['empanelmentNo'] ?? '', - 'documentType' => $postData['documentType'] ?? '', - 'ailmentName' => $postData['ailmentName'] ?? '', - 'hospitalAddress' => $postData['hospitalAddress'] ?? '', - 'hospitalState' => $postData['hospitalState'] ?? '', - 'hospitalCity' => $postData['hospitalCity'] ?? '', - 'hospitalPinCode' => $postData['hospitalPinCode'] ?? '', - 'hospitalPhoneNo' => $postData['hospitalPhoneNo'] ?? '', - ]; - - // ✅ Handle file upload - if ($file = $this->request->getFile('File')) { - if ($file->isValid() && !$file->hasMoved()) { - $filePath = $file->getTempName(); - $originalName = $file->getClientName(); - $mimeType = $file->getMimeType(); - - $body['File'] = new \CURLFile($filePath, $mimeType, $originalName); - } - } - - $response = call_third_party_api($url, $method, $headers, $body); - - if($response['status'] != true){ - return $this->response->setJSON([ - 'status' => false, - 'message' => 'Token generation failed.', - 'data' => $response - ]); - } - - return $this->response->setJSON($response); - } - public function enrollment() { diff --git a/app/Helpers/header.php b/app/Helpers/header.php index f696e91b..54b357f2 100755 --- a/app/Helpers/header.php +++ b/app/Helpers/header.php @@ -56,18 +56,18 @@ - +
@@ -127,6 +134,7 @@ $(document).ready(function() { extend: 'excel', text: ' EXCEL ', title: 'Renewal-List', + sheetName: 'Renewal-List', exportOptions: { orthogonal: 'sort' }, @@ -135,12 +143,16 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 20, // Set default number of rows per page (optional) @@ -154,14 +166,17 @@ $(document).ready(function() { // Global DataTables defaults $.extend(true, $.fn.dataTable.defaults, { language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, - paging: true, pageLength: 10, ordering: false diff --git a/app/Views/bds_report_Insurer_wise_Data.php b/app/Views/bds_report_Insurer_wise_Data.php index 835f48d6..d020fb8c 100644 --- a/app/Views/bds_report_Insurer_wise_Data.php +++ b/app/Views/bds_report_Insurer_wise_Data.php @@ -94,6 +94,7 @@ table.dataTable tbody td { extend: 'excel', text: ' EXCEL ', title: 'Insurer-Wise-Report-List', + sheetName: 'Insurer-Wise-Report-List', exportOptions: { orthogonal: 'sort' }, @@ -104,12 +105,16 @@ table.dataTable tbody td { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/bds_report_bap_wise_data.php b/app/Views/bds_report_bap_wise_data.php index 3b2175db..928ad3a4 100644 --- a/app/Views/bds_report_bap_wise_data.php +++ b/app/Views/bds_report_bap_wise_data.php @@ -100,18 +100,23 @@ table.dataTable tbody td { }, className: 'app-btn-primary ', title: 'Bap-Wise-Report-List', + sheetName: 'Bap-Wise-Report-List', footer: true } ] } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/bds_tat_wise_report.php b/app/Views/bds_tat_wise_report.php index 1c30125d..c47cc259 100644 --- a/app/Views/bds_tat_wise_report.php +++ b/app/Views/bds_tat_wise_report.php @@ -123,18 +123,23 @@ extend: 'excel', text: ' EXCEL ', title: 'BDS TAT BAND WISE DATA', + sheetName: 'BDS TAT BAND WISE DATA', className: 'app-btn-primary ', } ] } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, pageLength: 10, diff --git a/app/Views/business_team_list.php b/app/Views/business_team_list.php index 4329ecb6..3aeb2ed0 100644 --- a/app/Views/business_team_list.php +++ b/app/Views/business_team_list.php @@ -385,13 +385,16 @@ } ], language: { - search: ` -
+ search: ` +
_INPUT_ - + +
`, - searchPlaceholder: "Search", - emptyTable: '
No Data found
' + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, pageLength: 10, diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 466588e9..c0ff4584 100755 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -243,6 +243,7 @@ table.dataTable thead th { { extend: 'excel', text: ' EXCEL ', + sheetName: 'CD-Master-List', exportOptions: { orthogonal: 'sort' }, @@ -252,12 +253,16 @@ table.dataTable thead th { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, pageLength: 10, diff --git a/app/Views/claim_dump_file_list.php b/app/Views/claim_dump_file_list.php index 7a52530b..70282d89 100644 --- a/app/Views/claim_dump_file_list.php +++ b/app/Views/claim_dump_file_list.php @@ -297,12 +297,16 @@ } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, // Enable pagination pageLength: 15, // Set default number of rows per page (optional) diff --git a/app/Views/claims_report_acc_manager_wise.php b/app/Views/claims_report_acc_manager_wise.php index 105f552a..177fe93f 100644 --- a/app/Views/claims_report_acc_manager_wise.php +++ b/app/Views/claims_report_acc_manager_wise.php @@ -94,17 +94,21 @@ className: 'btn app-btn-secondary ', buttons: [ { extend: 'csv', text: ' CSV ', title: 'Insurer-Wise-Report-List', className: 'app-btn-primary ' }, - { extend: 'excel', text: ' EXCEL ', title: 'Insurer-Wise-Report-List', className: 'app-btn-primary ', exportOptions: { orthogonal: 'sort' } } + { extend: 'excel', text: ' EXCEL ', title: 'Insurer-Wise-Report-List', className: 'app-btn-primary ', sheetName: 'Insurer-Wise-Report-List', exportOptions: { orthogonal: 'sort' } } ], } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, pageLength: 10, diff --git a/app/Views/claims_report_tpa_wise.php b/app/Views/claims_report_tpa_wise.php index ec66572a..fbf5daa5 100644 --- a/app/Views/claims_report_tpa_wise.php +++ b/app/Views/claims_report_tpa_wise.php @@ -92,17 +92,21 @@ className: 'btn app-btn-secondary ', buttons: [ { extend: 'csv', text: ' CSV ', title: 'Insurer-Wise-Report-List',className: 'app-btn-primary ' }, - { extend: 'excel', text: ' EXCEL ', title: 'Insurer-Wise-Report-List',className: 'app-btn-primary ', exportOptions: { orthogonal: 'sort' } } + { extend: 'excel', text: ' EXCEL ', title: 'Insurer-Wise-Report-List',className: 'app-btn-primary ', sheetName: 'Insurer-Wise-Report-List', exportOptions: { orthogonal: 'sort' } } ] } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true, pageLength: 10, diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 178439fa..01ff9597 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -436,6 +436,7 @@ $("#branch_form").submit(function(event) { toastr.error(res.message, 'Error'); }else{ toastr.success(res.message, 'Success'); + newBranchSavedPeaseCallTheHrAccessFormApi = true; } // var message = (branch_PrimaryKey === '') ? // 'Client Branch Created successfully' : diff --git a/app/Views/client_deposit_list.php b/app/Views/client_deposit_list.php index 81c80750..c8be27ae 100755 --- a/app/Views/client_deposit_list.php +++ b/app/Views/client_deposit_list.php @@ -99,13 +99,17 @@ $(document).ready(function() { } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search" - }, + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' + }, }); diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 237c2752..1a2f21f4 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -340,13 +340,16 @@ $(document).ready(function() } ], language: { - search: ` -
- _INPUT_ - -
`, - searchPlaceholder: "Search", - emptyTable: '
No Data found
' + search: ` +
+ _INPUT_ + + +
`, + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true , // pagingType: 'full_numbers' diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 3dc798d6..3a195fe7 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -456,6 +456,7 @@ - - + @@ -1210,6 +1210,30 @@ $(function(){ $(object).select2(); } + // SVR asked - Add padding to input so text doesn’t merge with icon + $(document).on('init.dt', function () { + $('.dataTables_filter input[type="search"]').css('padding-right', '30px'); + }); + + // SVR asked - Toggle icons + $(document).on('input', '.dataTables_filter input', function() { + const wrapper = $(this).closest('.datatable-search-wrapper'); + if ($(this).val()) { + wrapper.find('.datatable-search-icon').hide(); + wrapper.find('.datatable-clear-icon').show(); + } else { + wrapper.find('.datatable-search-icon').show(); + wrapper.find('.datatable-clear-icon').hide(); + } + }); + + // SVR asked - Clear search + $(document).on('click', '.datatable-clear-icon', function() { + const input = $(this).closest('.datatable-search-wrapper').find('input'); + input.val('').trigger('input'); + table.search('').draw(); + }); + diff --git a/app/Views/layout/footer_old.php b/app/Views/layout/footer_old.php index c150e074..3ab68845 100644 --- a/app/Views/layout/footer_old.php +++ b/app/Views/layout/footer_old.php @@ -88,8 +88,8 @@ - - + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index ffaba0a3..d81c7f68 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -62,7 +62,7 @@ - + @@ -71,15 +71,15 @@ @@ -1660,6 +1660,12 @@ .right-btn { right: 0; } + + input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; + appearance: none; + } + @@ -1953,6 +1959,7 @@
+
  • diff --git a/app/Views/layout/header_old.php b/app/Views/layout/header_old.php index 3b1cf061..fdc80046 100644 --- a/app/Views/layout/header_old.php +++ b/app/Views/layout/header_old.php @@ -62,18 +62,18 @@ - + diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 1762f32c..8075471d 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -487,12 +487,16 @@ table.dataTable tbody td { } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/nhance_branch_list.php b/app/Views/nhance_branch_list.php index 8d0c1add..32c7c09c 100644 --- a/app/Views/nhance_branch_list.php +++ b/app/Views/nhance_branch_list.php @@ -124,11 +124,15 @@ ], language: { search: ` -
    +
    _INPUT_ - + +
    `, - searchPlaceholder: "Search" + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/oldheader.php b/app/Views/oldheader.php index e0c5b0f2..29671b46 100644 --- a/app/Views/oldheader.php +++ b/app/Views/oldheader.php @@ -62,21 +62,21 @@ - + diff --git a/app/Views/other_policy_terms.php b/app/Views/other_policy_terms.php index e674fa52..16166973 100755 --- a/app/Views/other_policy_terms.php +++ b/app/Views/other_policy_terms.php @@ -215,6 +215,7 @@ } }); + window.scrollTo({ top: 0, behavior: 'smooth' }); setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -749,8 +750,8 @@
    - +
    diff --git a/app/Views/outstanding_report_list.php b/app/Views/outstanding_report_list.php index 203c4151..bd45e251 100644 --- a/app/Views/outstanding_report_list.php +++ b/app/Views/outstanding_report_list.php @@ -21,6 +21,18 @@ .center-align-input { text-align: center; } + + .column-header { + margin-right: 10px; /* Adjust this value as needed */ + } + + /* Center align header text and icons */ + table[data-custom-table-css="table"].dataTable thead th { + padding-top: 3px !important; + padding-bottom: 4px !important; + padding-right: 15px !important; + padding-left: 15px !important; + }
    @@ -107,21 +119,21 @@
    - +
    - + - - - - - - - - - - + + + + + + + + + + @@ -182,6 +194,7 @@ extend: 'excel', text: ' EXCEL ', title: 'Outstanding Report', + sheetName: 'Outstanding Report', customize: function(xlsx) { var sheet = xlsx.xl.worksheets['sheet1.xml']; var total = 0; @@ -213,8 +226,16 @@ ] }], language: { - search: "_INPUT_", - searchPlaceholder: "Search..." + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index e9f6848f..5c28b10a 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1052,6 +1052,7 @@ } }); + window.scrollTo({ top: 0, behavior: 'smooth' }); setTimeout(function() { $('.loader').fadeOut(); @@ -1761,15 +1762,14 @@ value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured mr-2" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)"> + -
    diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index b8be22c0..87a151b9 100755 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -499,6 +499,7 @@ } }); + window.scrollTo({ top: 0, behavior: 'smooth' }); setTimeout(function() { $('.loader').fadeOut(); @@ -927,14 +928,14 @@ style="max-width:200px;" value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured mr-2" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)"> - +
    diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 2c1bfae3..04f4b2de 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -458,7 +458,7 @@ - > + @@ -1346,6 +1346,41 @@ // $('#co_premium_' + input).val(cop.toFixed(2)); // $('#co_tp_premium_' + input).val(cotp.toFixed(2)); // $('#co_ter_premium_' + input).val(cotep.toFixed(2)); + // } + + // Apply Deletion (Negative) Values + // function applyDeletionSymbolsToFields(input, isDeletion) { + // console.log('========== APPLYING DELETION SYMBOLS =========='); + + // if (!isDeletion) return; + + // const fieldIds = [ + // 'base_premium', + // 'tp_premium', + // 'ter_premium', + // 'co_premium', + // 'co_tp_premium', + // 'co_ter_premium', + // 'gst_amount', + // 'agreed_amount', + // 'non_comm_per_amt', + // 'total_amt', + // 'exp_amt' + // ]; + + // fieldIds.forEach(field => { + // const $el = $('#' + field + '_' + input); + // console.log('$el', '#' + field + '_' + input); + // console.log('$el', $el); + // let val = $el.val()?.trim(); + // console.log('$val', val); + // if (!val || val.startsWith('-')) return; + + // let num = parseFloat(val); + // if (!isNaN(num) && num > 0) $el.val(-num); + // }); + + // console.log('========== COMPLETED DELETION SYMBOL APPLICATION =========='); // } function checkAndDistributeTax(input){ @@ -1432,9 +1467,9 @@ let bap = selectedOption.data('bap') || ''; let allocg = selectedOption.data('allocg') || ''; let endorsement_type = $('#action_type').val(); - let isDeletion = endorsement_type === "deletion"; - - console.log("bap:", bap, "allocg:", allocg, "isDeletion:", isDeletion); + let isDeletion = false; + // let isDeletion = endorsement_type === "deletion" || endorsement_type === "policy_cancellation"; + console.log({bap, allocg, isDeletion}); const event = window.event || {}; @@ -1458,7 +1493,20 @@ let cotp = (allocg !== 'EB') ? absNum('co_tp_premium') : 0; let cotep = (['Fire', 'Marine Cargo', 'Marine Hull'].includes(bap)) ? absNum('co_ter_premium') : 0; - console.log({ bp, tp, tep, cop, cotp, cotep, ncpa }); + console.log('premiums :', { bp, tp, tep, cop, cotp, cotep, ncpa }); + + let bp_raw_val = parseFloat($('#base_premium_' + input).val()); + console.log('bp_raw_val', bp_raw_val); + + // handel the positive(+), negative(-) symbole add the value + if(endorsement_type === "addition" || endorsement_type === "baby_addition" || endorsement_type === "addition_inception"){ + isDeletion = false + }else if(endorsement_type === "deletion" || endorsement_type === "policy_cancellation"){ + isDeletion = true + }else if(bp_raw_val < 0){ + isDeletion = true; + console.log('Value is negative:', bp_raw_val); + } let co_share_type_val = numVal('co_share_type'); console.log('co_share_type_val :', co_share_type_val); @@ -1532,18 +1580,17 @@ setCoPremiums(input); // ✅ Apply deletion symbols last (safely); - if (isDeletion) { - applyDeletionSymbolsToFields(input, true); - } + // if (isDeletion) { + applyDeletionSymbolsToFields(input, isDeletion); + // } console.log('############################## END AMOUNT CALCULATION ############################################'); } // Apply Deletion (Negative) Values function applyDeletionSymbolsToFields(input, isDeletion) { - console.log('========== APPLYING DELETION SYMBOLS =========='); - if (!isDeletion) return; + console.log('========== APPLYING DELETION SYMBOLS =========='); const fieldIds = [ 'base_premium', @@ -1561,14 +1608,20 @@ fieldIds.forEach(field => { const $el = $('#' + field + '_' + input); - console.log('$el', '#' + field + '_' + input); - console.log('$el', $el); let val = $el.val()?.trim(); - console.log('$val', val); - if (!val || val.startsWith('-')) return; + if (!val) return; - let num = parseFloat(val); - if (!isNaN(num) && num > 0) $el.val(-num); + let num = parseFloat(val.replace(/^-/, '')); // remove any existing minus first + console.log('num', num); + if (isNaN(num)) return; + + if (isDeletion) { + // Apply minus sign + if (num > 0) $el.val(-num); + } else { + // Remove minus sign + $el.val(num); + } }); console.log('========== COMPLETED DELETION SYMBOL APPLICATION =========='); diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index d91ef483..6f5485cb 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -519,12 +519,16 @@ table.dataTable thead th { } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 41df9fe9..3b8013c6 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -813,7 +813,7 @@ - + @@ -883,7 +883,7 @@ - > + @@ -3588,7 +3588,7 @@ $("#inception_form_id").submit(function(event) { - + if (!this.checkValidity()) { return; } event.preventDefault(); let policy_type_id = $('#policy_type_id').val(); @@ -3607,6 +3607,53 @@ return; } + let hasEmptyInsurer = false; + let firstEmptyField = null; + + // $('select[name="follow_insurer_id[]"]').each(function() { + // const $field = $(this); + // const errorId = 'error-' + $field.attr('id'); + + // // Remove any old message + // $('#' + errorId).remove(); + + // if ($field.val().trim() === "") { + // hasEmptyInsurer = true; + // $field.addClass('is-invalid'); + + // // Add error message only once + // if (!$field.next('.text-danger').length) { + // $field.after(`This value is required.`); + // } + + // if (!firstEmptyField) { + // firstEmptyField = this; // store first empty field + // } + // } else { + // $field.removeClass('is-invalid'); + // $('#' + errorId).remove(); // remove if filled + // } + // }); + $('select[name="follow_insurer_id[]"]').each(function() { + if ($(this).val().trim() === "") { + hasEmptyInsurer = true; + $(this).addClass('is-invalid'); + if (!firstEmptyField) { + firstEmptyField = this; // store the first invalid field + } + } else { + $(this).removeClass('is-invalid'); + } + }); + + if (hasEmptyInsurer) { + if (firstEmptyField) { + $(firstEmptyField).focus(); + } + toastr.warning('Please select all Insurers before submitting', 'Warning'); + return; + } + if(pt_form_sumbit_handler == 0){ toastr.warning('Base premium greater than CD Amount', 'WARNING'); return; @@ -4392,7 +4439,7 @@ case 0: // Insurer selection newCell = ` - - + + @@ -147,8 +147,8 @@ table.dataTable tbody td { - - + + + // $max_amount = max($irda_amt, $exp_amt); + // $total_irda_amt = number_format($max_amount, 2, '.', ''); + $total_irda_amt = empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; + ?> @@ -340,6 +342,7 @@ $(document).ready(function() { { extend: 'excel', title: 'Policy-Tranction-BDS-List', + sheetName: 'Policy-Tranction-BDS-List', text: ' EXCEL ', className: 'app-btn-primary ', // customize: function (xlsx) { @@ -453,12 +456,16 @@ $(document).ready(function() { } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/report_bds_filter.php b/app/Views/report_bds_filter.php index bc5db80b..d55ab379 100644 --- a/app/Views/report_bds_filter.php +++ b/app/Views/report_bds_filter.php @@ -169,8 +169,6 @@ $(document).ready(function() { - getClientAndBranchAndPolicy() - getURLParams() $('#client_id').select2(); $('#client_branch_id').select2(); $('#insurer_id').select2(); @@ -179,7 +177,9 @@ $('#client_policy_id').select2(); $('#user_id').select2(); - }) + getClientAndBranchAndPolicy(); + }); + function fetchEmpolyeeList(event) { event.preventDefault(); // Prevent default action @@ -223,21 +223,30 @@ return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); } + function getSafeParam(params, paramName) { + const val = params.get(paramName); + if (val === null || val === '' || val === 'null' || val === 'undefined' || val === undefined) { + return ''; + } + return val; + } + + function getURLParams() { const url = new URL(window.location.href); const params = new URLSearchParams(url.search); - const startDate = params.get('start_date') || 0; // Default to 0 if not found - const endDate = params.get('end_date') || 0; // Default to 0 if not found - const client_id = params.get('client_id') || 0; // Default to 0 if not found - const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found - const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found - const date_type = params.get('date_type') || 0; // Default to 0 if not found - const issuer = params.get('issuer') || 0; // Default to 0 if not found - const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found - const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found - const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found - const user_id = params.get('user_id') || 0; // Default to 0 if not found + const startDate = getSafeParam(params, 'start_date'); + const endDate = getSafeParam(params, 'end_date'); + const client_id = getSafeParam(params, 'client_id'); + const insurer_id = getSafeParam(params, 'insurer_id'); + const policy_type_id = getSafeParam(params, 'policy_type_id'); + const date_type = getSafeParam(params, 'date_type'); + const issuer = getSafeParam(params, 'issuer'); + const client_branch_id = getSafeParam(params, 'client_branch_id'); + const insurer_branch_id = getSafeParam(params, 'insurer_branch_id'); + const client_policy_id = getSafeParam(params, 'client_policy_id'); + const user_id = getSafeParam(params, 'user_id'); hideDateField(date_type) @@ -258,24 +267,38 @@ console.log('End Date:', endDate); if (startDate != 0 && endDate != 0) { - setTimeout(function() { - $('#start_date').val(startDate) - $('#end_date').val(endDate) - $('#client_id').val(client_id).select2() - $('#insurer_id').val(insurer_id).select2() - $('#user_id').val(user_id).select2() - $('#policy_type_id').val(policy_type_id).select2() - $('#date_type').val(date_type).trigger('change'); - $('#issuer').val(issuer) - setTimeout(function() { - $('#client_branch_id').val(client_branch_id).select2() - $('#insurer_branch_id').val(insurer_branch_id).select2() + // wait for dropdowns (Select2) to be loaded setTimeout(function() { - $('#client_policy_id').val(client_policy_id).select2(); - }, 1000); - }, 2000) - }, 1000) + // Step 1: Set top-level fields first + $('#startDate').val(startDate); + $('#endDate').val(endDate); + $('#client_id').val(client_id).trigger('change.select2'); + $('#insurer_id').val(insurer_id).trigger('change.select2'); + $('#user_id').val(user_id).trigger('change.select2'); + $('#policy_type_id').val(policy_type_id).trigger('change.select2'); + $('#date_type').val(date_type).trigger('change'); + $('#issuer').val(issuer); + // Step 2: Wait a bit to let change events happen + setTimeout(function() { + // populate branch dropdowns manually if data exists + if (client_id && branch_list[client_id]) { + appendBranch(branch_list[client_id]); + } + if (insurer_id && insurer_branch_list[insurer_id]) { + appendInsurerBranch(insurer_branch_list[insurer_id]); + } + + // Step 3: Set branch selections + $('#client_branch_id').val(client_branch_id).trigger('change.select2'); + $('#insurer_branch_id').val(insurer_branch_id).trigger('change.select2'); + + // Step 4: After branches, handle client policies + setTimeout(function() { + $('#client_policy_id').val(client_policy_id).trigger('change.select2'); + }, 500); + }, 500); + }, 500); } } @@ -370,6 +393,7 @@ insurer_branch_list = res.insurer_branch_data; appendClients(res.client_data); appendInsurer(res.insurer_data); + getURLParams(); } else { console.log('No data found'); } @@ -401,6 +425,7 @@ }); $('#client_id').append(option); + }); } @@ -469,7 +494,6 @@ function appendPolicies(data) { // console.log('appendPolicies', data); // console.log('appendPolicies', $('#client_policy_id')); - $('#client_policy_id').empty(); $('#client_policy_id').append($('
    S.No 
    S.No
    Insurer Insurer
    Branch 
    Statement
    Month 
    Statement
    No 
    Invoice No Invoice Status Invoice Date Invoice Amount Realization
    Amount 
    Outstanding
    Amount 
    Insurer
    Insurer
    Branch
    Statement
    Month
    Statement
    No
    Invoice No
    Invoice Status
    Invoice Date
    Invoice Amount
    Realization
    Amount
    Outstanding
    Amount
    Agreed Amount
    InsurerInsurer*
    Agreed Amount
    - - - @@ -4747,11 +4794,11 @@ $('[name="standard_tp[]"]').val(std_tp); $('[name="standard_ter[]"]').val(std_tep); - if(insurerCount > 1){ - $('.follow_insurer').prop('required', true); - }else{ - $('.follow_insurer').prop('required', false); - } + // if(insurerCount > 1){ + // $('.follow_insurer').prop('required', true); + // }else{ + // $('.follow_insurer').prop('required', false); + // } }); @@ -4768,6 +4815,12 @@ // }); co_share_percentage_calculation(insurerCount, "add"); + + if (insurerCount === 0) { + $('.follow_insurer').prop('required', false); + } else { + $('.follow_insurer').prop('required', true); + } } function removeInsurerColumn(index, count_index) { @@ -4798,6 +4851,11 @@ insurer_count_array = insurer_count_array.filter(item => item !== count_index); co_share_percentage_calculation(null, "remove"); insurerCount--; + if (insurerCount === 0) { + $('.follow_insurer').prop('required', false); + } else { + $('.follow_insurer').prop('required', true); + } console.log('#################################### END Remove Insurer Column ####################################'); diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index ede897ce..37640c11 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -591,12 +591,16 @@ $(document).ready(function() { } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/policy_type_list.php b/app/Views/policy_type_list.php index 990f06a5..2f6d6002 100755 --- a/app/Views/policy_type_list.php +++ b/app/Views/policy_type_list.php @@ -250,12 +250,16 @@ ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true , diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index edbfa6d8..2261d79c 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -103,8 +103,8 @@ table.dataTable tbody td {
    Premium
    (without GST)
    Total PremiumBP %TP/Ter %BP%TP/Ter% Rewards Agreed Amount Invoiced Amount  % %%%
    @@ -557,12 +557,16 @@ document.addEventListener("DOMContentLoaded", function () { className:"unmapEmployees" }], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index 5e2376a5..63c64862 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -350,17 +350,22 @@ table.dataTable tbody td { }, className: 'app-btn-primary ', title: 'Tickets' + sheetName: 'Tickets', } ] } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, pageLength: 10, diff --git a/app/Views/ticket_feedback_list.php b/app/Views/ticket_feedback_list.php index 57ab8b6b..3902ca42 100644 --- a/app/Views/ticket_feedback_list.php +++ b/app/Views/ticket_feedback_list.php @@ -131,19 +131,24 @@ $(document).ready(function() { orthogonal: 'sort' }, title: 'claim-List', + sheetName: 'claim-List', className: 'app-btn-primary ', } ] } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" - }, + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' + }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) ordering: false, diff --git a/app/Views/ticket_history.php b/app/Views/ticket_history.php index 505fe971..54711dd2 100644 --- a/app/Views/ticket_history.php +++ b/app/Views/ticket_history.php @@ -60,13 +60,17 @@ if (ticketsTable.length) { // ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" - }, + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' + }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) ordering: false, diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index e1b306e9..bc5c065b 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -315,6 +315,7 @@ $(document).ready(function() { extend: 'excel', text: ' EXCEL ', title: 'claim-List', + sheetName: 'claim-List', exportOptions: { orthogonal: 'sort' }, @@ -324,12 +325,16 @@ $(document).ready(function() { } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php index d816f2a3..a2cc86d5 100644 --- a/app/Views/ticket_mail_template.php +++ b/app/Views/ticket_mail_template.php @@ -265,12 +265,16 @@ } }], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) diff --git a/app/Views/tpa_list.php b/app/Views/tpa_list.php index 19737cdc..412b9910 100755 --- a/app/Views/tpa_list.php +++ b/app/Views/tpa_list.php @@ -208,13 +208,17 @@ } ], language: { - search: ` -
    + search: ` +
    _INPUT_ - + +
    `, - searchPlaceholder: "Search" - }, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' + }, paging: true, }); diff --git a/app/Views/variance_report_list.php b/app/Views/variance_report_list.php index 5e59e7fc..800334a1 100644 --- a/app/Views/variance_report_list.php +++ b/app/Views/variance_report_list.php @@ -236,7 +236,8 @@ { extend: 'excel', text: ' EXCEL ', - title: 'Variance-Report-List', + title: 'Variance-Report-List', + sheetName: 'Variance-Report-List', // Sheet name customize: function(xlsx) { var sheet = xlsx.xl.worksheets['sheet1.xml']; var total = 0; @@ -267,13 +268,17 @@ } ] }], - language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + language: { + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, paging: true, // Enable pagination pageLength: 25 // Set default number of rows per page (optional) diff --git a/app/Views/vehicle_master_list.php b/app/Views/vehicle_master_list.php index 9d83d62e..2e54f852 100644 --- a/app/Views/vehicle_master_list.php +++ b/app/Views/vehicle_master_list.php @@ -499,6 +499,7 @@ $(document).ready(function() { }, { extend: 'excel', + sheetName: 'Vehicle-Master', text: ' EXCEL ', exportOptions: { orthogonal: 'sort' @@ -509,13 +510,17 @@ $(document).ready(function() { } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" - }, + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' + }, paging: true, pageLength: 10, order: [[0, 'desc']] diff --git a/app/Views/vehicle_type_list.php b/app/Views/vehicle_type_list.php index 3cc0de76..ce0181d5 100644 --- a/app/Views/vehicle_type_list.php +++ b/app/Views/vehicle_type_list.php @@ -845,6 +845,7 @@ text: ' EXCEL ', exportOptions: { orthogonal: 'sort' }, className: 'app-btn-primary', + sheetName: 'Vehicle-Type', exportOptions: { columns: ':not(:last-child)' } @@ -855,13 +856,17 @@ paging: true, pageLength: 10, language: { - search: ` -
    + search: ` +
    _INPUT_ - + +
    `, - searchPlaceholder: "Search" - }, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' + }, initComplete: function () { $(".dt-buttons").prepend(`
    diff --git a/app/Views/vehicle_type_master_list.php b/app/Views/vehicle_type_master_list.php index 7dd4e3a1..fd6d0801 100755 --- a/app/Views/vehicle_type_master_list.php +++ b/app/Views/vehicle_type_master_list.php @@ -124,12 +124,16 @@ ], language: { search: ` -
    +
    _INPUT_ - + +
    `, - searchPlaceholder: "Search" - }, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' + }, paging: true, // Enable pagination pageLength: 10, // Set default number of rows per page (optional) // ordering: false, diff --git a/app/Views/view_deposit.php b/app/Views/view_deposit.php index 606da89e..d382d21c 100755 --- a/app/Views/view_deposit.php +++ b/app/Views/view_deposit.php @@ -347,12 +347,16 @@ } ], language: { - search: ` -
    - _INPUT_ - -
    `, - searchPlaceholder: "Search" + search: ` +
    + _INPUT_ + + +
    `, + searchPlaceholder: "Search", + emptyTable: '
    No Data found
    ' }, ordering: false, paging: true