diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3e60e8bd..b26c46c4 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -592,7 +592,9 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID"); $routes->post("getMoreInfo","TicketController::getMoreInfo"); $routes->get("getMoreInfo","TicketController::getMoreInfo"); -// $routes->post('ticket_messages','TicketController::getTicketMessage'); + $routes->post('upload_url',"TicketController::upload_url"); + $routes->post('getUrlDataByTicketId',"TicketController::getUrlDataByTicketId"); + $routes->get('remove_url',"TicketController::remove_url"); }); $routes->group("clientApi",["filter" => "AuthClientApi"], function ($routes){ diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 6a311ea1..5e119628 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -20,6 +20,7 @@ use App\Models\EmployeePolicyModel; use App\Models\InsurerModel; use App\Models\EmployeeModel; use App\Models\TPAModel; +use App\Models\ClaimFilesModel; use DOMDocument; use Psr\Log\LoggerInterface; @@ -58,6 +59,7 @@ class TicketController extends BaseController protected $extraFieldsDisplayForFrontend; protected $insurerModel; protected $TPAModel; + protected $claimFilesModel; public function __construct() { @@ -341,6 +343,7 @@ class TicketController extends BaseController $this->employeePolicyModel = new EmployeePolicyModel(); $this->insurerModel = new InsurerModel(); $this->TPAModel = new TPAModel(); + $this->claimFilesModel = new ClaimFilesModel(); } public function ticketList() @@ -825,8 +828,12 @@ class TicketController extends BaseController // dd($data); $data['ticket_data'] = $ticket_data; $data['acms'] = $this->employeeModel->getAcmUsingClientID($ticket_data['client_id']); + + $raw_json = $this->ticketMasterModel->getPolicyTermsJson($ticket_id) ; + + $decoded_top = json_decode($raw_json ?? "", true) ?? []; + $data['policy_terms'] = $this->recursive_json_decode($decoded_top); - // dd($data); return $this->loadLayout('ticket_edit_onbording', $data); } @@ -2135,7 +2142,117 @@ class TicketController extends BaseController $date = \DateTime::createFromFormat($format, $value); return $date && $date->format($format) === $value; } + + public function upload_url(){ + + $data = $this->request->getPost(); + + $insertArr = []; + + foreach ($data['docs_name'] as $key => $eachData) { + + if (!empty($eachData) ) { + + $insertData = [ + 'doc_name' => $data['docs_name'][$key]??'', + 'url' => $data['url'][$key]??'', + 'ticket_id'=> $data['ticket_id_url']??'', + 'created_by' => get_session_userid(), + 'is_active' => 1 + ]; + + $insertArr[] = $insertData; + + } + } + + if(!empty($insertArr)){ + // Insert into database + $insert = $this->claimFilesModel->insertBatch($insertArr); + } + + + if (isset($insert) && !empty($insert)) { + return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']); + } else { + return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); + } + } + + public function getUrlDataByTicketId() + { + $ticket_id = $this->request->getPost('ticket_id'); + + if (!$ticket_id) { + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Ticket ID is required', + 'data' => [] + ]); + } + + $urlData = $this->claimFilesModel + ->where('ticket_id', $ticket_id) + ->where('is_active',1) + ->findAll(); + + return $this->response->setJSON([ + 'status' => true, + 'data' => $urlData + ]); + } + + public function remove_url() + { + $id = $this->request->getGet('id'); + + if (empty(trim($id))) { + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Invalid ID' + ]); + } + + $updated = $this->claimFilesModel + ->where('id', $id) + ->set(['is_active' => 0]) + ->update(); + + if ($updated) { + return $this->response->setJSON([ + 'status' => true, + 'message' => 'URL successfully marked inactive.' + ]); + } else { + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Failed to update record.' + ]); + } + } + + public function recursive_json_decode($input) { + if (is_string($input)) { + $decoded = json_decode($input, true); + if (json_last_error() === JSON_ERROR_NONE) { + return $this->recursive_json_decode($decoded); // continue decoding recursively + } else { + return $input; + } + } + + if (is_array($input)) { + foreach ($input as $key => $value) { + $input[$key] = $this->recursive_json_decode($value); + } + } + + return $input; + } + + + } diff --git a/app/Models/ClaimFilesModel.php b/app/Models/ClaimFilesModel.php new file mode 100644 index 00000000..2a5ec138 --- /dev/null +++ b/app/Models/ClaimFilesModel.php @@ -0,0 +1,55 @@ + $ticketIdsString ]; } + + public function getPolicyTermsJson($ticket_id) + { + $sql = " SELECT cp.policy_terms + FROM ticket_master tm + JOIN client_policy cp ON cp.id = tm.client_policy_id + WHERE tm.id = ? + AND tm.is_active = 1 + AND cp.is_active = 1 + "; + + $binds = [$ticket_id]; + $query = $this->db->query($sql, $binds); + + if ($query && $query->getNumRows() > 0) { + $row = $query->getRowArray(); + return json_encode(['policy_terms' => $row['policy_terms']]); + } + + return json_encode(['policy_terms' => null]); + } + + + + } diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php new file mode 100644 index 00000000..8fa2ad4c --- /dev/null +++ b/app/Views/claim_files_upload.php @@ -0,0 +1,329 @@ + +
+
+
+
+
+
+ + + +
+
+
+
+ + + +
+ +
+ +
+ +
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+
+

File List

+
+ +
+
+ + + + + + + + + + + +
S.NoDocs NameFile NameAction
+
+
+
+
+
+
+ + + + + + + + + diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 9dd0956c..feefb665 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -106,6 +106,8 @@ EMP Code Relationship Gender + Email + Mobile Date of Birth Policy name Insurer name @@ -141,6 +143,8 @@ + + - diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index 14e4a66f..c84a7206 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -56,6 +56,20 @@ Auto Query Content + + @@ -82,6 +96,12 @@
+
+ +
+
+ +
diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index b81836f1..15198800 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -109,7 +109,12 @@ table.dataTable tbody td { TAT + + + ACTION + + @@ -217,16 +222,21 @@ table.dataTable tbody td { - -