update serahan baru

This commit is contained in:
BTMS2
2025-03-19 11:13:46 +08:00
parent c2b4ca6fb5
commit bae227dbf4
4 changed files with 307 additions and 178 deletions
+33 -41
View File
@@ -19,6 +19,7 @@ use App\Services\RingkasanHarianServices;
use App\Exports\Laporan\StokAuditBackdateExport;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\PendSerExport;
class AkaunController extends Controller
{
@@ -495,59 +496,50 @@ class AkaunController extends Controller
$api_url = $request->hostname;
$auth_user = Auth::user();
$current = Carbon::now();
$current = new Carbon();
$current = now();
$tarikh_cetak = $current->toDateString();
if($request->datemula == null){
$mula_date = '2017-01-01';
}else{
$split_date = explode('-', $request->datemula);
// $mula_date = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
$mula_date = $request->datemula;
}
$mula_date = $request->datemula ?? '2017-01-01';
$hingga_date = $request->datehingga ?? $current->toDateString();
if($request->datehingga == null){
$hingga_date = $current->toDateString();
}else{
$split_date = explode('-', $request->datehingga);
// $hingga_date = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
$hingga_date = $request->datehingga;
}
$pendser = Http::get($request->hostname . '/api/SenaraiPendSer/range/' . $request->kodcaw, [
'mula' => $mula_date,
'hingga' => $hingga_date,
'jenis' => $request->radpendser
])->json();
$pendser = Http::get($request->hostname. '/api/SenaraiPendSer/range/' . $request->kodcaw,['mula' => $mula_date,'hingga' => $hingga_date,'jenis' => $request->radpendser])->json();
$cawangan = Http::get($request->hostname . '/api/cawangan/detail/' . $request->kodcaw)->json();
$cawangan_detail = $cawangan[0];
$cawangan = Http::get($request->hostname.'/api/cawangan/detail/'.$request->kodcaw)->json();
$cawangan_detail=$cawangan[0];
// Define report title mappings
$reportTitles = [
'serahan' => 'Laporan_Serahan_HQ',
'pendahuluan' => 'Laporan_Pendahuluan_HQ',
'online' => 'Laporan_Serahan_Online_HQ',
'serahanlelong' => 'Laporan_Serahan_Lelong_HQ',
'serahanonline' => 'Laporan_Serahan_Dan_Serahan_Online_HQ',
'all' => 'Laporan_Keseluruhan_HQ'
];
if(isset($request->jenis))
{
$jenisLaporan = $request->radpendser; // Get report type
// Get the correct report title
$jenisLaporan = $request->radpendser;
$fileTitle = $reportTitles[$jenisLaporan] ?? 'Laporan_Tidak_Diketahui';
if($request->jenis == 'pdf')
{
if (isset($request->jenis)) {
if ($request->jenis == 'pdf') {
$pdf = PDF::loadView('akaun.laporan_pendahuluanserahan', compact(
'pendser',
'cawangan_detail',
'tarikh_cetak',
'mula_date',
'hingga_date',
'api_url',
'jenisLaporan' // Pass the report type
'pendser', 'cawangan_detail', 'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url', 'jenisLaporan'
))->setPaper('a4', 'portrait');
return $pdf->download('laporan_HQ_' . $request->kodcaw . '_' . $mula_date . '_' . $jenisLaporan . '.pdf');
return $pdf->download($fileTitle . '_' . $request->kodcaw . '_' . $mula_date . '.pdf');
}
else
{
else if ($request->jenis == 'excel') {
return Excel::download(new PendSerExport($pendser, $jenisLaporan), $fileTitle . '_' . $request->kodcaw . '_' . $mula_date . '.xlsx');
}
else {
return view('akaun.laporan_pendahuluanserahan', compact(
'pendser',
'cawangan_detail',
'tarikh_cetak',
'mula_date',
'hingga_date',
'api_url',
'jenisLaporan' // Pass the report type to the view
'pendser', 'cawangan_detail', 'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url', 'jenisLaporan'
));
}
}