Merge branch 'main' into atie

This commit is contained in:
Nur Izzati Zulkifli
2022-04-20 12:16:04 +08:00
3 changed files with 121 additions and 90 deletions
+98 -67
View File
@@ -338,7 +338,8 @@ class SimulasiController extends Controller
foreach($cawangansim as $cawsim)
{
$cawangan = Cawangan::where('id','=',$cawsim->caw_id)->first();
$databid = SimulasiBid::where('caw_id','=',$cawsim->caw_id)->where('simulasi_id','=',$simulasi_id)->get();
$databid = SimulasiBid::join('gadai','simulasibid.norujukan','=','gadai.norujukan')
->where('caw_id','=',$cawsim->caw_id)->where('simulasi_id','=',$simulasi_id)->get()->toArray();
$packet = 0;
$berat = 0;
@@ -349,97 +350,107 @@ class SimulasiController extends Controller
$cajlelong = 0;
$rugilelong = 0;
$bakilelong = 0;
$keuntungan = 0;
$total_upahkeuntungan = 0;
foreach($databid as $bid)
foreach($databid as $index1=>$bid)
{
$marhun = SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)->get();
$berat = $berat + $bid->berat;
$marhun = SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])->get();
$berat = $berat + $bid['berat'];
$nilai_marhun = $nilai_marhun + ($marhun->sum('n_marhun'));
$pinjaman =$pinjaman + $bid->pinjaman;
$upah = $upah + $bid->upah;
$hargaasas = $hargaasas + $bid->hargaasas;
$cajlelong = $cajlelong + $bid->cajlelong;
$pinjaman =$pinjaman + $bid['pinjaman'];
$upah = $upah + $bid['upahsimpan'];
$hargaasas = $hargaasas + $bid['hargaasas'];
$cajlelong = $cajlelong + $bid['cajlelong'];
if($bid->baki > 0)
$keuntungan = $bid['bakipjm'] - ($bid['bakihargajualan'] - ($bid['upah12'] - $bid['ansakhir'])-(($bid['tempoh']-$bid['tempohbayar'])*$bid['kadarupah']/100*$bid['bakipjm']) );
$databid[$index1]['keuntungan'] = $keuntungan;
$total_upahkeuntungan = $total_upahkeuntungan + $keuntungan;
if($bid['baki'] > 0)
{
$bakilelong = $bakilelong + $bid->baki;
$bakilelong = $bakilelong + $bid['baki'];
}
else
{
$rugilelong = $rugilelong - $bid->baki;
$rugilelong = $rugilelong - $bid['baki'];
}
$total24Kgb += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','24.0Kgb')
->sum('berat');
$total24Kgb += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','24.0Kgb')
->sum('berat');
$total24K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','24.0K')
->sum('berat');
$total23k += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','23.0K')
->sum('berat');
$total22K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','22.0K')
->sum('berat');
$total21K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','21.0K')
->sum('berat');
$total20K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','20.0K')
->sum('berat');
$total18Kp += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','18.0Kp')
->sum('berat');
$total18K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','18.0K')
->sum('berat');
$total14Kp += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','14.0Kp')
->sum('berat');
$total14K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','14.0K')
->sum('berat');
$total9K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','9.0K')
->sum('berat');
$total24K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','24.0K')
->sum('berat');
$total23k += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','23.0K')
->sum('berat');
$total22K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','22.0K')
->sum('berat');
$total21K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','21.0K')
->sum('berat');
$total20K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','20.0K')
->sum('berat');
$total18Kp += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','18.0Kp')
->sum('berat');
$total18K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','18.0K')
->sum('berat');
$total14Kp += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','14.0Kp')
->sum('berat');
$total14K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','14.0K')
->sum('berat');
$total9K += SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])
->where('karat','=','9.0K')
->sum('berat');
}
array_push($arraycaw,[
'id_cawangan'=> $cawangan->id,
'cawangan'=>$cawangan->caw_name,
't_lelong'=>$simulasi->tarikh_lelong,
'id_cawangan'=> $cawangan['id'],
'cawangan'=>$cawangan['caw_name'],
't_lelong'=>$simulasi['tarikh_lelong'],
'bil_marhun'=>sizeof($databid),
'berat'=>$berat,
'n_marhun'=>$nilai_marhun,
'pinjaman'=>$pinjaman,
'upah'=>0,
'upahsimpan'=>$total_upahkeuntungan,
'hargaasas'=>$hargaasas,
'cajlelong'=>$cajlelong,
'rugilelong'=>$rugilelong,
'bakilelong'=>$bakilelong,
]);
$total_marhun = $total_marhun + sizeof($databid);
$total_berat = $total_berat + $berat;
$total_nmarhun = $total_nmarhun + $nilai_marhun;
$total_pinjaman = $total_pinjaman + $pinjaman;
$total_upah = $total_upah + 0;
$total_hargaasas = $total_hargaasas + $hargaasas;
$total_cazlelong = $total_cazlelong + $cajlelong;
$total_rugilelong = $total_rugilelong + $rugilelong;
@@ -449,7 +460,6 @@ class SimulasiController extends Controller
->get();
}
return view('simulasi.showsimulasi',compact(
'arraycaw',
@@ -476,7 +486,8 @@ class SimulasiController extends Controller
'simkarat',
'simulasi_id',
'jeniskarat',
'data'));
'data',
'total_upahkeuntungan'));
}
public function delete($id)
@@ -738,7 +749,10 @@ class SimulasiController extends Controller
public function senaraimarhunlel($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(
@@ -754,11 +768,28 @@ class SimulasiController extends Controller
'simulasibid.cajlelong',
'simulasibid.baki',
'simulasibid.status_jual',
'simulasibid.jbg'
'simulasibid.jbg',
'gadai.bakipjm',
'gadai.bakihargajualan',
'gadai.upah12',
'gadai.ansakhir',
'gadai.tempoh',
'gadai.tempohbayar',
'gadai.kadarupah'
)
->get();
->get()->toArray();
foreach($marhuns as $index1=>$cal){
$keuntungan = $cal['bakipjm'] - ($cal['bakihargajualan'] - ($cal['upah12'] - $cal['ansakhir'])-(($cal['tempoh']-$cal['tempohbayar'])*$cal['kadarupah']/100*$cal['bakipjm']) );
$marhuns[$index1]['keuntungan'] = $keuntungan;
}
return view('simulasi.senaraimarhunlel',compact('marhuns','simulasi_id','cawid'));
return view('simulasi.senaraimarhunlel',compact('marhuns','simulasi_id','cawid','keuntungan','cal'));
}
public function deletemarhunlel(Request $request){
@@ -28,7 +28,7 @@
<th>Berat (gm)</th>
<th>Nilai Marhun (RM)</th>
<th>Harga Asas (RM)</th>
<th>Upah Simpan (RM)</th>
<th>Keuntungan (RM)</th>
<th>Caj Lelong (%)</th>
<th>Rugi Lelong (RM)</th>
<th>Baki Lelong (RM)</th>
@@ -38,34 +38,34 @@
<tbody>
@foreach ($marhuns as $index=> $marhun)
<tr>
<td>{{$index+1}}</td>
<td>{{ $marhun->t_lelong }}</td>
<td class="text-center">{{ $marhun->kodcaw }}</td>
<td>{{ $marhun->caw_name }}</td>
<td>{{ $marhun->norujukan}}</td>
<td>{{ $marhun->pinjaman }}</td>
<td>{{ $marhun->jbg }}</td>
<td>{{ $marhun->berat }}</td>
<td>{{ $marhun->nilaimarhun }}</td>
<td>{{ $marhun->hargaasas }}</td>
<td>{{ $marhun->upahsimpan }}</td>
<td>{{ $marhun->cajlelong }}</td>
<td>{{$loop->iteration}}</td>
<td>{{ $marhun['t_lelong'] }}</td>
<td class="text-center">{{ $marhun['kodcaw'] }}</td>
<td>{{ $marhun['caw_name'] }}</td>
<td>{{ $marhun['norujukan']}}</td>
<td>{{ number_format($marhun['pinjaman'], 2, '.', ',') }}</td>
<td>{{ number_format($marhun['jbg'], 2, '.', ',') }}</td>
<td>{{ number_format($marhun['berat'], 2, '.', ',') }}</td>
<td>{{ number_format($marhun['nilaimarhun'], 2, '.', ',') }}</td>
<td>{{ number_format($marhun['hargaasas'], 2, '.', ',') }}</td>
<td>{{ number_format($marhun['keuntungan'], 2, '.', ',') }}</td>
<td>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</td>
<?php
$rugi = '';
$baki = '';
if(strpos($marhun->baki, '-') !== false)
$rugi = 0;
$baki = 0;
if(strpos($marhun['baki'], '-') !== false)
{
$rugi = $marhun->baki;
$rugi = $marhun['baki'];
}
else {
$baki = $marhun->baki;
$baki = $marhun['baki'];
}
?>
<td>{{$rugi}}</td>
<td>{{$baki}}</td>
<td>{{number_format($rugi, 2, '.', ',')}}</td>
<td>{{number_format($baki, 2, '.', ',')}}</td>
<td class="text-center">
<input type="checkbox" aria-label="Checkbox for following text input" onclick="btnDelete(this)" name="checkboxdata[]" value="{{ $marhun->norujukan }}">
<input type="checkbox" aria-label="Checkbox for following text input" onclick="btnDelete(this)" name="checkboxdata[]" value="{{ $marhun['norujukan'] }}">
</td>
</tr>
@@ -84,7 +84,7 @@
<td>{{ number_format($caw['berat'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['n_marhun'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['pinjaman'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['upah'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['upahsimpan'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['hargaasas'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['cajlelong'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['bakilelong'], 2, '.', ',') }}</td>
@@ -99,7 +99,7 @@
<td>{{ number_format($total_berat, 2, '.', ',') }}</td>
<td>{{ number_format($total_nmarhun, 2, '.', ',') }}</td>
<td>{{ number_format($total_pinjaman, 2, '.', ',') }}</td>
<td>{{ number_format($total_upah, 2, '.', ',') }}</td>
<td>{{ number_format($total_upahkeuntungan, 2, '.', ',') }}</td>
<td>{{ number_format($total_hargaasas, 2, '.', ',') }}</td>
<td>{{ number_format($total_cazlelong, 2, '.', ',') }}</td>
<td>{{ number_format($total_bakilelong, 2, '.', ',') }}</td>