436 lines
14 KiB
PHP
436 lines
14 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 Carbon\Carbon;
|
|
|
|
class ReportCawanganController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Contracts\Support\Renderable
|
|
*/
|
|
|
|
|
|
|
|
// Laporan by cawangan
|
|
public function laporancawindex(request $request)
|
|
{
|
|
$user = Auth::user();
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
$cawname = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
|
|
return view('lelong.laporancawindex',compact('lelongid','cawname'));
|
|
}
|
|
|
|
public function laporanbrglelcaw($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$brglelongcaw = LelongBid::join('gadai','lelongbid.norujukan','=','gadai.norujukan')
|
|
->where('lelongbid.lelong_id', $lelong_id)
|
|
->where('gadai.kodcaw','=',$user['kodcaw'])
|
|
->get()->toArray();
|
|
|
|
$keuntungan=0;
|
|
$total_hargaasas = 0;
|
|
$total_berat = 0;
|
|
|
|
foreach($brglelongcaw as $index1=>$upah)
|
|
{
|
|
|
|
$total_hargaasas = $total_hargaasas + $upah['hargaasas'];
|
|
$total_berat = $total_berat + $upah['berat'];
|
|
|
|
}
|
|
|
|
$info = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan_lelong.lelong_id','=',$lelong_id)
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->select('lelong_id','tarikh_lelong','caw_name','fasa')
|
|
->groupBy('lelong_id','caw_name')
|
|
->get()->toArray();
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.brglelcaw',compact('brglelongcaw','lelong_id','keuntungan','total_hargaasas','total_berat','info'))
|
|
->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Senarai Barang Lelong.pdf');
|
|
|
|
|
|
}
|
|
|
|
public function indexbrgleldetailscaw(request $request)
|
|
{
|
|
$user = Auth::user();
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
$cawname = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
return view('lelong.indexbrgleldetailscaw',compact('lelongid','cawname'));
|
|
}
|
|
|
|
public function laporanbrgleldetailscaw($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$lelongs= LelongBid::where('lelong_id','=',$lelong_id)
|
|
->where('kodcaw','=',$user['kodcaw'])
|
|
->get()->toArray();
|
|
|
|
$arraycaw= [];
|
|
|
|
$total_berat = 0;
|
|
$berat = 0;
|
|
|
|
$total_harga = 0;
|
|
$harga = 0;
|
|
|
|
$total_nmarhun = 0;
|
|
$nilai_marhun = 0;
|
|
|
|
$total_hargaasas = 0;
|
|
$hargaasas = 0;
|
|
|
|
$arrayinfo = [];
|
|
|
|
|
|
$lelongid = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
|
|
->where('cawangan_lelong.lelong_id','=',$lelong_id)
|
|
->select('lelong_id','tarikh_lelong','fasa')
|
|
->groupBy('lelong_id')
|
|
->get()->toArray();
|
|
|
|
foreach($lelongid as $laporan)
|
|
{
|
|
$details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('lelong_id',$laporan['lelong_id'])
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->get()
|
|
->toArray();
|
|
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
|
|
}
|
|
|
|
foreach($lelongs as $index1=>$lelong){
|
|
|
|
$marhun= LelongBidMarhun::where('lelongbid_id','=',$lelong['id'])
|
|
// ->where('kodcaw','=',$user['kodcaw'])
|
|
->get();
|
|
|
|
$total_berat = $total_berat + ($marhun->sum('berat'));
|
|
$total_harga = $total_harga + ($marhun->sum('harga'));
|
|
$total_nmarhun = $total_nmarhun + ($marhun->sum('n_marhun'));
|
|
$total_hargaasas = $total_hargaasas + ($marhun->sum('hargaasas'));
|
|
|
|
$lelongs[$index1]['detailmarhun']=$marhun;
|
|
|
|
}
|
|
|
|
array_push($arraycaw,[
|
|
'berat'=>$berat,
|
|
'harga'=>$harga,
|
|
'n_marhun'=>$nilai_marhun,
|
|
'hargaasas'=>$hargaasas
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.laporanbrgleldetailscaw',compact('lelongs','arraycaw','total_nmarhun','total_berat','total_harga','total_hargaasas','arrayinfo'
|
|
))->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Senarai Lelong Details.pdf');
|
|
|
|
|
|
}
|
|
|
|
|
|
public function indexnamapembidacaw(){
|
|
$user = Auth::user();
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
$cawname = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
return view('lelong.indexnamapembidacaw',compact('lelongid','cawname'));
|
|
|
|
|
|
}
|
|
|
|
public function laporannamapembidacaw($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
|
|
$arraydetails = [];
|
|
$arrayinfocaw = [];
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan_lelong.lelong_id','=',$lelong_id)
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->select('lelong_id','tarikh_lelong','fasa')
|
|
->groupBy('lelong_id')
|
|
->get();
|
|
|
|
foreach($lelongid as $laporancaw)
|
|
{
|
|
$cawangan = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('lelong_id',$laporancaw['lelong_id'])
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->get()
|
|
->toArray();
|
|
array_push($arrayinfocaw,['laporancaw' => $laporancaw,'cawangan' => $cawangan]);
|
|
}
|
|
|
|
|
|
$laporanpembida= LelongBid::join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
|
->select('lelongbid_id','norujukan','hargaasas')
|
|
->where('lelongbid.lelong_id','=',$lelong_id)
|
|
->groupBy('lelongbid_id')
|
|
->get()
|
|
->toArray();
|
|
|
|
|
|
foreach($laporanpembida as $laporan)
|
|
{
|
|
$details = LelongBidder::where('lelongbid_id',$laporan['lelongbid_id'])
|
|
->orderBy('hargabida','desc')
|
|
->orderBy('masa_bidaan','asc')
|
|
->get()
|
|
->toArray();
|
|
array_push($arraydetails,['laporan' => $laporan,'details' => $details]);
|
|
}
|
|
|
|
$pdf = PDF::loadView('pdf.laporannamapembidacaw', compact('lelongid','arraydetails','lelong_id','lelongid','cawangan','arrayinfocaw'))
|
|
->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Senarai Nama Bidaan Pembida.pdf');
|
|
|
|
|
|
|
|
}
|
|
|
|
public function indexlelfullcaw (){
|
|
|
|
$user = Auth::user();
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
$cawname = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
return view('lelong.indexlelfullcaw',compact('lelongid','cawname'));
|
|
|
|
}
|
|
|
|
public function laporanlelfullcaw($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$total_nmarhun = 0;
|
|
$total_pembiayaan = 0;
|
|
$total_upahsimpan = 0;
|
|
$total_cajlelong = 0;
|
|
$total_hargalelong = 0;
|
|
$total_bakirugi = 0;
|
|
$total_hargaasas = 0;
|
|
$arrayinfocaw = [];
|
|
|
|
$info = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->where('cawangan_lelong.lelong_id','=',$lelong_id)
|
|
->select('lelong_id','tarikh_lelong','fasa')
|
|
->groupBy('lelong_id')
|
|
->get();
|
|
|
|
foreach($info as $laporancaw)
|
|
{
|
|
$cawangan = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('lelong_id',$laporancaw['lelong_id'])
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->get()
|
|
->toArray();
|
|
array_push($arrayinfocaw,['laporancaw' => $laporancaw,'cawangan' => $cawangan]);
|
|
}
|
|
|
|
$laporanlelong= LelongBid::join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
|
->where('lelongbid.lelong_id','=',$lelong_id)
|
|
->where('lelongbid.kodcaw','=',$user['kodcaw'])
|
|
->where('lelongbidder.status_bidder','=','1')
|
|
->select('lelongbid.norujukan','lelongbid.nilaimarhun','lelongbid.pinjaman','lelongbid.upahsimpan',
|
|
'lelongbid.cajlelong','lelongbidder.hargabida','lelongbid.baki','lelongbid.hargaasas','lelongbidder.nama_bidder')
|
|
->get()->toArray();
|
|
|
|
foreach($laporanlelong as $index1=>$laplelong)
|
|
{
|
|
|
|
$total_nmarhun = $total_nmarhun + $laplelong['nilaimarhun'];
|
|
$total_pembiayaan = $total_pembiayaan + $laplelong['pinjaman'];
|
|
$total_upahsimpan = $total_upahsimpan + $laplelong['upahsimpan'];
|
|
$total_cajlelong = $total_cajlelong + $laplelong['cajlelong'];
|
|
$total_hargalelong = $total_hargalelong + $laplelong['hargabida'];
|
|
$total_bakirugi = $total_bakirugi + $laplelong['baki'];
|
|
$total_hargaasas = $total_hargaasas + $laplelong['hargaasas'];
|
|
|
|
}
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.laporanlelfullcaw',compact('info','lelong_id','laporanlelong','lelong_id','total_nmarhun','total_pembiayaan',
|
|
'total_upahsimpan','total_cajlelong','total_hargalelong','total_bakirugi','total_hargaasas','arrayinfocaw'))
|
|
|
|
->setPaper('a4', 'potrait');
|
|
return $pdf->download('Laporan Lelong Keseluruhan.pdf');
|
|
|
|
|
|
}
|
|
|
|
public function indexbrglelpembidacaw(){
|
|
|
|
$user = Auth::user();
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
$cawname = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
return view('lelong.indexbrglelpembidacaw',compact('lelongid','cawname'));
|
|
|
|
}
|
|
|
|
public function laporanbrglelpembidacaw($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$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_lelong.lelong_id','=',$lelong_id)
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->select('lelong_id','tarikh_lelong','fasa')
|
|
->groupBy('lelong_id')
|
|
->get();
|
|
|
|
foreach($info as $laporancaw)
|
|
{
|
|
$cawangan = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('lelong_id',$laporancaw['lelong_id'])
|
|
->where('cawangan.caw_code','=',$user['kodcaw'])
|
|
->get()
|
|
->toArray();
|
|
array_push($arrayinfocaw,['laporancaw' => $laporancaw,'cawangan' => $cawangan]);
|
|
}
|
|
|
|
$brglelpembida = LelongBid::join('gadai','lelongbid.norujukan','=','gadai.norujukan')
|
|
->join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
|
->where('gadai.kodcaw','=',$user['kodcaw'])
|
|
->where('lelongbid.lelong_id','=',$lelong_id)
|
|
->where('lelongbidder.status_bidder','=','1')
|
|
->get()->toArray();
|
|
|
|
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.laporanbrglelpembidacaw',compact('lelong_id','info','brglelpembida','total_berat','total_hargaasas','total_hargalelong','arrayinfocaw'))
|
|
->setPaper('a4','potrait');
|
|
|
|
return $pdf->download('Laporan Barang Lelong Pembida.pdf');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|