create report controller
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class SafetyAndPrivacyReportController extends Controller
|
||||||
|
{
|
||||||
|
public function countryActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -163,9 +163,9 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deserialize(SafetyAndPrivacy $safety_and_privacy): JsonResponse
|
public function deserialize(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||||
{
|
{
|
||||||
$judiciaries = isset($safety_and_privacy->judiciary_document) ? unserialize($safety_and_privacy->judiciary_document) : [];
|
$judiciaries = isset($safetyAndPrivacy->judiciary_document) ? unserialize($safetyAndPrivacy->judiciary_document) : [];
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
@@ -175,4 +175,12 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
|
|
||||||
return $this->successResponse($result);
|
return $this->successResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subItem(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(InfoItem::query()
|
||||||
|
->where('item', 17)
|
||||||
|
->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item')
|
||||||
|
->get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Services\Cartables;
|
|||||||
|
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\Province;
|
||||||
use App\Models\SafetyAndPrivacy;
|
use App\Models\SafetyAndPrivacy;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -48,75 +49,58 @@ class SafetyAndPrivacyTableService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countryActivity(Request $request)
|
public function countryActivity(Request $request): array
|
||||||
{
|
{
|
||||||
$fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString();
|
$fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString();
|
||||||
$toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString();
|
$toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString();
|
||||||
|
|
||||||
$country_name = "کشوری";
|
$activities = [];
|
||||||
$all[0]["info-89"]["step-1"] = 0;
|
|
||||||
$all[0]["info-89"]["step-2"] = 0;
|
|
||||||
$all[0]["info-89"]["step-3"] = 0;
|
|
||||||
|
|
||||||
$all[0]["info-90"]["step-1"] = 0;
|
$country = DB::select(
|
||||||
$all[0]["info-90"]["step-2"] = 0;
|
"SELECT COUNT(*) as qty,info_id, step,step_fa, info_fa FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' GROUP BY info_id,step"
|
||||||
$all[0]["info-90"]["step-3"] = 0;
|
);
|
||||||
|
$provinces = DB::select(
|
||||||
|
"SELECT province_id, COUNT(*) as qty,info_id, step, step_fa, info_fa FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' GROUP BY info_id,step,province_id,province_fa"
|
||||||
|
);
|
||||||
|
|
||||||
$all[0]["info-91"]["step-1"] = 0;
|
$countryTotalSum = 0;
|
||||||
$all[0]["info-91"]["step-2"] = 0;
|
foreach ($country as $key => $value) {
|
||||||
$all[0]["info-91"]["step-3"] = 0;
|
$countryTotalSum += $value->qty;
|
||||||
|
$activities[-1]["info-".$value->info_id]["step-".$value->step] = $value->qty;
|
||||||
$all[0]["sum"] = 0;
|
$activities[-1]["sum"] = $countryTotalSum;
|
||||||
$all[0]["name_fa"] = $country_name;
|
|
||||||
$all[0]["id"] = -1;
|
|
||||||
|
|
||||||
foreach (\App\Models\Province::all() as $key => $value) {
|
|
||||||
$all[$value->id]["info-89"]["step-1"] = 0;
|
|
||||||
$all[$value->id]["info-89"]["step-2"] = 0;
|
|
||||||
$all[$value->id]["info-89"]["step-3"] = 0;
|
|
||||||
|
|
||||||
$all[$value->id]["info-90"]["step-1"] = 0;
|
|
||||||
$all[$value->id]["info-90"]["step-2"] = 0;
|
|
||||||
$all[$value->id]["info-90"]["step-3"] = 0;
|
|
||||||
|
|
||||||
$all[$value->id]["info-91"]["step-1"] = 0;
|
|
||||||
$all[$value->id]["info-91"]["step-2"] = 0;
|
|
||||||
$all[$value->id]["info-91"]["step-3"] = 0;
|
|
||||||
|
|
||||||
$all[$value->id]["sum"] = 0;
|
|
||||||
$all[$value->id]["name_fa"] = $value->name_fa;
|
|
||||||
$all[$value->id]["id"] = $value->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp = DB::select("SELECT COUNT(*) as qty,info_id, step,step_fa, info_fa FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' GROUP BY info_id,step");
|
|
||||||
|
|
||||||
$sum = 0;
|
foreach (Province::all() as $key => $value) {
|
||||||
foreach ($temp as $key => $value) {
|
$activities[$value->id]["info-89"]["step-1"] = 0;
|
||||||
$sum += $value->qty;
|
$activities[$value->id]["info-89"]["step-2"] = 0;
|
||||||
$all[0]["info-".$value->info_id]["step-".$value->step] = $value->qty;
|
$activities[$value->id]["info-89"]["step-3"] = 0;
|
||||||
$all[0]["sum"] = $sum;
|
|
||||||
|
$activities[$value->id]["info-90"]["step-1"] = 0;
|
||||||
|
$activities[$value->id]["info-90"]["step-2"] = 0;
|
||||||
|
$activities[$value->id]["info-90"]["step-3"] = 0;
|
||||||
|
|
||||||
|
$activities[$value->id]["info-91"]["step-1"] = 0;
|
||||||
|
$activities[$value->id]["info-91"]["step-2"] = 0;
|
||||||
|
$activities[$value->id]["info-91"]["step-3"] = 0;
|
||||||
|
|
||||||
|
$activities[$value->id]["sum"] = 0;
|
||||||
|
$activities[$value->id]["name_fa"] = $value->name_fa;
|
||||||
|
$activities[$value->id]["id"] = $value->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp = DB::select("SELECT province_id, COUNT(*) as qty,info_id, step,step_fa, info_fa FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' GROUP BY info_id,step,province_id order by province_id");
|
$provinceTotalSum = 0;
|
||||||
$province_id_flag = "";
|
foreach ($provinces as $key => $value) {
|
||||||
$sum = 0;
|
$provinceTotalSum += $value->qty;
|
||||||
|
$activities[$value->province_id]["info-".$value->info_id]["step-".$value->step] = $value->qty;
|
||||||
foreach ($temp as $key => $value) {
|
$activities[$value->province_id]["sum"] = $provinceTotalSum;
|
||||||
|
$activities[$value->province_id]["province_fa"] = $value->province_fa;
|
||||||
if ($province_id_flag !== $value->province_id) {
|
|
||||||
|
|
||||||
$province_id_flag = $value->province_id;
|
|
||||||
$sum = $value->qty ;
|
|
||||||
|
|
||||||
}else {
|
|
||||||
|
|
||||||
$sum += $value->qty;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$all[$value->province_id]["info-".$value->info_id]["step-".$value->step] = $value->qty;
|
|
||||||
$all[$value->province_id]["sum"] = $sum;
|
|
||||||
}
|
}
|
||||||
return $all;
|
|
||||||
|
return [
|
||||||
|
'activities' => $activities,
|
||||||
|
'fromDate' => $fromDate,
|
||||||
|
'toDate' => $toDate,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Http\Controllers\V3\Dashboard\AccidentReceiptController;
|
|||||||
use App\Http\Controllers\V3\Dashboard\Reports\AccidentReceiptReportController;
|
use App\Http\Controllers\V3\Dashboard\Reports\AccidentReceiptReportController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController;
|
use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController;
|
use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\Reports\SafetyAndPrivacyReportController;
|
||||||
use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController;
|
use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController;
|
||||||
use App\Http\Controllers\V3\Dashboard\RoadObservationController;
|
use App\Http\Controllers\V3\Dashboard\RoadObservationController;
|
||||||
use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
|
use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
|
||||||
@@ -24,7 +25,7 @@ use Illuminate\Support\Facades\Route;
|
|||||||
|
|
||||||
Route::get('admin/permissions', function () {
|
Route::get('admin/permissions', function () {
|
||||||
if (auth()->user()->username == 'witel') {
|
if (auth()->user()->username == 'witel') {
|
||||||
auth()->user()->syncPermissions(\App\Models\Permission::all()->pluck('id')->toArray());
|
auth()->user()->syncPermissions(\App\Models\Permission::all());
|
||||||
return response('done');
|
return response('done');
|
||||||
}
|
}
|
||||||
abort(404);
|
abort(404);
|
||||||
@@ -333,3 +334,10 @@ Route::prefix('safety_and_privacy')
|
|||||||
Route::get('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
Route::get('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
||||||
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::prefix('safety_and_privacy_report')
|
||||||
|
->name('SafetyAndPrivacyReport.')
|
||||||
|
->controller(SafetyAndPrivacyReportController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user