42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
use Maatwebsite\Excel\Concerns\FromView;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class WTDDetailExport implements FromView
|
|
{
|
|
protected $kodcaw;
|
|
protected $startDate;
|
|
protected $endDate;
|
|
|
|
public function __construct($kodcaw, $startDate, $endDate)
|
|
{
|
|
$this->kodcaw = $kodcaw;
|
|
$this->startDate = $startDate;
|
|
$this->endDate = $endDate;
|
|
}
|
|
|
|
public function view(): View
|
|
{
|
|
$data = Http::get(config('api.url') . '/admin/wtd/summaryWtd', [
|
|
'startDate' => $this->startDate,
|
|
'endDate' => $this->endDate,
|
|
])->json();
|
|
|
|
$branch = collect($data)->firstWhere('kodcaw', $this->kodcaw);
|
|
$details = collect($branch['details'] ?? []);
|
|
|
|
return view('reports.wtd.excel', [
|
|
'details' => $details, // data WTD
|
|
'branch' => $branch,
|
|
'generatedAt' => now()->format('d/m/Y H:i'),
|
|
'startDate' => $this->startDate,
|
|
'endDate' => $this->endDate,
|
|
]);
|
|
}
|
|
|
|
}
|