Merge remote main
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AccountStatementController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the bank statement view with mock data.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showStatement(Request $request)
|
||||
{
|
||||
$gadaian = Http::get(config('api.url').'/api/gadai/norujukan/'.$request->norujukan)->json()[0][0];
|
||||
$transaction = Http::get(config('api.url').'/portal/transaksipelanggan',['norujukan' => $request->norujukan])->json();
|
||||
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'. $gadaian['kodcaw'])->json()[0];
|
||||
$customer = Http::get(config('api.url') . '/api/customers/' . $gadaian['nokp'])->json();
|
||||
$poskod = Http::get(config('api.url') . '/api/poskod/' . $customer['poskod'])->json();
|
||||
|
||||
$accountHolder = [
|
||||
'name' => $customer['nama'],
|
||||
'address' => $customer['alamat1'] . '<br>' . $customer['alamat2'],
|
||||
'city_state_zip' => $customer['poskod'] . ', ' . $poskod['daerah']['namadaerah'] . ', ' . $poskod['negeri']['negeri'],
|
||||
];
|
||||
|
||||
$bankDetails = [
|
||||
'name' => $cawangan['cawangan'],
|
||||
'address' => $cawangan['alamat1'] . '<br>' . $cawangan['alamat2'],
|
||||
'branch' => $cawangan['namacaw'],
|
||||
];
|
||||
|
||||
|
||||
$transaction_count = count(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'A'));
|
||||
$totalPages = ceil($transaction_count / 10);
|
||||
|
||||
$ansuranTransaction = array_values(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'A'));
|
||||
$originLoan = $gadaian['pinjaman'];
|
||||
$bakipinjaman = $originLoan;
|
||||
$ansuranTransaction = array_map(function($trans) use(&$bakipinjaman) {
|
||||
$bakipinjaman -= $trans['bayaran_pembiayaan'];
|
||||
return array_merge($trans, ['bakipinjaman' => $bakipinjaman]);
|
||||
}, $ansuranTransaction);
|
||||
|
||||
$tebusTransaction = array_values(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'T'))[0];
|
||||
|
||||
return view('accounts-statements', compact('tebusTransaction','ansuranTransaction','transaction_count','gadaian','transaction','accountHolder', 'bankDetails'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to format currency.
|
||||
* In a real app, this would be a Blade helper or filter.
|
||||
* We'll format it directly in the view for simplicity in this example.
|
||||
*/
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Barryvdh\DomPDF\Facade as PDF;
|
||||
@@ -22,6 +23,7 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\PendSerExport;
|
||||
use App\Exports\SAExport;
|
||||
use App\Exports\SAcombineExport;
|
||||
use App\Exports\SAExportAudit;
|
||||
|
||||
class AkaunController extends Controller
|
||||
{
|
||||
@@ -314,7 +316,7 @@ class AkaunController extends Controller
|
||||
|
||||
// return view('akaun.laporan_imbanduga',compact('tarikh_imbangan', 'tarikh_imbangan2','hartasemasa','untungrugifield','tanggungansemasa','totalhartasemasa','totaluntungrugi','totaltanggungansemasa','tarikh_cetak','cawangan_info','cawangan','api_url','cawangan_detail'));
|
||||
}
|
||||
|
||||
////ainizazi
|
||||
public function cetakLaporanGadai(Request $request){
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
@@ -337,10 +339,20 @@ class AkaunController extends Controller
|
||||
}
|
||||
// $gadai = Http::get($request->hostname. '/api/gadai/laporan/'. $request->kodcaw .'/'. $gadai_date)->json();
|
||||
|
||||
$gadai = Http::get($request->hostname. '/api/gadailaporanRangeDate/'. $request->kodcaw,['mula' => $tarikh_mula,'akhir' => $tarikh_akhir])->json();
|
||||
$reportGadai = Http::get($request->hostname. '/api/gadailaporanRangeDate/'. $request->kodcaw,['mula' => $tarikh_mula,'akhir' => $tarikh_akhir])->json();
|
||||
$gadai = $reportGadai['gadai'];
|
||||
// dd($reportsGadai);
|
||||
$statistik =$reportGadai['statistik'];
|
||||
$reportPembiayaan= $statistik['reportPembiayaan'];
|
||||
$reportLoanAmount=$statistik['reportLoanAmount'];
|
||||
$reportMarhunValue=$statistik['reportMarhunValue'];
|
||||
$reportMarhunMargin=$statistik['reportMarhunMargin'];
|
||||
$reportCustomerJob=$statistik['reportCustomerJob'];
|
||||
$reportCustomerRace=$statistik['reportCustomerRace'];
|
||||
|
||||
|
||||
$cawangan=Http::get($request->hostname.'/api/cawangan/detail/'.$request->kodcaw)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
if(isset($request->jenis))
|
||||
{
|
||||
@@ -349,10 +361,9 @@ class AkaunController extends Controller
|
||||
$pdf = PDF::loadView('akaun.laporan_gadaian', compact('gadai','cawangan_detail','tarikh_cetak','tarikh_mula','tarikh_akhir','api_url'))->setPaper('a4', 'landscape');
|
||||
return $pdf->download('laporan_gadaian_' . $request->kodcaw .'_'. $tarikh_mula .'-'. $tarikh_akhir .'.pdf');
|
||||
}else{
|
||||
return view('akaun.laporan_gadaian', compact('gadai','cawangan_detail','tarikh_cetak','tarikh_mula','tarikh_akhir','api_url'));
|
||||
return view('akaun.laporan_gadaian', compact('gadai','cawangan_detail','tarikh_cetak','tarikh_mula','tarikh_akhir','api_url','reportGadai','gadai','statistik','reportPembiayaan','reportLoanAmount','reportMarhunValue','reportMarhunMargin','reportCustomerJob','reportCustomerRace'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function cetakLaporanPenebusan(Request $request){
|
||||
@@ -416,8 +427,6 @@ class AkaunController extends Controller
|
||||
return view('akaun.laporan_ansuran', compact('tebus','cawangan_detail','tarikh_cetak','tebus_date','api_url'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -492,7 +501,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)
|
||||
{
|
||||
|
||||
@@ -572,9 +581,9 @@ class AkaunController extends Controller
|
||||
|
||||
$request->hostname = config('app.env') == 'production' ? 'http://apiujrah.arrahn' : $request->hostname;
|
||||
|
||||
$tuntutbaki = Http::get($request->hostname. '/api/TuntutBakiRangeDate/'. $request->kodcaw,['mula' => $tarikh_mula,'akhir' => $tarikh_akhir])->json();
|
||||
$tuntutbaki = Http::get($api_url. '/api/TuntutBakiRangeDate/'. $request->kodcaw,['mula' => $tarikh_mula,'akhir' => $tarikh_akhir])->json();
|
||||
|
||||
$cawangan=Http::get($request->hostname.'/api/cawangan/detail/'.$request->kodcaw)->json();
|
||||
$cawangan=Http::get($api_url.'/api/cawangan/detail/'.$request->kodcaw)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
if(isset($request->jenis))
|
||||
@@ -760,6 +769,49 @@ class AkaunController extends Controller
|
||||
$cawangan_detail['namacaw']// ✅ Use the correct branch name from API
|
||||
), 'laporan_stokaudit_' . $request->kodcaw . '_' . $tebus_date . '.xlsx');
|
||||
}
|
||||
elseif ($request->jenis == 'excelaudit') {
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
// pilih column untuk audit sahaja
|
||||
$auditRecords = collect($stokauditRecords)->values()->map(function ($item, $index) {
|
||||
return [
|
||||
'Bil' => $index + 1,
|
||||
'No Rujukan' => $item['norujukan'] ?? '',
|
||||
'No KP' => $item['nokp'] ?? '',
|
||||
'Marhun' => $item['marhun'] ?? '',
|
||||
'Berat (g)' => $item['berat'] ?? '',
|
||||
'Nilai Marhun' => $item['nilaimarhun'] ?? '',
|
||||
'Pinjaman' => $item['pinjaman'] ?? '',
|
||||
'Baki Pinjaman' => $item['bakipjm'] ?? '',
|
||||
'Tempoh' => $item['tempoh'] ?? '',
|
||||
];
|
||||
});
|
||||
|
||||
return Excel::download(
|
||||
new SAExportAudit(
|
||||
$auditRecords,
|
||||
'Laporan Stok Audit',
|
||||
$tebus_date,
|
||||
$cawangan_detail['namacaw']
|
||||
),
|
||||
'laporan_stokaudit_audit_' . $request->kodcaw . '_' . $tebus_date . '.xlsx'
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ($request->radaktif === 'aktif') {
|
||||
$stokaudit = Http::get($api_url . '/api/stokaudit/aktif/' . $request->kodcaw, ['tarikh' => $tebus_date])->json();
|
||||
@@ -831,7 +883,6 @@ class AkaunController extends Controller
|
||||
// ])->json();
|
||||
|
||||
// $laporan_ringkasan = $laporan_ringkasan[0];
|
||||
|
||||
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'.$request->kodcaw)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
@@ -860,9 +911,8 @@ class AkaunController extends Controller
|
||||
|
||||
$petibesi = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/laporanpetibesi/'. $request->kodcaw .'/'. $tebus_date)->json();
|
||||
|
||||
if(!$petibesi)
|
||||
{
|
||||
return redirect()->back()->with('errormessage', 'Tiada data pada tarikh tersebut.');
|
||||
if (($petibesi['error'] ?? null) === 'Tiada data pada tarikh tersebut') {
|
||||
return redirect()->back()->with('peti_besi_error_message', 'Tiada data pada tarikh tersebut.');
|
||||
}
|
||||
|
||||
if(isset($request->jenis))
|
||||
@@ -1656,44 +1706,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($api_url . '/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($api_url . '/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();
|
||||
@@ -1890,6 +1967,55 @@ class AkaunController extends Controller
|
||||
));
|
||||
}
|
||||
|
||||
public function cetak_laporanbarangkes(Request $request)
|
||||
|
||||
{
|
||||
$api_url = $request->hostname;
|
||||
// $api_url = ($request->hostname) ? $request->hostname : config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
if($request->datemula == null){
|
||||
$mula_date = '2017-01-01';
|
||||
}else{
|
||||
$mula_date = $request->datemula;
|
||||
}
|
||||
|
||||
if($request->datehingga == null){
|
||||
$hingga_date = $current->toDateString();
|
||||
}else{
|
||||
$hingga_date = $request->datehingga;
|
||||
}
|
||||
|
||||
$status = $request->status ?? 'all';
|
||||
// $barangkes = Http::get($request->hostname . '/api/barangkes/laporan/', ['kodcaw' => $request->kodcaw,'alasan' => $request->sltalasan,'tarikh_mula' => $mula_date,'tarikh_akhir' => $hingga_date, 'status' => $status,])->json();
|
||||
$palsu = Http::get($request->hostname . '/api/palsu/laporan/', ['kodcaw' => $request->kodcaw,'tarikh_mula' => $mula_date,'tarikh_akhir' => $hingga_date, 'status' => $status,])->json();
|
||||
|
||||
if (!is_array($palsu)) {
|
||||
$palsu = []; // utk nak tengok data tubik ke dok
|
||||
}
|
||||
|
||||
$cawangan_info = Http::get($request->hostname . '/api/cawangan/'. $request->kodcaw)->json();
|
||||
$cawangan = Http::get($request->hostname . '/api/cawangan/detail/'. $request->kodcaw)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
$hostname = $request->hostname;
|
||||
|
||||
if(isset($request->jenis))
|
||||
{
|
||||
if($request->jenis == 'pdf')
|
||||
{
|
||||
$pdf = PDF::loadView('akaun.laporan_brgkes', compact('hostname','palsu','cawangan_detail','tarikh_cetak','mula_date','hingga_date','api_url','status'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('laporan_brgkes' . $request->kodcaw .'_'. $mula_date .'_'. $hingga_date . '.pdf');
|
||||
}else{
|
||||
return view('akaun.laporan_brgkes', compact('hostname','palsu','cawangan_detail','tarikh_cetak','mula_date','hingga_date','api_url','status'));
|
||||
}
|
||||
}
|
||||
|
||||
return view('akaun.laporan_brgkes', compact('hostname','cawangan_detail','mula_date','hingga_date','tarikh_cetak','api_url','palsu','status'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class BarangkesController extends Controller
|
||||
{
|
||||
// lebih kurg mcm index
|
||||
public function AdminBarangKes(Request $request)
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
// dd($api_url);
|
||||
return view('barangkes.barangkes',compact('api_url','auth_user'));
|
||||
// return view('barangkes.index', compact('data'));
|
||||
}
|
||||
|
||||
public function Detailssag(Request $request, $id)
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
|
||||
// ambil customer info
|
||||
$customer_info = Http::get($api_url . '/admin/Customers/' . $id)->json();
|
||||
// dd($customer_info);
|
||||
// ambil gadai info (by kodcaw + norujukan dari route)
|
||||
// $gadai = null;
|
||||
if (!empty($customer_info['kodcaw']) && !empty($norujukan)) {
|
||||
$gadai = Http::get($api_url . '/api/gadai/norujukan/'
|
||||
. $customer_info['kodcaw'] . '/' . $norujukan)->json();
|
||||
}
|
||||
|
||||
$gadai = Http::get($api_url . '/api/gadai/norujukan/' . $request->kodcaw . '/' . $request->norujukan)->json();
|
||||
$gadai = $gadai[0];
|
||||
|
||||
return view('pelanggan.detailssag', compact('api_url', 'auth_user', 'customer_info', 'gadai'));
|
||||
}
|
||||
|
||||
public function store(Request $request, $id){
|
||||
|
||||
$api_url = config('api.url');
|
||||
$customer_info = Http::get($api_url . '/admin/Customers/' . $id)->json();
|
||||
// $auth_user = Auth::user();
|
||||
// dd($customer_info);
|
||||
|
||||
return view('pelanggan.detailssag', ['customer' => $customer_info,'kodcaw' => $request->query('kodcaw'),'norujukan' => $request->query('norujukan'),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Exports\LaporanKeseluruhan\AgingAllExportExcel;
|
||||
use App\Exports\LaporanKeseluruhan\AgingTebusAllExportExcel;
|
||||
|
||||
class AgingController extends Controller
|
||||
{
|
||||
@@ -81,4 +81,77 @@ class AgingController extends Controller
|
||||
}
|
||||
return view('reports.aging.index', compact('aging', 'endDate'));
|
||||
}
|
||||
|
||||
public function agingtebus(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
$request->hostname = config('api.url');
|
||||
// dd($request->hostname );
|
||||
$kod_cawangan = $request->kod_cawangan;
|
||||
$action = $request->input('action', 'search');
|
||||
// dd($action);
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
$aging = Http::get($request->hostname . '/api/reports/agingtebus', [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
])->json();
|
||||
|
||||
$aging = $aging ?? [];
|
||||
|
||||
if ($action === 'excel') {
|
||||
$file_title = sprintf("LaporanAging(%s).xlsx", $kod_cawangan, $startDate, $endDate);
|
||||
return Excel::download(new AgingTebusAllExportExcel($aging,$startDate,$endDate), $file_title);
|
||||
}
|
||||
|
||||
return view('reports.agingtebus.index', compact('aging', 'startDate', 'endDate'));
|
||||
}
|
||||
public function showagingtebus(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$action = $request->input('action', 'search');
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
return $date_string ? $date_string : $current->toDateString();
|
||||
};
|
||||
|
||||
$hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
$response = Http::get("$hostname/api/reports/agingtebus", [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
]);
|
||||
|
||||
$aging = $response->json() ?? []; // Ensure it's an array
|
||||
|
||||
// Debugging: Check the response before using it
|
||||
if (empty($aging)) {
|
||||
return back()->with('error', 'Failed to fetch data from API.');
|
||||
}
|
||||
|
||||
if ($action === 'excel') {
|
||||
// Ensure $kod_cawangan is defined (Modify as per your data structure)
|
||||
$kod_cawangan = $request->input('kod_cawangan', 'DEFAULT');
|
||||
|
||||
$file_title = sprintf("LaporanAgingTebus(%s).xlsx", $kod_cawangan, $startDate, $endDate);
|
||||
return Excel::download(new AgingTebusAllExportExcel($aging, $startDate, $endDate), $file_title);
|
||||
}
|
||||
return view('reports.agingtebus.index', compact('aging', 'startDate', 'endDate'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Exports\LaporanKeseluruhan\PelangganbaruAllExportExcel;
|
||||
use App\Exports\LaporanKeseluruhan\PelangganaktifAllExportExcel;
|
||||
use App\Exports\DataPelangganDetailExport;
|
||||
use App\Exports\DataPelangganBycawDetailExport;
|
||||
|
||||
class AnalisaController extends Controller
|
||||
{
|
||||
@@ -90,5 +92,114 @@ class AnalisaController extends Controller
|
||||
return view('reports.pelangganaktif.index', compact('pelangganaktif', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function dataPelanggan(Request $request)
|
||||
{
|
||||
$request->hostname = config('api.url');
|
||||
$current = new Carbon();
|
||||
|
||||
$month = $request->filled('month') ? $request->month : $current->month;
|
||||
$year = $request->filled('year') ? $request->year : $current->year;
|
||||
|
||||
return view('reports.data-pelanggan.index', compact('month', 'year'));
|
||||
}
|
||||
|
||||
public function dataPelangganShow(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'year' => 'required|digits:4'
|
||||
]);
|
||||
|
||||
$year = $validated['year'];
|
||||
$tarikh_cetak = now()->format('d/m/Y');
|
||||
$tebus_date = 'Tahun ' . $year;
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$response = Http::get($request->hostname . '/api/reports/data-pelanggan', [
|
||||
'year' => $year,
|
||||
])->json();
|
||||
|
||||
$summary = $response['summary'];
|
||||
$pelanggan = $response['pelanggan'];
|
||||
|
||||
if ($request->generateType === 'pdf') {
|
||||
return view(
|
||||
'reports.data-pelanggan.show',
|
||||
compact('summary','pelanggan','tarikh_cetak','tebus_date','year')
|
||||
);
|
||||
}
|
||||
elseif ($request->generateType === 'excel') {
|
||||
return Excel::download(
|
||||
new DataPelangganDetailExport($pelanggan, $year),
|
||||
"Laporan-Data-Pelanggan-{$year}.xlsx"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dataPelangganBycaw(Request $request)
|
||||
{
|
||||
$request->hostname = config('api.url');
|
||||
$current = new Carbon();
|
||||
|
||||
$month = $request->filled('month') ? $request->month : $current->month;
|
||||
$year = $request->filled('year') ? $request->year : $current->year;
|
||||
|
||||
return view('reports.data-pelanggan-bycaw.index', compact('month', 'year'));
|
||||
}
|
||||
|
||||
public function dataPelangganBycawShow(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'year' => 'required|digits:4',
|
||||
'cawangan' => 'required|array|min:1'
|
||||
]);
|
||||
|
||||
$year = $validated['year'];
|
||||
$cawangan = $validated['cawangan']; // array kod cawangan
|
||||
|
||||
$tarikh_cetak = now()->format('d/m/Y');
|
||||
$tebus_date = 'Tahun ' . $year;
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
// 🔑 Forward ke API
|
||||
$response = Http::get(
|
||||
$request->hostname . '/api/reports/data-pelanggan-bycaw',
|
||||
[
|
||||
'year' => $year,
|
||||
'cawangan' => $cawangan, // array terus
|
||||
]
|
||||
)->json();
|
||||
|
||||
if (!isset($response['summary'], $response['pelanggan'])) {
|
||||
abort(500, 'Data API tidak sah');
|
||||
}
|
||||
|
||||
$summary = $response['summary'];
|
||||
$pelanggan = $response['pelanggan'];
|
||||
|
||||
if ($request->generateType === 'pdf') {
|
||||
return view(
|
||||
'reports.data-pelanggan-bycaw.show',
|
||||
compact('summary','pelanggan','tarikh_cetak','tebus_date','year','cawangan')
|
||||
);
|
||||
}
|
||||
|
||||
if ($request->generateType === 'excel') {
|
||||
return Excel::download(
|
||||
new DataPelangganBycawDetailExport($pelanggan, $year, $cawangan),
|
||||
"Laporan-Data-Pelanggan-Bycaw-{$year}.xlsx"
|
||||
);
|
||||
}
|
||||
|
||||
abort(400, 'Jenis laporan tidak sah');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,38 +25,53 @@ class StokAuditController extends Controller
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
$tarikh_cetak = Carbon::now()->toDateString(); // tarikh cetak
|
||||
|
||||
if ($request->dateOption === 'current') {
|
||||
$date = Carbon::now();
|
||||
$tebus_date = $date->format('d-m-Y'); // tarikh semasa
|
||||
$monthName = $date->translatedFormat('F'); // bulan semasa
|
||||
} else {
|
||||
$validated = $request->validate(
|
||||
['monthYear' => 'required'],
|
||||
['monthYear.required' => 'Sila isi tarikh sebelum hantar',
|
||||
]);
|
||||
|
||||
$current = Carbon::now();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
$tokens = explode('-', $validated['monthYear']);
|
||||
$month = ltrim($tokens[0], '0');
|
||||
$year = $tokens[1];
|
||||
|
||||
// Set the locale to Malaysian
|
||||
App::setLocale('ms');
|
||||
|
||||
// Create a Carbon instance representing the date
|
||||
$date = Carbon::createFromDate($year, $month, 1); // Set the day to 1st of the month
|
||||
|
||||
// Get the name of the month in Malaysian local
|
||||
$date = Carbon::createFromDate($year, $month, 1); // set day = 1
|
||||
$monthName = $date->translatedFormat('F');
|
||||
$tebus_date = $monthName . ' ' . $year;
|
||||
}
|
||||
|
||||
$month = $date->month;
|
||||
$year = $date->year;
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$stokAudit = Http::get($request->hostname . '/api/reports/stok-audit', [
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'dateOption' => $request->dateOption
|
||||
])->json();
|
||||
|
||||
$tebus_date = $monthName . ' ' . $year;
|
||||
$file_title = sprintf("Laporan-StokAudit %s (%s - %s).xlsx", 'Semua cawangan', $monthName, $year);
|
||||
$file_title = sprintf(
|
||||
"Laporan-StokAudit %s (%s).xlsx",
|
||||
'Semua cawangan',
|
||||
$tebus_date
|
||||
);
|
||||
|
||||
if ($request->generateType === 'pdf') {
|
||||
return view('reports.stok-audit.show', compact('tebus_date', 'tarikh_cetak', 'stokAudit', 'month', 'year'));
|
||||
return view('reports.stok-audit.show', compact(
|
||||
'stokAudit',
|
||||
'month',
|
||||
'year',
|
||||
'monthName',
|
||||
'tarikh_cetak',
|
||||
'tebus_date'
|
||||
));
|
||||
} else {
|
||||
return Excel::download(new StokAuditExport($stokAudit), $file_title);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
@@ -17,7 +18,7 @@ class ResitController extends Controller
|
||||
|
||||
public function resit($id)
|
||||
{
|
||||
|
||||
$auth_user = Auth::user();
|
||||
$totaltransaction = 0;
|
||||
|
||||
$transaction = Http::get(config('api.url') . '/api/transaction/id/'. $id)->json();
|
||||
@@ -32,7 +33,16 @@ class ResitController extends Controller
|
||||
|
||||
$customers_info = Http::get(config('api.url') . '/api/customers/'. $gadai['nokp'])->json();
|
||||
|
||||
return view('resit.resitansuran',compact('transaction','gadai','customers_info'));
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $gadai['kodcaw'])->json();
|
||||
|
||||
$wakil = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/getwakil/' . $auth_user['cawangan'] . '/code/' . $transaction['nowakil'])->json();
|
||||
|
||||
if($gadai['tagbaru'] == 1){
|
||||
return view('resit.resitansuran_ujrah',compact('transaction','gadai','customers_info','cawangan_info','wakil'));
|
||||
|
||||
}else{
|
||||
return view('resit.resitansuran',compact('transaction','gadai','customers_info','cawangan_info','wakil'));
|
||||
}
|
||||
}
|
||||
|
||||
public function resittebusseparuh($id)
|
||||
@@ -114,7 +124,7 @@ class ResitController extends Controller
|
||||
|
||||
public function resittebus($id)
|
||||
{
|
||||
|
||||
$auth_user = Auth::user();
|
||||
$gadai = Http::get(config('api.url') . '/api/gadai/norujukan/'. $id)->json();
|
||||
|
||||
if(sizeof($gadai) != 0)
|
||||
@@ -126,6 +136,8 @@ class ResitController extends Controller
|
||||
|
||||
$transaction = Http::get(config('api.url') . '/api/transaction/'. $id)->json();
|
||||
|
||||
$transaction_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/one/'. $id)->json();
|
||||
|
||||
foreach($transaction as $trans)
|
||||
{
|
||||
$totaltransaction += $trans['duit_masuk'];
|
||||
@@ -142,10 +154,25 @@ class ResitController extends Controller
|
||||
|
||||
$totalBayaranAnsuran = Http::get(config('api.url') . '/api/transaction/norujukan/total/ansuran',['norujukan'=>$id])->json();
|
||||
|
||||
if(sizeof($wakil) != 0)
|
||||
$wakil = $wakil[0];
|
||||
// $totalrebate = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/reports/totalrebate',['norujukan'=>$id])->json();
|
||||
|
||||
$surat_wakil = [];
|
||||
if(sizeof($wakil) != 0) {
|
||||
$wakil = $wakil[0];
|
||||
$surat_wakil = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/getsuratwakil/' . $auth_user['cawangan'] . '/' . $id)->json();
|
||||
}
|
||||
|
||||
return view('resit.resittebus',compact('transaction','gadai','cawangan_info','customers_info','penebusan','wakil','totaltransaction','totalBayaranAnsuran'));
|
||||
$transaction_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/one/'. $id)->json();
|
||||
$totalrebate = ['ujrah' => ($transaction_tebus['ujrah'] - $transaction_tebus['ujrah_rebet']), 'onepercent' => ($transaction_tebus['onepercent'] - $transaction_tebus['onepercent_rebet'])];
|
||||
|
||||
$khazanah_user = User::where('role_harian', 'khazanah')->where('cawangan', $auth_user['cawangan'])->select('name')->first();
|
||||
|
||||
if($gadai['tagbaru'] == 1){
|
||||
return view('resit.resittebus_ujrah',compact('transaction','transaction_tebus','totalrebate','khazanah_user','gadai','cawangan_info','customers_info','penebusan','wakil','totaltransaction','totalBayaranAnsuran'));
|
||||
|
||||
}else{
|
||||
return view('resit.resittebus',compact('transaction','transaction_tebus','totalrebate','khazanah_user','gadai','cawangan_info','customers_info','penebusan','wakil','totaltransaction','totalBayaranAnsuran'));
|
||||
}
|
||||
}
|
||||
|
||||
public function resitbelumtebus($id)
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\GadaianDetailExport;
|
||||
|
||||
class SaringanGadaianController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
return $date_string ? $date_string : $current->toDateString();
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
|
||||
$gadaian = Http::get($request->hostname . '/api/reports/saringan/gadaian', [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
])->json();
|
||||
|
||||
return view('reports.saringan-gadaian.index', compact('gadaian', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function exportExcel(Request $request, $kodcaw)
|
||||
{
|
||||
return Excel::download(
|
||||
new GadaianDetailExport(
|
||||
$kodcaw,
|
||||
$request->startDate,
|
||||
$request->endDate
|
||||
),
|
||||
"Saringan_Gadaian_{$kodcaw}.xlsx"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\GadaianDetailExport;
|
||||
|
||||
class StatistikController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
return $date_string ? $date_string : $current->toDateString();
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
|
||||
$gadaian = Http::get($request->hostname . '/api/statistik', [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
])->json();
|
||||
dd($gadaian);
|
||||
|
||||
return view('akaun.laporan_gadaian', compact('gadaian', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
@@ -10,7 +9,8 @@ use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use PDF;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\WTDDetailExport;
|
||||
|
||||
class WTDController extends Controller
|
||||
{
|
||||
@@ -19,8 +19,8 @@ class WTDController extends Controller
|
||||
// $this->middleware('auth');
|
||||
// }
|
||||
|
||||
public function index(){
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('wtd.index');
|
||||
}
|
||||
|
||||
@@ -30,27 +30,25 @@ class WTDController extends Controller
|
||||
|
||||
$norujukan = json_decode($request->norujukan);
|
||||
|
||||
$tuntutbaki = Http::get(config('api.url').'/admin/wtd/senarai',['norujukan' => $norujukan,'kodcaw' => $request->cawangan])->json();
|
||||
$tuntutbaki = Http::get(config('api.url') . '/admin/wtd/senarai', ['norujukan' => $norujukan, 'kodcaw' => $request->cawangan])->json();
|
||||
|
||||
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'. $request->cawangan)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
$cawangan = Http::get(config('api.url') . '/api/cawangan/detail/' . $request->cawangan)->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
|
||||
$current = Carbon::now();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
$api_url = config('api.url');
|
||||
$mula = $request->mula;
|
||||
$mula = $request->mula;
|
||||
$hingga = $request->hingga;
|
||||
// $myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh_cetak);
|
||||
// $tarikhcetakan = $myDateTime->format('d-m-Y');
|
||||
|
||||
if(isset($request->jenis))
|
||||
{
|
||||
if($request->jenis == 'pdf')
|
||||
{
|
||||
$pdf = PDF::loadView('wtd.cetakan', compact('tuntutbaki','cawangan_detail','tarikh_cetak','api_url','mula','hingga'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('wtd_' . $request->cawangan .'_'. $tarikh_cetak . '.pdf');
|
||||
}else{
|
||||
return view('wtd.cetakanexcel', compact('tuntutbaki','cawangan_detail','tarikh_cetak','api_url','mula','hingga'));
|
||||
|
||||
if (isset($request->jenis)) {
|
||||
if ($request->jenis == 'pdf') {
|
||||
$pdf = PDF::loadView('wtd.cetakan', compact('tuntutbaki', 'cawangan_detail', 'tarikh_cetak', 'api_url', 'mula', 'hingga'))->setPaper('a4', 'potrait');
|
||||
return $pdf->download('wtd_' . $request->cawangan . '_' . $tarikh_cetak . '.pdf');
|
||||
} else {
|
||||
return view('wtd.cetakanexcel', compact('tuntutbaki', 'cawangan_detail', 'tarikh_cetak', 'api_url', 'mula', 'hingga'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,21 +59,196 @@ class WTDController extends Controller
|
||||
$current = Carbon::now();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'. $request->cawangan)->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
$cawangan = Http::get(config('api.url') . '/api/cawangan/detail/' . $request->cawangan)->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
|
||||
$wtdDalamProses = Http::get(config('api.url'). '/admin/wtd/dalamproses' ,['batchno' => $request->batchno,'kodcaw' => $request->cawangan])->json();
|
||||
if(isset($request->jenis))
|
||||
{
|
||||
if($request->jenis == 'pdf')
|
||||
{
|
||||
$pdf = PDF::loadView('wtd.dalamprosespdf', compact('tarikh_cetak','cawangan_detail','wtdDalamProses','api_url'))->setPaper('a4', 'landscape');
|
||||
return $pdf->download('wtd_' . $request->cawangan .'_'. $tarikh_cetak . '.pdf');
|
||||
}else{
|
||||
$wtdDalamProses = Http::get(config('api.url') . '/admin/wtd/dalamproses', ['batchno' => $request->batchno, 'kodcaw' => $request->cawangan])->json();
|
||||
if (isset($request->jenis)) {
|
||||
if ($request->jenis == 'pdf') {
|
||||
$pdf = PDF::loadView('wtd.dalamprosespdf', compact('tarikh_cetak', 'cawangan_detail', 'wtdDalamProses', 'api_url'))->setPaper('a4', 'landscape');
|
||||
return $pdf->download('wtd_' . $request->cawangan . '_' . $tarikh_cetak . '.pdf');
|
||||
} else {
|
||||
|
||||
|
||||
return view('wtd.dalamprosesexcel', compact('tarikh_cetak','cawangan_detail','wtdDalamProses','api_url'));
|
||||
return view('wtd.dalamprosesexcel', compact('tarikh_cetak', 'cawangan_detail', 'wtdDalamProses', 'api_url'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function janaSimulasi(Request $request)
|
||||
{
|
||||
$cawangan = Http::get(config('api.url') . '/api/cawangan/')->json();
|
||||
|
||||
return view('wtd.simulasi.janaSimulasi', compact('cawangan'));
|
||||
}
|
||||
|
||||
public function showSimulasi(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'kodcaw' => 'required',
|
||||
'tahun' => 'required',
|
||||
], [
|
||||
'kodcaw.required' => 'Sila Pilih Cawangan Terlebih Dahulu.',
|
||||
'tahun.required' => 'Sila Masukkan Tahun Terlebih Dahulu.',
|
||||
]);
|
||||
|
||||
$senaraiSimulasi = Http::get(config('api.url') . '/admin/wtd/janaSimulasi', ['kodcaw' => $request->kodcaw, 'tahun' => $request->tahun])->json();
|
||||
|
||||
$year = $request->tahun;
|
||||
|
||||
// dd($senaraiSimulasi, $request->kodcaw, $request->tahun);
|
||||
|
||||
return view('wtd.simulasi.show', compact('senaraiSimulasi', 'year'));
|
||||
}
|
||||
|
||||
public function showRekod(Request $request)
|
||||
{
|
||||
$bulan = $request->input('month');
|
||||
$bulanNumber = date('n', strtotime($bulan));
|
||||
|
||||
$rekod = Http::get(config('api.url') . '/admin/wtd/rekodSimulasi', ['kodcaw' => $request->kodcaw, 'month' => $bulanNumber, 'year' => $request->year])->json();
|
||||
|
||||
$totalBaki = collect($rekod)->sum('baki');
|
||||
|
||||
// dd($rekod, $bulanNumber, $totalBaki, $bulan);
|
||||
|
||||
return view('wtd.simulasi.rekod', compact('bulan', 'rekod', 'totalBaki'));
|
||||
}
|
||||
|
||||
public function prosesWTD(Request $request)
|
||||
{
|
||||
// dd($request->input());
|
||||
$request->validate([
|
||||
'data.*.bulan' => 'required|string',
|
||||
'data.*.jumlah_norujukan' => 'required|numeric',
|
||||
'data.*.pembiayaan' => 'required|numeric',
|
||||
'data.*.baki' => 'required|numeric',
|
||||
'data.*.selected' => 'nullable',
|
||||
]);
|
||||
|
||||
// Process the selected data
|
||||
$data = $request->input('data', []);
|
||||
$insertedRecords = [];
|
||||
$kodcaw = $request->data[0]['kodcaw'];
|
||||
|
||||
foreach ($data as $item) {
|
||||
if (isset($item['selected'])) {
|
||||
$insertedRecords[] = [
|
||||
'bulan' => $item['bulan'],
|
||||
'tahun' => $request->tahun,
|
||||
'kodcaw' => $kodcaw,
|
||||
'jumlah_sag' => $item['jumlah_norujukan'],
|
||||
'pembiayaan' => $item['pembiayaan'],
|
||||
'baki' => $item['baki'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
$response = Http::post(config('api.url') . '/admin/wtd/prosesSimulasi', [
|
||||
'input' => $insertedRecords
|
||||
])->json();
|
||||
|
||||
// dd($data, $insertedRecords, $kodcaw, $response);
|
||||
|
||||
return view('wtd.simulasi.pengesahan', compact('insertedRecords', 'response', 'kodcaw'));
|
||||
}
|
||||
|
||||
public function pengesahanSimulasi(Request $request)
|
||||
{
|
||||
$response = Http::post(config('api.url') . '/admin/wtd/pengesahanSimulasi', [
|
||||
'records' => $request->records,
|
||||
'kodcaw' => $request->kodcaw,
|
||||
])->json();
|
||||
|
||||
return view('wtd.index');
|
||||
}
|
||||
|
||||
public function serahbaki()
|
||||
{
|
||||
return view('wtd.simulasi.serahbaki');
|
||||
}
|
||||
|
||||
public function simulasiToDraft(Request $request)
|
||||
{
|
||||
$response = Http::post(config('api.url') . '/admin/wtd/simulasiToDraft', [
|
||||
'bulan' => $request->bulan,
|
||||
|
||||
])->json();
|
||||
|
||||
dd($response);
|
||||
}
|
||||
|
||||
public function summaryWtd(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
return $date_string ? $date_string : $current->toDateString();
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
// $summarywtd = Http::get($request->hostname . '/admin/wtd/summaryWtd', [
|
||||
// 'startDate' => $startDate,
|
||||
// 'endDate' => $endDate,
|
||||
// ])->effectiveUri()->__toString();
|
||||
|
||||
$summarywtd = Http::get($request->hostname . '/admin/wtd/summaryWtd', [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
])->json();
|
||||
|
||||
|
||||
if (!is_array($summarywtd)) {
|
||||
$summarywtd = [];
|
||||
}
|
||||
|
||||
return view('reports.wtd.index', compact('summarywtd', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function exportExcel(Request $request, $kodcaw)
|
||||
{
|
||||
return Excel::download(
|
||||
new WTDDetailExport(
|
||||
$kodcaw,
|
||||
$request->startDate,
|
||||
$request->endDate
|
||||
),"Detail_Laporan_WTD_{$kodcaw}.xlsx");
|
||||
}
|
||||
|
||||
public function home()
|
||||
{
|
||||
return view('wtd.debug.home');
|
||||
}
|
||||
|
||||
public function trail(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
return $date_string ? $date_string : $current->toDateString();
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
$debugwtd = Http::get($request->hostname . '/admin/wtd/debugWtd', [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
])->json();
|
||||
|
||||
|
||||
if (!is_array($debugwtd)) {
|
||||
$debugwtd = [];
|
||||
}
|
||||
|
||||
return view('wtd.debug.index', compact('debugwtd', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user