add excel dalam stokaudit combine
This commit is contained in:
@@ -21,6 +21,7 @@ use App\Exports\Laporan\StokAuditBackdateExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\PendSerExport;
|
||||
use App\Exports\SAExport;
|
||||
use App\Exports\SAcombineExport;
|
||||
|
||||
class AkaunController extends Controller
|
||||
{
|
||||
@@ -1560,6 +1561,25 @@ class AkaunController extends Controller
|
||||
$pdf = PDF::loadView('akaun.laporan_stokaudit_combine', compact('stokaudit_aktif','stokaudit_takaktif','cawangan_detail','tarikh_cetak','tebus_date','api_url'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('laporan_stokaudit_' . $request->kodcaw .'_'. $tebus_date . '.pdf');
|
||||
}
|
||||
elseif ($request->jenis == 'excel') {
|
||||
$stokaudit_aktif = Http::get($api_url . '/api/stokaudit/aktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
$stokaudit_takaktif = Http::get($api_url . '/api/stokaudit/takaktifcombine/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
|
||||
// ✅ Extract 'rekod' arrays correctly
|
||||
$aktifData = $stokaudit_aktif['rekod'] ?? [];
|
||||
$takaktifData = $stokaudit_takaktif['rekod'] ?? [];
|
||||
|
||||
// ✅ Ensure at least one dataset is not empty
|
||||
if (empty($aktifData) && empty($takaktifData)) {
|
||||
return back()->with('error', 'No records found to export.');
|
||||
}
|
||||
|
||||
return Excel::download(
|
||||
new SAcombineExport($aktifData, $takaktifData, $tebus_date,$cawangan_detail['namacaw']),
|
||||
'laporan_stokauditcombine_' . $request->kodcaw . '_' . $tebus_date . '.xlsx'
|
||||
);
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$stokaudit_aktif = Http::get($api_url. '/api/stokaudit/aktif/'. $request->kodcaw,['tarikh' => $tebus_date])->json();
|
||||
|
||||
Reference in New Issue
Block a user