change Format table report
This commit is contained in:
102
app/Exports/V3/Mission/Report/Tradod/CountryReport.php
Normal file
102
app/Exports/V3/Mission/Report/Tradod/CountryReport.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report\Tradod;
|
||||
|
||||
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\Worksheet\Drawing;
|
||||
|
||||
class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
public function __construct(private array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$grid = [];
|
||||
$national = null;
|
||||
|
||||
foreach ($this->data as $r) {
|
||||
$pid = (int) $r->province_id;
|
||||
$name = $r->province_name;
|
||||
|
||||
if ($pid === -1) {
|
||||
$national = [
|
||||
'province_name' => $name,
|
||||
'total_missions' => (int) ($r->total_missions ?? 0),
|
||||
'taradod_khareg_mahdode' => (int) ($r->taradod_khareg_mahdode ?? 0),
|
||||
'bafarayand_saeti' => (int) ($r->bafarayand_saeti ?? 0),
|
||||
'bafarayand_rozaneh' => (int) ($r->bafarayand_rozaneh ?? 0),
|
||||
'bedon_bafarayand_saeti' => (int) ($r->bedon_bafarayand_saeti ?? 0),
|
||||
'bedon_bafarayand_rozaneh' => (int) ($r->bedon_bafarayand_rozaneh ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($grid[$pid])) {
|
||||
$grid[$pid] = [
|
||||
'province_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$pid]['total_missions'] = (int) ($r->total_missions ?? 0);
|
||||
$grid[$pid]['taradod_khareg_mahdode'] = (int) ($r->taradod_khareg_mahdode ?? 0);
|
||||
$grid[$pid]['bafarayand_saeti'] = (int) ($r->bafarayand_saeti ?? 0);
|
||||
$grid[$pid]['bafarayand_rozaneh'] = (int) ($r->bafarayand_rozaneh ?? 0);
|
||||
$grid[$pid]['bedon_bafarayand_saeti'] = (int) ($r->bedon_bafarayand_saeti ?? 0);
|
||||
$grid[$pid]['bedon_bafarayand_rozaneh'] = (int) ($r->bedon_bafarayand_rozaneh ?? 0);
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
if ($national) {
|
||||
$exportRows[] = $national;
|
||||
}
|
||||
foreach ($grid as $row) {
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
return view('v3.Reports.Mission.Report.CountryActivityReport', [
|
||||
'rows' => $exportRows,
|
||||
]);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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('C1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
107
app/Exports/V3/Mission/Report/Tradod/ProvinceReport.php
Normal file
107
app/Exports/V3/Mission/Report/Tradod/ProvinceReport.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report\Tradod;
|
||||
|
||||
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 ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
public function __construct(private array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$grid = [];
|
||||
$province = null;
|
||||
|
||||
foreach ($this->data as $r) {
|
||||
$cid = (int) $r->city_id;
|
||||
$name = $r->city_name;
|
||||
|
||||
if ($cid === -1) {
|
||||
$province = [
|
||||
'city_name' => $name,
|
||||
'total_missions' => (int) ($r->total_missions ?? 0),
|
||||
'taradod_khareg_mahdode' => (int) ($r->taradod_khareg_mahdode ?? 0),
|
||||
'bafarayand_saeti' => (int) ($r->bafarayand_saeti ?? 0),
|
||||
'bafarayand_rozaneh' => (int) ($r->bafarayand_rozaneh ?? 0),
|
||||
'bedon_bafarayand_saeti' => (int) ($r->bedon_bafarayand_saeti ?? 0),
|
||||
'bedon_bafarayand_rozaneh' => (int) ($r->bedon_bafarayand_rozaneh ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($grid[$cid])) {
|
||||
$grid[$cid] = [
|
||||
'city_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$cid]['total_missions'] = (int) ($r->total_missions ?? 0);
|
||||
$grid[$cid]['taradod_khareg_mahdode'] = (int) ($r->taradod_khareg_mahdode ?? 0);
|
||||
$grid[$cid]['bafarayand_saeti'] = (int) ($r->bafarayand_saeti ?? 0);
|
||||
$grid[$cid]['bafarayand_rozaneh'] = (int) ($r->bafarayand_rozaneh ?? 0);
|
||||
$grid[$cid]['bedon_bafarayand_saeti'] = (int) ($r->bedon_bafarayand_saeti ?? 0);
|
||||
$grid[$cid]['bedon_bafarayand_rozaneh'] = (int) ($r->bedon_bafarayand_rozaneh ?? 0);
|
||||
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
if ($province) {
|
||||
$exportRows[] = $province;
|
||||
}
|
||||
foreach ($grid as $row) {
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
return view('v3.Reports.Mission.Report.ProvinceActivityReport', [
|
||||
'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(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('C1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report;
|
||||
namespace App\Exports\V3\Mission\Report\Violation;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
@@ -28,8 +28,11 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
if ($pid === -1) {
|
||||
$national = [
|
||||
'province_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'out_of_area_count' => (int) ($r->out_of_area_count ?? 0),
|
||||
'total_violations' => (int) ($r->total_violations ?? 0),
|
||||
'egdam_shode' => (int) ($r->egdam_shode ?? 0),
|
||||
'bedone_egdam' => (int) ($r->bedone_egdam ?? 0),
|
||||
'sabt_gps' => (int) ($r->sabt_gps ?? 0),
|
||||
'sabt_herasat' => (int) ($r->herasat ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
@@ -41,8 +44,11 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$pid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$pid]['out_of_area_count'] = (int) ($r->out_of_area_count ?? 0);
|
||||
$grid[$pid]['total_violations'] = (int) ($r->total_violations ?? 0);
|
||||
$grid[$pid]['egdam_shode'] = (int) ($r->egdam_shode ?? 0);
|
||||
$grid[$pid]['bedone_egdam'] = (int) ($r->bedone_egdam ?? 0);
|
||||
$grid[$pid]['sabt_gps'] = (int) ($r->sabt_gps ?? 0);
|
||||
$grid[$pid]['sabt_herasat'] = (int) ($r->sabt_herasat ?? 0);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report;
|
||||
namespace App\Exports\V3\Mission\Report\Violation;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
@@ -29,8 +29,12 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
if ($cid === -1) {
|
||||
$province = [
|
||||
'city_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'out_of_area_count' => (int) ($r->out_of_area_count ?? 0),
|
||||
'total_violations' => (int) ($r->total_violations ?? 0),
|
||||
'egdam_shode' => (int) ($r->egdam_shode ?? 0),
|
||||
'bedone_egdam' => (int) ($r->bedone_egdam ?? 0),
|
||||
'sabt_gps' => (int) ($r->sabt_gps ?? 0),
|
||||
'sabt_herasat' => (int) ($r->herasat ?? 0),
|
||||
|
||||
];
|
||||
|
||||
continue;
|
||||
@@ -42,8 +46,11 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$cid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$cid]['out_of_area_count'] = (int) ($r->out_of_area_count ?? 0);
|
||||
$grid[$cid]['total_violations'] = (int) ($r->total_violations ?? 0);
|
||||
$grid[$cid]['egdam_shode'] = (int) ($r->egdam_shode ?? 0);
|
||||
$grid[$cid]['bedone_egdam'] = (int) ($r->bedone_egdam ?? 0);
|
||||
$grid[$cid]['sabt_gps'] = (int) ($r->sabt_gps ?? 0);
|
||||
$grid[$cid]['sabt_herasat'] = (int) ($r->sabt_herasat ?? 0);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user