From 2e10afa5eb00b49c12a6b47bb75c445b01c0f08a Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 26 Jan 2025 09:44:27 +0330 Subject: [PATCH] create blade files --- .../Reports/RoadItemReportService.php | 27 +++++-- .../CountryActivityPerSubItem.blade.php | 50 +++++++------ .../ProvinceActivityPerSubItem.blade.php | 74 +++++++++++++++++++ 3 files changed, 122 insertions(+), 29 deletions(-) create mode 100644 resources/views/v3/Reports/RoadItems/ProvinceActivityPerSubItem.blade.php diff --git a/app/Services/Reports/RoadItemReportService.php b/app/Services/Reports/RoadItemReportService.php index 146d3250..ae052bfe 100644 --- a/app/Services/Reports/RoadItemReportService.php +++ b/app/Services/Reports/RoadItemReportService.php @@ -10,10 +10,12 @@ class RoadItemReportService { public function countryActivityPerSubItem(int $item, string $fromDate, string $toDate): array { - $subItems = InfoItem::query()->where('item', $item)->get(['sub_item', 'sub_item_str', 'sub_item_unit']); + $subItems = InfoItem::query()->where('item', $item) + ->orderBy('sub_item') + ->get(['sub_item', 'sub_item_str', 'sub_item_unit']); $query = DB::table('road_items_projects') - ->selectRaw('province_id, province_fa, sub_item'); + ->selectRaw('province_id, province_fa'); foreach ($subItems as $subItem) { $query->selectRaw(" @@ -45,13 +47,15 @@ class RoadItemReportService 'data' => $activities->push($totalItemCount), 'fromDate' => $fromDate, 'toDate' => $toDate, - 'details' => $subItems, + 'details' => $subItems->keyBy('sub_item'), ]; } public function provinceActivityPerSubItem(int $item, string $fromDate, string $toDate, int $provinceId): Collection { - $subItems = InfoItem::query()->where('item', $item)->get(['sub_item', 'sub_item_str', 'sub_item_unit']); + $subItems = InfoItem::query()->where('item', $item) + ->orderBy('sub_item') + ->get(['sub_item', 'sub_item_str', 'sub_item_unit']); $query = DB::table('road_items_projects') ->selectRaw('province_id, province_fa, user_name as city_fa, city_id'); @@ -72,11 +76,22 @@ class RoadItemReportService $activities = $query->get(); + $totalItemCount = [ + 'city_fa' => 'استانی' + ]; + + foreach ($subItems as $subItem) { + $totalItemCount[] = [ + "total_count_{$subItem->sub_item}" => $activities->sum("Count_{$subItem->sub_item}"), + "total_sum_{$subItem->sub_item}" => $activities->sum("Sum_{$subItem->sub_item}"), + ]; + } + return collect([ - 'data' => $activities, + 'data' => $activities->push($totalItemCount), 'fromDate' => $fromDate, 'toDate' => $toDate, - 'details' => $subItems + 'details' => $subItems->keyBy('sub_item') ]); } } \ No newline at end of file diff --git a/resources/views/v3/Reports/RoadItems/CountryActivityPerSubItem.blade.php b/resources/views/v3/Reports/RoadItems/CountryActivityPerSubItem.blade.php index 8f465ba1..62d19ec5 100644 --- a/resources/views/v3/Reports/RoadItems/CountryActivityPerSubItem.blade.php +++ b/resources/views/v3/Reports/RoadItems/CountryActivityPerSubItem.blade.php @@ -23,7 +23,7 @@ - تعداد و احجام فعالیت های روزانه و جاری راهداری ثبت شده از تاریخ + تعداد و مجموع فعالیت های روزانه و جاری راهداری ثبت شده از تاریخ {{verta($fromDate)->format('Y/n/j')}} تا تاریخ @@ -33,34 +33,38 @@ اداره کل + فعالیت های انجام شده + + + + @foreach($details as $detail) + {{ $detail->sub_item_str }} + @endforeach + + + + @foreach($details as $detail) + تعداد + مجموع ({{ $detail->sub_item_unit }}) + @endforeach - @foreach($details as $detail) - - -
- {{ $detail->sub_item_str }} -
- تعداد - {{ $detail["sub_item_unit"] }}مجموع -
-
- - - @foreach ($activities as $activity) - - {{ $activity["province_fa"] }} + @foreach ($activities as $activity) + + {{ $activity->province_fa }} - @if($activity["sub_item"] == $detail["sub_item"]) - {{ $activity["Count_{$activity["sub_item"]}"] }} - {{ round($activity["Sum_{$activity["sub_item"]}"], 1) }} - @endif - - - @endforeach + @foreach ($details as $index => $detail) + + {{ $activity->{'Count_' . ($index)} ?? '-' }} + + + {{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }} + + @endforeach + @endforeach diff --git a/resources/views/v3/Reports/RoadItems/ProvinceActivityPerSubItem.blade.php b/resources/views/v3/Reports/RoadItems/ProvinceActivityPerSubItem.blade.php new file mode 100644 index 00000000..9ff1b3cf --- /dev/null +++ b/resources/views/v3/Reports/RoadItems/ProvinceActivityPerSubItem.blade.php @@ -0,0 +1,74 @@ + + + + + + + استانی + + + + + + + + + + + + + + + + > + + + + + + + + + @foreach($details as $detail) + + @endforeach + + + + @foreach($details as $detail) + + + @endforeach + + + + + + @foreach ($activities as $activity) + + + + @foreach ($details as $index => $detail) + + + @endforeach + + @endforeach + +
+ تاریخ دریافت گزارش: {{verta()->now()->format('Y/m/d H:i')}} +
+ تعداد و مجموع فعالیت های روزانه و جاری راهداری ثبت شده از تاریخ + {{verta($fromDate)->format('Y/n/j')}} + تا + تاریخ + {{verta($toDate)->format('Y/n/j')}} +
ادارهفعالیت های انجام شده
{{ $detail->sub_item_str }}
تعدادمجموع ({{ $detail->sub_item_unit }})
{{ $activity->city_fa }} + {{ $activity->{'Count_' . ($index)} ?? '-' }} + + {{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }} +
+ + + + \ No newline at end of file