536 lines
17 KiB
PHP
536 lines
17 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use App\Events\LelongNotify;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Permission\Models\Role;
|
|
use Spatie\Permission\Models\Permission;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use PDF;
|
|
use App\Models\User;
|
|
use App\Models\Cawangan;
|
|
use App\Models\Gadai;
|
|
use App\Models\JenisEmas;
|
|
use App\Models\JenisKarat;
|
|
|
|
use App\Models\Simulasi;
|
|
use App\Models\SimulasiBid;
|
|
use App\Models\SimulasiBidMarhun;
|
|
use App\Models\SimKarat;
|
|
use App\Models\SimKarat_temp;
|
|
use App\Models\CawanganSimulasi;
|
|
|
|
|
|
use App\Models\Lelong;
|
|
use App\Models\CawanganLelong;
|
|
use App\Models\LelongBid;
|
|
use App\Models\LelongBidder;
|
|
use App\Models\LelongBidMarhun;
|
|
use App\Models\LelKarat;
|
|
use App\Models\LelKarat_temp;
|
|
use App\Models\Resit;
|
|
use App\Models\Customer;
|
|
use App\Models\LelongTebus;
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
class ReportAllController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Contracts\Support\Renderable
|
|
*/
|
|
|
|
|
|
|
|
public function lapbrglelongindexall (){
|
|
|
|
$arrayinfo = [];
|
|
|
|
$lelong = Lelong::select('kali')
|
|
->groupBy('kali')
|
|
->get();
|
|
|
|
foreach($lelong as $info)
|
|
{
|
|
$detailsinfo = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('kali',$info->kali)
|
|
->get()
|
|
->toArray();
|
|
|
|
array_push($arrayinfo, ['info'=> $info, 'detailsinfo'=>$detailsinfo]);
|
|
|
|
}
|
|
|
|
return view('lelongall.laporanlelongall', compact('lelong','arrayinfo'));
|
|
}
|
|
|
|
public function senaraibrglelongall(Request $request, $kali){
|
|
|
|
|
|
$kali = $kali;
|
|
$lelong = Lelong::where('kali','=',$kali)->first();
|
|
// dd($lelong);
|
|
|
|
$cawanganlel = CawanganLelong::where('kali','=',$kali)->get();
|
|
// dd($cawanganlel);
|
|
|
|
|
|
$arraycaw = [];
|
|
|
|
$total_marhun = 0;
|
|
$total_berat = 0;
|
|
$total_hargaasas = 0;
|
|
|
|
|
|
foreach($cawanganlel as $cawlel)
|
|
{
|
|
$cawangan = Cawangan::where('id','=',$cawlel->caw_id)->first();
|
|
$brglel = LelongBid::join('cawangan_lelong','cawangan_lelong.caw_id','=','lelongbid.caw_id')
|
|
->select('lelongbid.id','lelongbid.berat','lelongbid.marhun','lelongbid.hargaasas')
|
|
->where('cawangan_lelong.caw_id','=',$cawlel->caw_id)
|
|
->where('cawangan_lelong.lelong_id','=',$cawlel->lelong_id)
|
|
->get();
|
|
// dd($cawlel);
|
|
|
|
$t_lelong = Lelong::join('cawangan_lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->where('cawangan_lelong.lelong_id','=', $cawlel->lelong_id)
|
|
->where('cawangan_lelong.kali','=',$kali)->first();
|
|
|
|
$packet = 0;
|
|
$berat = 0;
|
|
$hargaasas = 0;
|
|
$id = $cawlel->lelong_id;
|
|
|
|
foreach($brglel as $index1=>$bid)
|
|
{
|
|
|
|
$marhun = LelongBidMarhun::where('lelongbid_id','=',$bid['id'])->get();
|
|
$berat = $berat + $bid['berat'];
|
|
$hargaasas = $hargaasas + $bid['hargaasas'];
|
|
|
|
|
|
}
|
|
|
|
array_push($arraycaw,[
|
|
'id_cawangan'=> $cawangan['id'],
|
|
'cawangan'=>$cawangan['caw_name'],
|
|
't_lelong'=>$t_lelong['tarikh_lelong'],
|
|
'bil_marhun'=>sizeof($brglel),
|
|
'berat'=>$berat,
|
|
'hargaasas'=>$hargaasas,
|
|
|
|
]);
|
|
|
|
$total_marhun = $total_marhun + sizeof($brglel);
|
|
$total_berat = $total_berat + $berat;
|
|
$total_hargaasas = $total_hargaasas + $hargaasas;
|
|
|
|
}
|
|
|
|
$pdf = PDF::loadView('pdf.listlelongall',compact('arraycaw',
|
|
'total_marhun',
|
|
'total_berat',
|
|
'total_hargaasas',
|
|
'kali'))->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Senarai Barang Lelong All.pdf');
|
|
}
|
|
|
|
public function lapbidaanpembidaindexall (){
|
|
|
|
$arrayinfo = [];
|
|
|
|
$lelong = Lelong::select('kali')
|
|
->groupBy('kali')
|
|
->get();
|
|
|
|
foreach($lelong as $info)
|
|
{
|
|
$detailsinfo = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('kali',$info->kali)
|
|
->get()
|
|
->toArray();
|
|
|
|
array_push($arrayinfo, ['info'=> $info, 'detailsinfo'=>$detailsinfo]);
|
|
|
|
}
|
|
|
|
return view('lelongall.laporanbidaanindexall', compact('arrayinfo','lelong'));
|
|
|
|
}
|
|
|
|
public function senarailapbidaanall (Request $request, $kali){
|
|
|
|
|
|
$kali = $kali;
|
|
$lelong = Lelong::where('kali','=',$kali)->first();
|
|
// dd($lelong);
|
|
|
|
$cawanganlel = CawanganLelong::where('kali','=',$kali)->get();
|
|
// dd($cawanganlel);
|
|
|
|
|
|
$arraycaw = [];
|
|
|
|
$total_marhun = 0;
|
|
$total_berat = 0;
|
|
$total_hargaasas = 0;
|
|
$total_hargabida = 0;
|
|
|
|
|
|
foreach($cawanganlel as $cawlel)
|
|
{
|
|
$cawangan = Cawangan::where('id','=',$cawlel->caw_id)->first();
|
|
$brglel = LelongBid::join('cawangan_lelong','cawangan_lelong.caw_id','=','lelongbid.caw_id')
|
|
->join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
|
->select('lelongbid.id','lelongbid.berat','lelongbid.marhun','lelongbid.hargaasas','lelongbidder.hargabida','lelongbidder.status_bidder')
|
|
->where('lelongbidder.status_bidder','=','1')
|
|
->where('cawangan_lelong.caw_id','=',$cawlel->caw_id)
|
|
->where('cawangan_lelong.lelong_id','=',$cawlel->lelong_id)
|
|
->get();
|
|
|
|
$t_lelong = Lelong::join('cawangan_lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->where('cawangan_lelong.lelong_id','=', $cawlel->lelong_id)
|
|
->where('cawangan_lelong.kali','=',$kali)->first();
|
|
|
|
$packet = 0;
|
|
$berat = 0;
|
|
$hargaasas = 0;
|
|
$hargabida = 0;
|
|
$id = $cawlel->lelong_id;
|
|
|
|
foreach($brglel as $index1=>$bid)
|
|
{
|
|
|
|
$marhun = LelongBidMarhun::where('lelongbid_id','=',$bid['id'])->get();
|
|
$berat = $berat + $bid['berat'];
|
|
$hargaasas = $hargaasas + $bid['hargaasas'];
|
|
$hargabida = $hargabida + $bid['hargabida'];
|
|
|
|
|
|
}
|
|
|
|
array_push($arraycaw,[
|
|
'id_cawangan'=> $cawangan['id'],
|
|
'cawangan'=>$cawangan['caw_name'],
|
|
't_lelong'=>$t_lelong['tarikh_lelong'],
|
|
'bil_marhun'=>sizeof($brglel),
|
|
'berat'=>$berat,
|
|
'hargaasas'=>$hargaasas,
|
|
'hargabida'=>$hargabida,
|
|
|
|
]);
|
|
|
|
$total_marhun = $total_marhun + sizeof($brglel);
|
|
$total_berat = $total_berat + $berat;
|
|
$total_hargaasas = $total_hargaasas + $hargaasas;
|
|
$total_hargabida = $total_hargabida + $hargabida;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.pdfsenarailapbidaanall',compact('arraycaw',
|
|
'total_marhun',
|
|
'total_berat',
|
|
'total_hargaasas',
|
|
'total_hargabida',
|
|
'kali'))->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Senarai Barang Lelong All.pdf');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
Public function laplelongindexall (){
|
|
|
|
$arrayinfo = [];
|
|
|
|
$lelong = Lelong::select('kali')
|
|
->groupBy('kali')
|
|
->get();
|
|
|
|
foreach($lelong as $info)
|
|
{
|
|
$detailsinfo = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('kali',$info->kali)
|
|
->get()
|
|
->toArray();
|
|
|
|
array_push($arrayinfo, ['info'=> $info, 'detailsinfo'=>$detailsinfo]);
|
|
|
|
}
|
|
return view('lelongall.laplelongindexall',compact('arrayinfo','lelong'));
|
|
|
|
|
|
}
|
|
|
|
Public function laplelongallall (Request $request, $kali){
|
|
|
|
$kali = $kali;
|
|
$lelong = Lelong::where('kali','=',$kali)->first();
|
|
|
|
// dd($t_simulasi);
|
|
$cawanganlel = CawanganLelong::where('kali','=',$kali)->get();
|
|
// dd($cawangansim);
|
|
|
|
$arraycaw = [];
|
|
|
|
$total_nilaimarhun = 0;
|
|
$total_pinjaman = 0;
|
|
$total_marhun = 0;
|
|
$total_cazlelong = 0;
|
|
$total_berat = 0;
|
|
$total_rugilelong = 0;
|
|
$total_bakilelong = 0;
|
|
$total_keuntungan = 0;
|
|
$total_hargaasas = 0;
|
|
|
|
foreach($cawanganlel as $cawlel)
|
|
{
|
|
$cawangan = Cawangan::where('id','=',$cawlel->caw_id)->first();
|
|
$databid = LelongBid::join('cawangan_lelong','cawangan_lelong.caw_id','=','lelongbid.caw_id')
|
|
->join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
|
->select('lelongbid.id','lelongbid.berat','lelongbid.marhun','lelongbid.cajlelong','lelongbid.baki','lelongbid.nilaimarhun',
|
|
'lelongbid.pinjaman','lelongbid.hargaasas','lelongbid.cajlelong','lelongbid.bakiupah')
|
|
->where('lelongbidder.status_bidder','=','1')
|
|
->where('cawangan_lelong.caw_id','=', $cawlel->caw_id)
|
|
->where('cawangan_lelong.lelong_id','=', $cawlel->lelong_id)
|
|
->get();
|
|
|
|
$t_lelong = Lelong::join('cawangan_lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->where('cawangan_lelong.lelong_id','=', $cawlel->lelong_id)
|
|
->where('cawangan_lelong.kali','=',$kali)->first();
|
|
|
|
|
|
$packet = 0;
|
|
$berat = 0;
|
|
$nilai_marhun = 0;
|
|
$pinjaman =0;
|
|
$keuntungan = 0;
|
|
$hargaasas = 0;
|
|
$cajlelong = 0;
|
|
$rugilelong = 0;
|
|
$bakilelong = 0;
|
|
$id = $cawlel->lelong_id;
|
|
|
|
|
|
foreach($databid as $index1=>$bid)
|
|
{
|
|
|
|
$marhun = LelongBidMarhun::where('lelongbid_id','=',$bid['id'])->get();
|
|
$berat = $berat + $bid['berat'];
|
|
$nilai_marhun = $nilai_marhun + $bid['nilaimarhun'];
|
|
$pinjaman =$pinjaman + $bid['pinjaman'];
|
|
$keuntungan = $keuntungan + $bid['bakiupah'];
|
|
$hargaasas = $hargaasas + $bid['hargaasas'];
|
|
$cajlelong = $cajlelong + $bid['cajlelong'];
|
|
|
|
|
|
}
|
|
|
|
array_push($arraycaw,[
|
|
'id_cawangan'=> $cawangan['id'],
|
|
'cawangan'=>$cawangan['caw_name'],
|
|
't_lelong'=>$lelong['tarikh_lelong'],
|
|
't_simulasi'=>$t_lelong['tarikh_lelong'],
|
|
'bil_marhun'=>sizeof($databid),
|
|
'berat'=>$berat,
|
|
'n_marhun'=>$nilai_marhun,
|
|
'pinjaman'=>$pinjaman,
|
|
'upahsimpan'=>$keuntungan,
|
|
'bakiupah'=>$keuntungan,
|
|
'hargaasas'=>$hargaasas,
|
|
'cajlelong'=>$cajlelong,
|
|
'rugilelong'=>$rugilelong,
|
|
'bakilelong'=>$bakilelong,
|
|
]);
|
|
|
|
|
|
$total_marhun = $total_marhun + sizeof($databid);
|
|
$total_berat = $total_berat + $berat;
|
|
$total_nilaimarhun = $total_nilaimarhun + $nilai_marhun;
|
|
$total_pinjaman = $total_pinjaman + $pinjaman;
|
|
$total_hargaasas = $total_hargaasas + $hargaasas;
|
|
$total_cazlelong = $total_cazlelong + $cajlelong;
|
|
$total_rugilelong = $total_rugilelong + $rugilelong;
|
|
$total_bakilelong = $total_bakilelong + $bakilelong;
|
|
$total_keuntungan = $total_keuntungan + $keuntungan;
|
|
|
|
}
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.pdflaplelongall',compact('arraycaw',
|
|
'total_marhun',
|
|
'total_berat',
|
|
'total_pinjaman',
|
|
'total_hargaasas',
|
|
'total_cazlelong',
|
|
'total_rugilelong',
|
|
'total_bakilelong',
|
|
'total_keuntungan',
|
|
'total_nilaimarhun',
|
|
'kali'))
|
|
|
|
->setPaper('a4', 'potrait');
|
|
return $pdf->download('Laporan Lelong Keseluruhan.pdf');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Public function lelongtebus ($lelong_id, $kodcaw){
|
|
|
|
$total_berat = 0;
|
|
$total_hargaasas = 0;
|
|
$total_hargalelong = 0;
|
|
$arrayinfocaw = [];
|
|
|
|
|
|
$info = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code',$kodcaw)
|
|
->where('cawangan_lelong.lelong_id','=',$lelong_id)
|
|
->select('lelong_id','tarikh_lelong','lelong.fasa')
|
|
->groupBy('lelong_id')
|
|
->get();
|
|
|
|
foreach($info as $laporancaw)
|
|
{
|
|
$cawangan = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code',$kodcaw)
|
|
->where('lelong_id',$laporancaw['lelong_id'])
|
|
->get()
|
|
->toArray();
|
|
array_push($arrayinfocaw,['laporancaw' => $laporancaw,'cawangan' => $cawangan]);
|
|
}
|
|
// dd($arrayinfocaw);
|
|
|
|
|
|
$laporantebus = LelongTebus::where('kodcaw',$kodcaw)
|
|
->get()->toArray();
|
|
// dd($laporantebus);
|
|
|
|
// foreach( $brglelpembida as $index1=>$totalbrglelpembida){
|
|
|
|
// $total_berat = $total_berat + $totalbrglelpembida['berat'];
|
|
// $total_hargaasas = $total_hargaasas + $totalbrglelpembida['hargaasas'];
|
|
// $total_hargalelong = $total_hargalelong + $totalbrglelpembida['hargabida'];
|
|
|
|
// }
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.pdflelongtebus',compact('lelong_id','info','laporantebus','total_berat','total_hargaasas','total_hargalelong','arrayinfocaw'))
|
|
->setPaper('a4','potrait');
|
|
|
|
return $pdf->download('Laporan Barang Lelong Pembida.pdf');
|
|
}
|
|
|
|
|
|
Public function simulasireport ($simulasi_id, $cawid){
|
|
|
|
$keuntungan = 0;
|
|
|
|
$marhuns = SimulasiBid::join('cawangan', 'simulasibid.caw_id', '=', 'cawangan.id')
|
|
// ->join('gadai','simulasibid.norujukan','=','gadai.norujukan')
|
|
->where('simulasi_id','=',$simulasi_id)
|
|
->where('caw_id','=',$cawid)
|
|
->select(
|
|
'simulasibid.t_lelong',
|
|
'simulasibid.kodcaw',
|
|
'cawangan.caw_name',
|
|
'simulasibid.norujukan',
|
|
'simulasibid.pinjaman',
|
|
'simulasibid.berat',
|
|
'simulasibid.nilaimarhun',
|
|
'simulasibid.hargaasas',
|
|
'simulasibid.bakiupah',
|
|
'simulasibid.cajlelong',
|
|
'simulasibid.baki',
|
|
'simulasibid.status_jual',
|
|
'simulasibid.jbg'
|
|
// 'gadai.bakipjm',
|
|
// 'gadai.bakihargajualan',
|
|
// 'gadai.upah12',
|
|
// 'gadai.ansakhir',
|
|
// 'gadai.tempoh',
|
|
// 'gadai.tempohbayar',
|
|
// 'gadai.kadarupah',
|
|
// 'gadai.nokp'
|
|
|
|
)
|
|
->get()->toArray();
|
|
// dd($marhuns);
|
|
$arraymarhun = [];
|
|
foreach($marhuns as $index1=>$cal){
|
|
// dd($cal);
|
|
$gadai = Gadai::on($cal['kodcaw'])
|
|
->where('norujukan','=',$cal['norujukan'])
|
|
->first();
|
|
// dd($gadai);
|
|
$customer = Customer::where('kpbaru','=',$gadai['nokp'])
|
|
->orWhere('kplama','=',$gadai['nokp'])
|
|
->first();
|
|
// dd($customer);
|
|
|
|
// $keuntungan = $cal['bakipjm'] - ($cal['bakihargajualan'] - ($cal['upah12'] - $cal['ansakhir'])-(($cal['tempoh']-$cal['tempohbayar'])*$cal['kadarupah']/100*$cal['bakipjm']) );
|
|
$marhuns[$index1]['keuntungan'] = $keuntungan;
|
|
$marhuns[$index1]['nama'] = $customer;
|
|
|
|
array_push($arraymarhun,[
|
|
'norujukan' => $cal['norujukan'],
|
|
'tempoh' => $gadai['tempoh'],
|
|
'nama' => $customer['nama'],
|
|
'berat' => $cal['berat'],
|
|
'nilaimarhun' => $cal['nilaimarhun'],
|
|
'hargaasas' => $cal['hargaasas'],
|
|
'pinjaman' => $cal['pinjaman'],
|
|
'bakiupah' => $cal['bakiupah'],
|
|
'cajlelong' => $cal['cajlelong'],
|
|
'baki' => $cal['baki'],
|
|
]);
|
|
|
|
|
|
$datacaw = Cawangan::where('id','=',$cawid)
|
|
|
|
->get();
|
|
}
|
|
|
|
$pdf = PDF::loadView('pdf.pdfsimulasireport',compact('arraymarhun','marhuns','simulasi_id','cawid','keuntungan','datacaw'))
|
|
->setPaper('a4','potrait');
|
|
|
|
return $pdf->download('Laporan Barang Lelong Pembida.pdf');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|