| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Http\Controllers; |
| 4 |
|
| 5 |
use FluentSupport\App\Models\Agent; |
| 6 |
use FluentSupport\App\Modules\Reporting\Reporting; |
| 7 |
use FluentSupport\App\Modules\StatModule; |
| 8 |
use FluentSupport\App\Services\Helper; |
| 9 |
use FluentSupport\Framework\Request\Request; |
| 10 |
|
| 11 |
class ReportingController extends Controller |
| 12 |
{ |
| 13 |
public function getOverallReports(Request $request) |
| 14 |
{ |
| 15 |
return [ |
| 16 |
'overall_reports' => StatModule::getOverAllStats() |
| 17 |
]; |
| 18 |
} |
| 19 |
|
| 20 |
public function getTicketsChart(Request $request, Reporting $reporting) |
| 21 |
{ |
| 22 |
list($from, $to) = $request->get('date_range') ?: ['', '']; |
| 23 |
|
| 24 |
return [ |
| 25 |
'stats' => $reporting->getTicketsGrowth($from, $to) |
| 26 |
]; |
| 27 |
} |
| 28 |
|
| 29 |
public function getResolveChart(Request $request, Reporting $reporting) |
| 30 |
{ |
| 31 |
list($from, $to) = $request->get('date_range') ?: ['', '']; |
| 32 |
|
| 33 |
return [ |
| 34 |
'stats' => $reporting->getTicketResolveGrowth($from, $to) |
| 35 |
]; |
| 36 |
} |
| 37 |
|
| 38 |
public function getResponseChart(Request $request, Reporting $reporting) |
| 39 |
{ |
| 40 |
list($from, $to) = $request->get('date_range') ?: ['', '']; |
| 41 |
|
| 42 |
return [ |
| 43 |
'stats' => $reporting->getResponseGrowth($from, $to) |
| 44 |
]; |
| 45 |
} |
| 46 |
|
| 47 |
public function getAgentsSummary(Request $request, Reporting $reporting) |
| 48 |
{ |
| 49 |
return [ |
| 50 |
'summary' => $reporting->agentSummary($request->get('from'), $request->get('to')) |
| 51 |
]; |
| 52 |
} |
| 53 |
|
| 54 |
public function getAgentOverallReports(Request $request) |
| 55 |
{ |
| 56 |
$agent = Helper::getAgentByUserId(get_current_user_id()); |
| 57 |
|
| 58 |
return [ |
| 59 |
'overall_reports' => StatModule::getAgentOverallStats($agent->id) |
| 60 |
]; |
| 61 |
} |
| 62 |
|
| 63 |
public function getAgentResolveChart(Request $request, Reporting $reporting) |
| 64 |
{ |
| 65 |
$agent = Helper::getAgentByUserId(get_current_user_id()); |
| 66 |
list($from, $to) = $request->get('date_range') ?: ['', '']; |
| 67 |
|
| 68 |
return [ |
| 69 |
'stats' => $reporting->getTicketResolveGrowth($from, $to, ['agent_id' => $agent->id]) |
| 70 |
]; |
| 71 |
} |
| 72 |
|
| 73 |
public function getAgentResponseChart(Request $request, Reporting $reporting) |
| 74 |
{ |
| 75 |
$agent = Helper::getAgentByUserId(get_current_user_id()); |
| 76 |
list($from, $to) = $request->get('date_range') ?: ['', '']; |
| 77 |
|
| 78 |
return [ |
| 79 |
'stats' => $reporting->getResponseGrowth($from, $to, ['person_id' => $agent->id]) |
| 80 |
]; |
| 81 |
} |
| 82 |
|
| 83 |
public function getPersonalSummary(Reporting $reporting, Request $request) |
| 84 |
{ |
| 85 |
$agent = Helper::getAgentByUserId(get_current_user_id()); |
| 86 |
|
| 87 |
return [ |
| 88 |
'summary' => $reporting->agentSummary($request->get('from'), $request->get('to'), $agent->id) |
| 89 |
]; |
| 90 |
} |
| 91 |
} |
| 92 |
|