Merge branch 'develop' into 'main'
change structure of road patrol and route See merge request witelgroup/rms_v2!158
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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";
|
||||
|
||||
25
app/Enums/HarimAction.php
Normal file
25
app/Enums/HarimAction.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum HarimAction: int
|
||||
{
|
||||
case FEEDBACK = 1;
|
||||
case YES = 2;
|
||||
case NO = 3;
|
||||
case CONFIRM = 4;
|
||||
case REFER = 5;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => "بازخورد",
|
||||
2 => "بله",
|
||||
3 => "خیر",
|
||||
4 => "تائید کردن",
|
||||
5 => "ارجاع",
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
46
app/Enums/HarimStates.php
Normal file
46
app/Enums/HarimStates.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum HarimStates: int
|
||||
{
|
||||
case BARESI_EDARE_SHAHRESTAN = 1;
|
||||
case BARESI_TAVASOT_DAFTAR_HARIM = 2;
|
||||
case BARESI_TAVASOT_MOAVEN = 3;
|
||||
case BARESI_TAVASOT_MODIR_KOL = 4;
|
||||
case BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM = 5;
|
||||
case BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN = 6;
|
||||
case BARESI_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL = 7;
|
||||
case ERSAL_ZEMANAT_NAME_TAVASOTE_KARBAR =8;
|
||||
case ERSAL_BE_PANJAREH_VAHED_NIAZ_BE_RAH_DASTRASI = 9;
|
||||
case EMKAN_PAZIR_NEMEBASHAD = 10;
|
||||
case ERSAL_BE_PANJAREH_VAHED_BEDONEH_NIAZ_BE_RAH_DASTRASI = 11;
|
||||
case UPDATE_FILE_BARGOZARE_SHODE = 12;
|
||||
case TAEDE_ARSE_VA_AYAN_ERSAL_SHODE_TAVASOT_DAFTAR_KARBAR = 13;
|
||||
case TAEDE_ARSE_VA_AYAN_ERSAL_SHODE_TAVASOT_TAVASOTE_MOAVEN = 14;
|
||||
case TAEDE_ARSE_VA_AYAN_ERSAL_SHODE_TAVASOT_MODIR_KOL = 15;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => "بررسی ادارات شهرستان",
|
||||
2 => "بررسی توسط ادارات حریم",
|
||||
3 => "بررسی توسط معاون ",
|
||||
4 => "بررسی توسط مدیر کل",
|
||||
5 => "بررسی فایل آپلود شده توسط اداره حریم",
|
||||
6 => "بررسی فایل آپلود شده توسط معاون",
|
||||
7 => "بررسی فایل آپلود شده توسط مدیر",
|
||||
8 => "ارسال ضمانت نامه توسط کاربر",
|
||||
9 => "ارسال به پنجره واحد ( نیاز به راه دسترسی)",
|
||||
10 => "امکان پذیر نمی باشد",
|
||||
11 => "ارسال به پنجره واحد (بدون نیاز به راه دسترسی)",
|
||||
12 => "بازبینی فایل بارگذاری شده",
|
||||
13 => "تائید عرصه و اعیان ارسال شده توسط اداره حریم",
|
||||
14 => "تائید عرصه و اعیان ارسال شده توسط معاون",
|
||||
15 => "تائید عرصه و اعیان ارسال شده توسط مدیر",
|
||||
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
22
app/Enums/MissionCategory.php
Normal file
22
app/Enums/MissionCategory.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum MissionCategory: int
|
||||
{
|
||||
case ROAD_ITEM= 1;
|
||||
case ROAD_PATROL = 2;
|
||||
case ROAD_OBSERVATION = 3;
|
||||
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => "فعالیت روزانه",
|
||||
2 => "گشت راهداری",
|
||||
3 => "واکنش سریع",
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
19
app/Enums/MissionTypes.php
Normal file
19
app/Enums/MissionTypes.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum MissionTypes: int
|
||||
{
|
||||
case SAATY= 1;
|
||||
case ROZANE = 2;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => 'ساعتی',
|
||||
2 => 'روزانه',
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
21
app/Enums/MissionZones.php
Normal file
21
app/Enums/MissionZones.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum MissionZones: int
|
||||
{
|
||||
case DAKHEL_SHAHR= 1;
|
||||
case BIRON_SHAHR_DHAKHEL_MAHDODE = 2;
|
||||
case BIRON_SHAHR_BIRON_MAHDODE = 3;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => 'داخل شهر',
|
||||
2 => 'بیرون شهر (داخل محدوده)',
|
||||
3 => 'بیرون شهر (بیرون محدوده)',
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
@@ -2667,6 +2667,12 @@ enum NikarayanComplaints: int
|
||||
"ProvinceID" => "21",
|
||||
"InvarID" => 497
|
||||
],
|
||||
437 => [
|
||||
"OnvarID" => 437,
|
||||
"CityName" => "آزادراه کاشان-قم",
|
||||
"ProvinceID" => "4",
|
||||
"InvarID" => 804
|
||||
],
|
||||
];
|
||||
return $nikarayanToRmsCityId[$city_id]["InvarID"];
|
||||
}
|
||||
|
||||
83
app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php
Normal file
83
app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy\Country;
|
||||
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AccessRoadReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private array $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = $this->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];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy\Country;
|
||||
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
|
||||
public function __construct(private array $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = $this->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];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy\Country;
|
||||
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class UtilityPassingReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
|
||||
public function __construct(private array $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = $this->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];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy\Province;
|
||||
|
||||
use App\Models\EdarateShahri;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AccessRoadReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private array $data, public Request $request){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = $this->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];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy\Province;
|
||||
|
||||
use App\Models\EdarateShahri;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private array $data, public Request $request){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = $this->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];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy\Province;
|
||||
|
||||
use App\Models\EdarateShahri;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class UtilityPassingReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private array $data, public Request $request){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = $this->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];
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmRoadAccessEditNeedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmRoadAccessNeedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmGuaranteeLetterNeedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmNoRoadAccessNeedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ReferFileRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ReferRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\RejectRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ShowRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GeneralManagerController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()
|
||||
->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'));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\FileRejectedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\FileAcceptedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\RejectRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\ShowRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\NeedRoadAccessRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\WithoutRoadAccessRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class HarimOfficeController extends Controller
|
||||
{
|
||||
use ApiResponse ;
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()
|
||||
->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'));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\FeedBackRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\ShowRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProvinceOfficeController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ConfirmRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ConfirmRoadAccessRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ReferRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ReferRoadAccessRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ShowRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TechnicalDeputyController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()
|
||||
->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'));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadItem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DetailController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function machines(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 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']));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadItem;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Exports\V3\RoadItemsProjects\OperatorCartableReport;
|
||||
use App\Facades\File\FileFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\RoadItem\Operator\StoreRequest;
|
||||
use App\Http\Requests\V3\RoadItem\Operator\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\Mission;
|
||||
use App\Models\ObservedItem;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Services\Cartables\RoadItem\OperatorService;
|
||||
use App\Services\NominatimService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
|
||||
class OperatorController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$data = $operatorService->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();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadItem;
|
||||
|
||||
use App\Exports\V3\RoadItemsProjects\CountryActivityPerItemReport;
|
||||
use App\Exports\V3\RoadItemsProjects\CountryActivityPerSubItemReport;
|
||||
@@ -12,15 +12,16 @@ use App\Models\EdarateShahri;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\Province;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Services\Cartables\RoadItemTableService;
|
||||
use App\Services\Cartables\RoadItem\ReportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class RoadItemsReportController extends Controller
|
||||
class ReportController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function getSubItems(): JsonResponse
|
||||
{
|
||||
$data = InfoItem::all();
|
||||
@@ -32,9 +33,9 @@ class RoadItemsReportController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function countryActivityPerSubItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||
public function countryActivityPerSubItem(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
$activities = $roadItemTableService->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)
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadItem;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Exports\V3\RoadItemsProjects\SupervisorCartableReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\RoadItem\Supervisor\ConfirmRequest;
|
||||
use App\Http\Requests\V3\RoadItem\Supervisor\RejectRequest;
|
||||
use App\Http\Requests\V3\RoadItem\VerifyBySupervisorRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Services\Cartables\RoadItem\SupervisorService;
|
||||
use App\Services\Cartables\RoadItemTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
|
||||
class SupervisorController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SupervisorService $supervisorService): JsonResponse
|
||||
{
|
||||
$data = $supervisorService->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();
|
||||
}
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
|
||||
use App\Exports\V3\RoadItemsProjects\OperatorCartableReport;
|
||||
use App\Exports\V3\RoadItemsProjects\SupervisorCartableReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\RoadItemsProject\StoreRequest;
|
||||
use App\Http\Requests\V3\RoadItemsProject\UpdateRequest;
|
||||
use App\Http\Requests\V3\RoadItemsProject\VerifyBySupervisorRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Services\NominatimService;
|
||||
use App\Services\Cartables\RoadItemTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class RoadItemsProjectController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function supervisorIndex(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||
{
|
||||
$data = $roadItemTableService->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']));
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadPatrol;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Models\RoadPatrol;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class DetailController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
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 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']));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadPatrol;
|
||||
|
||||
|
||||
use App\Exports\V3\RoadPatrols\OperatorCartableReport;
|
||||
use App\Facades\Sms\Sms;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\RoadPatrol\DeleteRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Mission;
|
||||
use App\Models\RoadPatrol;
|
||||
use App\Services\Cartables\RoadPatrol\OperatorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
|
||||
class OperatorController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$data = $operatorService->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();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadPatrol;
|
||||
|
||||
use App\Exports\V3\RoadPatrols\CountryActivity;
|
||||
use App\Exports\V3\RoadPatrols\ProvinceActivity;
|
||||
@@ -8,69 +8,16 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Models\RoadPatrol;
|
||||
use App\Services\Cartables\RoadPatrolTableService;
|
||||
use App\Services\Cartables\RoadPatrol\ReportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class RoadPatrolReportController extends Controller
|
||||
class ReportController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function countryPatrolActivity(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
|
||||
{
|
||||
$activities = $roadPatrolTableService->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\RoadPatrol;
|
||||
|
||||
use App\Exports\V3\RoadPatrols\SupervisorCartableReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Services\Cartables\RoadPatrol\SupervisorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
|
||||
class SupervisorController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SupervisorService $supervisorService): JsonResponse
|
||||
{
|
||||
$data = $supervisorService->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);
|
||||
}
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
|
||||
use App\Exports\V3\RoadPatrols\OperatorCartableReport;
|
||||
use App\Exports\V3\RoadPatrols\SupervisorCartableReport;
|
||||
use App\Facades\Sms\Sms;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\RoadPatrolProject\DeleteRequest;
|
||||
use App\Http\Requests\V3\RoadPatrolProject\StoreRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Models\RoadPatrol;
|
||||
use App\Services\NominatimService;
|
||||
use App\Services\Cartables\RoadPatrolTableService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class RoadPatrolProjectController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function supervisorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
|
||||
{
|
||||
$data = $roadPatrolTableService->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']));
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -1,53 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReport;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\Country\AccessRoadReport as ExcelReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\Province\AccessRoadReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class OperatorReportController extends Controller
|
||||
class AccessRoadActivityController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReport;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\Country\ConstructionReport as ExcelReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\Province\ConstructionReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class ConstructionActivityController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReport;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\Country\UtilityPassingReport as ExcelReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\Province\UtilityPassingReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class UtilityPassingActivityController extends Controller
|
||||
{
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
25
app/Http/Controllers/V3/WebServices/RoadItemController.php
Normal file
25
app/Http/Controllers/V3/WebServices/RoadItemController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\WebServices;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\WebServices\RoadItem\IndexRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class RoadItemController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(IndexRequest $request): JsonResponse
|
||||
{
|
||||
$fromDate = $request->from_date;
|
||||
$toDate = $request->to_date;
|
||||
$roadItems = RoadItemsProject::query()
|
||||
->where('is_new', '=', 1)
|
||||
->whereBetween('activity_date_time', [$fromDate, $toDate])
|
||||
->get();
|
||||
|
||||
return $this->successResponse($roadItems);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\WebServices;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\WebServices\RoadMaintenanceStation\IndexRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\RahdariPoint;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoadMaintenanceStationController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(IndexRequest $request): JsonResponse
|
||||
{
|
||||
$province = $request->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmRoadAccessRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRequest.php
Normal file
30
app/Http/Requests/V3/Dashboard/Harim/Deputy/ReferRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReferRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReferRoadAccessRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/V3/Dashboard/Harim/Deputy/ShowRequest.php
Normal file
33
app/Http/Requests/V3/Dashboard/Harim/Deputy/ShowRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ShowRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmGuaranteeLetterNeedRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmNoRoadAccessNeedRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmRoadAccessEditNeedRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmRoadAccessNeedRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReferFileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReferRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ShowRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FileAcceptedRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FileRejectedRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NeedRoadAccessRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ShowRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class WithoutRoadAccessRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FeedBackRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ShowRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php
Normal file
30
app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\ControlUnit;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FinishRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->mission->state_id == MissionStates::START_MISSION->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Http/Requests/V3/Mission/ControlUnit/StartRequest.php
Normal file
45
app/Http/Requests/V3/Mission/ControlUnit/StartRequest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\ControlUnit;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StartRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->mission->state_id == MissionStates::PENDING_CONFIRMATION->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
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',
|
||||
'کد وارد شده صحیح نمی باشد'
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
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',
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
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',
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
36
app/Http/Requests/V3/ObservedItem/StoreRequest.php
Normal file
36
app/Http/Requests/V3/ObservedItem/StoreRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\ObservedItem;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|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',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/V3/Rahdaran/StoreRequest.php
Normal file
30
app/Http/Requests/V3/Rahdaran/StoreRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Rahdaran;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'code' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/V3/Rahdaran/UpdateRequest.php
Normal file
30
app/Http/Requests/V3/Rahdaran/UpdateRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Rahdaran;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'code' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadItemsProject;
|
||||
namespace App\Http\Requests\V3\RoadItem\Operator;
|
||||
|
||||
use App\Models\Mission;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
@@ -18,11 +23,12 @@ class StoreRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
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'));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadItemsProject;
|
||||
namespace App\Http\Requests\V3\RoadItem\Operator;
|
||||
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
@@ -16,19 +13,25 @@ class UpdateRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return !($this->roadItemsProject->user_id != auth()->user()->id || $this->roadItemsProject->status != 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
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' => 'ساعت فعالیت',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/V3/RoadItem/Supervisor/ConfirmRequest.php
Normal file
30
app/Http/Requests/V3/RoadItem/Supervisor/ConfirmRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadItem\Supervisor;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class ConfirmRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('gate-supervise-road-item', $this->roadItemsProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'description' => 'string',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/V3/RoadItem/Supervisor/RejectRequest.php
Normal file
30
app/Http/Requests/V3/RoadItem/Supervisor/RejectRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadItem\Supervisor;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('gate-supervise-road-item', $this->roadItemsProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'description' => 'string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadItemsProject;
|
||||
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
|
||||
class VerifyBySupervisorRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('gate-supervise-road-item', $this->roadItemsProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'verify' => 'required|in:1,2',
|
||||
'description' => 'nullable|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadPatrolProject;
|
||||
namespace App\Http\Requests\V3\RoadPatrol;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadPatrolProject;
|
||||
|
||||
use App\Rules\VerificationCode;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|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' => 'ساعت پایان گشت',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
33
app/Http/Requests/V3/WebServices/RoadItem/IndexRequest.php
Normal file
33
app/Http/Requests/V3/WebServices/RoadItem/IndexRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\WebServices\RoadItem;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class IndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return
|
||||
$this->username === 'service_user257' &&
|
||||
Hash::check('S3rv1ce@123', $this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'from_date' => 'required|date_format:Y-m-d',
|
||||
'to_date' => 'required|date_format:Y-m-d',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\WebServices\RoadMaintenanceStation;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class IndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return
|
||||
$this->username === 'service_user257' &&
|
||||
Hash::check('S3rv1ce@123', $this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'province' => 'exists:provinces,id',
|
||||
'status' => 'in:0,1',
|
||||
'type' => 'in:1,2,3',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
26
app/Models/Harim.php
Normal file
26
app/Models/Harim.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Harim extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
|
||||
public function histories(): HasMany
|
||||
{
|
||||
return $this->hasMany(HarimHistory::class);
|
||||
}
|
||||
|
||||
protected function polygon(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => json_decode($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
13
app/Models/HarimAction.php
Normal file
13
app/Models/HarimAction.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HarimAction extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
|
||||
}
|
||||
18
app/Models/HarimHistory.php
Normal file
18
app/Models/HarimHistory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class HarimHistory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
|
||||
public function harim(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Harim::class);
|
||||
}
|
||||
}
|
||||
12
app/Models/HarimState.php
Normal file
12
app/Models/HarimState.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HarimState extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -13,11 +13,19 @@ class Mission extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
protected $hidden = ['pivot'];
|
||||
|
||||
protected function requestedMachines(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => 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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
42
app/Services/Cartables/Harim/FetchNewRequestsService.php
Normal file
42
app/Services/Cartables/Harim/FetchNewRequestsService.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Harim;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchNewRequestsService
|
||||
{
|
||||
protected string $url;
|
||||
protected string $channelName;
|
||||
protected string $username;
|
||||
protected string $password;
|
||||
public function __construct()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
30
app/Services/Cartables/RoadItem/OperatorService.php
Normal file
30
app/Services/Cartables/RoadItem/OperatorService.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\RoadItem;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OperatorService
|
||||
{
|
||||
public function dataTable(Request $request, $loadRelations = false)
|
||||
{
|
||||
$query = RoadItemsProject::query()
|
||||
->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'
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables;
|
||||
namespace App\Services\Cartables\RoadItem;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RoadItemTableService
|
||||
class ReportService
|
||||
{
|
||||
public function supervisorCartableReport(Request $request, $loadRelations = false)
|
||||
{
|
||||
$allowedFilters = ['*'];
|
||||
$allowedSortings = ['*'];
|
||||
|
||||
$user = auth()->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();
|
||||
46
app/Services/Cartables/RoadItem/SupervisorService.php
Normal file
46
app/Services/Cartables/RoadItem/SupervisorService.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\RoadItem;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Illuminate\Http\Request;
|
||||
use Throwable;
|
||||
|
||||
class SupervisorService
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function dataTable(Request $request, $loadRelations = false)
|
||||
{
|
||||
$user = auth()->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'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user