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/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/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 @@ + + + .reload:hover { + cursor: pointer; + } + + .table th, + .table td { + padding: 8px; + } + + table.dataTable tbody td { + padding: 4px 4px !important; + } + + .addbtnStyle{ + margin-left: 20px !important; + } + + .dataTables_filter { + position: absolute; + } + + .dataTables_length label {height: 21px !important;} + + .readonly-select { background-color: #f3f3f3 !important; cursor: not-allowed; pointer-events: none; } + + +