diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9ab269ae..b9cd244a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -183,6 +183,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->post('get_emp_history','EmployeeController::getEmpHistory'); }); + + $routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->group("insurer", ["filter" => "authMVC"], function ($routes) { @@ -561,7 +563,15 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("ticketConversationSave", "ThzController::ticketConversationSave"); $routes->get("ticketConversationList", "ThzController::ticketConversationList"); + $routes->get("hrFileList", "EmployeeRestController::hrFileList"); + $routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); + $routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload"); + $routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload"); + $routes->post("updateHrFileUploadData", "EmployeeRestController::updateHrFileUploadData"); + }); +$routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); +$routes->post("hrFileList", "EmployeeRestController::hrFileList"); $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index d8ec8b0e..6fc764b3 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -34,6 +34,7 @@ use App\Models\TicketMasterModel; use App\Models\TicketMessageModel; use App\Models\HRAccessControlModel; use App\Models\InsurerModel; +use App\Models\HrFileUploadModel; @@ -87,6 +88,7 @@ class EmployeeRestController extends AdminController protected $ticketController; protected $hrAccessControlModel; protected $insurerModel; + protected $hrFileUploadModel; public function __construct() @@ -118,6 +120,7 @@ class EmployeeRestController extends AdminController $this->ticketController = new TicketController(); $this->hrAccessControlModel = new HRAccessControlModel(); $this->insurerModel = new InsurerModel(); + $this->hrFileUploadModel = new HrFileUploadModel(); } @@ -3781,4 +3784,232 @@ class EmployeeRestController extends AdminController return $response->getBody(); } + + + //-------------------------------------------------------------------------------------------- + public function hrFileUpload() + { + try { + // Check file + $file = $this->request->getFile('file_name'); + if (!$file) { + return $this->response->setJSON([ + 'status' => false, + 'message' => "Invalid file or file not uploaded.", + 'data' => "No Data" + ]); + } + + // Upload folder path + $uploadPath = WRITEPATH . 'uploads/hr_files/'; + + // If directory not exists, create it + if (!is_dir($uploadPath)) { + mkdir($uploadPath, 0777, true); + } + + // New file name with timestamp + $newFileName = time() . '_' . $file->getRandomName(); + + // Move file + $file->move($uploadPath, $newFileName); + + // Prepare data + $data = [ + 'client_id' => $this->request->getPost('client_id'), + 'client_branch_id' => $this->request->getPost('client_branch_id'), + 'policy_no' => $this->request->getPost('policy_no'), + 'file_name' => $newFileName, + 'file_action' => $this->request->getPost('file_action'), + 'status' => 'Yet to start', + 'created_by' => $this->request->getPost('created_by'), + 'updated_by' => $this->request->getPost('created_by'), + ]; + + // Save into DB + $this->hrFileUploadModel->insert($data); + + return $this->respondCreated([ + 'status' => true, + 'message' => 'File uploaded successfully', + 'data' => $data + ]); + + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + + } + + public function updateHrFileUploadData() + { + try { + $id = $this->request->getPost('id'); + + if (!$id) { + return $this->failValidationErrors('ID is required for update.'); + } + + // Prepare data + $data = [ + 'client_id' => $this->request->getPost('client_id'), + 'client_branch_id' => $this->request->getPost('client_branch_id'), + 'policy_no' => $this->request->getPost('policy_no'), + 'file_action' => $this->request->getPost('file_action'), + 'status' => $this->request->getPost('status'), + 'updated_by' => $this->request->getPost('updated_by'), + ]; + + // Check if record exists + $record = $this->hrFileUploadModel->find($id); + if (!$record) { + return $this->failNotFound("Record with ID {$id} not found."); + } + + // Update record + $this->hrFileUploadModel->update($id, $data); + + return $this->respond([ + 'status' => true, + 'message' => 'File record updated successfully', + 'data' => $data + ], 200); + + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + + public function hrFileDownload($id = null) + { + try { + + $file_id = $this->request->getGet('id') ?? $id; + + // Find record + $record = $this->hrFileUploadModel->where('id',$file_id)->find(); + + // print_rr( $record);die; + + if (!$record) { + return $this->failNotFound("File record not found"); + } + + $uploadPath = WRITEPATH . 'uploads/hr_files/'; + $filePath = $uploadPath . $record[0]['file_name']; + + if (!file_exists($filePath)) { + return $this->failNotFound("File not found on server"); + } + + // Force file download + return $this->response->download($filePath, null) + ->setFileName($record[0]['file_name']); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + // public function hrFileList() + // { + // try { + // $request = service('request'); + // $builder = $this->hrFileUploadModel + // ->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name '); + + // // Allowed filter keys + // $filters = [ + // 'client_id', + // 'client_branch_id', + // 'policy_no', + // 'file_action', + // 'status', + // 'created_by' + // ]; + + // // Apply filters dynamically + // foreach ($filters as $key) { + // $value = $request->getGetPost($key); // supports both GET and POST + // if (!empty($value)) { + // $builder->where($key, $value); + // } + // } + + // // Fetch results + // $builder->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left'); + // $builder->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left'); + // $builder->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left'); + // $data = $builder->findAll(); + + // return $this->respond([ + // 'status' => true, + // 'message' => 'File list fetched successfully', + // 'data' => $data + // ]); + // } catch (\Exception $e) { + // return $this->failServerError($e->getMessage()); + // } + // } + + public function hrFileList() + { + try { + $request = service('request'); + + // Start builder from model + $builder = $this->hrFileUploadModel + ->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name') + ->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left') + ->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left') + ->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left'); + + // Allowed filter keys + $filters = [ + 'client_id', + 'client_branch_id', + 'policy_no', + 'file_action', + 'status', + 'created_by' + ]; + + // Apply filters dynamically + foreach ($filters as $key) { + $value = $request->getGetPost($key); // supports both GET and POST + if (!empty($value)) { + $builder->where("hr_file_upload.$key", $value); + } + } + + // Execute query + $data = $builder->get()->getResultArray(); + + return $this->respond([ + 'status' => "success", + 'message' => 'File list fetched successfully', + 'data' => $data + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + + public function hrFileUploadMasters() + { + try { + //for inception upload + $data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement']; + + return $this->respond([ + 'status' => true, + 'message' => 'File inception upload masters', + 'data' => $data + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + } \ No newline at end of file diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index 0141ef61..059ebfce 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -96,6 +96,7 @@ class ThzController extends BaseController $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu // 2,3,4 remain person varannum. $data['client_list'] = $this->clientModel->getCreatedByUserName(); + return $this->loadLayout('thz_list', $data); } @@ -149,7 +150,7 @@ class ThzController extends BaseController $policyIds = array_column($details, 'policy_id'); $policyIds = array_filter($policyIds); - $clientPolicy = $this->clientPolicyModel->whereIn('policy_id', $policyIds)->where('is_active', 1)->get()->getResultArray(); + $clientPolicy = $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray(); $result['client_details'] = $details; $result['policy_details'] = empty($clientPolicy) ? [] : $clientPolicy ; @@ -195,14 +196,19 @@ class ThzController extends BaseController if ($returnType === 'api') { return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); }else{ - $toGetRelated = $result['master'][0]['created_by']; + $toGetCreatedBy = $result['master'][0]['created_by']; + $toGetPolicyId = (!empty($result['master'][0]['policy_id']) && strtolower($result['master'][0]['policy_id']) !== 'null') + ? $result['master'][0]['policy_id'] + : ''; + $result['related_tickets'] = $this->thzMasterModel ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') - ->where('thz_master.created_by', $toGetRelated) + ->where('thz_master.created_by', $toGetCreatedBy) ->findAll(); $result['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu // 2,3,4 remain person varannum. + $result['policy_terms'] = $toGetPolicyId ? $this->getPolicyTerms($toGetPolicyId) : ''; return $this->loadLayout('thz_notes', $result); } @@ -449,6 +455,23 @@ class ThzController extends BaseController } + public function getPolicyTerms($client_policy_id) + { + $policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $client_policy_id)->first(); + + $policy_terms = []; + if(isset($policy_data['policy_terms']) && !empty($policy_data['policy_terms'])){ + + $raw_terms = json_decode($policy_data['policy_terms'] ?? [] , true) ?? []; + + $ticketController = new TicketController(); + $policy_terms = $ticketController->convertTermsToDisplay($raw_terms); + } + + $data['policy_terms'] = $policy_terms; + return view('view_policy_terms', $data); + } + } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index a50b55be..800f464b 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -2386,17 +2386,20 @@ class TicketController extends BaseController } // 5. Merge the Sum Insured value if the multiple sum insured exists - if(isset($data['multiple_sum_insured'])){ - if(isset($data['sumInsured2'])){ - $data['sumInsured2'] = $data['sumInsured2'] . ", " . implode(", ", $data['multiple_sum_insured']); - }else{ - $data['sum_insured'] = $data['sum_insured'] . ", " . implode(", ", $data['multiple_sum_insured']); + if (isset($data['multiple_sum_insured'])) { + + $multipleSumInsured = is_array($data['multiple_sum_insured']) ? $data['multiple_sum_insured'] : [$data['multiple_sum_insured']]; // force into array if string + + if (isset($data['sumInsured2'])) { + $data['sumInsured2'] .= ", " . implode(", ", $multipleSumInsured); + } else { + $data['sum_insured'] .= ", " . implode(", ", $multipleSumInsured); } + unset($data['multiple_sum_insured']); } // 6. Add the special condition to key value pair - if(!empty($data['special_condition_label'])){ foreach ($data['special_condition_label'] as $key => $value) { if($value != "" && $value != null) { diff --git a/app/Models/HrFileUploadModel.php b/app/Models/HrFileUploadModel.php new file mode 100644 index 00000000..e5e2a22b --- /dev/null +++ b/app/Models/HrFileUploadModel.php @@ -0,0 +1,34 @@ +db->query($notes_sql)->getResultArray(); diff --git a/app/Views/hr_file_upload.php b/app/Views/hr_file_upload.php new file mode 100644 index 00000000..e9dce959 --- /dev/null +++ b/app/Views/hr_file_upload.php @@ -0,0 +1,383 @@ + + +
+
+
+
+
+
+ + + +
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+
+
+

Files

+
+ +
+ + + + + + + + + + + + + + + + + $file) { ?> + + + + + + + + + + + + + + + +
SNOFile nameClientClient BranchPolicyEventUser/TimeStatusAction
+ + ' . $file['first_name'] . '' ?>
+
+
+
+ +
+ +
+ + + \ No newline at end of file diff --git a/app/Views/import_export.php b/app/Views/import_export.php index 604e9853..0879c988 100755 --- a/app/Views/import_export.php +++ b/app/Views/import_export.php @@ -25,10 +25,17 @@ Insurer or TPA Data +
+
@@ -45,6 +52,11 @@ $('#kyc_tab').click(); } + if (window.location.hash === '#HR-DOC-tab') { + console.log('url hash :', window.location.hash) + $('#hr_tab').click(); + } + }) diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 712a44f1..dc34b27d 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -537,7 +537,7 @@ .show > .btn-ternary:dropdown-toggle:focus { box-shadow: 0 0 0 0.15rem rgba(226, 103, 40, 0.5); } - .btn-border-radius{ .border-radius: 10px !important; } + .btn-border-radius{ border-radius: 10px !important; } diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index e711f27a..986c4594 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -80,6 +80,11 @@ tbody tr td:last-child { white-space: nowrap !important; } +.maincard{ + margin-top:0 !important; + padding-top: 0 !important; +} + .col-12 { max-width: 98% !important; @@ -122,8 +127,8 @@ td .text-muted {
-
-
+
+

Ticket List

@@ -155,7 +160,10 @@ td .text-muted {
- + + @@ -259,22 +267,23 @@ td .text-muted {
+
+ + +
+ +
-
- - -
- - - + +
+ +
- + - +
@@ -368,6 +378,11 @@ td .text-muted { myModal.show(); } + function resetTicket(){ + var form = document.getElementById('ticketForm'); + form.reset(); + } + function submitTicket() { var form = document.getElementById('ticketForm'); @@ -483,14 +498,14 @@ td .text-muted { let opt = document.createElement("option"); opt.value = p.policy_no; opt.text = p.policy_no; - opt.setAttribute("data-id", p.policy_id); + opt.setAttribute("data-id", p.id); policySelect.appendChild(opt); }); // If you want to auto-select the first real policy instead of "Select Policy" policySelect.value = policies[0].policy_no; document.getElementById('policy_no').value = policies[0].policy_no || ""; - document.getElementById('policy_id').value = policies[0].policy_id; + document.getElementById('policy_id').value = policies[0].id; } } else { toastr.warning(response.message || "No details found.", 'warning'); @@ -512,6 +527,19 @@ td .text-muted { var policyId = selectedOption.getAttribute("data-id"); document.getElementById('policy_id').value = policyId || ""; } + + function hideandshowpolicy() { + var select = document.getElementById('ticket_type').value; + var policyContainer = document.getElementById('policy_container'); + + if (select === 'Service') { + policyContainer.style.display = "block"; // show + } else { + policyContainer.style.display = "none"; // hide + document.getElementById('policy_no').value = ""; + document.getElementById('policy_id').value = ""; + } + }