diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 531d5836..89e8cfc8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -736,6 +736,12 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->get('getTpaClaimStatus',"ApiServiceController::getClaimStatus"); }); +$routes->group("/claim_mis", ["filter" => "authMVC"], function ($routes) { + $routes->get('list','TicketController::claimMisFileList'); + $routes->get('download','TicketController::downloadClaimMisFile'); + $routes->post('upload','TicketController::uploadClaimMisFile'); +}); + $routes->group("clientApi",["filter" => "AuthClientApi"], function ($routes){ $routes->post("getPolicyMaster","ClientAPIController::sendPolicyMaster"); diff --git a/app/Controllers/ApiServiceController.php b/app/Controllers/ApiServiceController.php index 49d2ca62..7c256f40 100644 --- a/app/Controllers/ApiServiceController.php +++ b/app/Controllers/ApiServiceController.php @@ -109,8 +109,8 @@ class ApiServiceController extends BaseController ->where('employees.id', $id) ->where('employee_polices.is_active', 1) ->where('employees.is_active', 1) - ->where('employee_polices.status', 'active') - ->where('employees.emp_status', 'active') + ->whereIn('employee_polices.status', ['active', 'expired']) + ->whereIn('employees.emp_status', ['active', 'expired']) ->findAll(); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 35a13f9a..f4ceecc2 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1517,10 +1517,10 @@ class EmployeeController extends AdminController ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('employees', 'employees.id = employee_polices.employee_id') ->join('tpa', 'tpa.id = client_policy.tpa_id') - ->where('employees.emp_status', 'active') ->where('employees.is_active', '1') ->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''") - ->where('employee_polices.status', 'active') + ->whereIn('employee_polices.status', ['active', 'expired']) + ->whereIn('employees.emp_status', ['active', 'expired']) ->where('employee_polices.is_active', '1') ->where('employee_polices.rand_string', $rand_string) ->first(); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 79f5753b..06fbfb0c 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1984,6 +1984,7 @@ class MasterController extends AdminController 'rules' => WRITEPATH . 'uploads/commission/rules', 'claim_sample_forms' => ROOTPATH . 'public/claim_sample_forms/', 'bds_dump_excel' => WRITEPATH . 'uploads/bds_dump_excel/', + 'claims_mis' => WRITEPATH . 'uploads/claims_mis/', ]; foreach ($folders as $folderName => $folderPath) { diff --git a/app/Controllers/PayoutController.php b/app/Controllers/PayoutController.php index 90d501dc..813dda75 100644 --- a/app/Controllers/PayoutController.php +++ b/app/Controllers/PayoutController.php @@ -335,7 +335,7 @@ class PayoutController extends BaseController $invoiceData = [ 'invoice_no' => $json['invoice_no'], - 'agent_id' => $json['agent_id'], + // 'agent_id' => $json['agent_id'] ?? null, 'invoice_date' => $json['invoice_date'], 'invoice_amount' => $json['invoice_amount'], ]; diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 51775eec..308c5a07 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -24,6 +24,7 @@ use App\Models\ClaimFilesModel; use App\Models\ClaimDumpFileModel; use App\Models\VehicleModel; use App\Models\PartnerPolicyModel; +use App\Models\ClaimMisFileModel; use DOMDocument; use DOMXPath; @@ -67,6 +68,7 @@ class TicketController extends BaseController protected $claimDumpFileModel; protected $vehicleModel; protected $partnerPolicyModel; + protected $claimmisFileModel; public function __construct() { @@ -398,6 +400,7 @@ class TicketController extends BaseController $this->claimDumpFileModel = new ClaimDumpFileModel(); $this->vehicleModel = new VehicleModel(); $this->partnerPolicyModel = new PartnerPolicyModel(); + $this->claimmisFileModel = new ClaimMisFileModel(); } public function ticketList() @@ -2980,4 +2983,83 @@ class TicketController extends BaseController return $this->respond(['status' => true, 'code' => 200, 'message' => 'IR docs saved successfully', 'data' => $required_docs], 200); } + + public function claimMisFileList() + { + $data['page_name'] = "Cliam MIS Files"; + $data['claim_mis_file_list'] = $this->claimmisFileModel + ->select('claims_mis_files.*, user_profiles.first_name as user_name') + ->join('user_profiles', 'claims_mis_files.created_by = user_profiles.id') + ->where('claims_mis_files.is_active', 1) + ->orderBy('claims_mis_files.id', 'desc') + ->findAll(); + $data['tpa_list'] = $this->TPAModel->where('is_active', 1)->findAll(); + + return $this->loadLayout('claim_mis_file_list', $data); + } + + public function uploadClaimMisFile() + { + $file = $this->request->getFile('file'); + $data = $this->request->getPost(); + + if(isset($data['from_date']) && !empty($data['from_date'])){ + $data['from_date'] = change_date_format($data['from_date'], 'd/m/Y', 'Y-m-d'); + } + + if(isset($data['to_date']) && !empty($data['to_date'])){ + $data['to_date'] = change_date_format($data['to_date'], 'd/m/Y', 'Y-m-d'); + } + + $file_path = WRITEPATH.'uploads/claims_mis'; + $file_name = file_Upload_for_lead($file, $file_path); + + if(!empty($file_name)){ + $data['file_name'] = $file_name; + } + + $response = $this->claimmisFileModel->insert($data); + + if($response){ + return $this->respond(['status'=>true, 'code'=>200, 'message'=>'MIS file uploaded successfully'], 200); + }else{ + return $this->respond(['status'=>true, 'code'=>500, 'message'=>'Failed to upload'], 200); + } + } + + public function downloadClaimMisFile() + { + try { + + $file_id = $this->request->getGet('id'); + + // Find record + $record = $this->claimmisFileModel->where('id', $file_id)->first(); + // dd($record); + + if (!$record) { + $data['message'] = 'File record not found'; + return view('errors/404', $data); + } + + $uploadPath = WRITEPATH . 'uploads/claims_mis/'; + $filePath = $uploadPath . $record['file_name']; + // dd($filePath); + + if (!file_exists($filePath)) { + $data['message'] = 'The Physical File Not Found'; + return view('errors/404', $data); + } + + // Force file download + return $this->response->download($filePath, null)->setFileName($record['file_name']); + + } catch (\Exception $e) { + // return $this->failServerError($e->getMessage()); + $this->myLogger->logme('error', 'Error occoured in downloadClaimMisFile : ' . $e->getMessage()); + $data['message'] = 'File record not found'; + return view('errors/404', $data); + } + } + } diff --git a/app/Models/ClaimMisFileModel.php b/app/Models/ClaimMisFileModel.php new file mode 100644 index 00000000..057f9cd0 --- /dev/null +++ b/app/Models/ClaimMisFileModel.php @@ -0,0 +1,57 @@ +join('insurer_branch', 'insurer_branch.id = cp.insurer_branch_id') ->join('tpa', 'tpa.id = cp.tpa_id') ->where("ep.tpa_id IS NOT NULL AND ep.tpa_id <> ''") - ->where('e.emp_status', 'active') ->where('e.is_active', '1') - ->where('ep.status', 'active') + ->whereIn('ep.status', ['active', 'expired']) + ->whereIn('e.emp_status', ['active', 'expired']) ->where('ep.is_active', '1') ->where('e.emp_code', $emp_code) ->where('ep.client_policy_id', $client_policy_id) @@ -1618,9 +1618,9 @@ class EmployeePolicyModel extends Model ->join('insurer_branch', 'insurer_branch.id = cp.insurer_branch_id') ->join('tpa', 'tpa.id = cp.tpa_id') ->where("ep.tpa_id IS NOT NULL AND ep.tpa_id <> ''") - ->where('e.emp_status', 'active') ->where('e.is_active', '1') - ->where('ep.status', 'active') + ->whereIn('ep.status', ['active', 'expired']) + ->whereIn('e.emp_status', ['active', 'expired']) ->where('ep.is_active', '1') ->where('ep.rand_string', $rand_string) ->get() diff --git a/app/Views/claim_mis_file_list.php b/app/Views/claim_mis_file_list.php new file mode 100644 index 00000000..4ce6d111 --- /dev/null +++ b/app/Views/claim_mis_file_list.php @@ -0,0 +1,388 @@ + + +