create excel for report

This commit is contained in:
faezeh
2026-06-27 17:07:13 +03:30
parent aa468b592b
commit da82c7841b
11 changed files with 635 additions and 130 deletions

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Exports\V3\Mission\Report\Machine;
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\Exception;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class machineDetailsReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$exportRows = [];
foreach ($this->data as $r) {
$exportRows[] = [
'id' => $r->id,
'province_name' => $r->province_name,
'city_name' => $r->city_name,
'station_name' => $r->station_name ?? 0,
'driver_name' => $r->driver_name ?? '',
'km' => $r->km ?? '',
'end_km' => $r->end_km ?? '',
];
}
return view('v3.Reports.Mission.Report.Machine.ActivityDetailsReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
/**
* @throws Exception
*/
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(+90);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('E1');
return [$drawing, $drawing2];
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace App\Exports\V3\Mission\Report\Machine;
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\Exception;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class machineDriverDetailsReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$exportRows = [];
foreach ($this->data as $r) {
$exportRows[] = [
'id' => $r->id,
'province_name' => $r->province_name,
'city_name' => $r->city_name,
'station_name' => $r->station_name ?? 0,
'driver_name' => $r->driver_name ?? '',
'km' => $r->km ?? '',
'end_km' => $r->end_km ?? '',
];
}
return view('v3.Reports.Mission.Report.Machine.MachineDriverDetailsReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
/**
* @throws Exception
*/
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(+90);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('D1');
return [$drawing, $drawing2];
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Exports\V3\Mission\Report\Machine;
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\Exception;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class machineTypeDetailsReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
{
public function __construct(private array $data)
{
}
public function view(): View
{
$exportRows = [];
foreach ($this->data as $r) {
$exportRows[] = [
'id' => $r->id,
'province_name' => $r->province_name,
'city_name' => $r->city_name,
'station_name' => $r->station_name ?? 0,
'driver_name' => $r->driver_name ?? '',
'km' => $r->km ?? '',
'end_km' => $r->end_km ?? '',
];
}
return view('v3.Reports.Mission.Report.Machine.MachineTypeDetailsReport', [
'rows' => $exportRows,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
/**
* @throws Exception
*/
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(+90);
$drawing2->setOffsetY(5);
$drawing2->setCoordinates('C1');
return [$drawing, $drawing2];
}
}

View File

@@ -2,14 +2,14 @@
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
use App\Exports\V3\Mission\Report\Machine\machineDetailsReport;
use App\Exports\V3\Mission\Report\Machine\machineDriverDetailsReport;
use App\Exports\V3\Mission\Report\Machine\machineDriverReport;
use App\Exports\V3\Mission\Report\Machine\machineReport;
use App\Exports\V3\Mission\Report\Machine\machineTypeDetailsReport;
use App\Exports\V3\Mission\Report\Machine\machineTypeReport;
use App\Facades\DataTable\DataTableFacade;
use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\CMMSMachine;
use App\Models\Mission;
use App\Services\Cartables\Mission\Report\ReportMachineService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -21,113 +21,26 @@ class ReportMachineController extends Controller
{
use ApiResponse;
public function countryMachinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
public function machineDetailsReport(Request $request, ReportMachineService $reportMachineService,int $machine_id): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->countryMachinesActivity($request),
// 'provinces' => Province::all(['id', 'name_fa']),
]);
$data = $reportMachineService->dataTableMachinesActivity($request,$machine_id);
return response()->json($data);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function countryMachinesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
public function machineDetailsReportExcel(Request $request, int $machine_id, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->countryMachinesActivity($request);
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
$data = $reportMachineService->dataTableMachinesActivity($request,$machine_id);
$name = 'گزارش عملکرد ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineReport($data), $name);
return Excel::download(new machineDetailsReport($data['data']), $name);
}
public function provinceMachinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->provinceMachinesActivity($request),
// 'city' => City::query()
// ->where('province_id', $request->province_id)
// ->where(function ($query) {
// $query->where('type_id', 1)
// ->orWhereIn('name_fa', ['اداره ماشين‌آلات', 'اداره نقلیه']);
// })
// ->get(['id', 'name_fa'])
]);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function provinceMachinesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->provinceMachinesActivity($request);
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineReport($data), $name);
}
public function countryMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->countryMachineTypesActivity($request),
// 'provinces' => Province::all(['id', 'name_fa']),
]);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function countryMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->countryMachineTypesActivity($request);
$name = 'گزارش نوع ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineTypeReport($data), $name);
}
public function provinceMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->provinceMachineTypesActivity($request),
// 'city' => City::query()
// ->where('province_id', $request->province_id)
// ->where(function ($query) {
// $query->where('type_id', 1)
// ->orWhereIn('name_fa', ['اداره ماشين‌آلات', 'اداره نقلیه']);
// })
// ->get(['id', 'name_fa'])
]);
}
public function machineDetailsReport(Request $request, int $machine_id)
{
return DataTableFacade::run(
Mission::query()->where('machine_id', '=', $machine_id),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: [
'id', 'province_id', 'province_name', 'city_id', 'city_name',
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
]
);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function provinceMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->provinceMachineTypesActivity($request);
$name = 'گزارش نوع ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineTypeReport($data), $name);
}
public function countryMachineDriversActivity(Request $request, ReportMachineService $reportMachineService)
public function machinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->machinesActivity($request),
@@ -149,19 +62,23 @@ class ReportMachineController extends Controller
}
public function machineTypeDetailsReport(Request $request): array
public function machineTypeDetailsReport(Request $request, ReportMachineService $reportMachineService,int $car_type): JsonResponse
{
$machineIds = CMMSMachine::query()->where('car_type', '=', $request->query('car_type'))->pluck('machine_id');
return DataTableFacade::run(
Mission::query()->whereIn('machine_id', $machineIds),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: [
'id', 'province_id', 'province_name', 'city_id', 'city_name',
'end_km', 'km', 'driver_name', 'state_name', 'station_name'
]
);
$data = $reportMachineService->dataTableMachineTypesActivity($request,$car_type);
return response()->json($data);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function machineTypeDetailsReportExcel(Request $request, ReportMachineService $reportMachineService,int $car_type): BinaryFileResponse
{
$data = $reportMachineService->dataTableMachineTypesActivity($request,$car_type);
$name = 'گزارش عملکردیک نوع ماشین'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineTypeDetailsReport($data['data']), $name);
}
public function machineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
@@ -184,19 +101,26 @@ class ReportMachineController extends Controller
return Excel::download(new machineTypeReport($data), $name);
}
public function machineDriverDetailsReport(Request $request, int $driver_id): array
public function machineDriverDetailsReport(Request $request, int $driver_id, ReportMachineService $reportMachineService): JsonResponse
{
return DataTableFacade::run(
Mission::query()->where('driver_id', '=', $driver_id),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: [
'id', 'province_id', 'province_name', 'city_id', 'city_name',
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
]
);
$data = $reportMachineService->dataTableMachineDriversActivity($request,$driver_id);
return response()->json($data);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function machineDriverDetailsReportExcel(Request $request, int $driver_id, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->dataTableMachineDriversActivity($request,$driver_id);
$name = 'گزارش عملکرد راننده'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(
new machineDriverDetailsReport($data['data']), $name);
}
public function machineDriversActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([

View File

@@ -3,6 +3,7 @@
namespace App\Http\Requests\V3\Mission\ControlUnit;
use App\Enums\MissionStates;
use App\Models\CMMSMachine;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
@@ -34,6 +35,7 @@ class FinishRequest extends FormRequest
{
return [
function (Validator $validator) {
$mission = $this->mission;
if (strtotime($this->time) < strtotime($mission->start_time)) {
$validator->errors()->add(
@@ -41,18 +43,36 @@ class FinishRequest extends FormRequest
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
);
}
if ($this->end_km <= $mission->km) {
$validator->errors()->add(
'end_km',
'کیلومتر پایان باید بزرگتر از کیلومتر شروع باشد.'
);
}
if (($this->end_km - $mission->km ) < 100) {
$machine = CMMSMachine::find($mission->machine_id);
$distance = $this->end_km - $mission->km;
if ($machine->car_group === 'سنگین') {
if ($distance > 15) {
$validator->errors()->add(
'end_km',
'اختلاف کلیلومتر شروع و پایان نباید بیشتر از 100 کیلومتر باشد'
'اختلاف کیلومتر برای خودروهای سنگین باید کمتر از 15 باشد.'
);
}
} else {
if ($distance > 1000) {
$validator->errors()->add(
'end_km',
'اختلاف کیلومتر برای خودروهای سبک و نیمه سنگین باید کمتر از 1000 باشد.'
);
}
}
}
];
}

View File

@@ -15,7 +15,7 @@ class AllocateRequest extends FormRequest
*/
public function authorize(): bool
{
return $this->mission->station_id == auth()->user()->station_id && $this->mission->state_id == MissionStates::REQUEST_CREATED->value
return ($this->mission->station_id == auth()->user()->station_id && $this->mission->state_id == MissionStates::REQUEST_CREATED->value)
|| auth()->user()->username === 'witel';
}

View File

@@ -3,11 +3,25 @@
namespace App\Services\Cartables\Mission\Report;
use App\Facades\DataTable\DataTableFacade;
use App\Models\CMMSMachine;
use App\Models\Mission;
use Illuminate\Http\Request;
class ReportMachineService
{
public function dataTableMachinesActivity(Request $request, int $machine_id): array
{
return DataTableFacade::run(
Mission::query()->where('machine_id', '=', $machine_id),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: [
'id', 'province_id', 'province_name', 'city_id', 'city_name',
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
]
);
}
public function machinesActivity(Request $request): array
{
$query = Mission::query()
@@ -35,6 +49,21 @@ class ReportMachineService
);
}
public function dataTableMachineTypesActivity(Request $request,int $car_type): array
{
$machineIds = CMMSMachine::query()->where('car_type', '=', $request->query('car_type'))->pluck('machine_id');
return DataTableFacade::run(
Mission::query()->whereIn('machine_id', $machineIds),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: [
'id', 'province_id', 'province_name', 'city_id', 'city_name',
'end_km', 'km', 'driver_name', 'state_name', 'station_name'
]
);
}
public function machineTypesActivity(Request $request): array
{
$query = Mission::query()
@@ -61,6 +90,20 @@ class ReportMachineService
);
}
public function dataTableMachineDriversActivity(Request $request,int $driver_id): array
{
return DataTableFacade::run(
Mission::query()->where('driver_id', '=', $driver_id),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: [
'id', 'province_id', 'province_name', 'city_id', 'city_name',
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
]
);
}
public function machineDriversActivity(Request $request): array
{
$query = Mission::query()

View File

@@ -0,0 +1,94 @@
<!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;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="7"
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="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش ماشین های ماموریت رفته
</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>
</tr>
</thead>
<tbody>
@foreach ($rows 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_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['station_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['driver_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['km'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['end_km'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,94 @@
<!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;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="7"
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="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش عملکرد راندده در ماموریت
</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>
</tr>
</thead>
<tbody>
@foreach ($rows 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_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['station_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['driver_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['km'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['end_km'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,94 @@
<!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;">
@php
// show a dot if key missing or value is 0/empty
function cell($row, $key) {
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
}
@endphp
<table>
<thead>
<tr>
<th colspan="7"
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="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="7"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش نوع ماشین هادرماموریت
</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>
</tr>
</thead>
<tbody>
@foreach ($rows 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_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['station_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['driver_name'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['km'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['end_km'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -568,13 +568,17 @@ Route::prefix('missions')
->group(function () {
Route::get('/machines_activity', 'machinesActivity')->name('machinesActivity');
Route::get('/machines_activity_excel', 'machinesActivityExcel')->name('machinesActivityExcel');
Route::get('/machine_types_activity', 'machineTypesActivity')->name('machineTypesActivity');
Route::get('/machine_types_activity_excel', 'machineTypesActivityExcel')->name('machineTypesActivityExcel');
Route::get('/machine_drivers_activity', 'machineDriversActivity')->name('machineDriversActivity');
Route::get('/machine_drivers_activity_excel', 'machineDriversActivityExcel')->name('machineDriversActivityExcel');
Route::get('/machine_details_report/{machine_id}', 'machineDetailsReport')->name('machineDetailsReport');
Route::get('/machine_details_report_excel/{machine_id}', 'machineDetailsReportExcel')->name('machineDetailsReportExcel');
Route::get('/machine_type_details_report/{car_type}', 'machineTypeDetailsReport')->name('machineTypeDetailsReport');
Route::get('/machine_type_details_report_excel/{car_type}', 'Excel')->name('machineTypeDetailsReportExcel');
Route::get('/machine_driver_details_report/{driver_id}', 'machineDriverDetailsReport')->name('machineDriverDetailsReport');
Route::get('/machine_type_details_report', ' machineTypeDetailsReport')->name('machineTypeDetailsReport');
Route::get('/machine_driver_details_report_excel/{driver_id}', 'machineDriverDetailsReportExcel')->name('machineDriverDetailsReportExcel');
});
});