63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\HeadquartersDashboard;
|
|
|
|
use App\Facades\DataTable\DataTableFacade;
|
|
use App\Http\Controllers\Controller;
|
|
use app\Http\Traits\ApiResponse;
|
|
use App\Models\CountryCallsReport;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CumulativeCentersStatsController extends Controller
|
|
{
|
|
use ApiResponse;
|
|
|
|
public function index(Request $request): JsonResponse
|
|
{
|
|
$data = DB::select("
|
|
SELECT
|
|
province_id,
|
|
province_name,
|
|
SUM(total) as total,
|
|
SUM(route_to_teh4) as route_to_teh4,
|
|
SUM(route_to_teh5) as route_to_teh5,
|
|
SUM(route_to_os4) as route_to_os4,
|
|
SUM(route_to_os5) as route_to_os5,
|
|
SUM(answered) as answered,
|
|
SUM(answered_over10) as answered_over10,
|
|
SUM(missed) as missed,
|
|
SUM(dnd) as dnd,
|
|
SUM(transferred) as transferred,
|
|
SUM(talked_to_operator) as talked_to_operator,
|
|
AVG(average_calls_time) as average_calls_time,
|
|
SUM(fails) as fails
|
|
FROM country_calls_reports
|
|
GROUP BY province_id, province_name
|
|
|
|
UNION ALL
|
|
|
|
SELECT
|
|
0 as province_id,
|
|
'کشور' as province_name,
|
|
SUM(total),
|
|
SUM(route_to_teh4),
|
|
SUM(route_to_teh5),
|
|
SUM(route_to_os4),
|
|
SUM(route_to_os5),
|
|
SUM(answered),
|
|
SUM(answered_over10),
|
|
SUM(missed),
|
|
SUM(dnd),
|
|
SUM(transferred),
|
|
SUM(talked_to_operator),
|
|
AVG(average_calls_time),
|
|
SUM(fails)
|
|
FROM country_calls_reports
|
|
");
|
|
|
|
return $this->successResponse($data);
|
|
}
|
|
}
|