diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e116fcd1..9c09427e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -531,6 +531,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->post('note/(:any)','TicketController::crudNote/$1'); $routes->post('reply','TicketController::saveReply'); $routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports'); + $routes->post('getPolicyStartDate','TicketController::getPolicyStartDate'); + $routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID"); // $routes->post('ticket_messages','TicketController::getTicketMessage'); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 3d1ca91e..07fb963a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4705,6 +4705,9 @@ class ClientController extends AdminController // $this->loadLayout('tat_report_band_wise_list', $reportData); // $data = $ticketModel->getTATReport(1); + // $empmodel = new EmployeeModel(); + // $data = $empmodel->getEmployeePolicy(348); + // dd($data); } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 6da26715..4b3a9619 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -12,6 +12,9 @@ use App\Models\TicketMailTemplateModel; use App\Models\TicketMessageModel; use App\Models\TicketNoteModel; use App\Models\UserModel; +use App\Models\ClientPolicyModel; +use App\Models\EmployeePolicyModel; + use DOMDocument; use Psr\Log\LoggerInterface; use Kint\Kint; @@ -45,6 +48,8 @@ class TicketController extends BaseController protected $triggerType; protected $userModel; protected $employeeModel; + protected $clientPolicyModel; + protected $employeePolicyModel; public function __construct() { @@ -80,10 +85,10 @@ class TicketController extends BaseController ]; $this->claimType = [ 1 => [ - 1 => "Main", + 1 => "Main Hospitalization", + 3 => "Pre / Post", 2 => "OPD", - 3 => "Pre ReOpen", - 4 => "Post ReOpen", + 4 => "ReOpen", ], 2 => [ 1 => "TTD", @@ -157,6 +162,8 @@ class TicketController extends BaseController $this->ticketMessageModel = new TicketMessageModel(); $this->userModel = new UserModel(); $this->employeeModel = new EmployeeModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + $this->employeePolicyModel = new EmployeePolicyModel(); } public function ticketList() @@ -439,7 +446,6 @@ class TicketController extends BaseController $template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data); } $data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']); - $data['ticket_data'] = $ticket_data; $data['reply_data'] = $template_data; $data['placeHolders'] = $this->placeHolders; $data['message_data'] = $this->getTicketMessage($ticket_id); @@ -447,6 +453,12 @@ class TicketController extends BaseController $data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']); $data['ticket_history'] = $this->ticketHistory($ticket_id); $data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray(); + if (!empty($ticket_data['client_policy_id'])){ + $ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name']; + } + // dd($ticket_data); + $data['ticket_data'] = $ticket_data; + // dd($data); return $this->loadLayout('ticket_edit_onbording', $data); @@ -841,8 +853,16 @@ class TicketController extends BaseController $replaceData = $ticket_data[$value] ?? ''; } else if ($value == "policy_type") { $replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? ""); - } else { - $replaceData = isset($ticket_data[$value]) ? strtoupper($ticket_data[$value]) : ''; + } else if ($value == 'emp_name'){ + if(empty($ticket_data['emp_id'])){ + $replaceData = $ticket_data['emp_name']??""; + } + }else if ($value == 'insured_name'){ + if(empty($ticket_data['insured_emp_id'])){ + $replaceData = $ticket_data['insured_name']?? ""; + } + }else { + $replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : ''; } $content = str_replace($key, $replaceData, $content); @@ -1433,5 +1453,73 @@ class TicketController extends BaseController return $lastMatchedStatus; } + + public function getPolicyStartDate() + { + + $data = $this->request->getPost(); + $client_policy_id = $data['policy_id']; + $policy_start_date = $this->clientPolicyModel->select('policy_start_date')->where('id', $client_policy_id)->first()['policy_start_date']; + // dd($data); + if (isset($data['employeeId']) && $data['employeeId'] != "" && $data['employeeId'] != null) { + // dd($data); + $emp_id = $data['employeeId']; + $empData = $this->employeeModel->select('dob,doj')->where('id',$emp_id)->findAll(); + + if (!empty($empData) && $empData != "" && $empData != null ) { + foreach ($empData as &$emp) { // Loop through the data + $emp['dob'] = date('d/m/Y', strtotime($emp['dob'])); + $emp['doj'] = date('d/m/Y', strtotime($emp['doj'])); + } + } + + if ($empData){ + return $this->respond(['status' => true, 'minDate' => $policy_start_date,'empData'=> $empData], 200); + }else{ + return $this->respond(['status' => false, 'message' => "Policy Not Found"]); + } + + } else { + // dd($policy_start_date); + if ($policy_start_date) { + return $this->respond(['status' => true, 'minDate' => $policy_start_date], 200); + } else { + return $this->respond(['status' => false, 'message' => "Policy Not Found"]); + } + } + } + + public function getPoliciesbyEmpID() { + $received_data = $this->request->getPost(); + $emp_id = $received_data['emp_id']; + + // Get all client policy IDs for the given employee + $policies = $this->employeePolicyModel + ->select('client_policy_id') + ->where('employee_id', $emp_id) + ->findAll(); + + if (empty($policies)) { + return []; // Return empty if no policies found + } + + // Extract client policy IDs into an array + $policy_ids = array_column($policies, 'client_policy_id'); + + // Fetch all policy names and IDs in one query + $policyNameandID = $this->clientPolicyModel + ->select('CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name, client_policy.id as client_policy_value,client_policy.policy_type_id') + ->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1') + ->whereIn('client_policy.id', $policy_ids) + ->findAll(); + + // dd($policyNameandID); + if ($policyNameandID){ + + return $this->respond(['status'=>true,'policy_data'=> $policyNameandID]); + }else{ + return $this->respond(['status'=>false,'message'=> "Policy Not Found"]); + } + } } diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 14ec368d..57ac791b 100755 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -149,7 +149,21 @@ class EmployeeModel extends Model { return $this->db->table('employee_polices') - ->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables + ->select(' + policy_type.long_name as Policy_Name , + client_policy.policy_terms as Policy_Terms, + client_policy.client_id as ClientId, + client_policy.policy_id as PolicyId, + client_policy.id as ClientPolicyId, + CASE + WHEN client_policy.open_for_enrollment IS NULL THEN 0 + ELSE client_policy.open_for_enrollment + END AS OpenForEnrollment, + client_policy.disclaimer, + client_policy.policy_type_id , + employee_polices.tpa_id as tpa_id , + employee_polices.rand_string as rand_string + ', FALSE) // Select all columns from both tables ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->where('client_policy.policy_status', 1) diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 090e7ff3..41a4f019 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -961,7 +961,8 @@ class PolicyTransactionModel extends Model policy_type.policy_type, pt_co_share_details.agreed_amt AS amount, pt_co_share_details.bp_amt AS bp, - pt_co_share_details.tp_amt AS tp + pt_co_share_details.tp_amt AS tp, + clients.pan ') ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left') ->join('clients', 'clients.id = policy_transaction.client_id', 'left') diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 878fad2e..f75cf2a6 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -72,6 +72,8 @@ class TicketMasterModel extends Model 'non_id_reason', 'head_rejection_reason', 'pay_initiate_date', + 'emp_personal_mail', + 'client_policy_id' ]; diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index f26439e5..66d00a2a 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -691,111 +691,121 @@ - + -