Merge pull request #130 from witelgroup/develop

Develop
This commit is contained in:
Amir Ghasempoor
2026-01-31 13:23:28 +03:30
committed by GitHub
26 changed files with 1352 additions and 237 deletions

View File

@@ -98,9 +98,9 @@ HARIM_NEED_GUARANTEE_LETTER_URL='https://zamin.gov.ir/ow/api/ow/esb/response'
HARIM_NEED_GUARANTEE_LETTER_PASSWORD= HARIM_NEED_GUARANTEE_LETTER_PASSWORD=
HARIM_NEED_GUARANTEE_LETTER_USERNAME= HARIM_NEED_GUARANTEE_LETTER_USERNAME=
BACKUP_TARGET_DIR= BACKUP_TARGET_DIR=/var
BACKUP_USER= BACKUP_USER=
BACKUP_PASSWORD= BACKUP_PASSWORD=1qaz
HARIM_ENCRYPTION_KEY="TestKey" HARIM_ENCRYPTION_KEY="TestKey"

View File

@@ -58,14 +58,20 @@ class DailyMovingMachineCommand extends Command
break; break;
} }
$machine = CMMSMachine::query()->firstWhere('machine_code', '=', $code);
MissionViolation::query()->create([ MissionViolation::query()->create([
'machine_code' => $code, 'machine_code' => $code,
'machine_id' => CMMSMachine::query()->firstWhere('machine_code', '=', $code)->id, 'machine_id' => $machine->id,
'type' => MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value, 'type' => MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
'request_date' => $date, 'request_date' => $date,
'mileage' => $cmm['mileageKM'], 'mileage' => $cmm['mileageKM'],
// 'exit_time' => $cmm['exit_time'], // 'exit_time' => $cmm['exit_time'],
// 'enter_time' => $cmm['enter_time'], // 'enter_time' => $cmm['enter_time'],
'province_id' => $machine->province_id,
// 'province_name' => $machine->province_fa,
'city_id' => $machine->city_id,
// 'city_name' => $machine->city_fa,
]); ]);
} }

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Exports\V3\Mission\Report\Tradod;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithDrawings;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$grid = [];
$national = null;
foreach ($this->data as $r) {
$pid = (int) $r->province_id;
$name = $r->province_name;
if ($pid === -1) {
$national = [
'province_name' => $name,
'total' => (int) ($r->total ?? 0),
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
'gps' => (int) ($r->gps ?? 0),
'durations' => (int) ($r->durations ?? 0),
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
'bedon_bafarayand_rozaneh' => (int) ($r->un_far_d ?? 0),
'item' => (int) ($r->item ?? 0),
'patrol' => (int) ($r->patrol ?? 0),
];
continue;
}
if (! isset($grid[$pid])) {
$grid[$pid] = [
'province_name' => $name,
];
}
$grid[$pid]['total'] = (int) ($r->total ?? 0);
$grid[$pid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
$grid[$pid]['gps'] = (int) ($r->gps ?? 0);
$grid[$pid]['durations'] = (int) ($r->durations ?? 0);
$grid[$pid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
$grid[$pid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
$grid[$pid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
$grid[$pid]['bedon_bafarayand_rozaneh'] = (int) ($r->un_far_d ?? 0);
$grid[$pid]['item'] = (int) ($r->item ?? 0);
$grid[$pid]['patrol'] = (int) ($r->patrol ?? 0);
}
$exportRows = [];
if ($national) {
$exportRows[] = $national;
}
foreach ($grid as $row) {
$exportRows[] = $row;
}
return view('v3.Reports.Mission.Report.Tradod .CountryActivityReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
public function drawings(): array
{
$drawing = new Drawing();
$drawing->setName('Logo');
$drawing->setDescription('This is my logo');
$drawing->setPath(public_path('/dist/logo.png'));
$drawing->setWidth(50);
$drawing->setHeight(50);
$drawing->setOffsetX(5);
$drawing->setOffsetY(5);
$drawing->setCoordinates('A1');
$drawing2 = new Drawing();
$drawing2->setName('Logo');
$drawing2->setDescription('This is my logo');
$drawing2->setPath(public_path('/dist/141icon.png'));
$drawing2->setWidth(50);
$drawing2->setHeight(50);
$drawing2->setOffsetX(5);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('J1');
return [$drawing, $drawing2];
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace App\Exports\V3\Mission\Report\Tradod;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithDrawings;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Exception;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$grid = [];
$province = null;
foreach ($this->data as $r) {
$cid = (int) $r->city_id;
$name = $r->city_name;
if ($cid === -1) {
$province = [
'city_name' => $name,
'total' => (int) ($r->total ?? 0),
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
'gps' => (int) ($r->gps ?? 0),
'durations' => (int) ($r->durations ?? 0),
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
'bedon_bafarayand_rozaneh' => (int) ($r->un_far_d ?? 0),
'item' => (int) ($r->item ?? 0),
'patrol' => (int) ($r->patrol ?? 0),
];
continue;
}
if (! isset($grid[$cid])) {
$grid[$cid] = [
'city_name' => $name,
];
}
$grid[$cid]['total'] = (int) ($r->total ?? 0);
$grid[$cid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
$grid[$cid]['gps'] = (int) ($r->gps ?? 0);
$grid[$cid]['durations'] = (int) ($r->durations ?? 0);
$grid[$cid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
$grid[$cid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
$grid[$cid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
$grid[$cid]['bedon_bafarayand_rozaneh'] = (int) ($r->un_far_d ?? 0);
$grid[$cid]['item'] = (int) ($r->item ?? 0);
$grid[$cid]['patrol'] = (int) ($r->patrol ?? 0);
}
$exportRows = [];
if ($province) {
$exportRows[] = $province;
}
foreach ($grid as $row) {
$exportRows[] = $row;
}
return view('v3.Reports.Mission.Report.Tradod .ProvinceActivityReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
/**
* @throws Exception
*/
public function drawings(): array
{
$drawing = new Drawing();
$drawing->setName('Logo');
$drawing->setDescription('This is my logo');
$drawing->setPath(public_path('/dist/logo.png'));
$drawing->setWidth(50);
$drawing->setHeight(50);
$drawing->setOffsetX(5);
$drawing->setOffsetY(5);
$drawing->setCoordinates('A1');
$drawing2 = new Drawing();
$drawing2->setName('Logo');
$drawing2->setDescription('This is my logo');
$drawing2->setPath(public_path('/dist/141icon.png'));
$drawing2->setWidth(50);
$drawing2->setHeight(50);
$drawing2->setOffsetX(5);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('J1');
return [$drawing, $drawing2];
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace App\Exports\V3\Mission\Report\Violation;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithDrawings;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$grid = [];
$national = null;
foreach ($this->data as $r) {
$pid = (int) $r->province_id;
$name = $r->province_name;
if ($pid === -1) {
$national = [
'province_name' => $name,
'total' => (int) ($r->total ?? 0),
'egdam_shode' => (int) ($r->done ?? 0),
'bedone_egdam' => (int) ($r->undone ?? 0),
'sabt_gps' => (int) ($r->gps ?? 0),
'sabt_herasat' => (int) ($r->herasat ?? 0),
'mil_gps' => (int) ($r->mil_gps ?? 0),
];
continue;
}
if (! isset($grid[$pid])) {
$grid[$pid] = [
'province_name' => $name,
];
}
$grid[$pid]['total'] = (int) ($r->total ?? 0);
$grid[$pid]['egdam_shode'] = (int) ($r->done ?? 0);
$grid[$pid]['bedone_egdam'] = (int) ($r->undone ?? 0);
$grid[$pid]['sabt_gps'] = (int) ($r->gps ?? 0);
$grid[$pid]['sabt_herasat'] = (int) ($r->herasat ?? 0);
$grid[$pid]['mil_gps'] = (int) ($r->mil_gps ?? 0);
}
$exportRows = [];
if ($national) {
$exportRows[] = $national;
}
foreach ($grid as $row) {
$exportRows[] = $row;
}
return view('v3.Reports.Mission.Report.CountryActivityReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
public function drawings(): array
{
$drawing = new Drawing();
$drawing->setName('Logo');
$drawing->setDescription('This is my logo');
$drawing->setPath(public_path('/dist/logo.png'));
$drawing->setWidth(50);
$drawing->setHeight(50);
$drawing->setOffsetX(5);
$drawing->setOffsetY(5);
$drawing->setCoordinates('A1');
$drawing2 = new Drawing();
$drawing2->setName('Logo');
$drawing2->setDescription('This is my logo');
$drawing2->setPath(public_path('/dist/141icon.png'));
$drawing2->setWidth(50);
$drawing2->setHeight(50);
$drawing2->setOffsetX(5);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('G1');
return [$drawing, $drawing2];
}
}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Exports\V3\Mission\Report\Violation;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithDrawings;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Exception;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$grid = [];
$province = null;
foreach ($this->data as $r) {
$cid = (int) $r->city_id;
$name = $r->city_name;
if ($cid === -1) {
$province = [
'city_name' => $name,
'total' => (int) ($r->total ?? 0),
'egdam_shode' => (int) ($r->done ?? 0),
'bedone_egdam' => (int) ($r->undone ?? 0),
'sabt_gps' => (int) ($r->gps ?? 0),
'sabt_herasat' => (int) ($r->herasat ?? 0),
'mil_gps' => (int) ($r->mil_gps ?? 0),
];
continue;
}
if (! isset($grid[$cid])) {
$grid[$cid] = [
'city_name' => $name,
];
}
$grid[$cid]['total'] = (int) ($r->total ?? 0);
$grid[$cid]['egdam_shode'] = (int) ($r->done ?? 0);
$grid[$cid]['bedone_egdam'] = (int) ($r->undone ?? 0);
$grid[$cid]['sabt_gps'] = (int) ($r->gps ?? 0);
$grid[$cid]['sabt_herasat'] = (int) ($r->herasat ?? 0);
$grid[$cid]['mil_gps'] = (int) ($r->mil_gps ?? 0);
}
$exportRows = [];
if ($province) {
$exportRows[] = $province;
}
foreach ($grid as $row) {
$exportRows[] = $row;
}
return view('v3.Reports.Mission.Report.ProvinceActivityReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
/**
* @throws Exception
*/
public function drawings(): array
{
$drawing = new Drawing();
$drawing->setName('Logo');
$drawing->setDescription('This is my logo');
$drawing->setPath(public_path('/dist/logo.png'));
$drawing->setWidth(50);
$drawing->setHeight(50);
$drawing->setOffsetX(5);
$drawing->setOffsetY(5);
$drawing->setCoordinates('A1');
$drawing2 = new Drawing();
$drawing2->setName('Logo');
$drawing2->setDescription('This is my logo');
$drawing2->setPath(public_path('/dist/141icon.png'));
$drawing2->setWidth(50);
$drawing2->setHeight(50);
$drawing2->setOffsetX(5);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('G1');
return [$drawing, $drawing2];
}
}

View File

@@ -43,7 +43,7 @@ class ControlUnitController extends Controller
$mission->update([ $mission->update([
'state_id' => $state, 'state_id' => $state,
'state_name' => MissionStates::name($state), 'state_name' => MissionStates::name($state),
'start_time' => now(), 'start_time' => $request->time,
'km' => $request->km, 'km' => $request->km,
]); ]);
}); });
@@ -56,7 +56,7 @@ class ControlUnitController extends Controller
*/ */
public function finish(FinishRequest $request, Mission $mission, GetErrorRateService $getErrorRateService): JsonResponse public function finish(FinishRequest $request, Mission $mission, GetErrorRateService $getErrorRateService): JsonResponse
{ {
DB::transaction(function () use ($mission, $getErrorRateService) { DB::transaction(function () use ($mission, $getErrorRateService, $request) {
$mission->histories()->create([ $mission->histories()->create([
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,
'previous_state_id' => $mission->state_id, 'previous_state_id' => $mission->state_id,
@@ -68,8 +68,8 @@ class ControlUnitController extends Controller
$mission->update([ $mission->update([
'state_id' => $state, 'state_id' => $state,
'state_name' => MissionStates::name($state), 'state_name' => MissionStates::name($state),
'finish_time' => now(), 'finish_time' => $request->time,
'mission_duration' => strtotime(now()) - strtotime($mission->start_time), 'mission_duration' => strtotime($request->time) - strtotime($mission->start_time),
]); ]);
$getErrorRateService->setInputParameters($mission); $getErrorRateService->setInputParameters($mission);

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
use App\Exports\V3\Mission\Report\Tradod\CountryReport;
use App\Exports\V3\Mission\Report\Tradod\ProvinceReport;
use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\City;
use App\Models\Province;
use App\Services\Cartables\Mission\Report\ReportTradodService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use PhpOffice\PhpSpreadsheet\Exception;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ReportTradodController extends Controller
{
use ApiResponse;
public function countryActivity(Request $request, ReportTradodService $reportMissionService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMissionService->countryActivity($request),
'provinces' => Province::all(['id', 'name_fa']),
]);
}
public function provinceActivity(Request $request, ReportTradodService $reportMissionService): JsonResponse
{
return $this->successResponse([
'activities' =>$reportMissionService->provinceActivity($request),
'city' => City::query()
->where('province_id', $request->province_id)
->where(function ($query) {
$query->where('type_id', 1)
->orWhereIn('name_fa', ['اداره ماشين‌آلات', 'اداره نقلیه']);
})
->get(['id', 'name_fa'])
]);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function countryExcelActivity(Request $request, ReportTradodService $reportMissionService): BinaryFileResponse
{
$data = $reportMissionService->countryActivity($request);
$name = 'گزارش کل تردد '.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new CountryReport($data), $name);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function provinceExcelActivity(Request $request, ReportTradodService $reportMissionService): BinaryFileResponse
{
$data = $reportMissionService->provinceActivity($request);
$name = 'گزارش کل تردد '.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new ProvinceReport($data), $name);
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
use App\Exports\V3\Mission\Report\Violation\CountryReport;
use App\Exports\V3\Mission\Report\Violation\ProvinceReport;
use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\City;
use App\Models\Province;
use App\Services\Cartables\Mission\Report\ReportViolationService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use PhpOffice\PhpSpreadsheet\Exception;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ReportViolationController extends Controller
{
use ApiResponse;
public function countryActivity(Request $request, ReportViolationService $reportService): JsonResponse
{
return $this->successResponse([
'activities' => $reportService->countryActivity($request),
'provinces' => Province::all(['id', 'name_fa']),
]);
}
public function provinceActivity(Request $request, ReportViolationService $reportService): JsonResponse
{
return $this->successResponse([
'activities' =>$reportService->provinceActivity($request),
'city' => City::query()
->where('province_id', $request->province_id)
->where(function ($query) {
$query->where('type_id', 1)
->orWhereIn('name_fa', ['اداره ماشين‌آلات', 'اداره نقلیه']);
})
->get(['id', 'name_fa'])
]);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function countryExcelActivity(Request $request, ReportViolationService $reportService): BinaryFileResponse
{
$data = $reportService->countryActivity($request);
$name = 'گزارش تخلفات ماموریت ها '.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new CountryReport($data), $name);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function provinceExcelActivity(Request $request, ReportViolationService $reportService): BinaryFileResponse
{
$data = $reportService->provinceActivity($request);
$name = 'گزارش تخلفات ماموریت ها '.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new ProvinceReport($data), $name);
}
}

View File

@@ -1,48 +0,0 @@
<?php
namespace App\Http\Controllers\V3\Dashboard\Mission;
use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\City;
use App\Models\Province;
use App\Services\Cartables\Mission\ReportService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ReportController extends Controller
{
use ApiResponse;
public function countryActivity(Request $request, ReportService $reportService): JsonResponse
{
return $this->successResponse([
'activities' => $reportService->countryActivity($request),
'provinces' => Province::all(['id', 'name_fa']),
]);
}
public function provinceActivity(Request $request, ReportService $reportService): JsonResponse
{
return $this->successResponse([
'activities' =>$reportService->provinceActivity($request),
'city' => City::query()->where('province_id', $request->province_id)->get(['id', 'name_fa']),
]);
}
//
// public function countryExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
// {
// $data = $operatorService->countryActivity($request);
// $name = 'گزارش تخلفات ماموریت ها '.verta()->now()->format('Y-m-d H-i').'.xlsx';
//
// return Excel::download(new ExcelReport($data), $name);
// }
//
// public function provinceExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
// {
// $data = $operatorService->provinceActivity($request);
// $name = 'گزارش تخلفات ماموریت ها '.verta()->now()->format('Y-m-d H-i').'.xlsx';
//
// return Excel::download(new ProvinceExcelReport($data, $request), $name);
// }
}

View File

@@ -96,6 +96,8 @@ class ViolationManagementController extends Controller
} }
public function store(StoreRequest $request): JsonResponse public function store(StoreRequest $request): JsonResponse
{ {
$user = auth()->user();
MissionViolation::query()->create([ MissionViolation::query()->create([
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'), 'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
'machine_code'=> $request->machine_code, 'machine_code'=> $request->machine_code,
@@ -104,6 +106,10 @@ class ViolationManagementController extends Controller
'request_date' => now(), 'request_date' => now(),
'km' => $request->km, 'km' => $request->km,
'gps' => 0, 'gps' => 0,
'province_id' => $user->province_id,
'province_name' => $user->province_fa,
'city_id' => $user->city_id,
'city_name' => $user->city_fa,
]); ]);
return $this->successResponse(); return $this->successResponse();

View File

@@ -24,7 +24,7 @@ class FinishRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
// 'time' => 'required|date',
]; ];
} }
} }

View File

@@ -27,6 +27,7 @@ class StartRequest extends FormRequest
return [ return [
'code' => 'required|string', 'code' => 'required|string',
'km' => 'required', 'km' => 'required',
'time' => 'required|date',
]; ];
} }

View File

@@ -2,7 +2,6 @@
namespace App\Services\Cartables\Mission; namespace App\Services\Cartables\Mission;
use App\Enums\MissionStates; use App\Enums\MissionStates;
use App\Facades\DataTable\DataTableFacade; use App\Facades\DataTable\DataTableFacade;
use App\Http\Traits\ApiResponse; use App\Http\Traits\ApiResponse;
@@ -19,16 +18,14 @@ class ControlUnitService
$user = Auth::user(); $user = Auth::user();
$query = Mission::query()->whereIn('state_id', [ $query = Mission::query()->whereIn('state_id', [
MissionStates::PENDING_CONFIRMATION->value, MissionStates::START_MISSION->value MissionStates::PENDING_CONFIRMATION->value, MissionStates::START_MISSION->value,
]); ]);
if ($user->hasPermissionTo('manage-control-unit-station')) { if ($user->hasPermissionTo('manage-control-unit-station')) {
$query->where('station_id', '=', $user->station_id); $query->where('station_id', '=', $user->station_id);
} } elseif ($user->hasPermissionTo('manage-control-unit-city')) {
elseif ($user->hasPermissionTo('manage-control-unit-city')) {
$query->where('city_id', '=', $user->city_id); $query->where('city_id', '=', $user->city_id);
} } elseif ($user->hasPermissionTo('manage-control-unit-province')) {
elseif ($user->hasPermissionTo('manage-control-unit-province')) {
$query->where('province_id', '=', $user->province_id); $query->where('province_id', '=', $user->province_id);
} }
@@ -41,8 +38,8 @@ class ControlUnitService
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time', 'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time',
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name' 'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name',
] ]
); );
} }
} }

View File

@@ -17,11 +17,9 @@ class DailyMoveMachineService
if ($user->hasPermissionTo('manage-violation-station')) { if ($user->hasPermissionTo('manage-violation-station')) {
$query->whereRelation('machine', 'station_id', '=', $user->station_id); $query->whereRelation('machine', 'station_id', '=', $user->station_id);
} } elseif ($user->hasPermissionTo('manage-violation-city')) {
elseif ($user->hasPermissionTo('manage-violation-city')) {
$query->whereRelation('machine', 'city_id', '=', $user->city_id); $query->whereRelation('machine', 'city_id', '=', $user->city_id);
} } elseif ($user->hasPermissionTo('manage-violation-province')) {
elseif ($user->hasPermissionTo('manage-violation-province')) {
$query->whereRelation('machine', 'province_id', '=', $user->province_id); $query->whereRelation('machine', 'province_id', '=', $user->province_id);
} }

View File

@@ -0,0 +1,155 @@
<?php
namespace App\Services\Cartables\Mission\Report;
use App\Facades\DataTable\DataTableFacade;
use App\Models\MissionViolation;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ReportTradodService
{
public function dataTable(Request $request)
{
$user = auth()->user();
$query = MissionViolation::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
return DataTableFacade::run(
$query,
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
);
}
public function countryActivity(Request $request): array
{
$from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
$sql = "
SELECT*
FROM(
SELECT
'کل کشور' AS province_name,
-1 AS province_id,
COUNT(m.id) AS total,
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
COALESCE(SUM(m.in_area_duration), 0) AS gps,
COALESCE(SUM(m.mission_duration), 0) AS durations,
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
FROM missions m
WHERE m.created_at >= :from_m_1
AND m.created_at <= :to_m_1
UNION ALL
SELECT
p.name_fa AS province_name,
p.id AS province_id,
COUNT(m.id) AS total,
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
COALESCE(SUM(m.in_area_duration), 0) AS gps,
COALESCE(SUM(m.mission_duration), 0) AS durations,
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
FROM provinces p
LEFT JOIN missions m
ON m.province_id = p.id
AND m.created_at >= :from_m_2
AND m.created_at <= :to_m_2
GROUP BY p.id, p.name_fa
) q
ORDER BY
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
province_name;
";
return DB::select($sql, [
'from_m_1' => $from,
'to_m_1' => $to,
'from_m_2' => $from,
'to_m_2' => $to,
]);
}
public function provinceActivity(Request $request): array
{
$provinceId = $request->province_id ?? auth()->user()->province_id;
$from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
$sql = "
SELECT*
FROM(
SELECT
'کل استان' AS city_name,
-1 AS city_id,
COUNT(m.id) AS total,
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
COALESCE(SUM(m.in_area_duration), 0) AS gps,
COALESCE(SUM(m.mission_duration), 0) AS durations,
COALESCE(SUM(m.type = 1), 0) AS far_h,
COALESCE(SUM(m.type = 2), 0) AS far_d,
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
COALESCE(SUM(m.category_id = 1), 0) AS item,
COALESCE(SUM(m.category_id = 2), 0) AS patrol
FROM missions m
WHERE m.created_at >= :from_m_1
AND m.created_at <= :to_m_1
AND m.province_id = :province_id_1
UNION ALL
SELECT
c.name_fa AS city_name,
c.id AS city_id,
COUNT(m.id) AS total,
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
COALESCE(SUM(m.in_area_duration), 0) AS gps,
COALESCE(SUM(m.mission_duration), 0) AS durations,
COALESCE(SUM(m.type = 1), 0) AS far_h,
COALESCE(SUM(m.type = 2), 0) AS far_d,
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
COALESCE(SUM(m.category_id = 1), 0) AS item,
COALESCE(SUM(m.category_id = 2), 0) AS patrol
FROM cities c
LEFT JOIN missions m
ON m.city_id = c.id
AND m.created_at >= :from_m_2
AND m.created_at <= :to_m_2
WHERE c.province_id = :province_id_2
AND (
c.type_id = 1
OR c.name_fa IN ('اداره ماشين‌آلات', 'اداره نقلیه')
)
GROUP BY c.id, c.name_fa
) q
ORDER BY
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
q.city_name;
";
return DB::select($sql, [
'province_id_1' => $provinceId,
'from_m_1' => $from,
'to_m_1' => $to,
'province_id_2' => $provinceId,
'from_m_2' => $from,
'to_m_2' => $to,
]);
}
}

View File

@@ -0,0 +1,142 @@
<?php
namespace App\Services\Cartables\Mission\Report;
use App\Facades\DataTable\DataTableFacade;
use App\Models\MissionViolation;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ReportViolationService
{
public function dataTable(Request $request)
{
$user = auth()->user();
$query = MissionViolation::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
return DataTableFacade::run(
$query,
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
);
}
public function countryActivity(Request $request): array
{
$from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
$sql = "
SELECT*
FROM(
SELECT
'کل کشور' AS province_name,
-1 AS province_id,
COUNT(mv.id) AS total,
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
FROM mission_violations mv
WHERE mv.created_at >= :from_mv_1
AND mv.created_at <= :to_mv_1
UNION ALL
SELECT
p.name_fa AS province_name,
p.id AS province_id,
COUNT(mv.id) AS total,
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
FROM provinces p
LEFT JOIN mission_violations mv
ON mv.province_id = p.id
AND mv.type = 1
AND mv.created_at >= :from_mv_2
AND mv.created_at <= :to_mv_2
GROUP BY p.id, p.name_fa
) q
ORDER BY
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
province_name;
";
return DB::select($sql, [
'from_mv_1' => $from,
'to_mv_1' => $to,
'from_mv_2' => $from,
'to_mv_2' => $to,
]);
}
public function provinceActivity(Request $request): array
{
$provinceId = $request->province_id ?? auth()->user()->province_id;
$from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
$sql = "
SELECT*
FROM(
SELECT
'کل استان' AS city_name,
-1 AS city_id,
COUNT(mv.id) AS total,
COALESCE(SUM(mv.status = 1), 0) AS done,
COALESCE(SUM(mv.status = 0), 0) AS undone,
COALESCE(SUM(mv.gps = 1), 0) AS gps,
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
FROM mission_violations mv
WHERE mv.type = 1
AND mv.created_at >= :from_mv_1
AND mv.created_at <= :to_mv_1
AND mv.province_id = :province_id_1
UNION ALL
SELECT
c.name_fa AS city_name,
c.id AS city_id,
COUNT(mv.id) AS total,
COALESCE(SUM(mv.status = 1), 0) AS done,
COALESCE(SUM(mv.status = 0), 0) AS undone,
COALESCE(SUM(mv.gps = 1), 0) AS gps,
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
FROM cities c
LEFT JOIN mission_violations mv
ON mv.city_id = c.id
AND mv.type = 1
AND mv.created_at >= :from_mv_2
AND mv.created_at <= :to_mv_2
WHERE c.province_id = :province_id_2
AND (
c.type_id = 1
OR c.name_fa IN ('اداره ماشين‌آلات', 'اداره نقلیه')
)
GROUP BY c.id, c.name_fa
) q
ORDER BY
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
q.city_name;
";
return DB::select($sql, [
'province_id_1' => $provinceId,
'from_mv_1' => $from,
'to_mv_1' => $to,
'province_id_2' => $provinceId,
'from_mv_2' => $from,
'to_mv_2' => $to,
]);
}
}

View File

@@ -1,152 +0,0 @@
<?php
namespace App\Services\Cartables\Mission;
use App\Exceptions\ProhibitedAction;
use App\Facades\DataTable\DataTableFacade;
use App\Models\Mission;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ReportService
{
public function dataTable(Request $request)
{
$user = auth()->user();
$query = Mission::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
return DataTableFacade::run(
$query,
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
);
}
public function countryActivity(Request $request): array
{
$from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ?? today()->endOfDay();
$sql = "
WITH r AS (
SELECT
p.id AS province_id,
p.name_fa AS province_name,
COUNT(DISTINCT CASE
WHEN mv.type = 1
AND mv.created_at BETWEEN :from_mv AND :to_mv
THEN mv.id
END) AS no_mission_count,
COUNT(DISTINCT CASE
WHEN m.mission_duration != m.in_area_duration
AND m.created_at BETWEEN :from_m AND :to_m
THEN m.id
END) AS out_of_area_count
FROM provinces p
LEFT JOIN cmms_machines cm
ON cm.province_id = p.id
LEFT JOIN mission_violations mv
ON TRIM(cm.machine_code) = TRIM(mv.machine_code)
LEFT JOIN missions m
ON m.province_id = p.id
GROUP BY p.id, p.name_fa
)
SELECT
-1 AS province_id,
'کل کشور' AS province_name,
SUM(no_mission_count) AS no_mission_count,
SUM(out_of_area_count) AS out_of_area_count
FROM r
UNION ALL
SELECT
province_id, province_name, no_mission_count, out_of_area_count
FROM r
ORDER BY
CASE WHEN province_name = 'کل کشور' THEN 0 ELSE 1 END,
province_name
";
return DB::select($sql, [
'from_mv' => $from,
'to_mv' => $to,
'from_m' => $from,
'to_m' => $to,
]);
}
public function provinceActivity(Request $request): array
{
$provinceId = $request->province_id ?? auth()->user()->province_id;
$from = $request->from_date ?? today()->startOfDay();
$to = $request->to_date ?? today()->endOfDay();
$sql = "
WITH r AS (
SELECT
c.id AS city_id,
c.name_fa AS city_name,
COUNT(DISTINCT CASE
WHEN mv.type = 1
AND mv.created_at BETWEEN :from_mv AND :to_mv
THEN mv.id
END) AS no_mission_count,
COUNT(DISTINCT CASE
WHEN m.mission_duration != m.in_area_duration
AND m.created_at BETWEEN :from_m AND :to_m
THEN m.id
END) AS out_of_area_count
FROM cities c
LEFT JOIN cmms_machines cm
ON cm.city_id = c.id
LEFT JOIN mission_violations mv
ON TRIM(cm.machine_code) = TRIM(mv.machine_code)
LEFT JOIN missions m
ON m.city_id = c.id
WHERE c.province_id = :province_id
GROUP BY c.id, c.name_fa
)
SELECT
-1 AS city_id,
'کل استان' AS city_name,
SUM(no_mission_count) AS no_mission_count,
SUM(out_of_area_count) AS out_of_area_count
FROM r
UNION ALL
SELECT
city_id, city_name, no_mission_count, out_of_area_count
FROM r
ORDER BY
CASE WHEN city_id = -1 THEN 0 ELSE 1 END,
city_name
";
return DB::select($sql, [
'province_id' => $provinceId,
'from_mv' => $from,
'to_mv' => $to,
'from_m' => $from,
'to_m' => $to,
]);
}
}

View File

@@ -2,7 +2,6 @@
namespace App\Services\Cartables\Mission; namespace App\Services\Cartables\Mission;
use App\Facades\DataTable\DataTableFacade; use App\Facades\DataTable\DataTableFacade;
use App\Http\Traits\ApiResponse; use App\Http\Traits\ApiResponse;
use App\Models\Mission; use App\Models\Mission;
@@ -19,11 +18,9 @@ class RequestPortalService
if ($user->hasPermissionTo('manage-request-portal-station')) { if ($user->hasPermissionTo('manage-request-portal-station')) {
$query->where('station_id', '=', $user->station_id); $query->where('station_id', '=', $user->station_id);
} } elseif ($user->hasPermissionTo('manage-request-portal-city')) {
elseif ($user->hasPermissionTo('manage-request-portal-city')) {
$query->where('city_id', '=', $user->city_id); $query->where('city_id', '=', $user->city_id);
} } elseif ($user->hasPermissionTo('manage-request-portal-province')) {
elseif ($user->hasPermissionTo('manage-request-portal-province')) {
$query->where('province_id', '=', $user->province_id); $query->where('province_id', '=', $user->province_id);
} }
@@ -36,8 +33,8 @@ class RequestPortalService
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time', 'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time',
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name' 'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name',
] ]
); );
} }
} }

View File

@@ -18,11 +18,9 @@ class TransportationUnitService
if ($user->hasPermissionTo('manage-transportation-unit-station')) { if ($user->hasPermissionTo('manage-transportation-unit-station')) {
$query->where('station_id', '=', $user->station_id); $query->where('station_id', '=', $user->station_id);
} } elseif ($user->hasPermissionTo('manage-transportation-unit-city')) {
elseif ($user->hasPermissionTo('manage-transportation-unit-city')) {
$query->where('city_id', '=', $user->city_id); $query->where('city_id', '=', $user->city_id);
} } elseif ($user->hasPermissionTo('manage-transportation-unit-province')) {
elseif ($user->hasPermissionTo('manage-transportation-unit-province')) {
$query->where('province_id', '=', $user->province_id); $query->where('province_id', '=', $user->province_id);
} }
@@ -35,8 +33,8 @@ class TransportationUnitService
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time', 'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time',
'code', 'category_id', 'category_name', 'explanation', 'km', 'city_id', 'city_name', 'province_id', 'station_name' 'code', 'category_id', 'category_name', 'explanation', 'km', 'city_id', 'city_name', 'province_id', 'station_name',
] ]
); );
} }
} }

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('mission_violations', function (Blueprint $table) {
$table->unsignedTinyInteger('province_id')->nullable();
$table->string('province_name')->nullable();
$table->unsignedSmallInteger('city_id')->nullable();
$table->string('city_name')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('mission_violations', function (Blueprint $table) {
$table->dropColumn(['province_id', 'province_name', 'city_id', 'city_name']);
});
}
};

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>گزارش کل کشور </title>
<style>
table,
th,
td {
border: 1px solid black;
}
</style>
</head>
<body dir="rtl" style="text-align: center;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش نخلف های صورت گرفته
</th>
</tr>
<tr>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
استان
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
کل تخلفات </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
اقدام شده
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
اقدام نشده
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
ثبت GPS</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
ثبت حراست
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
کیلومتر GPS
</th>
</tr>
</thead>
<tbody>
@foreach ($rows as $item)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['egdam_shode'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bedone_egdam'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_gps'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_herasat'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['mil_gps'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>گزارش ادارات شهرستان </title>
<style>
table,
th,
td {
border: 1px solid black;
}
</style>
</head>
<body dir="rtl" style="text-align: center;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش نخلف های صورت گرفته
</th>
</tr>
<tr>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
شهر
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
کل تخلفات</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
اقدام شده
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
اقدام نشده
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
ثبت GPS</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
ثبت حراست
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
مسافت ثبت شده GPS
</th>
</tr>
</thead>
<tbody>
@foreach ($rows as $item)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['egdam_shode'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bedone_egdam'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_gps'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_herasat'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['mil_gps'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>گزارش کل کشور </title>
<style>
table,
th,
td {
border: 1px solid black;
}
</style>
</head>
<body dir="rtl" style="text-align: center;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="11"
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
</th>
</tr>
<tr>
<th colspan="11"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="11"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش ماموریت های انجام شده
</th>
</tr>
<tr>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
استان
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
کل ماموریت </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
جمع ساعات GPS
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
جمع ساعات ماموریت </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
تردد خارج از محدوده
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
با فرآیند ساعتی
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
با فرآیند روزانه </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
بدون فرآیند ساعتی
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
بدون فرآیند روزانه
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
فعالیت روزانه </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
گشت راهداری
</th>
</tr>
</thead>
<tbody>
@foreach ($rows as $item)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_rozaneh'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['item'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['patrol'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>گزارش ادارات شهرستان </title>
<style>
table,
th,
td {
border: 1px solid black;
}
</style>
</head>
<body dir="rtl" style="text-align: center;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="11"
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
</th>
</tr>
<tr>
<th colspan="11"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="11"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش ماموریت های انجام شده
</th>
</tr>
<tr>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
شهر
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
کل ماموریت </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
جمع ساعات GPS
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
جمع ساعات ماموریت </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
تردد خارج از محدوده
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
با فرآیند ساعتی
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
با فرآیند روزانه </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
بدون فرآیند ساعتی
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
بدون فرآیند روزانه
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
فعالیت روزانه </th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
گشت راهداری
</th>
</tr>
</thead>
<tbody>
@foreach ($rows as $item)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_rozaneh'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['item'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['patrol'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -15,6 +15,8 @@ use App\Http\Controllers\V3\Dashboard\Harim\TechnicalDeputyController;
use App\Http\Controllers\V3\Dashboard\ItemsManagementController; use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController; use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController;
use App\Http\Controllers\V3\Dashboard\Mission\DetailController; use App\Http\Controllers\V3\Dashboard\Mission\DetailController;
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportTradodController;
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportViolationController;
use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController; use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController;
use App\Http\Controllers\V3\Dashboard\Mission\TransportationUnitController; use App\Http\Controllers\V3\Dashboard\Mission\TransportationUnitController;
use App\Http\Controllers\V3\Dashboard\Mission\ViolationManagementController; use App\Http\Controllers\V3\Dashboard\Mission\ViolationManagementController;
@@ -533,9 +535,9 @@ Route::prefix('missions')
Route::post('/{violation}', 'update')->name('update'); Route::post('/{violation}', 'update')->name('update');
Route::delete('/{violation}', 'destroy')->name('destroy'); Route::delete('/{violation}', 'destroy')->name('destroy');
}); });
Route::prefix('report') Route::prefix('report_violation')
->name('reports.') ->name('reportsViolation.')
->controller(\App\Http\Controllers\V3\Dashboard\Mission\ReportController::class) ->controller(ReportViolationController::class)
->group(function () { ->group(function () {
Route::get('/country_activity', 'countryActivity')->name('countryActivity') Route::get('/country_activity', 'countryActivity')->name('countryActivity')
->middleware('permission:mission-report-country'); ->middleware('permission:mission-report-country');
@@ -544,6 +546,17 @@ Route::prefix('missions')
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity'); Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity'); Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
}); });
Route::prefix('report_taradod')
->name('reportsTaradod.')
->controller(ReportTradodController::class)
->group(function () {
Route::get('/country_activity', 'countryActivity')->name('countryActivity')
->middleware('permission:mission-report-country');
Route::get('/province_activity', 'provinceActivity')->name('provinceActivity')
->middleware('permission:mission-report-province');
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
});
}); });
Route::prefix('harim') Route::prefix('harim')