diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php index ab5034ab..5fa5c71c 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php @@ -21,30 +21,50 @@ class AccessRoadReport implements FromView, WithEvents, ShouldAutoSize, WithDraw public function view(): View { - $data = $this->data; - $existedProvinces = array_keys($data); + $axis = [ + 1 => 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی' + ]; + $grid = []; + $national = null; - foreach (Province::all() as $value) { - $provinceId = $value->id; + foreach ($this->data as $r) { + $pid = $r->province_id; + $name = $r->province_name; + $axisKey = $axis[$r->axis_type_id] ?? "axis_{$r->axis_type_id}"; - if (!array_key_exists($provinceId, $existedProvinces)) { - $data[] = (object) [ - 'province_id' => $provinceId, - 'name_fa' => $value->name_fa, - 'sum' => 0, - 'axis_data' => [ - 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], - 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], - 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], - 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], - 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], - ], - ]; + if ($pid === -1) { + $national ??= ['province_name' => $name, 'total' => 0]; + $national["{$axisKey}_1"] = $r->s1; + $national["{$axisKey}_2"] = $r->s2; + $national["{$axisKey}_3"] = $r->s3; + $national['total'] = $r->total_sum; + continue; } + + if (!isset($grid[$pid])) { + $grid[$pid] = ['province_name' => $name, 'total' => 0]; + } + $grid[$pid]["{$axisKey}_1"] = $r->s1; + $grid[$pid]["{$axisKey}_2"] = $r->s2; + $grid[$pid]["{$axisKey}_3"] = $r->s3; + $grid[$pid]['total'] = $r->total_sum; } + $exportRows = []; + if ($national) $exportRows[] = $national; + foreach ($grid as $row) { + $exportRows[] = $row; + } + + return view('v3.Reports.SafetyAndPrivacy.Country.AccessRoadActivityReport', [ - 'data' => $data, + 'rows' => $exportRows, + 'axis' => $axis, + 'axisOrder' => array_keys($axis), ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php index 52f57616..537caa42 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php @@ -2,18 +2,13 @@ namespace App\Exports\V3\SafetyAndPrivacy\Country; -use App\Models\EdarateShahri; -use App\Models\Province; use Illuminate\Contracts\View\View; -use Illuminate\Database\Eloquent\Collection; -use Illuminate\Http\Request; use Maatwebsite\Excel\Concerns\FromView; use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\WithDrawings; use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Events\AfterSheet; use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; -use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings { @@ -22,30 +17,50 @@ class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDr public function view(): View { - $data = $this->data; - $existedProvinces = array_keys($data); + $axis = [ + 1 => 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی' + ]; + $grid = []; + $national = null; - foreach (Province::all() as $value) { - $provinceId = $value->id; + foreach ($this->data as $r) { + $pid = $r->province_id; + $name = $r->province_name; + $axisKey = $axis[$r->axis_type_id] ?? "axis_{$r->axis_type_id}"; - if (!array_key_exists($provinceId, $existedProvinces)) { - $data[] = (object) [ - 'province_id' => $provinceId, - 'name_fa' => $value->name_fa, - 'sum' => 0, - 'axis_data' => [ - 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], - 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], - 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], - 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], - 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], - ], - ]; + if ($pid === -1) { + $national ??= ['province_name' => $name, 'total' => 0]; + $national["{$axisKey}_1"] = $r->s1; + $national["{$axisKey}_2"] = $r->s2; + $national["{$axisKey}_3"] = $r->s3; + $national['total'] = $r->total_sum; + continue; } + + if (!isset($grid[$pid])) { + $grid[$pid] = ['province_name' => $name, 'total' => 0]; + } + $grid[$pid]["{$axisKey}_1"] = $r->s1; + $grid[$pid]["{$axisKey}_2"] = $r->s2; + $grid[$pid]["{$axisKey}_3"] = $r->s3; + $grid[$pid]['total'] = $r->total_sum; } + $exportRows = []; + if ($national) $exportRows[] = $national; + foreach ($grid as $row) { + $exportRows[] = $row; + } + + return view('v3.Reports.SafetyAndPrivacy.Country.ConstructionActivityReport', [ - 'data' => $data, + 'rows' => $exportRows, + 'axis' => $axis, + 'axisOrder' => array_keys($axis), ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php index 1221ca07..c6566cda 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php @@ -22,30 +22,50 @@ class UtilityPassingReport implements FromView, WithEvents, ShouldAutoSize, With public function view(): View { - $data = $this->data; - $existedProvinces = array_keys($data); + $axis = [ + 1 => 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی' + ]; + $grid = []; + $national = null; - foreach (Province::all() as $value) { - $provinceId = $value->id; + foreach ($this->data as $r) { + $pid = $r->province_id; + $name = $r->province_name; + $axisKey = $axis[$r->axis_type_id] ?? "axis_{$r->axis_type_id}"; - if (!array_key_exists($provinceId, $existedProvinces)) { - $data[] = (object) [ - 'province_id' => $provinceId, - 'name_fa' => $value->name_fa, - 'sum' => 0, - 'axis_data' => [ - 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], - 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], - 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], - 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], - 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], - ], - ]; + if ($pid === -1) { + $national ??= ['province_name' => $name, 'total' => 0]; + $national["{$axisKey}_1"] = $r->s1; + $national["{$axisKey}_2"] = $r->s2; + $national["{$axisKey}_3"] = $r->s3; + $national['total'] = $r->total_sum; + continue; } + + if (!isset($grid[$pid])) { + $grid[$pid] = ['province_name' => $name, 'total' => 0]; + } + $grid[$pid]["{$axisKey}_1"] = $r->s1; + $grid[$pid]["{$axisKey}_2"] = $r->s2; + $grid[$pid]["{$axisKey}_3"] = $r->s3; + $grid[$pid]['total'] = $r->total_sum; } + $exportRows = []; + if ($national) $exportRows[] = $national; + foreach ($grid as $row) { + $exportRows[] = $row; + } + + return view('v3.Reports.SafetyAndPrivacy.Country.UtilityPassingActivityReport', [ - 'data' => $data, + 'rows' => $exportRows, + 'axis' => $axis, + 'axisOrder' => array_keys($axis), ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php index 053de9b4..65fd8215 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php @@ -16,35 +16,51 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class AccessRoadReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings { - public function __construct(private array $data, public Request $request){} + public function __construct(private array $data){} public function view(): View { - $data = $this->data; - $existedCities = array_keys($data); - $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + $axis = [ + 1 => 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی' + ]; + $grid = []; + $summary = null; // کل استان - foreach ($edarat as $value) { - $edareId = $value->id; + foreach ($this->data as $r) { + $eid = $r->edare_id; + $name = $r->edare_name; + $axisKey = $axis[$r->axis_type_id] ?? "axis_{$r->axis_type_id}"; - if (!array_key_exists($edareId, $existedCities)) { - $data[] = (object) [ - 'edare_shahri_id' => $edareId, - 'name_fa' => $value->name_fa, - 'sum' => 0, - 'axis_data' => [ - 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], - 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], - 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], - 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], - 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], - ], - ]; + if ($eid === -1) { + $summary ??= ['edare_name' => $name, 'total' => 0]; + $summary["{$axisKey}_1"] = $r->s1; + $summary["{$axisKey}_2"] = $r->s2; + $summary["{$axisKey}_3"] = $r->s3; + $summary['total'] = $r->total_sum; + continue; } + + if (!isset($grid[$eid])) { + $grid[$eid] = ['edare_name' => $name, 'total' => 0]; + } + $grid[$eid]["{$axisKey}_1"] = $r->s1; + $grid[$eid]["{$axisKey}_2"] = $r->s2; + $grid[$eid]["{$axisKey}_3"] = $r->s3; + $grid[$eid]['total'] = $r->total_sum; } + $exportRows = []; + if ($summary) $exportRows[] = $summary; + foreach ($grid as $row) $exportRows[] = $row; + return view('v3.Reports.SafetyAndPrivacy.Province.AccessRoadActivityReport', [ - 'data' => $data, + 'rows' => $exportRows, + 'axis' => $axis, + 'axisOrder' => array_keys($axis), ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php index 07e2d138..fa2b578a 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php @@ -4,7 +4,6 @@ namespace App\Exports\V3\SafetyAndPrivacy\Province; use App\Models\EdarateShahri; use Illuminate\Contracts\View\View; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Http\Request; use Maatwebsite\Excel\Concerns\FromView; use Maatwebsite\Excel\Concerns\ShouldAutoSize; @@ -12,39 +11,54 @@ use Maatwebsite\Excel\Concerns\WithDrawings; use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Events\AfterSheet; use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; -use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings { - public function __construct(private array $data, public Request $request){} + public function __construct(private array $data){} public function view(): View { - $data = $this->data; - $existedCities = array_keys($data); - $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + $axis = [ + 1 => 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی' + ]; + $grid = []; + $summary = null; // کل استان - foreach ($edarat as $value) { - $edareId = $value->id; + foreach ($this->data as $r) { + $eid = $r->edare_id; + $name = $r->edare_name; + $axisKey = $axis[$r->axis_type_id] ?? "axis_{$r->axis_type_id}"; - if (!array_key_exists($edareId, $existedCities)) { - $data[] = (object) [ - 'edare_shahri_id' => $edareId, - 'name_fa' => $value->name_fa, - 'sum' => 0, - 'axis_data' => [ - 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], - 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], - 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], - 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], - 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], - ], - ]; + if ($eid === -1) { + $summary ??= ['edare_name' => $name, 'total' => 0]; + $summary["{$axisKey}_1"] = $r->s1; + $summary["{$axisKey}_2"] = $r->s2; + $summary["{$axisKey}_3"] = $r->s3; + $summary['total'] = $r->total_sum; + continue; } + + if (!isset($grid[$eid])) { + $grid[$eid] = ['edare_name' => $name, 'total' => 0]; + } + $grid[$eid]["{$axisKey}_1"] = $r->s1; + $grid[$eid]["{$axisKey}_2"] = $r->s2; + $grid[$eid]["{$axisKey}_3"] = $r->s3; + $grid[$eid]['total'] = $r->total_sum; } + $exportRows = []; + if ($summary) $exportRows[] = $summary; + foreach ($grid as $row) $exportRows[] = $row; + return view('v3.Reports.SafetyAndPrivacy.Province.ConstructionActivityReport', [ - 'data' => $data, + 'rows' => $exportRows, + 'axis' => $axis, + 'axisOrder' => array_keys($axis), ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php index 5c67b160..5ee033a6 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php @@ -16,35 +16,51 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class UtilityPassingReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings { - public function __construct(private array $data, public Request $request){} + public function __construct(private array $data){} public function view(): View { - $data = $this->data; - $existedCities = array_keys($data); - $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); + $axis = [ + 1 => 'آزادراه', + 2 => 'بزرگراه', + 3 => 'اصلی', + 4 => 'فرعی', + 5 => 'روستایی' + ]; + $grid = []; + $summary = null; // کل استان - foreach ($edarat as $value) { - $edareId = $value->id; + foreach ($this->data as $r) { + $eid = $r->edare_id; + $name = $r->edare_name; + $axisKey = $axis[$r->axis_type_id] ?? "axis_{$r->axis_type_id}"; - if (!array_key_exists($edareId, $existedCities)) { - $data[] = (object) [ - 'edare_shahri_id' => $edareId, - 'name_fa' => $value->name_fa, - 'sum' => 0, - 'axis_data' => [ - 'آزادراه' => ['1' => 0, '2' => 0, '3' => 0], - 'بزرگراه' => ['1' => 0, '2' => 0, '3' => 0], - 'اصلی' => ['1' => 0, '2' => 0, '3' => 0], - 'فرعی' => ['1' => 0, '2' => 0, '3' => 0], - 'روستایی' => ['1' => 0, '2' => 0, '3' => 0], - ], - ]; + if ($eid === -1) { + $summary ??= ['edare_name' => $name, 'total' => 0]; + $summary["{$axisKey}_1"] = $r->s1; + $summary["{$axisKey}_2"] = $r->s2; + $summary["{$axisKey}_3"] = $r->s3; + $summary['total'] = $r->total_sum; + continue; } + + if (!isset($grid[$eid])) { + $grid[$eid] = ['edare_name' => $name, 'total' => 0]; + } + $grid[$eid]["{$axisKey}_1"] = $r->s1; + $grid[$eid]["{$axisKey}_2"] = $r->s2; + $grid[$eid]["{$axisKey}_3"] = $r->s3; + $grid[$eid]['total'] = $r->total_sum; } + $exportRows = []; + if ($summary) $exportRows[] = $summary; + foreach ($grid as $row) $exportRows[] = $row; + return view('v3.Reports.SafetyAndPrivacy.Province.UtilityPassingActivityReport', [ - 'data' => $data, + 'rows' => $exportRows, + 'axis' => $axis, + 'axisOrder' => array_keys($axis), ]); } diff --git a/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php b/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php index 1a5e5555..86725e9e 100644 --- a/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php +++ b/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php @@ -84,6 +84,7 @@ class AccidentReceiptController extends Controller 'police_file_date' => $request->police_file_date ?? null, 'status' => AccidentStates::BEDON_EGHDAM->value, 'status_fa' => AccidentStates::name(AccidentStates::BEDON_EGHDAM->value), + 'driver_rate' => $request->driver_rate, ]; $sum = 0; @@ -104,6 +105,7 @@ class AccidentReceiptController extends Controller $accidentData['ojrate_nasb'] = $ojrate_nasb; $accidentData['sum'] = $sum; + $accidentData['driver_share_amount'] = ($request->sum * $request->driver_rate)/100; $accident = Accident::query()->create($accidentData); $accident->damage_picture1 = FileFacade::save($request->file('damage_picture1'), "receipts_files/{$accident->id}"); @@ -153,6 +155,7 @@ class AccidentReceiptController extends Controller 'report_base' => $request->report_base, 'police_serial' => $request->police_serial ?? null, 'police_file_date' => $request->police_file_date ?? null, + 'driver_rate' => $request->driver_rate, ]; if ($request->report_base && $accident->police_file) { @@ -192,6 +195,8 @@ class AccidentReceiptController extends Controller $accidentData['ojrate_nasb'] = $ojrate_nasb; $accidentData['sum'] = $sum; + $accidentData['driver_share_amount'] = ($request->sum * $request->driver_rate)/100; + $accident->update($accidentData); @@ -246,13 +251,25 @@ class AccidentReceiptController extends Controller public function confirmPaymentInfo(ConfirmPaymentInfoRequest $request, Accident $accident): JsonResponse { DB::transaction(function () use ($request, $accident) { - $accident->update([ + + $final_amount = $accident->driver_share_amount - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount); + + if ($final_amount > 0) { + $status = AccidentStates::SABT_FISH->value; + $status_fa = AccidentStates::name($status); + } + elseif ($final_amount == 0) { + $status = AccidentStates::PARDAKHT_FACTOR->value; + $status_fa = AccidentStates::name($status); + } + + $accident->update([ 'deposit_insurance_image' => $request->has('deposit_insurance_image') ? 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->has('deposit_daghi_image') ? 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), + 'status' => $status, + 'status_fa' => $status_fa, ]); auth()->user()->addActivityComplete(1132); @@ -266,7 +283,7 @@ class AccidentReceiptController extends Controller */ public function submitInvoice(Accident $accident, PaymentService $paymentService): JsonResponse { - $final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount); + $final_amount = $accident->driver_share_amount - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount); throw_if($final_amount < 0, new ProhibitedAction('مبالغ داغی و بیمه از مبلغ کل بیشتر می باشد.')); diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php index cef7b562..f3907676 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorReport/ConstructionActivityController.php @@ -12,6 +12,7 @@ use App\Services\Cartables\SafetyAndPrivacy\OperatorService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Maatwebsite\Excel\Facades\Excel; +use PhpOffice\PhpSpreadsheet\Exception; use Symfony\Component\HttpFoundation\BinaryFileResponse; class ConstructionActivityController extends Controller @@ -38,6 +39,11 @@ class ConstructionActivityController extends Controller 'edarateShahri' => EdarateShahri::where('province_id', $request->province_id)->get(['id', 'name_fa']), ]); } + + /** + * @throws Exception + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + */ public function countryExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse { $data = $operatorService->countryActivity(89); @@ -46,6 +52,10 @@ class ConstructionActivityController extends Controller return Excel::download(new ExcelReport($data), $name); } + /** + * @throws Exception + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + */ public function provinceExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse { $data = $operatorService->provinceActivity( diff --git a/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php b/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php index f3fe71dd..2e967f3a 100644 --- a/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php +++ b/app/Http/Requests/V3/AccidentReceipt/StoreRequest.php @@ -46,6 +46,7 @@ class StoreRequest extends FormRequest 'damage_items' => 'required|array', 'damage_items.*.value' => 'required', 'damage_items.*.amount' => 'required', + 'driver_rate' => 'required|numeric', ]; } } diff --git a/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php b/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php index 134bb4a0..1959b35f 100644 --- a/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php +++ b/app/Http/Requests/V3/AccidentReceipt/UpdateRequest.php @@ -45,6 +45,7 @@ class UpdateRequest extends FormRequest 'damage_items' => 'required|array', 'damage_items.*.value' => 'required', 'damage_items.*.amount' => 'required', + 'driver_rate' => 'required|numeric', ]; } } diff --git a/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php b/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php index 39b86060..efc94ac3 100644 --- a/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php +++ b/app/Services/Cartables/SafetyAndPrivacy/OperatorService.php @@ -40,6 +40,7 @@ class OperatorService WITH base AS ( SELECT p.id AS province_id, + p.name AS province_name, a.id AS axis_type_id, COALESCE(SUM(t.step = 1), 0) AS s1, COALESCE(SUM(t.step = 2), 0) AS s2, @@ -54,6 +55,7 @@ class OperatorService ) SELECT province_id, + province_name, axis_type_id, s1, s2, @@ -68,6 +70,7 @@ class OperatorService SELECT -1 AS province_id, + 'کل کشور' AS province_name, axis_type_id, COALESCE(SUM(s1), 0) AS s1, COALESCE(SUM(s2), 0) AS s2, @@ -91,6 +94,7 @@ class OperatorService WITH edareh_data AS ( SELECT e.id AS edare_id, + e.name_fa AS edare_name, a.id AS axis_type_id, COALESCE(SUM(t.step = 1), 0) AS s1, COALESCE(SUM(t.step = 2), 0) AS s2, @@ -106,6 +110,7 @@ class OperatorService ) SELECT edare_id, + edare_name, axis_type_id, s1, s2, @@ -120,6 +125,7 @@ class OperatorService SELECT -1 AS edare_id, + 'کل استان' AS edare_name, axis_type_id, COALESCE(SUM(s1), 0) AS s1, COALESCE(SUM(s2), 0) AS s2, diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php index 673063c3..da65da08 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Country/AccessRoadActivityReport.blade.php @@ -1,132 +1,71 @@ - - + - - کشوری - + - +@php + // show a dot if key missing or value is 0/empty + function cell($row, $key) { + return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0'; + } +@endphp - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + @endforeach - - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + + + @endforeach + - @foreach ($data as $item) + @foreach ($rows as $r) - - - - - - - - - - - - - - - - - + + + + @foreach ($axisOrder as $aid) + @php $group = $axis[$aid]; @endphp + + + + @endforeach @endforeach
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
+ + گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز
- گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز -
+ اداره کل + تعداد کل - آزاد راه - -بزرگ راه - - اصلی - - فرعی - - روستایی - + {{ $axis[$aid] }} +
- گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - گام اول (شناسایی)گام دوم (مستندات قضایی)گام سوم (برخورد)
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}{{ $r['province_name'] }}{{ $r['total'] ?: '0' }}{{ cell($r, "{$group}_1") }}{{ cell($r, "{$group}_2") }}{{ cell($r, "{$group}_3") }}
+ diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php index 1854ba63..7ed4abde 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Country/ConstructionActivityReport.blade.php @@ -1,132 +1,71 @@ - - + - - کشوری - + - +@php + // show a dot if key missing or value is 0/empty + function cell($row, $key) { + return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0'; + } +@endphp - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + @endforeach - - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + + + @endforeach + - @foreach ($data as $item) + @foreach ($rows as $r) - - - - - - - - - - - - - - - - - + + + + @foreach ($axisOrder as $aid) + @php $group = $axis[$aid]; @endphp + + + + @endforeach @endforeach
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
-
+ گزارش نگهداری حریم راه برای ساخت و ساز غیر مجاز
+ اداره کل + تعداد کل - آزاد راه - - بزرگ راه - - اصلی - - فرعی - - روستایی - + {{ $axis[$aid] }} +
- گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - گام اول (شناسایی)گام دوم (مستندات قضایی)گام سوم (برخورد)
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}{{ $r['province_name'] }}{{ $r['total'] ?: '0' }}{{ cell($r, "{$group}_1") }}{{ cell($r, "{$group}_2") }}{{ cell($r, "{$group}_3") }}
+ diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php index 092683d7..2e558491 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Country/UtilityPassingActivityReport.blade.php @@ -1,132 +1,71 @@ - - + - - کشوری - + - +@php + // show a dot if key missing or value is 0/empty + function cell($row, $key) { + return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0'; + } +@endphp - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + @endforeach - - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + + + @endforeach + - @foreach ($data as $item) + @foreach ($rows as $r) - - - - - - - - - - - - - - - - - + + + + @foreach ($axisOrder as $aid) + @php $group = $axis[$aid]; @endphp + + + + @endforeach @endforeach
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
-
+ گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز
+ اداره کل + تعداد کل - آزاد راه - - بزرگ راه - - اصلی - - فرعی - - روستایی - + {{ $axis[$aid] }} +
- گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - گام اول (شناسایی)گام دوم (مستندات قضایی)گام سوم (برخورد)
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}{{ $r['province_name'] }}{{ $r['total'] ?: '0' }}{{ cell($r, "{$group}_1") }}{{ cell($r, "{$group}_2") }}{{ cell($r, "{$group}_3") }}
+ diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php index e54e7ddc..e039b603 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Province/AccessRoadActivityReport.blade.php @@ -1,131 +1,70 @@ - - + - - - استانی - + گزارش ادارات شهرستانی + - +@php + function cell($row, $key) { + return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0'; + } +@endphp - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + @endforeach - - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + + + @endforeach + - @foreach ($data as $item) + @foreach ($rows as $r) - - - - - - - - - - - - - - - - - + + + + @foreach ($axisOrder as $aid) + @php $g = $axis[$aid]; @endphp + + + + @endforeach @endforeach
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
-
+ گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز
- اداره کل + + اداره + تعداد کل - آزاد راه - - بزرگ راه - - اصلی - - فرعی - - روستایی - + {{ $axis[$aid] }} +
- گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - گام اول (شناسایی)گام دوم (مستندات قضایی)گام سوم (برخورد)
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}{{ $r['edare_name'] }}{{ $r['total'] ?: '0' }}{{ cell($r, "{$g}_1") }}{{ cell($r, "{$g}_2") }}{{ cell($r, "{$g}_3") }}
+ diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php index 509e3b0c..0e9357a6 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Province/ConstructionActivityReport.blade.php @@ -1,131 +1,70 @@ - - + - - - استانی - + گزارش ادارات شهرستانی + - +@php + function cell($row, $key) { + return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0'; + } +@endphp - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + @endforeach - - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + + + @endforeach + - @foreach ($data as $item) + @foreach ($rows as $r) - - - - - - - - - - - - - - - - - + + + + @foreach ($axisOrder as $aid) + @php $g = $axis[$aid]; @endphp + + + + @endforeach @endforeach
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
-
- گزارش نگهداری حریم راه برای ساخت و ساز غیر مجاز + + گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز
- اداره کل + + اداره + تعداد کل - آزاد راه - - بزرگ راه - - اصلی - - فرعی - - روستایی - + {{ $axis[$aid] }} +
- گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - گام اول (شناسایی)گام دوم (مستندات قضایی)گام سوم (برخورد)
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}{{ $r['edare_name'] }}{{ $r['total'] ?: '0' }}{{ cell($r, "{$g}_1") }}{{ cell($r, "{$g}_2") }}{{ cell($r, "{$g}_3") }}
+ diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php index 407ca02a..0e9357a6 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/Province/UtilityPassingActivityReport.blade.php @@ -1,131 +1,70 @@ - - + - - - استانی - + گزارش ادارات شهرستانی + - +@php + function cell($row, $key) { + return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0'; + } +@endphp - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + @endforeach - - - - - - - - - - - - - - - + @foreach($axisOrder as $aid) + + + + @endforeach + - @foreach ($data as $item) + @foreach ($rows as $r) - - - - - - - - - - - - - - - - - + + + + @foreach ($axisOrder as $aid) + @php $g = $axis[$aid]; @endphp + + + + @endforeach @endforeach
+ تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
-
+ گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز
- اداره کل + + اداره + تعداد کل - آزاد راه - - بزرگ راه - - اصلی - - فرعی - - روستایی - + {{ $axis[$aid] }} +
- گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - - گام اول (شناسایی) - - گام دوم (مستندات قضایی) - - گام سوم (برخورد) - گام اول (شناسایی)گام دوم (مستندات قضایی)گام سوم (برخورد)
{{ $item->name_fa }}{{ $item->sum }}{{ $item->axis_data['آزادراه'][1] }}{{$item->axis_data['آزادراه'][2] }}{{ $item->axis_data['آزادراه'][3] }}{{ $item->axis_data['بزرگراه'][1] }}{{ $item->axis_data['بزرگراه'][2] }}{{ $item->axis_data['بزرگراه'][3] }}{{ $item->axis_data['اصلی'][1] }}{{ $item->axis_data['اصلی'][2] }}{{ $item->axis_data['اصلی'][3] }}{{ $item->axis_data['فرعی'][1] }}{{ $item->axis_data['فرعی'][2] }}{{ $item->axis_data['فرعی'][3] }}{{ $item->axis_data['روستایی'][1] }}{{ $item->axis_data['روستایی'][2] }}{{ $item->axis_data['روستایی'][3] }}{{ $r['edare_name'] }}{{ $r['total'] ?: '0' }}{{ cell($r, "{$g}_1") }}{{ cell($r, "{$g}_2") }}{{ cell($r, "{$g}_3") }}
+