create operator dialogue cartable
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ProvinceDashboard\OperatorDialogues;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Dashboard\Province\OperatorDialogues\DataTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OperatorController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request, DataTableService $dataTableService): JsonResponse
|
||||
{
|
||||
return response()->json($dataTableService->index($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function download(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function excel(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Http\Controllers\ProvinceDashboard\PeopleMessages;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Dashboard\Province\PeopleMessages\DataTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SupervisorController extends Controller
|
||||
@@ -10,17 +12,14 @@ class SupervisorController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request, DataTableService $dataTableService): JsonResponse
|
||||
{
|
||||
//
|
||||
return response()->json($dataTableService->index($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function excel()
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,28 +29,4 @@ class SupervisorController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
36
app/Http/Controllers/ProvinceDashboard/ReportController.php
Normal file
36
app/Http/Controllers/ProvinceDashboard/ReportController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ProvinceDashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Dashboard\Province\ReportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function cumulative(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->cumulative($request));
|
||||
}
|
||||
|
||||
public function peopleMessages(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->peopleMessages($request));
|
||||
}
|
||||
|
||||
public function detailedLogs(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->detailedLogs($request));
|
||||
}
|
||||
|
||||
public function operatorPerformanceDaily(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->operatorPerformanceDaily($request));
|
||||
}
|
||||
|
||||
public function operatorPerformanceTotal(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->operatorPerformanceTotal($request));
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\OperatorDialogueRatingFactory;
|
||||
use Database\Factories\OperatorDialogueFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OperatorDialogueRating extends Model
|
||||
class OperatorDialogue extends Model
|
||||
{
|
||||
/** @use HasFactory<OperatorDialogueRatingFactory> */
|
||||
/** @use HasFactory<OperatorDialogueFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Dashboard\Province\OperatorDialogues;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\OperatorDialogue;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DataTableService
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->leftJoin('crm_db.voice_experts', 'asteriskcdrdb.cdr.uniqueid', '=', 'crm_db.operator_dialogues.cdr_unique_id')
|
||||
->where('dst', '<>', '')
|
||||
->where('lastapp', '=', 'Dial')
|
||||
->where('duration', '>', 0)
|
||||
->where('recordingfile', '<>', '')
|
||||
->select('*');
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
}
|
||||
157
app/Services/Dashboard/Province/ReportService.php
Normal file
157
app/Services/Dashboard/Province/ReportService.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Dashboard\Province;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportService
|
||||
{
|
||||
public function cumulative(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->selectRaw("
|
||||
DATE(calldate) AS d,
|
||||
COUNT(CASE WHEN (recordingfile = '' OR recordingfile LIKE 'q-%') THEN 1 END) AS c_all,
|
||||
COUNT(CASE WHEN lastdata = 'IAX2/serverpeer/100' THEN 1 END) AS c_teh4,
|
||||
COUNT(CASE WHEN lastdata = 'IAX2/242serverpeer/200' THEN 1 END) AS c_teh5,
|
||||
COUNT(CASE WHEN dst = '500' THEN 1 END) AS c_os4,
|
||||
COUNT(CASE WHEN dst = '600' THEN 1 END) AS c_os5,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS c_ok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS c_nok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS c_b10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS c_dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS c_trans,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS ch_all,
|
||||
AVG(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' THEN billsec END) AS c_avg
|
||||
");
|
||||
// ->whereBetween('calldate', [$from, $to]) // use Carbon or date strings
|
||||
// ->groupBy(DB::raw('DATE(calldate)'))
|
||||
// ->orderByDesc(DB::raw('DATE(calldate)'))
|
||||
// ->get();
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedGroupBy: ['d']
|
||||
);
|
||||
}
|
||||
|
||||
public function peopleMessages(Request $request)
|
||||
{
|
||||
$query = DB::table('people_messages')
|
||||
->selectRaw('
|
||||
COUNT(CASE WHEN is_listen = 1 THEN 1 END) AS c_l,
|
||||
COUNT(CASE WHEN is_listen = 0 THEN 1 END) AS c_nl
|
||||
');
|
||||
// ->whereBetween('date', [$date_from, $date_to])
|
||||
// ->first();
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function detailedLogs(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->where('recordingfile', '<>', '');
|
||||
// ->whereBetween('calldate', ["$date_from $time_from", "$date_to $time_to"])
|
||||
// ->when($cid, function ($query, $cid) {
|
||||
// return $query->where('src', 'like', "%{$cid}%");
|
||||
// })
|
||||
// ->when($c_op, function ($query, $c_op) {
|
||||
// return $query->where('dst', $c_op);
|
||||
// }, function ($query) {
|
||||
// return $query->whereBetween('dst', [100, 110]);
|
||||
// })
|
||||
// ->orderByDesc('calldate');
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function operatorPerformanceDaily(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->selectRaw("
|
||||
SELECT
|
||||
*
|
||||
(ch_all - (c_ok + c_nok)) AS c_fail
|
||||
FROM (
|
||||
SELECT
|
||||
DATE(calldate) AS d,
|
||||
dst,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS c_ok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS c_nok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS c_b10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS c_dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS c_trans,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS ch_all
|
||||
FROM asteriskcdrdb.cdr
|
||||
WHERE dst BETWEEN 101 AND 105 AND calldate BETWEEN ? AND ?
|
||||
GROUP BY d, dst
|
||||
ORDER BY d, dst
|
||||
);
|
||||
");
|
||||
// ->whereBetween('calldate', ["$date_from $time_from", "$date_to $time_to"])
|
||||
// ->when($cid, function ($query, $cid) {
|
||||
// return $query->where('src', 'like', "%{$cid}%");
|
||||
// })
|
||||
// ->when($c_op, function ($query, $c_op) {
|
||||
// return $query->where('dst', $c_op);
|
||||
// }, function ($query) {
|
||||
// return $query->whereBetween('dst', [100, 110]);
|
||||
// })
|
||||
// ->orderByDesc('calldate');
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function operatorPerformanceTotal(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->selectRaw("
|
||||
SELECT
|
||||
*
|
||||
(ch_all - (c_ok + c_nok)) AS c_fail
|
||||
FROM (
|
||||
SELECT
|
||||
DATE(calldate) AS d,
|
||||
dst,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS c_ok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS c_nok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS c_b10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS c_dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS c_trans,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS ch_all
|
||||
FROM asteriskcdrdb.cdr
|
||||
WHERE dst BETWEEN 101 AND 105 AND calldate BETWEEN ? AND ?
|
||||
GROUP dst
|
||||
ORDER dst
|
||||
);
|
||||
");
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ namespace Database\Factories;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OperatorDialogueRating>
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OperatorDialogue>
|
||||
*/
|
||||
class OperatorDialogueRatingFactory extends Factory
|
||||
class OperatorDialogueFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
@@ -11,11 +11,11 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('operator_dialogue_ratings', function (Blueprint $table) {
|
||||
Schema::create('operator_dialogues', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('cdr_unique_id');
|
||||
$table->dateTime('date');
|
||||
$table->foreignId('expert_id')->constrained('users');
|
||||
$table->foreignId('supervisor_id')->constrained('users');
|
||||
$table->boolean('is_listen')->default(false);
|
||||
$table->boolean('is_good');
|
||||
$table->string('description')->nullable();
|
||||
@@ -28,6 +28,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('operator_dialogue_ratings');
|
||||
Schema::dropIfExists('operator_dialogues');
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OperatorDialogueRatingSeeder extends Seeder
|
||||
class OperatorDialogueSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
Reference in New Issue
Block a user