diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2f294b04..5065832a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -520,6 +520,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->post('crud_mail_template/(:any)','TicketController::crudTemplate/$1'); $routes->post('note/(:any)','TicketController::crudNote/$1'); $routes->post('reply','TicketController::saveReply'); + $routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports'); // $routes->post('ticket_messages','TicketController::getTicketMessage'); }); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 43b0bf0d..3da804a2 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -841,4 +841,184 @@ class TicketController extends BaseController return 'Ticket id\'s : '.json_encode($ticket_ids); } + + public function ticketReports(){ + + if ($this->request->is('get')){ + $default_start = new \DateTime(); + $data['default_end'] = $default_start->format('d-m-Y'); + $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); + + $data['policy_type'] = $this->ticketType; + $data['account_manager'] = $this->userModel->select('first_name')->where('is_active',1)->where('role',3)->findAll(); + $data['report_type'] = [ + 'acc_manager_wise_status'=>'Account Manger Wise Status Report', + 'tpa_wise_status' => 'TPA Wise Status Report', + 'tat_band_wise' => 'TAT Wise Status Report' + ]; + // + $this->loadLayout('ticket_reports',$data); + }else{ + $received_data = $this->request->getPost(); + $from_Date = $received_data['fromDate']; + $to_Date = $received_data['toDate']; + $fromDate = \DateTime::createFromFormat('d-m-Y', $from_Date)->format('Y-m-d'); + $toDate = \DateTime::createFromFormat('d-m-Y', $to_Date)->format('Y-m-d'); + $policy_type = $received_data['policy_type']; +// print_rr($received_data); + if ($received_data['report_type'] == "acc_manager_wise_status"){ + + $viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type,$fromDate,$toDate); + // print_rr($viewData); + if ($policy_type == 1){ + $html = view('claims_report_acc_manager_gmc', $viewData); + return $this->respond(['status' => true, 'html' => $html], 200); + }else{ + $html = view('claims_report_acc_manager_gpa', $viewData); + return $this->respond(['status' => true, 'html' => $html], 200); + } + + }elseif ($received_data['report_type'] == 'tpa_wise_status'){ + + $viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type,$fromDate,$toDate); + $html = view('claims_report_tpa_wise',$viewData); + return $this->respond(['status' => true, 'html' => $html], 200); + + } + } + + + + } + + public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){ + + if ($policy_type == 1) { + $sql = "SELECT + u.first_name AS acc_manager_name, + COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) AS id_not_generated, + COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) AS non_id, + COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) AS cda, + COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) AS information_required, + COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) AS under_process, + COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) AS approved, + COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) AS payment_initiated, + ( + COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) + ) AS total + FROM + ticket_master master + JOIN + user_profiles u ON master.acm_id = u.id and u.is_active = 1 + JOIN + ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 + WHERE + master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 + GROUP BY + u.id; + "; + $result = $this->ticketMasterModel->query($sql)->getResultArray(); + // dd($result); + + return $result; + + + }else{ + $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 = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer, + COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS client_pending, + COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required, + COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS investigation, + COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved, + COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS on_hold, + + ( + COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END)+ + COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END)+ + COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) + ) AS total1, + COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS not_covered, + COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed, + COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled, + ( + COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + ) AS total2 + FROM + ticket_master master + JOIN + user_profiles u ON master.acm_id = u.id and u.is_active = 1 + JOIN + ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 + WHERE + master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 and master.ticket_type_id = '$policy_type' + GROUP BY + u.id; + "; + $result = $this->ticketMasterModel->query($sql)->getResultArray(); + + return $result; + } + } + + public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){ + // $policy_type = 1; + $sql = "SELECT + tpa.name AS tpa_name, + COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS id_not_generated, + COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS non_id, + COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS cda, + COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required, + COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS under_process, + COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved, + COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS payment_initiated, + ( + COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + ) AS total, + COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed, + COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled, + COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS returned, + COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS denied, + ( + COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type'THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + ) AS total2 + FROM + ticket_master master + JOIN + tpa ON master.tpa_id = tpa.id and tpa.is_active = 1 + JOIN + ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 + WHERE + master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 + GROUP BY + tpa.id; + + + "; + $result = $this->ticketMasterModel->query($sql)->getResultArray(); + + return $result; + } + } diff --git a/app/Views/claims_report_acc_manager_gmc.php b/app/Views/claims_report_acc_manager_gmc.php new file mode 100644 index 00000000..b24b462b --- /dev/null +++ b/app/Views/claims_report_acc_manager_gmc.php @@ -0,0 +1,169 @@ + + +
+
+
+
+
+

Insurer List

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account MangerID Not GeneratedNon-IDCDAInformation RequiredUnder ProcessApprovedPayment InitiatedTotal
Grand Total
+
+
+
+
+ + diff --git a/app/Views/claims_report_acc_manager_gpa.php b/app/Views/claims_report_acc_manager_gpa.php new file mode 100644 index 00000000..b1523e04 --- /dev/null +++ b/app/Views/claims_report_acc_manager_gpa.php @@ -0,0 +1,203 @@ + + +
+
+
+
+
+

Insurer List

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPENCLEARED
Account MangerClaim IntimationIntimation to InsurerClient PendingInsurer PendingInvestigationApprovedOn HoldTotalNot CoveredClosedSettledTotal
Grand Total
+
+
+
+
+ + diff --git a/app/Views/claims_report_tpa_wise.php b/app/Views/claims_report_tpa_wise.php new file mode 100644 index 00000000..3682ca00 --- /dev/null +++ b/app/Views/claims_report_tpa_wise.php @@ -0,0 +1,210 @@ + + +
+
+
+
+
+

Insurer List

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPENCLEARED
TPAID Not GeneratedNon-IDCDAInformation RequiredUnder ProcessApprovedPayment InitiatedTotalClosedSettledReturnedDeniedTotal
Grand Total
+
+
+
+
+ + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index fa265d9c..f26439e5 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -658,6 +658,9 @@
  • Mail Template
  • +
  • + Claim Reports +
  • diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php index 28a782f4..fffb138d 100644 --- a/app/Views/ticket_reply.php +++ b/app/Views/ticket_reply.php @@ -34,7 +34,7 @@
    - + diff --git a/app/Views/ticket_reports.php b/app/Views/ticket_reports.php new file mode 100644 index 00000000..4fe9732d --- /dev/null +++ b/app/Views/ticket_reports.php @@ -0,0 +1,140 @@ +
    +
    +
    +
    +
    + + + +
    +
    +
    + +
    +
    + +
    +   + +
    + > + > +
    + + +
    +
    + +
    + + +
    +
    + +
    + + +
    +
    + +
    + Submit +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + + \ No newline at end of file