update scanbarcode pembida by nama
This commit is contained in:
@@ -4779,6 +4779,7 @@ class LelongController extends Controller
|
||||
$total_bakiupah = 0;
|
||||
$total_nilaimarhun = 0;
|
||||
$keuntungan = 0;
|
||||
$total_cazlelong = 0;
|
||||
|
||||
$marhuns = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
|
||||
->where('lelong_id','=',$lelongid)->where('caw_id','=',$cawid)
|
||||
@@ -4804,6 +4805,9 @@ class LelongController extends Controller
|
||||
->get()->toArray();
|
||||
// dd($marhuns);
|
||||
$arraymarhun = [];
|
||||
$cajlelong = 0;
|
||||
$rugilelong = 0;
|
||||
$bakilelong = 0;
|
||||
foreach ($marhuns as $index1=> $cal) {
|
||||
// dd($cal);
|
||||
$gadai = Gadai::on($cal['kodcaw'])
|
||||
@@ -4814,10 +4818,13 @@ class LelongController extends Controller
|
||||
->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']) );
|
||||
$lelonglel = Lelong::where('id','=',$lelongid)->first();
|
||||
$sumcajlelong = $cal['hargaasas'] * ($lelonglel->cajlelong/100);
|
||||
$cajlelongnew = round($sumcajlelong,1,1);
|
||||
$totalbaki = $cal['hargaasas'] - $cal['pinjaman'] - $cal['bakiupah'] - $cajlelongnew;
|
||||
$marhuns[$index1]['cajlelong'] = $cajlelongnew;
|
||||
$marhuns[$index1]['baki'] = $totalbaki;
|
||||
$marhuns[$index1]['keuntungan'] = $keuntungan;
|
||||
$marhuns[$index1]['nama'] = $customer;
|
||||
|
||||
array_push($arraymarhun,[
|
||||
'norujukan' => $cal['norujukan'],
|
||||
@@ -4831,8 +4838,8 @@ class LelongController extends Controller
|
||||
'pinjaman' => $cal['pinjaman'],
|
||||
'pinjasal' => $gadai['pinjaman'],
|
||||
'bakiupah' => $cal['bakiupah'],
|
||||
'cajlelong' => $cal['cajlelong'],
|
||||
'baki' => $cal['baki'],
|
||||
'cajlelong' => $cajlelongnew,
|
||||
'baki' => $totalbaki,
|
||||
'upah6bulan' => $gadai['bakiupah']
|
||||
]);
|
||||
// $total_marhun = $total_marhun + sizeof($databid);
|
||||
@@ -4841,6 +4848,7 @@ class LelongController extends Controller
|
||||
$total_hargaasas = $total_hargaasas + $cal['hargaasas'];
|
||||
$total_nilaimarhun = $total_nilaimarhun + $cal['nilaimarhun'];
|
||||
$total_bakiupah = $total_bakiupah + $cal['bakiupah'];
|
||||
$total_cazlelong += $cajlelongnew;
|
||||
}
|
||||
|
||||
$arrayinfo = [];
|
||||
@@ -4861,12 +4869,14 @@ class LelongController extends Controller
|
||||
->toArray();
|
||||
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
|
||||
}
|
||||
return view('lelong.senaraimarhunpc',compact('arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat',
|
||||
return view('lelong.senaraimarhunpc',compact('totalbaki','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat',
|
||||
'total_pinjaman',
|
||||
'total_upah',
|
||||
'total_hargaasas',
|
||||
'total_bakiupah',
|
||||
'total_nilaimarhun'));
|
||||
'total_nilaimarhun',
|
||||
'total_cazlelong',
|
||||
));
|
||||
}
|
||||
|
||||
public function showlelongpc(Request $request, $id)
|
||||
@@ -4935,20 +4945,21 @@ class LelongController extends Controller
|
||||
$pinjaman =$pinjaman + $bid['pinjaman'];
|
||||
$bakiupah = $bakiupah + $bid['bakiupah'];
|
||||
$hargaasas = $hargaasas + $bid['hargaasas'];
|
||||
$cajlelong = $cajlelong + $bid['cajlelong'];
|
||||
// $cajlelong = $cajlelong + $bid['cajlelong'];
|
||||
|
||||
$lelongsim = Lelong::where('id',$id)->get();
|
||||
$sumcajlelong = $bid['hargaasas'] * ($lelongsim[0]['cajlelong']/100);
|
||||
$cajlelong = $cajlelong + bcdiv($sumcajlelong,1,1);
|
||||
$totalbaki = $bid['hargaasas'] - $bid['pinjaman'] - $bid['bakiupah'] - bcdiv($sumcajlelong,1,1);
|
||||
$cajlelongnew = round($sumcajlelong, 1, 1);
|
||||
// $cajlelong = $cajlelong + bcdiv($sumcajlelong, 1, 1);
|
||||
$cajlelong = $cajlelong + $cajlelongnew;
|
||||
$totalbaki = $bid['hargaasas'] - $bid['pinjaman'] - $bid['bakiupah'] - $cajlelongnew;
|
||||
|
||||
if($totalbaki > 0)
|
||||
{
|
||||
$bakilelong = $bakilelong + $totalbaki;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rugilelong = $rugilelong - $totalbaki;
|
||||
if (strpos($totalbaki, '-') !== false) {
|
||||
$rugi = -$totalbaki;
|
||||
$rugilelong += $rugi;
|
||||
} else {
|
||||
$baki = $totalbaki;
|
||||
$bakilelong += $baki;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2045,15 +2045,33 @@ class MarhunController extends Controller
|
||||
->select('lelong_id', 'tarikh_lelong', 'cawangan_lelong.masatamat_lelong', 'harga_emas_asas', 'jbg', 'cajlelong', 'sts_lelong')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
if($lelong){
|
||||
foreach ($lelong as $info) {
|
||||
$lelong_id = $info['lelong_id'];
|
||||
// dd( $lelong_id );
|
||||
|
||||
$listwinner = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('lelongbid.kodcaw',$user->kodcaw)
|
||||
// ->where('lelongbid.lelong_id', $info->lelong_id)
|
||||
->select('lelongbidder.user_id')
|
||||
->groupBy('lelongbidder.user_id')
|
||||
->get()->toArray();
|
||||
|
||||
foreach($listwinner as $index1=>$winner){
|
||||
|
||||
$userdetails = User::where('id', $winner['user_id'])->first();
|
||||
$listwinner[$index1]['details'] = $userdetails;
|
||||
}
|
||||
}
|
||||
|
||||
$detailsinfo = CawanganLelong::join('cawangan', 'cawangan_lelong.caw_id', '=', 'cawangan.id')
|
||||
->where('lelong_id', $info['lelong_id'])
|
||||
->where('cawangan.caw_code', $user->kodcaw)
|
||||
->get()
|
||||
->toArray();
|
||||
array_push($arrayinfo, ['info' => $info, 'detailsinfo' => $detailsinfo]);
|
||||
}
|
||||
array_push($arrayinfo, ['info' => $info, 'detailsinfo' => $detailsinfo, 'listwinner' => $listwinner]);
|
||||
}
|
||||
|
||||
return view('marhun.senarailelongscanjual', compact('lelong', 'arrayinfo'));
|
||||
}
|
||||
@@ -2369,6 +2387,136 @@ class MarhunController extends Controller
|
||||
return $pdf->download('Senarai Marhun Pembida.pdf');
|
||||
}
|
||||
|
||||
public function scanbarcodejualbycust($lelong_id,$userid)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first();
|
||||
|
||||
$lelongDetail = Lelong::where('id', '=', $lelong_id)->first();
|
||||
$lelongbid = LelongBid::where('lelong_id', '=', $lelong_id)
|
||||
->where('status_payment', '=', '1')
|
||||
->where('nopembeli', '=', $userid)
|
||||
->where('caw_id', '=', $caw->id)
|
||||
->select('id')
|
||||
->get()
|
||||
->keyBy('id');
|
||||
foreach ($lelongbid as $index => $value) {
|
||||
$namabidder = LelongBidder::
|
||||
where('lelongbid_id', '=', $value['id'])
|
||||
// ->where('lelongbid.kodcaw', '=', $user->kodcaw)
|
||||
->where('lelongbidder.status_bidder','=','1')
|
||||
->where('user_id', '=', $userid)
|
||||
->select('lelongbidder.lelongbid_id','lelongbidder.nama_bidder')
|
||||
->get();
|
||||
// dump($namabidder);
|
||||
foreach ($namabidder as $namabid) {
|
||||
$userdetails = User::where('id', $userid)->first();
|
||||
// dd($userdetails);
|
||||
}
|
||||
$lelongbid[$index]['nama_bidder'] = $namabidder;
|
||||
$lelongbid[$index]['namabid'] = $userdetails;
|
||||
}
|
||||
// dd($namabidder);
|
||||
$senaraiScanKeluar = ScanSemak::join('lelongbidder', 'lelongbidder.lelongbid_id', '=', 'scan_semak.lelongbid_id')
|
||||
->where('scan_semak.lelong_id', '=', $lelong_id)
|
||||
->where('lelongbidder.status_bidder', '=', 1)
|
||||
->where('scan_semak.kodcaw', '=', $caw->caw_code)
|
||||
->where('lelongbidder.user_id', '=', $userid)
|
||||
->where('scan_semak.serahkpdpembida', '=', '1')
|
||||
// ->whereNull('scan_masuk')
|
||||
->get();
|
||||
|
||||
$pluckLelongBid = $lelongbid->pluck('id')->toArray();
|
||||
$pluckScanKeluar = $senaraiScanKeluar->pluck('lelongbid_id')->toArray();
|
||||
$diff_lelong_bid = array_diff($pluckLelongBid, $pluckScanKeluar);
|
||||
|
||||
$new_lelong_bid = LelongBid::with('scanSemakSelesaiJual')
|
||||
->whereIn('id', $diff_lelong_bid)
|
||||
// ->whereIn('nopembeli', $userid)
|
||||
->get();
|
||||
// dd($new_lelong_bid);
|
||||
|
||||
return view('marhun.scanbarcodejualbycust', compact('userid','userdetails','namabidder','new_lelong_bid','lelong_id', 'lelongDetail', 'lelongbid', 'senaraiScanKeluar'));
|
||||
}
|
||||
|
||||
|
||||
public function scanKeluarMarhunjualbycust(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
|
||||
$checkExisting = ScanSemak::where('norujukan', '=', $request->norujukan_barcode)
|
||||
->where('serahkpdpembida', '=', '1')
|
||||
->get();
|
||||
|
||||
if ($checkExisting->isEmpty()) {
|
||||
$lelongbidItem = LelongBid::where('norujukan', '=', $request->norujukan_barcode)->first();
|
||||
|
||||
$scanKeluar = new ScanSemak();
|
||||
$scanKeluar->kodcaw = $lelongbidItem['kodcaw'];
|
||||
$scanKeluar->lelong_id = $lelongbidItem['lelong_id'];
|
||||
$scanKeluar->lelongbid_id = $lelongbidItem['id'];
|
||||
$scanKeluar->norujukan = $lelongbidItem['norujukan'];
|
||||
$scanKeluar->khazanah_id = $user['id'];
|
||||
$scanKeluar->scan_keluar = $current->toDateTimeString();
|
||||
$scanKeluar->serahkpdpembida = 1;
|
||||
$scanKeluar->save();
|
||||
|
||||
$scanJualKeluar = new ScanJual();
|
||||
$scanJualKeluar->kodcaw = $lelongbidItem['kodcaw'];
|
||||
$scanJualKeluar->lelong_id = $lelongbidItem['lelong_id'];
|
||||
$scanJualKeluar->lelongbid_id = $lelongbidItem['id'];
|
||||
$scanJualKeluar->norujukan = $lelongbidItem['norujukan'];
|
||||
$scanJualKeluar->khazanah_id = $user['id'];
|
||||
$scanJualKeluar->scan_keluar = $current->toDateTimeString();
|
||||
$scanJualKeluar->serah_marhun = $current->toDateTimeString();
|
||||
$scanJualKeluar->serahkpdpembida = 1;
|
||||
$scanJualKeluar->save();
|
||||
|
||||
return redirect()
|
||||
->route('marhun.scanbarcodejualbycust', ['lelong_id'=>$request->lelong_id,'userid'=>$request->userid])
|
||||
->with('success', 'Marhun Berjaya Di Scan Keluar Serahan Kepada Pembida.');
|
||||
} else {
|
||||
return redirect()
|
||||
->route('marhun.scanbarcodejualbycust', ['lelong_id'=>$request->lelong_id,'userid'=>$request->userid])
|
||||
->with('failed', 'Maaf,Marhun Telah Serah Kepada Pembida.');
|
||||
}
|
||||
}
|
||||
|
||||
public function cetakkeluarscanbarcodejualbycust($lelong_id,$userid)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first();
|
||||
|
||||
$lelongDetail = Lelong::where('id', '=', $lelong_id)->first();
|
||||
$lelongbid = LelongBid::where('lelong_id', '=', $lelong_id)
|
||||
->where('status_payment', '=', '1')
|
||||
->where('caw_id', '=', $caw->id)
|
||||
->get();
|
||||
|
||||
$userdetails = User::where('id', $userid)->first();
|
||||
|
||||
// $senaraiScanKeluar = ScanSemak::where('lelong_id', '=', $lelong_id)
|
||||
// ->where('kodcaw', '=', $caw->caw_code)
|
||||
// ->where('serahkpdpembida', '=', '1')
|
||||
// ->orderBy('id', 'desc')
|
||||
// ->get();
|
||||
$senaraiScanKeluar = ScanSemak::join('lelongbidder', 'lelongbidder.lelongbid_id', '=', 'scan_semak.lelongbid_id')
|
||||
->where('scan_semak.lelong_id', '=', $lelong_id)
|
||||
->where('lelongbidder.status_bidder', '=', 1)
|
||||
->where('scan_semak.kodcaw', '=', $caw->caw_code)
|
||||
->where('lelongbidder.user_id', '=', $userid)
|
||||
->where('scan_semak.serahkpdpembida', '=', '1')
|
||||
// ->whereNull('scan_masuk')
|
||||
->get();
|
||||
// dd($senaraiScanKeluar);
|
||||
// return view('pdf.cetakkeluarscanbarcode', compact('lelong_id', 'lelongDetail', 'lelongbid', 'senaraiScanKeluar', 'senaraiScanMasuk','caw'));
|
||||
$pdf = PDF::loadView('pdf.cetakkeluarscanbarcodejualbycust', compact('caw', 'lelong_id', 'lelongDetail', 'lelongbid', 'senaraiScanKeluar','userdetails'))->setPaper('a4', 'potrait');
|
||||
|
||||
return $pdf->download('Senarai SAG Telah Serah Kepada Pembida.pdf');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user