Files
admin-erahn/app/Exports/SAcombineExport.php
T
2025-03-24 10:45:30 +08:00

64 lines
1.9 KiB
PHP

<?php
namespace App\Exports;
use App\Exports\SAExport;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
class SAcombineExport implements WithMultipleSheets
{
protected $aktifData;
protected $takaktifData;
protected $tebus_date;
protected $namacaw;
public function __construct($aktifData, $takaktifData,$tebus_date,$namacaw)
{
$this->aktifData = $aktifData;
$this->takaktifData = $takaktifData;
$this->tebus_date = $tebus_date;
$this->namacaw = $namacaw;
}
public function sheets(): array
{
return [
new SAExport($this->aktifData, 'Stok Audit Aktif', $this->tebus_date,$this->namacaw),
new SAExport($this->takaktifData, 'Stok Audit Tidak Aktif', $this->tebus_date,$this->namacaw),
];
}
public function map($row): array
{
static $counter = 1;
// ✅ Ensure $row is an array before accessing keys
if (!is_array($row)) {
dd($row);
return []; // Skip invalid rows
}
return [
$counter++,
$row['norujukan'] ?? '', // ✅ Prevent Undefined Index
$row['tempoh'] ?? '',
$row['nokp'] ?? '',
is_numeric($row['berat']) ? (float) $row['berat'] : 0,
is_numeric($row['nilaimarhun']) ? (float) $row['nilaimarhun'] : 0,
$row['marhun'] ?? '',
is_numeric($row['pinjaman']) ? (float) $row['pinjaman'] : 0,
is_numeric($row['bakipjm']) ? (float) $row['bakipjm'] : 0,
$row['kadarupah'] ?? '',
(is_numeric($row['tempoh']) && is_numeric($row['tempohbayar'])) ?
($row['tempoh'] - $row['tempohbayar']) : 0,
is_numeric($row['tunggakan']) ? (float) $row['tunggakan'] : 0,
is_numeric($row['tunggakanujrah']) ? (float) $row['tunggakanujrah'] : 0,
is_numeric($row['tunggakanonepercent']) ? (float) $row['tunggakanonepercent'] : 0,
$row['lelong_tawarruq'] ?? '',
];
}
}