Merge branch 'develop' into 'main'
Develop See merge request witelgroup/rms_v2!91
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -32,15 +32,14 @@ class SendRoadObservationToNikarayanCommand extends Command
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$this->info("Dispatching jobs with a delay between each...");
|
$this->info("Dispatching jobs with a delay between each...");
|
||||||
|
|
||||||
DB::transaction(function () use ($count) {
|
DB::transaction(function () use (&$count) {
|
||||||
$delay = 0;
|
$delay = 0;
|
||||||
RoadObserved::query()
|
RoadObserved::query()
|
||||||
->whereBetween('StartTime_DateTime_fa', ['1403-01-01 00:00:00', '1403-07-13 23:59:59'])
|
->whereBetween('StartTime_DateTime_fa', ['1403-01-01 00:00:00', '1403-07-13 23:59:59'])
|
||||||
->where('rms_status', '=', 0)
|
->chunkById(50, function ($roads) use (&$delay, &$count) {
|
||||||
->chunkById(50, function ($roads) use ($delay, $count) {
|
|
||||||
foreach ($roads as $road) {
|
foreach ($roads as $road) {
|
||||||
$road->update(['rms_status' => 1]);
|
$road->update(['status' => 1]);
|
||||||
SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addMinutes(10)->addSeconds($delay));
|
SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addSeconds($delay));
|
||||||
Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled with a {$delay} seconds delay.");
|
Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled with a {$delay} seconds delay.");
|
||||||
$this->info("Scheduled job for Road ID: {$road->id} {$delay}s");
|
$this->info("Scheduled job for Road ID: {$road->id} {$delay}s");
|
||||||
$delay += 3;
|
$delay += 3;
|
||||||
|
|||||||
28
app/Enums/AccidentStates.php
Normal file
28
app/Enums/AccidentStates.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum AccidentStates: int
|
||||||
|
{
|
||||||
|
case BEDON_EGHDAM= 0;
|
||||||
|
case SODOR_NAME_BIME_VA_DAGHI = 1;
|
||||||
|
case SABT_FISH = 2;
|
||||||
|
|
||||||
|
case SODOR_FACTOR = 3;
|
||||||
|
case PARDAKHT_FACTOR = 4;
|
||||||
|
case SODOR_NAME_POLICE_RAH = 5;
|
||||||
|
|
||||||
|
public static function name(int $state): string
|
||||||
|
{
|
||||||
|
$mapArray = [
|
||||||
|
0 => "بدون اقدام",
|
||||||
|
1 => "صدور نامه بیمه و کارشناسی داغی",
|
||||||
|
2 => "فیش ها ثبت شده است.",
|
||||||
|
3 => "فاکتور صادر شده است.",
|
||||||
|
4 => "فاکتور پرداخت شده است",
|
||||||
|
5 => "نامه پلیس راه صادر شده است (اتمام فرایند)",
|
||||||
|
];
|
||||||
|
|
||||||
|
return $mapArray[$state];
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Enums/AxisTypes.php
Normal file
26
app/Enums/AxisTypes.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum AxisTypes: int
|
||||||
|
{
|
||||||
|
case AZADRAH= 1;
|
||||||
|
case BOZORGRAH = 2;
|
||||||
|
case ASLI = 3;
|
||||||
|
|
||||||
|
case FARYI = 4;
|
||||||
|
case ROSTAYI = 5;
|
||||||
|
|
||||||
|
public static function name(int $state): string
|
||||||
|
{
|
||||||
|
$mapArray = [
|
||||||
|
1 => 'آزادراه',
|
||||||
|
2 => 'بزرگراه',
|
||||||
|
3 => 'اصلی',
|
||||||
|
4 => 'فرعی',
|
||||||
|
5 => 'روستایی',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $mapArray[$state];
|
||||||
|
}
|
||||||
|
}
|
||||||
2643
app/Enums/NikarayanComplaints.php
Normal file
2643
app/Enums/NikarayanComplaints.php
Normal file
File diff suppressed because it is too large
Load Diff
26
app/Exceptions/ProhibitedAction.php
Normal file
26
app/Exceptions/ProhibitedAction.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class ProhibitedAction extends Exception
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function __construct(public $message = "", int $code = 422, ?Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the exception into an HTTP response.
|
||||||
|
*/
|
||||||
|
public function render(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->errorResponse($this->message);
|
||||||
|
}
|
||||||
|
}
|
||||||
125
app/Exports/V3/AccidentReceipt/CountryReport.php
Normal file
125
app/Exports/V3/AccidentReceipt/CountryReport.php
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\AccidentReceipt;
|
||||||
|
|
||||||
|
use App\Models\Province;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
|
class CountryReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||||
|
{
|
||||||
|
public function __construct(private array $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
$data = $this->data;
|
||||||
|
|
||||||
|
$country = array_search(-1, array_column($data['data'], 'province_id'));
|
||||||
|
|
||||||
|
$activities[] = [
|
||||||
|
'name' => 'کل کشور',
|
||||||
|
'tedade' => $data['data'][$country]->tedade,
|
||||||
|
'police_rah' => $data['data'][$country]->police_rah,
|
||||||
|
'gozaresh_gasht' => $data['data'][$country]->gozaresh_gasht,
|
||||||
|
'kol_sabt_shode' => $data['data'][$country]->kol_sabt_shode,
|
||||||
|
'vasel_shode' => $data['data'][$country]->vasel_shode ?? 0,
|
||||||
|
'vasel_shode_bimeh' => $data['data'][$country]->vasel_shode_bimeh ?? 0,
|
||||||
|
'vasel_shode_daghi' => $data['data'][$country]->vasel_shode_daghi ?? 0,
|
||||||
|
'vasel_shode_final' => $data['data'][$country]->vasel_shode_final ?? 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (Province::all() as $province) {
|
||||||
|
|
||||||
|
$existingProvince = array_search($province->id, array_column($data['data'], 'province_id'));
|
||||||
|
|
||||||
|
if ($existingProvince) {
|
||||||
|
$activities[] = [
|
||||||
|
'name' => $province->name_fa,
|
||||||
|
'tedade' => $data['data'][$existingProvince]->tedade,
|
||||||
|
'police_rah' => $data['data'][$existingProvince]->police_rah,
|
||||||
|
'gozaresh_gasht' => $data['data'][$existingProvince]->gozaresh_gasht,
|
||||||
|
'kol_sabt_shode' => $data['data'][$existingProvince]->kol_sabt_shode,
|
||||||
|
'vasel_shode' => $data['data'][$existingProvince]->vasel_shode ?? 0,
|
||||||
|
'vasel_shode_bimeh' => $data['data'][$existingProvince]->vasel_shode_bimeh ?? 0,
|
||||||
|
'vasel_shode_daghi' => $data['data'][$existingProvince]->vasel_shode_daghi ?? 0,
|
||||||
|
'vasel_shode_final' => $data['data'][$existingProvince]->vasel_shode_final ?? 0,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$activities[] = [
|
||||||
|
'name' => $province->name_fa,
|
||||||
|
'tedade' => "",
|
||||||
|
'police_rah' => "",
|
||||||
|
'gozaresh_gasht' => "",
|
||||||
|
'kol_sabt_shode' => "",
|
||||||
|
'vasel_shode' => "",
|
||||||
|
'vasel_shode_bimeh' => "",
|
||||||
|
'vasel_shode_daghi' => "",
|
||||||
|
'vasel_shode_final' => "",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('v3.Reports.AccidentReceipt.CountryReport', [
|
||||||
|
'data' => $activities,
|
||||||
|
'fromDate' => $data['fromDate'],
|
||||||
|
'toDate' => $data['toDate'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
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('B1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function styles(Worksheet $sheet): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// Style the first row as bold text.
|
||||||
|
'A:BA' => [
|
||||||
|
'font' => [
|
||||||
|
'name' => 'B Nazanin'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
75
app/Exports/V3/AccidentReceipt/DataTableReport.php
Normal file
75
app/Exports/V3/AccidentReceipt/DataTableReport.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\AccidentReceipt;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
|
class DataTableReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||||
|
{
|
||||||
|
public function __construct(private Collection $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view('v3.Reports.AccidentReceipt.DataTableReport', [
|
||||||
|
'data' => $this->data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function drawings()
|
||||||
|
{
|
||||||
|
$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('B1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function styles(Worksheet $sheet)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// Style the first row as bold text.
|
||||||
|
'A:BA' => [
|
||||||
|
'font' => [
|
||||||
|
'name' => 'B Nazanin'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
125
app/Exports/V3/AccidentReceipt/ProvinceReport.php
Normal file
125
app/Exports/V3/AccidentReceipt/ProvinceReport.php
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\AccidentReceipt;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
|
class ProvinceReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||||
|
{
|
||||||
|
public function __construct(private array $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
$inputData = $this->data;
|
||||||
|
$reportData =$inputData['report'];
|
||||||
|
|
||||||
|
$province = array_search(-1, array_column($reportData, 'province_id'));
|
||||||
|
|
||||||
|
$activities[] = [
|
||||||
|
'name' => 'کل استان',
|
||||||
|
'tedade' => $reportData['data'][$province]->tedade,
|
||||||
|
'police_rah' => $reportData['data'][$province]->police_rah,
|
||||||
|
'gozaresh_gasht' => $reportData['data'][$province]->gozaresh_gasht,
|
||||||
|
'kol_sabt_shode' => $reportData['data'][$province]->kol_sabt_shode,
|
||||||
|
'vasel_shode' => $reportData['data'][$province]->vasel_shode ?? 0,
|
||||||
|
'vasel_shode_bimeh' => $reportData['data'][$province]->vasel_shode_bimeh ?? 0,
|
||||||
|
'vasel_shode_daghi' => $reportData['data'][$province]->vasel_shode_daghi ?? 0,
|
||||||
|
'vasel_shode_final' => $reportData['data'][$province]->vasel_shode_final ?? 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($inputData['cities'] as $city) {
|
||||||
|
|
||||||
|
$existingCity = array_search($city->id, array_column($reportData['data'], 'city_id'));
|
||||||
|
|
||||||
|
if ($existingCity) {
|
||||||
|
$activities[] = [
|
||||||
|
'name' => $city->name_fa,
|
||||||
|
'tedade' => $reportData['data'][$existingCity]->tedade,
|
||||||
|
'police_rah' => $reportData['data'][$existingCity]->police_rah,
|
||||||
|
'gozaresh_gasht' => $reportData['data'][$existingCity]->gozaresh_gasht,
|
||||||
|
'kol_sabt_shode' => $reportData['data'][$existingCity]->kol_sabt_shode,
|
||||||
|
'vasel_shode' => $reportData['data'][$existingCity]->vasel_shode ?? 0,
|
||||||
|
'vasel_shode_bimeh' => $reportData['data'][$existingCity]->vasel_shode_bimeh ?? 0,
|
||||||
|
'vasel_shode_daghi' => $reportData['data'][$existingCity]->vasel_shode_daghi ?? 0,
|
||||||
|
'vasel_shode_final' => $reportData['data'][$existingCity]->vasel_shode_final ?? 0,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$activities[] = [
|
||||||
|
'name' => $city->name_fa,
|
||||||
|
'tedade' => "",
|
||||||
|
'police_rah' => "",
|
||||||
|
'gozaresh_gasht' => "",
|
||||||
|
'kol_sabt_shode' => "",
|
||||||
|
'vasel_shode' => "",
|
||||||
|
'vasel_shode_bimeh' => "",
|
||||||
|
'vasel_shode_daghi' => "",
|
||||||
|
'vasel_shode_final' => "",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('v3.Reports.AccidentReceipt.ProvinceReport', [
|
||||||
|
'data' => $activities,
|
||||||
|
'fromDate' => $reportData['fromDate'],
|
||||||
|
'toDate' => $reportData['toDate'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function drawings()
|
||||||
|
{
|
||||||
|
$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('B1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function styles(Worksheet $sheet)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// Style the first row as bold text.
|
||||||
|
'A:BA' => [
|
||||||
|
'font' => [
|
||||||
|
'name' => 'B Nazanin'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
67
app/Exports/V3/RoadObservation/ComplaintsReport.php
Normal file
67
app/Exports/V3/RoadObservation/ComplaintsReport.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
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\Style\Alignment;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
|
||||||
|
class ComplaintsReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||||
|
{
|
||||||
|
public function __construct(private Collection $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view('v3.Reports.RoadObservation.ComplaintsReport', [
|
||||||
|
'data' => $this->data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial');
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/Exports/V3/RoadObservation/OperatorCartableReport.php
Normal file
70
app/Exports/V3/RoadObservation/OperatorCartableReport.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
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\Style\Alignment;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class OperatorCartableReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||||
|
{
|
||||||
|
public function __construct(private Collection $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view('v3.Reports.RoadObservation.OperatorCartableReport', [
|
||||||
|
'data' => $this->data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial');
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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('K1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
69
app/Exports/V3/RoadObservation/SupervisorCartableReport.php
Normal file
69
app/Exports/V3/RoadObservation/SupervisorCartableReport.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
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\Style\Alignment;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
|
||||||
|
class SupervisorCartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||||
|
{
|
||||||
|
public function __construct(private Collection $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
$data = $this->data;
|
||||||
|
|
||||||
|
return view('v3.Reports.RoadObservation.SupervisorCartableReport', [
|
||||||
|
'data' => $this->data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial');
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A:U')
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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('K1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
}
|
||||||
69
app/Exports/V3/SafetyAndPrivacy/CartableReport.php
Normal file
69
app/Exports/V3/SafetyAndPrivacy/CartableReport.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\SafetyAndPrivacy;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
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 CartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||||
|
{
|
||||||
|
public function __construct(private ?Collection $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view('v3.Reports.SafetyAndPrivacy.CartableReport', [
|
||||||
|
'data' => $this->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('B1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function styles(Worksheet $sheet): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A:BA' => [
|
||||||
|
'font' => [
|
||||||
|
'name' => 'B Nazanin'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
78
app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php
Normal file
78
app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\SafetyAndPrivacy;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
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 CountryActivityReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||||
|
{
|
||||||
|
public function __construct(private array $data){}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
$data = $this->data;
|
||||||
|
$existedProvinces = array_keys($data['activities']);
|
||||||
|
|
||||||
|
foreach (\App\Models\Province::all() as $value) {
|
||||||
|
$provinceId = $value->id;
|
||||||
|
|
||||||
|
if (!array_key_exists($provinceId, $existedProvinces)) {
|
||||||
|
$data['activities'][] = (object) [
|
||||||
|
'province_id' => $provinceId,
|
||||||
|
'name_fa' => $value->name_fa,
|
||||||
|
'sum' => 0,
|
||||||
|
'89' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'90' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'91' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('v3.Reports.SafetyAndPrivacy.CountryActivityReport', [
|
||||||
|
'data' => $data['activities'],
|
||||||
|
'fromDate' => $data['fromDate'],
|
||||||
|
'toDate' => $data['toDate'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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('K1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
}
|
||||||
81
app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php
Normal file
81
app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\SafetyAndPrivacy;
|
||||||
|
|
||||||
|
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 ProvinceActivityReport 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['activities']);
|
||||||
|
$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['activities'][] = (object) [
|
||||||
|
'edare_shahri_id' => $edareId,
|
||||||
|
'name_fa' => $value->name_fa,
|
||||||
|
'sum' => 0,
|
||||||
|
'89' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'90' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'91' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('v3.Reports.SafetyAndPrivacy.ProvinceActivityReport', [
|
||||||
|
'data' => $data['activities'],
|
||||||
|
'fromDate' => $data['fromDate'],
|
||||||
|
'toDate' => $data['toDate'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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('K1');
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
}
|
||||||
93
app/Http/Controllers/V3/DamageManagementController.php
Normal file
93
app/Http/Controllers/V3/DamageManagementController.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\Damage\StoreRequest;
|
||||||
|
use App\Http\Requests\V3\Damage\UpdateRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\Damage;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class DamageManagementController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$allowedFilters = ['*'];
|
||||||
|
$allowedSortings = ['*'];
|
||||||
|
|
||||||
|
$query = Damage::query();
|
||||||
|
|
||||||
|
$data = DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: $allowedFilters,
|
||||||
|
allowedSortings: $allowedSortings);
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list(): JsonResponse
|
||||||
|
{
|
||||||
|
$damages = Damage::query()->where('status', '=', 1)->get();
|
||||||
|
return $this->successResponse($damages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
Damage::query()->create([
|
||||||
|
'title' => $request->title,
|
||||||
|
'unit' => $request->unit,
|
||||||
|
'base_price' => $request->base_price,
|
||||||
|
'status' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Damage $damage): JsonResponse
|
||||||
|
|
||||||
|
{
|
||||||
|
return $this->successResponse($damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function update(UpdateRequest $request, Damage $damage): JsonResponse
|
||||||
|
|
||||||
|
{
|
||||||
|
$damage->update([
|
||||||
|
'title' => $request->title,
|
||||||
|
'unit' => $request->unit,
|
||||||
|
'base_price' => $request->base_price,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function activate(Damage $damage): JsonResponse
|
||||||
|
{
|
||||||
|
$damage->status == 1 ? $damage->update(['status' => 0]) : $damage->update(['status' => 1]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
342
app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php
Normal file
342
app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard;
|
||||||
|
|
||||||
|
use App\Enums\AccidentStates;
|
||||||
|
use App\Exports\V3\AccidentReceipt\DataTableReport;
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
|
use App\Facades\Sms\Sms;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\AccidentReceipt\ConfirmPaymentInfoRequest;
|
||||||
|
use App\Http\Requests\V3\AccidentReceipt\StoreRequest;
|
||||||
|
use App\Http\Requests\V3\AccidentReceipt\UpdateRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\Accident;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\DailyAccidentSettings;
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Services\Cartables\AccidentReceiptTableService;
|
||||||
|
use App\Services\NominatimService;
|
||||||
|
use App\Services\PaymentService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class AccidentReceiptController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index(Request $request, AccidentReceiptTableService $accidentReceiptTableService): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $accidentReceiptTableService->dataTable($request);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1122);
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function excelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
auth()->user()->addActivityComplete(1126);
|
||||||
|
$name = 'گزارش از خسارات وارده به ابنیه فنی و تاسیسات راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
$data = $accidentReceiptTableService->dataTable($request, true);
|
||||||
|
return Excel::download(new DataTableReport($data['data']), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accidentDamage(Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($accident->damages()->get(['unit', 'amount', 'value']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse
|
||||||
|
{
|
||||||
|
DB::transaction(function () use ($request, $nominatimService) {
|
||||||
|
|
||||||
|
$province = Province::query()->where('id', '=', $request->province_id)->first();
|
||||||
|
$city = City::query()->where('id', '=', $request->city_id)->first();
|
||||||
|
|
||||||
|
$accidentData = [
|
||||||
|
'province_id' => $province->id,
|
||||||
|
'province_fa' => $province->name_fa,
|
||||||
|
'city_id' => $city->id,
|
||||||
|
'city_fa' => $city->name_fa,
|
||||||
|
'axis_name' => $request->axis_name,
|
||||||
|
'driver_name' => $request->driver_name,
|
||||||
|
'plaque' => $request->plaque,
|
||||||
|
'driver_national_code' => $request->driver_national_code,
|
||||||
|
'driver_phone_number' => $request->driver_phone_number,
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lng' => $request->lng,
|
||||||
|
'accident_type' => $request->accident_type,
|
||||||
|
'accident_date' => $request->accident_date,
|
||||||
|
'accident_time' => $request->accident_time,
|
||||||
|
'accident_type_fa' => DailyAccidentSettings::query()->where('type', 'accident_type')->where('name', $request->accident_type)->first()->value,
|
||||||
|
'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng),
|
||||||
|
'report_base' => $request->report_base,
|
||||||
|
'police_file' => $request->report_base ? null : FileFacade::save($request->file('police_file'), 'receipts_files/'),
|
||||||
|
'police_serial' => $request->police_serial ?? null,
|
||||||
|
'police_file_date' => $request->police_file_date ?? null,
|
||||||
|
'damage_picture1' => FileFacade::save($request->file('damage_picture1'), 'receipts_files/'),
|
||||||
|
'damage_picture2' => FileFacade::save($request->file('damage_picture2'), 'receipts_files/'),
|
||||||
|
'status' => AccidentStates::BEDON_EGHDAM->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::BEDON_EGHDAM->value),
|
||||||
|
];
|
||||||
|
|
||||||
|
$sum = 0;
|
||||||
|
$damageData = [];
|
||||||
|
|
||||||
|
foreach ($request->damage_items as $key => $item) {
|
||||||
|
$damage = Damage::query()->find($item['id']);
|
||||||
|
$damageData[$item['id']] = [
|
||||||
|
'value' => $item['value'],
|
||||||
|
'unit' => $damage->unit,
|
||||||
|
'amount' => $item['amount'],
|
||||||
|
];
|
||||||
|
$sum += $item['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$ojrate_nasb = $sum/100*20;
|
||||||
|
$sum += $ojrate_nasb;
|
||||||
|
|
||||||
|
$accidentData['ojrate_nasb'] = $ojrate_nasb;
|
||||||
|
$accidentData['sum'] = $sum;
|
||||||
|
|
||||||
|
$accident = Accident::query()->create($accidentData);
|
||||||
|
|
||||||
|
$accident->damages()->attach($damageData);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1123);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($accident->load('damages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Accident $accident, UpdateRequest $request, NominatimService $nominatimService): JsonResponse
|
||||||
|
{
|
||||||
|
DB::transaction(function () use ($request, $accident, $nominatimService) {
|
||||||
|
|
||||||
|
$province = Province::query()->where('id', '=', $request->province_id)->first();
|
||||||
|
$city = City::query()->where('id', '=', $request->city_id)->first();
|
||||||
|
|
||||||
|
$accidentData = [
|
||||||
|
'province_id' => $province->id,
|
||||||
|
'province_fa' => $province->name_fa,
|
||||||
|
'city_id' => $city->id,
|
||||||
|
'city_fa' => $city->name_fa,
|
||||||
|
'axis_name' => $request->axis_name,
|
||||||
|
'driver_name' => $request->driver_name,
|
||||||
|
'plaque' => $request->plaque,
|
||||||
|
'driver_national_code' => $request->driver_national_code,
|
||||||
|
'driver_phone_number' => $request->driver_phone_number,
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lng' => $request->lng,
|
||||||
|
'accident_type' => $request->accident_type,
|
||||||
|
'accident_date' => $request->accident_date,
|
||||||
|
'accident_time' => $request->accident_time,
|
||||||
|
'accident_type_fa' => DailyAccidentSettings::query()->where('type', 'accident_type')->where('name', $request->accident_type)->first()->value,
|
||||||
|
'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng),
|
||||||
|
'report_base' => $request->report_base,
|
||||||
|
'police_serial' => $request->police_serial ?? null,
|
||||||
|
'police_file_date' => $request->police_file_date ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->report_base && $accident->police_file) {
|
||||||
|
FileFacade::delete($accident->police_file, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$request->report_base && $request->has('police_file')) {
|
||||||
|
FileFacade::delete($accident->police_file, true);
|
||||||
|
$accidentData['police_file'] = FileFacade::save($request->file('police_file'), "receipts_files/{$accident->id}/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('damage_picture1')) {
|
||||||
|
FileFacade::delete($accident->damage_picture1, true);
|
||||||
|
$accidentData['damage_picture1'] = FileFacade::save($request->file('damage_picture1'), "receipts_files/{$accident->id}/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('damage_picture2')) {
|
||||||
|
FileFacade::delete($accident->damage_picture2, true);
|
||||||
|
$accidentData['damage_picture2'] = FileFacade::save($request->file('damage_picture2'), "receipts_files/{$accident->id}/");
|
||||||
|
}
|
||||||
|
|
||||||
|
$sum = 0;
|
||||||
|
$damageData = [];
|
||||||
|
|
||||||
|
foreach ($request->damage_items as $key => $item) {
|
||||||
|
$damage = Damage::query()->find($item['id']);
|
||||||
|
$damageData[$item['id']] = [
|
||||||
|
'value' => $item['value'],
|
||||||
|
'unit' => $damage->unit,
|
||||||
|
'amount' => $item['amount'],
|
||||||
|
];
|
||||||
|
$sum += $item['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$ojrate_nasb = $sum/100*20;
|
||||||
|
$sum += $ojrate_nasb;
|
||||||
|
|
||||||
|
$accidentData['ojrate_nasb'] = $ojrate_nasb;
|
||||||
|
$accidentData['sum'] = $sum;
|
||||||
|
|
||||||
|
$accident->update($accidentData);
|
||||||
|
|
||||||
|
$accident->damages()->sync($damageData);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1124);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
FileFacade::delete('storage/receipts_files/'.$accident->id);
|
||||||
|
|
||||||
|
DB::transaction(function () use ($accident) {
|
||||||
|
|
||||||
|
$accident->damages()->detach();
|
||||||
|
|
||||||
|
$accident->delete();
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1125);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateInsuranceLetter(Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
DB::transaction(function () use ($accident) {
|
||||||
|
$accident->update([
|
||||||
|
'status' => AccidentStates::SODOR_NAME_BIME_VA_DAGHI->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::SODOR_NAME_BIME_VA_DAGHI->value),
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1126);
|
||||||
|
});
|
||||||
|
|
||||||
|
$account_data = Province::query()->where('id', $accident->province_id)->first();
|
||||||
|
|
||||||
|
return $this->successResponse([
|
||||||
|
$account_data,
|
||||||
|
$accident->load('damages')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confirmPaymentInfo(ConfirmPaymentInfoRequest $request, Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
DB::transaction(function () use ($request, $accident) {
|
||||||
|
|
||||||
|
$accident->update([
|
||||||
|
'deposit_insurance_image' => $request->deposit_insurance_image != null ? FileFacade::save($request->deposit_insurance_image, "receipts_files/{$accident->id}/deposit_insurance/") : null,
|
||||||
|
'deposit_insurance_amount' => $request->deposit_insurance_amount ?? 0,
|
||||||
|
'deposit_daghi_image' => $request->deposit_insurance_image != null ? FileFacade::save($request->deposit_daghi_image, "receipts_files/{$accident->id}/deposit_daghi/") : null,
|
||||||
|
'deposit_daghi_amount' => $request->deposit_daghi_amount ?? 0,
|
||||||
|
'status' => AccidentStates::SABT_FISH->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::SABT_FISH->value),
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1132);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submitInvoice(Accident $accident, PaymentService $paymentService): JsonResponse
|
||||||
|
{
|
||||||
|
$final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
|
||||||
|
|
||||||
|
if ($final_amount < 0) {
|
||||||
|
return $this->errorResponse('error');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bill_code = $paymentService->invoiceBillApi($accident->driver_national_code, $final_amount);
|
||||||
|
|
||||||
|
DB::transaction(function () use ($bill_code, $final_amount, $accident) {
|
||||||
|
|
||||||
|
$accident->update([
|
||||||
|
'final_amount' => $final_amount,
|
||||||
|
'bill_code' => $bill_code,
|
||||||
|
'status' => AccidentStates::SODOR_FACTOR->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::SODOR_FACTOR->value),
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1129);
|
||||||
|
});
|
||||||
|
|
||||||
|
$msg = "فاکتور با شناسه پرداخت \n" . explode("/", $accident->bill_code)[0]. "\n در سامانه سازمان راهداری ثبت شد. برای پرداخت از لینک زیر اقدام نمایید.\n\n".env("PAYMENT_LINK")."/#/pay/".explode("/", $accident->bill_code)[0]."/$final_amount";
|
||||||
|
|
||||||
|
Sms::sendSms($accident->driver_phone_number, $msg);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPaymentStatus(Accident $accident, PaymentService $paymentService): JsonResponse
|
||||||
|
{
|
||||||
|
DB::transaction(function () use ($accident, $paymentService) {
|
||||||
|
if ($accident->final_amount > 0) {
|
||||||
|
|
||||||
|
$response = json_decode($paymentService->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0]));
|
||||||
|
|
||||||
|
if ($response->isPayed) {
|
||||||
|
$accident->update([
|
||||||
|
'status' => AccidentStates::PARDAKHT_FACTOR->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::PARDAKHT_FACTOR->value),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$accident->update([
|
||||||
|
'status' => AccidentStates::PARDAKHT_FACTOR->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::PARDAKHT_FACTOR->value),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1130);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse($accident);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generatePoliceDocument(Request $request, Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
DB::transaction(function () use ($request, $accident) {
|
||||||
|
|
||||||
|
$accident->update([
|
||||||
|
'status' => AccidentStates::SODOR_NAME_POLICE_RAH->value,
|
||||||
|
'status_fa' => AccidentStates::name(AccidentStates::SODOR_NAME_POLICE_RAH->value),
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1131);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse($accident);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendSmsAgain(Accident $accident): JsonResponse
|
||||||
|
{
|
||||||
|
$msg = "فاکتور با شناسه پرداخت \n" . explode("/", $accident->bill_code)[0]. "\n در سامانه سازمان راهداری ثبت شد. برای پرداخت از لینک زیر اقدام نمایید.\n\n".env("PAYMENT_LINK")."/#/pay/".explode("/", $accident->bill_code)[0]."/$accident->final_amount";
|
||||||
|
|
||||||
|
Sms::sendSms($accident->driver_phone_number, $msg);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accidentTypes(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(DailyAccidentSettings::query()->where('type', 'accident_type')->get());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\InfoItem;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class ItemsManagementController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function getItems(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(
|
||||||
|
InfoItem::query()
|
||||||
|
->select('item as id', 'item_str as name', 'icon')
|
||||||
|
->where('type', '=', 'item')
|
||||||
|
->groupby('item')
|
||||||
|
->get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubItems($item): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(
|
||||||
|
InfoItem::query()
|
||||||
|
->where('item', '=', $item)
|
||||||
|
->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item')
|
||||||
|
->get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard;
|
||||||
|
|
||||||
|
use App\Facades\Otp\Otp;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\Otp\GetOtpTokenRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class OtpManagementController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function getOtpToken(GetOtpTokenRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
Otp::getOtpToken($request, $request->ip(), $request->phone_number, "کد تایید تلفن همراه سامانه جامع راهداری (RMS) : \n");
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\V3\Dashboard;
|
|
||||||
|
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
|
||||||
use App\Facades\Sms\Sms;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Traits\ApiResponse;
|
|
||||||
use App\Models\Accident;
|
|
||||||
use App\Models\City;
|
|
||||||
use App\Models\DailyAccidentSettings;
|
|
||||||
use App\Models\Damage;
|
|
||||||
use App\Models\Province;
|
|
||||||
use App\Services\NominatimService;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class ReceiptController extends Controller
|
|
||||||
{
|
|
||||||
use ApiResponse;
|
|
||||||
|
|
||||||
public function show(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
$columns = array('id', 'province_fa','city_fa', 'axis_name', 'accident_type_fa', 'accident_date', 'id',
|
|
||||||
'damage_picture1', 'damage_picture2', 'plaque', 'created_at', 'sum', 'deposit_date', 'status',
|
|
||||||
'police_file_date','deposit_insurance_image','deposit_daghi_image','deposit_insurance_amount',
|
|
||||||
'deposit_daghi_amount','status_fa','final_amount','province_id','accident_time','accident_type',
|
|
||||||
'city_id','driver_name','driver_national_code','driver_phone_number','police_file','lat','lng',
|
|
||||||
'police_serial','report_base'
|
|
||||||
);
|
|
||||||
|
|
||||||
$allowedFilters = $columns;
|
|
||||||
$allowedSortings = $columns;
|
|
||||||
|
|
||||||
$user = auth()->user();
|
|
||||||
$query = null;
|
|
||||||
|
|
||||||
if ($user->hasPermissionTo('show-receipt')) {
|
|
||||||
$query = Accident::with('damages');
|
|
||||||
} else {
|
|
||||||
if (is_null($user->province_id)) {
|
|
||||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = Accident::with('damages')->where('province_id', '=', $user->province_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = DataTableFacade::run(
|
|
||||||
$query,
|
|
||||||
$request,
|
|
||||||
allowedFilters: $allowedFilters,
|
|
||||||
allowedSortings: $allowedSortings
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$user->addActivityComplete(1122);
|
|
||||||
|
|
||||||
return $this->successResponse($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request, NominatimService $nominatimService)
|
|
||||||
{
|
|
||||||
DB::transaction(function () use ($request, $nominatimService) {
|
|
||||||
|
|
||||||
$province = Province::query()->where('id', '=', $request->province_id)->first();
|
|
||||||
$city = City::query()->where('id', '=', $request->city_id)->first();
|
|
||||||
|
|
||||||
$accident = [
|
|
||||||
'province_id' => $province->id,
|
|
||||||
'province_fa' => $province->name_fa,
|
|
||||||
'city_id' => $city->id,
|
|
||||||
'city_fa' => $city->name_fa,
|
|
||||||
'axis_name' => $request->axis_name,
|
|
||||||
'driver_name' => $request->driver_name,
|
|
||||||
'plaque' => $request->plaque,
|
|
||||||
'driver_national_code' => $request->driver_national_code,
|
|
||||||
'driver_phone_number' => $request->driver_phone_number,
|
|
||||||
'user_id' => auth()->user()->id,
|
|
||||||
'lat' => $request->lat,
|
|
||||||
'lng' => $request->lng,
|
|
||||||
'accident_type' => $request->accident_type,
|
|
||||||
'accident_date' => $request->accident_date,
|
|
||||||
'accident_time' => $request->accident_time,
|
|
||||||
'accident_type_fa' => DailyAccidentSettings::where('type', 'accident_type')->where('name', $request->accident_type)->first()->value,
|
|
||||||
'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng),
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($request->report_base) {
|
|
||||||
$accident['report_base'] = 1;
|
|
||||||
} else {
|
|
||||||
$accident['police_file'] = $request->file('police_file')->storeAs('receipts_files/'.$accident->id, 'police_file_'.$accident->id.'_'.time().'.'.$request->file('police_file')->extension(), 'public');
|
|
||||||
$accident['police_serial'] = $request->police_serial;
|
|
||||||
$accident['police_file_date'] = $request->police_file_date;
|
|
||||||
$accident['report_base'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('damage_picture1')) {
|
|
||||||
$new_accident->damage_picture1 = $request->file('damage_picture1')->storeAs('receipts_files/'.$new_accident->id, 'damage_picture1_'.$new_accident->id.'_'.time().'.'.$request->file('damage_picture1')->extension(), 'public');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('damage_picture2')) {
|
|
||||||
$new_accident->damage_picture2 = $request->file('damage_picture2')->storeAs('receipts_files/'.$new_accident->id, 'damage_picture2_'.$new_accident->id.'_'.time().'.'.$request->file('damage_picture2')->extension(), 'public');
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_accident->save();
|
|
||||||
$sum = 0;
|
|
||||||
foreach (json_decode($request->items_damge) as $key => $item) {
|
|
||||||
$damage = Damage::find($item->id);
|
|
||||||
$new_accident->damages()->attach($item->id, [
|
|
||||||
'value' => $item->value,
|
|
||||||
'unit' => $damage->unit,
|
|
||||||
'amount' => $item->amount,
|
|
||||||
]);
|
|
||||||
$sum += $item->amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ojrate_nasb = $sum/100*20;
|
|
||||||
$new_accident->ojrate_nasb = $ojrate_nasb;
|
|
||||||
|
|
||||||
$sum += $ojrate_nasb;
|
|
||||||
$new_accident->sum = $sum;
|
|
||||||
$new_accident->withoutAction();
|
|
||||||
$new_accident->save();
|
|
||||||
$msg = "درخواست شما بابت پرداخت خسارت وارده به ابنیه فنی و تاسیسات راه با کد یکتا ".$new_accident->id." ثبت شد.\n".verta()->now()->format('Y/m/d H:i') ;
|
|
||||||
Sms::sendSms($request->phone_number, $msg);
|
|
||||||
auth()->user()->addActivityComplete(1123);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||||
|
|
||||||
|
use App\Exports\V3\AccidentReceipt\ProvinceReport;
|
||||||
|
use App\Exports\V3\AccidentReceipt\CountryReport;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Services\Cartables\AccidentReceiptTableService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class AccidentReceiptReportController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function countryReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $accidentReceiptTableService->countryReport($request);
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $data['data'],
|
||||||
|
'provinces' => Province::all(['id', 'name_fa']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $accidentReceiptTableService->provinceReport($request);
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $data['data'],
|
||||||
|
'cities' => City::query()->where('province_id', '=', $request->province_id)
|
||||||
|
->where('type_id', '=', 1)
|
||||||
|
->get(['id', 'name_fa']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryExcelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $accidentReceiptTableService->countryReport($request);
|
||||||
|
$name = 'گزارش از خسارات وارده به ابنیه فنی و تاسیسات راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
return Excel::download(new CountryReport($data), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceExcelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $accidentReceiptTableService->provinceReport($request);
|
||||||
|
$name = 'گزارش از خسارات وارده به ابنیه فنی و تاسیسات راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
return Excel::download(new ProvinceReport([
|
||||||
|
'report' => $data,
|
||||||
|
'cities' => City::query()->where('province_id', '=', $request->province_id)
|
||||||
|
->where('type_id', '=', 1)
|
||||||
|
->get(['id', 'name_fa']),
|
||||||
|
]), $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ use App\Models\EdarateShahri;
|
|||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
use App\Models\RoadItemsProject;
|
use App\Models\RoadItemsProject;
|
||||||
use App\Services\Reports\RoadItemReportService;
|
use App\Services\Cartables\RoadItemTableService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
@@ -32,9 +32,9 @@ class RoadItemsReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countryActivityPerSubItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
|
public function countryActivityPerSubItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$activities = $roadItemReportService->countryActivityPerSubItem($request);
|
$activities = $roadItemTableService->countryActivityPerSubItem($request);
|
||||||
$provinces = Province::all(['id', 'name_fa']);
|
$provinces = Province::all(['id', 'name_fa']);
|
||||||
$subItems = InfoItem::query()
|
$subItems = InfoItem::query()
|
||||||
->where('item', $request->item)
|
->where('item', $request->item)
|
||||||
@@ -47,9 +47,9 @@ class RoadItemsReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provinceActivityPerSubItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
|
public function provinceActivityPerSubItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$activities = $roadItemReportService->provinceActivityPerSubItem($request);
|
$activities = $roadItemTableService->provinceActivityPerSubItem($request);
|
||||||
|
|
||||||
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
||||||
|
|
||||||
@@ -64,13 +64,13 @@ class RoadItemsReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countryActivityPerItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
|
public function countryActivityPerItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||||
{
|
{
|
||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
auth()->user()->addActivityComplete(1033);
|
auth()->user()->addActivityComplete(1033);
|
||||||
}
|
}
|
||||||
|
|
||||||
$activities = $roadItemReportService->countryActivityPerItem($request);
|
$activities = $roadItemTableService->countryActivityPerItem($request);
|
||||||
$provinces = Province::all(['id', 'name_fa']);
|
$provinces = Province::all(['id', 'name_fa']);
|
||||||
|
|
||||||
return $this->successResponse([
|
return $this->successResponse([
|
||||||
@@ -79,9 +79,9 @@ class RoadItemsReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provinceActivityPerItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
|
public function provinceActivityPerItem(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$activities = $roadItemReportService->provinceActivityPerItem($request);
|
$activities = $roadItemTableService->provinceActivityPerItem($request);
|
||||||
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
||||||
|
|
||||||
return $this->successResponse([
|
return $this->successResponse([
|
||||||
@@ -90,11 +90,11 @@ class RoadItemsReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countryActivityExcelPerItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
public function countryActivityExcelPerItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
auth()->user()->addActivityComplete(1034);
|
auth()->user()->addActivityComplete(1034);
|
||||||
$name = 'گزارش کشوری از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
$name = 'گزارش کشوری از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
$activities = $roadItemReportService->countryActivityPerItem($request);
|
$activities = $roadItemTableService->countryActivityPerItem($request);
|
||||||
return Excel::download(new CountryActivityPerItemReport([
|
return Excel::download(new CountryActivityPerItemReport([
|
||||||
'activities' => $activities,
|
'activities' => $activities,
|
||||||
'provinces' => Province::all(['id', 'name_fa']),
|
'provinces' => Province::all(['id', 'name_fa']),
|
||||||
@@ -102,11 +102,11 @@ class RoadItemsReportController extends Controller
|
|||||||
]), $name);
|
]), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provinceActivityExcelPerItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
public function provinceActivityExcelPerItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
auth()->user()->addActivityComplete(1034);
|
auth()->user()->addActivityComplete(1034);
|
||||||
$name = 'گزارش استانی از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
$name = 'گزارش استانی از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
$activities = $roadItemReportService->provinceActivityPerItem($request);
|
$activities = $roadItemTableService->provinceActivityPerItem($request);
|
||||||
return Excel::download(new ProvinceActivityPerItemReport([
|
return Excel::download(new ProvinceActivityPerItemReport([
|
||||||
'activities' => $activities,
|
'activities' => $activities,
|
||||||
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
|
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
|
||||||
@@ -114,11 +114,11 @@ class RoadItemsReportController extends Controller
|
|||||||
]), $name);
|
]), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countryActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
public function countryActivityExcelPerSubItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
auth()->user()->addActivityComplete(1034);
|
auth()->user()->addActivityComplete(1034);
|
||||||
$name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
$name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
$activities = $roadItemReportService->countryActivityPerSubItem($request);
|
$activities = $roadItemTableService->countryActivityPerSubItem($request);
|
||||||
$subItems = InfoItem::query()
|
$subItems = InfoItem::query()
|
||||||
->where('item', $request->item)
|
->where('item', $request->item)
|
||||||
->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']);
|
->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']);
|
||||||
@@ -130,10 +130,10 @@ class RoadItemsReportController extends Controller
|
|||||||
]), $name);
|
]), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provinceActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
public function provinceActivityExcelPerSubItem(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
auth()->user()->addActivityComplete(1034);
|
auth()->user()->addActivityComplete(1034);
|
||||||
$activities = $roadItemReportService->provinceActivityPerSubItem($request);
|
$activities = $roadItemTableService->provinceActivityPerSubItem($request);
|
||||||
$name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
$name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
$subItems = InfoItem::query()
|
$subItems = InfoItem::query()
|
||||||
->where('item', $request->item)
|
->where('item', $request->item)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||||
|
|
||||||
|
use App\Exports\V2\RoadObservation\ReportComplaintsExport;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\RoadObserved;
|
||||||
|
use App\Services\Cartables\RoadObservationTableService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class RoadObservationReportController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request, RoadObservationTableService $roadObservationTableService): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $roadObservationTableService->reportIndex($request);
|
||||||
|
return response()->json($data['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function excelReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$name = 'گزارش رسیدگی به شکایات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
|
$data = $roadObservationTableService->reportIndex($request);
|
||||||
|
return Excel::download(new ReportComplaintsExport($data), $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ use App\Models\EdarateShahri;
|
|||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use App\Models\RoadPatrol;
|
use App\Models\RoadPatrol;
|
||||||
use App\Services\Reports\RoadPatrolReportService;
|
use App\Services\Cartables\RoadPatrolTableService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
@@ -19,9 +19,9 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|||||||
class RoadPatrolReportController extends Controller
|
class RoadPatrolReportController extends Controller
|
||||||
{
|
{
|
||||||
use ApiResponse;
|
use ApiResponse;
|
||||||
public function countryPatrolActivity(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse
|
public function countryPatrolActivity(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$activities = $roadPatrolReportService->countryActivity($request);
|
$activities = $roadPatrolTableService->countryActivity($request);
|
||||||
|
|
||||||
$provinces = Province::all(['id', 'name_fa']);
|
$provinces = Province::all(['id', 'name_fa']);
|
||||||
|
|
||||||
@@ -31,11 +31,11 @@ class RoadPatrolReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provincePatrolActivity(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse
|
public function provincePatrolActivity(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate(["province_id" => "required",]);
|
$request->validate(["province_id" => "required",]);
|
||||||
|
|
||||||
$activities = $roadPatrolReportService->provinceActivity($request);
|
$activities = $roadPatrolTableService->provinceActivity($request);
|
||||||
|
|
||||||
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
||||||
|
|
||||||
@@ -45,9 +45,9 @@ class RoadPatrolReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countryActivityExcel(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse
|
public function countryActivityExcel(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$activities = $roadPatrolReportService->countryActivity($request);
|
$activities = $roadPatrolTableService->countryActivity($request);
|
||||||
$provinces = Province::all(['id', 'name_fa']);
|
$provinces = Province::all(['id', 'name_fa']);
|
||||||
|
|
||||||
$name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
$name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
@@ -58,9 +58,9 @@ class RoadPatrolReportController extends Controller
|
|||||||
]), $name);
|
]), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provinceActivityExcel(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse
|
public function provinceActivityExcel(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$activities = $roadPatrolReportService->provinceActivity($request);
|
$activities = $roadPatrolTableService->provinceActivity($request);
|
||||||
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
|
||||||
|
|
||||||
$name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
$name = 'گزارش از گشت راهداری و ترابری ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||||
|
|
||||||
|
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||||
|
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\EdarateShahri;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class SafetyAndPrivacyReportController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function countryActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $safetyAndPrivacyTableService->countryActivity($request);
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $data['activities'],
|
||||||
|
'provinces' => Province::all(['id', 'name_fa'])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $safetyAndPrivacyTableService->provinceActivity($request);
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $data['activities'],
|
||||||
|
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryExcelActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $safetyAndPrivacyTableService->countryActivity($request);
|
||||||
|
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
return Excel::download(new CountryActivityReport($data), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceExcelActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $safetyAndPrivacyTableService->provinceActivity($request);
|
||||||
|
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ use App\Models\EdarateShahri;
|
|||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
use App\Models\RoadItemsProject;
|
use App\Models\RoadItemsProject;
|
||||||
use App\Services\NominatimService;
|
use App\Services\NominatimService;
|
||||||
use App\Services\Reports\RoadItemReportService;
|
use App\Services\Cartables\RoadItemTableService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
@@ -28,9 +28,9 @@ class RoadItemsProjectController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
public function supervisorIndex(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
|
public function supervisorIndex(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $roadItemReportService->supervisorCartableReport($request);
|
$data = $roadItemTableService->supervisorCartableReport($request);
|
||||||
|
|
||||||
foreach ($data['data'] as $road_item) {
|
foreach ($data['data'] as $road_item) {
|
||||||
if (Gate::allows('gate-supervise-road-item', $road_item)) {
|
if (Gate::allows('gate-supervise-road-item', $road_item)) {
|
||||||
@@ -96,16 +96,16 @@ class RoadItemsProjectController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function supervisorCartableReport(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
public function supervisorCartableReport(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$name = 'گزارش از کارتابل ارزیابی فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
$name = 'گزارش از کارتابل ارزیابی فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
$data = $roadItemReportService->supervisorCartableReport($request);
|
$data = $roadItemTableService->supervisorCartableReport($request, true);
|
||||||
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorIndex(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
|
public function operatorIndex(Request $request, RoadItemTableService $roadItemTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $roadItemReportService->operatorCartableReport($request);
|
$data = $roadItemTableService->operatorCartableReport($request);
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,10 +264,25 @@ class RoadItemsProjectController extends Controller
|
|||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorCartableReport(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
public function operatorCartableReport(Request $request, RoadItemTableService $roadItemTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$name = 'گزارش از کارتابل عملیات فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
$name = 'گزارش از کارتابل عملیات فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
$data = $roadItemReportService->operatorCartableReport($request);
|
$data = $roadItemTableService->operatorCartableReport($request, true);
|
||||||
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
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']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
308
app/Http/Controllers/V3/Dashboard/RoadObservationController.php
Normal file
308
app/Http/Controllers/V3/Dashboard/RoadObservationController.php
Normal file
@@ -0,0 +1,308 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard;
|
||||||
|
use App\Exports\V3\RoadObservation\ComplaintsReport;
|
||||||
|
use App\Exports\V3\RoadObservation\OperatorCartableReport;
|
||||||
|
use App\Exports\V3\RoadObservation\SupervisorCartableReport;
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
|
use App\Facades\Sms\Sms;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\RoadObservation\ModifyRegisterationRequest;
|
||||||
|
use App\Http\Requests\V3\RoadObservation\ReferRequest;
|
||||||
|
use App\Http\Requests\V3\RoadObservation\RegisterRequest;
|
||||||
|
use App\Http\Requests\V3\RoadObservation\RestoreRequest;
|
||||||
|
use App\Http\Requests\V3\RoadObservation\VerifyBySupervisorRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\EdarateShahri;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Models\RoadObservationHistory;
|
||||||
|
use App\Models\RoadObserved;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\NikarayanService;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Hekmatinasser\Verta\Verta;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Services\Cartables\RoadObservationTableService;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use SoapFault;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class RoadObservationController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function supervisorIndex(Request $request,RoadObservationTableService $roadObservationTableService ): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json($roadObservationTableService->supervisorCartableIndex($request));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyBySupervisor(VerifyBySupervisorRequest $request, RoadObserved $roadObserved): JsonResponse
|
||||||
|
{
|
||||||
|
$statusFa = $request->verify == 1 ? 'تایید شده' : 'عدم تایید';
|
||||||
|
|
||||||
|
$roadObserved->update([
|
||||||
|
'status' => $request->verify,
|
||||||
|
'status_fa' => $statusFa,
|
||||||
|
'supervisor_id' => auth()->user()->id,
|
||||||
|
'supervisor_name' => auth()->user()->name,
|
||||||
|
'supervisor_description' => $request->description,
|
||||||
|
'supervising_time' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1138);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supervisorCartableReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$name = 'گزارش از کارتابل ارزیابی واکنش سریع '. verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
|
$data = $roadObservationTableService->supervisorCartableIndex($request);
|
||||||
|
|
||||||
|
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function operatorIndex(Request $request, RoadObservationTableService $roadObservationTableService): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json($roadObservationTableService->operatorCartableIndex($request));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function operatorCartableReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$name = 'گزارش از کارتابل عملیات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
|
$data = $roadObservationTableService->operatorCartableIndex($request);
|
||||||
|
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function complaintsIndex(Request $request, RoadObservationTableService $roadObservationTableService): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json($roadObservationTableService->complaintsIndex($request));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function complaintsReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$name = 'گزارش از رسیدگی به شکایات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
|
$data = $roadObservationTableService->complaintsIndex($request);
|
||||||
|
return Excel::download(new ComplaintsReport($data['data']), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(RoadObserved $roadObserved): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($roadObserved->only(['rms_status', 'rms_description', 'image_before', 'image_after', 'rms_start_latlng']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register(RegisterRequest $request, RoadObserved $roadObserved, NikarayanService $nikarayanService): JsonResponse
|
||||||
|
{
|
||||||
|
$roadObservedData = [
|
||||||
|
'status' => 0,
|
||||||
|
'status_fa' => 'در حال بررسی',
|
||||||
|
'rms_status' => $request->rms_status ?? $roadObserved->rms_status,
|
||||||
|
'rms_description' => $request->rms_description ?? $roadObserved->rms_description,
|
||||||
|
];
|
||||||
|
|
||||||
|
$roadObservedHistoryData = [
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'previous_rms_status' => $roadObserved->rms_status,
|
||||||
|
'previous_rms_start_latlng' => $roadObserved->rms_start_latlng,
|
||||||
|
'previous_rms_end_latlng' => $roadObserved->rms_end_latlng,
|
||||||
|
'previous_rms_description' => $roadObserved->rms_description,
|
||||||
|
'new_files' => json_encode([])
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->rms_status == 1) {
|
||||||
|
|
||||||
|
$files_path = [];
|
||||||
|
|
||||||
|
$roadObserved->files()->where('path', 'like', '%_image_before%')->delete();
|
||||||
|
$roadObserved->files()->where('path', 'like', '%_image_after%')->delete();
|
||||||
|
|
||||||
|
$image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}/");
|
||||||
|
$image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}/");
|
||||||
|
|
||||||
|
$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;
|
||||||
|
$roadObservedData['image_before'] = $image_before;
|
||||||
|
$roadObservedData['rms_start_latlng'] = explode(',', $request->start_point);
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$roadObserved->problemHistories()->create($roadObservedHistoryData);
|
||||||
|
$roadObserved->update($roadObservedData);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1142);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files']));
|
||||||
|
}
|
||||||
|
catch (SoapFault $e) {
|
||||||
|
|
||||||
|
$msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n";
|
||||||
|
$msg .= $e->getMessage();
|
||||||
|
Sms::sendSms(env('RMS_CTO_PHONE_NUMBER'), $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function modifyRegistration(ModifyRegisterationRequest $request, RoadObserved $roadObserved, NikarayanService $nikarayanService): JsonResponse
|
||||||
|
{
|
||||||
|
$roadObservedData = [
|
||||||
|
'status' => 0,
|
||||||
|
'status_fa' => 'در حال بررسی',
|
||||||
|
'rms_status' => $request->rms_status ?? $roadObserved->rms_status,
|
||||||
|
'rms_description' => $request->rms_description ?? $roadObserved->rms_description,
|
||||||
|
];
|
||||||
|
|
||||||
|
$roadObservedHistoryData = [
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'previous_rms_status' => $roadObserved->rms_status,
|
||||||
|
'previous_rms_start_latlng' => $roadObserved->rms_start_latlng,
|
||||||
|
'previous_rms_end_latlng' => $roadObserved->rms_end_latlng,
|
||||||
|
'previous_rms_description' => $roadObserved->rms_description,
|
||||||
|
'new_files' => json_encode([])
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->rms_status == 1) {
|
||||||
|
|
||||||
|
$files_path = [];
|
||||||
|
|
||||||
|
$roadObserved->files()->where('path', 'like', '%_image_before%')->delete();
|
||||||
|
$roadObserved->files()->where('path', 'like', '%_image_after%')->delete();
|
||||||
|
|
||||||
|
if ($request->has('image_before')) {
|
||||||
|
if ($roadObserved->image_before) {
|
||||||
|
FileFacade::delete($roadObserved->image_before, true);
|
||||||
|
}
|
||||||
|
$image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}/");
|
||||||
|
$roadObservedData['image_before'] = $image_before;
|
||||||
|
$files_path[0]['path'] = $image_before;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('image_after')) {
|
||||||
|
if ($roadObserved->image_after) {
|
||||||
|
FileFacade::delete($roadObserved->image_after, true);
|
||||||
|
}
|
||||||
|
$image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}/");
|
||||||
|
$roadObservedData['image_after'] = $image_after;
|
||||||
|
$files_path[1]['path'] = $image_after;
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = json_encode($files_path);
|
||||||
|
$now_date_time = Carbon::now();
|
||||||
|
|
||||||
|
$roadObservedData['rms_start_latlng'] = explode(',', $request->start_point);
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$roadObserved->problemHistories()->create($roadObservedHistoryData);
|
||||||
|
$roadObserved->update($roadObservedData);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1142);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files']));
|
||||||
|
}
|
||||||
|
catch (SoapFault $e) {
|
||||||
|
|
||||||
|
$msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n";
|
||||||
|
$msg .= $e->getMessage();
|
||||||
|
Sms::sendSms(env('RMS_CTO_PHONE_NUMBER'), $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refer(ReferRequest $request, RoadObserved $roadObserved): JsonResponse
|
||||||
|
{
|
||||||
|
$province = Province::query()->find($request->province_id);
|
||||||
|
|
||||||
|
RoadObservationHistory::query()->create([
|
||||||
|
'id' => $roadObserved->id,
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'action' => 'refer',
|
||||||
|
'description' => $request->refer_description,
|
||||||
|
'from_edareh' => $roadObserved->edarate_shahri_id,
|
||||||
|
'to_edareh' => $request->edarate_shahri_id,
|
||||||
|
'from_province' => $roadObserved->province_id,
|
||||||
|
'to_province' => $province->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$roadObserved->update([
|
||||||
|
'edarate_shahri_id' => $request->edarate_shahri_id,
|
||||||
|
'province_id' => $province->id,
|
||||||
|
'province_fa' => $province->name_fa,
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1037);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function referList(RoadObserved $roadObserved): JsonResponse
|
||||||
|
{
|
||||||
|
$data = RoadObservationHistory::query()
|
||||||
|
->where('id', '=', $roadObserved->id)
|
||||||
|
->where('action', '=', 'refer')
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->get([
|
||||||
|
'created_at', 'description', 'from_edareh', 'to_edareh',
|
||||||
|
'from_province', 'to_province', 'user_id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
$data[$key]->from_edareh = EdarateShahri::query()->find($value->from_edareh)->name_fa ?? null;
|
||||||
|
$data[$key]->to_edareh = EdarateShahri::query()->find($value->to_edareh)->name_fa ?? null;
|
||||||
|
$data[$key]->from_province = Province::query()->find($value->from_province)->name_fa ?? null;
|
||||||
|
$data[$key]->to_province = Province::query()->find($value->to_province)->name_fa ?? null;
|
||||||
|
$user = User::query()->find($value->user_id);
|
||||||
|
$data[$key]->user = $user->first_name . ' ' . $user->last_name;
|
||||||
|
}
|
||||||
|
return $this->successResponse($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restore(RestoreRequest $request, RoadObserved $roadObserved): JsonResponse
|
||||||
|
{
|
||||||
|
if ($roadObserved->image_before) {
|
||||||
|
FileFacade::delete($roadObserved->image_before);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($roadObserved->image_after) {
|
||||||
|
FileFacade::delete($roadObserved->image_after);
|
||||||
|
}
|
||||||
|
|
||||||
|
$roadObserved->update([
|
||||||
|
'image_before' => null,
|
||||||
|
'image_after' => null,
|
||||||
|
'rms_last_activity' => null,
|
||||||
|
'rms_last_activity_fa' => null,
|
||||||
|
'updated_at_fa' => null,
|
||||||
|
'updated_at' => null,
|
||||||
|
'rms_status' => 0,
|
||||||
|
'status' => null,
|
||||||
|
'status_fa' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
RoadObservationHistory::query()->create([
|
||||||
|
'id' => $roadObserved->id,
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'action' => 'restore',
|
||||||
|
'description' => $request->restore_description,
|
||||||
|
]);
|
||||||
|
|
||||||
|
auth()->user()->addActivityComplete(1141);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ use App\Models\RoadItemsProject;
|
|||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use App\Models\RoadPatrol;
|
use App\Models\RoadPatrol;
|
||||||
use App\Services\NominatimService;
|
use App\Services\NominatimService;
|
||||||
use App\Services\Reports\RoadPatrolReportService;
|
use App\Services\Cartables\RoadPatrolTableService;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -30,9 +30,9 @@ class RoadPatrolProjectController extends Controller
|
|||||||
{
|
{
|
||||||
use ApiResponse;
|
use ApiResponse;
|
||||||
|
|
||||||
public function supervisorIndex(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse
|
public function supervisorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $roadPatrolReportService->supervisorCartableReport($request);
|
$data = $roadPatrolTableService->supervisorCartableReport($request);
|
||||||
|
|
||||||
foreach ($data['data'] as $road_patrol) {
|
foreach ($data['data'] as $road_patrol) {
|
||||||
if (Gate::allows('gate-supervise-road-item', $road_patrol)) {
|
if (Gate::allows('gate-supervise-road-item', $road_patrol)) {
|
||||||
@@ -80,16 +80,16 @@ class RoadPatrolProjectController extends Controller
|
|||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supervisorCartableReport(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse
|
public function supervisorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
$name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
$data = $roadPatrolReportService->supervisorCartableReport($request);
|
$data = $roadPatrolTableService->supervisorCartableReport($request, true);
|
||||||
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorIndex(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse
|
public function operatorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $roadPatrolReportService->operatorCartableReport($request);
|
$data = $roadPatrolTableService->operatorCartableReport($request);
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,10 +322,20 @@ class RoadPatrolProjectController extends Controller
|
|||||||
return $this->successResponse($roadPatrol);
|
return $this->successResponse($roadPatrol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorCartableReport(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse
|
public function operatorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$name = 'گزارش از کارتابل عملیات گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
$name = 'گزارش از کارتابل عملیات گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
$data = $roadPatrolReportService->operatorCartableReport($request);
|
$data = $roadPatrolTableService->operatorCartableReport($request, true);
|
||||||
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
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']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
189
app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php
Normal file
189
app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard;
|
||||||
|
|
||||||
|
use App\Enums\AxisTypes;
|
||||||
|
use App\Exports\V3\SafetyAndPrivacy\CartableReport;
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\SafetyAndPrivacy\FirstStepStoreRequest;
|
||||||
|
use App\Http\Requests\V3\SafetyAndPrivacy\SecondStepStoreRequest;
|
||||||
|
use App\Http\Requests\V3\SafetyAndPrivacy\ThirdStepStoreRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\InfoItem;
|
||||||
|
use App\Models\SafetyAndPrivacy;
|
||||||
|
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||||
|
use App\Services\NominatimService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class SafetyAndPrivacyController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json($safetyAndPrivacyTableService->datatable($request));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||||
|
$data = $safetyAndPrivacyTableService->datatable($request);
|
||||||
|
return Excel::download(new CartableReport($data['data']), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function firstStepStore(FirstStepStoreRequest $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('اداره شهری برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$coordinates = explode(',', $request->point);
|
||||||
|
$item = InfoItem::query()
|
||||||
|
->where('id', $request->info_id)
|
||||||
|
->where('item', 17)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
DB::transaction(function () use ($request, $coordinates, $item, $nominatimService, $user)
|
||||||
|
{
|
||||||
|
$safety_and_privacy = SafetyAndPrivacy::query()->create([
|
||||||
|
'lat' => $coordinates[0],
|
||||||
|
'lon' => $coordinates[1],
|
||||||
|
'operator_id' => $user->id,
|
||||||
|
'operator_name' => $user->name,
|
||||||
|
'province_id' => $user->province_id,
|
||||||
|
'province_fa' => $user->province_fa,
|
||||||
|
'info_id' => $item->id,
|
||||||
|
'info_fa' => $item->sub_item_str,
|
||||||
|
'city_id' => $user->city_id,
|
||||||
|
'city_fa' => $user->city_fa,
|
||||||
|
'activity_date_time' => $request->activity_date." ".$request->activity_time,
|
||||||
|
'edare_shahri_id' => $user->edarate_shahri_id,
|
||||||
|
'edare_shahri_name' => $user->edarate_shahri_name,
|
||||||
|
'way_id' => $nominatimService->get_way_id_from_nominatim($coordinates[0], $coordinates[1]),
|
||||||
|
'axis_type_id' => $request->axis_type_id,
|
||||||
|
'axis_type_name' => AxisTypes::name($request->axis_type_id),
|
||||||
|
'step' => 1,
|
||||||
|
'step_fa' => 'گام اول (شناسایی)'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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->save();
|
||||||
|
|
||||||
|
$user->addActivityComplete(1134);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function secondStepStore(SafetyAndPrivacy $safetyAndPrivacy, SecondStepStoreRequest $request): 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('اداره شهری برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($request, $safetyAndPrivacy, $user)
|
||||||
|
{
|
||||||
|
$judiciary_document = [];
|
||||||
|
foreach ($request->judiciary_document as $index => $file) {
|
||||||
|
$judiciary_document[] = FileFacade::save($file, "safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document");
|
||||||
|
}
|
||||||
|
$safetyAndPrivacy->update([
|
||||||
|
'judiciary_document' => serialize($judiciary_document),
|
||||||
|
'judiciary_document_upload_date' => now(),
|
||||||
|
'step' => 2,
|
||||||
|
'step_fa' => 'گام دوم (مستندات قضایی)'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->addActivityComplete(1135);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function thirdStepStore(SafetyAndPrivacy $safetyAndPrivacy, ThirdStepStoreRequest $request): 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('اداره شهری برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
|
||||||
|
$safetyAndPrivacy->update([
|
||||||
|
'step' => 3,
|
||||||
|
'step_fa' => 'گام سوم (برخورد)',
|
||||||
|
'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"),
|
||||||
|
'action_picture_document_upload_date' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->addActivityComplete(1136);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($safetyAndPrivacy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||||
|
{
|
||||||
|
Storage::deleteDirectory("public/safety_and_privacy/{$safetyAndPrivacy->id}");
|
||||||
|
|
||||||
|
DB::transaction(function () use ($safetyAndPrivacy)
|
||||||
|
{
|
||||||
|
auth()->user()->addActivityComplete(1155);
|
||||||
|
$safetyAndPrivacy->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deserialize(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||||
|
{
|
||||||
|
$judiciaries = $safetyAndPrivacy->judiciary_document ? unserialize($safetyAndPrivacy->judiciary_document) : [];
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach ($judiciaries as $judiciary) {
|
||||||
|
$result[] = Storage::disk('public')->url($judiciary);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->successResponse($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subItems(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(InfoItem::query()
|
||||||
|
->where('item', '=', 17)
|
||||||
|
->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item')
|
||||||
|
->get());
|
||||||
|
}
|
||||||
|
}
|
||||||
63
app/Http/Controllers/V3/LogListManagementController.php
Normal file
63
app/Http/Controllers/V3/LogListManagementController.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\LogList\StoreRequest;
|
||||||
|
use App\Http\Requests\V3\LogList\UpdateRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\LogList;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class LogListManagementController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json(DataTableFacade::run(
|
||||||
|
LogList::query(),
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(LogList::all('description', 'log_unique_code'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
LogList::query()->create([
|
||||||
|
'description' => $request->description,
|
||||||
|
'log_unique_code' => $request->log_unique_code,
|
||||||
|
'action_type' => $request->action_type,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(LogList $logList): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($logList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(UpdateRequest $request, LogList $logList): JsonResponse
|
||||||
|
{
|
||||||
|
$logList->update([
|
||||||
|
'description' => $request->description,
|
||||||
|
'log_unique_code' => $request->log_unique_code,
|
||||||
|
'action_type' => $request->action_type,
|
||||||
|
]);
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(LogList $logList): JsonResponse
|
||||||
|
{
|
||||||
|
$logList->delete();
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
197
app/Http/Controllers/V3/NotificationController.php
Normal file
197
app/Http/Controllers/V3/NotificationController.php
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Exceptions\ProhibitedAction;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\EdarateOstani;
|
||||||
|
use App\Models\RoadItemsProject;
|
||||||
|
use App\Models\RoadObserved;
|
||||||
|
use App\Models\SafetyAndPrivacy;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class NotificationController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the incoming request.
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'roadItem' => $this->roadItemNotifications(),
|
||||||
|
'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(),
|
||||||
|
'roadObserved' => $this->roadObservedNotifications(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
private function roadItemNotifications(): JsonResponse|array
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$road_items = [
|
||||||
|
'total' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('create-road-item')) {
|
||||||
|
$road_items['operation_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('user_id', '=', $user->id)
|
||||||
|
->where('status', '=', 2)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['operation_cnt'];
|
||||||
|
}
|
||||||
|
if ($user->hasPermissionTo('supervise-road-item')) {
|
||||||
|
$road_items['supervise_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('status', '=', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['supervise_cnt'];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('supervise-road-item-province')) {
|
||||||
|
throw_if(is_null($user->province_id) || !$user->province_id, new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$road_items['supervise_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->where('status', '=', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['supervise_cnt'];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('supervise-road-item-by-edareostani')) {
|
||||||
|
throw_if(is_null($user->edarate_ostani_id) || !$user->edarate_ostani_id, new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$confirmableItems = EdarateOstani::query()->where('id', '=', $user->edarate_ostani_id)->value('items_for_confirm');
|
||||||
|
$road_items['supervise_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->whereIn('item', explode(",", $confirmableItems))
|
||||||
|
->where('status', '=', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['supervise_cnt'];
|
||||||
|
}
|
||||||
|
return $road_items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
private function safetyAndPrivacyNotifications(): JsonResponse|array
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$safety_and_privacy = array();
|
||||||
|
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||||
|
$activity = SafetyAndPrivacy::query()
|
||||||
|
->selectRaw('count(*) as cnt, step')
|
||||||
|
->groupby('step')
|
||||||
|
->orderBy('step')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {
|
||||||
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$activity = SafetyAndPrivacy::query()
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->selectRaw('count(*) as cnt, step')
|
||||||
|
->groupby('step')
|
||||||
|
->orderBy('step')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) {
|
||||||
|
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$activity = SafetyAndPrivacy::query()
|
||||||
|
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||||
|
->selectRaw('count(*) as cnt, step')
|
||||||
|
->groupby('step')
|
||||||
|
->orderBy('step')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$safety_and_privacy['step_one'] = isset($activity[0]) ? $activity[0]->cnt : 0;
|
||||||
|
$safety_and_privacy['step_two'] = isset($activity[1]) ? $activity[1]->cnt : 0;
|
||||||
|
|
||||||
|
return $safety_and_privacy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
private function roadObservedNotifications(): JsonResponse|array
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$road_observations = [
|
||||||
|
'total' => 0,
|
||||||
|
'operation_cnt' => 0,
|
||||||
|
'complaint_cnt' => 0,
|
||||||
|
'supervise_cnt' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
$conditions = [];
|
||||||
|
$complaintConditions = [
|
||||||
|
['rms_status', '=', 0],
|
||||||
|
['edarate_shahri_id', '!=', null]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('show-fast-react')) {
|
||||||
|
$conditions[] = ['status', '=', 2];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
||||||
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
$conditions = [
|
||||||
|
['status', '=', 2],
|
||||||
|
['rms_province_id', '=', $user->province_id]
|
||||||
|
];
|
||||||
|
$complaintConditions[] = ['province_id', '=', $user->province_id];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
||||||
|
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
|
$conditions = [
|
||||||
|
['status', '=', 2],
|
||||||
|
['edarate_shahri_id', '=', $user->edarate_shahri_id]
|
||||||
|
];
|
||||||
|
$complaintConditions[] = ['edarate_shahri_id', '=', $user->edarate_shahri_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($conditions)) {
|
||||||
|
$road_observations['operation_cnt'] = RoadObserved::query()->where($conditions)->count();
|
||||||
|
$road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count();
|
||||||
|
$road_observations['total'] += $road_observations['operation_cnt'] + $road_observations['complaint_cnt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$superviseConditions = [
|
||||||
|
['status', '=', 0]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('supervise-fast-react')) {
|
||||||
|
$road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count();
|
||||||
|
$road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count();
|
||||||
|
$road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt'];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('supervise-fast-react-province')) {
|
||||||
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
$superviseConditions[] = ['province_id', '=', $user->province_id];
|
||||||
|
$complaintConditions[] = ['province_id', '=', $user->province_id];
|
||||||
|
|
||||||
|
$road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count();
|
||||||
|
$road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count();
|
||||||
|
$road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $road_observations;
|
||||||
|
}
|
||||||
|
}
|
||||||
83
app/Http/Controllers/V3/PermissionManagementController.php
Normal file
83
app/Http/Controllers/V3/PermissionManagementController.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\Permission\StoreRequest;
|
||||||
|
use App\Http\Requests\V3\Permission\UpdateRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\Permission;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class PermissionManagementController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json(DataTableFacade::run(
|
||||||
|
Permission::query(),
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
Permission::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'guard_name' => 'web',
|
||||||
|
'name_fa' => $request->name_fa,
|
||||||
|
'description' => $request->description,
|
||||||
|
'type' => $request->type,
|
||||||
|
'type_fa' => $request->type_fa,
|
||||||
|
'need_province' => $request->need_province,
|
||||||
|
'need_edare_shahri' => $request->need_edare_shahri,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Permission $permission): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Permission $permission): JsonResponse
|
||||||
|
{
|
||||||
|
$permission->update([
|
||||||
|
'name' => $request->name,
|
||||||
|
'name_fa' => $request->name_fa,
|
||||||
|
'description' => $request->description,
|
||||||
|
'type' => $request->type,
|
||||||
|
'type_fa' => $request->type_fa,
|
||||||
|
'need_province' => $request->need_province,
|
||||||
|
'need_edare_shahri' => $request->need_edare_shahri,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Permission $permission): JsonResponse
|
||||||
|
{
|
||||||
|
$permission->delete();
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\AccidentReceipt;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ConfirmPaymentInfoRequest 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 [
|
||||||
|
'deposit_insurance_image' => 'file',
|
||||||
|
'deposit_insurance_amount' => 'required_with:deposit_insurance_image',
|
||||||
|
'deposit_daghi_image' => 'file',
|
||||||
|
'deposit_daghi_amount' => 'required_with:deposit_daghi_image',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/Http/Requests/V3/AccidentReceipt/StoreRequest.php
Normal file
50
app/Http/Requests/V3/AccidentReceipt/StoreRequest.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\AccidentReceipt;
|
||||||
|
|
||||||
|
use App\Enums\AccidentStates;
|
||||||
|
use App\Models\DailyAccidentSettings;
|
||||||
|
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 [
|
||||||
|
'province_id' => 'required|integer|exists:provinces,id',
|
||||||
|
'city_id' => 'required|integer|exists:cities,id',
|
||||||
|
'axis_name' => 'required|string',
|
||||||
|
'driver_name' => 'required|string',
|
||||||
|
'plaque' => 'required|string',
|
||||||
|
'driver_national_code' => 'required|string',
|
||||||
|
'driver_phone_number' => 'required|string',
|
||||||
|
'lat' => 'required|numeric',
|
||||||
|
'lng' => 'required|numeric',
|
||||||
|
'accident_type' => 'required|integer',
|
||||||
|
'accident_date' => 'required|date',
|
||||||
|
'accident_time' => 'required|string',
|
||||||
|
'report_base' => 'required|in:0,1',
|
||||||
|
'police_file' => 'required_if:report_base,0|file|mimes:pdf,jpg,jpeg,png',
|
||||||
|
'police_serial' => 'required_if:report_base,0|string',
|
||||||
|
'police_file_date' => 'required_if:report_base,0|date',
|
||||||
|
'damage_picture1' => 'required|file|mimes:pdf,jpg,jpeg,png',
|
||||||
|
'damage_picture2' => 'required|file|mimes:pdf,jpg,jpeg,png',
|
||||||
|
'damage_items' => 'required|array',
|
||||||
|
'damage_items.*.value' => 'required',
|
||||||
|
'damage_items.*.amount' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php
Normal file
48
app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\AccidentReceipt;
|
||||||
|
|
||||||
|
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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'province_id' => 'required|integer|exists:provinces,id',
|
||||||
|
'city_id' => 'required|integer|exists:cities,id',
|
||||||
|
'axis_name' => 'required|string',
|
||||||
|
'driver_name' => 'required|string',
|
||||||
|
'plaque' => 'required|string',
|
||||||
|
'driver_national_code' => 'required|string',
|
||||||
|
'driver_phone_number' => 'required|string',
|
||||||
|
'lat' => 'required|numeric',
|
||||||
|
'lng' => 'required|numeric',
|
||||||
|
'accident_type' => 'required|integer',
|
||||||
|
'accident_date' => 'required|date',
|
||||||
|
'accident_time' => 'required|string',
|
||||||
|
'report_base' => 'required|in:0,1',
|
||||||
|
'police_file' => 'file|mimes:pdf,jpg,jpeg,png',
|
||||||
|
'police_serial' => 'required_if:report_base,0|string',
|
||||||
|
'police_file_date' => 'required_if:report_base,0|date',
|
||||||
|
'damage_picture1' => 'file|mimes:pdf,jpg,jpeg,png',
|
||||||
|
'damage_picture2' => 'file|mimes:pdf,jpg,jpeg,png',
|
||||||
|
'damage_items' => 'required|array',
|
||||||
|
'damage_items.*.value' => 'required',
|
||||||
|
'damage_items.*.amount' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/V3/Damage/StoreRequest.php
Normal file
30
app/Http/Requests/V3/Damage/StoreRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Damage;
|
||||||
|
|
||||||
|
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 [
|
||||||
|
'title' =>'required|string|max:255|unique:damages,title',
|
||||||
|
'unit' =>'required|string|max:255',
|
||||||
|
'base_price' =>'required|integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Http/Requests/V3/Damage/UpdateRequest.php
Normal file
31
app/Http/Requests/V3/Damage/UpdateRequest.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Damage;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' =>['required', 'string', 'max:255',Rule::unique('damages','title')->ignore($this->damage->id)],
|
||||||
|
'unit' =>'required|string',
|
||||||
|
'base_price' =>'required|integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/V3/LogList/StoreRequest.php
Normal file
30
app/Http/Requests/V3/LogList/StoreRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\LogList;
|
||||||
|
|
||||||
|
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 [
|
||||||
|
'description' =>'required|string',
|
||||||
|
'log_unique_code' =>'required|numeric|unique:log_lists,log_unique_code',
|
||||||
|
'action_type' =>'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Http/Requests/V3/LogList/UpdateRequest.php
Normal file
31
app/Http/Requests/V3/LogList/UpdateRequest.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\LogList;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'description' => 'required|string',
|
||||||
|
'log_unique_code' => ['required', 'numeric', Rule::unique('log_lists', 'log_unique_code')->ignore($this->logList->id)],
|
||||||
|
'action_type' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Http/Requests/V3/Otp/GetOtpTokenRequest.php
Normal file
35
app/Http/Requests/V3/Otp/GetOtpTokenRequest.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Otp;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class GetOtpTokenRequest 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 [
|
||||||
|
'phone_number' => 'required|digits:11|starts_with:09',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'starts_with' => ':attribute باید با :values شروع شود.'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Http/Requests/V3/Permission/StoreRequest.php
Normal file
34
app/Http/Requests/V3/Permission/StoreRequest.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Permission;
|
||||||
|
|
||||||
|
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 [
|
||||||
|
'name' => 'required|string|unique:permissions,name',
|
||||||
|
'name_fa' => 'required|string',
|
||||||
|
'description' => 'string',
|
||||||
|
'type' => 'required|string',
|
||||||
|
'type_fa' => 'required|string',
|
||||||
|
'need_province' => 'required|in:0,1',
|
||||||
|
'need_edare_shahri' => 'required|in:0,1',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Http/Requests/V3/Permission/UpdateRequest.php
Normal file
34
app/Http/Requests/V3/Permission/UpdateRequest.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Permission;
|
||||||
|
|
||||||
|
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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => "required|string|unique:permissions,name,{$this->permission->id}",
|
||||||
|
'name_fa' => 'required|string',
|
||||||
|
'description' => 'string',
|
||||||
|
'type' => 'required|string',
|
||||||
|
'type_fa' => 'required|string',
|
||||||
|
'need_province' => 'required|in:0,1',
|
||||||
|
'need_edare_shahri' => 'required|in:0,1',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ModifyRegisterationRequest 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 [
|
||||||
|
'rms_status' => 'required|in:1,2',
|
||||||
|
'rms_description' => 'required_if:rms_status,1|string',
|
||||||
|
'image_before' => 'file|mimes:jpg,jpeg,png',
|
||||||
|
'image_after' => 'file|mimes:jpg,jpeg,png',
|
||||||
|
'start_point' => 'string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/V3/RoadObservation/ReferRequest.php
Normal file
30
app/Http/Requests/V3/RoadObservation/ReferRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\RoadObservation;
|
||||||
|
|
||||||
|
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->roadObserved->rms_status == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'edarate_shahri_id' => 'required|exists:edarate_shahri,id',
|
||||||
|
'province_id' => 'required|exists:provinces,id',
|
||||||
|
'refer_description' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Http/Requests/V3/RoadObservation/RegisterRequest.php
Normal file
32
app/Http/Requests/V3/RoadObservation/RegisterRequest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class RegisterRequest 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 [
|
||||||
|
'rms_status' => 'required|in:1,2',
|
||||||
|
'rms_description' => 'required_if:rms_status,1|string',
|
||||||
|
'image_before' => 'required_if:rms_status,1|file|mimes:jpg,jpeg,png',
|
||||||
|
'image_after' => 'required_if:rms_status,1|file|mimes:jpg,jpeg,png',
|
||||||
|
'start_point' => 'string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Http/Requests/V3/RoadObservation/RestoreRequest.php
Normal file
28
app/Http/Requests/V3/RoadObservation/RestoreRequest.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class RestoreRequest 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 [
|
||||||
|
'restore_description' => 'string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\RoadObservation;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class VerifyBySupervisorRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return Gate::allows('gate-supervise-road-observed',$this->roadObserved);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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' => ['string'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class FirstStepStoreRequest 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 [
|
||||||
|
'point' => 'required',
|
||||||
|
'info_id' => 'required',
|
||||||
|
'activity_date' => 'required|date_format:Y-m-d',
|
||||||
|
'activity_time' => 'required|date_format:H:i',
|
||||||
|
'recognize_picture' => 'required|image',
|
||||||
|
'axis_type_id' => 'required|integer|exists:axis_types,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'activity_date' => 'تاریخ فعالیت',
|
||||||
|
'activity_time' => 'ساعت فعالیت',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class SecondStepStoreRequest 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 [
|
||||||
|
'judiciary_document' => 'required|array',
|
||||||
|
'judiciary_document.*' => 'file',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ThirdStepStoreRequest 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 [
|
||||||
|
'action_picture' => 'required|image',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,13 @@ class SendRoadObservationToNikarayan implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of times the job may be attempted.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public int $tries = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,13 +2,19 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Traits\ReceiptReportAble;
|
use App\Traits\ReceiptReportAble;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Accident extends Model
|
class Accident extends Model
|
||||||
{
|
{
|
||||||
use ReceiptReportAble, HasFactory;
|
use ReceiptReportAble, HasFactory;
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
@@ -87,4 +93,29 @@ class Accident extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function files(): MorphMany
|
||||||
|
{
|
||||||
|
return $this->morphMany(File::class, 'fileable');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function damagePicture1(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function damagePicture2(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function policeFile(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
app/Models/AxisType.php
Normal file
13
app/Models/AxisType.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AxisType extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
|
}
|
||||||
@@ -2,15 +2,18 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
|
||||||
class Damage extends Model
|
class Damage extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $fillable = [
|
|
||||||
'damage_id',
|
public $timestamps = false;
|
||||||
];
|
|
||||||
public function accidents()
|
protected $guarded = [];
|
||||||
|
public function accidents(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('App\Accident');
|
return $this->belongsToMany('App\Accident');
|
||||||
}
|
}
|
||||||
|
|||||||
19
app/Models/File.php
Normal file
19
app/Models/File.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
|
class File extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function fileable(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,4 +10,6 @@ class LogList extends Model
|
|||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class RoadObserved extends Model
|
class RoadObserved extends Model
|
||||||
{
|
{
|
||||||
@@ -60,6 +62,9 @@ class RoadObserved extends Model
|
|||||||
'supervisor_description',
|
'supervisor_description',
|
||||||
'supervising_time',
|
'supervising_time',
|
||||||
'supervisor_name',
|
'supervisor_name',
|
||||||
|
'rms_start_latlng',
|
||||||
|
'rms_end_latlng',
|
||||||
|
'rms_description',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,4 +104,18 @@ class RoadObserved extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\EdarateShahri', 'edarate_shahri_id');
|
return $this->belongsTo('App\Models\EdarateShahri', 'edarate_shahri_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function imageAfter(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function imageBefore(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Traits\SafetyAndPrivacyReportAble;
|
use App\Traits\SafetyAndPrivacyReportAble;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class SafetyAndPrivacy extends Model
|
class SafetyAndPrivacy extends Model
|
||||||
{
|
{
|
||||||
@@ -26,7 +28,14 @@ class SafetyAndPrivacy extends Model
|
|||||||
'edare_shahri_name',
|
'edare_shahri_name',
|
||||||
'way_id',
|
'way_id',
|
||||||
'activity_date_time',
|
'activity_date_time',
|
||||||
|
'step',
|
||||||
|
'step_fa',
|
||||||
|
'judiciary_document',
|
||||||
|
'judiciary_document_upload_date',
|
||||||
|
'action_picture',
|
||||||
|
'action_picture_document_upload_date',
|
||||||
|
'axis_type_id',
|
||||||
|
'axis_type_name',
|
||||||
];
|
];
|
||||||
|
|
||||||
public $table = "safety_and_privacy";
|
public $table = "safety_and_privacy";
|
||||||
@@ -60,4 +69,23 @@ class SafetyAndPrivacy extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function recognizePicture(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null :
|
||||||
|
(filter_var($value, FILTER_VALIDATE_URL)
|
||||||
|
? $value
|
||||||
|
: Storage::disk('public')->url($value))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
123
app/Services/Cartables/AccidentReceiptTableService.php
Normal file
123
app/Services/Cartables/AccidentReceiptTableService.php
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Cartables;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\Accident;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class AccidentReceiptTableService
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function dataTable(Request $request, $loadRelations = false)
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$query = null;
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('show-receipt')) {
|
||||||
|
$query = Accident::query()
|
||||||
|
->when($loadRelations, fn ($query) => $query->with('damages'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (is_null($user->province_id)) {
|
||||||
|
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = Accident::query()
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->when($loadRelations, fn ($query) => $query->with('damages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryReport(Request $request): array
|
||||||
|
{
|
||||||
|
$data = DB::select(
|
||||||
|
'SELECT
|
||||||
|
"کشوری" as province_fa,
|
||||||
|
-1 as province_id,
|
||||||
|
COUNT(id) AS tedade,
|
||||||
|
COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah,
|
||||||
|
COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht,
|
||||||
|
SUM(`sum`) AS kol_sabt_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final
|
||||||
|
FROM `accidents`
|
||||||
|
where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'"
|
||||||
|
union
|
||||||
|
SELECT
|
||||||
|
province_fa,
|
||||||
|
province_id,
|
||||||
|
COUNT(id) AS tedade,
|
||||||
|
COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah,
|
||||||
|
COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht,
|
||||||
|
SUM(`sum`) AS kol_sabt_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final
|
||||||
|
FROM `accidents`
|
||||||
|
where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'"
|
||||||
|
GROUP BY province_id
|
||||||
|
'
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'data' => $data,
|
||||||
|
'fromDate' => $request->from_date,
|
||||||
|
'toDate' => $request->date_to,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceReport(Request $request): array
|
||||||
|
{
|
||||||
|
$data = DB::select(
|
||||||
|
'SELECT
|
||||||
|
"استانی" as city_fa,
|
||||||
|
-1 as city_id,
|
||||||
|
COUNT(id) AS tedade,
|
||||||
|
COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah,
|
||||||
|
COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht,
|
||||||
|
SUM(`sum`) AS kol_sabt_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final
|
||||||
|
FROM `accidents`
|
||||||
|
where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'" AND province_id ='.$request->province_id.'
|
||||||
|
union
|
||||||
|
SELECT
|
||||||
|
city_fa,
|
||||||
|
city_id,
|
||||||
|
COUNT(id) AS tedade,
|
||||||
|
COUNT(CASE WHEN report_base = 0 THEN 1 END) AS police_rah,
|
||||||
|
COUNT(CASE WHEN report_base = 1 THEN 1 END) AS gozaresh_gasht,
|
||||||
|
SUM(`sum`) AS kol_sabt_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `sum` END) AS vasel_shode,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_insurance_amount` END) AS vasel_shode_bimeh,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `deposit_daghi_amount` END) AS vasel_shode_daghi,
|
||||||
|
SUM(CASE WHEN STATUS > 3 THEN `final_amount` END) AS vasel_shode_final
|
||||||
|
FROM `accidents`
|
||||||
|
where created_at BETWEEN "'.$request->from_date.'" AND "'.$request->date_to.'" AND province_id ='.$request->province_id.'
|
||||||
|
GROUP BY city_id
|
||||||
|
'
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'data' => $data,
|
||||||
|
'fromDate' => $request->from_date,
|
||||||
|
'toDate' => $request->date_to,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Services\Reports;
|
namespace App\Services\Cartables;
|
||||||
|
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
@@ -9,33 +9,33 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class RoadItemReportService
|
class RoadItemTableService
|
||||||
{
|
{
|
||||||
public function supervisorCartableReport(Request $request)
|
public function supervisorCartableReport(Request $request, $loadRelations = false)
|
||||||
{
|
{
|
||||||
$columns = array(
|
$allowedFilters = ['*'];
|
||||||
'id', 'user_id', 'start_lat', 'start_lng', 'end_lat',
|
$allowedSortings = ['*'];
|
||||||
'end_lng', 'project_distance', 'item', 'item_fa', 'sub_item_fa', 'sub_item',
|
|
||||||
'sub_item_data', 'created_at', 'updated_at', 'province_id', 'province_fa',
|
|
||||||
'unit_fa', 'status', 'status_fa', 'supervisor_description', 'supervising_time',
|
|
||||||
'supervisor_name', 'edarat_id', 'edarat_name', 'activity_date_time','cmmsMachines.machine_code', 'rahdaran.code',
|
|
||||||
);
|
|
||||||
|
|
||||||
$allowedFilters = $columns;
|
|
||||||
$allowedSortings = $columns;
|
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$query = null;
|
$query = null;
|
||||||
|
|
||||||
if ($user->hasPermissionTo('show-road-item-supervise-cartable')) {
|
if ($user->hasPermissionTo('show-road-item-supervise-cartable')) {
|
||||||
$query = RoadItemsProject::query()->where('is_new', 1)->with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']);
|
$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')) {
|
elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) {
|
||||||
if (is_null($user->province_id)) {
|
if (is_null($user->province_id)) {
|
||||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||||
}
|
}
|
||||||
$query = RoadItemsProject::query()->where('is_new', 1)
|
$query = RoadItemsProject::query()
|
||||||
->with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])->where('province_id', auth()->user()->province_id);
|
->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(
|
$data = DataTableFacade::run(
|
||||||
@@ -47,22 +47,17 @@ class RoadItemReportService
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorCartableReport(Request $request)
|
public function operatorCartableReport(Request $request, $loadRelations = false)
|
||||||
{
|
{
|
||||||
$columns = array(
|
$allowedFilters = ['*'];
|
||||||
'id', 'user_id', 'start_lat', 'start_lng', 'end_lat',
|
$allowedSortings = ['*'];
|
||||||
'end_lng', 'project_distance', 'item', 'item_fa', 'sub_item_fa', 'sub_item',
|
|
||||||
'sub_item_data', 'created_at', 'updated_at', 'province_id', 'province_fa',
|
|
||||||
'unit_fa', 'status', 'status_fa', 'supervisor_description', 'supervising_time',
|
|
||||||
'supervisor_name', 'edarat_id', 'edarat_name', 'activity_date_time', 'cmmsMachines.machine_code', 'rahdaran.code',
|
|
||||||
);
|
|
||||||
|
|
||||||
$allowedFilters = $columns;
|
$query = RoadItemsProject::query()
|
||||||
$allowedSortings = $columns;
|
->select(['id', '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'])
|
||||||
$query = RoadItemsProject::with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
|
|
||||||
->where('is_new', 1)
|
->where('is_new', 1)
|
||||||
->where('user_id', auth()->user()->id);
|
->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(
|
$data = DataTableFacade::run(
|
||||||
$query,
|
$query,
|
||||||
169
app/Services/Cartables/RoadObservationTableService.php
Normal file
169
app/Services/Cartables/RoadObservationTableService.php
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Cartables;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\RoadObserved;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class RoadObservationTableService
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
public function supervisorCartableIndex(Request $request)
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'fk_RegisteredEventMessage', 'road_observeds.id', 'Title', 'road_observeds.created_at', 'StartTime_DateTime',
|
||||||
|
'lat', 'lng', 'FeatureTypeTitle', 'Description', 'MobileForSendEventSms', 'rms_start_latlng',
|
||||||
|
'rms_description', 'rms_status', 'rms_last_activity_fa', 'rms_last_activity', 'edarate_shahri_id',
|
||||||
|
'road_observeds.province_id', 'province_fa', 'city_id', 'city_fa', 'edarate_shahri.name_fa',
|
||||||
|
'status', 'status_fa', 'supervisor_description', 'supervising_time', 'image_after', 'image_before'
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('show-fast-react')) {
|
||||||
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
|
->whereNotNull('road_observeds.status')
|
||||||
|
->select($fields);
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-province'))
|
||||||
|
{
|
||||||
|
if (is_null($user->province_id))
|
||||||
|
{
|
||||||
|
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
|
->where('road_observeds.province_id', $user->province_id)
|
||||||
|
->whereNotNull('road_observeds.status')
|
||||||
|
->select($fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function operatorCartableIndex(Request $request)
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'fk_RegisteredEventMessage', 'road_observeds.id', 'Title', 'road_observeds.created_at', 'StartTime_DateTime',
|
||||||
|
'lat', 'lng', 'FeatureTypeTitle', 'Description', 'MobileForSendEventSms', 'edarate_shahri_id',
|
||||||
|
'rms_description', 'rms_status', 'rms_start_latlng', 'rms_last_activity_fa', 'image_after', 'image_before',
|
||||||
|
'rms_last_activity', 'road_observeds.province_id', 'province_fa', 'city_id', 'city_fa',
|
||||||
|
'edarate_shahri.name_fa', 'status', 'status_fa', 'supervisor_description', 'supervising_time'
|
||||||
|
];
|
||||||
|
|
||||||
|
$query = RoadObserved::query()
|
||||||
|
->where('rms_status', '!=', 0)
|
||||||
|
->whereNotNull('road_observeds.province_id')
|
||||||
|
->whereNotNull('status')
|
||||||
|
->leftJoin('edarate_shahri', 'road_observeds.edarate_shahri_id', '=', 'edarate_shahri.id')
|
||||||
|
->where('edarate_shahri_id', $user->edarate_shahri_id)
|
||||||
|
->select($fields);
|
||||||
|
|
||||||
|
return DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function complaintsIndex(Request $request)
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$fields = 'fk_RegisteredEventMessage, road_observeds.id, Title, FeatureTypeTitle, MobileForSendEventSms, StartTime_DateTime,
|
||||||
|
road_observeds.created_at, rms_last_activity, rms_last_activity_fa, status, edarate_shahri_id,
|
||||||
|
status_fa, supervisor_description, rms_description, province_fa, city_id, city_fa, Description, edarate_shahri.name_fa as edarate_shahri_name_fa, lat, lng';
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('show-fast-react')) {
|
||||||
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
|
->where('rms_status', '=', 0)
|
||||||
|
->whereNotNull('edarate_shahri_id')
|
||||||
|
->selectRaw($fields);
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
||||||
|
|
||||||
|
if (is_null($user->province_id)) {
|
||||||
|
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
|
->where('rms_status', '=', 0)
|
||||||
|
->whereNotNull('road_observeds.province_id')
|
||||||
|
->where('road_observeds.province_id', '=', $user->province_id)
|
||||||
|
->selectRaw($fields);
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
||||||
|
|
||||||
|
if (is_null($user->edarate_shahri_id)) {
|
||||||
|
return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
|
->where('rms_status', '=', 0)
|
||||||
|
->whereNotNull('edarate_shahri_id')
|
||||||
|
->where('edarate_shahri_id', '=', $user->edarate_shahri_id)
|
||||||
|
->selectRaw($fields);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reportIndex(Request $request)
|
||||||
|
{
|
||||||
|
$fromDate = $request->from_date . ' 00:00:00';
|
||||||
|
$toDate = $request->date_to . ' 23:59:59';
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'fk_RegisteredEventMessage',
|
||||||
|
'road_observeds.id',
|
||||||
|
'Title',
|
||||||
|
'road_observeds.created_at',
|
||||||
|
'lat',
|
||||||
|
'lng',
|
||||||
|
'FeatureTypeTitle',
|
||||||
|
'Description',
|
||||||
|
'MobileForSendEventSms',
|
||||||
|
'road_observeds.province_id',
|
||||||
|
'province_fa',
|
||||||
|
'city_fa',
|
||||||
|
'edarate_shahri.name_fa',
|
||||||
|
'rms_last_activity_fa',
|
||||||
|
'rms_description'
|
||||||
|
];
|
||||||
|
|
||||||
|
$query = RoadObserved::leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
|
->where('rms_status', "<>", 0)
|
||||||
|
->whereNotNull('edarate_shahri_id')
|
||||||
|
->whereBetween('road_observeds.created_at', [$fromDate, $toDate])
|
||||||
|
->select($fields);
|
||||||
|
|
||||||
|
$data = DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'data' => $data,
|
||||||
|
'fromDate' => $fromDate,
|
||||||
|
'toDate' => $toDate,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,41 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Services\Reports;
|
namespace App\Services\Cartables;
|
||||||
|
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Models\RoadPatrol;
|
use App\Models\RoadPatrol;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class RoadPatrolReportService
|
class RoadPatrolTableService
|
||||||
{
|
{
|
||||||
public function supervisorCartableReport(Request $request)
|
public function supervisorCartableReport(Request $request, $loadRelations = false)
|
||||||
{
|
{
|
||||||
$columns = array(
|
$allowedFilters = ['*'];
|
||||||
'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'operator_id', 'created_at',
|
$allowedSortings = ['*'];
|
||||||
'operator_name', 'officer_plaque', 'officer_phone_number', 'officer_name',
|
|
||||||
'supervisor_description', 'supervising_time', 'supervisor_name', 'status',
|
|
||||||
'status_fa', 'distance', 'province_id', 'province_fa', 'edare_id', 'edare_name',
|
|
||||||
'start_time', 'end_time','description', 'cmmsMachines.machine_code', 'rahdaran.code',
|
|
||||||
);
|
|
||||||
|
|
||||||
$allowedFilters = $columns;
|
|
||||||
$allowedSortings = $columns;
|
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$query = null;
|
$query = null;
|
||||||
|
|
||||||
if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) {
|
if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) {
|
||||||
$query = RoadPatrol::query()
|
$query = RoadPatrol::query()
|
||||||
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']);
|
->select([
|
||||||
|
'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description',
|
||||||
|
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points'
|
||||||
|
])
|
||||||
|
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||||
}
|
}
|
||||||
elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) {
|
elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) {
|
||||||
if (is_null($user->province_id)) {
|
if (is_null($user->province_id)) {
|
||||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||||
}
|
}
|
||||||
$query = RoadPatrol::query()
|
$query = RoadPatrol::query()
|
||||||
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
|
->select([
|
||||||
->where('province_id', '=', $user->province_id);
|
'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description',
|
||||||
|
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points'
|
||||||
|
])
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = DataTableFacade::run(
|
$data = DataTableFacade::run(
|
||||||
@@ -47,20 +47,18 @@ class RoadPatrolReportService
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorCartableReport(Request $request)
|
public function operatorCartableReport(Request $request, $loadRelations = false)
|
||||||
{
|
{
|
||||||
$columns = array(
|
$allowedFilters = ['*'];
|
||||||
'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'officer_plaque', 'created_at',
|
$allowedSortings = ['*'];
|
||||||
'officer_phone_number', 'officer_name', 'supervisor_description', 'supervising_time',
|
|
||||||
'supervisor_name', 'status', 'status_fa', 'distance', 'start_time', 'end_time', 'cmmsMachines.machine_code', 'rahdaran.code',
|
|
||||||
);
|
|
||||||
|
|
||||||
$allowedFilters = $columns;
|
|
||||||
$allowedSortings = $columns;
|
|
||||||
|
|
||||||
$query = RoadPatrol::query()
|
$query = RoadPatrol::query()
|
||||||
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
|
->select([
|
||||||
->where('operator_id', '=', auth()->user()->id);
|
'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description',
|
||||||
|
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points'
|
||||||
|
])
|
||||||
|
->where('operator_id', '=', auth()->user()->id)
|
||||||
|
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||||
|
|
||||||
$data = DataTableFacade::run(
|
$data = DataTableFacade::run(
|
||||||
$query,
|
$query,
|
||||||
240
app/Services/Cartables/SafetyAndPrivacyTableService.php
Normal file
240
app/Services/Cartables/SafetyAndPrivacyTableService.php
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Cartables;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Models\SafetyAndPrivacy;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class SafetyAndPrivacyTableService
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function dataTable(Request $request, $loadRelations = false)
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$fields = ['id','lat','lon','province_id','province_fa','city_id','city_fa','edare_shahri_id','edare_shahri_name',
|
||||||
|
'recognize_picture','action_picture','operator_id','operator_name','way_id','created_at','updated_at','step',
|
||||||
|
'info_id','info_fa','activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date',
|
||||||
|
'step_fa', 'axis_type_id', 'axis_type_name'
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||||
|
$query = SafetyAndPrivacy::query()->select($fields);
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {
|
||||||
|
if (is_null($user->province_id)) {
|
||||||
|
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = SafetyAndPrivacy::query()->where('province_id', '=', $user->province_id)->select($fields);
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) {
|
||||||
|
if (is_null($user->edarate_shahri_id)) {
|
||||||
|
return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString();
|
||||||
|
$toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString();
|
||||||
|
$axisTypeId = $request->axis_type_id;
|
||||||
|
|
||||||
|
$activities = [];
|
||||||
|
|
||||||
|
$country = SafetyAndPrivacy::query()
|
||||||
|
->selectRaw('COUNT(*) as qty,info_id, step')
|
||||||
|
->whereBetween('created_at', [$fromDate, $toDate])
|
||||||
|
->when($axisTypeId, function ($query) use ($axisTypeId) {
|
||||||
|
$query->where('axis_type_id', '=', $axisTypeId);
|
||||||
|
})
|
||||||
|
->groupBy('info_id', 'step')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// $country = DB::select(
|
||||||
|
// "SELECT COUNT(*) as qty,info_id, step
|
||||||
|
// FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."'
|
||||||
|
// GROUP BY info_id,step"
|
||||||
|
// );
|
||||||
|
|
||||||
|
$countryTotalSum = 0;
|
||||||
|
$countryData = [
|
||||||
|
'name_fa' => 'کشوری',
|
||||||
|
'province_id' => -1,
|
||||||
|
'sum' => 0,
|
||||||
|
'89' => [
|
||||||
|
'1' => 0,
|
||||||
|
'2' => 0,
|
||||||
|
'3' => 0,
|
||||||
|
],
|
||||||
|
'90' => [
|
||||||
|
'1' => 0,
|
||||||
|
'2' => 0,
|
||||||
|
'3' => 0,
|
||||||
|
],
|
||||||
|
'91' => [
|
||||||
|
'1' => 0,
|
||||||
|
'2' => 0,
|
||||||
|
'3' => 0,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
foreach ($country as $key => $value) {
|
||||||
|
$countryTotalSum += $value->qty;
|
||||||
|
$countryData[$value->info_id][$value->step] = $value->qty;
|
||||||
|
$countryData["sum"] = $countryTotalSum;
|
||||||
|
}
|
||||||
|
$activities[] = (object) $countryData;
|
||||||
|
|
||||||
|
$provinces = SafetyAndPrivacy::query()
|
||||||
|
->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step')
|
||||||
|
->whereBetween('created_at', [$fromDate, $toDate])
|
||||||
|
->when($axisTypeId, function ($query) use ($axisTypeId) {
|
||||||
|
$query->where('axis_type_id', '=', $axisTypeId);
|
||||||
|
})
|
||||||
|
->groupBy('info_id', 'step', 'province_id', 'province_fa')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// $provinces = DB::select(
|
||||||
|
// "SELECT province_id, province_fa, COUNT(*) as qty,info_id, step
|
||||||
|
// FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."'
|
||||||
|
// GROUP BY info_id,step,province_id,province_fa"
|
||||||
|
// );
|
||||||
|
|
||||||
|
foreach ($provinces as $value) {
|
||||||
|
$provinceId = $value->province_id;
|
||||||
|
|
||||||
|
// Check if the province already exists in the activities array
|
||||||
|
if (!isset($activities[$provinceId])) {
|
||||||
|
$activities[$provinceId] = (object) [
|
||||||
|
'province_id' => $provinceId,
|
||||||
|
'name_fa' => $value->province_fa,
|
||||||
|
'sum' => 0,
|
||||||
|
'89' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'90' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'91' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$activities[$provinceId]->{$value->info_id}[$value->step] = $value->qty;
|
||||||
|
$activities[$provinceId]->sum += $value->qty;
|
||||||
|
}
|
||||||
|
|
||||||
|
$activities = array_values($activities);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'activities' => $activities,
|
||||||
|
'fromDate' => $fromDate,
|
||||||
|
'toDate' => $toDate,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString();
|
||||||
|
$toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString();
|
||||||
|
$provinceId = $request->province_id;
|
||||||
|
$axisTypeId = $request->axis_type_id;
|
||||||
|
$activities = [];
|
||||||
|
|
||||||
|
$province = SafetyAndPrivacy::query()
|
||||||
|
->selectRaw('COUNT(*) as qty,info_id, step')
|
||||||
|
->where('province_id', '=', $provinceId)
|
||||||
|
->whereBetween('created_at', [$fromDate, $toDate])
|
||||||
|
->when($axisTypeId, function ($query) use ($axisTypeId) {
|
||||||
|
$query->where('axis_type_id', '=', $axisTypeId);
|
||||||
|
})
|
||||||
|
->groupBy('info_id', 'step')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// $province = DB::select('
|
||||||
|
// SELECT COUNT(*) as qty,info_id, step
|
||||||
|
// FROM safety_and_privacy where province_id ='.$provinceId.' and created_at BETWEEN "'.$fromDate.'" and "'.$toDate.'"
|
||||||
|
// GROUP BY info_id,step
|
||||||
|
// ');
|
||||||
|
|
||||||
|
$provinceTotalSum = 0;
|
||||||
|
$provinceData = [
|
||||||
|
'name_fa' => 'استانی',
|
||||||
|
'edare_shahri_id' => -1,
|
||||||
|
'sum' => 0,
|
||||||
|
'89' => [
|
||||||
|
'1' => 0,
|
||||||
|
'2' => 0,
|
||||||
|
'3' => 0,
|
||||||
|
],
|
||||||
|
'90' => [
|
||||||
|
'1' => 0,
|
||||||
|
'2' => 0,
|
||||||
|
'3' => 0,
|
||||||
|
],
|
||||||
|
'91' => [
|
||||||
|
'1' => 0,
|
||||||
|
'2' => 0,
|
||||||
|
'3' => 0,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
foreach ($province as $key => $value) {
|
||||||
|
$provinceTotalSum += $value->qty;
|
||||||
|
$provinceData["sum"] = $provinceTotalSum;
|
||||||
|
$provinceData[$value->info_id][$value->step] = $value->qty;
|
||||||
|
}
|
||||||
|
$activities[] = (object) $provinceData;
|
||||||
|
|
||||||
|
$cities = SafetyAndPrivacy::query()
|
||||||
|
->selectRaw('edare_shahri_id, COUNT(*) as qty,info_id, step')
|
||||||
|
->where('province_id', '=', $provinceId)
|
||||||
|
->whereBetween('created_at', [$fromDate, $toDate])
|
||||||
|
->when($axisTypeId, function ($query) use ($axisTypeId) {
|
||||||
|
$query->where('axis_type_id', '=', $axisTypeId);
|
||||||
|
})
|
||||||
|
->groupBy('info_id', 'step', 'edare_shahri_id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// $cities = DB::select('
|
||||||
|
// SELECT edare_shahri_id, COUNT(*) as qty,info_id, step
|
||||||
|
// FROM safety_and_privacy where province_id ='.$provinceId.' and created_at BETWEEN "'.$fromDate.'" and "'.$toDate.'"
|
||||||
|
// GROUP BY info_id,step,edare_shahri_id
|
||||||
|
// ');
|
||||||
|
|
||||||
|
foreach ($cities as $value) {
|
||||||
|
$cityId = $value->edare_shahri_id;
|
||||||
|
|
||||||
|
// Initialize data for each unique city
|
||||||
|
if (!isset($activities[$cityId])) {
|
||||||
|
$activities[$cityId] = (object) [
|
||||||
|
'edare_shahri_id' => $cityId,
|
||||||
|
'name_fa' => \App\Models\EdarateShahri::query()->find($cityId)->name_fa,
|
||||||
|
'sum' => 0,
|
||||||
|
'89' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'90' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
'91' => ['1' => 0, '2' => 0, '3' => 0],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$activities[$cityId]->{$value->info_id}[$value->step] = $value->qty;
|
||||||
|
$activities[$cityId]->sum += $value->qty;
|
||||||
|
}
|
||||||
|
|
||||||
|
$activities = array_values($activities);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'activities' => $activities,
|
||||||
|
'fromDate' => $fromDate,
|
||||||
|
'toDate' => $toDate,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,7 +66,7 @@ class ApplyFilter
|
|||||||
}
|
}
|
||||||
|
|
||||||
$relation = $this->filter->getRelation();
|
$relation = $this->filter->getRelation();
|
||||||
return $relation ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply();
|
return method_exists($this->query->getModel(), $relation) ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function applyFilterToRelation(string $relation): Builder
|
protected function applyFilterToRelation(string $relation): Builder
|
||||||
|
|||||||
@@ -5,31 +5,71 @@ namespace App\Services;
|
|||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use SoapClient;
|
use SoapClient;
|
||||||
|
use SoapFault;
|
||||||
|
|
||||||
class NikarayanService
|
class NikarayanService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws SoapFault
|
||||||
|
*/
|
||||||
public function updateRoadObservedInfoByNikarayan(Request $request, RoadObserved $roadObserved, $files)
|
public function updateRoadObservedInfoByNikarayan(Request $request, RoadObserved $roadObserved, $files)
|
||||||
{
|
{
|
||||||
if (App::isProduction())
|
if (App::isProduction())
|
||||||
{
|
{
|
||||||
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
try {
|
||||||
|
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
||||||
|
|
||||||
$array = array('strUserName' => 'vaytelrop',
|
$array = array('strUserName' => 'vaytelrop',
|
||||||
'strPassword' => 'VaYtelROP*2024',
|
'strPassword' => 'VaYtelROP*2024',
|
||||||
'strAutoID' => $roadObserved->fk_RegisteredEventMessage,
|
'strAutoID' => $roadObserved->fk_RegisteredEventMessage,
|
||||||
'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3',
|
'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3',
|
||||||
'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description,
|
'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description,
|
||||||
'strPreviousImageLink' => "https://rms.rmto.ir/".$files,
|
'strPreviousImageLink' => "https://rms.rmto.ir/".$files,
|
||||||
'strNextImageLink' => "https://rms.rmto.ir/".$files,
|
'strNextImageLink' => "https://rms.rmto.ir/".$files,
|
||||||
'strRMSDateAndTime' => $roadObserved->updated_at
|
'strRMSDateAndTime' => $roadObserved->updated_at
|
||||||
);
|
);
|
||||||
|
|
||||||
$soapClient = new SoapClient($url);
|
$soapClient = new SoapClient($url);
|
||||||
|
$result = $soapClient->UpdateInfo_RoadObservedProblems($array);
|
||||||
|
Log::channel('nikarayan')->info($result);
|
||||||
|
|
||||||
return $soapClient->UpdateInfo_RoadObservedProblems($array);
|
return $result;
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
Log::channel('nikarayan')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws SoapFault
|
||||||
|
*/
|
||||||
|
public function getRoadObservedProblemsByDate()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
||||||
|
|
||||||
|
$v = verta();
|
||||||
|
$month = $v->month < 10 ? '0' . $v->month : $v->month;
|
||||||
|
$day = $v->day < 10 ? '0' . $v->day : $v->day;
|
||||||
|
$date = $v->year . $month . $day;
|
||||||
|
|
||||||
|
$soap_client = new SoapClient($url);
|
||||||
|
return $soap_client->Get_RoadObservedProblems_ByDate(array(
|
||||||
|
'strUserName' => 'vaytelrop',
|
||||||
|
'strPassword' => 'VaYtelROP*2024',
|
||||||
|
'strStartDate' => $date,
|
||||||
|
'strEndDate' => $date
|
||||||
|
));
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
Log::channel('nikarayan')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,62 +2,82 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class NominatimService
|
class NominatimService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function get_way_id_from_nominatim($lat = null, $lng = null)
|
public function get_way_id_from_nominatim($lat = null, $lng = null)
|
||||||
{
|
{
|
||||||
if (App::isProduction())
|
if (App::isProduction())
|
||||||
{
|
{
|
||||||
$url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16";
|
try {
|
||||||
$arrContextOptions=array(
|
$url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16";
|
||||||
"ssl"=>array(
|
$arrContextOptions=array(
|
||||||
"verify_peer"=>false,
|
"ssl"=>array(
|
||||||
"verify_peer_name"=>false,
|
"verify_peer"=>false,
|
||||||
),
|
"verify_peer_name"=>false,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||||
$result = json_decode($result);
|
$result = json_decode($result);
|
||||||
if (isset($result->osm_type)) {
|
if (isset($result->osm_type)) {
|
||||||
if ($result->osm_type == 'way') {
|
if ($result->osm_type == 'way') {
|
||||||
return $result->osm_id;
|
return $result->osm_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel('nominatim')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
function getIDFromNominatim($s_lng, $s_lat, $d_lng, $d_lat)
|
function getIDFromNominatim($s_lng, $s_lat, $d_lng, $d_lat)
|
||||||
{
|
{
|
||||||
if (App::isProduction())
|
if (App::isProduction())
|
||||||
{
|
{
|
||||||
$url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true";
|
try {
|
||||||
$arrContextOptions = array(
|
$url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true";
|
||||||
"ssl" => array(
|
$arrContextOptions = array(
|
||||||
"verify_peer" => false,
|
"ssl" => array(
|
||||||
"verify_peer_name" => false,
|
"verify_peer" => false,
|
||||||
),
|
"verify_peer_name" => false,
|
||||||
);
|
),
|
||||||
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
);
|
||||||
$result = json_decode($result);
|
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||||
if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) {
|
$result = json_decode($result);
|
||||||
// if(){
|
if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) {
|
||||||
$ways = $result->routes[1]->legs[0]->steps;
|
// if(){
|
||||||
// }
|
$ways = $result->routes[1]->legs[0]->steps;
|
||||||
} else
|
// }
|
||||||
$ways = $result->routes[0]->legs[0]->steps;
|
} else
|
||||||
$ids = array();
|
$ways = $result->routes[0]->legs[0]->steps;
|
||||||
foreach ($ways as $key => $value) {
|
$ids = array();
|
||||||
if (!in_array($value->name, $ids)) {
|
foreach ($ways as $key => $value) {
|
||||||
$ids[] = $value->name;
|
if (!in_array($value->name, $ids)) {
|
||||||
|
$ids[] = $value->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel('nominatim')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [1, 2, 3];
|
return [1, 2, 3];
|
||||||
|
|||||||
@@ -117,6 +117,18 @@ return [
|
|||||||
'path' => storage_path('logs/road_observation_problem.log'),
|
'path' => storage_path('logs/road_observation_problem.log'),
|
||||||
'level' => 'info',
|
'level' => 'info',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'nominatim' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/nominatim.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
],
|
||||||
|
|
||||||
|
'nikarayan' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/nikarayan.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
23
database/factories/AxisTypeFactory.php
Normal file
23
database/factories/AxisTypeFactory.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AxisType>
|
||||||
|
*/
|
||||||
|
class AxisTypeFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
26
database/factories/DamageFactory.php
Normal file
26
database/factories/DamageFactory.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Damage>
|
||||||
|
*/
|
||||||
|
class DamageFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => $this->faker->title(),
|
||||||
|
'unit' => $this->faker->word(),
|
||||||
|
'base_price' => $this->faker->numberBetween(1000, 10000),
|
||||||
|
'status' => 1
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
database/factories/FileFactory.php
Normal file
23
database/factories/FileFactory.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\File>
|
||||||
|
*/
|
||||||
|
class FileFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
database/migrations/2025_02_22_101703_create_files_table.php
Normal file
30
database/migrations/2025_02_22_101703_create_files_table.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('files', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->text('path');
|
||||||
|
$table->morphs('fileable');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('files');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('road_observation_histories', function (Blueprint $table) {
|
||||||
|
$table->string('from_province')->nullable();
|
||||||
|
$table->string('to_province')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('road_observation_histories', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('from_province');
|
||||||
|
$table->dropColumn('to_province');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('axis_types', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('axis_types');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||||
|
$table->foreignId('axis_type_id')->nullable()->constrained('axis_types');
|
||||||
|
$table->string('axis_type_name')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('axis_type_id');
|
||||||
|
$table->dropColumn('axis_type_name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
17
database/seeders/AxisTypeSeeder.php
Normal file
17
database/seeders/AxisTypeSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class AxisTypeSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
18
database/seeders/DamageSeeder.php
Normal file
18
database/seeders/DamageSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DamageSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
Damage::factory(10)->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
database/seeders/FileSeeder.php
Normal file
17
database/seeders/FileSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class FileSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|||||||
@@ -202,5 +202,8 @@ return [
|
|||||||
'fields.*.option' => 'گزینه های فیلد',
|
'fields.*.option' => 'گزینه های فیلد',
|
||||||
'cmms_machine_id' => 'کد یکتا ماشین',
|
'cmms_machine_id' => 'کد یکتا ماشین',
|
||||||
'contract_subitem_id' => 'کد یکتای پروژه',
|
'contract_subitem_id' => 'کد یکتای پروژه',
|
||||||
|
'base_price' => 'قیمت پایه',
|
||||||
|
'unit' => 'واحد',
|
||||||
|
'phone_number'=> 'شماره تلفن'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>کشوری</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
|
||||||
|
گزارش خسارات وارده به ابنیه فنی و تاسیسات راه از تاریخ
|
||||||
|
{{ verta($fromDate)->format('Y/n/j') }}
|
||||||
|
تا
|
||||||
|
تاریخ
|
||||||
|
{{ verta($toDate)->format('Y/n/j') }}
|
||||||
|
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr class="headercolortable">
|
||||||
|
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
اداره کل
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
تعداد کل
|
||||||
|
</th>
|
||||||
|
<th colspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
نحوه شناسایی خسارت
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
مبلغ کل خسارت ثبت شده (ریال)
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
کل مبلغ وصول شده (ریال)
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
مبلغ وصول شده به تفکیک نوع پرداخت (ریال)
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گزارش پلیس راه
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گزارش گشت راهداری
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
فیش
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
بیمه
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
کسر داغی
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $road)
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['name'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['tedade'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['police_rah'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['gozaresh_gasht'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['kol_sabt_shode'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode_final'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode_bimeh'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode_daghi'] }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>خسارات وارده به ابنیه فنی</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="16" style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;text-align:center;">
|
||||||
|
تاریخ دریافت گزارش: {{verta()->now()->format('Y/m/d H:i')}}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="16" style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;"></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="16" style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">گزارش کلی خسارات وارده</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">کد یکتا</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">استان</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">شهرستان</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">نام محور</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">نام راننده</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">کد ملی راننده</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">شماره موبایل راننده</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">پلاک</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">نوع تصادف</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">تاریخ تصادف</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">مبلغ کل خسارت</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">مبلغ فیش</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">مبلغ بیمه</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">مبلغ داغی</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">تاریخ ثبت</th>
|
||||||
|
<th style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">وضعیت</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->id}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->province_fa}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->city_fa}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->axis_name}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->driver_name}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->driver_national_code}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->driver_phone_number}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->plaque}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->accident_type_fa}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{Hekmatinasser\Verta\Verta::instance($item->accident_date)->format('Y/n/j')}} {{$item->accident_time}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->sum ?? 0}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->final_amount ?? 0}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->deposit_insurance_amount ?? 0}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->deposit_daghi_amount ?? 0}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{Hekmatinasser\Verta\Verta::instance($item->created_at)->format('Y/n/j')}}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{$item->status_fa}}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>استانی</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
|
||||||
|
گزارش خسارات وارده به ابنیه فنی و تاسیسات راه از تاریخ
|
||||||
|
{{ verta($fromDate)->format('Y/n/j') }}
|
||||||
|
تا
|
||||||
|
تاریخ
|
||||||
|
{{ verta($toDate)->format('Y/n/j') }}
|
||||||
|
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
<tr class="headercolortable">
|
||||||
|
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
اداره کل
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
تعداد کل
|
||||||
|
</th>
|
||||||
|
<th colspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
تعداد نحوه شناسایی خسارت
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
مبلغ کل خسارت ثبت شده (ریال)
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
کل مبلغ وصول شده (ریال)
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
مبلغ وصول شده به تفکیک نوع پرداخت (ریال)
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گزارش پلیس راه
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گزارش گشت راهداری
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
فیش
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
بیمه
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
داغی
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $road)
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['name'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['tedade'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['police_rah'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['gozaresh_gasht'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['kol_sabt_shode'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode_final'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode_bimeh'] }}</td>
|
||||||
|
<td style="text-align: center;border:1px solid black;background-color: #DAEEF3;">
|
||||||
|
{{ $road['vasel_shode_daghi'] }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>گزارش واکنش سریع</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
table,
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="10"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="10"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="10"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||||
|
گزارش رسیدگی به شکایات واکنش سریع
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">کد یکتا</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">کد سوانح</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">استان</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">اداره</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">موضوع گزارش</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">نوع گزارش</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">توضیح گزارش</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">موقعیت مکانی</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">شماره تماس گیرنده</th>
|
||||||
|
<th rowspan="1" style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">تاریخ ثبت</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['id'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['fk_RegisteredEventMessage'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['province_fa'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['edarate_shahri_name_fa'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['Title'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['FeatureTypeTitle'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['Description'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ isset($item['lat']) && isset($item['lng']) ? $item['lat'] . ' ' . $item['lng'] : '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['MobileForSendEventSms'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>گزارش واکنش سریع</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
table,
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
|
||||||
|
گزارش کارتابل عملیات واکنش سریع
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>کد یکتا</th>
|
||||||
|
<th>کد سوانح</th>
|
||||||
|
<th>موضوع گزارش</th>
|
||||||
|
<th>نوع گزارش</th>
|
||||||
|
<th>توضیح گزارش</th>
|
||||||
|
<th>شماره تماس گیرنده</th>
|
||||||
|
<th>تاریخ ثبت</th>
|
||||||
|
<th>تاریخ اقدام</th>
|
||||||
|
<th>توضیح مامور</th>
|
||||||
|
<th>توضیح کارشناس</th>
|
||||||
|
<th>وضعیت</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $item['id'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['fk_RegisteredEventMessage'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['Title'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['FeatureTypeTitle'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['Description'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['MobileForSendEventSms'] ?? '-' }}</td>
|
||||||
|
<td>{{ verta($item['created_at'])->format('Y/n/j') ?? '-' }}</td>
|
||||||
|
<td>{{ $item['rms_last_activity_fa'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['rms_description'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['supervisor_description'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['status_fa'] ?? '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>گزارش واکنش سریع</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
table,
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||||
|
گزارش کارتابل ارزیابی واکنش سریع
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>کد یکتا</th>
|
||||||
|
<th>کد سوانح</th>
|
||||||
|
<th>استان</th>
|
||||||
|
<th>اداره</th>
|
||||||
|
<th>موضوع گزارش</th>
|
||||||
|
<th>نوع گزارش</th>
|
||||||
|
<th>توضیح گزارش</th>
|
||||||
|
<th>شماره تماس گیرنده</th>
|
||||||
|
<th>تاریخ ثبت</th>
|
||||||
|
<th>تاریخ اقدام</th>
|
||||||
|
<th>توضیح مامور</th>
|
||||||
|
<th>توضیح کارشناس</th>
|
||||||
|
<th>وضعیت</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $item['id'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['fk_RegisteredEventMessage'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['province_fa'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['name_fa'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['Title'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['FeatureTypeTitle'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['Description'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['MobileForSendEventSms'] ?? '-' }}</td>
|
||||||
|
<td>{{ verta($item['created_at'])->format('Y/n/j') ?? '-' }}</td>
|
||||||
|
<td>{{ $item['rms_last_activity_fa'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['rms_description'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['supervisor_description'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['status_fa'] ?? '-' }}</td>
|
||||||
|
<td>{{ $item['rms_last_activity_fa'] ?? '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>فعالیت های نگهداری حریم راه</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
table,
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="9"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||||
|
گزارش فعالیت های نگهداری حریم راه
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
کد یکتا
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
استان
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
اداره
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
مورد
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
تاریخ بازدید
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
تاریخ ثبت مستندات قضایی
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
تاریخ اقدام
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
وضعیت
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
تاریخ ثبت
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['id'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['province_fa'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['edare_shahri_name'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['info_fa'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['activity_date_time'] ? verta($item['activity_date_time'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||||
|
|
||||||
|
<td style="border: 1px solid black;text-align: center;">
|
||||||
|
{{ $item['judiciary_document_upload_date'] && $item['judiciary_document_upload_date'] != '0000-00-00 00:00:00' ? verta($item['judiciary_document_upload_date'])->format('Y/n/j H:i:s') : '-' }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td style="border: 1px solid black;text-align: center;">
|
||||||
|
{{ $item['action_picture_document_upload_date'] ? verta($item['action_picture_document_upload_date'])->format('Y/n/j H:i:s') : '-' }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['step_fa'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>کشوری</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||||
|
گزارش نگهداری حریم راه از تاریخ
|
||||||
|
{{ verta($fromDate)->format('Y/n/j') }}
|
||||||
|
تا
|
||||||
|
تاریخ
|
||||||
|
{{ verta($toDate)->format('Y/n/j') }}
|
||||||
|
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
<tr class="headercolortable">
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
اداره کل
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
تعداد کل
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
ساخت و ساز غیر مجاز
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
راه دسترسی غیر مجاز
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
عبور تاسیسات زیربنایی غیر مجاز
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام اول (شناسایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام دوم (مستندات قضایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام سوم (برخورد)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام اول (شناسایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام دوم (مستندات قضایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام سوم (برخورد)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام اول (شناسایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام دوم (مستندات قضایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام سوم (برخورد)
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->name_fa }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->sum }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'89'}[1] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'89'}[2] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'89'}[3] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'90'}[1] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'90'}[2] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'90'}[3] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'91'}[1] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'91'}[2] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'91'}[3] }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>استانی</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="11"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
|
||||||
|
گزارش نگهداری حریم راه از تاریخ
|
||||||
|
{{ verta($fromDate)->format('Y/n/j') }}
|
||||||
|
تا
|
||||||
|
تاریخ
|
||||||
|
{{ verta($toDate)->format('Y/n/j') }}
|
||||||
|
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr class="headercolortable">
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #C4D79B;">
|
||||||
|
اداره کل
|
||||||
|
</th>
|
||||||
|
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
تعداد کل
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
ساخت و ساز غیر مجاز
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
راه دسترسی غیر مجاز
|
||||||
|
</th>
|
||||||
|
<th colspan="3" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
عبور تاسیسات زیربنایی غیر مجاز
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام اول (شناسایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام دوم (مستندات قضایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام سوم (برخورد)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام اول (شناسایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام دوم (مستندات قضایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام سوم (برخورد)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام اول (شناسایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام دوم (مستندات قضایی)
|
||||||
|
</th>
|
||||||
|
<th style="border:1px solid black;text-align:center;background-color: #EBF1DE;">
|
||||||
|
گام سوم (برخورد)
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($data as $item)
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->name_fa }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->sum }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'89'}[1] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'89'}[2] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'89'}[3] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'90'}[1] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'90'}[2] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'90'}[3] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'91'}[1] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'91'}[2] }}</td>
|
||||||
|
<td style="border:1px solid black;text-align: center;">{{ $item->{'91'}[3] }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
167
routes/v3.php
167
routes/v3.php
@@ -2,20 +2,39 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\V3\Auth\LogoutController;
|
use App\Http\Controllers\V3\Auth\LogoutController;
|
||||||
use App\Http\Controllers\V3\CMMSMachinesController;
|
use App\Http\Controllers\V3\CMMSMachinesController;
|
||||||
|
use App\Http\Controllers\V3\DamageManagementController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshController;
|
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController;
|
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController;
|
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
||||||
use App\Http\Controllers\V3\Dashboard\ObservedItemController;
|
use App\Http\Controllers\V3\Dashboard\ObservedItemController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\AccidentReceiptController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\OtpManagementController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\Reports\AccidentReceiptReportController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController;
|
use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController;
|
use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\Reports\SafetyAndPrivacyReportController;
|
||||||
use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController;
|
use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\RoadObservationController;
|
||||||
use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
|
use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacyController;
|
||||||
use App\Http\Controllers\V3\FMSVehicleManagementController;
|
use App\Http\Controllers\V3\FMSVehicleManagementController;
|
||||||
use App\Http\Controllers\V3\Harim\DivarkeshiController;
|
use App\Http\Controllers\V3\Harim\DivarkeshiController;
|
||||||
|
use App\Http\Controllers\V3\LogListManagementController;
|
||||||
|
use App\Http\Controllers\V3\NotificationController;
|
||||||
|
use App\Http\Controllers\V3\PermissionManagementController;
|
||||||
use App\Http\Controllers\V3\ProfileController;
|
use App\Http\Controllers\V3\ProfileController;
|
||||||
use App\Http\Controllers\V3\RahdaranController;
|
use App\Http\Controllers\V3\RahdaranController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::get('admin/permissions', function () {
|
||||||
|
if (auth()->user()->username == 'witel') {
|
||||||
|
auth()->user()->syncPermissions(\App\Models\Permission::all());
|
||||||
|
return response('done');
|
||||||
|
}
|
||||||
|
abort(404);
|
||||||
|
});
|
||||||
|
|
||||||
Route::prefix('harim')->name('harim')->group(function () {
|
Route::prefix('harim')->name('harim')->group(function () {
|
||||||
Route::prefix('divarkeshi')->name('divarkeshi')->controller(DivarkeshiController::class)->group(function () {
|
Route::prefix('divarkeshi')->name('divarkeshi')->controller(DivarkeshiController::class)->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
@@ -120,6 +139,10 @@ Route::prefix('road_items')
|
|||||||
|
|
||||||
Route::get('/operator_report', 'operatorCartableReport')
|
Route::get('/operator_report', 'operatorCartableReport')
|
||||||
->name('operatorCartableReport');
|
->name('operatorCartableReport');
|
||||||
|
|
||||||
|
Route::get('/machines/{roadItemsProject}', 'roadItemMachine')->name('roadItemMachine');
|
||||||
|
Route::get('/rahdaran/{roadItemsProject}', 'roadItemRahdar')->name('roadItemRahdar');
|
||||||
|
Route::get('/files/{roadItemsProject}', 'roadItemFile')->name('roadItemFile');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('road_patrols')
|
Route::prefix('road_patrols')
|
||||||
@@ -154,6 +177,9 @@ Route::prefix('road_patrols')
|
|||||||
|
|
||||||
Route::get('/detail/{roadPatrol}', 'show')
|
Route::get('/detail/{roadPatrol}', 'show')
|
||||||
->name('show');
|
->name('show');
|
||||||
|
|
||||||
|
Route::get('/machines/{roadPatrol}', 'roadPatrolMachine')->name('roadPatrolMachine');
|
||||||
|
Route::get('/rahdaran/{roadPatrol}', 'roadPatrolRahdar')->name('roadPatrolRahdar');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('cmms_machines')
|
Route::prefix('cmms_machines')
|
||||||
@@ -215,3 +241,144 @@ Route::prefix('road_patrol_reports')
|
|||||||
Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap');
|
Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap');
|
||||||
Route::get('/show_on_map/{roadPatrol}', 'showOnMap')->name('showOnMap');
|
Route::get('/show_on_map/{roadPatrol}', 'showOnMap')->name('showOnMap');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::prefix('damages')
|
||||||
|
->name('damages.')
|
||||||
|
->middleware('permission:manage-damage')
|
||||||
|
->controller(DamageManagementController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::get('/list', 'list')->name('list')->withoutMiddleware('permission:manage-damage');
|
||||||
|
Route::post('/', 'store')->name('store');
|
||||||
|
Route::get('/{damage}', 'show')->name('show');
|
||||||
|
Route::post('/{damage}', 'update')->name('update');
|
||||||
|
Route::post('/activate/{damage}', 'activate')->name('activate');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('receipts')
|
||||||
|
->name('receipts.')
|
||||||
|
->controller(AccidentReceiptController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::get('/excel_report', 'excelReport')->name('excelReport');
|
||||||
|
Route::post('/', 'store')->name('store');
|
||||||
|
Route::get('/accident_types', 'accidentTypes')->name('accidentTypes');
|
||||||
|
Route::get('/{accident}', 'show')->name('show');
|
||||||
|
Route::post('/{accident}', 'update')->name('update');
|
||||||
|
Route::delete('/{accident}', 'destroy')->name('destroy');
|
||||||
|
Route::get('/generate_insurance_letter/{accident}', 'generateInsuranceLetter')->name('generateInsuranceLetter');
|
||||||
|
Route::post('/confirm_payment_info/{accident}', 'confirmPaymentInfo')->name('confirmPaymentInfo');
|
||||||
|
Route::get('/submit_invoice/{accident}', 'submitInvoice')->name('submitInvoice');
|
||||||
|
Route::get('/check_payment_status/{accident}', 'checkPaymentStatus')->name('checkPaymentStatus');
|
||||||
|
Route::get('/generate_police_document/{accident}', 'generatePoliceDocument')->name('generatePoliceDocument');
|
||||||
|
Route::get('/send_sms_again/{accident}', 'sendSmsAgain')->name('sendSmsAgain');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('receipt_reports')
|
||||||
|
->name('receiptReports.')
|
||||||
|
->controller(AccidentReceiptReportController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/country_report', 'countryReport')->name('countryReport');
|
||||||
|
Route::get('/province_report', 'provinceReport')->name('provinceReport');
|
||||||
|
Route::get('/country_excel_report', 'countryExcelReport')->name('countryExcelReport');
|
||||||
|
Route::get('/province_excel_report', 'provinceExcelReport')->name('provinceExcelReport');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('road_observations')
|
||||||
|
->name('roadObservations.')
|
||||||
|
->controller(RoadObservationController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/supervisor_index', 'supervisorIndex')->name('supervisorIndex')->middleware('permission:show-fast-react-province|show-fast-react');
|
||||||
|
Route::post('/verify/{roadObserved}', 'verifyBySupervisor')->name('verifyBySupervisor');
|
||||||
|
Route::get('/supervisor_report', 'supervisorCartableReport')->name('supervisorCartableReport')->middleware('permission:show-fast-react-province|show-fast-react');
|
||||||
|
Route::get('/operator_index','operatorIndex')->name('operatorIndex')->middleware('permission:show-fast-react-edarate-shahri');
|
||||||
|
Route::get('/operator_report','operatorCartableReport')->name('operatorCartableReport')->middleware('permission:show-fast-react-edarate-shahri');
|
||||||
|
Route::get('/complaints_index', 'complaintsIndex')
|
||||||
|
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||||
|
->name('complaintsIndex');
|
||||||
|
Route::get('/complaints_report', 'complaintsReport')->name('complaintsReport')
|
||||||
|
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react');
|
||||||
|
Route::post('/register/{roadObserved}', 'register')
|
||||||
|
->middleware('permission:show-fast-react-edarate-shahri')
|
||||||
|
->name('register');
|
||||||
|
Route::post('/modify_registration/{roadObserved}', 'modifyRegistration')
|
||||||
|
->middleware('permission:show-fast-react-edarate-shahri')
|
||||||
|
->name('modifyRegistration');
|
||||||
|
|
||||||
|
Route::get('/{roadObserved}', 'show')->name('show');
|
||||||
|
Route::post('/refer/{roadObserved}', 'refer')
|
||||||
|
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||||
|
->name('refer');
|
||||||
|
|
||||||
|
Route::get('/refer_list/{roadObserved}', 'referList')
|
||||||
|
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||||
|
->name('referList');
|
||||||
|
|
||||||
|
Route::post('/restore/{roadObserved}', 'restore')
|
||||||
|
->middleware('permission:restore-fast-react')
|
||||||
|
->name('restore');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('log_list')
|
||||||
|
->name('logList.')
|
||||||
|
->controller(LogListManagementController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::get('/list', 'list')->name('list');
|
||||||
|
Route::post('/', 'store')->name('store');
|
||||||
|
Route::get('/{logList}', 'show')->name('show');
|
||||||
|
Route::post('/{logList}', 'update')->name('update');
|
||||||
|
Route::delete('/{logList}', 'destroy')->name('destroy');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('safety_and_privacy')
|
||||||
|
->name('SafetyAndPrivacy.')
|
||||||
|
->controller(SafetyAndPrivacyController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||||
|
Route::get('/excel_report', 'excelReport')->name('excelReport')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||||
|
Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')->middleware('permission:add-safety-and-privacy');
|
||||||
|
Route::get('/sub_items', 'subItems')->name('subItems');
|
||||||
|
Route::post('/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware('permission:add-safety-and-privacy');
|
||||||
|
Route::post('/third_step_store/{safetyAndPrivacy}', 'thirdStepStore')->name('thirdStepStore')->middleware('permission:add-safety-and-privacy');
|
||||||
|
Route::get('/{safetyAndPrivacy}', 'show')->name('show');
|
||||||
|
Route::delete('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
||||||
|
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('safety_and_privacy_report')
|
||||||
|
->name('SafetyAndPrivacyReport.')
|
||||||
|
->controller(SafetyAndPrivacyReportController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/country_activity', 'countryActivity')->name('countryActivity');
|
||||||
|
Route::get('/province_activity', 'provinceActivity')->name('provinceActivity');
|
||||||
|
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||||
|
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('otp')
|
||||||
|
->name('otp.')
|
||||||
|
->controller(OtpManagementController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::post('/get_token', 'getOtpToken')->name('getOtpToken');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::name('items.')
|
||||||
|
->controller(ItemsManagementController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/items', 'getItems')->name('list');
|
||||||
|
Route::get('/sub_items/{item}', 'getSubItems')->name('subItems');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('permissions')
|
||||||
|
->name('permissions.')
|
||||||
|
->controller(PermissionManagementController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::post('/', 'store')->name('store');
|
||||||
|
Route::get('/{permission}', 'show')->name('show');
|
||||||
|
Route::post('/{permission}', 'update')->name('update');
|
||||||
|
Route::delete('/{permission}', 'destroy')->name('destroy');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::get('/notifications', NotificationController::class)->name('notifications');
|
||||||
|
|||||||
@@ -134,4 +134,5 @@ INSERT INTO permissions (name,guard_name,name_fa,description,created_at,updated_
|
|||||||
('show-receipt-province','web','نمایش خسارت (استانی)','نمایش خسارات استانی',NULL,NULL,NULL,NULL,'receipt','خسارات وارد بر ابنیه فنی راه',1,0),
|
('show-receipt-province','web','نمایش خسارت (استانی)','نمایش خسارات استانی',NULL,NULL,NULL,NULL,'receipt','خسارات وارد بر ابنیه فنی راه',1,0),
|
||||||
('supervise-road-item-by-edareostani','web','نظارت بر ثبت فعالیت روزانه و جاری(ادارات استانی)',NULL,'2023-07-09 09:48:35','2023-07-09 09:48:37',NULL,NULL,'road-item','فعالیت روزانه',0,0),
|
('supervise-road-item-by-edareostani','web','نظارت بر ثبت فعالیت روزانه و جاری(ادارات استانی)',NULL,'2023-07-09 09:48:35','2023-07-09 09:48:37',NULL,NULL,'road-item','فعالیت روزانه',0,0),
|
||||||
('azmayesh-management','web','مدیریت آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0),
|
('azmayesh-management','web','مدیریت آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0),
|
||||||
('azmayesh-type-management','web','مدیریت نوع آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0);
|
('azmayesh-type-management','web','مدیریت نوع آزمایشات',NULL,'2024-11-18 09:48:35','2024-11-18 09:48:35',NULL,NULL,'azmayesh','آزمایشات',0,0),
|
||||||
|
('manage-damage','web','مدیریت خسارات',NULL,'2025-02-17 15:20:35','2025-02-17 15:20:35',NULL,NULL,'damage','خسارات',0,0);
|
||||||
|
|||||||
73
tests/Feature/V3/Damage/ActivateTest.php
Normal file
73
tests/Feature/V3/Damage/ActivateTest.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Damage;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\Permission;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ActivateTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase, WithFaker;
|
||||||
|
|
||||||
|
public function test_unauthenticated_user_cannot_activate_damage(): void
|
||||||
|
{
|
||||||
|
$response = $this->postJson(route('v3.damages.store'));
|
||||||
|
$response->assertStatus(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_without_permission_cannot_activate_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'));
|
||||||
|
$response->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function test_user_with_permission_can_activate_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory()->state(['name' => 'manage-damage']))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create(['status' => 0]);
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.activate', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJson([
|
||||||
|
'message' => __('messages.successful')
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('damages', [
|
||||||
|
'id' => $damage->id,
|
||||||
|
'status' => 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_with_permission_can_deactivate_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory()->state(['name' => 'manage-damage']))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create(['status' => 1]);
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.activate', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJson([
|
||||||
|
'message' => __('messages.successful')
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('damages', [
|
||||||
|
'id' => $damage->id,
|
||||||
|
'status' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
66
tests/Feature/V3/Damage/IndexTest.php
Normal file
66
tests/Feature/V3/Damage/IndexTest.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Damage;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\Permission;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class IndexTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase, WithFaker;
|
||||||
|
/**
|
||||||
|
* A basic feature test example.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function test_user_should_have_manage_damage_permission_index_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.damages.index'));
|
||||||
|
$response->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_cannot_access_authentication_to_index_damage(): void
|
||||||
|
{
|
||||||
|
$response = $this->getJson(route('v3.damages.index'));
|
||||||
|
$response->assertStatus(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_all_damages_returned_successfully_for_index_damage(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = User::factory()
|
||||||
|
->has(factory: Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
|
||||||
|
Damage::factory()->count(5)->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.damages.index', [
|
||||||
|
'start' => 0,
|
||||||
|
'size' => 10,
|
||||||
|
'filters' => json_encode([]),
|
||||||
|
'sorting' => json_encode([]),
|
||||||
|
]));
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertJsonStructure([
|
||||||
|
'data' => [
|
||||||
|
'*' => [
|
||||||
|
'id',
|
||||||
|
'title',
|
||||||
|
'unit',
|
||||||
|
'base_price',
|
||||||
|
'status',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'meta' => [
|
||||||
|
'totalRowCount',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
43
tests/Feature/V3/Damage/ListTest.php
Normal file
43
tests/Feature/V3/Damage/ListTest.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Damage;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ListTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase, WithFaker;
|
||||||
|
|
||||||
|
public function test_user_cannot_access_authentication_list_damage(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$response = $this->getJson(route('v3.damages.list'));
|
||||||
|
$response->assertStatus(401);
|
||||||
|
}
|
||||||
|
public function test_all_damages_returned_successfully_for_list_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Damage::factory()->count(5)->create();
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.damages.list'));
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertJsonStructure([
|
||||||
|
'data' => [
|
||||||
|
'*' => [
|
||||||
|
'id',
|
||||||
|
'title',
|
||||||
|
'unit',
|
||||||
|
'base_price',
|
||||||
|
'status',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
59
tests/Feature/V3/Damage/ShowTest.php
Normal file
59
tests/Feature/V3/Damage/ShowTest.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Damage;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\Permission;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ShowTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase , WithFaker;
|
||||||
|
|
||||||
|
public function test_unauthenticated_user_cannot_view_show_damage(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();;
|
||||||
|
$response = $this->getJson(route('v3.damages.show', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertStatus(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_without_permission_cannot_view_damage_show_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$damage = Damage::factory()->create();;
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.damages.show', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_with_permission_can_view_damage_to_show_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.damages.show', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJson([
|
||||||
|
'data' => [
|
||||||
|
'id' => $damage->id,
|
||||||
|
'title' => $damage->title,
|
||||||
|
'unit' => $damage->unit,
|
||||||
|
'base_price' => $damage->base_price,
|
||||||
|
'status' => $damage->status,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
156
tests/Feature/V3/Damage/StoreTest.php
Normal file
156
tests/Feature/V3/Damage/StoreTest.php
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Damage;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\Permission;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
use App\Models\User;
|
||||||
|
class StoreTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase, WithFaker;
|
||||||
|
|
||||||
|
public function test_unauthenticated_user_cannot_store_damage(): void
|
||||||
|
{
|
||||||
|
$response = $this->postJson(route('v3.damages.store'));
|
||||||
|
$response->assertStatus(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_without_permission_cannot_store_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'));
|
||||||
|
$response->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_validation_fails_when_required_fields_are_missing(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'));
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.required', ['attribute' => "عنوان"]),
|
||||||
|
'unit' => __('validation.required', ['attribute' => 'واحد']),
|
||||||
|
'base_price' => __('validation.required', ['attribute' => 'قیمت پایه']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_title_must_be_unique(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'), [
|
||||||
|
'title' => $damage->title,
|
||||||
|
'unit' => 'kg',
|
||||||
|
'base_price' => 5000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.unique', ['attribute' => "عنوان"]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_title_and_unit_must_be_string(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'), [
|
||||||
|
'title' => 12345,
|
||||||
|
'unit' => 67890,
|
||||||
|
'base_price' => 10000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.string', ['attribute' => "عنوان"]),
|
||||||
|
'unit' => __('validation.string', ['attribute' => 'واحد']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_title_must_not_exceed_255_characters(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$longTitle = $this->faker->text(500);
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'), [
|
||||||
|
'title' => $longTitle,
|
||||||
|
'unit' => 'kg',
|
||||||
|
'base_price' => 10000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.max.string',['attribute' => 'عنوان', 'max' => 255]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_store_base_price_must_be_intger(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'), [
|
||||||
|
'title' => 'Valid Title',
|
||||||
|
'unit' => 'm',
|
||||||
|
'base_price' => 'valid intger',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'base_price' => __('validation.integer', ['attribute' => 'قیمت پایه']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function test_user_with_permission_can_store_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => 'New Damage',
|
||||||
|
'unit' => 'm',
|
||||||
|
'base_price' => 10000,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.store'), $data);
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJson([
|
||||||
|
'message' => __('messages.successful'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('damages', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
180
tests/Feature/V3/Damage/UpdateTest.php
Normal file
180
tests/Feature/V3/Damage/UpdateTest.php
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Damage;
|
||||||
|
|
||||||
|
use App\Models\Damage;
|
||||||
|
use App\Models\Permission;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class UpdateTest extends TestCase
|
||||||
|
{
|
||||||
|
use WithFaker, RefreshDatabase;
|
||||||
|
|
||||||
|
public function test_unauthenticated_user_cannot_update_damage(): void
|
||||||
|
{
|
||||||
|
$damage = Damage::factory()->create();;
|
||||||
|
$response = $this->getJson(route('v3.damages.update', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertStatus(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_without_permission_cannot_update_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$damage = Damage::factory()->create();;
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.damages.update', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_validation_fails_when_required_fields_are_missing(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]));
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.required', ['attribute' => "عنوان"]),
|
||||||
|
'unit' => __('validation.required', ['attribute' => 'واحد']),
|
||||||
|
'base_price' => __('validation.required', ['attribute' => 'قیمت پایه']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_title_must_be_unique(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$existingDamage = Damage::factory()->create([
|
||||||
|
'title' => 'Existing Title'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]),[
|
||||||
|
'title' => $existingDamage->title,
|
||||||
|
'unit' => 'm',
|
||||||
|
'base_price' => 5000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.unique', ['attribute' => "عنوان"]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_title_and_unit_must_be_string(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), [
|
||||||
|
'title' => 12345,
|
||||||
|
'unit' => 67890,
|
||||||
|
'base_price' => 10000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.string', ['attribute' => "عنوان"]),
|
||||||
|
'unit' => __('validation.string', ['attribute' => 'واحد']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_title_must_not_exceed_255_characters(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
$longTitle = $this->faker->text(500);
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), [
|
||||||
|
'title' => $longTitle,
|
||||||
|
'unit' => 'kg',
|
||||||
|
'base_price' => 10000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'title' => __('validation.max.string',['attribute' => 'عنوان', 'max' => 255]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_base_price_must_be_integer(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), [
|
||||||
|
'title' => 'Valid Title',
|
||||||
|
'unit' => 'kg',
|
||||||
|
'base_price' => 'invalid_price',]);
|
||||||
|
|
||||||
|
$response->assertUnprocessable()
|
||||||
|
->assertInvalid([
|
||||||
|
'base_price' => __('validation.integer', ['attribute' => 'قیمت پایه']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function test_user_with_permission_can_update_damage(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()
|
||||||
|
->has(Permission::factory([
|
||||||
|
'name' => 'manage-damage'
|
||||||
|
]))
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$damage = Damage::factory()->create();
|
||||||
|
|
||||||
|
$updateData = [
|
||||||
|
'title' => 'Updated Damage',
|
||||||
|
'unit' => 'litre',
|
||||||
|
'base_price' => 20000,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->postJson(route('v3.damages.update', [$damage->id]), $updateData);
|
||||||
|
|
||||||
|
$response->assertStatus(200)
|
||||||
|
->assertJson([
|
||||||
|
'message' => __('messages.successful'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('damages', [
|
||||||
|
'id' => $damage->id,
|
||||||
|
'title' => $updateData['title'],
|
||||||
|
'unit' => $updateData['unit'],
|
||||||
|
'base_price' => $updateData['base_price'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user