update stokaudit excel
This commit is contained in:
@@ -20,6 +20,7 @@ use App\Services\RingkasanHarianServices;
|
||||
use App\Exports\Laporan\StokAuditBackdateExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\PendSerExport;
|
||||
use App\Exports\SAExport;
|
||||
|
||||
class AkaunController extends Controller
|
||||
{
|
||||
@@ -714,54 +715,56 @@ class AkaunController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function cetaklaporan_stokaudit(Request $request){
|
||||
|
||||
public function cetaklaporan_stokaudit(Request $request)
|
||||
{
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
if($request->datetimepicker1 == null){
|
||||
$tebus_date = $current->toDateString();
|
||||
}else{
|
||||
$tebus_date = $request->datetimepicker1;
|
||||
}
|
||||
|
||||
$cawangan=Http::get($api_url.'/api/cawangan/detail/'.$request->kodcaw)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
if(isset($request->jenis))
|
||||
{
|
||||
if($request->jenis == 'pdf')
|
||||
{
|
||||
|
||||
if($request->radaktif === 'aktif')
|
||||
{
|
||||
$stokaudit = Http::get($api_url. '/api/stokaudit/aktif/'. $request->kodcaw,['tarikh' => $tebus_date])->json();
|
||||
$pdf = PDF::loadView('akaun.laporan_stokaudit', compact('stokaudit','cawangan_detail','tarikh_cetak','tebus_date','api_url'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('laporan_stokaudit_' . $request->kodcaw .'_'. $tebus_date . '.pdf');
|
||||
|
||||
}else{
|
||||
$stokaudit = Http::get($api_url. '/api/stokaudit/takaktif/'. $request->kodcaw,['tarikh' => $tebus_date])->json();
|
||||
$pdf = PDF::loadView('akaun.laporan_stokauditbelumaktif',compact('stokaudit','cawangan_detail','tarikh_cetak','tebus_date','api_url'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('laporan_stokauditbelumaktif_' . $request->kodcaw .'_'. $tebus_date . '.pdf');
|
||||
$tebus_date = $request->datetimepicker1 ?? $tarikh_cetak;
|
||||
|
||||
$cawangan = Http::get($api_url . '/api/cawangan/detail/' . $request->kodcaw)->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
|
||||
if (isset($request->jenis)) {
|
||||
if ($request->jenis == 'pdf') {
|
||||
if ($request->radaktif === 'aktif') {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/aktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
$pdf = PDF::loadView('akaun.laporan_stokaudit', compact('stokaudit', 'cawangan_detail', 'tarikh_cetak', 'tebus_date', 'api_url'))->setPaper('a4', 'portrait');
|
||||
return $pdf->download('laporan_stokaudit_' . $request->kodcaw . '_' . $tebus_date . '.pdf');
|
||||
} else {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/takaktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
$pdf = PDF::loadView('akaun.laporan_stokauditbelumaktif', compact('stokaudit', 'cawangan_detail', 'tarikh_cetak', 'tebus_date', 'api_url'))->setPaper('a4', 'portrait');
|
||||
return $pdf->download('laporan_stokauditbelumaktif_' . $request->kodcaw . '_' . $tebus_date . '.pdf');
|
||||
}
|
||||
}
|
||||
elseif ($request->jenis == 'excel') {
|
||||
if ($request->radaktif === 'aktif') {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/aktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
} else {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/takaktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
}
|
||||
|
||||
$stokauditRecords = $stokaudit['rekod'] ?? [];
|
||||
|
||||
if (empty($stokauditRecords)) {
|
||||
return back()->with('error', 'No records found to export.');
|
||||
}
|
||||
return Excel::download(new SAExport($stokauditRecords, 'Laporan Stok Audit'), 'laporan_stokaudit_' . $request->kodcaw . '_' . $tebus_date . '.xlsx');
|
||||
}
|
||||
else {
|
||||
if ($request->radaktif === 'aktif') {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/aktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
return view('akaun.laporan_stokaudit', compact('stokaudit', 'cawangan_detail', 'tarikh_cetak', 'tebus_date', 'api_url'));
|
||||
} else {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/takaktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
return view('akaun.laporan_stokauditbelumaktif', compact('stokaudit', 'cawangan_detail', 'tarikh_cetak', 'tebus_date', 'api_url'));
|
||||
}
|
||||
}
|
||||
else{
|
||||
if($request->radaktif === 'aktif')
|
||||
{
|
||||
$stokaudit = Http::get($api_url. '/api/stokaudit/aktif/'. $request->kodcaw,['tarikh' => $tebus_date])->json();
|
||||
return view('akaun.laporan_stokaudit', compact('stokaudit','cawangan_detail','tarikh_cetak','tebus_date','api_url'));
|
||||
|
||||
}else{
|
||||
|
||||
$stokaudit = Http::get($api_url. '/api/stokaudit/takaktif/'. $request->kodcaw,['tarikh' => $tebus_date])->json();
|
||||
return view('akaun.laporan_stokauditbelumaktif', compact('stokaudit','cawangan_detail','tarikh_cetak','tebus_date','api_url'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function cetaklaporan_kawalanstok(Request $request){
|
||||
$api_url = $request->hostname;
|
||||
|
||||
Reference in New Issue
Block a user