diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 953375e6..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'); 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 55bc121f..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,7 +5661,7 @@ class ClientController extends AdminController // $employeeController = new EmployeeController(); // $employeeController->truncateFileData('633'); - $res = $this->getHrAccessData(4005); dd($res); + // $res = $this->getHrAccessData(4075); dd($res); // ---------- TICKET SERVICE CONTROLLER -------------------------------------------------------------------------------- @@ -5702,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-------------------------------------------------------------------------------- @@ -7025,177 +7025,434 @@ 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() @@ -7236,7 +7493,6 @@ class ClientController extends AdminController $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); @@ -7847,7 +8103,4 @@ class ClientController extends AdminController - - - } 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 afaa2e1c..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(); 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 7f55abd6..761ceffa 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -1518,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(); @@ -1681,8 +1676,7 @@ class RestAuthenticationController extends AdminController if ($employeeData && password_verify($old_password, $employeeData['password'])) { // Hash new password - // $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); - $newHashedPassword = $new_password; + $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); // Update password and clear OTP $updated = $this->employeeModel->update($employeeData['id'], [ @@ -1697,7 +1691,7 @@ class RestAuthenticationController extends AdminController } }else{ - return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'User not found'], 404); + return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'Old password is incorrect'], 404); } } catch (\Throwable $th) { 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/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 @@ - + -