reform the blade files
This commit is contained in:
@@ -13,16 +13,18 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class CountryActivityPerSubItemReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private array $activities){}
|
||||
public function __construct(private array $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$activities = $this->activities;
|
||||
$data = $this->data;
|
||||
|
||||
return view('v3.Reports.RoadItems.CountryActivityPerSubItem', [
|
||||
'activities' => $activities["data"],
|
||||
'fromDate' => $activities["fromDate"],
|
||||
'toDate' => $activities["toDate"],
|
||||
'data' => $data['activities']['data'],
|
||||
'provinces' => $data['provinces'],
|
||||
'subItems' => $data['subItems'],
|
||||
'fromDate' => $data['activities']['fromDate'],
|
||||
'toDate' => $data['activities']['toDate']
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,16 +18,18 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class ProvinceActivityPerSubItemReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private array $activities){}
|
||||
public function __construct(private array $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$activities = $this->activities;
|
||||
$data = $this->data;
|
||||
|
||||
return view('v3.Reports.RoadItems.ProvinceActivityPerSubItem', [
|
||||
'activities' => $activities["data"],
|
||||
'fromDate' => $activities["fromDate"],
|
||||
'toDate' => $activities["toDate"],
|
||||
'data' => $data['activities']['data'],
|
||||
'edarateShahri' => $data['edarateShahri'],
|
||||
'subItems' => $data['subItems'],
|
||||
'fromDate' => $data['activities']['fromDate'],
|
||||
'toDate' => $data['activities']['toDate']
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,15 @@ class RoadItemsReportController extends Controller
|
||||
auth()->user()->addActivityComplete(1034);
|
||||
$name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$activities = $roadItemReportService->countryActivityPerSubItem($request);
|
||||
return Excel::download(new CountryActivityPerSubItemReport($activities), $name);
|
||||
$subItems = InfoItem::query()
|
||||
->where('item', $request->item)
|
||||
->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']);
|
||||
|
||||
return Excel::download(new CountryActivityPerSubItemReport([
|
||||
'activities' => $activities,
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
'subItems' => $subItems
|
||||
]), $name);
|
||||
}
|
||||
|
||||
public function provinceActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
|
||||
@@ -151,6 +159,14 @@ class RoadItemsReportController extends Controller
|
||||
auth()->user()->addActivityComplete(1034);
|
||||
$activities = $roadItemReportService->provinceActivityPerSubItem($request);
|
||||
$name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityPerSubItemReport($activities), $name);
|
||||
$subItems = InfoItem::query()
|
||||
->where('item', $request->item)
|
||||
->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']);
|
||||
|
||||
return Excel::download(new ProvinceActivityPerSubItemReport([
|
||||
'activities' => $activities,
|
||||
'subItems' => $subItems,
|
||||
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
|
||||
]), $name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,38 +37,36 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@foreach($details as $detail)
|
||||
<th colspan="2" style="border:1px solid black;text-align:center;background-color:#C4D79B">{{ $detail->sub_item_str }}</th>
|
||||
@foreach($subItems as $subItem)
|
||||
<th colspan="2" style="border:1px solid black;text-align:center;background-color:#C4D79B">{{ $subItem->sub_item_str }}</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@foreach($details as $detail)
|
||||
@foreach($subItems as $subItem)
|
||||
<th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">تعداد</th>
|
||||
<th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">مجموع ({{ $detail->sub_item_unit }})</th>
|
||||
<th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">مجموع ({{ $subItem->sub_item_unit }})</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($activities as $activity)
|
||||
@foreach ($provinces as $province)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $activity->province_fa }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $province['name_fa'] }}</td>
|
||||
|
||||
@foreach ($details as $index => $detail)
|
||||
@foreach ($subItems as $subItem)
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ $activity->{'Count_' . ($index)} ?? '-' }}
|
||||
{{ $province->{'Count_' . ($index)} ?? '-' }}
|
||||
</td>
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }}
|
||||
{{ isset($province->{'Sum_' . ($index)}) ? round($province->{'Sum_' . ($index)}, 1) : '-' }}
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -72,12 +72,12 @@
|
||||
@foreach($edarateShahri as $edareShahri)
|
||||
@php
|
||||
// محاسبه مجموع مقدار s برای این استان
|
||||
$totalForProvince = collect($data)->where('p', $edareShahri['id'])->sum('s');
|
||||
$totalForProvince = collect($data)->where('c', $edareShahri['id'])->sum('s');
|
||||
|
||||
// محاسبه مجموع مقدار s برای هر آیتم در این استان
|
||||
$itemTotalsForProvince = [];
|
||||
foreach ($items as $item) {
|
||||
$itemTotalsForProvince[$item['item']] = collect($data)->where('p', $edareShahri['id'])->where('i', $item['item'])->sum('s');
|
||||
$itemTotalsForProvince[$item['item']] = collect($data)->where('c', $edareShahri['id'])->where('i', $item['item'])->sum('s');
|
||||
}
|
||||
@endphp
|
||||
<tr>
|
||||
|
||||
@@ -37,31 +37,31 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@foreach($details as $detail)
|
||||
<th colspan="2" style="border:1px solid black;text-align:center;background-color:#C4D79B">{{ $detail->sub_item_str }}</th>
|
||||
@foreach($subItems as $subItem)
|
||||
<th colspan="2" style="border:1px solid black;text-align:center;background-color:#C4D79B">{{ $subItem->sub_item_str }}</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@foreach($details as $detail)
|
||||
@foreach($subItems as $subItem)
|
||||
<th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">تعداد</th>
|
||||
<th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">مجموع ({{ $detail->sub_item_unit }})</th>
|
||||
<th style="background-color: #FDE9D9;border: 1px solid black;text-align: center;">مجموع ({{ $subItem->sub_item_unit }})</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($activities as $activity)
|
||||
@foreach ($edarateShahri as $edareShahri)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $activity->city_fa }}</td>
|
||||
|
||||
@foreach ($details as $index => $detail)
|
||||
@foreach ($subItems as $subItem)
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ $activity->{'Count_' . ($index)} ?? '-' }}
|
||||
{{ $edareShahri->{'Count_' . ($subItem)} ?? '-' }}
|
||||
</td>
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }}
|
||||
{{ isset($edareShahri->{'Sum_' . ($subItem)}) ? round($edareShahri->{'Sum_' . ($subItem)}, 1) : '-' }}
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user