FEAT_TAT_BAND_WISE : RV
This commit is contained in:
parent
f6bed8485d
commit
eba590d907
@ -45,6 +45,7 @@ use App\Controllers\GoogleDriveController;
|
||||
|
||||
use App\Helpers\sendMailNotification;
|
||||
use App\Models\RFQModel;
|
||||
use App\Models\TicketMasterModel;
|
||||
|
||||
class ClientController extends AdminController
|
||||
{
|
||||
@ -4047,11 +4048,11 @@ class ClientController extends AdminController
|
||||
|
||||
// -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------
|
||||
|
||||
$BDSReportController = new BDSReportController();
|
||||
// $BDSReportController = new BDSReportController();
|
||||
|
||||
$data['data'] = $BDSReportController->getBAPInsurerData();
|
||||
// $data['data'] = $BDSReportController->getBAPInsurerData();
|
||||
|
||||
return $this->loadLayout('irda_bap_insurer_report_list', $data);
|
||||
// return $this->loadLayout('irda_bap_insurer_report_list', $data);
|
||||
|
||||
// $data['data'] = $BDSReportController->getBAPClientData();
|
||||
// return $this->loadLayout('irda_bap_client_report_list', $data);
|
||||
@ -4080,6 +4081,15 @@ class ClientController extends AdminController
|
||||
// $result = MailHelper::send_email($data[0]);
|
||||
// echo json_encode($result);
|
||||
// log_message('error',json_encode($result));
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
$ticketModel = new TicketMasterModel();
|
||||
$reportData['data'] = $ticketModel->getTATReport(1);
|
||||
// print_rr($reportData);
|
||||
$this->loadLayout('tat_report_band_wise_list', $reportData);
|
||||
// $data = $ticketModel->getTATReport(1);
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -146,5 +146,125 @@ class TicketMasterModel extends Model
|
||||
return $ticket_data;
|
||||
}
|
||||
|
||||
//get TAT report BAND wise 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 = "WHERE ticket_type = $ticket_type";
|
||||
$ticket_type_data_2 = "AND tm.ticket_type_id = $ticket_type";
|
||||
}
|
||||
|
||||
// Fetch claim statuses from the `ticket_claim_status` table
|
||||
$statusQuery = " SELECT
|
||||
id, claim_status
|
||||
FROM ticket_claim_status
|
||||
$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) {
|
||||
// Dynamically add the COALESCE and CASE for each status in the SELECT part
|
||||
$dynamicSelect .= "
|
||||
COALESCE(
|
||||
SUM(
|
||||
CASE
|
||||
WHEN subquery.status_id = {$status['id']} THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
),
|
||||
0
|
||||
) AS `{$status['claim_status']}`, ";
|
||||
}
|
||||
|
||||
// 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
|
||||
th.ticket_id,
|
||||
tcs.claim_status,
|
||||
tcs.id AS status_id,
|
||||
CASE
|
||||
WHEN DATEDIFF(
|
||||
th.created_at,
|
||||
COALESCE(tm.updated_at, th.created_at)
|
||||
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||
WHEN DATEDIFF(
|
||||
th.created_at,
|
||||
COALESCE(tm.updated_at, th.created_at)
|
||||
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||
WHEN DATEDIFF(
|
||||
th.created_at,
|
||||
COALESCE(tm.updated_at, th.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'
|
||||
) 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($this->db->getLastQuery(), $data);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
101
app/Views/tat_report_band_wise_list.php
Normal file
101
app/Views/tat_report_band_wise_list.php
Normal file
@ -0,0 +1,101 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-12" id="second_page">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">TAT Band Wise Report </h4>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach (array_keys($data[0]) as $header): ?>
|
||||
<th><?= esc($header) ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($data as $row): ?>
|
||||
<tr>
|
||||
<?php foreach ($row as $value): ?>
|
||||
<td class="right-align-input"><?= esc($value) ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-------------------------------------------------------------------------------------------------->
|
||||
|
||||
<script>
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'TAT BAND WISE DATA',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'TAT BAND WISE DATA',
|
||||
}
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
ordering: false,
|
||||
});
|
||||
} else {
|
||||
console.error("Table atet found.");
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user