Files
kaunter/resources/views/homepage/penilai/home.blade.php
T
LAPTOP-DGCU80CH\user1 f0cb6e3312 fix gadai teller
2020-12-02 11:43:12 +08:00

214 lines
11 KiB
PHP

@extends('layouts.app')
<!-- The Modal -->
<div class="modal fade" id="marhunModal">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title"></h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<h4>Marhun</h4>
<table id="biasa" class="table table-striped table-bordered text-center" style="width:100%">
<thead>
<tr>
<th>Bil</th>
<th>Jenis Marhun</th>
<th>Berat</th>
<th>Karat</th>
<th>Nilai Marhun</th>
</tr>
</thead>
<tbody id="tablemarhun">
</tbody>
</table>
<div class="row">
<div class="col-md-12 text-center">
<a href="" class="btn btn-primary disabled">Cetak SAG</a>
<a href="" class="btn btn-primary">Pembelian Komuditi</a>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-header">{{ __('Dashboard') }}</div>
<input type="hidden" name="kodcaw" id="kodcaw" value="{{$cawangan_info['kodcaw']}}">
<div class="card-body text-center">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="gadaian-semasa-tab" data-toggle="tab" href="#gadaian-semasa" role="tab" aria-controls="gadaian-semasa" aria-selected="true">Gadaian Semasa</a>
</li>
<li class="nav-item">
<a class="nav-link" id="gadaian-belum-serah-tab" data-toggle="tab" href="#gadaian-belum-serah" role="tab" aria-controls="gadaian-belum-serah" aria-selected="false">Gadaian Belum Serah</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="gadaian-semasa" role="tabpanel" aria-labelledby="gadaian-semasa-tab">
<h4>Gadaian Semasa</h4>
<table class='table' id='table-gadaian-semasa'>
<thead>
<tr>
<th>Bil</th>
<th>No Rujukan</th>
<th>Pembiayaan (RM)</th>
<th>Nilai Marhun (RM)</th>
<th>Berat (g)</th>
</tr>
</thead>
<tbody>
@php $count=1; @endphp
@if (is_array($gadaian_semasa) || is_object($gadaian_semasa))
@foreach($gadaian_semasa as $index=>$gadaian)
<tr>
<td>{{ $count }}</td>
<td>
@php
$marhun = Http::get('http://localhost:8000/api/marhun/' . $gadaian['norujukan'] )->json();
@endphp
<a href="#" data-toggle="modal" data-marhun="{{ json_encode($marhun) }}" data-norujukan="{{$gadaian['norujukan']}}" data-hargajualan="{{$gadaian['hargajualan']}}" data-kodcaw="{{ $gadaian['kodcaw'] }}" data-target="#marhunModal"> {{$gadaian['norujukan']}}</a>
</td>
<td>{{ $gadaian['pinjaman'] }}</td>
<td>{{ $gadaian['nilaimarhun'] }}</td>
<td>{{ $gadaian['berat'] }}</td>
</tr>
@php $count++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
<div class="tab-pane fade" id="gadaian-belum-serah" role="tabpanel" aria-labelledby="gadaian-belum-serah-tab">
<h4>Gadaian Belum Serah</h4>
<table class='table' id='table-gadaian-belum-serah'>
<thead>
<tr>
<th>Bil</th>
<th>No Rujukan</th>
<th>Pembiayaan (RM)</th>
<th>Nilai Marhun (RM)</th>
<th>Berat (g)</th>
</tr>
</thead>
<tbody>
@php $count=1; @endphp
@if (is_array($gadaian_belumserah) || is_object($gadaian_belumserah))
@foreach($gadaian_belumserah as $index=>$gadaian)
<tr>
<td><input type="checkbox" id="checkgadai" autocomplete="off" data-norujukan="{{$gadaian['norujukan']}}" data-kodcaw="{{ $gadaian['kodcaw'] }}" data-marhun="{{$gadaian['nilaimarhun']}}"></input></td>
<td>
@php
$marhun = Http::get('http://localhost:8000/api/marhun/' . $gadaian['norujukan'] )->json();
@endphp
<a href="#" data-toggle="modal" data-marhun="{{ json_encode($marhun) }}" data-norujukan="{{$gadaian['norujukan']}}" data-hargajualan="{{$gadaian['hargajualan']}}" data-kodcaw="{{ $gadaian['kodcaw'] }}" data-target="#marhunModal"> {{$gadaian['norujukan']}}</a>
</td>
<td>{{ $gadaian['pinjaman'] }}</td>
<td>{{ $gadaian['nilaimarhun'] }}</td>
<td>{{ $gadaian['berat'] }}</td>
</tr>
@php $count++; @endphp
@endforeach
@endif
</tbody>
</table>
<div class='row mt-md-3'>
<div class='col-md-12 d-flex justify-content-end form-group'>
Jumlah Nilai Marhun Dipilih
<div class='col-md-3'>
<input type="text" name="marhunpilih" id="marhunpilih" readonly class='form-control'>
</div>
<a href="" class='btn btn-primary'>Serah Marhun</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var api_url = "<?php echo $api_url ?>";
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
window.onload = timedRefresh(60000);
var table_gadaian_semasa = $('#table-gadaian-semasa').DataTable({
"ordering": false
});
var table_gadaian_belum_serah = $('#table-gadaian-belum-serah').DataTable({
"ordering": false
});
const formatter = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2
});
//modal
$('#marhunModal').on('show.bs.modal', function(event) {
var button = $(event.relatedTarget); // button yg trigger
var arraymarhun = button.data('marhun');
var norujukan = button.data('norujukan');
var kodcaw = button.data('kodcaw');
var hargajualan = button.data('hargajualan');
$('#tablemarhun').empty();
$.each(arraymarhun,function(index,marhun){
$.each(marhun, function(index,marhun_detail){
var marhun_name;
$.ajax({
method:'GET',
url: api_url + '/api/jemas/nama_marhun',
dataType: 'json',
data:{
marhun:marhun_detail['marhun']
},
success:function(marhun_ajax){
$("#tablemarhun").append("<tr><td>" + marhun_detail['bil'] + "</td><td>" + marhun_ajax['descpt'] +"</td><td>" + marhun_detail['berat'] +"</td><td>" + marhun_detail['karat'] +"</td><td>RM " + marhun_detail['n_marhun'].toLocaleString(undefined,{minimumFractionDigits:2}) +"</td></tr>");
}
});
});
});
});
var total_marhun_pilih = 0;
$(document).on('click', '#checkgadai', function(e) {
if ($(this).is(':checked')) {
var norujukan = $(this).data("norujukan");
var kodcaw = $(this).data("kodcaw");
var marhun = $(this).data("marhun");
total_marhun_pilih += Number(marhun);
$('#marhunpilih').val(total_marhun_pilih.toFixed(2));
}else {
var norujukan = $(this).data("norujukan");
var kodcaw = $(this).data("kodcaw");
var marhun = $(this).data("marhun");
total_marhun_pilih -= Number(marhun);
$('#marhunpilih').val(total_marhun_pilih.toFixed(2));
}
});
</script>
@endsection