Merge branch 'feature/GashtDebug' into 'develop'

Feature/gasht debug

See merge request witelgroup/rms_v2!64
This commit is contained in:
2025-02-08 08:18:36 +00:00
28 changed files with 1125 additions and 709 deletions

View File

@@ -17,72 +17,18 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class CountryActivityPerItemReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
{
public function __construct(private ?string $fromDate, private ?string $toDate){}
public function __construct(private ?array $data){}
public function view(): View
{
$fromDate = $this->fromDate ?? '2021-03-21 00:00:00';
$toDate = $this->toDate ?? \Carbon\Carbon::now();
$query = "SELECT
COUNT(CASE WHEN item = 1 THEN 1 END) AS MarematRooyeCount,
COUNT(CASE WHEN item = 2 THEN 1 END) AS PaksaziCount,
COUNT(CASE WHEN item = 3 THEN 1 END) AS AlaemCount,
COUNT(CASE WHEN item = 4 THEN 1 END) AS HefazCount,
COUNT(CASE WHEN item = 5 THEN 1 END) AS RoshanayiCount,
COUNT(CASE WHEN item = 6 THEN 1 END) AS KhatkeshiCount,
COUNT(CASE WHEN item = 7 THEN 1 END) AS RangamiziCount,
COUNT(CASE WHEN item = 8 THEN 1 END) AS WashingCount,
COUNT(CASE WHEN item = 9 THEN 1 END) AS ImenSaziCount,
COUNT(CASE WHEN item = 10 THEN 1 END) AS HarimCount,
COUNT(CASE WHEN item = 11 THEN 1 END) AS PolCount,
COUNT(CASE WHEN item = 12 THEN 1 END) AS ToonelCount,
COUNT(CASE WHEN item = 13 THEN 1 END) AS AmaliatZemestaniCount,
COUNT(CASE WHEN item = 14 THEN 1 END) AS MashinAlatCount,
COUNT(CASE WHEN item = 15 THEN 1 END) AS TollhouseCount,
COUNT(CASE WHEN item = 16 THEN 1 END) AS EmergencyCount,
province_fa,
province_id,
COUNT(CASE WHEN item != 20 THEN 1 END) AS TotalProvinceCount
FROM (
SELECT
province_fa,
province_id,
item,
status
FROM road_items_projects
WHERE activity_date_time BETWEEN '{$fromDate}' and '{$toDate}'
) AS merged_table
WHERE status = 1
GROUP BY province_id, province_fa;";
$provinceActivities = collect(DB::select($query));
$totalItemCount = [
'totalMarematRooyeCount' => $provinceActivities->sum('MarematRooyeCount'),
'totalPaksaziCount' => $provinceActivities->sum('PaksaziCount'),
'totalAlaemCount' => $provinceActivities->sum('AlaemCount'),
'totalHefazCount' => $provinceActivities->sum('HefazCount'),
'totalRoshanayiCount' => $provinceActivities->sum('RoshanayiCount'),
'totalKhatkeshiCount' => $provinceActivities->sum('KhatkeshiCount'),
'totalRangamiziCount' => $provinceActivities->sum('RangamiziCount'),
'totalWashingCount' => $provinceActivities->sum('WashingCount'),
'totalImenSaziCount' => $provinceActivities->sum('ImenSaziCount'),
'totalHarimCount' => $provinceActivities->sum('HarimCount'),
'totalPolCount' => $provinceActivities->sum('PolCount'),
'totalToonelCount' => $provinceActivities->sum('ToonelCount'),
'totalAmaliatZemestaniCount' => $provinceActivities->sum('AmaliatZemestaniCount'),
'totalMashinAlatCount' => $provinceActivities->sum('MashinAlatCount'),
'totalTollhouseCount' => $provinceActivities->sum('TollhouseCount'),
'totalEmergencyCount' => $provinceActivities->sum('EmergencyCount'),
'totalCountryCount' => $provinceActivities->sum('TotalProvinceCount'),
];
$data = $this->data;
return view('v3.Reports.RoadItems.CountryActivityPerItem', [
'provinceCount' => $provinceActivities,
'countryCount' => $totalItemCount,
'fromDate' => $fromDate,
'toDate' => $toDate
'data' => $data['activities']['data'],
'provinces' => $data['provinces'],
'items' => $data['items'],
'fromDate' => $data['activities']['fromDate'],
'toDate' => $data['activities']['toDate']
]);
}

View File

@@ -13,17 +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"],
'details' => $activities["details"]
'data' => $data['activities']['data'],
'provinces' => $data['provinces'],
'subItems' => $data['subItems'],
'fromDate' => $data['activities']['fromDate'],
'toDate' => $data['activities']['toDate']
]);
}

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Exports\V3\RoadItemsProjects;
use App\Models\Province;
use App\Models\RoadItemsProject;
use Carbon\Carbon;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
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, WithEvents, ShouldAutoSize, WithDrawings
{
public function __construct(private ?Collection $data){}
public function view(): View
{
return view('v3.Reports.RoadItems.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('q1');
return [$drawing, $drawing2];
}
}

View File

@@ -17,80 +17,18 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class ProvinceActivityPerItemReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
{
public function __construct(private ?string $fromDate,
private ?string $toDate,
private string $provinceId,
){}
public function __construct(private ?array $data){}
public function view(): View
{
$fromDate = $this->fromDate ?? '2021-03-21 00:00:00';
$toDate = $this->toDate ?? \Carbon\Carbon::now();
$query = "SELECT
COUNT(CASE WHEN item = 1 THEN 1 END) AS MarematRooyeCount,
COUNT(CASE WHEN item = 2 THEN 1 END) AS PaksaziCount,
COUNT(CASE WHEN item = 3 THEN 1 END) AS AlaemCount,
COUNT(CASE WHEN item = 4 THEN 1 END) AS HefazCount,
COUNT(CASE WHEN item = 5 THEN 1 END) AS RoshanayiCount,
COUNT(CASE WHEN item = 6 THEN 1 END) AS KhatkeshiCount,
COUNT(CASE WHEN item = 7 THEN 1 END) AS RangamiziCount,
COUNT(CASE WHEN item = 8 THEN 1 END) AS WashingCount,
COUNT(CASE WHEN item = 9 THEN 1 END) AS ImenSaziCount,
COUNT(CASE WHEN item = 10 THEN 1 END) AS HarimCount,
COUNT(CASE WHEN item = 11 THEN 1 END) AS PolCount,
COUNT(CASE WHEN item = 12 THEN 1 END) AS ToonelCount,
COUNT(CASE WHEN item = 13 THEN 1 END) AS AmaliatZemestaniCount,
COUNT(CASE WHEN item = 14 THEN 1 END) AS MashinAlatCount,
COUNT(CASE WHEN item = 15 THEN 1 END) AS TollhouseCount,
COUNT(CASE WHEN item = 16 THEN 1 END) AS EmergencyCount,
province_fa,
province_id,
edarat_name,
edarat_id,
COUNT(CASE WHEN item != 20 THEN 1 END) AS TotalCityCount
FROM (
SELECT
province_fa,
province_id,
edarat_name,
edarat_id,
item,
status
FROM road_items_projects
WHERE activity_date_time BETWEEN '{$fromDate}' and '{$toDate}'
) AS merged_table
WHERE status = 1
AND province_id = {$this->provinceId}
GROUP BY edarat_id, edarat_name order by province_id ASC;";
$cityActivities = collect(DB::select($query));
$totalItemCount = [
'totalMarematRooyeCount' => $cityActivities->sum('MarematRooyeCount'),
'totalPaksaziCount' => $cityActivities->sum('PaksaziCount'),
'totalAlaemCount' => $cityActivities->sum('AlaemCount'),
'totalHefazCount' => $cityActivities->sum('HefazCount'),
'totalRoshanayiCount' => $cityActivities->sum('RoshanayiCount'),
'totalKhatkeshiCount' => $cityActivities->sum('KhatkeshiCount'),
'totalRangamiziCount' => $cityActivities->sum('RangamiziCount'),
'totalWashingCount' => $cityActivities->sum('WashingCount'),
'totalImenSaziCount' => $cityActivities->sum('ImenSaziCount'),
'totalHarimCount' => $cityActivities->sum('HarimCount'),
'totalPolCount' => $cityActivities->sum('PolCount'),
'totalToonelCount' => $cityActivities->sum('ToonelCount'),
'totalAmaliatZemestaniCount' => $cityActivities->sum('AmaliatZemestaniCount'),
'totalMashinAlatCount' => $cityActivities->sum('MashinAlatCount'),
'totalTollhouseCount' => $cityActivities->sum('TollhouseCount'),
'totalEmergencyCount' => $cityActivities->sum('EmergencyCount'),
'TotalProvinceCount' => $cityActivities->sum('TotalCityCount'),
];
$data = $this->data;
return view('v3.Reports.RoadItems.ProvinceActivityPerItem', [
'cityCount' => $cityActivities,
'provinceCount' => $totalItemCount,
'fromDate' => $fromDate,
'toDate' => $toDate
'data' => $data['activities']['data'],
'edarateShahri' => $data['edarateShahri'],
'items' => $data['items'],
'fromDate' => $data['activities']['fromDate'],
'toDate' => $data['activities']['toDate']
]);
}

View File

@@ -18,17 +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"],
'details' => $activities["details"]
'data' => $data['activities']['data'],
'edarateShahri' => $data['edarateShahri'],
'subItems' => $data['subItems'],
'fromDate' => $data['activities']['fromDate'],
'toDate' => $data['activities']['toDate']
]);
}

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Exports\V3\RoadItemsProjects;
use App\Models\Province;
use App\Models\RoadItemsProject;
use Carbon\Carbon;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
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
{
return view('v3.Reports.RoadItems.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('q1');
return [$drawing, $drawing2];
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Exports\V3\RoadPatrols;
use Illuminate\Contracts\View\View;
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, WithEvents, ShouldAutoSize, WithDrawings
{
public function __construct(private array $data){}
public function view(): View
{
$data = $this->data;
return view('v3.Reports.RoadPatrols.OperatorCartableReport', [
'data' => $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];
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Exports\V3\RoadPatrols;
use Illuminate\Contracts\View\View;
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 array $data){}
public function view(): View
{
$data = $this->data;
return view('v3.Reports.RoadPatrols.SupervisorCartableReport', [
'data' => $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];
}
}

View File

@@ -32,174 +32,60 @@ class RoadItemsReportController extends Controller
]);
}
public function provinceActivityPerSubItem(Request $request): JsonResponse
public function countryActivityPerSubItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
{
$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();
$item = $request->item;
$provinceRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
province_id AS p')
->where('item', '=', $item)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('status', '=', 1)
->groupBy('province_id', 'sub_item')
->get();
$countryRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
-1 AS p')
->where('item', '=', $item)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('status', '=', 1)
->groupBy('sub_item')
->get();
$activities = $provinceRoadItemsPerSubItem->push(...$countryRoadItemsPerSubItem);
$activities = $roadItemReportService->countryActivityPerSubItem($request);
$provinces = Province::all(['id', 'name_fa']);
$subItems = InfoItem::query()
->where('item', $item)
->where('item', $request->item)
->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']);
return $this->successResponse([
'activities' => $activities,
'activities' => $activities['data'],
'sub_items' => $subItems,
'provinces' => $provinces,
]);
}
public function cityActivityPerSubItem(Request $request): JsonResponse
public function provinceActivityPerSubItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
{
$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();
$item = $request->item;
$province = $request->province_id;
$activities = $roadItemReportService->provinceActivityPerSubItem($request);
$cityRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
province_id AS p,
edarat_id AS ci
')
->where('item', '=', $item)
->where('province_id', '=', $province)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('status', '=', 1)
->groupBy('edarat_id', 'sub_item')
->get();
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
$provinceRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
province_id AS p,
-1 AS ci
')
->where('item', '=', $item)
->where('province_id', '=', $province)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('status', '=', 1)
->groupBy('sub_item')
->get();
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $province)->get(['id', 'name_fa']);
$activities = $cityRoadItemsPerSubItem->push(...$provinceRoadItemsPerSubItem);
$subItems = InfoItem::query()
->where('item', $item)
->where('item', $request->item)
->get(['id', 'item', 'item_str', 'sub_item_str', 'sub_item_unit', 'sub_item']);
return $this->successResponse([
'activities' => $activities,
'activities' => $activities['data'],
'edarateShahri' => $edarateShahri,
'sub_items' => $subItems,
]);
}
public function provinceActivityPerItem(Request $request): JsonResponse
public function countryActivityPerItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
{
if (auth()->check()) {
auth()->user()->addActivityComplete(1033);
}
$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();
$user = auth()->user();
// $isSpecialUser = in_array($user->username, ['witel', 'drdanesh']);
$isSpecialUser = $user->hasPermissionTo("show-road-item-supervise-cartable");
$provinceId = $isSpecialUser ? null : $user->province_id;
$provinceActivity = RoadItemsProject::query()
->selectRaw('COUNT(*) AS s, province_id AS p, item AS i')
->where('status', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->when(!$isSpecialUser, function ($query) use ($provinceId) {
$query->where('province_id', $provinceId);
})
->groupBy('province_id', 'item');
$countryActivity = RoadItemsProject::query()
->selectRaw('COUNT(*) AS s, -1 AS p, item AS i')
->where('status', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->when(!$isSpecialUser, function ($query) use ($provinceId) {
$query->where('province_id', $provinceId);
})
->groupBy('item');
$activities = $provinceActivity
->unionAll($countryActivity)
->get();
$activities = $roadItemReportService->countryActivityPerItem($request);
$provinces = Province::all(['id', 'name_fa']);
return $this->successResponse([
'activities' => $activities,
'activities' => $activities['data'],
'provinces' => $provinces,
]);
}
public function cityActivityPerItem(Request $request): JsonResponse
public function provinceActivityPerItem(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
{
$provinceId = $request->province_id;
$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();
$edarehActivity = RoadItemsProject::query()
->selectRaw('
COUNT(*) AS s,
edarat_id AS c,
item AS i')
->where('status', '=', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('province_id', $provinceId)
->groupBy('item', 'edarat_id');
$cityActivity = RoadItemsProject::query()
->selectRaw('
COUNT(*) AS s,
-1 AS c,
item AS i')
->where('status', '=', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('province_id', $provinceId)
->groupBy('item');
$activities = $edarehActivity
->unionAll($cityActivity)
->get();
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $provinceId)->get(['id', 'name_fa']);
$activities = $roadItemReportService->provinceActivityPerItem($request);
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']);
return $this->successResponse([
'activities' => $activities,
'activities' => $activities['data'],
'edarateShahri' => $edarateShahri,
]);
}
@@ -228,48 +114,59 @@ class RoadItemsReportController extends Controller
return $this->successResponse($data);
}
public function countryActivityExcelPerItem(Request $request): BinaryFileResponse
public function countryActivityExcelPerItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
{
auth()->user()->addActivityComplete(1034);
$name = 'گزارش کشوری از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
return Excel::download(new CountryActivityPerItemReport($request->fromDate, $request->toDate), $name);
$activities = $roadItemReportService->countryActivityPerItem($request);
return Excel::download(new CountryActivityPerItemReport([
'activities' => $activities,
'provinces' => Province::all(['id', 'name_fa']),
'items' => InfoItem::query()->distinct()->get(['item', 'item_str']),
]), $name);
}
public function provinceActivityExcelPerItem(Request $request): BinaryFileResponse
public function provinceActivityExcelPerItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
{
auth()->user()->addActivityComplete(1034);
$name = 'گزارش استانی از فعالیت روزانه و جاری - جدول 1 ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
return Excel::download(new ProvinceActivityPerItemReport($request->fromDate, $request->toDate, $request->province), $name);
$activities = $roadItemReportService->provinceActivityPerItem($request);
return Excel::download(new ProvinceActivityPerItemReport([
'activities' => $activities,
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
'items' => InfoItem::query()->distinct()->get(['item', 'item_str']),
]), $name);
}
public function countryActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
{
auth()->user()->addActivityComplete(1034);
$activities = $roadItemReportService->countryActivityPerSubItem(
$request->item,
$request->fromDate,
$request->toDate,
);
$name = "گزارش کشوری از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
$activities = $roadItemReportService->countryActivityPerSubItem($request);
$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), $name);
return Excel::download(new CountryActivityPerSubItemReport([
'activities' => $activities,
'provinces' => Province::all(['id', 'name_fa']),
'subItems' => $subItems
]), $name);
}
public function provinceActivityExcelPerSubItem(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
{
auth()->user()->addActivityComplete(1034);
$activities = $roadItemReportService->provinceActivityPerSubItem(
$request->item,
$request->fromDate,
$request->toDate,
$request->province_id
);
$activities = $roadItemReportService->provinceActivityPerSubItem($request);
$name = "گزارش استانی از فعالیت روزانه و جاری - جدول 2 " . verta()->now()->format('Y-m-d H-i') . '.xlsx';
$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), $name);
return Excel::download(new ProvinceActivityPerSubItemReport([
'activities' => $activities,
'subItems' => $subItems,
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
]), $name);
}
}

View File

@@ -8,6 +8,8 @@ use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\EdarateShahri;
use App\Models\Province;
use App\Models\RoadObserved;
use App\Models\RoadPatrol;
use App\Services\Reports\RoadPatrolReportService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -27,7 +29,7 @@ class RoadPatrolReportController extends Controller
$provinces = Province::all(['id', 'name_fa']);
return $this->successResponse([
'activities' => $activities,
'activities' => $activities['data'],
'provinces' => $provinces
]);
}
@@ -44,7 +46,7 @@ class RoadPatrolReportController extends Controller
$edarateShahri = EdarateShahri::query()->where('province_id', '=', $provinceId)->get(['id', 'name_fa']);
return $this->successResponse([
'activities' => $activities,
'activities' => $activities['data'],
'edarateShahri' => $edarateShahri,
]);
}
@@ -66,4 +68,25 @@ class RoadPatrolReportController extends Controller
return Excel::download(new ProvinceActivity($activities), $name);
}
public function activitiesOnMap(Request $request): JsonResponse
{
$date_from = $request->date_from ? $request->date_from .' 00:00:00' : Date('Y-m-d') .' 00:00:00';
$date_to = $request->date_to ? $request->date_to.' 23:59:59' : (new \DateTime('tomorrow'))->format('Y-m-d').' 23:59:59';
$data = RoadPatrol::query()->when($request->province_id, function ($query, $province) {
return $query->where('province_id', '=', $province);
})
->when($request->edare_id, function ($query, $edare_id) {
return $query->where('edare_id', '=', $edare_id);
})
->whereBetween('created_at', [
$date_from,
$date_to,
])
->select('id', 'start_lat', 'start_lon')
->get();
return $this->successResponse($data);
}
}

View File

@@ -2,9 +2,8 @@
namespace App\Http\Controllers\V3\Dashboard;
use App\Exports\V2\RoadItems\OperatorCartableExport;
use App\Exports\V2\RoadItems\SupervisorCartableExport;
use App\Facades\DataTable\DataTableFacade;
use App\Exports\V3\RoadItemsProjects\OperatorCartableReport;
use App\Exports\V3\RoadItemsProjects\SupervisorCartableReport;
use App\Http\Controllers\Controller;
use App\Http\Requests\V3\RoadItemsProject\StoreRequest;
use App\Http\Requests\V3\RoadItemsProject\UpdateRequest;
@@ -14,6 +13,7 @@ use App\Models\EdarateShahri;
use App\Models\InfoItem;
use App\Models\RoadItemsProject;
use App\Services\NominatimService;
use App\Services\Reports\RoadItemReportService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
@@ -28,39 +28,9 @@ class RoadItemsProjectController extends Controller
/**
* Display a listing of the resource.
*/
public function supervisorIndex(Request $request): JsonResponse
public function supervisorIndex(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
{
$columns = array(
'id', 'user_id', 'start_lat', 'start_lng', 'end_lat',
'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();
$query = null;
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']);
}
elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) {
if (is_null($user->province_id)) {
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
}
$query = RoadItemsProject::query()->where('is_new', 1)
->with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])->where('province_id', auth()->user()->province_id);
}
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
$data = $roadItemReportService->supervisorCartableReport($request);
foreach ($data['data'] as $road_item) {
if (Gate::allows('gate-supervise-road-item', $road_item)) {
@@ -95,9 +65,7 @@ class RoadItemsProjectController extends Controller
public function restore(RoadItemsProject $roadItemsProject): JsonResponse
{
if ($roadItemsProject->status == 0) {
return response()->json([
'message' => 'امکان بازگردانی وضعیت این فعالیت وجود ندارد!'
], 400);
return $this->errorResponse('امکان بازگردانی وضعیت این فعالیت وجود ندارد!');
}
$roadItemsProject->update([
@@ -128,36 +96,16 @@ class RoadItemsProjectController extends Controller
}
public function supervisorCartableReport(Request $request): BinaryFileResponse
public function supervisorCartableReport(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
{
$name = 'گزارش از کارتابل ارزیابی فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
return Excel::download(new SupervisorCartableExport($request->id, $request->item, $request->status,
$request->fromDate, $request->toDate, $request->province_id, $request->edarat_id), $name);
$data = $roadItemReportService->supervisorCartableReport($request);
return Excel::download(new SupervisorCartableReport($data['data']), $name);
}
public function operatorIndex(Request $request): JsonResponse
public function operatorIndex(Request $request, RoadItemReportService $roadItemReportService): JsonResponse
{
$columns = array(
'id', 'user_id', 'start_lat', 'start_lng', 'end_lat',
'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;
$query = RoadItemsProject::with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
->where('is_new', 1)
->where('user_id', auth()->user()->id);
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
$data = $roadItemReportService->operatorCartableReport($request);
return response()->json($data);
}
@@ -170,15 +118,11 @@ class RoadItemsProjectController extends Controller
$user = auth()->user();
if ($user->edarate_ostani_id || is_null($user->city_id)) {
return response()->json([
'message' => 'امکان ثبت فعالیت برای ادارات استانی و ستادی وجود ندارد!'
], 400);
return $this->errorResponse('امکان ثبت فعالیت برای ادارات استانی و ستادی وجود ندارد!');
}
if (is_null($user->edarate_shahri_id)) {
return response()->json([
'message' => 'اداره شهری برای شما در سامانه ثبت نشده است!'
], 400);
return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!');
}
$info_item = InfoItem::query()->where('item', $request->item_id)
@@ -241,9 +185,7 @@ class RoadItemsProjectController extends Controller
$road_item = RoadItemsProject::store($user, $attributes, $before_image, $after_image, $request->observed_item_id);
if ($road_item === -1) {
return response()->json([
'message' => 'اقدام مربوطه قبلا رسیدگی شده است.'
], 400);
return $this->errorResponse('اقدام مربوطه قبلا رسیدگی شده است.');
}
$road_item->rahdaran()->attach($request->rahdaran_id);
@@ -322,12 +264,10 @@ class RoadItemsProjectController extends Controller
return $this->successResponse();
}
public function operatorCartableReport(Request $request): BinaryFileResponse
public function operatorCartableReport(Request $request, RoadItemReportService $roadItemReportService): BinaryFileResponse
{
$name = 'گزارش از کارتابل عملیات فعالیت روزانه ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
return Excel::download(
new OperatorCartableExport($request->id, $request->item, $request->status, $request->fromDate, $request->toDate),
$name
);
$data = $roadItemReportService->operatorCartableReport($request);
return Excel::download(new OperatorCartableReport($data['data']), $name);
}
}

View File

@@ -4,6 +4,8 @@ namespace App\Http\Controllers\V3\Dashboard;
use App\Exports\V2\RoadPatrol\OperatorCartableExport;
use App\Exports\V2\RoadPatrol\SupervisorCartableExport;
use App\Exports\V3\RoadPatrols\OperatorCartableReport;
use App\Exports\V3\RoadPatrols\SupervisorCartableReport;
use App\Facades\DataTable\DataTableFacade;
use App\Facades\Sms\Sms;
use App\Http\Controllers\Controller;
@@ -16,6 +18,7 @@ use App\Models\RoadItemsProject;
use App\Models\RoadObserved;
use App\Models\RoadPatrol;
use App\Services\NominatimService;
use App\Services\Reports\RoadPatrolReportService;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -30,40 +33,9 @@ class RoadPatrolProjectController extends Controller
{
use ApiResponse;
public function supervisorIndex(Request $request): JsonResponse
public function supervisorIndex(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse
{
$columns = array(
'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'operator_id', 'created_at',
'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();
$query = null;
if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) {
$query = RoadPatrol::query()
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']);
}
elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) {
if (is_null($user->province_id)) {
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
}
$query = RoadPatrol::query()
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
->where('province_id', '=', $user->province_id);
}
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
$data = $roadPatrolReportService->supervisorCartableReport($request);
foreach ($data['data'] as $road_patrol) {
if (Gate::allows('gate-supervise-road-item', $road_patrol)) {
@@ -111,37 +83,16 @@ class RoadPatrolProjectController extends Controller
return $this->successResponse();
}
public function supervisorCartableReport(Request $request): BinaryFileResponse
public function supervisorCartableReport(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse
{
$name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
return Excel::download(
new SupervisorCartableExport($request->id, $request->fromDate,
$request->toDate, $request->province_id, $request->edare_id
), $name
);
$data = $roadPatrolReportService->supervisorCartableReport($request);
return Excel::download(new SupervisorCartableReport($data), $name);
}
public function operatorIndex(Request $request): JsonResponse
public function operatorIndex(Request $request, RoadPatrolReportService $roadPatrolReportService): JsonResponse
{
$columns = array(
'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'officer_plaque', 'created_at',
'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()
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
->where('operator_id', '=', auth()->user()->id);
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
$data = $roadPatrolReportService->operatorCartableReport($request);
return response()->json($data);
}
@@ -150,15 +101,11 @@ class RoadPatrolProjectController extends Controller
$user = auth()->user();
if ($user->edarate_ostani_id || is_null($user->city_id)) {
return response()->json([
'message' => 'امکان ثبت فعالیت برای ادارات استانی وجود ندارد!'
], 400);
return $this->errorResponse('امکان ثبت فعالیت برای ادارات استانی وجود ندارد!');
}
if (is_null($user->edarate_shahri_id)) {
return response()->json([
'message' => 'اداره شهری برای شما در سامانه ثبت نشده است!'
], 400);
return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!');
}
$edare_id = $user->edarate_shahri_id ?? $user->edarate_ostani_id;
@@ -279,9 +226,7 @@ class RoadPatrolProjectController extends Controller
$road_item = RoadItemsProject::store($user, $attributes, $before_image, $after_image, $observed_item->id);
if ($road_item === -1) {
return response()->json([
'message' => 'اقدام مربوطه قبلا رسیدگی شده است.'
], 400);
return $this->errorResponse('اقدام مربوطه قبلا رسیدگی شده است.');
}
$road_item->rahdaran()->attach($item['road_item_rahdaran_id']);
@@ -332,27 +277,6 @@ class RoadPatrolProjectController extends Controller
return $this->successResponse($data);
}
public function getAllDataToMap(Request $request): JsonResponse
{
$date_from = $request->date_from ? $request->date_from .' 00:00:00' : Date('Y-m-d') .' 00:00:00';
$date_to = $request->date_to ? $request->date_to.' 23:59:59' : (new \DateTime('tomorrow'))->format('Y-m-d').' 23:59:59';
$data = RoadPatrol::query()->when($request->province_id, function ($query, $province) {
return $query->where('province_id', '=', $province);
})
->when($request->edare_id, function ($query, $edare_id) {
return $query->where('edare_id', '=', $edare_id);
})
->whereBetween('created_at', [
$date_from,
$date_to,
])
->select('id', 'start_lat', 'start_lon')
->get();
return $this->successResponse($data);
}
public function map(Request $request): JsonResponse
{
$province = $request->province_id;
@@ -396,12 +320,10 @@ class RoadPatrolProjectController extends Controller
return $this->successResponse($roadPatrol);
}
public function operatorCartableReport(Request $request): BinaryFileResponse
public function operatorCartableReport(Request $request, RoadPatrolReportService $roadPatrolReportService): BinaryFileResponse
{
$name = 'گزارش از کارتابل عملیات گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
return Excel::download(
new OperatorCartableExport($request->id, $request->status, $request->officer_name, $request->fromDate, $request->toDate),
$name
);
$data = $roadPatrolReportService->operatorCartableReport($request);
return Excel::download(new OperatorCartableReport($data), $name);
}
}

View File

@@ -27,7 +27,7 @@ class StoreRequest extends FormRequest
'distance' => 'numeric',
'start_time' => 'required|date_format:Y-m-d H:i',
'end_time' => 'required|date_format:Y-m-d H:i|after:start_time',
'fuel_consumption' => 'required|integer',
'fuel_consumption' => 'required|numeric',
'vehicle_runtime' => 'required|integer',
'stop_points' => 'required|array',
'road_patrol_machines_id' => 'required|array',
@@ -38,9 +38,9 @@ class StoreRequest extends FormRequest
'observed_items' => 'array',
'observed_items.*.item_id' => 'required|integer',
'observed_items.*.sub_item_id' => 'required|integer',
'observed_items.*.local_name' => 'required',
'observed_items.*.description' => '',
'observed_items.*.instant_action' => 'required|in:0,1',
'observed_items.*.local_name' => 'required_if:observed_items.*.instant_action,0',
// road item projects fields
'observed_items.*.start_point' => 'required',
@@ -50,7 +50,7 @@ class StoreRequest extends FormRequest
'observed_items.*.after_image' => 'image|max:4096',
'observed_items.*.priority' => 'integer|in:1,2,3|required_if:observed_items.*.instant_action,0',
'observed_items.*.priority_fa' => 'string|required_if:observed_items.*.instant_action,0',
'description' => 'string|required_with:observed_items',
'description' => 'string',
'observed_items.*.road_item_machines_id' => 'required_if:observed_items.*.instant_action,1|array',
'observed_items.*.road_item_machines_id.*' => 'required_if:observed_items.*.instant_action,1|exists:cmms_machines,id',

View File

@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Casts\Attribute;
class RoadPatrol extends Model
{
@@ -13,6 +14,13 @@ class RoadPatrol extends Model
protected $guarded = ['id'];
protected function stopPoints(): Attribute
{
return Attribute::make(
get: fn ($value) => $value ? json_decode($value) : null,
);
}
public function observedItems(): HasMany
{
return $this->hasMany(ObservedItem::class);

View File

@@ -15,10 +15,10 @@ class DataTableInput
* @param array $rels
*/
public function __construct(
private int $start,
private ?int $start,
private ?int $size,
private array $filters,
private array $sorting,
private ?array $sorting,
private array $rels,
private array $allowedFilters,
private array $allowedSortings,
@@ -26,7 +26,7 @@ class DataTableInput
{
}
public function getStart(): int
public function getStart(): ?int
{
return $this->start;
}
@@ -74,6 +74,4 @@ class DataTableInput
{
return $this->rels;
}
}

View File

@@ -76,7 +76,9 @@ class DataTableService
$this->totalRowCount = $query->count();
$query->offset($this->dataTableInput->getStart());
if (!is_null($this->dataTableInput->getStart())) {
$query->offset($this->dataTableInput->getStart());
}
if(!is_null($this->dataTableInput->getSize())){
$query->limit($this->dataTableInput->getSize());

View File

@@ -50,7 +50,7 @@ class FilterValidator
protected function isAllowed(Filter $filter, array $allowedFilters): bool
{
return in_array($filter->getId(), $allowedFilters);
return $allowedFilters == ['*'] || in_array($filter->getId(), $allowedFilters);
}
protected function isValidSearchFunction(Filter $filter): bool

View File

@@ -34,6 +34,6 @@ class SortingValidator
protected function isAllowed(Sort $sorting, array $allowedSortings): bool
{
return in_array($sorting->getId(), $allowedSortings);
return $allowedSortings == ['*'] || in_array($sorting->getId(), $allowedSortings);
}
}

View File

@@ -2,92 +2,232 @@
namespace App\Services\Reports;
use App\Facades\DataTable\DataTableFacade;
use App\Models\InfoItem;
use App\Models\RoadItemsProject;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
class RoadItemReportService
{
public function countryActivityPerSubItem(int $item, string $fromDate, string $toDate): array
public function supervisorCartableReport(Request $request)
{
$subItems = InfoItem::query()->where('item', $item)
->orderBy('sub_item')
->get(['sub_item', 'sub_item_str', 'sub_item_unit']);
$columns = array(
'id', 'user_id', 'start_lat', 'start_lng', 'end_lat',
'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',
);
$query = DB::table('road_items_projects')
->selectRaw('province_id, province_fa');
$allowedFilters = $columns;
$allowedSortings = $columns;
foreach ($subItems as $subItem) {
$query->selectRaw("
COUNT(CASE WHEN sub_item = {$subItem->sub_item} THEN 1 END) as Count_{$subItem->sub_item},
SUM(CASE WHEN sub_item = {$subItem->sub_item} THEN sub_item_data END) as Sum_{$subItem->sub_item}
");
$user = auth()->user();
$query = null;
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']);
}
elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) {
if (is_null($user->province_id)) {
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
}
$query = RoadItemsProject::query()->where('is_new', 1)
->with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])->where('province_id', auth()->user()->province_id);
}
$query->where('item', '=', $item)
->where('status', '=', 1)
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
return $data;
}
public function operatorCartableReport(Request $request)
{
$columns = array(
'id', 'user_id', 'start_lat', 'start_lng', 'end_lat',
'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;
$query = RoadItemsProject::with(['files', 'rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
->where('is_new', 1)
->where('user_id', auth()->user()->id);
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
return $data;
}
public function countryActivityPerSubItem(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();
$item = $request->item;
$provinceRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
province_id AS p')
->where('item', '=', $item)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->groupBy('province_id', 'province_fa')
->orderBy('province_id');
->where('status', '=', 1)
->groupBy('province_id', 'sub_item')
->get();
$activities = $query->get();
$countryRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
-1 AS p')
->where('item', '=', $item)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('status', '=', 1)
->groupBy('sub_item')
->get();
$totalItemCount = [
'province_fa' => 'کشوری'
];
foreach ($subItems as $subItem) {
$totalItemCount["Count_{$subItem->sub_item}"] = $activities->sum("Count_{$subItem->sub_item}");
$totalItemCount["Sum_{$subItem->sub_item}"] = $activities->sum("Sum_{$subItem->sub_item}");
}
$activities = $provinceRoadItemsPerSubItem->push(...$countryRoadItemsPerSubItem);
return [
'data' => $activities->push((object)$totalItemCount),
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate,
'details' => $subItems->keyBy('sub_item'),
];
}
public function provinceActivityPerSubItem(int $item, string $fromDate, string $toDate, int $provinceId): array
public function provinceActivityPerSubItem(Request $request): array
{
$subItems = InfoItem::query()->where('item', $item)
->orderBy('sub_item')
->get(['sub_item', 'sub_item_str', 'sub_item_unit']);
$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();
$item = $request->item;
$province = $request->province_id;
$query = DB::table('road_items_projects')
->selectRaw('province_id, province_fa, TRIM(SUBSTRING_INDEX(user_name, "استان", 1)) as city_fa, city_id');
foreach ($subItems as $subItem) {
$query->selectRaw("
COUNT(CASE WHEN sub_item = {$subItem->sub_item} THEN 1 END) as Count_{$subItem->sub_item},
SUM(CASE WHEN sub_item = {$subItem->sub_item} THEN sub_item_data END) as Sum_{$subItem->sub_item}
");
}
$query->where('item', '=', $item)
->where('status', '=', 1)
->where('province_id', '=', $provinceId)
$cityRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
province_id AS p,
edarat_id AS ci
')
->where('item', '=', $item)
->where('province_id', '=', $province)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->groupBy('city_id')
->orderBy('province_id');
->where('status', '=', 1)
->groupBy('edarat_id', 'sub_item')
->get();
$activities = $query->get();
$provinceRoadItemsPerSubItem = RoadItemsProject::query()->selectRaw('
sub_item AS t,
COUNT(*) AS c,
CAST(SUM(CASE WHEN sub_item_data > 0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,
province_id AS p,
-1 AS ci
')
->where('item', '=', $item)
->where('province_id', '=', $province)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('status', '=', 1)
->groupBy('sub_item')
->get();
$totalItemCount = [
'city_fa' => 'استانی'
];
foreach ($subItems as $subItem) {
$totalItemCount["Count_{$subItem->sub_item}"] = $activities->sum("Count_{$subItem->sub_item}");
$totalItemCount["Sum_{$subItem->sub_item}"] = $activities->sum("Sum_{$subItem->sub_item}");
}
$activities = $cityRoadItemsPerSubItem->push(...$provinceRoadItemsPerSubItem);
return [
'data' => $activities->push((object)$totalItemCount),
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate,
];
}
public function countryActivityPerItem(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();
$user = auth()->user();
// $isSpecialUser = in_array($user->username, ['witel', 'drdanesh']);
$isSpecialUser = $user->hasPermissionTo("show-road-item-supervise-cartable");
$provinceId = $isSpecialUser ? null : $user->province_id;
$provinceActivity = RoadItemsProject::query()
->selectRaw('COUNT(*) AS s, province_id AS p, item AS i')
->where('status', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->when(!$isSpecialUser, function ($query) use ($provinceId) {
$query->where('province_id', $provinceId);
})
->groupBy('province_id', 'item');
$countryActivity = RoadItemsProject::query()
->selectRaw('COUNT(*) AS s, -1 AS p, item AS i')
->where('status', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->when(!$isSpecialUser, function ($query) use ($provinceId) {
$query->where('province_id', $provinceId);
})
->groupBy('item');
$activities = $provinceActivity
->unionAll($countryActivity)
->get();
return [
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate,
];
}
public function provinceActivityPerItem(Request $request): array
{
$provinceId = $request->province_id;
$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();
$edarehActivity = RoadItemsProject::query()
->selectRaw('
COUNT(*) AS s,
edarat_id AS c,
item AS i')
->where('status', '=', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('province_id', $provinceId)
->groupBy('item', 'edarat_id');
$cityActivity = RoadItemsProject::query()
->selectRaw('
COUNT(*) AS s,
-1 AS c,
item AS i')
->where('status', '=', 1)
->whereBetween('activity_date_time', [$fromDate, $toDate])
->where('province_id', $provinceId)
->groupBy('item');
$activities = $edarehActivity
->unionAll($cityActivity)
->get();
return [
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate,
'details' => $subItems->keyBy('sub_item')
];
}
}

View File

@@ -2,10 +2,75 @@
namespace App\Services\Reports;
use App\Facades\DataTable\DataTableFacade;
use App\Models\RoadPatrol;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class RoadPatrolReportService
{
public function supervisorCartableReport(Request $request)
{
$columns = array(
'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'operator_id', 'created_at',
'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();
$query = null;
if ($user->hasPermissionTo('show-road-patrol-supervise-cartable')) {
$query = RoadPatrol::query()
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']);
}
elseif ($user->hasPermissionTo('show-road-patrol-supervise-cartable-province')) {
if (is_null($user->province_id)) {
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
}
$query = RoadPatrol::query()
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
->where('province_id', '=', $user->province_id);
}
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
return $data;
}
public function operatorCartableReport(Request $request)
{
$columns = array(
'id', 'start_lat', 'start_lon', 'end_lat', 'end_lon', 'officer_plaque', 'created_at',
'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()
->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number'])
->where('operator_id', '=', auth()->user()->id);
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
return $data;
}
public function countryActivity(string $fromDate, string $toDate): array
{
$activities = DB::select('SELECT
@@ -53,7 +118,7 @@ class RoadPatrolReportService
);
return [
'activities' => $activities,
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate
];
@@ -116,7 +181,7 @@ class RoadPatrolReportService
);
return [
'activities' => $activities,
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate
];

View File

@@ -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::table('road_patrols', function (Blueprint $table) {
$table->string('fuel_consumption')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('road_patrols', function (Blueprint $table) {
$table->integer('fuel_consumption')->change();
});
}
};

View File

@@ -14,19 +14,19 @@
<table>
<thead>
<tr>
<th colspan="18"
<th colspan="20"
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="18"
<th colspan="20"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="18"
<th colspan="20"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
گزارش فعالیت روزانه و جاری راهداری از تاریخ
{{ verta($fromDate)->format('Y/n/j') }}
@@ -38,83 +38,60 @@
</tr>
<tr>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">اداره کل
</th>
<th colspan="16" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">فعالیت های
جاری و روزانه راهداری
</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">کل</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">اداره</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">مجموع</th>
<th colspan="18" 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: #C4D79B;">مرمت رویه</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">پاکسازی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">علائم</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">حفاظ</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">روشنایی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">خط کشی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">رنگ آمیزی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">شستشو</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">ایمن سازی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">حریم</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">پل</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">تونل و گالری</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">عملیات زمستانی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">ماشین آلات</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">راهدارخانه</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">موارد اضطراری</th>
@foreach($items as $item)
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">{{ $item['item_str'] }}</th>
@endforeach
</tr>
</thead>
<tbody>
<tr>
<td style="border:1px solid black;text-align: center;">کل کشور</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalMarematRooyeCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalPaksaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalAlaemCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalHefazCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalRoshanayiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalKhatkeshiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalRangamiziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalWashingCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalImenSaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalHarimCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalPolCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalToonelCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalAmaliatZemestaniCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalMashinAlatCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalTollhouseCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalEmergencyCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalCountryCount'] }}</td>
</tr>
@php
// محاسبه مجموع مقدار s برای کل کشور
$totalForCountry = collect($data)->where('p', -1)->sum('s');
@foreach ($provinceCount as $activity)
// محاسبه مجموع مقدار s برای هر آیتم در کل کشور
$itemTotalsForCountry = [];
foreach ($items as $item) {
$itemTotalsForCountry[$item['item']] = collect($data)->where('p', -1)->where('i', $item['item'])->sum('s');
}
@endphp
{{-- ردیف کل کشور --}}
<tr>
<td style="border:1px solid black;text-align: center;">کل کشور</td>
<td style="border:1px solid black;text-align: center;">{{ $totalForCountry }}</td>
@foreach($items as $item)
<td style="border:1px solid black;text-align: center;">{{ $itemTotalsForCountry[$item['item']] ?? '-' }}</td>
@endforeach
</tr>
{{-- ردیف‌های مربوط به هر استان --}}
@foreach($provinces as $province)
@php
// محاسبه مجموع مقدار s برای این استان
$totalForProvince = collect($data)->where('p', $province['id'])->sum('s');
// محاسبه مجموع مقدار s برای هر آیتم در این استان
$itemTotalsForProvince = [];
foreach ($items as $item) {
$itemTotalsForProvince[$item['item']] = collect($data)->where('p', $province['id'])->where('i', $item['item'])->sum('s');
}
@endphp
<tr>
<td style="border:1px solid black;text-align: center;">{{ $activity->province_fa }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->MarematRooyeCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->PaksaziCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->AlaemCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->HefazCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->RoshanayiCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->KhatkeshiCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->RangamiziCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->WashingCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->ImenSaziCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->HarimCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->PolCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->ToonelCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->AmaliatZemestaniCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->MashinAlatCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->TollhouseCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->EmergencyCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->TotalProvinceCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $province['name_fa'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $totalForProvince }}</td>
@foreach($items as $item)
<td style="border:1px solid black;text-align: center;">{{ $itemTotalsForProvince[$item['item']] ?? '-' }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -28,7 +28,7 @@
تا
تاریخ
{{verta($toDate)->format('Y/n/j')}}
</th>>
</th>
</tr>
<tr>
@@ -37,38 +37,60 @@
</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)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $activity->province_fa }}</td>
@php
// محاسبه مقدار c و s برای هر ساب‌آیتم در کل کشور
$countTotalsForCountry = [];
$sumTotalsForCountry = [];
@foreach ($details as $index => $detail)
<td style="border: 1px solid black;text-align: center;">
{{ $activity->{'Count_' . ($index)} ?? '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">
{{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }}
</td>
foreach ($subItems as $subItem) {
$countTotalsForCountry[$subItem['sub_item']] = collect($data)->where('p', -1)->where('t', $subItem['sub_item'])->sum('c');
$sumTotalsForCountry[$subItem['sub_item']] = collect($data)->where('p', -1)->where('t', $subItem['sub_item'])->sum('s');
}
@endphp
{{-- ردیف کل کشور --}}
<tr>
<td style="border:1px solid black;text-align: center;">کل کشور</td>
@foreach($subItems as $subItem)
<td style="border:1px solid black;text-align: center;">{{ $countTotalsForCountry[$subItem['sub_item']] ?? '-' }}</td>
<td style="border:1px solid black;text-align: center;">{{ $sumTotalsForCountry[$subItem['sub_item']] ?? '-' }}</td>
@endforeach
</tr>
{{-- ردیف‌های مربوط به هر استان --}}
@foreach($provinces as $province)
@php
$countTotalsForProvince = [];
$sumTotalsForProvince = [];
foreach ($subItems as $subItem) {
$countTotalsForProvince[$subItem['sub_item']] = collect($data)->where('p', $province['id'])->where('t', $subItem['sub_item'])->sum('c');
$sumTotalsForProvince[$subItem['sub_item']] = collect($data)->where('p', $province['id'])->where('t', $subItem['sub_item'])->sum('s');
}
@endphp
<tr>
<td style="border:1px solid black;text-align: center;">{{ $province['name_fa'] }}</td>
@foreach($subItems as $subItem)
<td style="border:1px solid black;text-align: center;">{{ $countTotalsForProvince[$subItem['sub_item']] ?? '-' }}</td>
<td style="border:1px solid black;text-align: center;">{{ $sumTotalsForProvince[$subItem['sub_item']] ?? '-' }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,119 @@
<!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="14"
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="14"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="14"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
گزارش کارتابل عملیات فعالیت های روزانه و جاری
</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>
<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['edarat_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['item_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['sub_item_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">
{{ $item['sub_item_data'] ? ($item['unit_fa'] ? $item['sub_item_data'] . '(' . $item['unit_fa'] . ')' : $item['sub_item_data'] . '(-)') : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }}</td>
<td style="border: 1px solid black;text-align: center;">
{{ isset($item['start_lat']) && isset($item['start_lng']) ? $item['start_lat'] . ' ' . $item['start_lng'] : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">
{{ isset($item['end_lat']) && isset($item['end_lng']) ? $item['end_lat'] . ' ' . $item['end_lng'] : '-' }}
</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 style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['status_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['supervisor_description'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -14,19 +14,19 @@
<table>
<thead>
<tr>
<th colspan="18"
<th colspan="20"
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="18"
<th colspan="20"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="18"
<th colspan="20"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
گزارش فعالیت روزانه و جاری راهداری از تاریخ
{{ verta($fromDate)->format('Y/n/j') }}
@@ -38,83 +38,57 @@
</tr>
<tr>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">اداره کل
</th>
<th colspan="16" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">فعالیت های
جاری و روزانه راهداری
</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">کل</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">اداره</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">مجموع</th>
<th colspan="18" 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: #C4D79B;">مرمت رویه</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">پاکسازی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">علائم</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">حفاظ</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">روشنایی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">خط کشی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">رنگ آمیزی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">شستشو</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">ایمن سازی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">حریم</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">پل</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">تونل و گالری</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">عملیات زمستانی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">ماشین آلات</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">راهدارخانه</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">موارد اضطراری</th>
@foreach($items as $item)
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">{{ $item['item_str'] }}</th>
@endforeach
</tr>
</thead>
<tbody>
<tr>
<td style="border:1px solid black;text-align: center;">کل استان</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalMarematRooyeCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalPaksaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalAlaemCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalHefazCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalRoshanayiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalKhatkeshiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalRangamiziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalWashingCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalImenSaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalHarimCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalPolCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalToonelCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalAmaliatZemestaniCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalMashinAlatCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalTollhouseCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['totalEmergencyCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $provinceCount['TotalProvinceCount'] }}</td>
</tr>
@php
$totalForProvince = collect($data)->where('c', -1)->sum('s');
@foreach ($cityCount as $activity)
$itemTotalsForProvince = [];
foreach ($items as $item) {
$itemTotalsForProvince[$item['item']] = collect($data)->where('c', -1)->where('i', $item['item'])->sum('s');
}
@endphp
<tr>
<td style="border:1px solid black;text-align: center;">کل استان</td>
<td style="border:1px solid black;text-align: center;">{{ $totalForProvince }}</td>
@foreach($items as $item)
<td style="border:1px solid black;text-align: center;">{{ $itemTotalsForProvince[$item['item']] ?? '-' }}</td>
@endforeach
</tr>
{{-- ردیف‌های مربوط به هر استان --}}
@foreach($edarateShahri as $edareShahri)
@php
// محاسبه مجموع مقدار s برای این استان
$totalForProvince = collect($data)->where('c', $edareShahri['id'])->sum('s');
// محاسبه مجموع مقدار s برای هر آیتم در این استان
$itemTotalsForProvince = [];
foreach ($items as $item) {
$itemTotalsForProvince[$item['item']] = collect($data)->where('c', $edareShahri['id'])->where('i', $item['item'])->sum('s');
}
@endphp
<tr>
<td style="border:1px solid black;text-align: center;">{{ $activity->edarat_name }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->MarematRooyeCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->PaksaziCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->AlaemCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->HefazCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->RoshanayiCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->KhatkeshiCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->RangamiziCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->WashingCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->ImenSaziCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->HarimCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->PolCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->ToonelCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->AmaliatZemestaniCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->MashinAlatCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->TollhouseCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->EmergencyCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity->TotalCityCount }}</td>
<td style="border:1px solid black;text-align: center;">{{ $edareShahri['name_fa'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $totalForProvince }}</td>
@foreach($items as $item)
<td style="border:1px solid black;text-align: center;">{{ $itemTotalsForProvince[$item['item']] ?? '-' }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -28,47 +28,69 @@
تا
تاریخ
{{verta($toDate)->format('Y/n/j')}}
</th>>
</th>
</tr>
<tr>
<th rowspan="3" style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">اداره</th>
<th rowspan="3" style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">اداره کل</th>
<th colspan="24" style="border: 1px solid black;text-align: center;background-color: #EBF1DE;">فعالیت های انجام شده</th>
</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)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $activity->city_fa }}</td>
@php
// محاسبه مقدار c و s برای هر ساب‌آیتم در کل کشور
$countTotalsForProvince = [];
$sumTotalsForProvince = [];
@foreach ($details as $index => $detail)
<td style="border: 1px solid black;text-align: center;">
{{ $activity->{'Count_' . ($index)} ?? '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">
{{ isset($activity->{'Sum_' . ($index)}) ? round($activity->{'Sum_' . ($index)}, 1) : '-' }}
</td>
foreach ($subItems as $subItem) {
$countTotalsForProvince[$subItem['sub_item']] = collect($data)->where('ci', -1)->where('t', $subItem['sub_item'])->sum('c');
$sumTotalsForProvince[$subItem['sub_item']] = collect($data)->where('ci', -1)->where('t', $subItem['sub_item'])->sum('s');
}
@endphp
{{-- ردیف کل کشور --}}
<tr>
<td style="border:1px solid black;text-align: center;">کل کشور</td>
@foreach($subItems as $subItem)
<td style="border:1px solid black;text-align: center;">{{ $countTotalsForProvince[$subItem['sub_item']] ?? '-' }}</td>
<td style="border:1px solid black;text-align: center;">{{ $sumTotalsForProvince[$subItem['sub_item']] ?? '-' }}</td>
@endforeach
</tr>
{{-- ردیف‌های مربوط به هر استان --}}
@foreach($edarateShahri as $edareShahri)
@php
$countTotalsForProvince = [];
$sumTotalsForProvince = [];
foreach ($subItems as $subItem) {
$countTotalsForProvince[$subItem['sub_item']] = collect($data)->where('ci', $edareShahri['id'])->where('t', $subItem['sub_item'])->sum('c');
$sumTotalsForProvince[$subItem['sub_item']] = collect($data)->where('ci', $edareShahri['id'])->where('t', $subItem['sub_item'])->sum('s');
}
@endphp
<tr>
<td style="border:1px solid black;text-align: center;">{{ $edareShahri['name_fa'] }}</td>
@foreach($subItems as $subItem)
<td style="border:1px solid black;text-align: center;">{{ $countTotalsForProvince[$subItem['sub_item']] ?? '-' }}</td>
<td style="border:1px solid black;text-align: center;">{{ $sumTotalsForProvince[$subItem['sub_item']] ?? '-' }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,119 @@
<!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="14"
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="14"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="14"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
گزارش کارتابل ارزیابی فعالیت های روزانه و جاری
</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>
<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['edarat_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['item_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['sub_item_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">
{{ $item['sub_item_data'] ? ($item['unit_fa'] ? $item['sub_item_data'] . '(' . $item['unit_fa'] . ')' : $item['sub_item_data'] . '(-)') : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }}</td>
<td style="border: 1px solid black;text-align: center;">
{{ isset($item['start_lat']) && isset($item['start_lng']) ? $item['start_lat'] . ' ' . $item['start_lng'] : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">
{{ isset($item['end_lat']) && isset($item['end_lng']) ? $item['end_lat'] . ' ' . $item['end_lng'] : '-' }}
</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 style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['status_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['supervisor_description'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -152,9 +152,6 @@ Route::prefix('road_patrols')
Route::get('/operator/report/{roadPatrol}', 'getReport')
->name('getReport');
Route::get('/operator/map_data', 'getAllDataToMap')
->name('getAllDataToMap');
Route::get('/detail/{roadPatrol}', 'show')
->name('show');
});
@@ -195,10 +192,10 @@ Route::prefix('road_item_reports')
->controller(RoadItemsReportController::class)
->group(function () {
Route::get('/get_sub_items', 'getSubItems')->name('getSubItems');
Route::get('/country_activity_per_sub_item', 'countryActivityPerSubItem')->name('countryActivityPerSubItem');
Route::get('/province_activity_per_sub_item', 'provinceActivityPerSubItem')->name('provinceActivityPerSubItem');
Route::get('/city_activity_per_sub_item', 'cityActivityPerSubItem')->name('cityActivityPerSubItem');
Route::get('/country_activity_per_item', 'countryActivityPerItem')->name('countryActivityPerItem');
Route::get('/province_activity_per_item', 'provinceActivityPerItem')->name('provinceActivityPerItem');
Route::get('/city_activity_per_item', 'cityActivityPerItem')->name('cityActivityPerItem');
Route::get('/map', 'map')->name('map');
Route::get('/country_activity_excel_per_item', 'countryActivityExcelPerItem')->name('countryActivityExcelPerItem');
Route::get('/province_activity_excel_per_item', 'provinceActivityExcelPerItem')->name('provinceActivityExcelPerItem');
@@ -214,4 +211,5 @@ Route::prefix('road_patrol_reports')
Route::get('/province_activity', 'provincePatrolActivity')->name('provincePatrolActivity');
Route::get('/country_activity_excel', 'countryActivityExcel')->name('countryActivityExcel');
Route::get('/province_activity_excel', 'provinceActivityExcel')->name('provinceActivityExcel');
Route::get('/activities_on_map', 'activitiesOnMap')->name('activitiesOnMap');
});