fix code and use pint for mission in some folder
This commit is contained in:
@@ -10,9 +10,11 @@ use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class CountryReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
public function __construct(private array $data){}
|
||||
public function __construct(private array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
@@ -20,32 +22,34 @@ class CountryReport implements FromView, WithEvents, ShouldAutoSize, WithDrawing
|
||||
$national = null;
|
||||
|
||||
foreach ($this->data as $r) {
|
||||
$pid = (int) $r->province_id;
|
||||
$pid = (int) $r->province_id;
|
||||
$name = $r->province_name;
|
||||
|
||||
if ($pid === -1) {
|
||||
$national = [
|
||||
'province_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'province_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'out_of_area_count' => (int) ($r->out_of_area_count ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!isset($grid[$pid])) {
|
||||
if (! isset($grid[$pid])) {
|
||||
$grid[$pid] = [
|
||||
'province_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$pid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$pid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$pid]['out_of_area_count'] = (int) ($r->out_of_area_count ?? 0);
|
||||
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
if ($national) $exportRows[] = $national;
|
||||
if ($national) {
|
||||
$exportRows[] = $national;
|
||||
}
|
||||
foreach ($grid as $row) {
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
@@ -85,6 +89,7 @@ class CountryReport implements FromView, WithEvents, ShouldAutoSize, WithDrawing
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('C1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Exports\V3\Mission\Report;
|
||||
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
@@ -12,9 +11,11 @@ use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class ProvinceReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
public function __construct(private array $data){}
|
||||
public function __construct(private array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
@@ -22,37 +23,38 @@ class ProvinceReport implements FromView, WithEvents, ShouldAutoSize, WithDrawin
|
||||
$province = null;
|
||||
|
||||
foreach ($this->data as $r) {
|
||||
$cid = (int) $r->city_id;
|
||||
$cid = (int) $r->city_id;
|
||||
$name = $r->city_name;
|
||||
|
||||
if ($cid === -1) {
|
||||
$province = [
|
||||
'city_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'city_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'out_of_area_count' => (int) ($r->out_of_area_count ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!isset($grid[$cid])) {
|
||||
if (! isset($grid[$cid])) {
|
||||
$grid[$cid] = [
|
||||
'city_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$cid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$cid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$cid]['out_of_area_count'] = (int) ($r->out_of_area_count ?? 0);
|
||||
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
if ($province) $exportRows[] = $province;
|
||||
if ($province) {
|
||||
$exportRows[] = $province;
|
||||
}
|
||||
foreach ($grid as $row) {
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
|
||||
return view('v3.Reports.Mission.Report.ProvinceActivityReport', [
|
||||
'rows' => $exportRows,
|
||||
]);
|
||||
@@ -61,7 +63,7 @@ class ProvinceReport implements FromView, WithEvents, ShouldAutoSize, WithDrawin
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
@@ -91,6 +93,7 @@ class ProvinceReport implements FromView, WithEvents, ShouldAutoSize, WithDrawin
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('C1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user