Gunawan19621
1 year ago
23 changed files with 369 additions and 181 deletions
@ -0,0 +1,77 @@
|
||||
<?php |
||||
|
||||
namespace App\Exports; |
||||
|
||||
use App\Models\Peti; |
||||
use Illuminate\Support\Carbon; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
|
||||
class StokOpNameExport implements FromCollection, WithHeadings |
||||
{ |
||||
protected $stokOpnames; |
||||
protected $todayStokOpnames; |
||||
protected $yesterdayStokOpnames; |
||||
|
||||
public function __construct($stokOpnames, $todayStokOpnames, $yesterdayStokOpnames) |
||||
{ |
||||
$this->stokOpnames = $stokOpnames; |
||||
$this->todayStokOpnames = $todayStokOpnames; |
||||
$this->yesterdayStokOpnames = $yesterdayStokOpnames; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
$data = collect(); |
||||
$nomor = 1; |
||||
|
||||
foreach ($this->stokOpnames as $data_StokOpname) { |
||||
$yesterdayStokOpname = $this->yesterdayStokOpnames |
||||
->where('customer_id', $data_StokOpname->customer_id) |
||||
->where('tipe_peti_id', $data_StokOpname->tipe_peti_id) |
||||
->first(); |
||||
|
||||
$todayStokOpname = $this->todayStokOpnames |
||||
->where('customer_id', $data_StokOpname->customer_id) |
||||
->where('tipe_peti_id', $data_StokOpname->tipe_peti_id) |
||||
->first(); |
||||
|
||||
$data->push([ |
||||
'No' => $nomor++, |
||||
'Customer' => $data_StokOpname->customer->name, |
||||
'Kode' => $data_StokOpname->customer->code_customer . ' 0 ' . $data_StokOpname->tipe_peti->type, |
||||
'Ukuran Peti' => $data_StokOpname->tipe_peti->size_peti, |
||||
'Bagging Stok' => $yesterdayStokOpname ? $yesterdayStokOpname->total_petis : '-', |
||||
'Add' => $todayStokOpname ? $todayStokOpname->total_petis : '0', |
||||
'Total' => $data_StokOpname->total_petis ?? '0', |
||||
'DI ISTW' => 'Belum', |
||||
'Gudang A' => 'Belum', |
||||
'Gudang B' => 'Belum', |
||||
'Gudang C' => 'Belum', |
||||
'Stok Opname' => 'Belum', |
||||
'Total Stok' => $data_StokOpname->total_petis ?? '0', |
||||
]); |
||||
} |
||||
|
||||
return $data; |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
return [ |
||||
'No', |
||||
'Customer', |
||||
'Kode', |
||||
'Ukuran Peti', |
||||
'Bagging Stok', |
||||
'Add', |
||||
'Total', |
||||
'DI ISTW', |
||||
'Gudang A', |
||||
'Gudang B', |
||||
'Gudang C', |
||||
'Stok Opname', |
||||
'Total Stok', |
||||
]; |
||||
} |
||||
} |
Loading…
Reference in new issue