(PDF) Senarai simulasi mengikut pelanggan
This commit is contained in:
@@ -33,6 +33,7 @@ use App\Models\Resit;
|
||||
use App\Models\Customer;
|
||||
use App\Models\LelongTebus;
|
||||
use App\Models\Pengesahan;
|
||||
use App\Models\TransaksiKeuntungan;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -649,10 +650,63 @@ class ReportController extends Controller
|
||||
->setPaper('a4','potrait');
|
||||
|
||||
return $pdf->download('Laporan Simulasi Cawangan.pdf');
|
||||
|
||||
}
|
||||
|
||||
public function simulasireportbycust($simulasi_id, $cawid)
|
||||
{
|
||||
$keuntungan = 0;
|
||||
$arraylistgadai = 0;
|
||||
|
||||
$simulasilel = Simulasi::with('cawangan')->find($simulasi_id);
|
||||
|
||||
$cawname = Cawangan::where('id','=',$cawid)->first();
|
||||
|
||||
$cawanganDetail = $simulasilel->cawangan->find($cawid);
|
||||
|
||||
$marhun = SimulasiBid::join('cawangan', 'simulasibid.caw_id', '=', 'cawangan.id')
|
||||
->where('simulasi_id','=',$simulasi_id)
|
||||
->where('caw_id','=',$cawid);
|
||||
|
||||
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
|
||||
$datasimulasi = $marhun->get();
|
||||
$marhuns = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
|
||||
->select('nokp')
|
||||
->groupBy('nokp')->get();
|
||||
// dd($datagadai);
|
||||
$arraysag = [];
|
||||
|
||||
foreach($marhuns as $index1=>$cal)
|
||||
{
|
||||
$customer = Customer::where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
// dd($customer);
|
||||
|
||||
$listsag = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
|
||||
->where('nokp','=',$cal['nokp'])
|
||||
->get();
|
||||
// dd($listgadai);
|
||||
foreach($listsag as $index=>$listing){
|
||||
$ktlhbyr = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan');
|
||||
// dd($ktlhbyr);
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan');
|
||||
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
|
||||
$keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
|
||||
// dd($keuntungan);
|
||||
$listsag[$index]['ktlhbyr'] = $ktlhbyr;
|
||||
$listsag[$index]['keuntungan'] = $keuntungan;
|
||||
}
|
||||
$marhuns[$index1]['nama'] = $customer;
|
||||
$marhuns[$index1]['listsag'] = $listsag;
|
||||
|
||||
}
|
||||
|
||||
$pdf = PDF::loadView('pdf.simulasireportbycust',compact('simulasilel','cawanganDetail','marhuns','simulasi_id','cawid','ktlhbyr','cawname'))
|
||||
->setPaper('a4','potrait');
|
||||
|
||||
return $pdf->download('Laporan Simulasi Cawangan by Pelanggan.pdf');
|
||||
|
||||
}
|
||||
|
||||
public function lelongreport ($lelongid, $cawid){
|
||||
|
||||
Reference in New Issue
Block a user