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()->now()->format('Y/m/d H:i')}} + | + +|||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| + | |||||||||||||||||||||||||
| + تعداد و مجموع فعالیت های روزانه و جاری راهداری ثبت شده از تاریخ + {{verta($fromDate)->format('Y/n/j')}} + تا + تاریخ + {{verta($toDate)->format('Y/n/j')}} + | > +|||||||||||||||||||||||||
| اداره | +فعالیت های انجام شده | +||||||||||||||||||||||||
| {{ $detail->sub_item_str }} | + @endforeach +|||||||||||||||||||||||||
| تعداد | +مجموع ({{ $detail->sub_item_unit }}) | + @endforeach +||||||||||||||||||||||||
| {{ $activity->city_fa }} | + + @foreach ($details as $index => $detail) ++ {{ $activity->{'Count_' . ($index)} ?? '-' }} + | ++ {{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }} + | + @endforeach +|||||||||||||||||||||||