CHANGE_CLAIM_VIEW
This commit is contained in:
parent
cb0639fede
commit
1db1aec51c
@ -3911,6 +3911,8 @@ class EmployeeRestController extends AdminController
|
|||||||
$emp_id = $this->request->getGet('emp_id');
|
$emp_id = $this->request->getGet('emp_id');
|
||||||
$ticket_type = $this->request->getGet('ticket_type') ?? null;
|
$ticket_type = $this->request->getGet('ticket_type') ?? null;
|
||||||
$ticket_id = $this->request->getGet('ticket_id') ?? null;
|
$ticket_id = $this->request->getGet('ticket_id') ?? null;
|
||||||
|
$mobile_number = $this->request->getGet('mobile_number') ?? null;
|
||||||
|
$email_id = $this->request->getGet('email_id') ?? null;
|
||||||
$request = \Config\Services::request();
|
$request = \Config\Services::request();
|
||||||
$uri = $request->uri->getPath();
|
$uri = $request->uri->getPath();
|
||||||
$returnType = "";
|
$returnType = "";
|
||||||
@ -3921,6 +3923,11 @@ class EmployeeRestController extends AdminController
|
|||||||
return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'emp_id is required.'])->setStatusCode(404);
|
return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'emp_id is required.'])->setStatusCode(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$retail_ticket_data = [];
|
||||||
|
if(!empty($mobile_number) || !empty($email_id)){
|
||||||
|
$retail_ticket_data = $this->getRetailPolicyClaimData($this->request->getGet());
|
||||||
|
}
|
||||||
|
|
||||||
$TicketMasterModel = new TicketMasterModel();
|
$TicketMasterModel = new TicketMasterModel();
|
||||||
$ticket_data = $TicketMasterModel->get_ticket_data($emp_id, $returnType, $ticket_type, $ticket_id);
|
$ticket_data = $TicketMasterModel->get_ticket_data($emp_id, $returnType, $ticket_type, $ticket_id);
|
||||||
|
|
||||||
@ -3995,9 +4002,108 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ticket_data = array_merge($ticket_data, $retail_ticket_data);
|
||||||
|
|
||||||
return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
|
return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRetailPolicyClaimData($receviedPayload)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Create minimal retail user object
|
||||||
|
$retailUserData = (object) [
|
||||||
|
'id' => null,
|
||||||
|
'mobile' => $receviedPayload['mobile_number'] ?? null,
|
||||||
|
'email_id' => $receviedPayload['email_id'] ?? null
|
||||||
|
];
|
||||||
|
|
||||||
|
// Get retail policies of user
|
||||||
|
$empRetailPolicyData = $this->getEmpRetailPolicy($retailUserData);
|
||||||
|
|
||||||
|
if (empty($empRetailPolicyData)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch ticket data for each policy
|
||||||
|
$retail_ticket_data = [];
|
||||||
|
foreach ($empRetailPolicyData as $policy) {
|
||||||
|
$tickets = $this->ticketMaster
|
||||||
|
->select("
|
||||||
|
ticket_master.*,
|
||||||
|
(
|
||||||
|
SELECT th1.old_value
|
||||||
|
FROM ticket_history th1
|
||||||
|
JOIN ticket_claim_status tcs ON th1.old_value = tcs.id
|
||||||
|
WHERE th1.field_name = 'claim_status_id'
|
||||||
|
AND th1.ticket_id = ticket_master.id
|
||||||
|
AND th1.id = (
|
||||||
|
SELECT MAX(th2.id)
|
||||||
|
FROM ticket_history th2
|
||||||
|
WHERE th2.ticket_id = th1.ticket_id
|
||||||
|
AND th2.field_name = 'claim_status_id'
|
||||||
|
)
|
||||||
|
) AS old_status_id
|
||||||
|
")
|
||||||
|
->where('is_active', 1)
|
||||||
|
->where('client_id', $policy['client_id'])
|
||||||
|
->where('policy_transaction_id', $policy['policy_transaction_id'])
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
if (!empty($tickets)) {
|
||||||
|
$retail_ticket_data = array_merge($retail_ticket_data, $tickets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($retail_ticket_data)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch grouped claim statuses
|
||||||
|
$client_claim_status = $this->getClaimStatusGrouped(); // Format expected: [status => [ids]]
|
||||||
|
$claim_type = $this->getClaimTypeMaster('internal');
|
||||||
|
|
||||||
|
// Convert claim type for quick access
|
||||||
|
$typeMap = array_column($claim_type, 'claim_type', 'id');
|
||||||
|
|
||||||
|
// Map status name to each ticket
|
||||||
|
foreach ($retail_ticket_data as &$ticket) {
|
||||||
|
$ticket['claim_status'] = null; // Default
|
||||||
|
|
||||||
|
$ticket['claim_type_name'] = $typeMap[$ticket['claim_type']] ?? null;
|
||||||
|
foreach ($client_claim_status as $status_name => $status_list) {
|
||||||
|
if (in_array($ticket['claim_status_id'], $status_list)) {
|
||||||
|
$ticket['claim_status'] = $status_name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($ticket['old_status_id'], $status_list)) {
|
||||||
|
$ticket['claim_status'] = $status_name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $retail_ticket_data;
|
||||||
|
|
||||||
|
}catch (\Throwable $th) {
|
||||||
|
|
||||||
|
$errorData = [
|
||||||
|
'message' => $th->getMessage(),
|
||||||
|
'file' => $th->getFile(),
|
||||||
|
'line' => $th->getLine(),
|
||||||
|
'code' => $th->getCode(),
|
||||||
|
'trace' => $th->getTraceAsString(),
|
||||||
|
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||||
|
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||||
|
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->myLogger->logme("error", "EMPLOYEE-REST-CONTROLLER - getRetailPolicyClaimData: Exception: " . json_encode($errorData ?? []));
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getClaimStatusGrouped()
|
public function getClaimStatusGrouped()
|
||||||
{
|
{
|
||||||
// Fetch active claim statuses
|
// Fetch active claim statuses
|
||||||
@ -4023,7 +4129,6 @@ class EmployeeRestController extends AdminController
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// not in use did for testing
|
// not in use did for testing
|
||||||
function encrypt_for_sso(): string
|
function encrypt_for_sso(): string
|
||||||
{
|
{
|
||||||
@ -4779,6 +4884,7 @@ class EmployeeRestController extends AdminController
|
|||||||
$emp_retail_client_data = $this->clientModel
|
$emp_retail_client_data = $this->clientModel
|
||||||
->select("
|
->select("
|
||||||
'{$emp_id}' AS emp_id,
|
'{$emp_id}' AS emp_id,
|
||||||
|
clients.id as client_id,
|
||||||
clients.client_name as insurerd_name,
|
clients.client_name as insurerd_name,
|
||||||
clients.email as insurerd_mail,
|
clients.email as insurerd_mail,
|
||||||
clients.phone as insurerd_mobile,
|
clients.phone as insurerd_mobile,
|
||||||
@ -4811,6 +4917,7 @@ class EmployeeRestController extends AdminController
|
|||||||
$emp_retail_client_data = $this->clientModel
|
$emp_retail_client_data = $this->clientModel
|
||||||
->select("
|
->select("
|
||||||
'{$emp_id}' AS emp_id,
|
'{$emp_id}' AS emp_id,
|
||||||
|
clients.id as client_id,
|
||||||
clients.client_name as insurerd_name,
|
clients.client_name as insurerd_name,
|
||||||
clients.email as insurerd_mail,
|
clients.email as insurerd_mail,
|
||||||
clients.phone as insurerd_mobile,
|
clients.phone as insurerd_mobile,
|
||||||
@ -4973,7 +5080,7 @@ class EmployeeRestController extends AdminController
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClaimTypeMaster()
|
public function getClaimTypeMaster($return_type = 'api')
|
||||||
{
|
{
|
||||||
$data = db_connect()->table('partner_claim_type_master')->select('id,claim_type')->where('is_active',1)->get()->getResultArray();
|
$data = db_connect()->table('partner_claim_type_master')->select('id,claim_type')->where('is_active',1)->get()->getResultArray();
|
||||||
|
|
||||||
@ -4981,7 +5088,11 @@ class EmployeeRestController extends AdminController
|
|||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data]);
|
if($return_type == 'api'){
|
||||||
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $data]);
|
||||||
|
}else{
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadIRDocs()
|
public function uploadIRDocs()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user