CHANGE_TAT_IN_CLAIM_LIST : RV
This commit is contained in:
parent
85423bc341
commit
8491a72213
@ -144,20 +144,52 @@ class TicketController extends BaseController
|
|||||||
{
|
{
|
||||||
//action 1 get last 100 rows, action 2 filter and get all rows related to that
|
//action 1 get last 100 rows, action 2 filter and get all rows related to that
|
||||||
if ($action == 1) {
|
if ($action == 1) {
|
||||||
|
|
||||||
$data = $this->ticketMasterModel
|
$data = $this->ticketMasterModel
|
||||||
->select('ticket_master.id, ticket_claim_status.claim_status as status,
|
->select("
|
||||||
ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name,
|
|
||||||
insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name,
|
ticket_master.id,
|
||||||
DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat')
|
ticket_claim_status.claim_status as status,
|
||||||
|
ticket_master.claim_number as claim_no,
|
||||||
|
ticket_master.tpa_id,
|
||||||
|
ticket_master.emp_name,
|
||||||
|
insurers.name as insurer_name,
|
||||||
|
clients.client_name,
|
||||||
|
ticket_master.insured_name,
|
||||||
|
clients.short_name,
|
||||||
|
DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date,
|
||||||
|
CASE
|
||||||
|
WHEN DATEDIFF(
|
||||||
|
ticket_master.updated_at,
|
||||||
|
COALESCE(ticket_master.updated_at, ticket_history.created_at)
|
||||||
|
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||||
|
WHEN DATEDIFF(
|
||||||
|
ticket_master.updated_at,
|
||||||
|
COALESCE(ticket_master.updated_at, ticket_history.created_at)
|
||||||
|
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||||
|
WHEN DATEDIFF(
|
||||||
|
ticket_master.updated_at,
|
||||||
|
COALESCE(ticket_master.updated_at, ticket_history.created_at)
|
||||||
|
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||||
|
ELSE 'Above 20 Days'
|
||||||
|
END AS tat
|
||||||
|
|
||||||
|
")
|
||||||
->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left')
|
->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left')
|
||||||
->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left')
|
->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left')
|
||||||
->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left')
|
->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left')
|
||||||
|
->join('ticket_history', "ticket_master.id = ticket_history.ticket_id")
|
||||||
->where('ticket_master.is_active', 1)
|
->where('ticket_master.is_active', 1)
|
||||||
|
->where('ticket_history.is_active', 1)
|
||||||
|
->groupBy('ticket_master.id')
|
||||||
->orderBy('ticket_master.id', 'DESC')
|
->orderBy('ticket_master.id', 'DESC')
|
||||||
->limit(100)
|
->limit(100)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
// dd($data);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$search_data = $this->request->getPost();
|
$search_data = $this->request->getPost();
|
||||||
// print_r($search_data);
|
// print_r($search_data);
|
||||||
@ -169,15 +201,41 @@ class TicketController extends BaseController
|
|||||||
}
|
}
|
||||||
// print_rr($where);
|
// print_rr($where);
|
||||||
$data = $this->ticketMasterModel
|
$data = $this->ticketMasterModel
|
||||||
->select('ticket_master.id, ticket_claim_status.claim_status as status,
|
->select("
|
||||||
ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name,
|
ticket_master.id,
|
||||||
insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name,
|
ticket_claim_status.claim_status as status,
|
||||||
DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat')
|
ticket_master.claim_number as claim_no,
|
||||||
|
ticket_master.tpa_id,
|
||||||
|
ticket_master.emp_name,
|
||||||
|
insurers.name as insurer_name,
|
||||||
|
clients.client_name,ticket_master.insured_name,
|
||||||
|
clients.short_name,
|
||||||
|
DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date,
|
||||||
|
CASE
|
||||||
|
WHEN DATEDIFF(
|
||||||
|
ticket_master.updated_at,
|
||||||
|
COALESCE(ticket_master.updated_at, ticket_history.created_at)
|
||||||
|
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||||
|
WHEN DATEDIFF(
|
||||||
|
ticket_master.updated_at,
|
||||||
|
COALESCE(ticket_master.updated_at, ticket_history.created_at)
|
||||||
|
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||||
|
WHEN DATEDIFF(
|
||||||
|
ticket_master.updated_at,
|
||||||
|
COALESCE(ticket_master.updated_at, ticket_history.created_at)
|
||||||
|
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||||
|
ELSE 'Above 20 Days'
|
||||||
|
END AS tat
|
||||||
|
")
|
||||||
->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left')
|
->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left')
|
||||||
->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left')
|
->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left')
|
||||||
->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left')
|
->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left')
|
||||||
|
->join('ticket_history', "ticket_master.id = ticket_history.ticket_id")
|
||||||
->where('ticket_master.is_active', 1)
|
->where('ticket_master.is_active', 1)
|
||||||
|
->where('ticket_history.is_active', 1)
|
||||||
->where($where)
|
->where($where)
|
||||||
|
->groupBy('ticket_master.id')
|
||||||
|
->orderBy('ticket_master.id', 'DESC')
|
||||||
->findAll();
|
->findAll();
|
||||||
// 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();
|
||||||
@ -842,7 +900,8 @@ class TicketController extends BaseController
|
|||||||
return 'Ticket id\'s : '.json_encode($ticket_ids);
|
return 'Ticket id\'s : '.json_encode($ticket_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ticketReports(){
|
public function ticketReports()
|
||||||
|
{
|
||||||
|
|
||||||
if ($this->request->is('get')) {
|
if ($this->request->is('get')) {
|
||||||
$default_start = new \DateTime();
|
$default_start = new \DateTime();
|
||||||
@ -877,27 +936,22 @@ class TicketController extends BaseController
|
|||||||
$html = view('claims_report_acc_manager_gpa', $viewData);
|
$html = view('claims_report_acc_manager_gpa', $viewData);
|
||||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($received_data['report_type'] == 'tpa_wise_status') {
|
} elseif ($received_data['report_type'] == 'tpa_wise_status') {
|
||||||
|
|
||||||
$viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type, $fromDate, $toDate);
|
$viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type, $fromDate, $toDate);
|
||||||
$html = view('claims_report_tpa_wise', $viewData);
|
$html = view('claims_report_tpa_wise', $viewData);
|
||||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||||
|
|
||||||
} 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);
|
||||||
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function accountManagerWiseReport($policy_type = null, $start_date = null, $end_date = null)
|
||||||
|
{
|
||||||
}
|
|
||||||
|
|
||||||
public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){
|
|
||||||
|
|
||||||
if ($policy_type == 1) {
|
if ($policy_type == 1) {
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
@ -933,8 +987,6 @@ class TicketController extends BaseController
|
|||||||
// dd($result);
|
// dd($result);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$sql = "SELECT u.first_name AS acc_manager_name,
|
$sql = "SELECT u.first_name AS acc_manager_name,
|
||||||
COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation,
|
COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation,
|
||||||
@ -979,7 +1031,8 @@ class TicketController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){
|
public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
|
||||||
|
{
|
||||||
// $policy_type = 1;
|
// $policy_type = 1;
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
tpa.name AS tpa_name,
|
tpa.name AS tpa_name,
|
||||||
|
|||||||
@ -166,7 +166,7 @@ class TicketMasterModel extends Model
|
|||||||
|
|
||||||
// Fetch claim statuses from the `ticket_claim_status` table
|
// Fetch claim statuses from the `ticket_claim_status` table
|
||||||
$statusQuery = " SELECT
|
$statusQuery = " SELECT
|
||||||
id, claim_status
|
id, claim_status, ticket_type
|
||||||
FROM ticket_claim_status
|
FROM ticket_claim_status
|
||||||
Where is_active = 1
|
Where is_active = 1
|
||||||
$ticket_type_data_1
|
$ticket_type_data_1
|
||||||
@ -179,7 +179,27 @@ class TicketMasterModel extends Model
|
|||||||
|
|
||||||
// Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
|
// Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
|
||||||
foreach ($statusResult as $status) {
|
foreach ($statusResult as $status) {
|
||||||
// Dynamically add the COALESCE and CASE for each status in the SELECT part
|
|
||||||
|
$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 .= "
|
$dynamicSelect .= "
|
||||||
COALESCE(
|
COALESCE(
|
||||||
SUM(
|
SUM(
|
||||||
@ -189,7 +209,7 @@ class TicketMasterModel extends Model
|
|||||||
END
|
END
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
) AS `{$status['claim_status']}`, ";
|
) AS `$columnName`, ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the trailing comma from the SELECT part
|
// Remove the trailing comma from the SELECT part
|
||||||
@ -219,15 +239,15 @@ class TicketMasterModel extends Model
|
|||||||
tcs.id AS status_id,
|
tcs.id AS status_id,
|
||||||
CASE
|
CASE
|
||||||
WHEN DATEDIFF(
|
WHEN DATEDIFF(
|
||||||
th.created_at,
|
tm.updated_at,
|
||||||
COALESCE(tm.updated_at, th.created_at)
|
COALESCE(tm.updated_at, th.created_at)
|
||||||
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||||
WHEN DATEDIFF(
|
WHEN DATEDIFF(
|
||||||
th.created_at,
|
tm.updated_at,
|
||||||
COALESCE(tm.updated_at, th.created_at)
|
COALESCE(tm.updated_at, th.created_at)
|
||||||
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||||
WHEN DATEDIFF(
|
WHEN DATEDIFF(
|
||||||
th.created_at,
|
tm.updated_at,
|
||||||
COALESCE(tm.updated_at, th.created_at)
|
COALESCE(tm.updated_at, th.created_at)
|
||||||
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||||
ELSE 'Above 20 Days'
|
ELSE 'Above 20 Days'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user