diff --git a/app/Console/Commands/GetMachinesInfoListCommand.php b/app/Console/Commands/GetMachinesInfoListCommand.php index fc997c6a..4f01d45d 100644 --- a/app/Console/Commands/GetMachinesInfoListCommand.php +++ b/app/Console/Commands/GetMachinesInfoListCommand.php @@ -47,6 +47,7 @@ class GetMachinesInfoListCommand extends Command [ 'car_name' => $entry['CarName'] == [] ? null : $entry['CarName'], 'car_group' => $entry['CarGroup'] == [] ? null : $entry['CarGroup'], + 'car_type' => $entry['CarType'] == [] ? null : $entry['CarType'], 'machine_code' => $entry['MachineCode'], 'unit_name' => $entry['UnitName'], 'car_status' => $entry['Status'], diff --git a/app/Console/Commands/RoadObservationProblems.php b/app/Console/Commands/RoadObservationProblems.php index 69cbc074..85d792bc 100755 --- a/app/Console/Commands/RoadObservationProblems.php +++ b/app/Console/Commands/RoadObservationProblems.php @@ -79,7 +79,7 @@ class RoadObservationProblems extends Command $cities = []; foreach ($xml as $value) { // if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 6) { //// code ghabli - if (RoadObserved::where('fk_RegisteredEventMessage', $value->fk_RegisteredEventMessage)->exists()) { + if (RoadObserved::query()->where('fk_RegisteredEventMessage', '=', $value->fk_RegisteredEventMessage)->exists()) { continue; } @@ -133,7 +133,7 @@ class RoadObservationProblems extends Command 'city_id' => $cityModel->id, // 'handler_type' => EdarateShahri::class, 'edarate_shahri_id' => $cityModel->edarateShahri()->first()->id, - 'province_fa' => (isset($city['province_id']) ? Province::find($city['province_id'])->name_fa : null), + 'province_fa' => $cityModel->province()->first()->name_fa, 'city_fa' => $cityModel ? $cityModel->name_fa : null, ] ); @@ -142,8 +142,8 @@ class RoadObservationProblems extends Command } } else { - $this->info('the received body is empty'); - Log::channel('nikarayan')->error("the received body is empty" . date('Y-m-d H:i:s')); + $this->info($result); + Log::channel('nikarayan')->error("the received body is empty" . date('Y-m-d H:i:s') . '\t'. $result); return $result; } echo 'done at: ' . date("Y-m-d H:i:s") . "\n"; diff --git a/app/Enums/HarimAction.php b/app/Enums/HarimAction.php new file mode 100644 index 00000000..462d0e02 --- /dev/null +++ b/app/Enums/HarimAction.php @@ -0,0 +1,25 @@ + "بازخورد", + 2 => "بله", + 3 => "خیر", + 4 => "تائید کردن", + 5 => "ارجاع", + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/HarimStates.php b/app/Enums/HarimStates.php new file mode 100644 index 00000000..c97f94f6 --- /dev/null +++ b/app/Enums/HarimStates.php @@ -0,0 +1,46 @@ + "بررسی ادارات شهرستان", + 2 => "بررسی توسط ادارات حریم", + 3 => "بررسی توسط معاون ", + 4 => "بررسی توسط مدیر کل", + 5 => "بررسی فایل آپلود شده توسط اداره حریم", + 6 => "بررسی فایل آپلود شده توسط معاون", + 7 => "بررسی فایل آپلود شده توسط مدیر", + 8 => "ارسال ضمانت نامه توسط کاربر", + 9 => "ارسال به پنجره واحد ( نیاز به راه دسترسی)", + 10 => "امکان پذیر نمی باشد", + 11 => "ارسال به پنجره واحد (بدون نیاز به راه دسترسی)", + 12 => "بازبینی فایل بارگذاری شده", + 13 => "تائید عرصه و اعیان ارسال شده توسط اداره حریم", + 14 => "تائید عرصه و اعیان ارسال شده توسط معاون", + 15 => "تائید عرصه و اعیان ارسال شده توسط مدیر", + + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/MissionCategory.php b/app/Enums/MissionCategory.php new file mode 100644 index 00000000..fe36f026 --- /dev/null +++ b/app/Enums/MissionCategory.php @@ -0,0 +1,22 @@ + "فعالیت روزانه", + 2 => "گشت راهداری", + 3 => "واکنش سریع", + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/MissionTypes.php b/app/Enums/MissionTypes.php new file mode 100644 index 00000000..e19472cf --- /dev/null +++ b/app/Enums/MissionTypes.php @@ -0,0 +1,19 @@ + 'ساعتی', + 2 => 'روزانه', + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/MissionZones.php b/app/Enums/MissionZones.php new file mode 100644 index 00000000..d5e7b87f --- /dev/null +++ b/app/Enums/MissionZones.php @@ -0,0 +1,21 @@ + 'داخل شهر', + 2 => 'بیرون شهر (داخل محدوده)', + 3 => 'بیرون شهر (بیرون محدوده)', + ]; + + return $mapArray[$state]; + } +} \ No newline at end of file diff --git a/app/Enums/NikarayanComplaints.php b/app/Enums/NikarayanComplaints.php index d8bfecd5..5d810bed 100644 --- a/app/Enums/NikarayanComplaints.php +++ b/app/Enums/NikarayanComplaints.php @@ -2667,6 +2667,12 @@ enum NikarayanComplaints: int "ProvinceID" => "21", "InvarID" => 497 ], + 437 => [ + "OnvarID" => 437, + "CityName" => "آزادراه کاشان-قم", + "ProvinceID" => "4", + "InvarID" => 804 + ], ]; return $nikarayanToRmsCityId[$city_id]["InvarID"]; } diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php new file mode 100644 index 00000000..37517385 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php @@ -0,0 +1,83 @@ +data; + $existedProvinces = array_keys($data); + + foreach (Province::all() as $value) { + $provinceId = $value->id; + + if (!array_key_exists($provinceId, $existedProvinces)) { + $data[] = (object) [ + 'province_id' => $provinceId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + 'axis_data' => [ + 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], + 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], + 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], + 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], + 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], + ], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.Country.AccessRoadReport', [ + 'data' => $data, + ]); + } + + 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('Q1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php new file mode 100644 index 00000000..3e64d0c8 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php @@ -0,0 +1,84 @@ +data; + $existedProvinces = array_keys($data); + + foreach (Province::all() as $value) { + $provinceId = $value->id; + + if (!array_key_exists($provinceId, $existedProvinces)) { + $data[] = (object) [ + 'province_id' => $provinceId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + 'axis_data' => [ + 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], + 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], + 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], + 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], + 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], + ], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.Country.ConstructionReport', [ + 'data' => $data, + ]); + } + + 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('Q1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php new file mode 100644 index 00000000..e44b14ac --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php @@ -0,0 +1,84 @@ +data; + $existedProvinces = array_keys($data); + + foreach (Province::all() as $value) { + $provinceId = $value->id; + + if (!array_key_exists($provinceId, $existedProvinces)) { + $data[] = (object) [ + 'province_id' => $provinceId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + 'axis_data' => [ + 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], + 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], + 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], + 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], + 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], + ], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.Country.UtilityPassingReport', [ + 'data' => $data, + ]); + } + + 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('Q1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php new file mode 100644 index 00000000..bc80b3a4 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php @@ -0,0 +1,83 @@ +data; + $existedCities = array_keys($data); + $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + + foreach ($edarat as $value) { + $edareId = $value->id; + + if (!array_key_exists($edareId, $existedCities)) { + $data[] = (object) [ + 'edare_shahri_id' => $edareId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + 'axis_data' => [ + 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], + 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], + 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], + 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], + 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], + ], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.Province.AccessRoadReport', [ + 'data' => $data, + ]); + } + + 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('Q1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php new file mode 100644 index 00000000..e6492019 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php @@ -0,0 +1,83 @@ +data; + $existedCities = array_keys($data); + $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + + foreach ($edarat as $value) { + $edareId = $value->id; + + if (!array_key_exists($edareId, $existedCities)) { + $data[] = (object) [ + 'edare_shahri_id' => $edareId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + 'axis_data' => [ + 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], + 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], + 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], + 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], + 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], + ], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.Province.ConstructionReport', [ + 'data' => $data, + ]); + } + + 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('Q1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php new file mode 100644 index 00000000..d0f5f6a4 --- /dev/null +++ b/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php @@ -0,0 +1,83 @@ +data; + $existedCities = array_keys($data); + $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + + foreach ($edarat as $value) { + $edareId = $value->id; + + if (!array_key_exists($edareId, $existedCities)) { + $data[] = (object) [ + 'edare_shahri_id' => $edareId, + 'name_fa' => $value->name_fa, + 'sum' => 0, + 'axis_data' => [ + 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], + 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], + 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], + 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], + 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], + ], + ]; + } + } + + return view('v3.Reports.SafetyAndPrivacy.Province.UtilityPassingReport', [ + 'data' => $data, + ]); + } + + 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('Q1'); + return [$drawing, $drawing2]; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/V2/Dashboard/RoadObservationController.php b/app/Http/Controllers/V2/Dashboard/RoadObservationController.php index b86660f7..e1a829ae 100644 --- a/app/Http/Controllers/V2/Dashboard/RoadObservationController.php +++ b/app/Http/Controllers/V2/Dashboard/RoadObservationController.php @@ -570,7 +570,7 @@ class RoadObservationController extends Controller // } // $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl"; try { - $result = $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, $files); + $result = $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, $files_path); } catch (SoapFault $e) { $msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n" . 'rms: error in get road observation webservice babe!!!!' . "\n"; diff --git a/app/Http/Controllers/V3/CMMSMachinesController.php b/app/Http/Controllers/V3/CMMSMachinesController.php index e575d179..b25ca2a7 100644 --- a/app/Http/Controllers/V3/CMMSMachinesController.php +++ b/app/Http/Controllers/V3/CMMSMachinesController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\V3; +use App\Facades\DataTable\DataTableFacade; use App\Http\Controllers\Controller; use App\Http\Traits\ApiResponse; use App\Models\CMMSMachine; @@ -12,6 +13,17 @@ class CMMSMachinesController extends Controller { use ApiResponse; + public function index(Request $request): JsonResponse + { + return response()->json(DataTableFacade::run( + CMMSMachine::query(), + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name'] + )); + } + public function list(): JsonResponse { $machinesList = CMMSMachine::query()->get(['machine_code', 'id', 'plak_number', 'car_name']); diff --git a/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php b/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php new file mode 100644 index 00000000..04c1ad76 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Harim/GeneralManagerController.php @@ -0,0 +1,202 @@ +whereIn('state_id', [HarimStates::BARESI_TAVASOT_MODIR_KOL->value, HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL->value]) + ->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id); + + $data = DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'] + ); + return response()->json($data); + } + + public function rejectRequest(RejectRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::EMKAN_PAZIR_NEMEBASHAD->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function referRequest(ReferRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::REFER->value; + $harim->histories()->create([ + 'expert_id'=> auth()->user()->id, + 'previous-state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'export_description' => $request->export_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_MOAVEN->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function referFile(ReferFileRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::REFER->value; + $harim->histories()->create([ + 'expert_id'=> auth()->user()->id, + 'previous-state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'export_description' => $request->export_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function confirmRoadAccessNeed(ConfirmRoadAccessNeedRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::ERSAL_BE_PANJAREH_VAHED_NIAZ_BE_RAH_DASTRASI->value; + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function confirmNoRoadAccessNeed(ConfirmNoRoadAccessNeedRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::ERSAL_BE_PANJAREH_VAHED_BEDONEH_NIAZ_BE_RAH_DASTRASI->value; + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function confirmRoadAccessEditNeed(ConfirmRoadAccessEditNeedRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::UPDATE_FILE_BARGOZARE_SHODE->value; + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function confirmGuaranteeLetterNeed(ConfirmGuaranteeLetterNeedRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::ERSAL_ZEMANAT_NAME_TAVASOTE_KARBAR->value; + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + public function show(ShowRequest $request, Harim $harim): JsonResponse + { + return $this->successResponse($harim->load('histories')); + + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Harim/HarimOfficeController.php b/app/Http/Controllers/V3/Dashboard/Harim/HarimOfficeController.php new file mode 100644 index 00000000..30bdc2ff --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Harim/HarimOfficeController.php @@ -0,0 +1,171 @@ +whereIn('state_id', [ + HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value, + HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value, + ]) + ->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id); + + $data = DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + ); + + return response()->json($data); + } + + + public function rejectRequest(RejectRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::NO->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_MOAVEN->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + 'is_possible' => false, + ]); + }); + return $this->successResponse(); + } + + + public function needRoadAccess(NeedRoadAccessRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::YES->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_MOAVEN->value; + + $harim ->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + 'is_possible' => true, + 'need_road_access' => true, + ]); + }); + return $this->successResponse(); + } + + + public function withoutRoadAccess(WithoutRoadAccessRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::YES->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_MOAVEN->value; + + $harim ->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + 'is_possible' => true, + 'need_road_access' => false, + ]); + }); + return $this->successResponse(); + } + public function fileAccepted(FileAcceptedRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::YES->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value; + + $harim ->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + 'is_file_good' => true, + ]); + }); + return $this->successResponse(); + } + public function fileRejected(FileRejectedRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::NO->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value; + + $harim ->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + 'is_file_good' => false, + ]); + }); + return $this->successResponse(); + } + public function show(ShowRequest $request, Harim $harim): JsonResponse + { + return $this->successResponse($harim->load('histories')); + + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Harim/ProvinceOfficeController.php b/app/Http/Controllers/V3/Dashboard/Harim/ProvinceOfficeController.php new file mode 100644 index 00000000..0e178706 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Harim/ProvinceOfficeController.php @@ -0,0 +1,65 @@ +user(); + $query = Harim::query() + ->where('state_id', '=', HarimStates::BARESI_EDARE_SHAHRESTAN->value) + ->where('edareh_shahri_id', '=', $user->edarate_shahri_id); + + $data = DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + ); + return response()->json($data); + + } + public function feedback(FeedBackRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::FEEDBACK->value; + + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value; + + $harim ->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function show(ShowRequest $request, Harim $harim): JsonResponse + { + return $this->successResponse($harim); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Harim/TechnicalDeputyController.php b/app/Http/Controllers/V3/Dashboard/Harim/TechnicalDeputyController.php new file mode 100644 index 00000000..749a73ab --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/Harim/TechnicalDeputyController.php @@ -0,0 +1,138 @@ +whereIn('state_id', [ + HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value, + HarimStates::BARESI_TAVASOT_MOAVEN->value, + ]) + ->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id); + + $data = DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + ); + + return response()->json($data); + } + public function confirmRequest(ConfirmRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::CONFIRM->value; + + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_MODIR_KOL->value; + + $harim ->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + + } + public function referRequest(ReferRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request,$harim) { + $action = HarimAction::REFER->value; + + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + public function confirmRoadAccess(ConfirmRoadAccessRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::CONFIRM->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + + public function referRoadAccess(ReferRoadAccessRequest $request, Harim $harim): JsonResponse + { + DB::transaction(function () use ($request, $harim) { + $action = HarimAction::REFER->value; + $harim->histories()->create([ + 'expert_id' => auth()->user()->id, + 'previous_state_id' => $harim->state_id, + 'previous_state_name' => $harim->state_name, + 'expert_description' => $request->expert_description, + 'action_id' => $action, + 'action_name' => HarimAction::name($action), + ]); + + $state = HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value; + + $harim->update([ + 'state_id' => $state, + 'state_name' => HarimStates::name($state), + ]); + }); + return $this->successResponse(); + } + public function show(ShowRequest $request, Harim $harim): JsonResponse + { + return $this->successResponse($harim->load('histories')); + + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Mission/ControlUnitController.php b/app/Http/Controllers/V3/Dashboard/Mission/ControlUnitController.php index 4b71192b..5b44888a 100644 --- a/app/Http/Controllers/V3/Dashboard/Mission/ControlUnitController.php +++ b/app/Http/Controllers/V3/Dashboard/Mission/ControlUnitController.php @@ -2,15 +2,62 @@ namespace App\Http\Controllers\V3\Dashboard\Mission; +use App\Enums\MissionStates; use App\Http\Controllers\Controller; +use App\Http\Requests\V3\Mission\ControlUnit\FinishRequest; +use App\Http\Requests\V3\Mission\ControlUnit\StartRequest; +use App\Http\Traits\ApiResponse; +use App\Models\Mission; use App\Services\Cartables\Mission\ControlUnitService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; class ControlUnitController extends Controller { + use ApiResponse; public function index(Request $request, ControlUnitService $controlUnitService): JsonResponse { return response()->json($controlUnitService->datatable($request)); } + + public function start(StartRequest $request, Mission $mission): JsonResponse + { + DB::transaction(function () use ($request, $mission) { + $mission->histories()->create([ + 'user_id' => auth()->user()->id, + 'previous_state_id' => $mission->state_id, + 'previous_state_name' => $mission->state_name, + ]); + + $state = MissionStates::START_MISSION->value; + $mission->update([ + 'state_id' => $state, + 'state_name' => MissionStates::name($state), + 'start_time' => now() + ]); + }); + + return $this->successResponse(); + } + + public function finish(FinishRequest $request, Mission $mission): JsonResponse + { + DB::transaction(function () use ($request, $mission) { + $mission->histories()->create([ + 'user_id' => auth()->user()->id, + 'previous_state_id' => $mission->state_id, + 'previous_state_name' => $mission->state_name, + ]); + + $state = MissionStates::END_MISSION->value; + $mission->update([ + 'state_id' => $state, + 'state_name' => MissionStates::name($state), + 'finish_time' => now() + ]); + }); + + return $this->successResponse(); + } } diff --git a/app/Http/Controllers/V3/Dashboard/Mission/DetailController.php b/app/Http/Controllers/V3/Dashboard/Mission/DetailController.php index 55ba3c14..2c5a5946 100644 --- a/app/Http/Controllers/V3/Dashboard/Mission/DetailController.php +++ b/app/Http/Controllers/V3/Dashboard/Mission/DetailController.php @@ -19,6 +19,17 @@ class DetailController extends Controller public function rahdaran(Mission $mission): JsonResponse { - return $this->successResponse($mission->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); + $rahdaran = $mission->rahdaran() + ->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code']) + ->map(function ($rahdar) { + return [ + 'id' => $rahdar->id, + 'name' => $rahdar->name, + 'code' => $rahdar->code, + 'is_driver' => (bool) $rahdar->pivot->is_driver, + ]; + }); + + return $this->successResponse($rahdaran); } } diff --git a/app/Http/Controllers/V3/Dashboard/Mission/RequestPortalController.php b/app/Http/Controllers/V3/Dashboard/Mission/RequestPortalController.php index f8a1fcef..8e5385da 100644 --- a/app/Http/Controllers/V3/Dashboard/Mission/RequestPortalController.php +++ b/app/Http/Controllers/V3/Dashboard/Mission/RequestPortalController.php @@ -2,12 +2,17 @@ namespace App\Http\Controllers\V3\Dashboard\Mission; +use App\Enums\MissionCategory; use App\Enums\MissionStates; +use App\Enums\MissionTypes; +use App\Enums\MissionZones; use App\Http\Controllers\Controller; +use App\Http\Controllers\V3\Dashboard\RoadPatrol\OperatorController; use App\Http\Requests\V3\Mission\RequestPortal\StoreRequest; use App\Http\Requests\V3\Mission\RequestPortal\UpdateRequest; use App\Http\Traits\ApiResponse; use App\Models\Mission; +use App\Models\RoadObserved; use App\Services\Cartables\Mission\RequestPortalService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -27,25 +32,46 @@ class RequestPortalController extends Controller DB::transaction(function () use ($request) { $user = auth()->user(); $state = MissionStates::REQUEST_CREATED->value; + $mission = Mission::query()->create([ 'user_id' => $user->id, 'username' => $user->username, 'province_id' => $user->province_id, 'province_name' => $user->province_fa, - 'edare_shahri_id' => $user->edare_shahri_id ?? null, - 'edare_shahri_name' => $user->edare_shahri_name ?? null, + 'edare_shahri_id' => $user->edarate_shahri_id ?? null, + 'edare_shahri_name' => $user->edarate_shahri_name ?? null, 'state_id' => $state, 'state_name' => MissionStates::name($state), 'requested_machines' => json_encode($request->requested_machines), 'type' => $request->type, + 'type_fa' => MissionTypes::name($request->type), + 'zone' => $request->zone, + 'zone_fa' => MissionZones::name($request->zone), 'start_date' => $request->start_date, 'end_date' => $request->end_date, 'request_date' => now(), 'description' => $request->description, 'end_point' => $request->end_point, + 'area' => json_encode($request->area), + 'category_id' => $request->category_id, + 'category_name' => MissionCategory::name($request->category_id), + 'explanation' => $request->explanation, + 'code' => rand(100000, 999999), ]); - $mission->rahdaran()->attach($request->rahdaran); + $mission->rahdaran()->sync($request->rahdaran); + + if ($request->category_id == 2) { + $rpc = new OperatorController(); + $rpc->store($mission); + } + + if ($request->category_id == 3){ + RoadObserved::query() + ->find($request->road_observed_id) + ->missions() + ->attach($mission->id); + } }); return $this->successResponse(); @@ -56,28 +82,40 @@ class RequestPortalController extends Controller return $this->successResponse($mission); } - public function update(UpdateRequest $request,Mission $mission): JsonResponse + public function update(UpdateRequest $request, Mission $mission): JsonResponse { DB::transaction(function () use ($mission, $request) { $state = MissionStates::REQUEST_CREATED->value; $mission->update([ - 'state_id' =>$state, - 'state_name' => MissionStates::name($state), - 'requested_machines' => json_encode($request->requested_machines), - 'type' => $request->type, - 'start_date' => $request->start_date, - 'end_date' => $request->end_date, - 'request_date' => $request->request_date, - 'description' => $request->description, - 'end_point' => $request->end_point, + 'state_id' => $state, + 'state_name' => MissionStates::name($state), + 'requested_machines' => json_encode($request->requested_machines), + 'type' => $request->type, + 'type_fa' => MissionTypes::name($request->type), + 'zone' => $request->zone, + 'zone_fa' => MissionZones::name($request->zone), + 'start_date' => $request->start_date, + 'end_date' => $request->end_date, + 'request_date' => $request->request_date, + 'description' => $request->description, + 'end_point' => $request->end_point, + 'area' => json_encode($request->area), + 'category_id' => $request->category_id, + 'category_name' => MissionCategory::name($request->category_id), + 'explanation' => $request->explanation, ]); $mission->rahdaran()->sync($request->rahdaran); + if ($request->category_id == 3){ + RoadObserved::query() + ->find($request->road_observed_id) + ->missions() + ->sync($mission->id); + } }); return $this->successResponse(); } - public function destroy(Mission $mission): JsonResponse { DB::transaction(function () use ($mission) { diff --git a/app/Http/Controllers/V3/Dashboard/Mission/TransportationUnitController.php b/app/Http/Controllers/V3/Dashboard/Mission/TransportationUnitController.php index 4e14cae4..e15cdccc 100644 --- a/app/Http/Controllers/V3/Dashboard/Mission/TransportationUnitController.php +++ b/app/Http/Controllers/V3/Dashboard/Mission/TransportationUnitController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\V3\Mission\TransportaionUnit\AllocateRequest; use App\Http\Requests\V3\Mission\TransportaionUnit\DeallocateRequest; use App\Http\Traits\ApiResponse; +use App\Models\CMMSMachine; use App\Models\Mission; use App\Services\Cartables\Mission\TransportationUnitService; use Illuminate\Http\JsonResponse; @@ -26,6 +27,7 @@ class TransportationUnitController extends Controller { DB::transaction(function () use ($request, $mission) { $mission->machines()->attach($request->machines); + $mission->rahdaran()->attach($request->driver, ['is_driver'=>true]); $mission->histories()->create([ 'user_id' => auth()->user()->id, @@ -35,8 +37,8 @@ class TransportationUnitController extends Controller $state = MissionStates::PENDING_CONFIRMATION->value; $mission->update([ - 'state_id' => $state, - 'state_name' => MissionStates::name($state), + 'state_id' => $state, + 'state_name' => MissionStates::name($state), ]); }); @@ -65,8 +67,12 @@ class TransportationUnitController extends Controller return $this->successResponse(); } - public function rahdaran(Mission $mission): JsonResponse + public function machinesList(Mission $mission): JsonResponse { - return $this->successResponse($mission->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); + return $this->successResponse( + CMMSMachine::query() + ->where('car_type', '=', $mission->car_type) + ->get(['machine_code', 'id', 'plak_number', 'car_name']) + ); } } diff --git a/app/Http/Controllers/V3/Dashboard/ObservedItemController.php b/app/Http/Controllers/V3/Dashboard/ObservedItemController.php index 5018fb5f..b261a049 100644 --- a/app/Http/Controllers/V3/Dashboard/ObservedItemController.php +++ b/app/Http/Controllers/V3/Dashboard/ObservedItemController.php @@ -4,10 +4,14 @@ namespace App\Http\Controllers\V3\Dashboard; use App\Facades\DataTable\DataTableFacade; use App\Http\Controllers\Controller; +use App\Http\Requests\V3\ObservedItem\StoreRequest; use App\Http\Traits\ApiResponse; +use App\Models\InfoItem; use App\Models\ObservedItem; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; +use Illuminate\Validation\ValidationException; class ObservedItemController extends Controller { @@ -37,4 +41,58 @@ class ObservedItemController extends Controller return response()->json($dataTable); } + + /** + * @throws ValidationException + */ + public function store(StoreRequest $request): jsonResponse + { + foreach ($request->observed_items as $index => $item) { + $info_item = InfoItem::query()->where('item', $item['item_id']) + ->where('sub_item', $item['sub_item_id']) + ->firstOrFail(); + + $start = explode(',', $item['start_point']); + $priority = [ + 1 => 'عادی', + 2 => 'فوری', + 3 => 'آنی', + ]; + + $data = [ + 'road_patrol_id' => $request->road_patrol_id, + 'item_id' => $info_item->item, + 'item_name' => $info_item->item_str, + 'sub_item_id' => $info_item->sub_item, + 'sub_item_name' => $info_item->sub_item_str, + 'description' => $item['description'] ?? null, + 'start_lat' => $start[0], + 'start_lon' => $start[1], + 'priority' => $item['instant_action'] == 0 ? $item['priority'] : null, + 'priority_fa' => $item['instant_action'] ? $priority[$item['priority']] : null, + ]; + + if ($item['instant_action'] == 1) { + $item_end_coordinates = null; + + if ($info_item->needs_end_point) { + if (!isset($item['end_point'])) { + throw ValidationException::withMessages([ + "observed_items.$index.end_point" => __('validation.required', ['attribute' => 'end_point']), + ]); + } + + $item_end_coordinates = explode(',', $item['end_point']); + + $data['end_lat'] = $item_end_coordinates[0]; + $data['end_lon'] = $item_end_coordinates[1]; + } + } + DB::transaction(function () use ($data) { + ObservedItem::query()->create($data); + }); + } + + return $this->successResponse(); + } } diff --git a/app/Http/Controllers/V3/Dashboard/RoadItem/DetailController.php b/app/Http/Controllers/V3/Dashboard/RoadItem/DetailController.php new file mode 100644 index 00000000..dc6d3efd --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadItem/DetailController.php @@ -0,0 +1,29 @@ +successResponse($roadItemsProject->cmmsMachines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number'])); + } + + public function rahdaran(RoadItemsProject $roadItemsProject): JsonResponse + { + return $this->successResponse($roadItemsProject->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); + } + + public function files(RoadItemsProject $roadItemsProject): JsonResponse + { + return $this->successResponse($roadItemsProject->files()->get(['path'])); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/RoadItem/OperatorController.php b/app/Http/Controllers/V3/Dashboard/RoadItem/OperatorController.php new file mode 100644 index 00000000..c422e120 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadItem/OperatorController.php @@ -0,0 +1,222 @@ +dataTable($request); + return response()->json($data); + } + + public function excel(Request $request, OperatorService $operatorService): BinaryFileResponse + { + $name = 'گزارش از کارتابل عملیات فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $operatorService->dataTable($request, true); + return Excel::download(new OperatorCartableReport($data['data']), $name); + } + + /** + * Store a newly created resource in storage. + * @throws Throwable + */ + public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse + { + + $info_item = InfoItem::query()->where('item', $request->item_id) + ->where('sub_item', $request->sub_item_id) + ->firstOrFail(); + + if ($info_item->needs_end_point && !$request->end_point) { + throw ValidationException::withMessages([ + 'end_point' => __('validation.required', ['attribute' => 'end_point']), + ]); + } + + if ((!$request->before_image || !$request->after_image) && $info_item->needs_image) { + throw ValidationException::withMessages([ + 'before_image' => __('validation.required', ['attribute' => 'before_image']), + 'after_image' => __('validation.required', ['attribute' => 'after_image']), + ]); + } + + $start_coordinates = explode(',', $request->start_point); + $end_coordinates = $info_item->needs_end_point ? explode(',', $request->end_point) : null; + + DB::transaction(function () use ($request, $nominatimService, $start_coordinates, $end_coordinates, $info_item) { + $user = auth()->user(); + $road_item = RoadItemsProject::query()->create([ + 'user_id' => $user->id, + 'start_lat' => $start_coordinates[0], + 'start_lng' => $start_coordinates[1], + 'end_lat' => $end_coordinates ? $end_coordinates[0] : null, + 'end_lng' => $end_coordinates ? $end_coordinates[1] : null, + 'item' => $info_item->item, + 'item_fa' => $info_item->item_str, + 'sub_item' => $info_item->sub_item, + 'sub_item_fa' => $info_item->sub_item_str, + 'sub_item_data' => $request->amount, + 'province_id' => $user->province_id, + 'province_fa' => $user->province_fa, + 'city_id' => $user->city_id, + 'city_fa' => $user->city_fa, + 'user_name' => $user->name, + 'start_way_id' => $nominatimService->get_way_id_from_nominatim($start_coordinates[0], $start_coordinates[1]), + 'end_way_id' => $end_coordinates ? $nominatimService->get_way_id_from_nominatim($end_coordinates[0], $end_coordinates[1]) : null, + 'unit_fa' => $info_item->sub_item_unit, + 'created_at_fa' => verta(\Carbon\Carbon::now())->format('Y-m-d H:i:s'), + 'info_id' => $info_item->id, + 'status' => 0, + 'status_fa' => 'در حال بررسی', + 'edarat_id' => $user->edarate_shahri_id, + 'edarat_type' => EdarateShahri::class, + 'edarat_name' => $user->edarate_shahri_name, + 'activity_date' => $request->activity_date, + 'activity_time' => $request->activity_time, + 'activity_date_time' => $request->activity_date." ".$request->activity_time, + 'is_new' => 1, + ]); + + if ($request->has('after_image')) { + $road_item->files()->create([ + 'path' => FileFacade::save($request->file('after_image'), + "/road_items_projects_new/{$road_item->id}/after") + ]); + } + if ($request->has('before_image')) { + $road_item->files()->create([ + 'path' => FileFacade::save($request->file('before_image'), + "/road_items_projects_new/{$road_item->id}/before") + ]); + } + + throw_if(ObservedItem::query()->where('id', $request->observed_item_id)->whereNotNull('road_item_id')->exists(), + new ProhibitedAction('اقدام مربوطه قبلا رسیدگی شده است.') + ); + + $road_item->rahdaran()->attach($request->rahdaran_id); + $road_item->cmmsMachines()->attach($request->machines_id); + $road_item->missions()->attach($request->mission_id); + + $user->addActivityComplete(1154); + }); + + return $this->successResponse(); + } + + /** + * Display the specified resource. + */ + public function show(RoadItemsProject $roadItemsProject): JsonResponse + { + return $this->successResponse($roadItemsProject); + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateRequest $request, RoadItemsProject $roadItemsProject): JsonResponse + { + $info_item = InfoItem::query()->where('item', $roadItemsProject->item) + ->where('sub_item', $roadItemsProject->sub_item) + ->firstOrFail(); + + $start_coordinates = explode(',', $request->start_point); + $end_coordinates = null; + + if ($info_item->needs_end_point) { + if (!$request->end_point) { + throw ValidationException::withMessages([ + 'end_point' => __('validation.required', ['attribute' => 'end_point']), + ]); + } + + $end_coordinates = explode(',', $request->end_point); + } + + if ($info_item->needs_image) { + if ($request->has('after_image')) { + FileFacade::delete($roadItemsProject->files[0]->path, true); + $roadItemsProject->files[0]->update([ + 'path' => FileFacade::save($request->file('after_image'), + "/road_items_projects_new/{$roadItemsProject->id}/after") + ]); + } + if ($request->has('before_image')) { + FileFacade::delete($roadItemsProject->files[1]->path, true); + $roadItemsProject->files[1]->update([ + 'path' => FileFacade::save($request->file('before_image'), + "/road_items_projects_new/{$roadItemsProject->id}/before") + ]); + } + } + + DB::transaction(function () use ($roadItemsProject, $start_coordinates, $end_coordinates, $request) { + $roadItemsProject->update([ + 'start_lat' => $start_coordinates[0], + 'start_lng' => $start_coordinates[1], + 'end_lat' => $end_coordinates ? $end_coordinates[0] : null, + 'end_lng' => $end_coordinates ? $end_coordinates[1] : null, + 'sub_item_data' => $request->amount, + 'status' => 0, + 'status_fa' => 'در حال بررسی', + ]); + + $roadItemsProject->rahdaran()->sync($request->rahdaran_id); + $roadItemsProject->cmmsMachines()->sync($request->machines_id); + $roadItemsProject->missions()->sync($request->mission_id); + + + auth()->user()->addActivityComplete(1155); + }); + + return $this->successResponse(); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(RoadItemsProject $roadItemsProject): JsonResponse + { + DB::transaction(function () use ($roadItemsProject) { + if ($roadItemsProject->files()->exists()) { + FileFacade::deleteDirectory("/road_items_projects_new/{$roadItemsProject->id}"); + $roadItemsProject->files()->delete(); + } + auth()->user()->addActivityComplete(1151); + + $roadItemsProject->delete(); + }); + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php b/app/Http/Controllers/V3/Dashboard/RoadItem/ReportController.php similarity index 82% rename from app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php rename to app/Http/Controllers/V3/Dashboard/RoadItem/ReportController.php index 46b47699..448ec873 100644 --- a/app/Http/Controllers/V3/Dashboard/Reports/RoadItemsReportController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadItem/ReportController.php @@ -1,6 +1,6 @@ countryActivityPerSubItem($request); + $activities = $reportService->countryActivityPerSubItem($request); $provinces = Province::all(['id', 'name_fa']); $subItems = InfoItem::query() ->where('item', $request->item) @@ -47,9 +48,9 @@ class RoadItemsReportController extends Controller ]); } - public function provinceActivityPerSubItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse + public function provinceActivityPerSubItem(Request $request, ReportService $reportService): JsonResponse { - $activities = $roadItemTableService->provinceActivityPerSubItem($request); + $activities = $reportService->provinceActivityPerSubItem($request); $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); @@ -64,13 +65,13 @@ class RoadItemsReportController extends Controller ]); } - public function countryActivityPerItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse + public function countryActivityPerItem(Request $request, ReportService $reportService): JsonResponse { if (auth()->check()) { auth()->user()->addActivityComplete(1033); } - $activities = $roadItemTableService->countryActivityPerItem($request); + $activities = $reportService->countryActivityPerItem($request); $provinces = Province::all(['id', 'name_fa']); return $this->successResponse([ @@ -79,9 +80,9 @@ class RoadItemsReportController extends Controller ]); } - public function provinceActivityPerItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse + public function provinceActivityPerItem(Request $request, ReportService $reportService): JsonResponse { - $activities = $roadItemTableService->provinceActivityPerItem($request); + $activities = $reportService->provinceActivityPerItem($request); $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); return $this->successResponse([ @@ -90,11 +91,11 @@ class RoadItemsReportController extends Controller ]); } - public function countryActivityExcelPerItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse + public function countryActivityExcelPerItem(Request $request, ReportService $reportService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); $name = 'گزارش کشوری از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - $activities = $roadItemTableService->countryActivityPerItem($request); + $activities = $reportService->countryActivityPerItem($request); return Excel::download(new CountryActivityPerItemReport([ 'activities' => $activities, 'provinces' => Province::all(['id', 'name_fa']), @@ -102,11 +103,11 @@ class RoadItemsReportController extends Controller ]), $name); } - public function provinceActivityExcelPerItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse + public function provinceActivityExcelPerItem(Request $request, ReportService $reportService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); $name = 'گزارش استانی از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - $activities = $roadItemTableService->provinceActivityPerItem($request); + $activities = $reportService->provinceActivityPerItem($request); return Excel::download(new ProvinceActivityPerItemReport([ 'activities' => $activities, 'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']), @@ -114,11 +115,11 @@ class RoadItemsReportController extends Controller ]), $name); } - public function countryActivityExcelPerSubItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse + public function countryActivityExcelPerSubItem(Request $request, ReportService $reportService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); $name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - $activities = $roadItemTableService->countryActivityPerSubItem($request); + $activities = $reportService->countryActivityPerSubItem($request); $subItems = InfoItem::query() ->where('item', $request->item) ->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']); @@ -130,10 +131,10 @@ class RoadItemsReportController extends Controller ]), $name); } - public function provinceActivityExcelPerSubItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse + public function provinceActivityExcelPerSubItem(Request $request, ReportService $reportService): BinaryFileResponse { auth()->user()->addActivityComplete(1034); - $activities = $roadItemTableService->provinceActivityPerSubItem($request); + $activities = $reportService->provinceActivityPerSubItem($request); $name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx'; $subItems = InfoItem::query() ->where('item', $request->item) diff --git a/app/Http/Controllers/V3/Dashboard/RoadItem/SupervisorController.php b/app/Http/Controllers/V3/Dashboard/RoadItem/SupervisorController.php new file mode 100644 index 00000000..42cdb28c --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadItem/SupervisorController.php @@ -0,0 +1,117 @@ +dataTable($request); + + foreach ($data['data'] as $road_item) { + if (Gate::allows('gate-supervise-road-item', $road_item)) { + $road_item['can_supervise'] = 1; + } else { + $road_item['can_supervise'] = 0; + } + } + + return response()->json($data); + } + + /** + * @throws Throwable + */ + public function excel(Request $request, SupervisorService $supervisorService): BinaryFileResponse + { + $name = 'گزارش از کارتابل ارزیابی فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $supervisorService->dataTable($request, true); + return Excel::download(new SupervisorCartableReport($data['data']), $name); + } + + public function confirm(ConfirmRequest $request, RoadItemsProject $roadItemsProject): JsonResponse + { + $user = auth()->user(); + + DB::transaction(function () use ($request, $roadItemsProject, $user) { + $roadItemsProject->update([ + 'status' => 1, + 'status_fa' => 'تایید شده', + 'supervisor_id' => $user->id, + 'supervisor_name' => $user->name, + 'supervisor_description' => $request->description, + 'supervising_time' => now(), + ]); + + $user->addActivityComplete(1149); + }); + + return $this->successResponse(); + } + + public function reject(RejectRequest $request, RoadItemsProject $roadItemsProject): JsonResponse + { + $user = auth()->user(); + + DB::transaction(function () use ($request, $roadItemsProject, $user) { + $roadItemsProject->update([ + 'status' => 2, + 'status_fa' => 'عدم تایید', + 'supervisor_id' => $user->id, + 'supervisor_name' => $user->name, + 'supervisor_description' => $request->description, + 'supervising_time' => now(), + ]); + + $user->addActivityComplete(1149); + }); + + return $this->successResponse(); + } + + /** + * @throws Throwable + */ + public function restore(RoadItemsProject $roadItemsProject): JsonResponse + { + + throw_if($roadItemsProject->status == 0, new ProhibitedAction('امکان بازگردانی وضعیت این فعالیت وجود ندارد!')); + + DB::transaction(function () use ($roadItemsProject) { + $roadItemsProject->update([ + 'status' => 0, + 'status_fa' => 'در حال بررسی', + 'supervisor_id' => null, + 'supervisor_description' => null, + 'supervising_time' => null, + 'supervisor_name' => null, + ]); + auth()->user()->addActivityComplete(1150); + }); + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php b/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php deleted file mode 100644 index bcb9e6fb..00000000 --- a/app/Http/Controllers/V3/Dashboard/RoadItemsProjectController.php +++ /dev/null @@ -1,288 +0,0 @@ -supervisorCartableReport($request); - - foreach ($data['data'] as $road_item) { - if (Gate::allows('gate-supervise-road-item', $road_item)) { - $road_item['can_supervise'] = 1; - } else { - $road_item['can_supervise'] = 0; - } - } - - return response()->json($data); - } - - public function verifyBySupervisor(VerifyBySupervisorRequest $request, RoadItemsProject $roadItemsProject): JsonResponse - { - $status_fa = $request->verify == 1 ? 'تایید شده' : 'عدم تایید'; - $user = auth()->user(); - - $roadItemsProject->update([ - 'status' => $request->verify, - 'status_fa' => $status_fa, - 'supervisor_id' => $user->id, - 'supervisor_name' => $user->name, - 'supervisor_description' => $request->description, - 'supervising_time' => now(), - ]); - - $user->addActivityComplete(1149); - - return $this->successResponse(); - } - - public function restore(RoadItemsProject $roadItemsProject): JsonResponse - { - if ($roadItemsProject->status == 0) { - return $this->errorResponse('امکان بازگردانی وضعیت این فعالیت وجود ندارد!'); - } - - $roadItemsProject->update([ - 'status' => 0, - 'status_fa' => 'در حال بررسی', - 'supervisor_id' => null, - 'supervisor_description' => null, - 'supervising_time' => null, - 'supervisor_name' => null, - ]); - auth()->user()->addActivityComplete(1150); - - return $this->successResponse(); - } - - public function delete(RoadItemsProject $roadItemsProject): JsonResponse - { - if ($roadItemsProject->files()->exists()) { - Storage::delete('public/'. $roadItemsProject->files[0]->path); - Storage::delete('public/'. $roadItemsProject->files[1]->path); - $roadItemsProject->files()->delete(); - } - auth()->user()->addActivityComplete(1151); - - $roadItemsProject->delete(); - - return $this->successResponse(); - } - - - public function supervisorCartableReport(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse - { - $name = 'گزارش از کارتابل ارزیابی فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadItemTableService->supervisorCartableReport($request, true); - return Excel::download(new SupervisorCartableReport($data['data']), $name); - } - - public function operatorIndex(Request $request, RoadItemTableService $roadItemTableService): JsonResponse - { - $data = $roadItemTableService->operatorCartableReport($request); - return response()->json($data); - } - - /** - * Store a newly created resource in storage. - * @throws ValidationException - */ - public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse - { - $user = auth()->user(); - - if ($user->edarate_ostani_id || is_null($user->city_id)) { - return $this->errorResponse('امکان ثبت فعالیت برای ادارات استانی و ستادی وجود ندارد!'); - } - - if (is_null($user->edarate_shahri_id)) { - return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!'); - } - - $info_item = InfoItem::query()->where('item', $request->item_id) - ->where('sub_item', $request->sub_item_id) - ->firstOrFail(); - - if ($info_item->needs_end_point && !$request->end_point) { - throw ValidationException::withMessages([ - 'end_point' => __('validation.required', ['attribute' => 'end_point']), - ]); - } - - if ((!$request->before_image || !$request->after_image) && $info_item->needs_image) { - throw ValidationException::withMessages([ - 'before_image' => __('validation.required', ['attribute' => 'before_image']), - 'after_image' => __('validation.required', ['attribute' => 'after_image']), - ]); - } - - $start_coordinates = explode(',', $request->start_point); - $end_coordinates = $info_item->needs_end_point ? explode(',', $request->end_point) : null; - - $attributes = [ - 'start_lat' => $start_coordinates[0], - 'start_lng' => $start_coordinates[1], - 'end_lat' => $end_coordinates ? $end_coordinates[0] : null, - 'end_lng' => $end_coordinates ? $end_coordinates[1] : null, - 'item' => $info_item->item, - 'item_fa' => $info_item->item_str, - 'sub_item' => $info_item->sub_item, - 'sub_item_fa' => $info_item->sub_item_str, - 'sub_item_data' => $request->amount, - 'province_id' => $user->province_id, - 'province_fa' => $user->province_fa, - 'city_id' => $user->city_id, - 'city_fa' => $user->city_fa, - 'user_name' => $user->name, - 'start_way_id' => $nominatimService->get_way_id_from_nominatim($start_coordinates[0], $start_coordinates[1]), - 'end_way_id' => $end_coordinates ? $nominatimService->get_way_id_from_nominatim($end_coordinates[0], $end_coordinates[1]) : null, - 'unit_fa' => $info_item->sub_item_unit, - 'created_at_fa' => verta(\Carbon\Carbon::now())->format('Y-m-d H:i:s'), - 'info_id' => $info_item->id, - 'status' => 0, - 'status_fa' => 'در حال بررسی', - 'edarat_id' => $user->edarate_shahri_id, - 'edarat_type' => EdarateShahri::class, - 'edarat_name' => $user->edarate_shahri_name, - 'activity_date' => $request->activity_date, - 'activity_time' => $request->activity_time, - ]; - - $after_image = ($request->has('after_image') && $info_item->needs_image) ? - $request->file('after_image') : - null; - - $before_image = ($request->has('before_image') && $info_item->needs_image) ? - $request->file('before_image') : - null; - - $road_item = RoadItemsProject::store($user, $attributes, $before_image, $after_image, $request->observed_item_id); - - if ($road_item === -1) { - return $this->errorResponse('اقدام مربوطه قبلا رسیدگی شده است.'); - } - - $road_item->rahdaran()->attach($request->rahdaran_id); - $road_item->cmmsMachines()->attach($request->machines_id); - - auth()->user()->addActivityComplete(1154); - - return $this->successResponse(); - } - - /** - * Update the specified resource in storage. - * @throws ValidationException - */ - public function update(UpdateRequest $request, RoadItemsProject $roadItemsProject): JsonResponse - { - $info_item = InfoItem::query()->where('item', $roadItemsProject->item) - ->where('sub_item', $roadItemsProject->sub_item) - ->firstOrFail(); - - $start_coordinates = explode(',', $request->start_point); - $end_coordinates = null; - - if ($info_item->needs_end_point) { - if (!$request->end_point) { - throw ValidationException::withMessages([ - 'end_point' => __('validation.required', ['attribute' => 'end_point']), - ]); - } - - $end_coordinates = explode(',', $request->end_point); - } - - if ($info_item->needs_image) { - if ($request->has('after_image')) { - - Storage::delete('public/'. $roadItemsProject->files[0]->path); - - $after = $request->file('after_image')->store('road_items_projects_new/after', 'public'); - $roadItemsProject->files[0]->update([ - 'path' => $after - ]); - // $roadItemsProject->files()->create(['path' => $after]); - $urlAfter = "/var/www/rms/public/storage/{$after}"; - // \App\Helpers\Compress::resize($urlAfter); - } - if ($request->has('before_image')) { - Storage::delete('public/'. $roadItemsProject->files[1]->path); - - $before = $request->file('before_image')->store('/road_items_projects_new/before', 'public'); - $roadItemsProject->files[1]->update([ - 'path' => $before - ]); - // $roadItemsProject->files()->create(['path' => $before]); - $urlBefore = "/var/www/rms/public/storage/{$before}"; - // \App\Helpers\Compress::resize($urlBefore); - } - } - - $roadItemsProject->update([ - 'start_lat' => $start_coordinates[0], - 'start_lng' => $start_coordinates[1], - 'end_lat' => $end_coordinates ? $end_coordinates[0] : null, - 'end_lng' => $end_coordinates ? $end_coordinates[1] : null, - 'sub_item_data' => $request->amount, - 'status' => 0, - 'status_fa' => 'در حال بررسی', - ]); - - $roadItemsProject->rahdaran()->sync($request->rahdaran_id); - $roadItemsProject->cmmsMachines()->sync($request->machines_id); - - - auth()->user()->addActivityComplete(1155); - - return $this->successResponse(); - } - - public function operatorCartableReport(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse - { - $name = 'گزارش از کارتابل عملیات فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadItemTableService->operatorCartableReport($request, true); - return Excel::download(new OperatorCartableReport($data['data']), $name); - } - - public function roadItemMachine(RoadItemsProject $roadItemsProject): JsonResponse - { - return $this->successResponse($roadItemsProject->cmmsMachines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number'])); - } - - public function roadItemRahdar(RoadItemsProject $roadItemsProject): JsonResponse - { - return $this->successResponse($roadItemsProject->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); - } - - public function roadItemFile(RoadItemsProject $roadItemsProject): JsonResponse - { - return $this->successResponse($roadItemsProject->files()->get(['path'])); - } -} diff --git a/app/Http/Controllers/V3/Dashboard/RoadObservation/OperatorController.php b/app/Http/Controllers/V3/Dashboard/RoadObservation/OperatorController.php index bd3033ee..33f5c8c3 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadObservation/OperatorController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadObservation/OperatorController.php @@ -82,10 +82,9 @@ class OperatorController 'new_files' => json_encode([]) ]; + $files_path = []; if ($request->rms_status == 1) { - $files_path = []; - $roadObserved->files()->where('path', 'like', '%_image_before%')->delete(); $roadObserved->files()->where('path', 'like', '%_image_after%')->delete(); @@ -95,7 +94,6 @@ class OperatorController $files_path[0]['path'] = $image_before; $files_path[1]['path'] = $image_after; - $files = json_encode($files_path); $now_date_time = Carbon::now(); $roadObservedData['image_after'] = $image_after; @@ -104,16 +102,16 @@ class OperatorController $roadObservedData['updated_at_fa'] = Verta::instance($now_date_time); $roadObservedData['rms_last_activity_fa'] = Verta::instance($now_date_time); $roadObservedData['rms_last_activity'] = $now_date_time; - $roadObservedHistoryData['new_files'] = $files; + $roadObservedHistoryData['new_files'] = json_encode($files_path); } - DB::transaction(function () use ($roadObserved, $roadObservedHistoryData, $roadObservedData, $request, $nikarayanService) { + DB::transaction(function () use ($roadObserved, $roadObservedHistoryData, $roadObservedData, $request, $nikarayanService, $files_path) { $roadObserved->problemHistories()->create($roadObservedHistoryData); $roadObserved->update($roadObservedData); auth()->user()->addActivityComplete(1142); - $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files'])); + $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, $files_path); }); return $this->successResponse(); diff --git a/app/Http/Controllers/V3/Dashboard/RoadPatrol/DetailController.php b/app/Http/Controllers/V3/Dashboard/RoadPatrol/DetailController.php new file mode 100644 index 00000000..e3b6ac5a --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadPatrol/DetailController.php @@ -0,0 +1,69 @@ +province_id; + $edare_shahri = $request->edare_shahri_id; + $status = $request->status; + $rms_status = $request->rms_status; + + if ($request->from_date && $request->date_to) { + $date_from = $request->from_date.' 00:00:00'; + $date_to = $request->date_to.' 23:59:59'; + } else { + $date_from = Date('Y-m-d'); + $date_to = new \DateTime('tomorrow'); + $date_to = $date_to->format('Y-m-d'); + } + + $projects = RoadObserved::query()->select(['id', 'lng', 'lat','status']) + ->whereBetween('created_at', [$date_from, $date_to]) + ->when($province, function ($query) use ($province) { + return $query->where('province_id', '=', $province); + }) + ->when($rms_status, function ($query) use ($rms_status) { + if ($rms_status == 2) { + return $query->where('rms_status', '<>', 0); + } else { + return $query->where('rms_status', '=', 0); + } + }) + ->when($edare_shahri, function ($query) use ($edare_shahri) { + return $query->where('edarate_shahri_id', '=', $edare_shahri); + }) + ->when($status, function ($query) use ($status) { + return $query->where('status', '=', $status); + }) + ->get(); + return $this->successResponse($projects); + } + + public function show(RoadPatrol $roadPatrol): JsonResponse + { + return $this->successResponse($roadPatrol); + } + + public function machines(RoadPatrol $roadPatrol): JsonResponse + { + return $this->successResponse($roadPatrol->cmmsMachines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number'])); + } + + public function rahdaran(RoadPatrol $roadPatrol): JsonResponse + { + return $this->successResponse($roadPatrol->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/RoadPatrol/OperatorController.php b/app/Http/Controllers/V3/Dashboard/RoadPatrol/OperatorController.php new file mode 100644 index 00000000..4b6e3ee2 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadPatrol/OperatorController.php @@ -0,0 +1,86 @@ +dataTable($request); + return response()->json($data); + } + public function excel(Request $request, OperatorService $operatorService): BinaryFileResponse + { + $name = 'گزارش از کارتابل عملیات گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $operatorService->dataTable($request, true); + return Excel::download(new OperatorCartableReport($data['data']), $name); + } + + public function store(Mission $mission): JsonResponse + { + $road_patrol = RoadPatrol::query()->create([ + 'status' => 0, + 'status_fa' => 'در حال بررسی', + ]); + + $road_patrol->missions()->attach($mission->id); + + auth()->user()->addActivityComplete(1147); + + return $this->successResponse(); + } + + public function delete(DeleteRequest $request, RoadPatrol $roadPatrol): JsonResponse + { + if ($request->type == 1) { + DB::transaction(function () use ($roadPatrol) { + $roadPatrol->observedItems()->delete(); + $roadPatrol->delete(); + }); + } else { + DB::transaction(function () use ($roadPatrol) { + if ($roadPatrol->observedItems) { + foreach ($roadPatrol->observedItems as $index => $observed_item) { + if ($observed_item->roadItemProject) { + $road_item = $observed_item->roadItemProject; + + if ($road_item->files()->exists()) { + Storage::delete('public/' . $road_item->files[0]->path); + Storage::delete('public/' . $road_item->files[1]->path); + $road_item->files()->delete(); + } + + $road_item->delete(); + } + + $observed_item->delete(); + } + } + auth()->user()->addActivityComplete(1144); + + $roadPatrol->delete(); + }); + } + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php b/app/Http/Controllers/V3/Dashboard/RoadPatrol/ReportController.php similarity index 57% rename from app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php rename to app/Http/Controllers/V3/Dashboard/RoadPatrol/ReportController.php index d4382427..a4fd027f 100644 --- a/app/Http/Controllers/V3/Dashboard/Reports/RoadPatrolReportController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadPatrol/ReportController.php @@ -1,6 +1,6 @@ countryActivity($request); - - $provinces = Province::all(['id', 'name_fa']); - - return $this->successResponse([ - 'activities' => $activities['data'], - 'provinces' => $provinces - ]); - } - - public function provincePatrolActivity(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse - { - $request->validate(["province_id" => "required",]); - - $activities = $roadPatrolTableService->provinceActivity($request); - - $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); - - return $this->successResponse([ - 'activities' => $activities['data'], - 'edarateShahri' => $edarateShahri, - ]); - } - - public function countryActivityExcel(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse - { - $activities = $roadPatrolTableService->countryActivity($request); - $provinces = Province::all(['id', 'name_fa']); - - $name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - - return Excel::download(new CountryActivity([ - 'activities' => $activities, - 'provinces' => $provinces, - ]), $name); - } - - public function provinceActivityExcel(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse - { - $activities = $roadPatrolTableService->provinceActivity($request); - $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); - - $name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; - - return Excel::download(new ProvinceActivity([ - 'activities' => $activities, - 'edarateShahri' => $edarateShahri, - ]), $name); - } - public function activitiesOnMap(Request $request): JsonResponse { $date_from = $request->from_date ? $request->from_date .' 00:00:00' : now()->startOfDay()->toDateTimeString(); @@ -92,4 +39,86 @@ class RoadPatrolReportController extends Controller { return $this->successResponse($roadPatrol->load(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); } + + public function getReport(RoadPatrol $roadPatrol): JsonResponse + { + $data = [ + 'serial_no' => $roadPatrol->id, + 'province_fa' => $roadPatrol->province_fa, + 'edare_name' => $roadPatrol->edare_name, + 'start_time' => $roadPatrol->start_time, + 'end_time' => $roadPatrol->end_time, + 'officer_name' => $roadPatrol->officer_name, + 'officer_plaque' => $roadPatrol->officer_plaque, + 'officer_phone_number' => $roadPatrol->officer_phone_number, + 'created_at' => $roadPatrol->created_at + ]; + + $observed_items = array(); + if($roadPatrol->observedItems) { + foreach ($roadPatrol->observedItems as $index => $observed_item) { + $observed_items[] = [ + 'item' => $observed_item->item_name, + 'sub_item' => $observed_item->sub_item_name, + 'local_name' => $observed_item->local_name, + 'description' => $observed_item->description, + 'priority_fa' => $observed_item->priority_fa, + ]; + } + } + + $data['observed_items'] = $observed_items; + return $this->successResponse($data); + } + public function countryPatrolActivity(Request $request, ReportService $reportService): JsonResponse + { + $activities = $reportService->countryActivity($request); + + $provinces = Province::all(['id', 'name_fa']); + + return $this->successResponse([ + 'activities' => $activities['data'], + 'provinces' => $provinces + ]); + } + + public function provincePatrolActivity(Request $request, ReportService $reportService): JsonResponse + { + $request->validate(["province_id" => "required",]); + + $activities = $reportService->provinceActivity($request); + + $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); + + return $this->successResponse([ + 'activities' => $activities['data'], + 'edarateShahri' => $edarateShahri, + ]); + } + + public function countryActivityExcel(Request $request, ReportService $reportService): BinaryFileResponse + { + $activities = $reportService->countryActivity($request); + $provinces = Province::all(['id', 'name_fa']); + + $name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + + return Excel::download(new CountryActivity([ + 'activities' => $activities, + 'provinces' => $provinces, + ]), $name); + } + + public function provinceActivityExcel(Request $request, ReportService $reportService): BinaryFileResponse + { + $activities = $reportService->provinceActivity($request); + $edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']); + + $name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + + return Excel::download(new ProvinceActivity([ + 'activities' => $activities, + 'edarateShahri' => $edarateShahri, + ]), $name); + } } diff --git a/app/Http/Controllers/V3/Dashboard/RoadPatrol/SupervisorController.php b/app/Http/Controllers/V3/Dashboard/RoadPatrol/SupervisorController.php new file mode 100644 index 00000000..6b5a9a91 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/RoadPatrol/SupervisorController.php @@ -0,0 +1,47 @@ +dataTable($request); + + foreach ($data['data'] as $road_patrol) { + if (Gate::allows('gate-supervise-road-item', $road_patrol)) { + $road_patrol['can_supervise'] = 1; + } else { + $road_patrol['can_supervise'] = 0; + } + } + + return response()->json($data); + } + + /** + * @throws Throwable + */ + public function excel(Request $request, SupervisorService $supervisorService): BinaryFileResponse + { + $name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; + $data = $supervisorService->dataTable($request, true); + return Excel::download(new SupervisorCartableReport($data['data']), $name); + } +} diff --git a/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php b/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php deleted file mode 100644 index 98550c02..00000000 --- a/app/Http/Controllers/V3/Dashboard/RoadPatrolProjectController.php +++ /dev/null @@ -1,341 +0,0 @@ -supervisorCartableReport($request); - - foreach ($data['data'] as $road_patrol) { - if (Gate::allows('gate-supervise-road-item', $road_patrol)) { - $road_patrol['can_supervise'] = 1; - } else { - $road_patrol['can_supervise'] = 0; - } - } - - return response()->json($data); - } - - public function delete(DeleteRequest $request, RoadPatrol $roadPatrol): JsonResponse - { - if ($request->type == 1) { - DB::transaction(function () use ($roadPatrol) { - $roadPatrol->observedItems()->delete(); - $roadPatrol->delete(); - }); - } else { - DB::transaction(function () use ($roadPatrol) { - if ($roadPatrol->observedItems) { - foreach ($roadPatrol->observedItems as $index => $observed_item) { - if ($observed_item->roadItemProject) { - $road_item = $observed_item->roadItemProject; - - if ($road_item->files()->exists()) { - Storage::delete('public/'. $road_item->files[0]->path); - Storage::delete('public/'. $road_item->files[1]->path); - $road_item->files()->delete(); - } - - $road_item->delete(); - } - - $observed_item->delete(); - } - } - auth()->user()->addActivityComplete(1144); - - $roadPatrol->delete(); - }); - } - - return $this->successResponse(); - } - - public function supervisorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse - { - $name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadPatrolTableService->supervisorCartableReport($request, true); - return Excel::download(new SupervisorCartableReport($data['data']), $name); - } - - public function operatorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse - { - $data = $roadPatrolTableService->operatorCartableReport($request); - return response()->json($data); - } - - public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse - { - $user = auth()->user(); - - if ($user->edarate_ostani_id || is_null($user->city_id)) { - return $this->errorResponse('امکان ثبت فعالیت برای ادارات استانی وجود ندارد!'); - } - - if (is_null($user->edarate_shahri_id)) { - return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!'); - } - - $edare_id = $user->edarate_shahri_id ?? $user->edarate_ostani_id; - $edare_name = $user->edarate_shahri_id ? $user->edarate_shahri_name : $user->edarate_ostani_name; - - $road_patrol = DB::transaction(function () use ($request, $edare_id, - $edare_name, $nominatimService, $user) { - - $road_patrol = RoadPatrol::query()->create([ - 'operator_id' => $user->id, - 'operator_name' => $user->name, - 'province_id' => $user->province_id, - 'province_fa' => $user->province_fa, - 'city_id' => $user->city_id, - 'city_fa' => $user->city_fa, - 'edare_id' => $edare_id, - 'edare_name' => $edare_name, - 'status' => 0, - 'status_fa' => 'در حال بررسی', - 'distance' => $request->distance, - 'start_time' => $request->start_time, - 'end_time' => $request->end_time, - 'description' => $request->description ?? null, - 'fuel_consumption' => $request->fuel_consumption, - 'vehicle_runtime' => $request->vehicle_runtime, - 'stop_points' => json_encode($request->stop_points), - ]); - - $road_patrol->rahdaran()->attach($request->road_patrol_rahdaran_id); - $road_patrol->cmmsMachines()->attach($request->road_patrol_machines_id); - - if ($request->observed_items) { - foreach ($request->observed_items as $index => $item) { - $info_item = InfoItem::where('item', $item['item_id']) - ->where('sub_item', $item['sub_item_id']) - ->firstOrFail(); - - $item_start_coordinates = explode(',', $item['start_point']); - - $observed_item = $road_patrol->observedItems()->create([ - 'item_id' => $info_item->item, - 'item_name' => $info_item->item_str, - 'sub_item_id' => $info_item->sub_item, - 'sub_item_name' => $info_item->sub_item_str, - 'local_name' => $item['local_name'], - 'description' => $item['description'] ?? null, - 'start_lat' => $item_start_coordinates[0], - 'start_lon' => $item_start_coordinates[1], - ]); - - $item_end_coordinates = null; - if ($item['instant_action'] == 0) { - $priority = [ - 1 => 'عادی', - 2 => 'فوری', - 3 => 'آنی', - ]; - $observed_item->priority = $item['priority']; - $observed_item->priority_fa = $priority[$item['priority']]; - $observed_item->save(); - } elseif ($item['instant_action'] == 1) { - if ($info_item->needs_end_point) { - if (!isset($item['end_point'])) { - throw ValidationException::withMessages([ - "observed_items.$index.end_point" => __('validation.required', ['attribute' => 'end_point']), - ]); - } - - $item_end_coordinates = explode(',', $item['end_point']); - } - - $before_image = null; - $after_image = null; - if ($info_item->needs_image) { - if (!isset($item['before_image'])) { - throw ValidationException::withMessages([ - "observed_items.$index.before_image" => __('validation.required', ['attribute' => 'before_image']), - ]); - } - if (!isset($item['after_image'])) { - throw ValidationException::withMessages([ - "observed_items.$index.after_image" => __('validation.required', ['attribute' => 'after_image']), - ]); - } - - $before_image = $item['before_image']; - $after_image = $item['after_image']; - } - - $start_time = Carbon::createFromFormat('Y-m-d H:i', $request->start_time); - $end_time = Carbon::createFromFormat('Y-m-d H:i', $request->end_time); - $activity_date = $start_time->average($end_time); - - $attributes = [ - 'start_lat' => $item_start_coordinates[0], - 'start_lng' => $item_start_coordinates[1], - 'end_lat' => $item_end_coordinates ? $item_end_coordinates[0] : null, - 'end_lng' => $item_end_coordinates ? $item_end_coordinates[1] : null, - 'item' => $info_item->item, - 'item_fa' => $info_item->item_str, - 'sub_item' => $info_item->sub_item, - 'sub_item_fa' => $info_item->sub_item_str, - 'sub_item_data' => $item['amount'], - 'province_id' => $user->province_id, - 'province_fa' => $user->province_fa, - 'city_id' => $user->city_id, - 'city_fa' => $user->city_fa, - 'user_name' => $user->name, - 'start_way_id' => $nominatimService->get_way_id_from_nominatim($item_start_coordinates[0], $item_start_coordinates[1]), - 'end_way_id' => $item_end_coordinates ? $nominatimService->get_way_id_from_nominatim($item_end_coordinates[0], $item_end_coordinates[1]) : null, - 'unit_fa' => $info_item->sub_item_unit, - 'created_at_fa' => verta(Carbon::now())->format('Y-m-d H:i:s'), - 'info_id' => $info_item->id, - 'status' => 0, - 'status_fa' => 'در حال بررسی', - 'edarat_id' => $user->edarate_shahri_id, - 'edarat_type' => EdarateShahri::class, - 'edarat_name' => $user->edarate_shahri_name, - 'activity_date' => $activity_date->format('Y-m-d'), - 'activity_time' => $activity_date->format('H:i:s'), - ]; - - $road_item = RoadItemsProject::store($user, $attributes, $before_image, $after_image, $observed_item->id); - - if ($road_item === -1) { - return $this->errorResponse('اقدام مربوطه قبلا رسیدگی شده است.'); - } - - $road_item->rahdaran()->attach($item['road_item_rahdaran_id']); - $road_item->cmmsMachines()->attach($item['road_item_machines_id']); - } - } - } - - auth()->user()->addActivityComplete(1147); - - Sms::sendSms($request->officer_phone_number, - "گشت راهداری با کد یکتای $road_patrol->id در تاریخ ".verta(\Carbon\Carbon::now())->format('Y-m-d H:i:s')." با شماره شما در سامانه RMS ثبت شد. \n لینک دریافت گزارش : \n https://rms.rmto.ir/v2/road_patrols/operator/report/$road_patrol->id" - ); - return $road_patrol; - }); - - return $this->successResponse(); - } - - public function getReport(RoadPatrol $roadPatrol): JsonResponse - { - $data = [ - 'serial_no' => $roadPatrol->id, - 'province_fa' => $roadPatrol->province_fa, - 'edare_name' => $roadPatrol->edare_name, - 'start_time' => $roadPatrol->start_time, - 'end_time' => $roadPatrol->end_time, - 'officer_name' => $roadPatrol->officer_name, - 'officer_plaque' => $roadPatrol->officer_plaque, - 'officer_phone_number' => $roadPatrol->officer_phone_number, - 'created_at' => $roadPatrol->created_at - ]; - - $observed_items = array(); - if($roadPatrol->observedItems) { - foreach ($roadPatrol->observedItems as $index => $observed_item) { - $observed_items[] = [ - 'item' => $observed_item->item_name, - 'sub_item' => $observed_item->sub_item_name, - 'local_name' => $observed_item->local_name, - 'description' => $observed_item->description, - 'priority_fa' => $observed_item->priority_fa, - ]; - } - } - - $data['observed_items'] = $observed_items; - return $this->successResponse($data); - } - - public function map(Request $request): JsonResponse - { - $province = $request->province_id; - $edare_shahri = $request->edare_shahri_id; - $status = $request->status; - $rms_status = $request->rms_status; - - if ($request->from_date && $request->date_to) { - $date_from = $request->from_date.' 00:00:00'; - $date_to = $request->date_to.' 23:59:59'; - } else { - $date_from = Date('Y-m-d'); - $date_to = new \DateTime('tomorrow'); - $date_to = $date_to->format('Y-m-d'); - } - - $projects = RoadObserved::query()->select(['id', 'lng', 'lat','status']) - ->whereBetween('created_at', [$date_from, $date_to]) - ->when($province, function ($query) use ($province) { - return $query->where('province_id', '=', $province); - }) - ->when($rms_status, function ($query) use ($rms_status) { - if ($rms_status == 2) { - return $query->where('rms_status', '<>', 0); - } else { - return $query->where('rms_status', '=', 0); - } - }) - ->when($edare_shahri, function ($query) use ($edare_shahri) { - return $query->where('edarate_shahri_id', '=', $edare_shahri); - }) - ->when($status, function ($query) use ($status) { - return $query->where('status', '=', $status); - }) - ->get(); - return $this->successResponse($projects); - } - - public function show(RoadPatrol $roadPatrol): JsonResponse - { - return $this->successResponse($roadPatrol); - } - - public function operatorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse - { - $name = 'گزارش از کارتابل عملیات گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx'; - $data = $roadPatrolTableService->operatorCartableReport($request, true); - return Excel::download(new OperatorCartableReport($data['data']), $name); - } - - public function roadPatrolMachine(RoadPatrol $roadPatrol): JsonResponse - { - return $this->successResponse($roadPatrol->cmmsMachines()->get(['cmms_machines.id', 'cmms_machines.machine_code', 'cmms_machines.car_name', 'cmms_machines.plak_number'])); - } - - public function roadPatrolRahdar(RoadPatrol $roadPatrol): JsonResponse - { - return $this->successResponse($roadPatrol->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code'])); - } -} diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php index 995233c1..cf03a4ae 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php @@ -87,6 +87,9 @@ class OperatorController extends Controller $safety_and_privacy->recognize_picture = $request->has('recognize_picture') ? FileFacade::save($request->recognize_picture, "safety_and_privacy/{$safety_and_privacy->id}") : null; + $safety_and_privacy->recognize_picture_second = $request->has('recognize_picture_second') ? + FileFacade::save($request->recognize_picture_second, "safety_and_privacy/{$safety_and_privacy->id}") : + null; $safety_and_privacy->save(); $user->addActivityComplete(1134); @@ -142,7 +145,9 @@ class OperatorController extends Controller 'step_fa' => SafetyAndPrivacySteps::name($step), 'status' => $status_id, 'status_fa' => SafetyAndPrivacyStatus::name($status_id), - 'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"), + 'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"), + 'finish_picture' => FileFacade::save($request->finish_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/finish_picture"), + 'evidence_picture' => FileFacade::save($request->evidence_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/evidence_picture"), 'action_picture_document_upload_date' => now(), 'action_date' => $request->action_date, 'is_finished' => true, diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReportController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/AccessRoadActivityController.php similarity index 56% rename from app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReportController.php rename to app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/AccessRoadActivityController.php index 0e3c5e78..f3e4a9cc 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReportController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/AccessRoadActivityController.php @@ -1,53 +1,57 @@ merge(['info_id' => 90]); + $data = $operatorService->countryActivity($request); + return $this->successResponse([ 'activities' => $data, - 'provinces' => Province::all(['id', 'name_fa']) + 'provinces' => Province::all(['id', 'name_fa']), ]); } public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse { + $request->merge(['info_id' => 90]); + $data = $operatorService->provinceActivity($request); + return $this->successResponse([ 'activities' => $data, - 'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']), + 'edarateShahri' => EdarateShahri::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 CountryActivityReport($data), $name); + $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 ProvinceActivityReport($data, $request), $name); + $name = 'گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; + return Excel::download(new AccessRoadReport($data, $request), $name); } + } diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php new file mode 100644 index 00000000..54dbad4b --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php @@ -0,0 +1,57 @@ +merge(['info_id' => 89]); + + $data = $operatorService->countryActivity($request); + + return $this->successResponse([ + 'activities' => $data, + 'provinces' => Province::all(['id', 'name_fa']), + ]); + } + public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse + { + $request->merge(['info_id' => 89]); + + $data = $operatorService->provinceActivity($request); + + return $this->successResponse([ + 'activities' => $data, + 'edarateShahri' => EdarateShahri::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 ConstructionReport($data, $request), $name); + } + + +} diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/UtilityPassingActivityController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/UtilityPassingActivityController.php new file mode 100644 index 00000000..dd61ed53 --- /dev/null +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/UtilityPassingActivityController.php @@ -0,0 +1,54 @@ +merge(['info_id' => 91]); + + $data = $operatorService->countryActivity($request); + + return $this->successResponse([ + 'activities' => $data, + 'provinces' => Province::all(['id', 'name_fa']), + ]); + } + public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse + { + $request->merge(['info_id' => 91]); + + $data = $operatorService->provinceActivity($request); + + return $this->successResponse([ + 'activities' => $data, + 'edarateShahri' => EdarateShahri::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 UtilityPassingReport($data, $request), $name); + } + +} diff --git a/app/Http/Controllers/V3/NotificationController.php b/app/Http/Controllers/V3/NotificationController.php index 293a79b3..b05f9f72 100644 --- a/app/Http/Controllers/V3/NotificationController.php +++ b/app/Http/Controllers/V3/NotificationController.php @@ -2,10 +2,12 @@ namespace App\Http\Controllers\V3; +use App\Enums\MissionStates; use App\Exceptions\ProhibitedAction; use App\Http\Controllers\Controller; use App\Http\Traits\ApiResponse; use App\Models\EdarateOstani; +use App\Models\Mission; use App\Models\RoadItemsProject; use App\Models\RoadObserved; use App\Models\SafetyAndPrivacy; @@ -28,6 +30,7 @@ class NotificationController extends Controller 'roadItem' => $this->roadItemNotifications(), 'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(), 'roadObserved' => $this->roadObservedNotifications(), + 'mission' => $this->missionNotification(), ]); } @@ -185,4 +188,35 @@ class NotificationController extends Controller return $road_observations; } + + public function missionNotification(): array + { + $user = auth()->user(); + $missions = [ + 'request_portal' => Mission::query() + ->where([ + ['state_id', '=', MissionStates::REJECT_BY_TRANSPORTATION->value], + ['user_id', '=', $user->id] + ])->count(), + 'transportation' => 0, + 'control' => 0, + ]; + + if ($user->hasPermissionTo('manage-transportation-unit')) { + $missions['transportation'] = Mission::query()->where([ + ['state_id', '=', MissionStates::REQUEST_CREATED->value], + ['edare_shahri_id', '=', $user->edarate_shahri_id] + ])->count(); + } + if ($user->hasPermissionTo('manage-control-unit')) { + $missions['control'] = Mission::query()->where([ + ['state_id', '=', MissionStates::PENDING_CONFIRMATION->value], + ['edare_shahri_id', '=', $user->edarate_shahri_id] + ])->count(); + } + + $missions['total'] = $missions['request_portal'] + $missions['transportation'] + $missions['control']; + + return $missions; + } } diff --git a/app/Http/Controllers/V3/ProfileController.php b/app/Http/Controllers/V3/ProfileController.php index 008ec6e7..b4b0fa70 100644 --- a/app/Http/Controllers/V3/ProfileController.php +++ b/app/Http/Controllers/V3/ProfileController.php @@ -22,6 +22,7 @@ class ProfileController extends Controller $user = Auth::user(); return $this->successResponse([ + 'id' => $user->id, 'username' => $user->username, 'first_name' => $user->first_name, 'last_name' => $user->last_name, diff --git a/app/Http/Controllers/V3/RahdaranController.php b/app/Http/Controllers/V3/RahdaranController.php index 5f7b7227..e287ff84 100644 --- a/app/Http/Controllers/V3/RahdaranController.php +++ b/app/Http/Controllers/V3/RahdaranController.php @@ -2,7 +2,10 @@ namespace App\Http\Controllers\V3; +use App\Facades\DataTable\DataTableFacade; use App\Http\Controllers\Controller; +use App\Http\Requests\V3\Rahdaran\StoreRequest; +use App\Http\Requests\V3\Rahdaran\UpdateRequest; use App\Http\Traits\ApiResponse; use App\Models\Rahdaran; use Illuminate\Http\JsonResponse; @@ -12,17 +15,55 @@ class RahdaranController extends Controller { use ApiResponse; + public function index(Request $request): JsonResponse + { + return response()->json(DataTableFacade::run( + Rahdaran::query(), + $request, + allowedFilters: ['*'], + allowedSortings: ['*']) + ); + } + + public function store(StoreRequest $request): JsonResponse + { + Rahdaran::query()->create([ + 'name' =>$request->name, + 'code' =>$request->code, + ]); + return $this->successResponse(); + } + + public function show(Rahdaran $rahdaran): JsonResponse + { + return $this->successResponse($rahdaran); + } + + public function update(UpdateRequest $request, Rahdaran $rahdaran): JsonResponse + { + $rahdaran->update([ + 'name' =>$request->name, + 'code' =>$request->code, + ]); + return $this->successResponse(); + } + + public function destroy(Rahdaran $rahdaran): JsonResponse + { + $rahdaran->delete(); + return $this->successResponse(); + } + public function list(): JsonResponse { - $rahdaranList = Rahdaran::query()->get(); - - return $this->successResponse($rahdaranList); + return $this->successResponse(Rahdaran::all()); } public function search(Request $request): JsonResponse { $matchedSearchedRahdaran = Rahdaran::query() - ->where('code', 'LIKE', "%{$request->code}%") + ->where('code', 'LIKE', "%{$request->search}%") + ->orWhere('name', 'LIKE', "%{$request->search}%") ->get(); return $this->successResponse($matchedSearchedRahdaran); diff --git a/app/Http/Controllers/V3/WebServices/RoadItemController.php b/app/Http/Controllers/V3/WebServices/RoadItemController.php new file mode 100644 index 00000000..e395f4dd --- /dev/null +++ b/app/Http/Controllers/V3/WebServices/RoadItemController.php @@ -0,0 +1,25 @@ +from_date; + $toDate = $request->to_date; + $roadItems = RoadItemsProject::query() + ->where('is_new', '=', 1) + ->whereBetween('activity_date_time', [$fromDate, $toDate]) + ->get(); + + return $this->successResponse($roadItems); + } +} diff --git a/app/Http/Controllers/V3/WebServices/RoadMaintenanceStationController.php b/app/Http/Controllers/V3/WebServices/RoadMaintenanceStationController.php new file mode 100644 index 00000000..a16294c8 --- /dev/null +++ b/app/Http/Controllers/V3/WebServices/RoadMaintenanceStationController.php @@ -0,0 +1,33 @@ +province; + $status = $request->status; + $type = $request->type; + + $data = RahdariPoint::query() + ->when($status, fn ($query, $status) => $query->where('status', $status)) + ->when($type, fn ($query, $type) => $query->where('type', $type)) + ->when($province, fn($query, $province) => $query->where('province_id', $province)) + ->get([ + 'id', 'province_name', 'city_name', 'name', 'status', 'type_fa', 'phone', + 'code', 'lat', 'lng', + ]); + + return $this->successResponse($data); + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/Deputy/ConfirmRequest.php b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ConfirmRequest.php new file mode 100644 index 00000000..f754eb14 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ConfirmRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MOAVEN->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/Deputy/ConfirmRoadAccessRequest.php b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ConfirmRoadAccessRequest.php new file mode 100644 index 00000000..525e72fd --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ConfirmRoadAccessRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRequest.php b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRequest.php new file mode 100644 index 00000000..335de432 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MOAVEN->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRoadAccessRequest.php b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRoadAccessRequest.php new file mode 100644 index 00000000..3cd3e81c --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRoadAccessRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/Deputy/ShowRequest.php b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ShowRequest.php new file mode 100644 index 00000000..0264699f --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/Deputy/ShowRequest.php @@ -0,0 +1,33 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + in_array($this->harim->state_id, [ + HarimStates::BARESI_TAVASOT_MOAVEN->value, + HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value, + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmGuaranteeLetterNeedRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmGuaranteeLetterNeedRequest.php new file mode 100644 index 00000000..6c943ebe --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmGuaranteeLetterNeedRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmNoRoadAccessNeedRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmNoRoadAccessNeedRequest.php new file mode 100644 index 00000000..94a60116 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmNoRoadAccessNeedRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmRoadAccessEditNeedRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmRoadAccessEditNeedRequest.php new file mode 100644 index 00000000..5d4649f5 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmRoadAccessEditNeedRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmRoadAccessNeedRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmRoadAccessNeedRequest.php new file mode 100644 index 00000000..9176609a --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ConfirmRoadAccessNeedRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ReferFileRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ReferFileRequest.php new file mode 100644 index 00000000..ea8ab9ed --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ReferFileRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ReferRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ReferRequest.php new file mode 100644 index 00000000..931578ee --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ReferRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/RejectRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/RejectRequest.php new file mode 100644 index 00000000..1d90ab5d --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/RejectRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_MODIR_KOL->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ShowRequest.php b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ShowRequest.php new file mode 100644 index 00000000..47e8bdce --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/GeneralManager/ShowRequest.php @@ -0,0 +1,33 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + in_array($this->harim->state_id, [ + HarimStates::BARESI_TAVASOT_MODIR_KOL->value, + HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL->value + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/FileAcceptedRequest.php b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/FileAcceptedRequest.php new file mode 100644 index 00000000..018d7de9 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/FileAcceptedRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/FileRejectedRequest.php b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/FileRejectedRequest.php new file mode 100644 index 00000000..5a95a458 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/FileRejectedRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/NeedRoadAccessRequest.php b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/NeedRoadAccessRequest.php new file mode 100644 index 00000000..6e83e4ad --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/NeedRoadAccessRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/RejectRequest.php b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/RejectRequest.php new file mode 100644 index 00000000..b072d879 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/RejectRequest.php @@ -0,0 +1,31 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value; + } + + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/ShowRequest.php b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/ShowRequest.php new file mode 100644 index 00000000..71977382 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/ShowRequest.php @@ -0,0 +1,34 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + in_array($this->harim->state_id, [ + HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value, + HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value, + ]); + } + + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/WithoutRoadAccessRequest.php b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/WithoutRoadAccessRequest.php new file mode 100644 index 00000000..44c64bfa --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/HarimOffice/WithoutRoadAccessRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/ProvinceOffice/FeedBackRequest.php b/app/Http/Requests/V3/Dashboard/Harim/ProvinceOffice/FeedBackRequest.php new file mode 100644 index 00000000..3c0b229b --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/ProvinceOffice/FeedBackRequest.php @@ -0,0 +1,30 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_EDARE_SHAHRESTAN->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'expert_description' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Dashboard/Harim/ProvinceOffice/ShowRequest.php b/app/Http/Requests/V3/Dashboard/Harim/ProvinceOffice/ShowRequest.php new file mode 100644 index 00000000..59739c40 --- /dev/null +++ b/app/Http/Requests/V3/Dashboard/Harim/ProvinceOffice/ShowRequest.php @@ -0,0 +1,31 @@ +harim->edareh_shahri_id == auth()->user()->edarate_shahri_id && + $this->harim->state_id == HarimStates::BARESI_EDARE_SHAHRESTAN->value; + } + + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php b/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php new file mode 100644 index 00000000..c6b48b09 --- /dev/null +++ b/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php @@ -0,0 +1,30 @@ +mission->state_id == MissionStates::START_MISSION->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/V3/Mission/ControlUnit/StartRequest.php b/app/Http/Requests/V3/Mission/ControlUnit/StartRequest.php new file mode 100644 index 00000000..59b7f5e1 --- /dev/null +++ b/app/Http/Requests/V3/Mission/ControlUnit/StartRequest.php @@ -0,0 +1,45 @@ +mission->state_id == MissionStates::PENDING_CONFIRMATION->value; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'code' => 'required|string', + ]; + } + + public function after(): array + { + return [ + function (Validator $validator) { + if ($this->mission->code != $this->code){ + $validator->errors()->add( + 'code', + 'کد وارد شده صحیح نمی باشد' + ); + } + } + ]; + } +} diff --git a/app/Http/Requests/V3/Mission/RequestPortal/StoreRequest.php b/app/Http/Requests/V3/Mission/RequestPortal/StoreRequest.php index d4927d28..740cd2e9 100644 --- a/app/Http/Requests/V3/Mission/RequestPortal/StoreRequest.php +++ b/app/Http/Requests/V3/Mission/RequestPortal/StoreRequest.php @@ -2,7 +2,10 @@ namespace App\Http\Requests\V3\Mission\RequestPortal; +use Carbon\Carbon; +use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Validation\Validator; class StoreRequest extends FormRequest { @@ -17,20 +20,45 @@ class StoreRequest extends FormRequest /** * Get the validation rules that apply to the request. * - * @return array|string> + * @return array */ public function rules(): array { return [ - 'rahdaran' => 'required|array', + 'rahdaran' => 'array', 'rahdaran.*' => 'exists:rahdaran,id', 'requested_machines' => 'required|array', - 'type' => 'required|string|max:50', + 'type' => 'required|in:1,2', + 'zone' => 'required|in:1,2,3', 'start_date' => 'required|date', 'end_date' => 'required|date', - 'request_date' => 'required|date', 'description' => 'string', 'end_point' => 'required|string', + 'area' => 'required|array', + 'area.type' => 'required|string', + 'area.coordinates' => 'required|array', + 'explanation' => 'required|string', + 'category_id' => 'required|in:1,2,3', + 'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id', + ]; + } + + public function after(): array + { + return [ + function (Validator $validator) { + if ($this->type == 1){ + $start = Carbon::parse($this->start_date); + $end = Carbon::parse($this->end_date); + + if ($start->diffInMinutes($end) > 480){ + $validator->errors()->add( + 'end_date', + 'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.' + ); + } + } + } ]; } } diff --git a/app/Http/Requests/V3/Mission/RequestPortal/UpdateRequest.php b/app/Http/Requests/V3/Mission/RequestPortal/UpdateRequest.php index be6eaee5..293c2e37 100644 --- a/app/Http/Requests/V3/Mission/RequestPortal/UpdateRequest.php +++ b/app/Http/Requests/V3/Mission/RequestPortal/UpdateRequest.php @@ -3,7 +3,10 @@ namespace App\Http\Requests\V3\Mission\RequestPortal; use App\Enums\MissionStates; +use Carbon\Carbon; +use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Validation\Validator; class UpdateRequest extends FormRequest { @@ -18,7 +21,7 @@ class UpdateRequest extends FormRequest /** * Get the validation rules that apply to the request. * - * @return array|string> + * @return array */ public function rules(): array { @@ -26,12 +29,37 @@ class UpdateRequest extends FormRequest 'rahdaran' => 'required|array', 'rahdaran.*' => 'exists:rahdaran,id', 'requested_machines' => 'required|array', - 'type' => 'required|string|max:50', + 'type' => 'required|in:1,2', + 'zone' => 'required|in:1,2,3', 'start_date' => 'required|date', 'end_date' => 'required|date', - 'request_date' => 'required|date', 'description' => 'string', 'end_point' => 'required|string', + 'area' => 'required|array', + 'area.type' => 'required|string', + 'area.coordinates' => 'required|array', + 'explanation' => 'required|string', + 'category_id' => 'required|in:1,2,3', + 'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id', + ]; + } + + public function after(): array + { + return [ + function (Validator $validator) { + if ($this->type === 1){ + $start = Carbon::parse($this->start_date); + $end = Carbon::parse($this->end_date); + + if ($start->diffInMinutes($end) > 480){ + $validator->errors()->add( + 'end_date', + 'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.' + ); + } + } + } ]; } } diff --git a/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php b/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php index 5cff54a5..4c744cba 100644 --- a/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php +++ b/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php @@ -25,6 +25,7 @@ class AllocateRequest extends FormRequest return [ 'machines' => 'required|array', 'machines.*' => 'required|integer|exists:cmms_machines,id', + 'driver' => 'required|integer|exists:rahdaran,id' ]; } } diff --git a/app/Http/Requests/V3/ObservedItem/StoreRequest.php b/app/Http/Requests/V3/ObservedItem/StoreRequest.php new file mode 100644 index 00000000..081d4b40 --- /dev/null +++ b/app/Http/Requests/V3/ObservedItem/StoreRequest.php @@ -0,0 +1,36 @@ +|string> + */ + public function rules(): array + { + return [ + 'road_patrol_id' => 'required|integer|exists:road_patrols,id', + 'observed_items' => 'required|array|min:1', + 'observed_items.*.item_id' => 'required|integer|exists:info_items,item', + 'observed_items.*.sub_item_id' => 'required|integer', + 'observed_items.*.start_point' => 'required|string', + 'observed_items.*.description' => 'nullable|string', + 'observed_items.*.instant_action' => 'required|in:0,1', + 'observed_items.*.priority' => 'required_if:observed_items.*.instant_action,0|in:1,2,3', + 'observed_items.*.end_point' => 'required_if:observed_items.*.instant_action,1|string', + ]; + } +} diff --git a/app/Http/Requests/V3/Rahdaran/StoreRequest.php b/app/Http/Requests/V3/Rahdaran/StoreRequest.php new file mode 100644 index 00000000..e9436240 --- /dev/null +++ b/app/Http/Requests/V3/Rahdaran/StoreRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules(): array + { + return [ + 'name' => 'required|string|max:255', + 'code' => 'required|string|max:255', + ]; + } +} diff --git a/app/Http/Requests/V3/Rahdaran/UpdateRequest.php b/app/Http/Requests/V3/Rahdaran/UpdateRequest.php new file mode 100644 index 00000000..9a8bc794 --- /dev/null +++ b/app/Http/Requests/V3/Rahdaran/UpdateRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules(): array + { + return [ + 'name' => 'required|string|max:255', + 'code' => 'required|string|max:255', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadItemsProject/StoreRequest.php b/app/Http/Requests/V3/RoadItem/Operator/StoreRequest.php similarity index 51% rename from app/Http/Requests/V3/RoadItemsProject/StoreRequest.php rename to app/Http/Requests/V3/RoadItem/Operator/StoreRequest.php index 03b3fb46..66f045b3 100644 --- a/app/Http/Requests/V3/RoadItemsProject/StoreRequest.php +++ b/app/Http/Requests/V3/RoadItem/Operator/StoreRequest.php @@ -1,8 +1,13 @@ |string> + * @return array */ public function rules(): array { return [ + 'mission_id' => 'required|integer|exists:missions,id', 'start_point' => 'required', 'item_id' => 'required|integer', 'sub_item_id' => 'required|integer', @@ -46,32 +52,18 @@ class StoreRequest extends FormRequest 'activity_time' => 'ساعت فعالیت', ]; } + public function after(): array + { + return [ + function (Validator $validator) { + $activityTime = Carbon::parse("{$this->activity_date} {$this->activity_time}"); + + if ($activityTime->lt($this->mission->start_date) || $activityTime->gt($this->mission->end_date)) { + $validator->errors()->add('activity_time', 'زمان گزارش باید بین بازه مأموریت باشد.'); + } + } + ]; + } + -// public function after(): array -// { -// return [ -// function (Validator $validator) { -// if ($this->has(['item_id', 'sub_item_id'])) { -// -// $info_item = InfoItem::query() -// ->where('item', $this->item_id) -// ->where('sub_item', $this->sub_item_id) -// ->firstOrFail(); -// -// if ($info_item->needs_end_point && !$this->filled('end_point')) { -// $validator->errors()->add('end_point', __('validation.required')); -// } -// -// if ($info_item->needs_image) { -// if (!$this->hasFile('before_image')) { -// $validator->errors()->add('before_image', __('validation.required')); -// } -// if (!$this->hasFile('after_image')) { -// $validator->errors()->add('after_image', __('validation.required')); -// } -// } -// } -// } -// ]; -// } } diff --git a/app/Http/Requests/V3/RoadItemsProject/UpdateRequest.php b/app/Http/Requests/V3/RoadItem/Operator/UpdateRequest.php similarity index 53% rename from app/Http/Requests/V3/RoadItemsProject/UpdateRequest.php rename to app/Http/Requests/V3/RoadItem/Operator/UpdateRequest.php index 6f80951f..51986ff5 100644 --- a/app/Http/Requests/V3/RoadItemsProject/UpdateRequest.php +++ b/app/Http/Requests/V3/RoadItem/Operator/UpdateRequest.php @@ -1,13 +1,10 @@ roadItemsProject->user_id != auth()->user()->id || $this->roadItemsProject->status != 2); + return true; } /** * Get the validation rules that apply to the request. * - * @return array|string> + * @return array */ public function rules(): array { return [ + 'mission_id' => 'required|integer|exists:missions,id', 'start_point' => 'required', + 'item_id' => 'required|integer', + 'sub_item_id' => 'required|integer', 'amount' => 'required|numeric', + 'observed_item_id' => 'integer|exists:observed_items,id', + 'activity_date' => 'required|date_format:Y-m-d', + 'activity_time' => 'required|date_format:H:i', 'before_image' => 'image|max:4096', 'after_image' => 'image|max:4096', 'machines_id' => 'required|array', @@ -37,4 +40,12 @@ class UpdateRequest extends FormRequest 'rahdaran_id.*' => 'required|exists:rahdaran,id', ]; } + + public function attributes(): array + { + return [ + 'activity_date' => 'تاریخ فعالیت', + 'activity_time' => 'ساعت فعالیت', + ]; + } } diff --git a/app/Http/Requests/V3/RoadItem/Supervisor/ConfirmRequest.php b/app/Http/Requests/V3/RoadItem/Supervisor/ConfirmRequest.php new file mode 100644 index 00000000..56f26ba5 --- /dev/null +++ b/app/Http/Requests/V3/RoadItem/Supervisor/ConfirmRequest.php @@ -0,0 +1,30 @@ +roadItemsProject); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'description' => 'string', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadItem/Supervisor/RejectRequest.php b/app/Http/Requests/V3/RoadItem/Supervisor/RejectRequest.php new file mode 100644 index 00000000..d6af0596 --- /dev/null +++ b/app/Http/Requests/V3/RoadItem/Supervisor/RejectRequest.php @@ -0,0 +1,30 @@ +roadItemsProject); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'description' => 'string', + ]; + } +} diff --git a/app/Http/Requests/V3/RoadItemsProject/VerifyBySupervisorRequest.php b/app/Http/Requests/V3/RoadItemsProject/VerifyBySupervisorRequest.php deleted file mode 100644 index 6d0a19a3..00000000 --- a/app/Http/Requests/V3/RoadItemsProject/VerifyBySupervisorRequest.php +++ /dev/null @@ -1,35 +0,0 @@ -roadItemsProject); - } - - /** - * Get the validation rules that apply to the request. - * - * @return array|string> - */ - public function rules(): array - { - return [ - 'verify' => 'required|in:1,2', - 'description' => 'nullable|string', - ]; - } -} diff --git a/app/Http/Requests/V3/RoadPatrolProject/DeleteRequest.php b/app/Http/Requests/V3/RoadPatrol/DeleteRequest.php similarity index 92% rename from app/Http/Requests/V3/RoadPatrolProject/DeleteRequest.php rename to app/Http/Requests/V3/RoadPatrol/DeleteRequest.php index b6527892..128c020f 100644 --- a/app/Http/Requests/V3/RoadPatrolProject/DeleteRequest.php +++ b/app/Http/Requests/V3/RoadPatrol/DeleteRequest.php @@ -1,6 +1,6 @@ |string> - */ - public function rules(): array - { - return [ - 'verification_code' => ['required', 'string', new VerificationCode($this->phone_number)], - 'distance' => 'numeric', - 'start_time' => 'required|date_format:Y-m-d H:i', - 'end_time' => 'required|date_format:Y-m-d H:i|after:start_time', - 'fuel_consumption' => 'required|numeric', - 'vehicle_runtime' => 'required|integer', - 'stop_points' => 'required|array', - 'road_patrol_machines_id' => 'required|array', - 'road_patrol_machines_id.*' => 'required|exists:cmms_machines,id', - 'road_patrol_rahdaran_id' => 'required|array', - 'road_patrol_rahdaran_id.*' => 'required|exists:rahdaran,id', - - 'observed_items' => 'array', - 'observed_items.*.item_id' => 'required|integer', - 'observed_items.*.sub_item_id' => 'required|integer', - 'observed_items.*.description' => '', - 'observed_items.*.instant_action' => 'required|in:0,1', - 'observed_items.*.local_name' => 'required_if:observed_items.*.instant_action,0', - - // road item projects fields - 'observed_items.*.start_point' => 'required', - 'observed_items.*.end_point' => '', - 'observed_items.*.amount' => 'numeric|required_if:observed_items.*.instant_action,1', - 'observed_items.*.before_image' => 'image|max:4096', - 'observed_items.*.after_image' => 'image|max:4096', - 'observed_items.*.priority' => 'integer|in:1,2,3|required_if:observed_items.*.instant_action,0', - 'description' => 'string', - - 'observed_items.*.road_item_machines_id' => 'required_if:observed_items.*.instant_action,1|array', - 'observed_items.*.road_item_machines_id.*' => 'required_if:observed_items.*.instant_action,1|exists:cmms_machines,id', - 'observed_items.*.road_item_rahdaran_id' => 'required_if:observed_items.*.instant_action,1|array', - 'observed_items.*.road_item_rahdaran_id.*' => 'required_if:observed_items.*.instant_action,1|exists:rahdaran,id', - ]; - } - - public function attributes(): array - { - return [ - 'start_time' => 'ساعت شروع گشت', - 'end_time' => 'ساعت پایان گشت', - ]; - } -} diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php index b7b7cf82..b1c0f2af 100644 --- a/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php +++ b/app/Http/Requests/V3/SafetyAndPrivacy/FirstStepStoreRequest.php @@ -27,6 +27,7 @@ class FirstStepStoreRequest extends FormRequest 'activity_date' => 'required|date_format:Y-m-d', 'activity_time' => 'required|date_format:H:i', 'recognize_picture' => 'required|image', + 'recognize_picture_second' => 'required|image', 'axis_type_id' => 'required|integer|exists:axis_types,id', ]; } diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php index 91879ed5..9cab2e23 100644 --- a/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php +++ b/app/Http/Requests/V3/SafetyAndPrivacy/ThirdStepStoreRequest.php @@ -23,6 +23,8 @@ class ThirdStepStoreRequest extends FormRequest { return [ 'action_picture' => 'required|image', + 'finish_picture' => 'required|image', + 'evidence_picture' => 'required|image', 'action_date' => 'required|date', ]; } diff --git a/app/Http/Requests/V3/WebServices/RoadItem/IndexRequest.php b/app/Http/Requests/V3/WebServices/RoadItem/IndexRequest.php new file mode 100644 index 00000000..2ea5c62e --- /dev/null +++ b/app/Http/Requests/V3/WebServices/RoadItem/IndexRequest.php @@ -0,0 +1,33 @@ +username === 'service_user257' && + Hash::check('S3rv1ce@123', $this->password); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'from_date' => 'required|date_format:Y-m-d', + 'to_date' => 'required|date_format:Y-m-d', + ]; + } +} diff --git a/app/Http/Requests/V3/WebServices/RoadMaintenanceStation/IndexRequest.php b/app/Http/Requests/V3/WebServices/RoadMaintenanceStation/IndexRequest.php new file mode 100644 index 00000000..e03e9ae1 --- /dev/null +++ b/app/Http/Requests/V3/WebServices/RoadMaintenanceStation/IndexRequest.php @@ -0,0 +1,34 @@ +username === 'service_user257' && + Hash::check('S3rv1ce@123', $this->password); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'province' => 'exists:provinces,id', + 'status' => 'in:0,1', + 'type' => 'in:1,2,3', + ]; + } +} diff --git a/app/Models/Accident.php b/app/Models/Accident.php index f1495dce..aec15bce 100644 --- a/app/Models/Accident.php +++ b/app/Models/Accident.php @@ -14,6 +14,7 @@ class Accident extends Model use ReceiptReportAble, HasFactory; protected $guarded = []; + protected $appends = ['link']; public static function boot() { @@ -118,4 +119,11 @@ class Accident extends Model get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) ); } + + protected function link(): Attribute + { + return Attribute::make( + get: fn ($value) => env("PAYMENT_LINK")."/#/pay/".explode("/", $this->bill_code)[0]."/{$this->final_amount}", + ); + } } diff --git a/app/Models/Harim.php b/app/Models/Harim.php new file mode 100644 index 00000000..96bc4cc2 --- /dev/null +++ b/app/Models/Harim.php @@ -0,0 +1,26 @@ +hasMany(HarimHistory::class); + } + + protected function polygon(): Attribute + { + return Attribute::make( + get: fn($value) => json_decode($value) + ); + } +} diff --git a/app/Models/HarimAction.php b/app/Models/HarimAction.php new file mode 100644 index 00000000..c050b4f5 --- /dev/null +++ b/app/Models/HarimAction.php @@ -0,0 +1,13 @@ +belongsTo(Harim::class); + } +} diff --git a/app/Models/HarimState.php b/app/Models/HarimState.php new file mode 100644 index 00000000..7b8d3850 --- /dev/null +++ b/app/Models/HarimState.php @@ -0,0 +1,12 @@ + json_decode($value) + get: fn($value) => json_decode($value) + ); + } + + protected function area(): Attribute + { + return Attribute::make( + get: fn($value) => json_decode($value) ); } @@ -58,6 +66,17 @@ class Mission extends Model 'rahdarables', 'rahdarable_id', 'rahdar_id', + )->withPivot('is_driver'); + } + + public function roadObserved(): MorphToMany + { + return $this->morphedByMany( + RoadObserved::class, + 'missionable', + 'missionables', + 'mission_id', + 'missionable_id' ); } } diff --git a/app/Models/RoadObserved.php b/app/Models/RoadObserved.php index 16d30d16..3b9f3449 100644 --- a/app/Models/RoadObserved.php +++ b/app/Models/RoadObserved.php @@ -77,6 +77,7 @@ class RoadObserved extends Model 'rms_start_latlng' => 'array', 'rms_end_latlng' => 'array' ]; + protected $hidden = ['pivot']; /** * Get all of the project's files. diff --git a/app/Models/SafetyAndPrivacy.php b/app/Models/SafetyAndPrivacy.php index 0ae5ac91..246e8fe6 100644 --- a/app/Models/SafetyAndPrivacy.php +++ b/app/Models/SafetyAndPrivacy.php @@ -45,7 +45,10 @@ class SafetyAndPrivacy extends Model 'need_judiciary', 'operator_description', 'supervisor_name', - 'supervisor_id' + 'supervisor_id', + 'finish_picture', + 'evidence_picture', + 'recognize_picture_second', ]; public $table = "safety_and_privacy"; @@ -92,10 +95,28 @@ class SafetyAndPrivacy extends Model protected function actionPicture(): Attribute { return Attribute::make( - get: fn($value) => $value == null ? null : - (filter_var($value, FILTER_VALIDATE_URL) - ? $value - : Storage::disk('public')->url($value)) + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } + + protected function recognizePictureSecond(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } + + protected function evidencePicture(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + ); + } + + protected function finishPicture(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) ); } } diff --git a/app/Services/Cartables/Harim/FetchNewRequestsService.php b/app/Services/Cartables/Harim/FetchNewRequestsService.php new file mode 100644 index 00000000..144bedbd --- /dev/null +++ b/app/Services/Cartables/Harim/FetchNewRequestsService.php @@ -0,0 +1,42 @@ +url = config('cmms_web_services.MACHINE_INFO.url'); + $this->username = config('cmms_web_services.MACHINE_INFO.ViewName'); + $this->password = config('cmms_web_services.MACHINE_INFO.password'); + } + + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + public function sendRequest() + { + return Http::post($this->url, [])->json(); + } +} \ No newline at end of file diff --git a/app/Services/Cartables/Mission/ControlUnitService.php b/app/Services/Cartables/Mission/ControlUnitService.php index 571d361d..aa559a65 100644 --- a/app/Services/Cartables/Mission/ControlUnitService.php +++ b/app/Services/Cartables/Mission/ControlUnitService.php @@ -16,22 +16,23 @@ class ControlUnitService public function dataTable(Request $request) { - $fields = [ - 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', - 'description', 'requested_machines', 'type', 'start_date', - 'end_date', 'request_date', 'end_point', - ]; - $query = Mission::query() - ->where('state_id', '=', MissionStates::PENDING_CONFIRMATION->value) - ->where('edare_shahri_name', '=', Auth::user()->edarate_shahri_id); + ->whereIn('state_id', [ + MissionStates::PENDING_CONFIRMATION->value, MissionStates::START_MISSION->value + ]) + ->where('edare_shahri_id', '=', Auth::user()->edarate_shahri_id); return DataTableFacade::run( $query, $request, allowedFilters: ['*'], allowedSortings: ['*'], - allowedSelects: $fields + allowedSelects: [ + 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', + 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', + 'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time', + 'code', 'category_id', 'category_name', 'explanation' + ] ); } } \ No newline at end of file diff --git a/app/Services/Cartables/Mission/RequestPortalService.php b/app/Services/Cartables/Mission/RequestPortalService.php index 01d7cf76..fcd160af 100644 --- a/app/Services/Cartables/Mission/RequestPortalService.php +++ b/app/Services/Cartables/Mission/RequestPortalService.php @@ -15,12 +15,7 @@ class RequestPortalService public function datatable(Request $request) { $user = auth()->user(); - $fields = [ - 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', - 'description', 'requested_machines', 'type', 'start_date', - 'end_date', 'request_date', 'end_point', - ]; - $query = Mission::query(); + $query = Mission::query()->with('roadObserved:id'); if ($user->hasPermissionTo('manage-request-portal-city')) { $query->where('edare_shahri_id', '=', $user->edarate_shahri_id); @@ -34,7 +29,12 @@ class RequestPortalService $request, allowedFilters: ['*'], allowedSortings: ['*'], - allowedSelects: $fields + allowedSelects: [ + 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', + 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', + 'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time', + 'code', 'category_id', 'category_name', 'explanation' + ] ); } } \ No newline at end of file diff --git a/app/Services/Cartables/Mission/TransportationUnitService.php b/app/Services/Cartables/Mission/TransportationUnitService.php index 3462e2b2..7c5cc186 100644 --- a/app/Services/Cartables/Mission/TransportationUnitService.php +++ b/app/Services/Cartables/Mission/TransportationUnitService.php @@ -12,22 +12,21 @@ class TransportationUnitService { public function dataTable(Request $request) { - $fields = [ - 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', - 'description', 'requested_machines', 'type', 'start_date', - 'end_date', 'request_date', 'end_point', - ]; - $query = Mission::query() ->where('state_id', '=', MissionStates::REQUEST_CREATED->value) - ->where('edare_shahri_name', '=', Auth::user()->edarate_shahri_id); + ->where('edare_shahri_id', '=', Auth::user()->edarate_shahri_id); return DataTableFacade::run( $query, $request, allowedFilters: ['*'], allowedSortings: ['*'], - allowedSelects: $fields + allowedSelects: [ + 'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name', + 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', + 'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time', + 'code', 'category_id', 'category_name', 'explanation' + ] ); } } \ No newline at end of file diff --git a/app/Services/Cartables/RoadItem/OperatorService.php b/app/Services/Cartables/RoadItem/OperatorService.php new file mode 100644 index 00000000..cba4699a --- /dev/null +++ b/app/Services/Cartables/RoadItem/OperatorService.php @@ -0,0 +1,30 @@ +where('is_new', '=', 1) + ->where('user_id', '=', auth()->user()->id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedSelects: [ + 'id', 'province_fa', 'edarat_name', 'supervisor_description', 'item', 'item_fa', + 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', + 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status' + ], + ); + } +} \ No newline at end of file diff --git a/app/Services/Cartables/RoadItemTableService.php b/app/Services/Cartables/RoadItem/ReportService.php similarity index 67% rename from app/Services/Cartables/RoadItemTableService.php rename to app/Services/Cartables/RoadItem/ReportService.php index 2638e5c5..7b3916ff 100644 --- a/app/Services/Cartables/RoadItemTableService.php +++ b/app/Services/Cartables/RoadItem/ReportService.php @@ -1,73 +1,12 @@ user(); - $query = null; - - if ($user->hasPermissionTo('show-road-item-supervise-cartable')) { - $query = RoadItemsProject::query() - ->select(['id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', - 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) - ->where('is_new', 1) - ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); - } - elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) { - if (is_null($user->province_id)) { - return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); - } - $query = RoadItemsProject::query() - ->select(['id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', - 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) - ->where('is_new', 1) - ->where('province_id', auth()->user()->province_id) - ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); - } - - $data = DataTableFacade::run( - $query, - $request, - allowedFilters: $allowedFilters, - allowedSortings: $allowedSortings); - - return $data; - } - - public function operatorCartableReport(Request $request, $loadRelations = false) - { - $allowedFilters = ['*']; - $allowedSortings = ['*']; - - $query = RoadItemsProject::query() - ->select(['id', 'province_fa', 'edarat_name', 'supervisor_description', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', - 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) - ->where('is_new', 1) - ->where('user_id', auth()->user()->id) - ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));; - - $data = DataTableFacade::run( - $query, - $request, - allowedFilters: $allowedFilters, - allowedSortings: $allowedSortings); - - return $data; - } - public function countryActivityPerSubItem(Request $request): array { $fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString(); diff --git a/app/Services/Cartables/RoadItem/SupervisorService.php b/app/Services/Cartables/RoadItem/SupervisorService.php new file mode 100644 index 00000000..ee7510fb --- /dev/null +++ b/app/Services/Cartables/RoadItem/SupervisorService.php @@ -0,0 +1,46 @@ +user(); + $query = null; + + if ($user->hasPermissionTo('show-road-item-supervise-cartable')) { + $query = RoadItemsProject::query() + ->where('is_new', 1) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); + } + elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) { + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + $query = RoadItemsProject::query() + ->where('is_new', 1) + ->where('province_id', auth()->user()->province_id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); + } + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedSelects: [ + 'id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', + 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', + 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status' + ] + ); + } +} \ No newline at end of file diff --git a/app/Services/Cartables/RoadObservation/OperatorService.php b/app/Services/Cartables/RoadObservation/OperatorService.php index 7256a92d..287a7e89 100644 --- a/app/Services/Cartables/RoadObservation/OperatorService.php +++ b/app/Services/Cartables/RoadObservation/OperatorService.php @@ -46,7 +46,7 @@ class OperatorService $fields = ['fk_RegisteredEventMessage', 'road_observeds.id', 'Title', 'FeatureTypeTitle', 'MobileForSendEventSms', 'StartTime_DateTime', 'road_observeds.created_at', 'rms_last_activity', 'rms_last_activity_fa', 'status', 'edarate_shahri_id', - 'status_fa', 'supervisor_description', 'rms_description', 'province_fa', 'city_id', 'city_fa', 'Description', + 'status_fa', 'supervisor_description', 'rms_description', 'province_fa', 'city_id', 'city_fa', 'Description', 'road_observeds.province_id', 'edarate_shahri.name_fa as edarate_shahri_name_fa', 'lat', 'lng']; if ($user->hasPermissionTo('show-fast-react')) { diff --git a/app/Services/Cartables/RoadPatrol/OperatorService.php b/app/Services/Cartables/RoadPatrol/OperatorService.php new file mode 100644 index 00000000..ce754c57 --- /dev/null +++ b/app/Services/Cartables/RoadPatrol/OperatorService.php @@ -0,0 +1,30 @@ +where('operator_id', '=', auth()->user()->id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedSelects: [ + 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', + 'start_time', 'end_time', 'created_at', 'description', + 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' + ], + ); + } +} \ No newline at end of file diff --git a/app/Services/Cartables/RoadPatrolTableService.php b/app/Services/Cartables/RoadPatrol/ReportService.php similarity index 74% rename from app/Services/Cartables/RoadPatrolTableService.php rename to app/Services/Cartables/RoadPatrol/ReportService.php index d43a45d7..827648b3 100644 --- a/app/Services/Cartables/RoadPatrolTableService.php +++ b/app/Services/Cartables/RoadPatrol/ReportService.php @@ -1,74 +1,14 @@ user(); - $query = null; - - if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) { - $query = RoadPatrol::query() - ->select([ - 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description', - 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' - ]) - ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); - } - elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) { - if (is_null($user->province_id)) { - return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); - } - $query = RoadPatrol::query() - ->select([ - 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description', - 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' - ]) - ->where('province_id', '=', $user->province_id) - ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); - } - - $data = DataTableFacade::run( - $query, - $request, - allowedFilters: $allowedFilters, - allowedSortings: $allowedSortings); - - return $data; - } - - public function operatorCartableReport(Request $request, $loadRelations = false) - { - $allowedFilters = ['*']; - $allowedSortings = ['*']; - - $query = RoadPatrol::query() - ->select([ - 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description', - 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' - ]) - ->where('operator_id', '=', auth()->user()->id) - ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); - - $data = DataTableFacade::run( - $query, - $request, - allowedFilters: $allowedFilters, - allowedSortings: $allowedSortings); - - return $data; - } - public function countryActivity(Request $request): array { $fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString(); diff --git a/app/Services/Cartables/RoadPatrol/SupervisorService.php b/app/Services/Cartables/RoadPatrol/SupervisorService.php new file mode 100644 index 00000000..e726dbc2 --- /dev/null +++ b/app/Services/Cartables/RoadPatrol/SupervisorService.php @@ -0,0 +1,47 @@ +user(); + $query = null; + + if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) { + $query = RoadPatrol::query() + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); + } + elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) + { + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + + $query = RoadPatrol::query() + ->where('province_id', '=', $user->province_id) + ->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])); + } + + return DataTableFacade::run( + $query, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedSelects: [ + 'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', + 'start_time', 'end_time', 'created_at', 'description', + 'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points' + ] + ); + } +} \ No newline at end of file diff --git a/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php b/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php index f41270fd..c840e5d8 100644 --- a/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php +++ b/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php @@ -6,6 +6,7 @@ use App\Exceptions\ProhibitedAction; use App\Facades\DataTable\DataTableFacade; use App\Models\SafetyAndPrivacy; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; class OperatorService { @@ -16,7 +17,8 @@ class OperatorService $fields = [ 'id','lat','lon', 'recognize_picture','action_picture','created_at','step', 'final_description', 'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', - 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description' + 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', + 'operator_description', 'finish_picture', 'evidence_picture', 'recognize_picture_second' ]; throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); @@ -32,118 +34,95 @@ class OperatorService ); } - public function countryActivity(Request $request): array + public function countryActivity(int $info_id): array { - $activities = []; - $countryQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,info_id, step'); - - $country = DataTableFacade::run( - $countryQuery, - $request, - allowedFilters: ['*'], - allowedSortings: ['*'], - allowedGroupBy: ['info_id', 'step'] - ); - - $countryTotalSum = 0; - $countryData = [ - 'name_fa' => 'کشوری', - 'province_id' => -1, - 'sum' => 0, - '89' => ['1' => 0, '2' => 0, '3' => 0,], - '90' => ['1' => 0, '2' => 0, '3' => 0,], - '91' => ['1' => 0, '2' => 0, '3' => 0,], - ]; - foreach ($country['data'] as $key => $value) { - $countryTotalSum += $value->qty; - $countryData[$value->info_id][$value->step] = $value->qty; - $countryData["sum"] = $countryTotalSum; - } - - $activities[] = (object) $countryData; - $provinceQuery = SafetyAndPrivacy::query()->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step'); - $provinces = DataTableFacade::run( - $provinceQuery, - $request, - allowedFilters: ['*'], - allowedSortings: ['*'], - allowedGroupBy: ['info_id', 'step', 'province_id', 'province_fa'] - ); - - foreach ($provinces['data'] as $value) - { - $provinceId = $value->province_id; - if (!isset($activities[$provinceId])) { - $activities[$provinceId] = (object) [ - 'province_id' => $provinceId, - 'name_fa' => $value->province_fa, - 'sum' => 0, - '89' => ['1' => 0, '2' => 0, '3' => 0], - '90' => ['1' => 0, '2' => 0, '3' => 0], - '91' => ['1' => 0, '2' => 0, '3' => 0], - ]; - } - $activities[$provinceId]->{$value->info_id}[$value->step] = $value->qty; - $activities[$provinceId]->sum += $value->qty; - } - - return array_values($activities); + return DB::select(" + WITH combinations AS ( + SELECT + axis_type_id, + step + FROM ( + SELECT 1 AS axis_type_id UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 + ) a + CROSS JOIN ( + SELECT 1 AS step UNION ALL SELECT 2 UNION ALL SELECT 3 + ) s + ), + provinces AS ( + SELECT DISTINCT province_fa FROM safety_and_privacy WHERE info_id = ? + ), + data AS ( + SELECT + p.province_fa, + c.axis_type_id, + c.step, + COUNT(sp.id) AS total + FROM combinations c + CROSS JOIN provinces p + LEFT JOIN safety_and_privacy sp + ON sp.axis_type_id = c.axis_type_id + AND sp.step = c.step + AND sp.province_fa = p.province_fa + AND sp.info_id = ? + GROUP BY p.province_fa, c.axis_type_id, c.step + ) + SELECT + province_fa, + axis_type_id, + step, + total, + SUM(total) OVER (PARTITION BY province_fa) AS total_sum + FROM data + ORDER BY province_fa, axis_type_id, step + ", [$info_id, $info_id]); } - public function provinceActivity(Request $request): array + public function provinceActivity(int $info_id, int $province_id): array { - $activities = []; - $provinceQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,info_id, step'); - $province = DataTableFacade::run( - $provinceQuery, - $request, - allowedFilters: ['*'], - allowedSortings: ['*'], - allowedGroupBy: ['info_id', 'step'] - ); - - $provinceTotalSum = 0; - $provinceData = [ - 'name_fa' => 'استانی', - 'edare_shahri_id' => -1, - 'sum' => 0, - '89' => ['1' => 0, '2' => 0, '3' => 0,], - '90' => ['1' => 0, '2' => 0, '3' => 0,], - '91' => ['1' => 0, '2' => 0, '3' => 0,], - ]; - foreach ($province['data'] as $key => $value) { - $provinceTotalSum += $value->qty; - $provinceData["sum"] = $provinceTotalSum; - $provinceData[$value->info_id][$value->step] = $value->qty; - } - $activities[] = (object) $provinceData; - - $citiesQuery = SafetyAndPrivacy::query()->selectRaw('edare_shahri_id, COUNT(*) as qty,info_id, step'); - $cities = DataTableFacade::run( - $citiesQuery, - $request, - allowedFilters: ['*'], - allowedSortings: ['*'], - allowedGroupBy: ['info_id', 'step', 'edare_shahri_id'] - ); - - foreach ($cities['data'] as $value) - { - $cityId = $value->edare_shahri_id; - if (!isset($activities[$cityId])) { - $activities[$cityId] = (object) [ - 'edare_shahri_id' => $cityId, - 'name_fa' => \App\Models\EdarateShahri::query()->find($cityId)->name_fa, - 'sum' => 0, - '89' => ['1' => 0, '2' => 0, '3' => 0], - '90' => ['1' => 0, '2' => 0, '3' => 0], - '91' => ['1' => 0, '2' => 0, '3' => 0], - ]; - } - $activities[$cityId]->{$value->info_id}[$value->step] = $value->qty; - $activities[$cityId]->sum += $value->qty; - } - - return array_values($activities); + return DB::select(" + WITH combinations AS ( + SELECT axis_type_id, step + FROM ( + SELECT 1 AS axis_type_id UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 + ) a + CROSS JOIN ( + SELECT 1 AS step UNION ALL SELECT 2 UNION ALL SELECT 3 + ) s + ), + edarat AS ( + SELECT id AS edare_id, name_fa + FROM edarate_shahri + WHERE province_id = :provinceId + ), + data AS ( + SELECT + e.edare_id, + c.axis_type_id, + c.step, + COUNT(sp.id) AS total + FROM combinations c + CROSS JOIN edarat e + LEFT JOIN safety_and_privacy sp + ON sp.axis_type_id = c.axis_type_id + AND sp.step = c.step + AND sp.city_id = e.edare_id + AND sp.info_id = :infoId + GROUP BY e.edare_id, c.axis_type_id, c.step + ) + SELECT + e.edare_id, + e.name_fa AS edare_name, + d.axis_type_id, + d.step, + d.total, + SUM(d.total) OVER (PARTITION BY e.edare_id) AS total_sum + FROM data d + JOIN edarat e ON e.edare_id = d.edare_id + ORDER BY e.edare_id, d.axis_type_id, d.step + ",[ + 'provinceId' => $province_id, + 'infoId' => $info_id, + ]); } + } \ No newline at end of file diff --git a/app/Services/Cartables/SafetyAndPrivacy/SupervisorService.php b/app/Services/Cartables/SafetyAndPrivacy/SupervisorService.php index 0579bc8b..20d0257c 100644 --- a/app/Services/Cartables/SafetyAndPrivacy/SupervisorService.php +++ b/app/Services/Cartables/SafetyAndPrivacy/SupervisorService.php @@ -6,19 +6,17 @@ use App\Exceptions\ProhibitedAction; use App\Facades\DataTable\DataTableFacade; use App\Models\SafetyAndPrivacy; use Illuminate\Http\Request; +use Throwable; class SupervisorService { + /** + * @throws Throwable + */ public function dataTable(Request $request) { $user = auth()->user(); - $fields = [ - 'id','lat','lon', 'recognize_picture','action_picture','created_at','status', 'final_description', 'province_fa', - 'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', 'edare_shahri_name', - 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description' - ]; - $query = SafetyAndPrivacy::query(); if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) @@ -33,7 +31,12 @@ class SupervisorService $request, allowedFilters: ['*'], allowedSortings: ['*'], - allowedSelects: $fields + allowedSelects: [ + 'id','lat','lon', 'recognize_picture','action_picture','created_at','status', 'final_description', 'province_fa', + 'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', + 'edare_shahri_name', 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', + 'supervisor_description', 'operator_description' + ] ); } } \ No newline at end of file diff --git a/app/Services/NikarayanService.php b/app/Services/NikarayanService.php index ba87eb8b..aa09748e 100644 --- a/app/Services/NikarayanService.php +++ b/app/Services/NikarayanService.php @@ -26,8 +26,8 @@ class NikarayanService 'strAutoID' => $roadObserved->fk_RegisteredEventMessage, 'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3', 'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description, - 'strPreviousImageLink' => "https://rms.rmto.ir/".$files, - 'strNextImageLink' => "https://rms.rmto.ir/".$files, + 'strPreviousImageLink' => !empty($files) && isset($files[0]['path']) ? "https://rms.rmto.ir/" . $files[0]['path'] : "", + 'strNextImageLink' => !empty($files) && isset($files[1]['path']) ? "https://rms.rmto.ir/" . $files[1]['path'] : "", 'strRMSDateAndTime' => $roadObserved->updated_at ); diff --git a/composer.json b/composer.json index 825d349e..8d9ff456 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": "^8.1", "ext-zip": "*", - "doctrine/dbal": "^3.7", + "doctrine/dbal": "^3.10", "guzzlehttp/guzzle": "^7.2", "hekmatinasser/verta": "^8.3", "laravel/framework": "^10.10", diff --git a/composer.lock b/composer.lock index 406835fc..0388dc70 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fb6adbe1f5e02aaf3de31c514710f0b6", + "content-hash": "bf9b86b55591e7c7df84cb1be8ea9db3", "packages": [ { "name": "beberlei/assert", @@ -353,135 +353,43 @@ }, "time": "2022-10-27T11:44:00+00:00" }, - { - "name": "doctrine/cache", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/cache.git", - "reference": "1ca8f21980e770095a31456042471a57bc4c68fb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb", - "reference": "1ca8f21980e770095a31456042471a57bc4c68fb", - "shasum": "" - }, - "require": { - "php": "~7.1 || ^8.0" - }, - "conflict": { - "doctrine/common": ">2.2,<2.4" - }, - "require-dev": { - "cache/integration-tests": "dev-master", - "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psr/cache": "^1.0 || ^2.0 || ^3.0", - "symfony/cache": "^4.4 || ^5.4 || ^6", - "symfony/var-exporter": "^4.4 || ^5.4 || ^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", - "homepage": "https://www.doctrine-project.org/projects/cache.html", - "keywords": [ - "abstraction", - "apcu", - "cache", - "caching", - "couchdb", - "memcached", - "php", - "redis", - "xcache" - ], - "support": { - "issues": "https://github.com/doctrine/cache/issues", - "source": "https://github.com/doctrine/cache/tree/2.2.0" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", - "type": "tidelift" - } - ], - "time": "2022-05-20T20:07:39+00:00" - }, { "name": "doctrine/dbal", - "version": "3.8.0", + "version": "3.10.0", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "d244f2e6e6bf32bff5174e6729b57214923ecec9" + "reference": "1cf840d696373ea0d58ad0a8875c0fadcfc67214" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/d244f2e6e6bf32bff5174e6729b57214923ecec9", - "reference": "d244f2e6e6bf32bff5174e6729b57214923ecec9", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/1cf840d696373ea0d58ad0a8875c0fadcfc67214", + "reference": "1cf840d696373ea0d58ad0a8875c0fadcfc67214", "shasum": "" }, "require": { "composer-runtime-api": "^2", - "doctrine/cache": "^1.11|^2.0", "doctrine/deprecations": "^0.5.3|^1", "doctrine/event-manager": "^1|^2", "php": "^7.4 || ^8.0", "psr/cache": "^1|^2|^3", "psr/log": "^1|^2|^3" }, + "conflict": { + "doctrine/cache": "< 1.11" + }, "require-dev": { - "doctrine/coding-standard": "12.0.0", + "doctrine/cache": "^1.11|^2.0", + "doctrine/coding-standard": "13.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "1.10.56", - "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpunit": "9.6.15", - "psalm/plugin-phpunit": "0.18.4", - "slevomat/coding-standard": "8.13.1", - "squizlabs/php_codesniffer": "3.8.1", + "phpstan/phpstan": "2.1.17", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "9.6.23", + "slevomat/coding-standard": "8.16.2", + "squizlabs/php_codesniffer": "3.13.1", "symfony/cache": "^5.4|^6.0|^7.0", - "symfony/console": "^4.4|^5.4|^6.0|^7.0", - "vimeo/psalm": "4.30.0" + "symfony/console": "^4.4|^5.4|^6.0|^7.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -541,7 +449,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.8.0" + "source": "https://github.com/doctrine/dbal/tree/3.10.0" }, "funding": [ { @@ -557,7 +465,7 @@ "type": "tidelift" } ], - "time": "2024-01-25T21:44:02+00:00" + "time": "2025-07-10T21:11:04+00:00" }, { "name": "doctrine/deprecations", diff --git a/database/factories/HarimActionFactory.php b/database/factories/HarimActionFactory.php new file mode 100644 index 00000000..b90e48c7 --- /dev/null +++ b/database/factories/HarimActionFactory.php @@ -0,0 +1,23 @@ + + */ +class HarimActionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => $this->faker->name(), + ]; + } +} diff --git a/database/factories/HarimFactory.php b/database/factories/HarimFactory.php new file mode 100644 index 00000000..d5f07b19 --- /dev/null +++ b/database/factories/HarimFactory.php @@ -0,0 +1,58 @@ + + */ +class HarimFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'state_id' => $this->faker->numberBetween(1,15), + 'state_name' => function (array $attributes) { + return HarimState::query()->find($attributes['state_id'])->name; + }, + 'first_name' => $this->faker->firstName(), + 'last_name' => $this->faker->lastName(), + 'phone_number' => $this->faker->numerify('09#########'), + 'request_number' => $this->faker->numerify(), + 'request_date' => $this->faker->date(), + 'province_id' => Province::factory(), + 'province_name' => function (array $attributes) { + return Province::query()->find($attributes['province_id'])->name_fa; + }, + 'city_id' => City::factory(), + 'city_name' => function (array $attributes) { + return City::query()->find($attributes['city_id'])->name_fa; + }, + 'edareh_shahri_id' => EdarateShahri::factory(), + 'county' => $this->faker->citySuffix, + 'division' => $this->faker->word, + 'village' => $this->faker->name, + 'grand_area' => $this->faker->numberBetween(1,100), + 'plan_area' => $this->faker->numberBetween(1,100), + 'requested_organization' => $this->faker->name, + 'plan_group' => $this->faker->name, + 'plan_title' => $this->faker->title, + 'address' => $this->faker->address, + 'file' => $this->faker->name, + 'polygon' => json_encode($this->faker->numerify()), + 'need_road_access' => $this->faker->boolean(), + 'is_file_good' => $this->faker->boolean(), + 'is_possible' => $this->faker->boolean(), + ]; + } +} diff --git a/database/factories/HarimHistoryFactory.php b/database/factories/HarimHistoryFactory.php new file mode 100644 index 00000000..51a87c10 --- /dev/null +++ b/database/factories/HarimHistoryFactory.php @@ -0,0 +1,41 @@ + + */ +class HarimHistoryFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'previous_state_id' => HarimState::factory(), + 'previous_state_name' => function (array $attributes) { + return HarimStates::query()->find($attributes['state_id'])->name; + }, + 'current_state_id' => HarimState::factory(), + 'current_state_name' => function (array $attributes) { + return HarimState::query()->find($attributes['state_id'])->name; + }, + 'action_id' => HarimAction::factory(), + 'action_name' => function (array $attributes) { + return HarimAction::query()->find($attributes['state_id'])->name; + }, + 'expert_id' => User::factory(), + 'expert_description' => $this->fake()->text, + 'previous_data' => json_encode(['fake']), + ]; + } +} diff --git a/database/factories/HarimStateFactory.php b/database/factories/HarimStateFactory.php new file mode 100644 index 00000000..82d8e5ad --- /dev/null +++ b/database/factories/HarimStateFactory.php @@ -0,0 +1,23 @@ + + */ +class HarimStateFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => $this->faker->name(), + ]; + } +} diff --git a/database/migrations/2024_12_25_133822_create_machinables_table.php b/database/migrations/2024_12_25_133822_create_machinables_table.php index 4e81635b..31c4e9f4 100644 --- a/database/migrations/2024_12_25_133822_create_machinables_table.php +++ b/database/migrations/2024_12_25_133822_create_machinables_table.php @@ -24,6 +24,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('machinable'); + Schema::dropIfExists('machinables'); } }; diff --git a/database/migrations/2025_05_18_090655_create_missionables_table.php b/database/migrations/2025_05_18_090655_create_missionables_table.php index 3bd88f09..977d6f5d 100644 --- a/database/migrations/2025_05_18_090655_create_missionables_table.php +++ b/database/migrations/2025_05_18_090655_create_missionables_table.php @@ -13,7 +13,7 @@ return new class extends Migration { Schema::create('missionables', function (Blueprint $table) { $table->id(); - $table->foreignId('mission_id')->constrained('missions')->noActionOnDelete(); + $table->foreignId('mission_id')->constrained('missions')->cascadeOnDelete(); $table->morphs('missionable'); $table->timestamps(); }); diff --git a/database/migrations/2025_05_18_093843_create_mission_histories_table.php b/database/migrations/2025_05_18_093843_create_mission_histories_table.php index d3a79188..1333cc72 100644 --- a/database/migrations/2025_05_18_093843_create_mission_histories_table.php +++ b/database/migrations/2025_05_18_093843_create_mission_histories_table.php @@ -13,7 +13,7 @@ return new class extends Migration { Schema::create('mission_histories', function (Blueprint $table) { $table->id(); - $table->foreignId('mission_id')->constrained('missions'); + $table->foreignId('mission_id')->constrained('missions')->cascadeOnDelete(); $table->unsignedInteger('user_id'); $table->foreign('user_id')->references('id')->on('users'); $table->foreignId('previous_state_id')->constrained('mission_states'); diff --git a/database/migrations/2025_06_10_093806_add_area_to_missions_table.php b/database/migrations/2025_06_10_093806_add_area_to_missions_table.php new file mode 100644 index 00000000..bee98cf6 --- /dev/null +++ b/database/migrations/2025_06_10_093806_add_area_to_missions_table.php @@ -0,0 +1,31 @@ +json('area'); + $table->integer('zone'); + $table->string('zone_fa'); + $table->string('type_fa'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('missions', function (Blueprint $table) { + $table->dropColumn(['area', 'zone', 'zone_fa', 'type_fa']); + }); + } +}; diff --git a/database/migrations/2025_06_24_114516_add_column_to_missions_table.php b/database/migrations/2025_06_24_114516_add_column_to_missions_table.php new file mode 100644 index 00000000..eb96489a --- /dev/null +++ b/database/migrations/2025_06_24_114516_add_column_to_missions_table.php @@ -0,0 +1,29 @@ +dateTime('start_time')->nullable(); + $table->dateTime('finish_time')->nullable();; + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('missions', function (Blueprint $table) { + $table->dropColumn(['start_time', 'finish_time']); + }); + } +}; diff --git a/database/migrations/2025_07_12_140123_add_column_to_cmms_machines_table.php b/database/migrations/2025_07_12_140123_add_column_to_cmms_machines_table.php new file mode 100644 index 00000000..e77b3a1d --- /dev/null +++ b/database/migrations/2025_07_12_140123_add_column_to_cmms_machines_table.php @@ -0,0 +1,28 @@ +string('car_type')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('cmms_machines', function (Blueprint $table) { + $table->dropColumn('car_type'); + }); + } +}; diff --git a/database/migrations/2025_07_12_140818_add_colum_to_missions_table.php b/database/migrations/2025_07_12_140818_add_colum_to_missions_table.php new file mode 100644 index 00000000..62ebdebf --- /dev/null +++ b/database/migrations/2025_07_12_140818_add_colum_to_missions_table.php @@ -0,0 +1,31 @@ +integer('category_id')->nullable(); + $table->string('category_name')->nullable(); + $table->text('explanation')->nullable(); + $table->string('code')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('missions', function (Blueprint $table) { + $table->dropColumn(['category_id', 'category_name', 'explanation', 'code']); + }); + } +}; diff --git a/database/migrations/2025_07_21_095907_add_one_column_to_rahdarables_table.php b/database/migrations/2025_07_21_095907_add_one_column_to_rahdarables_table.php new file mode 100644 index 00000000..6dbc833b --- /dev/null +++ b/database/migrations/2025_07_21_095907_add_one_column_to_rahdarables_table.php @@ -0,0 +1,28 @@ +boolean('is_driver')->nullable()->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('rahdarables', function (Blueprint $table) { + $table->dropColumn('is_driver'); + }); + } +}; diff --git a/database/migrations/2025_07_22_162735_make_columns_name_nullable_on_road_patrols.php b/database/migrations/2025_07_22_162735_make_columns_name_nullable_on_road_patrols.php new file mode 100644 index 00000000..4ac40ee8 --- /dev/null +++ b/database/migrations/2025_07_22_162735_make_columns_name_nullable_on_road_patrols.php @@ -0,0 +1,30 @@ +timestamp('start_time')->nullable()->change(); + $table->timestamp('end_time')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('road_patrols', function (Blueprint $table) { + $table->timestamp('start_time')->change(); + $table->timestamp('end_time')->change(); + }); + } +}; diff --git a/database/migrations/2025_07_29_153245_create_harim_states_table.php b/database/migrations/2025_07_29_153245_create_harim_states_table.php new file mode 100644 index 00000000..a947bd8f --- /dev/null +++ b/database/migrations/2025_07_29_153245_create_harim_states_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('harim_states'); + } +}; diff --git a/database/migrations/2025_07_30_153041_create_harims_table.php b/database/migrations/2025_07_30_153041_create_harims_table.php new file mode 100644 index 00000000..cddf389a --- /dev/null +++ b/database/migrations/2025_07_30_153041_create_harims_table.php @@ -0,0 +1,56 @@ +id(); + $table->foreignId('state_id')->constrained('harim_states'); + $table->string('state_name'); + $table->string('first_name'); + $table->string('last_name'); + $table->string('phone_number'); + $table->string('request_number'); + $table->date('request_date'); + $table->unsignedTinyInteger('province_id'); + $table->foreign('province_id')->references('id')->on('provinces'); + $table->string('province_name'); + $table->unsignedSmallInteger('city_id'); + $table->foreign('city_id')->references('id')->on('cities'); + $table->string('city_name'); + $table->unsignedBigInteger('edareh_shahri_id'); + $table->foreign('edareh_shahri_id')->references('id')->on('edarate_shahri'); + $table->string('county'); + $table->string('division'); + $table->string('village'); + $table->integer('grand_area'); + $table->integer('plan_area'); + $table->string('requested_organization'); + $table->string('plan_group'); + $table->string('plan_title'); + $table->string('address'); + $table->string('file'); + $table->json('polygon'); + $table->boolean('need_road_access')->nullable(); + $table->boolean('is_file_good')->nullable(); + $table->boolean('is_possible')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('harims'); + } +}; diff --git a/database/migrations/2025_07_30_153133_create_harim_actions_table.php b/database/migrations/2025_07_30_153133_create_harim_actions_table.php new file mode 100644 index 00000000..32a8ddad --- /dev/null +++ b/database/migrations/2025_07_30_153133_create_harim_actions_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('harim_actions'); + } +}; diff --git a/database/migrations/2025_07_30_153216_create_harim_histories_table.php b/database/migrations/2025_07_30_153216_create_harim_histories_table.php new file mode 100644 index 00000000..8ac45608 --- /dev/null +++ b/database/migrations/2025_07_30_153216_create_harim_histories_table.php @@ -0,0 +1,35 @@ +id(); + $table->foreignId('previous_state_id')->constrained('harim_states'); + $table->string('previous_state_name'); + $table->foreignId('harim_id')->constrained('harims'); + $table->foreignId('action_id')->constrained('harim_actions'); + $table->string('action_name'); + $table->unsignedInteger('expert_id'); + $table->foreign('expert_id')->references('id')->on('users'); + $table->string('expert_description'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('harim_histories'); + } +}; diff --git a/database/migrations/2025_08_12_162810_add_pictures_to_safety_and_privacy_table.php b/database/migrations/2025_08_12_162810_add_pictures_to_safety_and_privacy_table.php new file mode 100644 index 00000000..cc8974e4 --- /dev/null +++ b/database/migrations/2025_08_12_162810_add_pictures_to_safety_and_privacy_table.php @@ -0,0 +1,30 @@ +string('recognize_picture_second')->nullable(); + $table->string('finish_picture')->nullable(); + $table->string('evidence_picture')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('safety_and_privacy', function (Blueprint $table) { + $table->dropColumn(['recognize_picture_second', 'finish_picture', 'evidence_picture']); + }); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 271c1f02..86225dd5 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -12,12 +12,12 @@ class DatabaseSeeder extends Seeder public function run(): void { $this->call([ - ProvinceSeeder::class; - CitySeeder::class; - EdarateShahriSeeder::class; - InfoItemSeeder::class; - LogListSeeder::class; - PermissionSeeder::class; + ProvinceSeeder::class, + CitySeeder::class, + EdarateShahriSeeder::class, + InfoItemSeeder::class, + LogListSeeder::class, + PermissionSeeder::class, ]); } } diff --git a/database/seeders/HarimActionSeeder.php b/database/seeders/HarimActionSeeder.php new file mode 100644 index 00000000..0a84a66f --- /dev/null +++ b/database/seeders/HarimActionSeeder.php @@ -0,0 +1,24 @@ +insert([ + ['id' => 1, 'name' => 'feedback', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 2, 'name' => 'yes', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 3, 'name' => 'no', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 4, 'name' => 'confirm', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 5, 'name' => 'refer', 'created_at' => now(), 'updated_at' => now(),], + ]); + } +} diff --git a/database/seeders/HarimHistorySeeder.php b/database/seeders/HarimHistorySeeder.php new file mode 100644 index 00000000..4a838e20 --- /dev/null +++ b/database/seeders/HarimHistorySeeder.php @@ -0,0 +1,20 @@ +count(5) + ->create(); + } +} diff --git a/database/seeders/HarimSeeder.php b/database/seeders/HarimSeeder.php new file mode 100644 index 00000000..577e542c --- /dev/null +++ b/database/seeders/HarimSeeder.php @@ -0,0 +1,21 @@ +count(5) + ->create(); + + } +} diff --git a/database/seeders/HarimStateSeeder.php b/database/seeders/HarimStateSeeder.php new file mode 100644 index 00000000..0024e975 --- /dev/null +++ b/database/seeders/HarimStateSeeder.php @@ -0,0 +1,34 @@ +insert([ + ['id' => 1, 'name' => 'بررسی ادارات شهرستان', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 2, 'name' => 'بررسی توسط ادارات حریم', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 3, 'name' => 'بررسی توسط معاون', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 4, 'name' => 'بررسی توسط مدیر کل', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 5, 'name' => 'بررسی فایل آپلود شده توسط اداره حریم', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 6, 'name' => 'بررسی فایل آپلود شده توسط معاون', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 7, 'name' => 'بررسی فایل آپلود شده توسط مدیر', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 8, 'name' => 'ارسال ضمانت نامه توسط کاربر', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 9, 'name' => 'ارسال به پنجره واحد ( نیاز به راه دسترسی)', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 10, 'name' => 'امکان پذیر نمی باشد', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 11, 'name' => 'ارسال به پنجره واحد (بدون نیاز به راه دسترسی)', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 12, 'name' => 'بازبینی فایل بارگذاری شده', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 13, 'name' => 'تائید عرصه و اعیان ارسال شده توسط اداره حریم', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 14, 'name' => 'تائید عرصه و اعیان ارسال شده توسط معاون', 'created_at' => now(), 'updated_at' => now(),], + ['id' => 15, 'name' => 'تائید عرصه و اعیان ارسال شده توسط مدیر', 'created_at' => now(), 'updated_at' => now(),], + ]); + } +} diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php similarity index 60% rename from resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php rename to resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php index ee8c6c6a..673063c3 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php @@ -21,14 +21,14 @@ - - - گزارش نگهداری حریم راه + گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز @@ -41,13 +41,19 @@ تعداد کل - ساخت و ساز غیر مجاز + آزاد راه - راه دسترسی غیر مجاز +بزرگ راه - عبور تاسیسات زیربنایی غیر مجاز + اصلی + + + فرعی + + + روستایی @@ -78,6 +84,24 @@ گام سوم (برخورد) + + گام اول (شناسایی) + + + گام دوم (مستندات قضایی) + + + گام سوم (برخورد) + + + گام اول (شناسایی) + + + گام دوم (مستندات قضایی) + + + گام سوم (برخورد) + @@ -85,15 +109,21 @@ {{ $item->name_fa }} {{ $item->sum }} - {{ $item->{'89'}[1] }} - {{ $item->{'89'}[2] }} - {{ $item->{'89'}[3] }} - {{ $item->{'90'}[1] }} - {{ $item->{'90'}[2] }} - {{ $item->{'90'}[3] }} - {{ $item->{'91'}[1] }} - {{ $item->{'91'}[2] }} - {{ $item->{'91'}[3] }} + {{ $item->axis_data['آزادراه'][1] }} + {{$item->axis_data['آزادراه'][2] }} + {{ $item->axis_data['آزادراه'][3] }} + {{ $item->axis_data['بزرگراه'][1] }} + {{ $item->axis_data['بزرگراه'][2] }} + {{ $item->axis_data['بزرگراه'][3] }} + {{ $item->axis_data['اصلی'][1] }} + {{ $item->axis_data['اصلی'][2] }} + {{ $item->axis_data['اصلی'][3] }} + {{ $item->axis_data['فرعی'][1] }} + {{ $item->axis_data['فرعی'][2] }} + {{ $item->axis_data['فرعی'][3] }} + {{ $item->axis_data['روستایی'][1] }} + {{ $item->axis_data['روستایی'][2] }} + {{ $item->axis_data['روستایی'][3] }} @endforeach diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php new file mode 100644 index 00000000..1854ba63 --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php @@ -0,0 +1,132 @@ + + + + + + + + کشوری + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش نگهداری حریم راه برای ساخت و ساز غیر مجاز +
+ اداره کل + + تعداد کل + + آزاد راه + + بزرگ راه + + اصلی + + فرعی + + روستایی +
+ گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) +
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}
+ + diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php new file mode 100644 index 00000000..092683d7 --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php @@ -0,0 +1,132 @@ + + + + + + + + کشوری + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز +
+ اداره کل + + تعداد کل + + آزاد راه + + بزرگ راه + + اصلی + + فرعی + + روستایی +
+ گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) +
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}
+ + diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php new file mode 100644 index 00000000..e54e7ddc --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php @@ -0,0 +1,131 @@ + + + + + + + + استانی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز +
+ اداره کل + + تعداد کل + + آزاد راه + + بزرگ راه + + اصلی + + فرعی + + روستایی +
+ گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) +
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}
+ + diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php similarity index 60% rename from resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php rename to resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php index df2f7638..509e3b0c 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php @@ -21,14 +21,14 @@ - - - گزارش نگهداری حریم راه + گزارش نگهداری حریم راه برای ساخت و ساز غیر مجاز @@ -40,13 +40,19 @@ تعداد کل - ساخت و ساز غیر مجاز + آزاد راه - راه دسترسی غیر مجاز + بزرگ راه - عبور تاسیسات زیربنایی غیر مجاز + اصلی + + + فرعی + + + روستایی @@ -77,6 +83,24 @@ گام سوم (برخورد) + + گام اول (شناسایی) + + + گام دوم (مستندات قضایی) + + + گام سوم (برخورد) + + + گام اول (شناسایی) + + + گام دوم (مستندات قضایی) + + + گام سوم (برخورد) + @@ -84,15 +108,21 @@ {{ $item->name_fa }} {{ $item->sum }} - {{ $item->{'89'}[1] }} - {{ $item->{'89'}[2] }} - {{ $item->{'89'}[3] }} - {{ $item->{'90'}[1] }} - {{ $item->{'90'}[2] }} - {{ $item->{'90'}[3] }} - {{ $item->{'91'}[1] }} - {{ $item->{'91'}[2] }} - {{ $item->{'91'}[3] }} + {{ $item->axis_data['آزادراه'][1] }} + {{$item->axis_data['آزادراه'][2] }} + {{ $item->axis_data['آزادراه'][3] }} + {{ $item->axis_data['بزرگراه'][1] }} + {{ $item->axis_data['بزرگراه'][2] }} + {{ $item->axis_data['بزرگراه'][3] }} + {{ $item->axis_data['اصلی'][1] }} + {{ $item->axis_data['اصلی'][2] }} + {{ $item->axis_data['اصلی'][3] }} + {{ $item->axis_data['فرعی'][1] }} + {{ $item->axis_data['فرعی'][2] }} + {{ $item->axis_data['فرعی'][3] }} + {{ $item->axis_data['روستایی'][1] }} + {{ $item->axis_data['روستایی'][2] }} + {{ $item->axis_data['روستایی'][3] }} @endforeach diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php new file mode 100644 index 00000000..407ca02a --- /dev/null +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php @@ -0,0 +1,131 @@ + + + + + + + + استانی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + + + + + + + + + + + + + @endforeach + +
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }} +
+
+ گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز +
+ اداره کل + + تعداد کل + + آزاد راه + + بزرگ راه + + اصلی + + فرعی + + روستایی +
+ گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) + + گام اول (شناسایی) + + گام دوم (مستندات قضایی) + + گام سوم (برخورد) +
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}
+ + diff --git a/routes/v3.php b/routes/v3.php index 6567212e..906a4ca0 100644 --- a/routes/v3.php +++ b/routes/v3.php @@ -8,6 +8,10 @@ use App\Http\Controllers\V3\Dashboard\Accident\AccidentReceiptReportController; use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshController; use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController; use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController; +use App\Http\Controllers\V3\Dashboard\Harim\GeneralManagerController; +use App\Http\Controllers\V3\Dashboard\Harim\HarimOfficeController; +use App\Http\Controllers\V3\Dashboard\Harim\ProvinceOfficeController; +use App\Http\Controllers\V3\Dashboard\Harim\TechnicalDeputyController; use App\Http\Controllers\V3\Dashboard\ItemsManagementController; use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController; use App\Http\Controllers\V3\Dashboard\Mission\DetailController; @@ -15,14 +19,12 @@ use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController; use App\Http\Controllers\V3\Dashboard\Mission\TransportationUnitController; use App\Http\Controllers\V3\Dashboard\ObservedItemController; use App\Http\Controllers\V3\Dashboard\OtpManagementController; -use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController; -use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController; -use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController; use App\Http\Controllers\V3\Dashboard\RoadMaintenanceStationController; -use App\Http\Controllers\V3\Dashboard\RoadObservation\RoadObservationController; -use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController; +use App\Http\Controllers\V3\Dashboard\RoadPatrol\ReportController; use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorController; -use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReportController; +use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReport\AccessRoadActivityController; +use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReport\ConstructionActivityController; +use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReport\UtilityPassingActivityController; use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\SupervisorController; use App\Http\Controllers\V3\FMSVehicleManagementController; use App\Http\Controllers\V3\Harim\DivarkeshiController; @@ -31,6 +33,7 @@ use App\Http\Controllers\V3\NotificationController; use App\Http\Controllers\V3\PermissionManagementController; use App\Http\Controllers\V3\ProfileController; use App\Http\Controllers\V3\RahdaranController; +use App\Http\Controllers\V3\WebServices\RoadItemController; use Illuminate\Support\Facades\Route; Route::get('admin/permissions', function () { @@ -112,86 +115,68 @@ Route::post('logout', LogoutController::class)->name('logout'); Route::prefix('road_items') ->name('road_items.') - ->controller(RoadItemsProjectController::class) ->group(function () { - - Route::get('/supervisor_index', 'supervisorIndex') + Route::prefix('operator') + ->name('operator.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadItem\OperatorController::class) + ->group(function () { + Route::get('/', 'index')->middleware('permission:create-road-item')->name('index'); + Route::get('/excel', 'excel')->name('excel'); + Route::post('/', 'store') + ->middleware(['permission:create-road-item', 'validate-store-access']) + ->name('store'); + Route::get('/{roadItemsProject}', 'show')->name('show'); + Route::post('/{roadItemsProject}', 'update')->name('update'); + Route::delete('/{roadItemsProject}', 'destroy')->middleware('permission:delete-road-item')->name('destroy'); + }); + Route::prefix('supervisor') + ->name('supervisor.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadItem\SupervisorController::class) ->middleware(['permission:show-road-item-supervise-cartable|show-road-item-supervise-cartable-province']) - ->name('supervisorIndex'); - - Route::post('/verify_by_supervisor/{roadItemsProject}', 'VerifyBySupervisor') - ->name('VerifyBySupervisor'); - - Route::post('/restore/{roadItemsProject}', 'restore') - ->middleware('permission:restore-road-item') - ->name('restore'); - - Route::post('/delete/{roadItemsProject}', 'delete') - ->middleware('permission:delete-road-item') - ->name('delete'); - - Route::get('/supervisor_report', 'supervisorCartableReport') - ->name('supervisorCartableReport'); - - Route::get('/operator_index', 'operatorIndex') - ->middleware('permission:create-road-item') - ->name('operatorIndex'); - - Route::post('/store', 'store') - ->middleware('permission:create-road-item') - ->name('store'); - - Route::post('/update/{roadItemsProject}', 'update')->name('update'); - - Route::get('/operator_report', 'operatorCartableReport') - ->name('operatorCartableReport'); - - Route::get('/machines/{roadItemsProject}', 'roadItemMachine')->name('roadItemMachine'); - Route::get('/rahdaran/{roadItemsProject}', 'roadItemRahdar')->name('roadItemRahdar'); - Route::get('/files/{roadItemsProject}', 'roadItemFile')->name('roadItemFile'); - }); - -Route::prefix('road_patrols') - ->name('road_patrols.') - ->controller(RoadPatrolProjectController::class) - ->group(function () { - - Route::get('/supervisor_index', 'supervisorIndex') - ->middleware(['permission:show-road-patrol-supervise-cartable|show-road-patrol-supervise-cartable-province']) - ->name('supervisorIndex'); - - Route::post('/delete/{roadPatrol}', 'delete') - ->middleware('permission:partial-delete-road-patrol|complete-delete-road-patrol') - ->name('delete'); - - Route::get('/supervisor_report', 'supervisorCartableReport') - ->name('supervisorCartableReport'); - - Route::get('/operator_index', 'operatorIndex') - ->middleware('permission:add-road-patrol') - ->name('operatorIndex'); - - Route::post('/store', 'store') - ->middleware('permission:add-road-patrol') - ->name('store'); - - Route::get('/operator_report', 'operatorCartableReport') - ->name('operatorCartableReport'); - - Route::get('/operator/report/{roadPatrol}', 'getReport') - ->name('getReport'); - - Route::get('/detail/{roadPatrol}', 'show') - ->name('show'); - - Route::get('/machines/{roadPatrol}', 'roadPatrolMachine')->name('roadPatrolMachine'); - Route::get('/rahdaran/{roadPatrol}', 'roadPatrolRahdar')->name('roadPatrolRahdar'); + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::get('/excel', 'excel')->name('excel'); + Route::post('/confirm/{roadItemsProject}', 'confirm')->name('confirm'); + Route::post('/reject/{roadItemsProject}', 'reject')->name('reject'); + Route::post('/restore/{roadItemsProject}', 'restore')->middleware('permission:restore-road-item')->name('restore'); + }); + Route::prefix('details') + ->name('details.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadItem\DetailController::class) + ->group(function () { + Route::get('/machines/{roadItemsProject}', 'machines')->name('machines'); + Route::get('/rahdaran/{roadItemsProject}', 'rahdaran')->name('rahdaran'); + Route::get('/files/{roadItemsProject}', 'files')->name('files'); + }); + Route::prefix('reports') + ->name('reports.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadItem\ReportController::class) + ->group(function () { + Route::get('/get_sub_items', 'getSubItems')->name('getSubItems'); + Route::get('/country_activity_per_sub_item', 'countryActivityPerSubItem')->name('countryActivityPerSubItem'); + Route::get('/province_activity_per_sub_item', 'provinceActivityPerSubItem')->name('provinceActivityPerSubItem'); + Route::get('/country_activity_per_item', 'countryActivityPerItem')->name('countryActivityPerItem'); + Route::get('/province_activity_per_item', 'provinceActivityPerItem')->name('provinceActivityPerItem'); + Route::get('/country_activity_excel_per_item', 'countryActivityExcelPerItem')->name('countryActivityExcelPerItem'); + Route::get('/province_activity_excel_per_item', 'provinceActivityExcelPerItem')->name('provinceActivityExcelPerItem'); + Route::get('/country_activity_excel_per_sub_item', 'countryActivityExcelPerSubItem')->name('countryActivityExcelPerSubItem'); + Route::get('/province_activity_excel_per_sub_item', 'provinceActivityExcelPerSubItem')->name('provinceActivityExcelPerSubItem'); + Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap'); + Route::get('/show_on_map/{roadItemsProject}', 'showOnMap')->name('showOnMap'); + }); + Route::prefix('webservice') + ->name('webservice.') + ->controller(RoadItemController::class) + ->group(function () { + Route::get('/', 'getRoadItems')->name('getRoadItem'); + }); }); Route::prefix('cmms_machines') ->name('cmms_machines.') ->controller(CMMSMachinesController::class) ->group(function () { + Route::get('/', 'index')->name('index'); Route::get('/list', 'list')->name('list'); Route::get('/search', 'search')->name('search'); }); @@ -200,8 +185,13 @@ Route::prefix('rahdaran') ->name('rahdaran.') ->controller(RahdaranController::class) ->group(function () { + Route::get('/', 'index')->name('index'); Route::get('/list', 'list')->name('list'); Route::get('/search', 'search')->name('search'); + Route::post('/', 'store')->name('store'); + Route::get('/{rahdaran}', 'show')->name('show'); + Route::post('/{rahdaran}', 'update')->name('update'); + Route::delete('/{rahdaran}', 'destroy')->name('destroy'); }); Route::prefix('fms_vehicle') @@ -215,37 +205,58 @@ Route::prefix('observed_items') ->name('observedItem.') ->controller(ObservedItemController::class) ->group(function () { + Route::post('/', 'store')->name('store'); Route::get('/filter', 'filter')->name('filter'); Route::get('/{observedItem}', 'show')->name('show'); }); -Route::prefix('road_item_reports') - ->name('roadItemReports.') - ->controller(RoadItemsReportController::class) +Route::prefix('road_patrols') ->group(function () { - Route::get('/get_sub_items', 'getSubItems')->name('getSubItems'); - Route::get('/country_activity_per_sub_item', 'countryActivityPerSubItem')->name('countryActivityPerSubItem'); - Route::get('/province_activity_per_sub_item', 'provinceActivityPerSubItem')->name('provinceActivityPerSubItem'); - Route::get('/country_activity_per_item', 'countryActivityPerItem')->name('countryActivityPerItem'); - Route::get('/province_activity_per_item', 'provinceActivityPerItem')->name('provinceActivityPerItem'); - Route::get('/country_activity_excel_per_item', 'countryActivityExcelPerItem')->name('countryActivityExcelPerItem'); - Route::get('/province_activity_excel_per_item', 'provinceActivityExcelPerItem')->name('provinceActivityExcelPerItem'); - Route::get('/country_activity_excel_per_sub_item', 'countryActivityExcelPerSubItem')->name('countryActivityExcelPerSubItem'); - Route::get('/province_activity_excel_per_sub_item', 'provinceActivityExcelPerSubItem')->name('provinceActivityExcelPerSubItem'); - Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap'); - Route::get('/show_on_map/{roadItemsProject}', 'showOnMap')->name('showOnMap'); - }); + Route::prefix('details') + ->name('details.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadPatrol\DetailController::class) + ->group(function () { + Route::get('/{roadPatrol}', 'show')->name('show'); + Route::get('/machines/{roadPatrol}', 'machines')->name('machines'); + Route::get('/rahdaran/{roadPatrol}', 'rahdaran')->name('rahdaran'); + }); -Route::prefix('road_patrol_reports') - ->name('roadPatrolReports.') - ->controller(RoadPatrolReportController::class) - ->group(function () { - Route::get('/country_activity', 'countryPatrolActivity')->name('countryPatrolActivity'); - Route::get('/province_activity', 'provincePatrolActivity')->name('provincePatrolActivity'); - Route::get('/country_activity_excel', 'countryActivityExcel')->name('countryActivityExcel'); - Route::get('/province_activity_excel', 'provinceActivityExcel')->name('provinceActivityExcel'); - Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap'); - Route::get('/show_on_map/{roadPatrol}', 'showOnMap')->name('showOnMap'); + Route::prefix('operator') + ->name('operator.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadPatrol\OperatorController::class) + ->group(function () { + Route::get('/', 'index')->middleware('permission:add-road-patrol')->name('index'); + Route::get('/excel', 'excel')->name('excel'); + Route::post('/delete/{roadPatrol}', 'delete') + ->middleware('permission:partial-delete-road-patrol|complete-delete-road-patrol') + ->name('delete'); + Route::post('/store', 'store') + ->middleware(['permission:add-road-patrol', 'validate-store-access']) + ->name('store'); + }); + + Route::prefix('report') + ->name('report.') + ->controller(ReportController::class) + ->group(function () { + Route::get('/country_activity', 'countryPatrolActivity')->name('countryPatrolActivity'); + Route::get('/province_activity', 'provincePatrolActivity')->name('provincePatrolActivity'); + Route::get('/country_activity_excel', 'countryActivityExcel')->name('countryActivityExcel'); + Route::get('/province_activity_excel', 'provinceActivityExcel')->name('provinceActivityExcel'); + Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap'); + Route::get('/show_on_map/{roadPatrol}', 'showOnMap')->name('showOnMap'); + Route::get('/{roadPatrol}', 'getReport')->name('getReport'); + }); + + Route::prefix('supervisor') + ->name('supervisor.') + ->controller(\App\Http\Controllers\V3\Dashboard\RoadPatrol\SupervisorController::class) + ->group(function () { + Route::get('/','index') + ->middleware(['permission:show-road-patrol-supervise-cartable|show-road-patrol-supervise-cartable-province']) + ->name('index'); + Route::get('/excel', 'excel')->name('excel'); + }); }); Route::prefix('damages') @@ -384,20 +395,36 @@ Route::prefix('safety_and_privacy') Route::post('/confirm/{safetyAndPrivacy}', 'confirm')->name('confirm'); Route::post('/reject/{safetyAndPrivacy}', 'reject')->name('reject'); }); - }); + Route::prefix('operator_report') + ->name('operatorReport.'); + Route::prefix('access_road') + ->name('accessRoad.') + ->controller(AccessRoadActivityController::class) + ->group(function () { + Route::get('/country_activity', 'countryActivity')->name('countryActivity'); + Route::get('/province_activity', 'provinceActivity')->name('provinceActivity'); + Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity'); + Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity'); + }); + Route::prefix('construction_activity') + ->name('constructionActivity.') + ->controller(ConstructionActivityController::class) + ->group(function () { + Route::get('/country_activity', 'countryActivity')->name('countryActivity'); + Route::get('/province_activity', 'provinceActivity')->name('provinceActivity'); + Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity'); + Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity'); + }); + Route::prefix('utility_passing_activity') + ->name('utilityPassingActivity.') + ->controller(UtilityPassingActivityController::class) + ->group(function () { + Route::get('/country_activity', 'countryActivity')->name('countryActivity'); + Route::get('/province_activity', 'provinceActivity')->name('provinceActivity'); + Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity'); + Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity'); + }); -Route::prefix('safety_and_privacy_report') - ->name('SafetyAndPrivacyReport.') - ->group(function () { - Route::prefix('operator') - ->name('operator.') - ->controller(OperatorReportController::class) - ->group(function () { - Route::get('/country_activity', 'countryActivity')->name('countryActivity'); - Route::get('/province_activity', 'provinceActivity')->name('provinceActivity'); - Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity'); - Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity'); - }); }); Route::prefix('otp') @@ -457,17 +484,22 @@ Route::prefix('missions') }); Route::name('transportationUnit.') ->prefix('transportation_unit') + ->middleware('permission:manage-transportation-unit') ->controller(TransportationUnitController::class) ->group(function () { Route::get('/', 'index')->name('index'); Route::post('/allocate/{mission}', 'allocate')->name('allocate'); Route::post('/deallocate/{mission}', 'deallocate')->name('deallocate'); + Route::post('/machines_list/{mission}', 'machinesList')->name('machinesList'); }); Route::name('controlUnit.') ->prefix('control_unit') + ->middleware('permission:manage-control-unit') ->controller(ControlUnitController::class) ->group(function () { Route::get('/', 'index')->name('index'); + Route::post('/start/{mission}', 'start')->name('start'); + Route::post('/finish/{mission}', 'finish')->name('finish'); }); Route::prefix('details') ->name('details.') @@ -477,3 +509,53 @@ Route::prefix('missions') Route::get('/rahdaran/{mission}', 'rahdaran')->name('rahdaran'); }); }); +Route::prefix('harim') + ->name('harim.') + ->group(function () { + Route::prefix('province_office') + ->name('province_office.') + ->controller(ProvinceOfficeController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/feedback/{harim}', 'feedback')->name('feedback'); + Route::get('/{harim}', 'show')->name('show'); + }); + Route::prefix('harim_office') + ->name('harim_office.') + ->controller(HarimOfficeController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/reject_request/{harim}', 'rejectRequest')->name('rejectRequest'); + Route::post('/need_road_access/{harim}', 'needRoadAccess')->name('needRoadAccess'); + Route::post('/without_road_access/{harim}', 'withoutRoadAccess')->name('withoutRoadAccess'); + Route::post('/file_accepted/{harim}', 'fileAccepted')->name('fileAccepted'); + Route::post('/file_rejected/{harim}', 'fileRejected')->name('fileRejected'); + Route::get('/{harim}', 'show')->name('show'); + }); + Route::prefix('technical_deputy') + ->name('technical_deputy.') + ->controller(TechnicalDeputyController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/confirm_request/{harim}', 'confirmRequest')->name('confirmRequest'); + Route::post('/refer_request/{harim}', 'referRequest')->name('referRequest'); + Route::post('/confirm_road_access/{harim}', 'confirmRoadAccess')->name('confirmRoadAccess'); + Route::post('/refer_road_access/{harim}', 'referRoadAccess')->name('referRoadAccess'); + Route::get('/{harim}', 'show')->name('show'); + }); + Route::prefix('general_manager') + ->name('general_manager.') + ->controller(GeneralManagerController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/reject_request/{harim}', 'rejectRequest')->name('rejectRequest'); + Route::post('/refer_request/{harim}', 'referRequest')->name('referRequest'); + Route::post('/refer_file/{harim}', 'referFile')->name('referFile'); + Route::post('/confirm_road_access_need/{harim}', 'confirmRoadAccessNeed')->name('confirmRoadAccessNeed'); + Route::post('/confirm_no_road_access_need/{harim}', 'confirmNoRoadAccessNeed')->name('confirmNoRoadAccessNeed'); + Route::post('/confirm_road_access_edit_need/{harim}', 'confirmRoadAccessEditNeed')->name('confirmRoadAccessEditNeed'); + Route::post('/confirm_guarantee_letter_need/{harim}', 'confirmGuaranteeLetterNeed')->name('confirmGuaranteeLetterNeed'); + Route::get('/{harim}', 'show')->name('show'); + }); + }); +