update simulasi all

This commit is contained in:
Nur Izzati Zulkifli
2022-07-26 22:35:00 +08:00
parent 0f7dd20e98
commit 295b86b06c
6 changed files with 696 additions and 3 deletions
+197 -1
View File
@@ -305,6 +305,7 @@ class SimulasiController extends Controller
'simulasibid.pinjaman','simulasibid.hargaasas','simulasibid.cajlelong','simulasibid.bakiupah')
->where('caw_id','=',$cawsim->caw_id)->where('simulasi_id','=',$simulasi_id)->get();
// ->toArray();
// dd($databid);
$packet = 0;
$berat = 0;
@@ -915,7 +916,8 @@ class SimulasiController extends Controller
{
if($request->fasa == '1'){
$cawangan_all = Cawangan::all();
$cawangan_all = Cawangan::orderBy('caw_name')->get();
// dd($cawangan_all);
$senarai = [];
$total_bil_lelong = 0;
foreach($cawangan_all as $cawangan){
@@ -1299,4 +1301,198 @@ class SimulasiController extends Controller
}
return view('simulasi.listsagbycust',compact('marhuns','simulasi_id','cawid','ktlhbyr'));
}
public function senaraisimulasiall()
{
// $simulasi = Simulasi::all();
$arrayinfo = [];
$simulasi = Simulasi::select('kali')
->groupBy('kali')
->get();
// ->toArray();
// dd($simulasi);
foreach($simulasi as $info)
{
$detailsinfo = CawanganSimulasi::join('cawangan','cawangan_simulasi.caw_id','=','cawangan.id')
->where('kali',$info->kali)
// ->groupBy('caw_id')
->get()
->toArray();
// dd($detailsinfo);
array_push($arrayinfo, ['info'=> $info, 'detailsinfo'=>$detailsinfo]);
}
return view('simulasi.senaraisimulasiall',compact('simulasi','arrayinfo'));
}
public function showsimulasiall(Request $request, $kali)
{
$kali = $kali;
$simulasi = Simulasi::where('kali','=',$kali)->first();
// dd($t_simulasi);
$cawangansim = CawanganSimulasi::where('kali','=',$kali)->get();
// dd($cawangansim);
// $simkarat = SimKarat::where('simulasi_id','=',$id)->get();
// $jeniskarat = JenisKarat::all();
$arraydata = [];
$arraycaw = [];
$data = [];
$total_marhun = 0;
$total_berat = 0;
$total_nmarhun = 0;
$total_pinjaman = 0;
$total_upah = 0;
$total_hargaasas = 0;
$total_cazlelong = 0;
$total_rugilelong = 0;
$total_bakilelong = 0;
$total24Kgb = 0;
$total24K = 0;
$total23k = 0;
$total22K = 0;
$total21K = 0;
$total20K = 0;
$total18Kp = 0;
$total18K = 0;
$total14Kp = 0;
$total14K = 0;
$total9K = 0;
$total_bakiupah = 0;
$total_nilaimarhun = 0;
foreach($cawangansim as $cawsim)
{
$cawangan = Cawangan::where('id','=',$cawsim->caw_id)->first();
$databid = SimulasiBid::join('cawangan_simulasi','cawangan_simulasi.caw_id','=','simulasibid.caw_id')
->select('simulasibid.id','simulasibid.berat','simulasibid.marhun','simulasibid.cajlelong','simulasibid.baki','simulasibid.nilaimarhun',
'simulasibid.pinjaman','simulasibid.hargaasas','simulasibid.cajlelong','simulasibid.bakiupah')
->where('cawangan_simulasi.caw_id','=', $cawsim->caw_id)
->where('cawangan_simulasi.simulasi_id','=', $cawsim->simulasi_id)
->get();
// ->toArray();
// dd($databid);
$t_simulasi = Simulasi::join('cawangan_simulasi','cawangan_simulasi.simulasi_id','=','simulasi.id')
->where('cawangan_simulasi.simulasi_id','=', $cawsim->simulasi_id)
->where('cawangan_simulasi.kali','=',$kali)->first();
$packet = 0;
$berat = 0;
$nilai_marhun = 0;
$pinjaman =0;
$bakiupah = 0;
$hargaasas = 0;
$cajlelong = 0;
$rugilelong = 0;
$bakilelong = 0;
// $keuntungan = 0;
// $total_upahkeuntungan = 0;
foreach($databid as $index1=>$bid)
{
// $t_lelong = $bid['t_lelong'];
// dd($bid['id']);
$marhun = SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])->get();
$berat = $berat + $bid['berat'];
// $nilai_marhun = $nilai_marhun + ($marhun->sum('n_marhun'));
$nilai_marhun = $nilai_marhun + $bid['nilaimarhun'];
$pinjaman =$pinjaman + $bid['pinjaman'];
$bakiupah = $bakiupah + $bid['bakiupah'];
$hargaasas = $hargaasas + $bid['hargaasas'];
$cajlelong = $cajlelong + $bid['cajlelong'];
// $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;
// $total_upahkeuntungan = bcdiv($total_upahkeuntungan,1,1) + bcdiv($keuntungan,1,1);
if($bid['baki'] > 0)
{
$bakilelong = $bakilelong + $bid['baki'];
}
else
{
$rugilelong = $rugilelong - $bid['baki'];
}
}
array_push($arraycaw,[
'id_cawangan'=> $cawangan['id'],
'cawangan'=>$cawangan['caw_name'],
't_lelong'=>$simulasi['tarikh_lelong'],
't_simulasi'=>$t_simulasi['tarikh_lelong'],
'bil_marhun'=>sizeof($databid),
'berat'=>$berat,
'n_marhun'=>$nilai_marhun,
'pinjaman'=>$pinjaman,
'upahsimpan'=>$bakiupah,
'bakiupah'=>$bakiupah,
'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_bakiupah = $total_bakiupah + $bakiupah;
$data = Simulasi::where('kali','=',$kali)
->first();
// dd($data);
}
return view('simulasi.showsimulasiall',compact(
'arraycaw',
'total_marhun',
'total_berat',
'total_nmarhun',
'total_pinjaman',
'total_upah',
'total_hargaasas',
'total_cazlelong',
'total_rugilelong',
'total_bakilelong',
'data',
'total_bakiupah',
'total_nilaimarhun'
));
}
}
@@ -172,6 +172,9 @@
<li class="{{ (request()->is('analisa/senaraisimulasi/*') || request()->is('analisa/senaraisimulasi') ) ? 'active' : '' }}">
<a href="{{url('analisa/senaraisimulasi')}}">Senarai Simulasi</a>
</li>
<li class="{{ (request()->is('analisa/senaraisimulasiall/*') || request()->is('analisa/senaraisimulasiall') ) ? 'active' : '' }}">
<a href="{{url('analisa/senaraisimulasiall')}}">Senarai Simulasi All</a>
</li>
</ul>
</li>
<li class="{{ (request()->is('lelong/*')) ? 'active' : '' }}">
@@ -0,0 +1,143 @@
@extends('layouts.app')
@section('content')
<div class="container-fluid">
<div class="row ">
<div class="col-md-11 mx-auto card p-4">
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif
<form id="exportform" action="" method="POST">
<input type="hidden" name="type" value="User">
<table class="table table-striped table-xl text-center" id="simulasi" style="width:100%">
<thead class="bg-primary text-white">
<tr>
<th>No</th>
<th>Kali Lelong</th>
{{-- <th>Tarikh Lelong</th> --}}
<th>Fasa</th>
<th align='left'>Cawangan</th>
{{-- <th>Harga Asas (RM)</th> --}}
<th class="text-center">Tindakan</th>
</tr>
</thead>
<tbody>
@foreach ($arrayinfo as $info)
<tr>
<td>{{$loop->iteration}}</td>
<td>{{$info['info']['kali']}}</td>
{{-- <td>
{{$info['info']['tarikh_lelong'] }}
</td> --}}
<td align = 'center'>
@foreach($info['detailsinfo'] as $info2)
{{$info2['fasa']}}<br>
@endforeach
</td>
<td align = 'left'>
@foreach($info['detailsinfo'] as $info2)
{{$info2['caw_name']}}<br>
@endforeach
{{-- </td>
<td>{{ $info['info']['harga_emas_asas'] }}</td> --}}
<td class="text-center">
{{-- <a href="{{ route('analisa.kemaskinidata',$info['info']['simulasi_id']) }}" data-toggle="tooltip" data-placement="top" title="Kemaskini Data" style="margin-right:40px"><i class="fas fa-sync-alt"></i></a> --}}
<a href="{{ route('analisa.showsimulasiall',$info['info']['kali']) }}" data-toggle="tooltip" data-placement="top" title="Butiran Simulasi" style="margin-right:30px"><i class="far fa-edit"></i></a>
{{-- <a class="confirmdel" href="{{ route('analisa.delete',$info['info']['simulasi_id']) }}" data-toggle="tooltip" data-placement="top" title="Hapus"><i class="far fa-trash-alt"></i></a> --}}
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
</div>
</div>
</div>
<script>
//Enable tooltips everywhere
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
$('a.confirmdel').confirm({
title: 'Confirmation',
content: 'Anda pasti?',
type: 'orange',
typeAnimated: true,
buttons: {
Delete: {
btnClass: 'btn-warning',
action: function () {
location.href = this.$target.attr('href');
}
},
Batal: {
btnClass: 'btn-default',
action: function () {}
}
}
});
var tablesimulasi = $('#simulasi').DataTable( {
"columnDefs": [
{
"targets": 0,
"orderable": false
},
{
"targets": 4,
"orderable": false
}
],
order: [[1, 'asc']],
// "ordering": false,
"info": false,
"lengthChange": false,
"pageLength": 15,
dom: 'Bfrtip',
// buttons: [
// // 'copy', 'excel', 'pdf'
// // { text: 'copy', className: 'btn btn-primary' },
// {
// className: 'btn btn-outline-success pl-4 pr-4 btn-sm addsim',
// text: '<i class="fas fa-plus" id="test"></i>',
// titleAttr: 'Tambah Simulasi',
// action: function ( e, dt, node, config ) {
// alert( 'Button activated' );
// }
// },
// {
// className: 'btn btn-outline-secondary pl-4 pr-4 btn-sm export',
// titleAttr: 'Export to CSV',
// text: '<i class="fas fa-download"></i>',
// action: function ( e, dt, node, config ) {
// $("#exportform").submit();
// }
// }
// ]
});
$('.addsim').tooltip();
$('.export').tooltip();
// $( '.dt-buttons').addClass('btn-group');
$( '.addsim').removeClass('dt-button');
$( '.export').removeClass('dt-button');
function selectall(cb) {
tablesimulasi.rows().nodes().to$().find('input[type="checkbox"]').each(function(){
$(this).prop('checked', cb.checked);
})
}
</script>
@endsection
@@ -0,0 +1,348 @@
@extends('layouts.app')
@section('content')
<div class="container-fluid">
<div class="row ">
<div class="col-md-11 mx-auto card p-4">
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button type="button" class="btn btn-light" ><a href="javascript:window.history.go(-1);"><h3><i class="fas fa-arrow-alt-circle-left"></i></h3></a></button>
<a class="nav-link active" id="nav-simulasi-tab" data-toggle="tab" href="#nav-simulasi" role="tab" aria-controls="nav-simulasi" aria-selected="true">Simulasi</a>
{{-- <a class="nav-link" id="nav-hargaasas-tab" data-toggle="tab" href="#nav-hargaasas" role="tab" aria-controls="nav-hargaasas" aria-selected="false">Harga Emas Asas</a> --}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-simulasi" role="tabpanel" aria-labelledby="nav-simulasi-tab">
<br>
<form id="exportform" action="{{route('analisa.export')}}" method="POST">
@csrf
<input type="hidden" name="type" value="User">
{{-- <input type="hidden" name="simulasiid" value="{{ $simulasi_id }}"> --}}
<div class="row">
<div class="col-md-5">
<table class="table table-striped table-xl" id="conclusion" style="width:100%">
<tr>
<td>Bilangan Lelong : {{$total_marhun}}</td>
</tr>
<tr>
<td>Nilai Marhun Keseluruhan : RM{{ number_format($total_nilaimarhun, 2, '.', ',') }}</td>
</tr>
<tr>
<td>Pembiayaan Keseluruhan : RM{{ number_format($total_pinjaman, 2, '.', ',') }}</td>
</tr>
<tr>
<td>Keuntungan Keseluruhan : RM{{ number_format($total_bakiupah, 2, '.', ',') }}</td>
</tr>
<tr>
{{-- <td>Tarikh Lelong : @php
$myDateTime = DateTime::createFromFormat('Y-m-d', $data['tarikh_lelong'] );
$t_lelong = $myDateTime->format('d-m-Y');
echo($t_lelong);
@endphp
</td> --}}
</tr>
</table>
</div>
<div class="col-md-2"></div>
<div class="col-md-5">
<table class="table table-striped table-xl" id="conclusion2" style="width:100%">
<tr>
<td>Rugi Lelong Keseluruhan : -RM{{ number_format($total_rugilelong, 2, '.', ',') }}</td>
</tr>
<tr>
<td>Baki Lelong Keseluruhan : RM{{ number_format($total_bakilelong, 2, '.', ',') }}</td>
</tr>
<tr>
<td>Caj Lelong Keseluruhan : RM{{ number_format($total_cazlelong, 2, '.', ',') }}</td>
</tr>
<tr>
<td>Tempoh: {{ $data['jbg']}}</td>
</tr>
</table>
</div>
</div>
<table class="table table-striped table-xl" id="simulasi" style="width:100%">
<thead class="bg-primary text-white">
<tr class="text-center">
<th>No</th>
<th>T.Lelong</th>
<th>Cawangan</th>
<th>Bil Marhun (Paket)</th>
<th>Berat (gm)</th>
<th>N. Marhun (RM)</th>
<th>Pembiayaan (RM)</th>
<th>Keuntungan (RM)</th>
<th>Harga Asas (RM)</th>
<th>Caj (RM)</th>
<th>Baki (RM)</th>
<th>Rugi (RM)</th>
</tr>
</thead>
<tbody>
@foreach ($arraycaw as $index=>$caw)
<tr>
<td>{{$index+1}}</td>
<td>@php
$myDateTime = DateTime::createFromFormat('Y-m-d', $caw['t_simulasi'] );
$t_lelong = $myDateTime->format('d-m-Y');
echo($t_lelong);
@endphp</td>
<td>{{ $caw['cawangan'] }}</td>
<td>{{ $caw['bil_marhun'] }}</td>
<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['upahsimpan'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['hargaasas'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['cajlelong'], 2, '.', ',') }}</td>
<td>{{ number_format($caw['bakilelong'], 2, '.', ',') }}</td>
<td>({{ number_format($caw['rugilelong'], 2, '.', ',') }})</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="3"><b>JUMLAH KESELURUHAN</b></td>
<td>{{ $total_marhun }}</td>
<td>{{ number_format($total_berat, 2, '.', ',') }}</td>
<td>{{ number_format($total_nilaimarhun, 2, '.', ',') }}</td>
<td>{{ number_format($total_pinjaman, 2, '.', ',') }}</td>
<td>{{ number_format($total_bakiupah, 2, '.', ',') }}</td>
<td>{{ number_format($total_hargaasas, 2, '.', ',') }}</td>
<td>{{ number_format($total_cazlelong, 2, '.', ',') }}</td>
<td>{{ number_format($total_bakilelong, 2, '.', ',') }}</td>
<td>({{ number_format($total_rugilelong, 2, '.', ',') }})</td>
</tr>
</tfoot>
</table>
{{-- <table class="table table-striped table-xl" id="jumlahberat" style="width:80%">
<tr class="text-center">
<th colspan="12">JUMLAH BERAT MENGIKUT MUTU (KESELURUHAN)</th>
</tr>
</thead>
<tbody>
<tr>
<td>MUTU</td>
@foreach ($simkarat as $index=>$karat)
<td>{{$karat->karat}}</td>
@endforeach
</tr>
<tr>
<td>BERAT (gm)</td>
<td>{{$total24Kgb}}</td>
<td>{{$total24K}}</td>
<td>{{$total23k}}</td>
<td>{{$total22K}}</td>
<td>{{$total21K}}</td>
<td>{{$total20K}}</td>
<td>{{$total18Kp}}</td>
<td>{{$total18K}}</td>
<td>{{$total14Kp}}</td>
<td>{{$total14K}}</td>
<td>{{$total9K}}</td>
</tr>
</tbody>
</table> --}}
</form>
{{-- <div class="row">
<div class="text-center">
<a class="btn btn-primary" href="{{ route('lelong.create',$simulasi_id) }}">Daftar Lelong</a>
</div>
</div> --}}
</div>
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif
{{-- {{$cawangan[0] }} --}}
</div>
<div class="modal fade" tabindex="-1" id="modalfilter">
<div class="modal-dialog modal-lg">
{{-- <div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Filter By</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div> --}}
<div class="modal-body">
<form action="{{ route('analisa.filter') }}" method="POST" id="formfilter">
@csrf
<div class="row justify-content-center">
<div class="col-md-8">
<div class="form-group row">
<input type="hidden" name="idmarhun" id="idmarhun" >
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
<button type="button" class="btn btn-primary" onclick="">Jana Semula Simulasi</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$("#hideform").hide();
$('#btnsimpan').prop('disabled', true)
function kemaskini() {
var inputdata = $("td.input").find("input");
if(inputdata.length ==0)
{
$("td.input").each(function(index) {
// console.log(index)
var la = $(this).html();
// if(index%2 ==0 ) //even-0-2-4
// {
$(this).html("<input type='text' name='harga2[]' id=harga2"+index+" value="+la+" />");
// }
// else //odd-1-3-5-7
// {
// $(this).html("<input type='text' name='harga[]' id=harga"+index+" value="+la+" />");
// }
})
$("#hideform").show();
$("#btnkemaskini").hide();
}
else
{
$("td.input").each(function() {
var la = $(this).html();
$(this).html($(la).val());
})
$("#hideform").hide();
$("#btnkemaskini").show();
}
}
function calculate(e)
{
let hargaasasbaru = $('#txthargaasas').val();
let jeniskarat = $(e).data('jeniskarat');
// let maxcolumn = 2;
let count = 0;
let indexarray = 0;
$("td.input").each(function(index) {
if(hargaasasbaru)
{
$('#btnsimpan').prop('disabled', false)
// if(index%2 == 0)
// {
let harga1 = parseFloat(hargaasasbaru);
let harga2 = parseFloat(jeniskarat[indexarray]['dariharga916']);
let newhargaasas = harga1 + (harga2);
count++;
$('#harga2'+index).val(newhargaasas.toFixed(2));
// }
// else
// {
// let harga1 = parseInt(hargaasasbaru);
// let harga2 = parseInt(jeniskarat[indexarray]['dariharga916']);
// let newhargaasas = (harga1 + (harga2))/2.72;;
// count++;
// $('#harga'+index).val(newhargaasas.toFixed(2));
// }
// if(count == maxcolumn)
// {
// count = 0;
indexarray++;
// }
}
else
{
$('#btnsimpan').prop('disabled', true)
let dummy =0;
// if(index%2 == 0)
// {
$('#harga2'+index).val(dummy.toFixed(2));
// }
// else
// {
// $('#harga'+index).val(dummy.toFixed(2));
// }
}
})
}
function save(){
$('#formhargaasas').submit();
}
$('a.confirmdel').confirm({
title: 'Confirmation',
content: 'Anda pasti?',
type: 'orange',
typeAnimated: true,
buttons: {
Delete: {
btnClass: 'btn-warning',
action: function () {
location.href = this.$target.attr('href');
}
},
Batal: {
btnClass: 'btn-default',
action: function () {}
}
}
});
var tablesimulasi = $('#simulasi').DataTable( {
"columnDefs": [
{
"targets": 0,
"orderable": false
}
],
order: [[0, 'asc']],
// "ordering": false,
"searching":false,
"info": false,
"lengthChange": false,
"pageLength": 15,
dom: 'Bfrtip',
buttons: [
{
className: 'btn btn-outline-secondary pl-4 pr-4 btn-sm export',
titleAttr: 'Download to PDF',
text: '<i class="fas fa-download"></i>',
action: function ( e, dt, node, config ) {
$("#exportform").submit();
}
}
]
});
$('.addsim').tooltip();
$('.export').tooltip();
// $( '.dt-buttons').addClass('btn-group');
$( '.addsim').removeClass('dt-button');
$( '.export').removeClass('dt-button');
function selectall(cb) {
tablesimulasi.rows().nodes().to$().find('input[type="checkbox"]').each(function(){
$(this).prop('checked', cb.checked);
})
}
</script>
@endsection
+2 -2
View File
@@ -17,12 +17,12 @@
<!-- <form action="{{route('analisa.janadata')}}" method="POST" enctype="multipart/form-data"> -->
<form action="{{route('tetapan.addparameter')}}" method="POST" enctype="multipart/form-data">
@csrf
<div class="form-group row">
{{-- <div class="form-group row">
<label for="tarikh_lelong" class="col-sm-2 col-form-label">Tarikh Lelong</label>
<div class="col-sm-3">
<input type="date" class="form-control" id="tarikh_lelong" name="tarikh_lelong" value = "{{$tetapan ? $tetapan->tetap_tarikh_lelong : ''}}">
</div>
</div>
</div> --}}
<div class="form-group row">
+3
View File
@@ -79,6 +79,9 @@ Route::group(['middleware' => ['permission:analisa'],'prefix'=>'analisa'], funct
Route::get('/kemaskinidata/{simulasi_id}',['as'=>'analisa.kemaskinidata','uses'=>'SimulasiController@kemaskinidata']);
//listsagbycust
Route::get('/listsagbycust/{simulasi_id}/{cawid}',['as'=>'analisa.listsagbycust','uses'=>'SimulasiController@listsagbycust']);
//simulasi all
Route::get('/senaraisimulasiall',['as'=>'analisa.senaraisimulasiall','uses'=>'SimulasiController@senaraisimulasiall']);
Route::get('/showsimulasiall/{kali}',['as'=>'analisa.showsimulasiall','uses'=>'SimulasiController@showsimulasiall']);
});
Route::group(['middleware' => ['permission:sistem'],'prefix'=>'sistem'], function () {