Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
c7384581ed
@ -198,6 +198,12 @@ class TicketController extends BaseController
|
|||||||
}else if ($isFromDashboard == 2){
|
}else if ($isFromDashboard == 2){
|
||||||
$data['ticket_data'] = $this->ticketSearch(4);
|
$data['ticket_data'] = $this->ticketSearch(4);
|
||||||
|
|
||||||
|
}else if ($isFromDashboard == 3){
|
||||||
|
$data['ticket_data'] = $this->ticketSearch(2);
|
||||||
|
|
||||||
|
}else if ($isFromDashboard == 4){
|
||||||
|
$data['ticket_data'] = $this->ticketSearch(5);
|
||||||
|
|
||||||
}
|
}
|
||||||
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
|
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
|
||||||
$data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll();
|
$data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll();
|
||||||
@ -249,7 +255,7 @@ class TicketController extends BaseController
|
|||||||
->groupBy('tm.id, tm.created_at, latest_history.created_at');
|
->groupBy('tm.id, tm.created_at, latest_history.created_at');
|
||||||
|
|
||||||
|
|
||||||
//action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM
|
//action 1 get last 100 rows, action 2 filter and get all rows related to that, action 3 gets according to dashboard, action 4 gets according to ACM, action 5 tat
|
||||||
if ($action == 1) {
|
if ($action == 1) {
|
||||||
|
|
||||||
$query = $db->table('ticket_master tm')
|
$query = $db->table('ticket_master tm')
|
||||||
@ -356,6 +362,10 @@ class TicketController extends BaseController
|
|||||||
$where = '1 = 0'; // No valid IDs, return empty result
|
$where = '1 = 0'; // No valid IDs, return empty result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else if ($action == 5) {
|
||||||
|
$search_data = $this->request->getPost();
|
||||||
|
$where = "tm.created_at >= '" . $search_data['from_date'] . "' AND tm.created_at <= '" . $search_data['to_date'] . "'" ."and ticket_type_id = ".$search_data['ticket_type_id'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$search_data = $this->request->getPost();
|
$search_data = $this->request->getPost();
|
||||||
// print_r($search_data); die()
|
// print_r($search_data); die()
|
||||||
@ -445,6 +455,17 @@ class TicketController extends BaseController
|
|||||||
->orderBy('tm.id', 'DESC');
|
->orderBy('tm.id', 'DESC');
|
||||||
|
|
||||||
$data = $query->get()->getResultArray();
|
$data = $query->get()->getResultArray();
|
||||||
|
// dd($db->getLastQuery()->getQuery());
|
||||||
|
// dd($data);
|
||||||
|
if ($action == 5){
|
||||||
|
|
||||||
|
$tat = $this->request->getPost("tat_category");
|
||||||
|
|
||||||
|
$data = array_values(array_filter($data, function($dat) use ($tat) {
|
||||||
|
return $dat['tat'] == $tat;
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
// print_rr($data);
|
// print_rr($data);
|
||||||
// log_message('error',' Claims Master Data '.json_encode($data));die();
|
// log_message('error',' Claims Master Data '.json_encode($data));die();
|
||||||
// print_rr($data);die();
|
// print_rr($data);die();
|
||||||
@ -1068,6 +1089,10 @@ class TicketController extends BaseController
|
|||||||
$this->myLogger->logme('error', "Replacing placeholders in content");
|
$this->myLogger->logme('error', "Replacing placeholders in content");
|
||||||
|
|
||||||
if (!empty($ticket_data) && !empty($content)) {
|
if (!empty($ticket_data) && !empty($content)) {
|
||||||
|
// print_rr($ticket_data);die();
|
||||||
|
if (!isset($ticket_data['id'])) { $ticket_data['id'] = $ticket_data['ticket_master_id'];}
|
||||||
|
if (!isset($ticket_data['ticket_master_id'])) {$ticket_data['ticket_master_id'] = $ticket_data['id'];}
|
||||||
|
|
||||||
foreach ($this->placeHolders as $key => $value) {
|
foreach ($this->placeHolders as $key => $value) {
|
||||||
|
|
||||||
if ($value == "emp_code") {
|
if ($value == "emp_code") {
|
||||||
@ -1451,7 +1476,7 @@ class TicketController extends BaseController
|
|||||||
'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED',
|
'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED',
|
||||||
'UNDER PROCESS - CLAIM NO. UPDATION',
|
'UNDER PROCESS - CLAIM NO. UPDATION',
|
||||||
'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED',
|
'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED',
|
||||||
'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL'
|
'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL','TPA_ID'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Reorder data based on column order
|
// Reorder data based on column order
|
||||||
@ -1465,6 +1490,7 @@ class TicketController extends BaseController
|
|||||||
$ordered_data[] = $temp;
|
$ordered_data[] = $temp;
|
||||||
}
|
}
|
||||||
$viewData['tpa_wise_data'] = $ordered_data;
|
$viewData['tpa_wise_data'] = $ordered_data;
|
||||||
|
// print_r($ordered_data);die();
|
||||||
// $html = view('claims_report_tpa_wise', $viewData);
|
// $html = view('claims_report_tpa_wise', $viewData);
|
||||||
|
|
||||||
$html = view('claims_report_tpa_wise',$viewData);
|
$html = view('claims_report_tpa_wise',$viewData);
|
||||||
@ -1472,6 +1498,9 @@ class TicketController extends BaseController
|
|||||||
} else if ($received_data['report_type'] == 'tat_band_wise') {
|
} else if ($received_data['report_type'] == 'tat_band_wise') {
|
||||||
|
|
||||||
$viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate);
|
$viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate);
|
||||||
|
$viewData['policyType'] = $policy_type;
|
||||||
|
$viewData['fromDate'] = $fromDate;
|
||||||
|
$viewData['toDate'] = $toDate;
|
||||||
$html = view('tat_report_band_wise_list', $viewData);
|
$html = view('tat_report_band_wise_list', $viewData);
|
||||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||||
}
|
}
|
||||||
@ -1876,9 +1905,10 @@ class TicketController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isDate($value) {
|
private function isDate($value, $format = 'Y-m-d') {
|
||||||
// Check if the value is a valid date string (basic validation)
|
// Check if the value is a valid date string (basic validation)
|
||||||
return strtotime($value) !== false;
|
$date = \DateTime::createFromFormat($format, $value);
|
||||||
|
return $date && $date->format($format) === $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -335,159 +335,240 @@ class TicketMasterModel extends Model
|
|||||||
// return $data;
|
// return $data;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
|
||||||
|
// {
|
||||||
|
// //set default last 3 months data date
|
||||||
|
// $fromDate = date('Y-m-d', strtotime('-90 days'));
|
||||||
|
// $toDate = date('Y-m-d 23:59:59');
|
||||||
|
|
||||||
|
// if (!empty($start_date) && !empty($end_date)) {
|
||||||
|
// $fromDate = change_date_format($start_date);
|
||||||
|
// $toDate = change_date_format($end_date);
|
||||||
|
// }
|
||||||
|
// $ticket_type_data_1 = "";
|
||||||
|
// $ticket_type_data_2 = "";
|
||||||
|
// if (!empty($ticket_type)) {
|
||||||
|
// $ticket_type_data_1 = "AND ticket_type = $ticket_type";
|
||||||
|
// $ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Fetch claim statuses from the `ticket_claim_status` table
|
||||||
|
// $statusQuery = " SELECT
|
||||||
|
// id, claim_status, ticket_type
|
||||||
|
// FROM ticket_claim_status
|
||||||
|
// Where is_active = 1
|
||||||
|
// $ticket_type_data_1
|
||||||
|
// ";
|
||||||
|
// $statusResult = $this->db->query($statusQuery)->getResultArray();
|
||||||
|
// // dd($statusResult);
|
||||||
|
|
||||||
|
// // Initialize dynamic query parts
|
||||||
|
// $dynamicSelect = '';
|
||||||
|
|
||||||
|
// // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
|
||||||
|
// foreach ($statusResult as $status) {
|
||||||
|
|
||||||
|
// $columnName = $status['claim_status']; // Default column name
|
||||||
|
|
||||||
|
// if (empty($ticket_type)) {
|
||||||
|
// // Append the insurance type prefix based on `ticket_type`
|
||||||
|
// switch ($status['ticket_type']) {
|
||||||
|
// case 1:
|
||||||
|
// $columnName = "GMC - {$status['claim_status']}";
|
||||||
|
// break;
|
||||||
|
// case 2:
|
||||||
|
// $columnName = "GPA - {$status['claim_status']}";
|
||||||
|
// break;
|
||||||
|
// case 3:
|
||||||
|
// $columnName = "EDLI - {$status['claim_status']}";
|
||||||
|
// break;
|
||||||
|
// case 4:
|
||||||
|
// $columnName = "GTLI - {$status['claim_status']}";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $dynamicSelect .= "
|
||||||
|
// COALESCE(
|
||||||
|
// SUM(
|
||||||
|
// CASE
|
||||||
|
// WHEN subquery.status_id = {$status['id']} THEN 1
|
||||||
|
// ELSE 0
|
||||||
|
// END
|
||||||
|
// ),
|
||||||
|
// 0
|
||||||
|
// ) AS `$columnName`, ";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Remove the trailing comma from the SELECT part
|
||||||
|
// $dynamicSelect = rtrim($dynamicSelect, ', ');
|
||||||
|
// // dd($dynamicSelect);
|
||||||
|
|
||||||
|
|
||||||
|
// // Construct the full SQL query
|
||||||
|
// $sql = "
|
||||||
|
// SELECT
|
||||||
|
// tc.TAT_Category,
|
||||||
|
// $dynamicSelect
|
||||||
|
// FROM
|
||||||
|
// (
|
||||||
|
// SELECT 'Above 20 Days' AS TAT_Category
|
||||||
|
// UNION ALL
|
||||||
|
// SELECT '13-20 Days'
|
||||||
|
// UNION ALL
|
||||||
|
// SELECT '7-12 Days'
|
||||||
|
// UNION ALL
|
||||||
|
// SELECT '0-6 Days'
|
||||||
|
// ) AS tc
|
||||||
|
// LEFT JOIN (
|
||||||
|
// SELECT
|
||||||
|
// tm.id AS ticket_id,
|
||||||
|
// latest_status.claim_status_id AS status_id,
|
||||||
|
// CASE
|
||||||
|
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||||
|
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||||
|
// WHEN DATEDIFF(CURDATE(), COALESCE(latest_status.change_date, tm.created_at)) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||||
|
// ELSE 'Above 20 Days'
|
||||||
|
// END AS TAT_Category
|
||||||
|
// FROM
|
||||||
|
// ticket_master tm
|
||||||
|
// LEFT JOIN (
|
||||||
|
// SELECT
|
||||||
|
// th.ticket_id,
|
||||||
|
// th.new_value AS claim_status_id,
|
||||||
|
// MAX(th.created_at) AS change_date
|
||||||
|
// FROM
|
||||||
|
// ticket_history th
|
||||||
|
// WHERE
|
||||||
|
// th.field_name = 'claim_status_id'
|
||||||
|
// AND th.is_active = 1
|
||||||
|
// GROUP BY
|
||||||
|
// th.ticket_id, th.new_value
|
||||||
|
// ) AS latest_status ON latest_status.ticket_id = tm.id
|
||||||
|
// WHERE tm.is_active = 1
|
||||||
|
// AND tm.created_at >= '$fromDate'
|
||||||
|
// AND tm.created_at <= '$toDate'
|
||||||
|
// " . (!empty($ticket_type) ? " AND tm.ticket_type_id = $ticket_type" : "") . "
|
||||||
|
// GROUP BY tm.id, latest_status.claim_status_id, latest_status.change_date, tm.created_at
|
||||||
|
// ) AS subquery ON tc.TAT_Category = subquery.TAT_Category
|
||||||
|
// GROUP BY
|
||||||
|
// tc.TAT_Category
|
||||||
|
// ORDER BY
|
||||||
|
// FIELD(
|
||||||
|
// tc.TAT_Category,
|
||||||
|
// 'Above 20 Days',
|
||||||
|
// '13-20 Days',
|
||||||
|
// '7-12 Days',
|
||||||
|
// '0-6 Days'
|
||||||
|
// );
|
||||||
|
// ";
|
||||||
|
|
||||||
|
// // Execute the query and return the result
|
||||||
|
// $data = $this->db->query($sql)->getResultArray();
|
||||||
|
// // dd($data);
|
||||||
|
// print_rr($data);die();
|
||||||
|
// // print_rr($this->db->getLastQuery()->getQuery()); die;
|
||||||
|
|
||||||
|
// return $data;
|
||||||
|
// }
|
||||||
public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
|
public function getTATReport($ticket_type = null, $start_date = null, $end_date = null)
|
||||||
{
|
{
|
||||||
//set default last 3 months data date
|
// Set default date range (last 90 days)
|
||||||
$fromDate = date('Y-m-d', strtotime('-90 days'));
|
$fromDate = date('Y-m-d', strtotime('-90 days'));
|
||||||
$toDate = date('Y-m-d 23:59:59');
|
$toDate = date('Y-m-d 23:59:59');
|
||||||
|
|
||||||
if (!empty($start_date) && !empty($end_date)) {
|
if (!empty($start_date) && !empty($end_date)) {
|
||||||
$fromDate = change_date_format($start_date);
|
$fromDate = change_date_format($start_date);
|
||||||
$toDate = change_date_format($end_date);
|
$toDate = change_date_format($end_date);
|
||||||
}
|
}
|
||||||
$ticket_type_data_1 = "";
|
|
||||||
$ticket_type_data_2 = "";
|
// Get all active claim statuses
|
||||||
|
$statusQuery = $this->db->table('ticket_claim_status')
|
||||||
|
->select('id, claim_status')
|
||||||
|
->where('is_active', 1)
|
||||||
|
->orderBy('id', 'ASC');
|
||||||
|
|
||||||
if (!empty($ticket_type)) {
|
if (!empty($ticket_type)) {
|
||||||
$ticket_type_data_1 = "AND ticket_type = $ticket_type";
|
$statusQuery->where('ticket_type', $ticket_type);
|
||||||
$ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch claim statuses from the `ticket_claim_status` table
|
$statusResult = $statusQuery->get()->getResultArray();
|
||||||
$statusQuery = " SELECT
|
|
||||||
id, claim_status, ticket_type
|
// Create a list of all TAT categories we want in the output
|
||||||
FROM ticket_claim_status
|
$tatCategories = [
|
||||||
Where is_active = 1
|
'Above 20 Days',
|
||||||
$ticket_type_data_1
|
'13-20 Days',
|
||||||
";
|
'7-12 Days',
|
||||||
$statusResult = $this->db->query($statusQuery)->getResultArray();
|
'0-6 Days'
|
||||||
// dd($statusResult);
|
];
|
||||||
|
|
||||||
// Initialize dynamic query parts
|
// Initialize the result array with all TAT categories
|
||||||
$dynamicSelect = '';
|
$result = [];
|
||||||
|
foreach ($tatCategories as $category) {
|
||||||
// Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
|
$row = ['TAT_Category' => $category];
|
||||||
foreach ($statusResult as $status) {
|
foreach ($statusResult as $status) {
|
||||||
|
$row[$status['claim_status']] = 0;
|
||||||
$columnName = $status['claim_status']; // Default column name
|
}
|
||||||
|
$result[] = $row;
|
||||||
if (empty($ticket_type)) {
|
}
|
||||||
// Append the insurance type prefix based on `ticket_type`
|
|
||||||
switch ($status['ticket_type']) {
|
// Get the base query for ticket counts by status and TAT category
|
||||||
case 1:
|
$query = $this->db->table('ticket_master tm')
|
||||||
$columnName = "GMC - {$status['claim_status']}";
|
->select([
|
||||||
break;
|
'tcs.claim_status',
|
||||||
case 2:
|
'CASE
|
||||||
$columnName = "GPA - {$status['claim_status']}";
|
WHEN DATEDIFF(CURDATE(), COALESCE(
|
||||||
break;
|
(SELECT MAX(th.created_at)
|
||||||
case 3:
|
FROM ticket_history th
|
||||||
$columnName = "EDLI - {$status['claim_status']}";
|
WHERE th.ticket_id = tm.id
|
||||||
break;
|
AND th.field_name = "claim_status_id"
|
||||||
case 4:
|
AND th.is_active = 1),
|
||||||
$columnName = "GTLI - {$status['claim_status']}";
|
tm.created_at
|
||||||
break;
|
)) BETWEEN 0 AND 6 THEN "0-6 Days"
|
||||||
|
WHEN DATEDIFF(CURDATE(), COALESCE(
|
||||||
|
(SELECT MAX(th.created_at)
|
||||||
|
FROM ticket_history th
|
||||||
|
WHERE th.ticket_id = tm.id
|
||||||
|
AND th.field_name = "claim_status_id"
|
||||||
|
AND th.is_active = 1),
|
||||||
|
tm.created_at
|
||||||
|
)) BETWEEN 7 AND 12 THEN "7-12 Days"
|
||||||
|
WHEN DATEDIFF(CURDATE(), COALESCE(
|
||||||
|
(SELECT MAX(th.created_at)
|
||||||
|
FROM ticket_history th
|
||||||
|
WHERE th.ticket_id = tm.id
|
||||||
|
AND th.field_name = "claim_status_id"
|
||||||
|
AND th.is_active = 1),
|
||||||
|
tm.created_at
|
||||||
|
)) BETWEEN 13 AND 20 THEN "13-20 Days"
|
||||||
|
ELSE "Above 20 Days"g
|
||||||
|
END AS tat_category',
|
||||||
|
'COUNT(*) AS count'
|
||||||
|
])
|
||||||
|
->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1')
|
||||||
|
->where('tm.is_active', 1)
|
||||||
|
->where('tm.created_at >=', $fromDate)
|
||||||
|
->where('tm.created_at <=', $toDate)
|
||||||
|
->groupBy('tcs.claim_status, tat_category')
|
||||||
|
->orderBy('FIELD(tat_category, "Above 20 Days", "13-20 Days", "7-12 Days", "0-6 Days")');
|
||||||
|
|
||||||
|
if (!empty($ticket_type)) {
|
||||||
|
$query->where('tm.ticket_type_id', $ticket_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
$countResults = $query->get()->getResultArray();
|
||||||
|
|
||||||
|
// Populate the result array with actual counts
|
||||||
|
foreach ($countResults as $row) {
|
||||||
|
foreach ($result as &$categoryRow) {
|
||||||
|
if ($categoryRow['TAT_Category'] === $row['tat_category']) {
|
||||||
|
$categoryRow[$row['claim_status']] = (int)$row['count'];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dynamicSelect .= "
|
|
||||||
COALESCE(
|
|
||||||
SUM(
|
|
||||||
CASE
|
|
||||||
WHEN subquery.status_id = {$status['id']} THEN 1
|
|
||||||
ELSE 0
|
|
||||||
END
|
|
||||||
),
|
|
||||||
0
|
|
||||||
) AS `$columnName`, ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the trailing comma from the SELECT part
|
return $result;
|
||||||
$dynamicSelect = rtrim($dynamicSelect, ', ');
|
|
||||||
// dd($dynamicSelect);
|
|
||||||
|
|
||||||
|
|
||||||
// Construct the full SQL query
|
|
||||||
$sql = "
|
|
||||||
SELECT
|
|
||||||
tc.TAT_Category,
|
|
||||||
$dynamicSelect
|
|
||||||
FROM
|
|
||||||
(
|
|
||||||
SELECT 'Above 20 Days' AS TAT_Category
|
|
||||||
UNION ALL
|
|
||||||
SELECT '13-20 Days'
|
|
||||||
UNION ALL
|
|
||||||
SELECT '7-12 Days'
|
|
||||||
UNION ALL
|
|
||||||
SELECT '0-6 Days'
|
|
||||||
) AS tc
|
|
||||||
LEFT JOIN (
|
|
||||||
|
|
||||||
SELECT
|
|
||||||
th.ticket_id,
|
|
||||||
tcs.claim_status,
|
|
||||||
tcs.id AS status_id,
|
|
||||||
CASE
|
|
||||||
WHEN DATEDIFF(
|
|
||||||
th.created_at,
|
|
||||||
COALESCE(
|
|
||||||
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
|
|
||||||
tm.created_at
|
|
||||||
)
|
|
||||||
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
|
||||||
WHEN DATEDIFF(
|
|
||||||
th.created_at,
|
|
||||||
COALESCE(
|
|
||||||
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
|
|
||||||
tm.created_at
|
|
||||||
)
|
|
||||||
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
|
||||||
WHEN DATEDIFF(
|
|
||||||
th.created_at,
|
|
||||||
COALESCE(
|
|
||||||
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
|
|
||||||
tm.created_at
|
|
||||||
)
|
|
||||||
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
|
||||||
ELSE 'Above 20 Days'
|
|
||||||
END AS TAT_Category
|
|
||||||
|
|
||||||
FROM
|
|
||||||
ticket_master tm
|
|
||||||
JOIN ticket_history th ON tm.id = th.ticket_id
|
|
||||||
JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' AND th.new_value = tcs.id
|
|
||||||
$ticket_type_data_2
|
|
||||||
AND tm.created_at >= '$fromDate'
|
|
||||||
AND tm.created_at <= '$toDate'
|
|
||||||
AND tm.is_active = 1
|
|
||||||
AND th.is_active = 1
|
|
||||||
AND tcs.is_active = 1
|
|
||||||
|
|
||||||
) AS subquery ON tc.TAT_Category = subquery.TAT_Category
|
|
||||||
GROUP BY
|
|
||||||
tc.TAT_Category
|
|
||||||
ORDER BY
|
|
||||||
FIELD(
|
|
||||||
tc.TAT_Category,
|
|
||||||
'Above 20 Days',
|
|
||||||
'13-20 Days',
|
|
||||||
'7-12 Days',
|
|
||||||
'0-6 Days'
|
|
||||||
);
|
|
||||||
";
|
|
||||||
|
|
||||||
// Execute the query and return the result
|
|
||||||
$data = $this->db->query($sql)->getResultArray();
|
|
||||||
// print_rr($this->db->getLastQuery(), $data); die;
|
|
||||||
|
|
||||||
// $tableData = [];
|
|
||||||
// if (!empty($data)) {
|
|
||||||
// // Extract table headers from the first row keys
|
|
||||||
// $headers = array_keys($data[0]);
|
|
||||||
// $tableData['headers'] = $headers;
|
|
||||||
// $tableData['body'] = $data;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
|
public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
|
||||||
@ -544,6 +625,7 @@ class TicketMasterModel extends Model
|
|||||||
// Construct the final SQL query
|
// Construct the final SQL query
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT
|
SELECT
|
||||||
|
tpa.id as TPA_ID,
|
||||||
tpa.name AS TPA_NAME,
|
tpa.name AS TPA_NAME,
|
||||||
$dynamicSelect,
|
$dynamicSelect,
|
||||||
($dynamicTotal) AS TOTAL,
|
($dynamicTotal) AS TOTAL,
|
||||||
|
|||||||
@ -37,16 +37,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($column_order as $col_name): ?>
|
<?php foreach ($column_order as $col_name): ?>
|
||||||
<th><?= str_replace('_', ' ', $col_name) ?></th>
|
<?php if ($col_name != "TPA_ID") { ?>
|
||||||
<?php endforeach; ?>
|
<th><?= str_replace('_', ' ', $col_name) ?></th>
|
||||||
|
<?php } endforeach; ?>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($tpa_wise_data as $row): ?>
|
<?php foreach ($tpa_wise_data as $row): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($column_order as $col_name): ?>
|
<?php foreach ($column_order as $col_name): ?>
|
||||||
<td><?= $row[$col_name] ?></td>
|
<?php if ($col_name != "TPA_ID") { ?>
|
||||||
<?php endforeach; ?>
|
<td onclick="redirectTPAToClaimList(<?= $row['TPA_ID'] ?>)"><?= $row[$col_name] ?></td>
|
||||||
|
<?php } endforeach;?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -62,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($column_order as $col_name) {
|
foreach ($column_order as $col_name) {
|
||||||
if ($col_name !== 'TPA_NAME') {
|
if ($col_name !== 'TPA_NAME' && $col_name != "TPA_ID") {
|
||||||
echo "<th>{$totals[$col_name]}</th>";
|
echo "<th>{$totals[$col_name]}</th>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,4 +100,35 @@
|
|||||||
console.error("Table not found.");
|
console.error("Table not found.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
|
function redirectTPAToClaimList(tpa_id){
|
||||||
|
|
||||||
|
// alert(tpa_id);
|
||||||
|
data = {
|
||||||
|
'tpa_id' : tpa_id,
|
||||||
|
'is_dashboard':3
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirectWithPost(url, data = {}) {
|
||||||
|
const form = document.createElement('form');
|
||||||
|
form.method = 'POST';
|
||||||
|
form.action = url;
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (data.hasOwnProperty(key)) {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'hidden';
|
||||||
|
input.name = key;
|
||||||
|
input.value = data[key];
|
||||||
|
form.appendChild(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(form);
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
$rowTotal += $numValue; // Add to row total
|
$rowTotal += $numValue; // Add to row total
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<td><?= esc($value) ?></td>
|
<td onclick="redirectTATtoClaims(`<?= $row['TAT_Category'] ?>`,`<?= $policyType ?>`)"><?= esc($value) ?></td>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
|
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
|
||||||
</tr>
|
</tr>
|
||||||
@ -129,4 +129,41 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
function redirectTATtoClaims(tat_category, policyType) {
|
||||||
|
// Safely render PHP dates inside JavaScript strings
|
||||||
|
var fromDate = "<?= isset($fromDate) && $fromDate != null ? change_date_format($fromDate) : date('Y-m-d', strtotime('-90 days')) ?>";
|
||||||
|
var toDate = "<?= isset($toDate) && $toDate != null ? change_date_format($toDate) : date('Y-m-d 23:59:59') ?>";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
'tat_category': tat_category,
|
||||||
|
'is_dashboard': 4,
|
||||||
|
'ticket_type_id': policyType,
|
||||||
|
'from_date': fromDate,
|
||||||
|
'to_date': toDate
|
||||||
|
};
|
||||||
|
|
||||||
|
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function redirectWithPost(url, data = {}) {
|
||||||
|
const form = document.createElement('form');
|
||||||
|
form.method = 'POST';
|
||||||
|
form.action = url;
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (data.hasOwnProperty(key)) {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'hidden';
|
||||||
|
input.name = key;
|
||||||
|
input.value = data[key];
|
||||||
|
form.appendChild(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(form);
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user