diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 15c4aa0a..251e26ee 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -817,6 +817,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->post('saveIRDocsJson',"TicketController::saveIRDocsJson"); $routes->get('getTpaClaimStatus',"ApiServiceController::getClaimStatus"); $routes->post('manualTpaClaimPush',"ApiServiceController::manualTpaClaimPush"); + $routes->match(['get', 'post'], 'getClaimTemplateData', 'TicketController::getClaimTemplateData'); + $routes->post('uploadApprovedLetterFromReply', 'TicketController::uploadApprovedLetterFromReply'); }); // Non-EB Claims diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 7d5e4c97..d590bae4 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3925,7 +3925,6 @@ class EmployeeRestController extends AdminController $count = $this->ticketMaster->where('id', $ticket_id)->where('is_active', 1)->where('tpa_claim_push_reference_no IS NULL')->countAllResults(); log_message('error', 'Ticket validation | Ticket ID: ' . $ticket_id . ' | Matching active tickets with NULL TPA reference: ' . $count); - if ($count > 0 && $pdf_exist_in_the_file && $tpa_claim_push == true) { try { // this call for TPA integration @@ -3945,6 +3944,16 @@ class EmployeeRestController extends AdminController } } + if($tpa_claim_push == false){ + try { + // this call for TPA integration Multiple document push for IR DOCUMENTS + $apiServiceController = new ApiServiceController(); + $apiServiceController->pushClaimFiles($ticket_id); + log_message('error', "pushClaimFiles IR FILE SUBMISSION function called with Ticket ID: {$ticket_id}, In Employee Rest Controller"); + } catch (\Throwable $e) { + log_message('error', "Error in TPA Claim Files Push via CRM : ApiServiceController pushClaims function call for Ticket ID: {$ticket_id}. Error: " . $e->getMessage() . " Trace: " . $e->getTraceAsString()); + } + } return $insert_ids; } @@ -4530,8 +4539,8 @@ class EmployeeRestController extends AdminController // print_r($post_data); die; - $Query = $this->clientPolicyModel - ->select(" + $Query = $this->clientPolicyModel + ->select(" client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, @@ -4544,14 +4553,14 @@ class EmployeeRestController extends AdminController DATE_FORMAT(client_policy.policy_end_date, '%d-%m-%Y') AS policy_expiry_date, CASE WHEN policy_type.allocg IN ('Non-EB', 'Marine') THEN 'Non-EB' ELSE 'EB' END as allocg ", false) - ->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left') - ->where('md5(client_policy.client_id)', $post_data['client_id']) - ->where('client_policy.client_branch_id', $post_data['client_branch_id']) - ->where('client_policy.is_active', 1); + ->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left') + ->where('md5(client_policy.client_id)', $post_data['client_id']) + ->where('client_policy.client_branch_id', $post_data['client_branch_id']) + ->where('client_policy.is_active', 1); // ->where('client_policy.policy_status', $this->request->getGet('policy_status')) - if(is_array($post_data['policy_id'])){ + if (is_array($post_data['policy_id'])) { $Query->whereIn('client_policy.id', $post_data['policy_id']); - }else{ + } else { $Query->where('client_policy.id', $post_data['policy_id']); } $ClientPolicyData = $Query->first(); @@ -4581,9 +4590,9 @@ class EmployeeRestController extends AdminController } return $this->respondCreated($responce); - } catch (\Exception $e) { // return $this->failServerError($e->getMessage()); + log_message('error', 'Error in hrFileUpload: ' . $e->getMessage() . ' in file ' . $e->getFile() . ' on line ' . $e->getLine() . ' Trace: ' . $e->getTraceAsString()); return $this->respondCreated(['status' => false, 'message' => $e->getMessage(), 'data' => []]); } } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 75fd9800..863b1bb1 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -277,61 +277,61 @@ class MasterController extends AdminController echo view('insurer_onboarding', $data); echo view('layout/footer'); - } + } public function createInsurerGeneralInfo() { - $this->myLogger->logme('error','Insurer general info function called'); + $this->myLogger->logme('error', 'Insurer general info function called'); $rules = [ - 'name' => [ - 'label' => 'Insurer Name', - 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s\-_]+$/]'], - 'errors' => [ - 'required' => 'Insurer Name is required.', - 'regex_match' => 'Insurer Name can only contain letters, numbers, spaces, hyphens, and underscores.', - ] - ], - 'short_name' => [ - 'label' => 'Insurer Short Name', - 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\-_]+$/]'], - 'errors' => [ - 'required' => 'Short Name is required.', - 'regex_match' => 'Short Name can only contain letters, numbers, hyphens, and underscores.', - ] - ], - 'type' => [ - 'label' => 'Insurer Type', - 'rules' => 'permit_empty|in_list[pvt,psu]', - 'errors' => [ - 'in_list' => 'Please select a valid Insurer Type (PVT or PSU).' - ] - ], - 'category' => [ - 'label' => 'Insurer Category', - 'rules' => 'permit_empty|in_list[life,general]', - 'errors' => [ - 'in_list' => 'Please select a valid Category (Life or General).' - ] - ], - 'addition_add_day' => [ - 'rules' => 'permit_empty' // Checkboxes return null if unchecked - ], - 'deletion_add_day' => [ - 'rules' => 'permit_empty' - ], - 'is_multi_event' => [ - 'rules' => 'permit_empty' - ], - 'insurer_logo' => [ + 'name' => [ + 'label' => 'Insurer Name', + 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s\-_]+$/]'], + 'errors' => [ + 'required' => 'Insurer Name is required.', + 'regex_match' => 'Insurer Name can only contain letters, numbers, spaces, hyphens, and underscores.', + ] + ], + 'short_name' => [ + 'label' => 'Insurer Short Name', + 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\-_]+$/]'], + 'errors' => [ + 'required' => 'Short Name is required.', + 'regex_match' => 'Short Name can only contain letters, numbers, hyphens, and underscores.', + ] + ], + 'type' => [ + 'label' => 'Insurer Type', + 'rules' => 'permit_empty|in_list[pvt,psu]', + 'errors' => [ + 'in_list' => 'Please select a valid Insurer Type (PVT or PSU).' + ] + ], + 'category' => [ + 'label' => 'Insurer Category', + 'rules' => 'permit_empty|in_list[life,general]', + 'errors' => [ + 'in_list' => 'Please select a valid Category (Life or General).' + ] + ], + 'addition_add_day' => [ + 'rules' => 'permit_empty' // Checkboxes return null if unchecked + ], + 'deletion_add_day' => [ + 'rules' => 'permit_empty' + ], + 'is_multi_event' => [ + 'rules' => 'permit_empty' + ], + 'insurer_logo' => [ 'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]', 'errors' => [ 'is_image' => 'The uploaded file must be an image', 'max_size' => 'File size should not exceed 200 KB', 'ext_in' => 'Allowed file types: jpg, jpeg, png', ] - ], -]; + ], + ]; // $rules = [ // 'name' => [ // 'rules' => 'required', @@ -3538,8 +3538,9 @@ class MasterController extends AdminController { $posModel = new PartnerPosModel(); $method = $this->request->getMethod(); - + if ($this->request->getMethod() === 'post') { + try { $rules = [ 'manager_id' => [ @@ -3555,7 +3556,7 @@ class MasterController extends AdminController 'required' => 'Name is required', 'min_length' => 'Name must be at least 3 characters', 'max_length' => 'Name cannot exceed 100 characters', - 'alpha_space'=> 'Name can contain only letters and spaces' + 'alpha_space' => 'Name can contain only letters and spaces' ] ], 'pos_code' => [ @@ -3589,27 +3590,27 @@ class MasterController extends AdminController ] ], 'state' => [ - 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', - 'errors' => [ - 'required' => 'State is required.', - 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' - ] - ], - 'city' => [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]', - 'errors' => [ - 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.' - ] - ], - 'pincode' => [ - 'rules' => 'required|numeric|exact_length[6]', - 'errors' => [ - 'required' => 'Pincode is required.', - 'numeric' => 'Pincode must be digits only.', - 'exact_length' => 'Pincode must be exactly 6 digits.' - ] - ], + 'label' => 'State', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/\-\_\.\s]+$/]', + 'errors' => [ + 'required' => 'State is required.', + 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' + ] + ], + 'city' => [ + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]', + 'errors' => [ + 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.' + ] + ], + 'pincode' => [ + 'rules' => 'required|numeric|exact_length[6]', + 'errors' => [ + 'required' => 'Pincode is required.', + 'numeric' => 'Pincode must be digits only.', + 'exact_length' => 'Pincode must be exactly 6 digits.' + ] + ], 'aadhar' => [ 'rules' => 'required|numeric|exact_length[12]', 'errors' => [ @@ -3632,25 +3633,22 @@ class MasterController extends AdminController ] ], 'aadhar_file_name' => [ - 'rules' => 'permit_empty|uploaded[aadhar_file_name]|max_size[aadhar_file_name,5120]|ext_in[aadhar_file_name,pdf,jpg,jpeg,png]', + 'rules' => 'if_exist|max_size[aadhar_file_name,5120]|ext_in[aadhar_file_name,pdf,jpg,jpeg,png]', 'errors' => [ - 'uploaded' => 'Invalid Aadhaar file', 'max_size' => 'Aadhaar file size should not exceed 5MB', 'ext_in' => 'Aadhaar must be PDF or image (jpg, jpeg, png)' ] ], 'pan_file_name' => [ - 'rules' => 'permit_empty|uploaded[pan_file_name]|max_size[pan_file_name,5120]|ext_in[pan_file_name,pdf,jpg,jpeg,png]', + 'rules' => 'if_exist|max_size[pan_file_name,5120]|ext_in[pan_file_name,pdf,jpg,jpeg,png]', 'errors' => [ - 'uploaded' => 'Invalid PAN file', 'max_size' => 'PAN file size should not exceed 5MB', 'ext_in' => 'PAN must be PDF or image (jpg, jpeg, png)' ] ], 'certificate_file_name' => [ - 'rules' => 'permit_empty|uploaded[certificate_file_name]|max_size[certificate_file_name,5120]|ext_in[certificate_file_name,pdf,jpg,jpeg,png]', + 'rules' => 'if_exist|max_size[certificate_file_name,5120]|ext_in[certificate_file_name,pdf,jpg,jpeg,png]', 'errors' => [ - 'uploaded' => 'Invalid Certificate file', 'max_size' => 'Certificate file size should not exceed 5MB', 'ext_in' => 'Certificate must be PDF or image (jpg, jpeg, png)' ] @@ -3669,138 +3667,217 @@ class MasterController extends AdminController $data = $this->request->getPost(); $sanitized_post_data = sanitizeInputArrayAdvanced($data); $id = $sanitized_post_data['pk'] ?? null; - unset($sanitized_post_data['pk']); + unset($sanitized_post_data['pk']); try { // Certificate $certificate = $this->uploadPOSFile('certificate_file_name', 'pos_certificate_files'); - if ($certificate !== null) { $sanitized_post_data['certificate_file_name'] = $certificate; } else { unset($sanitized_post_data['certificate_file_name']); } + if ($certificate !== null) { + $sanitized_post_data['certificate_file_name'] = $certificate; + } else { + unset($sanitized_post_data['certificate_file_name']); + } // PAN file $panFile = $this->uploadPOSFile('pan_file_name', 'pos_certificate_files'); - if ($panFile !== null) { $sanitized_post_data['pan_file_name'] = $panFile; } else { unset($sanitized_post_data['pan_file_name']);} + if ($panFile !== null) { + $sanitized_post_data['pan_file_name'] = $panFile; + } else { + unset($sanitized_post_data['pan_file_name']); + } // Aadhaar file $aadharFile = $this->uploadPOSFile('aadhar_file_name', 'pos_certificate_files'); - if ($aadharFile !== null) { $sanitized_post_data['aadhar_file_name'] = $aadharFile; } else { unset($sanitized_post_data['aadhar_file_name']);} - - } catch (\RuntimeException $e) { - return $this->respond([ 'status' => false, 'code' => 400, 'message' => $e->getMessage(), 'data' => $sanitized_post_data ], 400); + if ($aadharFile !== null) { + $sanitized_post_data['aadhar_file_name'] = $aadharFile; + } else { + unset($sanitized_post_data['aadhar_file_name']); + } + } catch (\Exception $e) { + log_message('error', 'File upload error: ' . $e->getMessage() . ' | POST data: ' . json_encode($sanitized_post_data) . $e->getTraceAsString()); + return $this->respond(['status' => false, 'code' => 400, 'message' => $e->getMessage(), 'data' => $sanitized_post_data], 400); } - foreach ($sanitized_post_data as $k => $v) { - if ($v === '' || $v === null) { - unset($sanitized_post_data[$k]); - } + foreach ($sanitized_post_data as $k => $v) { + if ($v === '' || $v === null) { + unset($sanitized_post_data[$k]); } - + } + // INSERT / UPDATE - if (empty($id)) { - $status = $posModel->insert($sanitized_post_data); - } else { - $status = $posModel->update($id, $sanitized_post_data); - } + try { + if (empty($id)) { + $status = $posModel->insert($sanitized_post_data); + } else { + $status = $posModel->update($id, $sanitized_post_data); + } - if ($status) { - return $this->respond([ 'status' => true, 'code' => 200, 'message' => 'POS updated successfully', 'data' => $sanitized_post_data ], 200); - } + if ($status) { + return $this->respond(['status' => true, 'code' => 200, 'message' => 'POS updated successfully', 'data' => $sanitized_post_data], 200); + } - return $this->respond([ 'status' => false, 'code' => 400, 'message' => 'Failed to update', 'data' => $sanitized_post_data ], 400); - } - elseif ($method === 'get') { + $modelErrors = method_exists($posModel, 'errors') ? $posModel->errors() : []; + return $this->respond([ + 'status' => false, + 'code' => 400, + 'message' => 'Failed to update', + 'errors' => $modelErrors, + 'data' => $sanitized_post_data + ], 400); + } catch (\Throwable $e) { + log_message('error', 'partnerPOS DB error: ' . $e->getMessage() . ' | payload: ' . json_encode($sanitized_post_data) . ' | trace: ' . $e->getTraceAsString()); - $id = $this->request->getGet('pk') ?? null; + $message = 'Something went wrong while saving POS details.'; + $statusCode = 500; - $db = db_connect(); - - $builder = $db->table('partner_staff'); - - $data['manager_list'] = $builder->select('partner_staff.id, partner_staff.name') - ->where('partner_staff.is_active', 1) - ->where('partner_staff.role_id', 1) - ->get() - ->getResultArray(); - - - if (!empty($id)) { - - $data['pos_list'] = $posModel - ->select('partner_pos.*, partner_staff.name AS manager_name') - ->join('partner_staff', 'partner_staff.id = partner_pos.manager_id', 'left') - ->where('partner_pos.id', $id) - ->orderBy('partner_pos.id', 'DESC') - ->findAll(); - - if (!empty($data)) { - return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200); - } else { - return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200); - } - } - - $data['pos_list'] = $posModel - ->select('partner_pos.*, ps.name AS manager_name') - ->join('partner_staff ps', 'ps.id = partner_pos.manager_id', 'left') - ->orderBy('partner_pos.id', 'DESC') - ->findAll(); - - - return $this->loadLayout('pos_list', ['data' => $data,'tab_name' => 'POS details','page_name' => 'POS details']); - - } elseif ($method === 'delete') { - - // $input = $this->request->getRawInput(); - $id = $this->request->getGet('pk'); // ✅ THIS - $id = $id ?? null; - - if (empty($id)) { - return $this->respond([ - 'status' => false, - 'code' => 404, - 'message' => 'No ID provided for deletion' - ], 200); - } - - $update_status = $posModel->where('id', $id)->set(['is_active' => 0])->update(); - - if ($update_status) { - return $this->respond([ - 'status' => true, - 'code' => 200, - 'message' => 'Data removed successfully', - 'pk' => $id - ], 200); - } else { - return $this->respond([ - 'status' => false, - 'code' => 400, - 'message' => 'Failed to remove data', - 'pk' => $id - ], 200); - } + if (stripos($e->getMessage(), 'Duplicate entry') !== false) { + $statusCode = 400; + if (stripos($e->getMessage(), 'email') !== false) { + $message = 'Email already exists.'; + } elseif (stripos($e->getMessage(), 'mobile') !== false) { + $message = 'Mobile number already exists.'; + } else { + $message = 'Duplicate data found. Please check email/mobile.'; } } - private function uploadPOSFile(string $fieldName, string $uploadDir) - { - $file = $this->request->getFile($fieldName); + return $this->respond([ + 'status' => false, + 'code' => $statusCode, + 'message' => $message + ], $statusCode); + } + } catch (\Throwable $e) { + log_message( + 'error', + 'partnerPOS fatal error: ' . $e->getMessage() . + ' | file: ' . $e->getFile() . + ' | line: ' . $e->getLine() . + ' | trace: ' . $e->getTraceAsString() + ); + return $this->respond([ + 'status' => false, + 'code' => 500, + 'message' => 'Internal server error while processing POS request.' + ], 500); + } + } elseif ($method === 'get') { - if (!$file || !$file->isValid()) { return null; } + $id = $this->request->getGet('pk') ?? null; - $allowedMime = [ 'image/jpg', 'image/jpeg', 'image/png', 'image/webp', 'application/pdf']; + $db = db_connect(); - if (!in_array($file->getMimeType(), $allowedMime)) { throw new \RuntimeException('Invalid file format'); } + $builder = $db->table('partner_staff'); - $path = ROOTPATH . 'public/uploads/' . $uploadDir . '/'; + $data['manager_list'] = $builder->select('partner_staff.id, partner_staff.name') + ->where('partner_staff.is_active', 1) + ->where('partner_staff.role_id', 1) + ->get() + ->getResultArray(); - if (!is_dir($path)) { mkdir($path, 0755, true); } - $newName = $file->getRandomName(); - $file->move($path, $newName); + if (!empty($id)) { - return $newName; + $data['pos_list'] = $posModel + ->select('partner_pos.*, partner_staff.name AS manager_name') + ->join('partner_staff', 'partner_staff.id = partner_pos.manager_id', 'left') + ->where('partner_pos.id', $id) + ->orderBy('partner_pos.id', 'DESC') + ->findAll(); + + if (!empty($data)) { + return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200); + } else { + return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200); } + } + + $data['pos_list'] = $posModel + ->select('partner_pos.*, ps.name AS manager_name') + ->join('partner_staff ps', 'ps.id = partner_pos.manager_id', 'left') + ->orderBy('partner_pos.id', 'DESC') + ->findAll(); - } \ No newline at end of file + return $this->loadLayout('pos_list', ['data' => $data, 'tab_name' => 'POS details', 'page_name' => 'POS details']); + } elseif ($method === 'delete') { + + // $input = $this->request->getRawInput(); + $id = $this->request->getGet('pk'); // ✅ THIS + $id = $id ?? null; + + if (empty($id)) { + return $this->respond([ + 'status' => false, + 'code' => 404, + 'message' => 'No ID provided for deletion' + ], 200); + } + + $update_status = $posModel->where('id', $id)->set(['is_active' => 0])->update(); + + if ($update_status) { + return $this->respond([ + 'status' => true, + 'code' => 200, + 'message' => 'Data removed successfully', + 'pk' => $id + ], 200); + } else { + return $this->respond([ + 'status' => false, + 'code' => 400, + 'message' => 'Failed to remove data', + 'pk' => $id + ], 200); + } + } + } + + private function uploadPOSFile(string $fieldName, string $uploadDir) + { + $file = $this->request->getFile($fieldName); + + if (!$file) { + return null; + } + + // No file selected for this optional input. + if ($file->getError() === UPLOAD_ERR_NO_FILE) { + return null; + } + + if (!$file->isValid()) { + throw new \RuntimeException('File upload failed for ' . $fieldName); + } + + $allowedMime = [ + 'image/jpg', + 'image/jpeg', + 'image/pjpeg', + 'image/png', + 'image/x-png', + 'image/webp', + 'application/pdf' + ]; + + $mimeType = (string) $file->getMimeType(); + if (!in_array($mimeType, $allowedMime, true)) { + throw new \RuntimeException('Invalid file format for ' . $fieldName); + } + + $path = ROOTPATH . 'public/uploads/' . $uploadDir . '/'; + + if (!is_dir($path)) { + mkdir($path, 0755, true); + } + + $newName = $file->getRandomName(); + $file->move($path, $newName); + + return $newName; + } + + +} \ No newline at end of file diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index d46306d4..b3607027 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -539,6 +539,7 @@ class TicketController extends BaseController 'tm.emp_personal_mail', 'tm.mode_of_intimation', 'tm.claim_type', + 'tm.tpa_claim_type', 'tm.hospital_name', 'tm.doa', 'tm.dod', @@ -673,6 +674,7 @@ class TicketController extends BaseController 'tm.emp_personal_mail', 'tm.mode_of_intimation', 'tm.claim_type', + 'tm.tpa_claim_type', 'tm.hospital_name', 'tm.doa', 'tm.dod', @@ -2319,8 +2321,8 @@ class TicketController extends BaseController ->findAll(); foreach ($dataToSend['messages'] as &$message) { - $mail_content_converted = $this->convertHtmlToText($message['mail_content']); - $message['mail_content'] = $mail_content_converted; + // $mail_content_converted = $this->convertHtmlToText($message['mail_content']); + // $message['mail_content'] = $mail_content_converted; $claimFiles = new ClaimFilesModel(); $message["files_data"] = $claimFiles->where('is_active', 1) @@ -2436,7 +2438,7 @@ class TicketController extends BaseController //---- Email Trigger Part---------------------------------------------------------------------------------------------- - public function constructMailContent($ticket_id) + public function constructMailContent($ticket_id, $status_id = null) { $this->myLogger->logme('error', "Constructing mail content for Ticket ID: $ticket_id"); @@ -2452,9 +2454,14 @@ class TicketController extends BaseController $this->myLogger->logme('error', "Fetched ticket data: " . json_encode($ticket_data)); + if (!empty($status_id)) { + $ticket_data['claim_status_id'] = (int) $status_id; + } + // Fetch Email Template Data - $template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); - // print_r($template_data); die; + $template_data = !empty($status_id) + ? ($this->ticketMasterModel->getTemplateDataByStatusID((int) $status_id, (int) ($ticket_data['ticket_type_id'] ?? 0))[0] ?? null) + : $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); if (!$template_data) { $this->myLogger->logme('error', "No email template found for Claim Status ID: " . $ticket_data['claim_status_id']); @@ -2626,7 +2633,7 @@ class TicketController extends BaseController 'mail' => [$mail_data['emp_mail'], $ticket_data['emp_personal_mail'] ?? ""], 'subject' => $mail_data['mail_subject'], 'message' => $mail_data['mail_content'], - 'common' => [], + 'common' => ['module' => "claim", 'pk' => $mail_data['ticket_id']], 'cc' => $acm_mails['common_mails'], 'attachments' => [] ]; @@ -2824,7 +2831,7 @@ class TicketController extends BaseController 'mail' => $template_data['emp_mail'], 'subject' => $template_data['subject'], 'message' => $template_data['mail_content'], - 'common' => [], + 'common' => ['module' => "claim", 'pk' => $ticket_id], 'cc' => $acm_mails['common_mails'], 'attachments' => [] ]; @@ -2985,7 +2992,7 @@ class TicketController extends BaseController 'mail' => $head_mail['email'], 'subject' => $subject, 'message' => $message, - 'common' => [], + 'common' => ['module' => "claim", 'pk' => $ticket_data['id']], ]; $this->sendTrigger($emailData); @@ -3720,7 +3727,7 @@ class TicketController extends BaseController return $input; } - function convertTermsToDisplay(array $data) + public function convertTermsToDisplay(array $data) { $result = []; @@ -3900,6 +3907,106 @@ class TicketController extends BaseController return $result; } + public function getClaimTemplateData() + { + try { + $ticket_id = $this->request->getPost('ticket_id') ?? $this->request->getGet('ticket_id'); + $status_id = $this->request->getPost('status_id') ?? $this->request->getGet('status_id'); + + if (empty($ticket_id) || empty($status_id)) { + return $this->respond(['status' => false, 'message' => 'Ticket ID and Status ID are required'], 400); + } + + $mail_content = $this->constructMailContent($ticket_id, $status_id); + if ($mail_content) { + return $this->respond(['status' => true, 'data' => $mail_content], 200); + } + + return $this->respond(['status' => false, 'message' => 'Failed to construct mail content'], 200); + } catch (\Exception $e) { + $this->myLogger->logme('error', 'Error in getClaimTemplateData: ' . $e->getMessage() . ' in file ' . $e->getFile() . ' on line ' . $e->getLine() . $e->getTraceAsString()); + return $this->respond(['status' => false, 'message' => 'An error occurred while fetching template data'], 500); + } + } + + public function uploadApprovedLetterFromReply() + { + try { + $ticket_id = $this->request->getPost('ticket_id'); + $status_id = $this->request->getPost('status_id'); + $approvedLetterUrl = trim((string) $this->request->getPost('approved_letter')); + $approvedLetterFile = $this->request->getFile('approved_letter_file'); + + if (empty($ticket_id) || empty($status_id)) { + return $this->respond(['status' => false, 'message' => 'Ticket ID and Status ID are required'], 400); + } + + if ((int) $status_id !== 9) { + return $this->respond(['status' => false, 'message' => 'Approved letter upload is allowed only for APPROVED status'], 400); + } + + $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); + if (empty($ticket_data)) { + return $this->respond(['status' => false, 'message' => 'Ticket not found'], 404); + } + + if (!empty($ticket_data['approved_letter'])) { + return $this->respond([ + 'status' => false, + 'message' => 'Approved letter already available', + 'data' => ['approved_letter' => $ticket_data['approved_letter']], + ], 200); + } + + $hasApprovedLetterFile = $approvedLetterFile !== null + && $approvedLetterFile->isValid() + && $approvedLetterFile->getError() !== UPLOAD_ERR_NO_FILE; + + if ($approvedLetterUrl !== '' && $hasApprovedLetterFile) { + return $this->respond([ + 'status' => false, + 'message' => 'Provide either Approved Letter URL or Approved Letter PDF file, not both.', + ], 400); + } + + if ($approvedLetterUrl !== '' && !$this->isClaimUploadUrl($approvedLetterUrl)) { + return $this->respond(['status' => false, 'message' => 'Approved Letter URL format is invalid.'], 400); + } + + if ($approvedLetterUrl === '' && !$hasApprovedLetterFile) { + return $this->respond(['status' => false, 'message' => 'Provide Approved Letter URL or Approved Letter PDF file.'], 400); + } + + $approvedLetterValue = $approvedLetterUrl; + if ($hasApprovedLetterFile) { + $uploadResult = $this->uploadApprovedLetterPdf($approvedLetterFile, 'Approved Letter'); + if (!($uploadResult['status'] ?? false)) { + return $this->respond(['status' => false, 'message' => $uploadResult['message'] ?? 'Invalid Approved Letter file.'], 400); + } + + $approvedLetterValue = $this->createApprovedLetterFileUrl( + (int) $ticket_id, + (int) ($ticket_data['ticket_type_id'] ?? 1), + $uploadResult['data'], + 'APPROVED_LETTER_PDF' + ); + } + + $this->ticketMasterModel + ->where('id', (int) $ticket_id) + ->set(['approved_letter' => $approvedLetterValue]) + ->update(); + + return $this->respond([ + 'status' => true, + 'message' => 'Approved letter uploaded successfully', + 'data' => ['approved_letter' => $approvedLetterValue], + ], 200); + } catch (\Exception $e) { + $this->myLogger->logme('error', 'Error in uploadApprovedLetterFromReply: ' . $e->getMessage() . ' in file ' . $e->getFile() . ' on line ' . $e->getLine() . $e->getTraceAsString()); + return $this->respond(['status' => false, 'message' => 'An error occurred while uploading approved letter'], 500); + } + } // -------- CLAIM DUMP UPLOAD ---------------------------------------------------------------------------------------------- diff --git a/app/Filters/AclFilter.php b/app/Filters/AclFilter.php index c3b052b8..d629afa7 100644 --- a/app/Filters/AclFilter.php +++ b/app/Filters/AclFilter.php @@ -143,7 +143,7 @@ class AclFilter implements FilterInterface $response = service('response'); $response->setStatusCode(403); - $response->setBody(view('errors/404', [ + $response->setBody(view('errors/403', [ 'message' => '403 Access denied - You do not have permission to access this resource' ])); diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 475df9b1..d6202941 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -133,17 +133,20 @@ class TicketMasterModel extends Model return $data; } - public function getTemplateDataByStatusID($claim_status_id) + public function getTemplateDataByStatusID($claim_status_id, $ticket_type_id = null) { - - $template_data = $this->table('ticket_claim_status') + $builder = $this->db->table('ticket_claim_status tcs') ->select('ticket_mail_template.*') - ->join('ticket_mail_template', 'ticket_mail_template.trigger_type = ticket_claim_status.trigger_type') + ->join('ticket_mail_template', 'ticket_mail_template.trigger_type = tcs.trigger_type') ->where('ticket_mail_template.is_active', 1) - ->where('ticket_claim_status.is_active', 1) - ->where('ticket_claim_status.id', $claim_status_id) - ->get() - ->getResultArray(); + ->where('tcs.id', $claim_status_id) + ->where('tcs.is_active', 1); + + if ($ticket_type_id !== null && $ticket_type_id !== '') { + $builder->where('ticket_mail_template.ticket_type', $ticket_type_id); + } + + $template_data = $builder->get()->getResultArray(); return $template_data; } diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php index 96d441b0..c7618915 100755 --- a/app/Views/batch_list.php +++ b/app/Views/batch_list.php @@ -1,4 +1,5 @@ diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php index 4a86c1bd..4a8380b7 100644 --- a/app/Views/claim_files_upload.php +++ b/app/Views/claim_files_upload.php @@ -163,7 +163,6 @@ \ No newline at end of file diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 57070c62..fd00a267 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -171,12 +171,16 @@ input:checked + .slider-branch-contact:before {
+ name="branch_name" required data-parsley-minlength="3" + data-parsley-pattern="^[a-zA-Z0-9\\s_-]+$" + data-parsley-pattern-message="Branch Name can contain letters, numbers, spaces, underscore (_) and hyphen (-).">
+ name="branch_code" onchange="setDefaultUnitValue(this)" required + data-parsley-pattern="^[a-zA-Z0-9_-]+$" + data-parsley-pattern-message="Branch Code can contain letters, numbers, underscore (_) and hyphen (-).">
@@ -204,23 +208,29 @@ input:checked + .slider-branch-contact:before {
+ name="district" required + data-parsley-pattern="^[a-zA-Z0-9\\s-]+$" + data-parsley-pattern-message="District can contain letters, numbers, spaces, and hyphens.">
+ name="city" required + data-parsley-pattern="^[a-zA-Z0-9\\s-]+$" + data-parsley-pattern-message="City can contain letters, numbers, spaces, and hyphens.">
- +
- +
@@ -252,13 +262,17 @@ input:checked + .slider-branch-contact:before {
+ name="name[]" id="name" required + data-parsley-pattern="^[A-Za-z\s]+$" + data-parsley-pattern-message="Contact name may contain only letters and spaces.">
@@ -267,7 +281,10 @@ input:checked + .slider-branch-contact:before {
+ name="email[]" id="email" data-parsley-trigger="change" + data-parsley-pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" + data-parsley-pattern-message="Please enter a valid email format (e.g., name@domain.com)." + onchange="validateDuplicateByClientBranch(this, 'email','branchBtnSubmit')" required>
@@ -275,8 +292,9 @@ input:checked + .slider-branch-contact:before { name="mobile[]" id="mobile" onchange="validateDuplicateByClientBranch(this, 'mobile','branchBtnSubmit')" onkeypress="return onlyNumbers(event)" maxlength="10" minlength="10" - data-parsley-type-message="Please enter a valid 10-digit mobile number." - data-parsley-required-message="Please enter a valid 10-digit mobile number." + data-parsley-pattern="^[0-9]{10}$" + data-parsley-pattern-message="Mobile number must be exactly 10 digits." + data-parsley-required-message="Mobile number must be exactly 10 digits." required>
@@ -752,12 +770,16 @@ function appendContactHtml(contact = false, reset = false) {
- +
@@ -765,11 +787,11 @@ function appendContactHtml(contact = false, reset = false) {
- +
- +
diff --git a/app/Views/client_deposit_list.php b/app/Views/client_deposit_list.php index e02041cc..ac777c29 100755 --- a/app/Views/client_deposit_list.php +++ b/app/Views/client_deposit_list.php @@ -54,6 +54,19 @@ $cd_col_width_px = nhance_dt_column_widths_px($cd_header_labels, $cd_col_max_len #client-deposit-list-table tbody td:nth-child(5) { overflow: visible; text-overflow: clip; + white-space: nowrap; + text-align: center; +} +#client-deposit-list-table .view-deposit-link { + display: inline-flex; + align-items: center; + gap: 0.35rem; + padding: 0.25rem 0.5rem; + border-radius: 0.25rem; + text-decoration: none; +} +#client-deposit-list-table .view-deposit-link:hover { + background-color: #f5f7fa; } #client-deposit-list-table tbody td { padding: 5px 11px !important; @@ -123,9 +136,9 @@ $cd_col_width_px = nhance_dt_column_widths_px($cd_header_labels, $cd_col_max_len ?> - insurer_id}?client_id={$value->client_id}&cd_ac_pk={$value->cd_ac_pk}"); ?>"> - View Deposit + View Deposit diff --git a/app/Views/client_info.php b/app/Views/client_info.php index aeb052cf..046b78f5 100755 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -10,11 +10,20 @@ + +
+
+
+
-
- -
- +
@@ -23,14 +32,19 @@

+ + + Client Basic Information - +

@@ -228,8 +242,9 @@
+
+
-
diff --git a/app/Views/client_kyc.php b/app/Views/client_kyc.php index 8fa6c56d..54f69c69 100755 --- a/app/Views/client_kyc.php +++ b/app/Views/client_kyc.php @@ -43,11 +43,13 @@
- +
+ Allowed: PDF, JPG, JPEG, PNG. Size : 200KB/image 25MB/PDF +
@@ -96,17 +98,79 @@ diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 82511643..c348cfae 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -205,7 +205,9 @@ input:checked + .slider_blue::before {
- @@ -248,7 +250,9 @@ input:checked + .slider_blue::before {
- +
@@ -280,12 +284,18 @@ input:checked + .slider_blue::before {
- +
- +
diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 07701fae..15df09cf 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -30,10 +30,6 @@ white-space: normal; } - .dataTables_filter{ - position: absolute; - } - .right-align-input { text-align: right; } @@ -95,9 +91,9 @@ if ($emp_show_branch) { $emp_header_labels[] = 'Branch'; } $emp_header_labels = array_merge($emp_header_labels, [ - 'Name', 'EMP Code', 'Relationship', 'Gender', 'Email', 'Mobile', 'Date of Birth', - 'Policy name', 'Insurer name', 'TPA ID', 'Risk ID', 'Policy status', - '(₹)Sum Insured', '(₹)Premium', '(₹)Pro Rata Premium', '(₹)GST', 'Action', + 'Name ', 'EMP Code ', 'Relationship ', 'Gender ', 'Email', 'Mobile', 'Date of Birth', + 'Policy name ', 'Insurer name ', 'TPA ID ', 'Risk ID ', 'Policy status ', + '(₹)Sum Insured ', '(₹)Premium ', '(₹)Pro Rata Premium ', '(₹)GST ', 'Action ', ]); $emp_col_count = count($emp_header_labels); $emp_col_max_len = array_fill(0, $emp_col_count, 0); @@ -161,8 +157,20 @@ if (isset($employees)) { $emp_col_max_len[$emp_col_count - 6] = max($emp_col_max_len[$emp_col_count - 6], mb_strlen('Total')); $emp_col_min_px = array_fill(0, $emp_col_count, 80); $emp_col_max_px = array_fill(0, $emp_col_count, 360); -$emp_col_min_px[0] = 48; -$emp_col_max_px[0] = 72; +$emp_col_min_px[0] = 64; +$emp_col_max_px[0] = 88; + +$emp_dynamic_idx = 1; +if ($emp_show_client_branch || $emp_show_branch) { + $emp_col_min_px[$emp_dynamic_idx] = max($emp_col_min_px[$emp_dynamic_idx], 120); + $emp_col_max_px[$emp_dynamic_idx] = max($emp_col_max_px[$emp_dynamic_idx], 190); + $emp_dynamic_idx++; +} +$emp_col_min_px[$emp_dynamic_idx] = max($emp_col_min_px[$emp_dynamic_idx], 110); // Name +$emp_dynamic_idx++; +$emp_col_min_px[$emp_dynamic_idx] = max($emp_col_min_px[$emp_dynamic_idx], 100); // EMP Code +$emp_col_max_px[$emp_dynamic_idx] = max($emp_col_max_px[$emp_dynamic_idx], 140); + $emp_col_min_px[$emp_col_count - 1] = 72; $emp_col_max_px[$emp_col_count - 1] = 96; $emp_col_width_px = nhance_dt_column_widths_px($emp_header_labels, $emp_col_max_len, $emp_col_min_px, $emp_col_max_px); @@ -187,6 +195,11 @@ $gst_total = 0; vertical-align: middle; } + #employee-data-list-table, + #employee-data-list-table_wrapper .dataTables_scrollHead table, + #employee-data-list-table_wrapper .dataTables_scrollBody table { + table-layout: fixed !important; + } #employee-data-list-table tbody td:not(:last-child) { overflow: hidden; text-overflow: ellipsis; @@ -205,6 +218,15 @@ $gst_total = 0; font-size: 13px; line-height: 1.25; } + #employee-data-list-table_wrapper table.dataTable thead .sorting:before, + #employee-data-list-table_wrapper table.dataTable thead .sorting:after, + #employee-data-list-table_wrapper table.dataTable thead .sorting_asc:before, + #employee-data-list-table_wrapper table.dataTable thead .sorting_asc:after, + #employee-data-list-table_wrapper table.dataTable thead .sorting_desc:before, + #employee-data-list-table_wrapper table.dataTable thead .sorting_desc:after { + right: 0.55rem !important; + opacity: 1 !important; + }
@@ -216,7 +238,8 @@ $gst_total = 0;

Employees

- +
+
@@ -243,7 +266,7 @@ $gst_total = 0; - + @@ -281,19 +304,19 @@ $gst_total = 0; ' . $employee['status'] . ''; + echo '' . ucfirst($employee['status']) . ''; break; case 'active': - echo '' . $employee['status'] . ''; + echo '' . ucfirst($employee['status']) . ''; break; case 'inactive': - echo '' . $employee['status'] . ''; + echo '' . ucfirst($employee['status']) . ''; break; case 'expired': - echo '' . $employee['status'] . ''; + echo '' . ucfirst($employee['status']) . ''; break; case 'enrolled': - echo '' . $employee['status'] . ''; + echo '' . ucfirst($employee['status']) . ''; break; default: echo $employee['status']; @@ -347,32 +370,21 @@ $gst_total = 0; - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + +
S.No Policy status  (₹)Sum Insured  (₹)Premium (₹)Pro Rata
Premium 
(₹)Pro Rata Premium  (₹)GST  Action  
TotalTotal
+
@@ -473,35 +485,54 @@ $gst_total = 0; $(document).ready(function() { var ticketsTable = $('#employee-data-list-table'); - if (ticketsTable.length) { - nhanceListDataTableBeforeInit(); - var nhEmpDataTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({ - // dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right - // "<'row'<'col-sm-12'tr>>" + - // "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector - dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right - "<'row'<'col-sm-12'tr>>" + - "<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>", + if (ticketsTable.length) { + var _dtDefScroll = { + scrollX: $.fn.dataTable.defaults.scrollX, + scrollY: $.fn.dataTable.defaults.scrollY, + scrollCollapse: $.fn.dataTable.defaults.scrollCollapse + }; + $.extend($.fn.dataTable.defaults, { scrollX: false, scrollY: false, scrollCollapse: false }); + + var nhEmpDataTable = ticketsTable.DataTable({ + dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>", lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]], + scrollX: false, + scrollY: false, + scrollCollapse: false, + initComplete: function () { + var $wrap = $(this.api().table().container()); + var $body = $wrap.find('.dataTables_scrollBody'); + var $head = $wrap.find('.dataTables_scrollHead'); + if ($body.length && $head.length) { + $body.off('scroll.nhEmpHScroll').on('scroll.nhEmpHScroll', function () { + $head.scrollLeft($(this).scrollLeft()); + }); + $head.off('scroll.nhEmpHScroll').on('scroll.nhEmpHScroll', function () { + $body.scrollLeft($(this).scrollLeft()); + }); + } + }, buttons: [ { extend: 'collection', text: ' Export ', className: 'btn app-btn-secondary ', buttons: [ - { - extend: 'csv', - text: ' CSV ', - className: 'app-btn-primary ', - title: 'Members', - }, - { - extend: 'excel', - text: ' EXCEL ', - className: 'app-btn-primary ', - title: 'Members', - sheetName: 'Members' - } + { + extend: 'csv', + text: ' CSV ', + className: 'app-btn-primary ', + title: 'Members', + }, + { + extend: 'excel', + text: ' EXCEL ', + className: 'app-btn-primary ', + title: 'Members', + sheetName: 'Members' + } ] } ], @@ -517,16 +548,28 @@ $gst_total = 0; searchPlaceholder: "Search", emptyTable: '
No Data found
' }, - paging: true, // Enable pagination - pageLength: 25, // Set default number of rows per page (optional) + paging: true, + pageLength: 25, + autoWidth: false, + responsive: false, columnDefs: [ { targets: , width: 'px' }, ], - })); - nhanceListDataTableAfterInit(); - nhanceListDataTableBindAdjust(nhEmpDataTable); + }); + + $.extend($.fn.dataTable.defaults, _dtDefScroll); + + nhEmpDataTable.on('draw.dt', function () { + nhEmpDataTable.columns.adjust(); + }); + $(window).on('resize', function () { + nhEmpDataTable.columns.adjust(); + }); + setTimeout(function () { + nhEmpDataTable.columns.adjust(); + }, 0); } else { console.error("Table not found."); } diff --git a/app/Views/finance_team_list.php b/app/Views/finance_team_list.php index d80aaad5..e0661664 100644 --- a/app/Views/finance_team_list.php +++ b/app/Views/finance_team_list.php @@ -239,6 +239,7 @@
+ @@ -338,11 +340,7 @@ $(document).ready(function () { if (ticketsTable.length) { ticketsTable.DataTable({ - // dom: - // "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right - // "<'row'<'col-sm-12'tr>>" + - // "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector - dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right + dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>", lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]], @@ -409,110 +407,23 @@ $(document).ready(function () { } else { console.error("Table not found."); } -}); - -$(document).ready(function() { - getURLParams() + getURLParams(); $('#client_id').select2(); $('#insurer_id').select2(); $('#policy_type_id').select2(); -}) - -function fetchEmpolyeeList(event) { - event.preventDefault(); // Prevent default action - - var start_date = $('#startDate').val(); - var end_date = $('#endDate').val(); - var client_id = $('#client_id').val(); - var insurer_id = $('#insurer_id').val(); - var policy_type_id = $('#policy_type_id').val(); - var date_type = $('#date_type').val(); - var issuer = $('#issuer').val(); - - console.log(start_date + '-' + end_date); - - var queryParams = { - start_date: start_date, - end_date: end_date, - client_id: client_id, - insurer_id: insurer_id, - policy_type_id: policy_type_id, - date_type: date_type, - issuer: issuer, - }; - - const queryString = objectToQueryString(queryParams); - const apiURL = $('#get-emp-list').attr('href') + "?" + queryString; - console.log(apiURL); - window.location.href = apiURL; -} - -function objectToQueryString(obj) { - return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); -} - -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 - - hideDateField(date_type) - - console.log('startDate', startDate) - console.log('endDate', endDate) - console.log('client_id', client_id) - console.log('insurer_id', insurer_id) - console.log('policy_type_id', policy_type_id) - console.log('date_type', date_type) - console.log('issuer', issuer) - - // Log the values or use them as needed - console.log('Start Date:', startDate); - 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).change() - $('#insurer_id').val(insurer_id).change() - $('#policy_type_id').val(policy_type_id).change() - $('#date_type').val(date_type) - $('#issuer').val(issuer) - }, 1000) - - } - -} - -$(function() { const url = new URL(window.location.href); const params = new URLSearchParams(url.search); - - // Get start and end dates from URL parameters, or use default values const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY'); const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY'); - - // Parse the dates to moment objects var start = moment(startDateParam, 'DD-MM-YYYY'); var end = moment(endDateParam, 'DD-MM-YYYY'); - // var start = moment().subtract(29, 'days'); - // var end = moment(); - - function cb(start, end) { - $('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY')); - $('#startDate').val(start.format('DD-MM-YYYY')); - $('#endDate').val(end.format('DD-MM-YYYY')); + function cb(startDate, endDate) { + $('#reportrange').html(startDate.format('D-MM-YYYY') + ' - ' + endDate.format('D-MM-YYYY')); + $('#startDate').val(startDate.format('DD-MM-YYYY')); + $('#endDate').val(endDate.format('DD-MM-YYYY')); } $('#reportrange').daterangepicker({ @@ -525,18 +436,24 @@ $(function() { 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 'This Month': [moment().startOf('month'), moment().endOf('month')], - 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month') - .endOf('month') - ] + 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] } - }); + }, cb); - $(document).ready(function() { - getURLParams() - $('#client_id').select2(); - $('#insurer_id').select2(); - $('#policy_type_id').select2(); - }) + cb(start, end); + + $('#clear-filters').on('click', function() { + $('#client_id').val('0').change(); + $('#insurer_id').val('0').change(); + $('#policy_type_id').val('0').change(); + $('#date_type').val('0'); + $('#issuer').val('0'); + $('#date_div').hide(); + $('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days')); + $('#reportrange').data('daterangepicker').setEndDate(moment()); + cb(moment().subtract(29, 'days'), moment()); + }); +}); function fetchEmpolyeeList(event) { event.preventDefault(); // Prevent default action @@ -568,7 +485,9 @@ $(function() { } function objectToQueryString(obj) { - return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); + return Object.keys(obj).map(function(key) { + return encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]); + }).join('&'); } function getURLParams() { @@ -599,78 +518,17 @@ $(function() { if (startDate != 0 && endDate != 0) { setTimeout(function() { - $('#start_date').val(startDate) - $('#end_date').val(endDate) - $('#client_id').val(client_id).change() - $('#insurer_id').val(insurer_id).change() - $('#policy_type_id').val(policy_type_id).change() - $('#date_type').val(date_type) - $('#issuer').val(issuer) - }, 1000) - + $('#startDate').val(startDate); + $('#endDate').val(endDate); + $('#client_id').val(client_id).change(); + $('#insurer_id').val(insurer_id).change(); + $('#policy_type_id').val(policy_type_id).change(); + $('#date_type').val(date_type); + $('#issuer').val(issuer); + }, 300); } - } - $(function() { - - const url = new URL(window.location.href); - const params = new URLSearchParams(url.search); - - // Get start and end dates from URL parameters, or use default values - const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY'); - const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY'); - - // Parse the dates to moment objects - var start = moment(startDateParam, 'DD-MM-YYYY'); - var end = moment(endDateParam, 'DD-MM-YYYY'); - - // var start = moment().subtract(29, 'days'); - // var end = moment(); - - function cb(start, end) { - $('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY')); - $('#startDate').val(start.format('DD-MM-YYYY')); - $('#endDate').val(end.format('DD-MM-YYYY')); - } - - $('#reportrange').daterangepicker({ - startDate: start, - endDate: end, - locale: { - format: 'DD-MM-YYYY' - }, - ranges: { - 'Today': [moment(), moment()], - 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], - 'Last 7 Days': [moment().subtract(6, 'days'), moment()], - 'Last 30 Days': [moment().subtract(29, 'days'), moment()], - 'This Month': [moment().startOf('month'), moment().endOf('month')], - 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month') - .endOf('month') - ] - } - }, cb); - - cb(start, end); - - $('#clear-filters').on('click', function() { - // Reset all select dropdowns to the first option - $('#client_id').val('0').change(); - $('#insurer_id').val('0').change(); - $('#policy_type_id').val('0').change(); - $('#date_type').val('0'); - $('#issuer').val('0'); - $('#date_div').hide() - - // Reset the date range picker to default - $('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days')); - $('#reportrange').data('daterangepicker').setEndDate(moment()); - cb(start, end); // Update the displayed date range - }); - - }); - function hideDateField(input = null) { let val = $('#date_type').val(); diff --git a/app/Views/insurer_basic_info.php b/app/Views/insurer_basic_info.php index ce0720ba..b3af15ed 100755 --- a/app/Views/insurer_basic_info.php +++ b/app/Views/insurer_basic_info.php @@ -170,8 +170,10 @@ input:checked + .slider:before {
@@ -204,8 +206,8 @@ input:checked + .slider:before { diff --git a/app/Views/kyc_list.php b/app/Views/kyc_list.php index ec621cd3..4ac46b93 100755 --- a/app/Views/kyc_list.php +++ b/app/Views/kyc_list.php @@ -138,7 +138,9 @@ $kyc_col_width_px = nhance_dt_column_widths_px($kyc_header_labels, $kyc_col_max_
+ + diff --git a/app/Views/pos_list.php b/app/Views/pos_list.php index d989318f..08ebde41 100644 --- a/app/Views/pos_list.php +++ b/app/Views/pos_list.php @@ -233,6 +233,7 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ + Allowed: PDF, PNG, JPG, JPEG.
@@ -241,6 +242,7 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_
+ Allowed: PDF, PNG, JPG, JPEG.
@@ -249,6 +251,7 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_
+ Allowed: PDF, PNG, JPG, JPEG. @@ -433,11 +436,17 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ }, error: function (xhr) { $('.loader, .loader-mask').fadeOut(); + let response = null; + try { + response = xhr.responseText ? JSON.parse(xhr.responseText) : null; + } catch (e) { + response = null; + } + if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); let errorMessages = ""; let seenMessages = []; // Array to store unique messages - if (response.errors) { + if (response && response.errors) { $.each(response.errors, function (field, message) { if (!seenMessages.includes(message)) { errorMessages += `• ${message}
`; @@ -446,16 +455,15 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ }); toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); + toastr.warning((response && response.message) ? response.message : 'Validation failed', 'Warning'); } } else if (xhr.status === 403) { - let response = JSON.parse(xhr.responseText); - toastr.error(response.message, 'Security Policy'); + toastr.error((response && response.message) ? response.message : 'Security policy error', 'Security Policy'); } else if (xhr.status === 500) { - toastr.error('Something went wrong . Please try again later.', 'Server Error'); + toastr.error((response && response.message) ? response.message : 'Something went wrong . Please try again later.', 'Server Error'); } else { - toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + toastr.error((response && response.message) ? response.message : 'An unexpected error occurred. Please try again later.', 'Error'); } console.error('Unexpected error:', xhr.responseText); @@ -470,9 +478,32 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ $('#partnerPOSForm').parsley().reset(); } $('#manager_id').val(null).trigger('change'); + updateFileNameDisplay('#aadhar_file_name', '#aadhar_file_name_display', ''); + updateFileNameDisplay('#pan_file_name', '#pan_file_name_display', ''); + updateFileNameDisplay('#certificate_file_name', '#certificate_file_name_display', ''); } + function updateFileNameDisplay(inputSelector, displaySelector, existingName = '') { + const $display = $(displaySelector); + let fileName = ''; + + if (existingName && String(existingName).trim() !== '') { + fileName = String(existingName).trim(); + } else { + const inputEl = $(inputSelector)[0]; + if (inputEl && inputEl.files && inputEl.files.length > 0) { + fileName = inputEl.files[0].name || ''; + } + } + + if (fileName) { + $display.text('Uploaded: ' + fileName).show(); + } else { + $display.text('').hide(); + } + } + function appendEditData(data){ $('#pos_id').val(data.id); @@ -481,14 +512,12 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ $('#mobile').val(data.mobile); $('#pos_code').val(data.pos_code); - // Instead of setting the file input - $('#current_file_name').text(data['certificate_file_name'] || 'No file uploaded'); - $('#aadhar').val(data.aadhar); - $('#aadhar_file_name').text(data['aadhar_file_name'] || 'No file uploaded'); + updateFileNameDisplay('#aadhar_file_name', '#aadhar_file_name_display', data['aadhar_file_name'] || ''); $('#pan').val(data.pan); - $('#pan_file_name').text(data['pan_file_name'] || 'No file uploaded'); + updateFileNameDisplay('#pan_file_name', '#pan_file_name_display', data['pan_file_name'] || ''); + updateFileNameDisplay('#certificate_file_name', '#certificate_file_name_display', data['certificate_file_name'] || ''); $('#bank_name').val(data.bank_name); $('#account_holder_name').val(data.account_holder_name); @@ -508,6 +537,18 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ }); } + $('#aadhar_file_name').on('change', function () { + updateFileNameDisplay('#aadhar_file_name', '#aadhar_file_name_display'); + }); + + $('#pan_file_name').on('change', function () { + updateFileNameDisplay('#pan_file_name', '#pan_file_name_display'); + }); + + $('#certificate_file_name').on('change', function () { + updateFileNameDisplay('#certificate_file_name', '#certificate_file_name_display'); + }); + $('#aadhar').on('input', function () { this.value = this.value.replace(/[^0-9]/g, ''); @@ -598,6 +639,7 @@ $pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_ \ No newline at end of file diff --git a/app/Views/rfq/gmc.php b/app/Views/rfq/gmc.php index 906057e6..b0bf5ac9 100644 --- a/app/Views/rfq/gmc.php +++ b/app/Views/rfq/gmc.php @@ -5,75 +5,75 @@
-