create setad report tables
This commit is contained in:
@@ -4,20 +4,59 @@ namespace App\Http\Controllers\Setad;
|
||||
|
||||
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 = DataTableFacade::run(
|
||||
CountryCallsReport::query(),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
return response()->json($data);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user