FIX_CLAIM_VIEW
This commit is contained in:
parent
d6db9f3541
commit
53326caf38
@ -754,7 +754,7 @@ class EmployeeRestController extends AdminController
|
|||||||
$result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]);
|
$result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]);
|
||||||
if (isset($result['error_summary']) && count($result['error_summary'])) {
|
if (isset($result['error_summary']) && count($result['error_summary'])) {
|
||||||
$result = $empServiceController->getExcelErrorData($file_id);
|
$result = $empServiceController->getExcelErrorData($file_id);
|
||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors", 'data' => $result], 200);
|
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "The data format is invalid. Click 'Next' to view details.", 'data' => $result], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2573,95 +2573,117 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
public function claimView()
|
public function claimView()
|
||||||
{
|
{
|
||||||
$ticket_id = $this->request->getGet('ticket_id');
|
try {
|
||||||
$ticketController = new TicketController;
|
|
||||||
$data['ticket_history'] = $ticketController->ticketHistory($ticket_id);
|
|
||||||
$data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id);
|
|
||||||
$data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id);
|
|
||||||
|
|
||||||
// $ticketData = $data['ticket_data'];
|
$ticket_id = $this->request->getGet('ticket_id');
|
||||||
// $ticketHistory = $data['ticket_history'];
|
$ticketController = new TicketController;
|
||||||
|
$data['ticket_history'] = $ticketController->ticketHistory($ticket_id);
|
||||||
|
$data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id);
|
||||||
|
$data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id);
|
||||||
|
|
||||||
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll();
|
// $ticketData = $data['ticket_data'];
|
||||||
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
|
// $ticketHistory = $data['ticket_history'];
|
||||||
|
// print_r($ticketHistory); die;
|
||||||
|
|
||||||
$data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []);
|
$currentClaimStatus = $this->claimStatusModel->select("claim_status")->where('id', $data['claims_data']['claim_status_id'])->where('is_active', 1)->first();
|
||||||
|
$ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll();
|
||||||
|
$status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status');
|
||||||
|
// print_r($currentClaimStatus); die;
|
||||||
|
|
||||||
|
$data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []);
|
||||||
|
|
||||||
// Loop through ticket_data
|
// Loop through ticket_data
|
||||||
foreach ($data['ticket_data'] as $status => &$fields) {
|
foreach ($data['ticket_data'] as $status => &$fields) {
|
||||||
// Search ticket_history for matching old_status_value
|
// Search ticket_history for matching old_status_value
|
||||||
foreach ($data['ticket_history'] as $history) {
|
foreach ($data['ticket_history'] as $history) {
|
||||||
|
|
||||||
if ($history['old_status_value'] === $status) {
|
if ($history['old_status_value'] === $status) {
|
||||||
// Attach modified_by and created_at
|
// Attach modified_by and created_at
|
||||||
// $fields['modified_by'] = $history['modified_by'];
|
// $fields['modified_by'] = $history['modified_by'];
|
||||||
$fields['modified_by'] = "";
|
$fields['modified_by'] = "";
|
||||||
$fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at']));
|
$fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at']));
|
||||||
// Break after first match (assuming latest entry is enough)
|
// Break after first match (assuming latest entry is enough)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$new_ticket_data = [];
|
$data['ticket_data'][$currentClaimStatus['claim_status']]['modified_by'] = "";
|
||||||
|
$data['ticket_data'][$currentClaimStatus['claim_status']]['modified_at'] = $formatted = date('d-m-Y h:i A', strtotime($data['claims_data']['updated_at']));
|
||||||
|
|
||||||
foreach ($data['ticket_data'] as $oldKey => $value) {
|
$new_ticket_data = [];
|
||||||
|
|
||||||
// Only process if key exists in status_list
|
foreach ($data['ticket_data'] as $oldKey => $value) {
|
||||||
if (!isset($status_list[$oldKey])) {
|
|
||||||
continue; // skip and do NOT add to new array
|
// Only process if key exists in status_list
|
||||||
|
if (!isset($status_list[$oldKey])) {
|
||||||
|
continue; // skip and do NOT add to new array
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get new key based on mapping
|
||||||
|
$newKey = $status_list[$oldKey];
|
||||||
|
|
||||||
|
// Avoid duplicates
|
||||||
|
if (!isset($new_ticket_data[$newKey])) {
|
||||||
|
$new_ticket_data[$newKey] = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get new key based on mapping
|
uasort($new_ticket_data, function ($a, $b) {
|
||||||
$newKey = $status_list[$oldKey];
|
$timeA = \DateTime::createFromFormat('d-m-Y h:i A', $a['modified_at']);
|
||||||
|
$timeB = \DateTime::createFromFormat('d-m-Y h:i A', $b['modified_at']);
|
||||||
|
return $timeA <=> $timeB; // Ascending
|
||||||
|
});
|
||||||
|
|
||||||
// Avoid duplicates
|
$data['ticket_data'] = $new_ticket_data;
|
||||||
if (!isset($new_ticket_data[$newKey])) {
|
|
||||||
$new_ticket_data[$newKey] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uasort($new_ticket_data, function ($a, $b) {
|
|
||||||
$timeA = \DateTime::createFromFormat('d-m-Y h:i A', $a['modified_at']);
|
|
||||||
$timeB = \DateTime::createFromFormat('d-m-Y h:i A', $b['modified_at']);
|
|
||||||
return $timeA <=> $timeB; // Ascending
|
|
||||||
});
|
|
||||||
|
|
||||||
$data['ticket_data'] = $new_ticket_data;
|
|
||||||
|
|
||||||
|
|
||||||
$ticketMesssageModel = new TicketMessageModel();
|
$ticketMesssageModel = new TicketMessageModel();
|
||||||
$ticket_message = $ticketMesssageModel
|
$ticket_message = $ticketMesssageModel
|
||||||
->where('is_active', 1)
|
|
||||||
->where('sender', "user")
|
|
||||||
->where('ticket_id', $ticket_id)
|
|
||||||
->orderBy('id', "desc")
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$claim_file_urls = [];
|
|
||||||
|
|
||||||
if (isset($ticket_message['id'])) {
|
|
||||||
|
|
||||||
$claimFiles = new ClaimFilesModel();
|
|
||||||
$claim_files_data = $claimFiles
|
|
||||||
->select('id as claim_file_id, doc_name as claim_file_name')
|
|
||||||
->where('is_active', 1)
|
->where('is_active', 1)
|
||||||
->where('file_type', 2)
|
->where('sender', "user")
|
||||||
->where('ticket_id', $ticket_id)
|
->where('ticket_id', $ticket_id)
|
||||||
->where('ticket_message_id', $ticket_message['id'])
|
->orderBy('id', "desc")
|
||||||
->findAll();
|
->first();
|
||||||
|
|
||||||
foreach ($claim_files_data as &$value) {
|
$claim_file_urls = [];
|
||||||
$value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id'];
|
|
||||||
$claim_file_urls[] = $value;
|
if (isset($ticket_message['id'])) {
|
||||||
|
|
||||||
|
$claimFiles = new ClaimFilesModel();
|
||||||
|
$claim_files_data = $claimFiles
|
||||||
|
->select('id as claim_file_id, doc_name as claim_file_name')
|
||||||
|
->where('is_active', 1)
|
||||||
|
->where('file_type', 2)
|
||||||
|
->where('ticket_id', $ticket_id)
|
||||||
|
->where('ticket_message_id', $ticket_message['id'])
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
foreach ($claim_files_data as &$value) {
|
||||||
|
$value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id'];
|
||||||
|
$claim_file_urls[] = $value;
|
||||||
|
}
|
||||||
|
unset($value);
|
||||||
}
|
}
|
||||||
unset($value);
|
|
||||||
|
$data['claim_files'] = $claim_file_urls;
|
||||||
|
|
||||||
|
return $this->respond(['status' => (count($data) ? 'success' : 'failed'), 'code' => (count($data) ? 200 : 404), 'data' => $data,], 200);
|
||||||
|
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
$this->myLogger->logme("error", 'claim_view' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $th->getTraceAsString()));
|
||||||
|
$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,
|
||||||
|
];
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => "", 'error_data' => $errorData], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['claim_files'] = $claim_file_urls;
|
|
||||||
|
|
||||||
return $this->respond(['status' => (count($data) ? 'success' : 'failed'), 'code' => (count($data) ? 200 : 404), 'data' => $data,], 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user