fix seperate laporan ansuran pembiayaan
This commit is contained in:
@@ -492,7 +492,7 @@ class AkaunController extends Controller
|
||||
|
||||
return view('akaun.laporan_petibesi', compact('petibesi','cawangan_detail','tarikh_cetak','tebus_date','api_url','hutang'));
|
||||
}
|
||||
|
||||
|
||||
public function cetaklaporan_laporan_pendserahan(Request $request)
|
||||
{
|
||||
|
||||
@@ -1656,44 +1656,71 @@ class AkaunController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function cetakLaporanAnsuranRangeDate(Request $request){
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
if($request->datemula == null){
|
||||
$mula_date = $current->toDateString();
|
||||
}else{
|
||||
$split_date = explode('-',$request->datemula);
|
||||
$mula_date = $request->datemula;
|
||||
}
|
||||
|
||||
if($request->datehingga == null){
|
||||
$hingga_date = $current->toDateString();
|
||||
}else{
|
||||
$split_date2 = explode('-',$request->datehingga);
|
||||
$hingga_date = $request->datehingga;
|
||||
}
|
||||
$request->hostname = config('app.env') == 'production' ? 'http://apiujrah.arrahn' : $request->hostname;
|
||||
$tebus = Http::get($request->hostname. '/api/ansuranujrah/laporan/'. $request->kodcaw,['mula' => $mula_date,'akhir' => $hingga_date])->json();
|
||||
$cawangan=Http::get($request->hostname.'/api/cawangan/detail/'.$request->kodcaw)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
if(isset($request->jenis))
|
||||
{
|
||||
if($request->jenis == 'pdf')
|
||||
{
|
||||
$pdf = PDF::loadView('akaun.laporan_ansuran', compact('tebus','cawangan_detail','tarikh_cetak','mula_date','hingga_date','api_url'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('laporan_ansuran_' . $request->kodcaw .'_'. $mula_date .'-'. $hingga_date .'.pdf');
|
||||
|
||||
}else{
|
||||
return view('akaun.laporan_ansuran', compact('tebus','cawangan_detail','tarikh_cetak','api_url','mula_date','hingga_date'));
|
||||
}
|
||||
}
|
||||
public function cetakLaporanAnsuranRangeDate(Request $request){
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
// Tarikh mula
|
||||
if ($request->datemula == null) {
|
||||
$mula_date = $current->toDateString();
|
||||
} else {
|
||||
$mula_date = $request->datemula;
|
||||
}
|
||||
|
||||
// Tarikh hingga
|
||||
if ($request->datehingga == null) {
|
||||
$hingga_date = $current->toDateString();
|
||||
} else {
|
||||
$hingga_date = $request->datehingga;
|
||||
}
|
||||
|
||||
// Tetapkan hostname ikut environment
|
||||
$request->hostname = config('app.env') == 'production' ? 'http://apiujrah.arrahn' : $request->hostname;
|
||||
|
||||
$response = Http::get($request->hostname . '/api/ansuranujrah/laporan/' . $request->kodcaw, [
|
||||
'mula' => $mula_date,
|
||||
'akhir' => $hingga_date,
|
||||
'jenis' => $request->laporanansuran
|
||||
]);
|
||||
|
||||
if ($response->failed() || !$response->json()) {
|
||||
$tebus = []; // fallback elak error di view
|
||||
} else {
|
||||
$tebus = $response->json();
|
||||
}
|
||||
|
||||
$cawangan = Http::get($request->hostname . '/api/cawangan/detail/' . $request->kodcaw)->json();
|
||||
$cawangan_detail = $cawangan[0] ?? ['nama' => 'Tiada data'];
|
||||
|
||||
// Tajuk laporan ikut jenis
|
||||
$reportTitles = [
|
||||
'online' => 'Laporan Ansuran Pembiayaan (Arrahn Pay)',
|
||||
'kaunter' => 'Laporan Ansuran Pembiayaan (Kaunter aros)',
|
||||
'all' => 'Laporan Ansuran Pembiayaan Semua'
|
||||
];
|
||||
|
||||
$jenisLaporan = $request->laporanansuran;
|
||||
$fileTitle = $reportTitles[$jenisLaporan] ?? 'Laporan_Tidak_Diketahui';
|
||||
|
||||
// PDF atau view biasa
|
||||
if (isset($request->jenis)) {
|
||||
if ($request->jenis == 'pdf') {
|
||||
$pdf = PDF::loadView('akaun.laporan_ansuran', compact(
|
||||
'tebus', 'cawangan_detail', 'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url', 'jenisLaporan'
|
||||
))->setPaper('a4', 'potrait');
|
||||
|
||||
return $pdf->download('laporan_ansuran_' . $request->kodcaw . '_' . $mula_date . '-' . $hingga_date . '.pdf');
|
||||
} else {
|
||||
return view('akaun.laporan_ansuran', compact(
|
||||
'tebus', 'cawangan_detail', 'tarikh_cetak', 'api_url', 'jenisLaporan', 'mula_date', 'hingga_date'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function cetakLaporanPenebusanRangeDate(Request $request){
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
|
||||
Reference in New Issue
Block a user