Siopas Inventory PETI for ISTW Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
2.4 KiB

<?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',
];
}
}