Files
kaunter/resources/views/homepage/penilai/home.blade.php
T
LAPTOP-DGCU80CH\user1 15cf079e2d latest
2020-12-24 10:56:32 +08:00

391 lines
18 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>
<th>Nota</th>
</tr>
</thead>
<tbody id="tablemarhun">
</tbody>
</table>
<div class="row form-group">
<div class="col-md-6 text-right">
<form target="_blank" action="{{ route('printsag') }}" method="post">
@csrf
<input type="text" hidden name="norujukan_modal" id="norujukan_modal">
<input type="submit" class="btn btn-primary" id="cetak_sag" value="Cetak SAG">
</form>
</div>
<div class="col-md-6">
<!-- <button class="btn btn-primary" id="pembelian_komuditi">Pembelian Komuditi</button> -->
<a href="" id="pembelian_komuditi" 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>
<div class="modal fade" id="belum_serah_modal">
<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>
<th>Nota</th>
</tr>
</thead>
<tbody id="belum_serah">
</tbody>
</table>
</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>Nama</th>
<th>No KP</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
$customer_info = Http::get($api_url . '/api/customers/'. $gadaian['nokp'])->json();
echo ($customer_info[0]['nama']);
@endphp
</td>
<td>{{ $gadaian['nokp'] }}</td>
<td>
@php
$marhun = Http::get($api_url . '/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>Nama</th>
<th>No KP</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>
@php
$customer_info = Http::get($api_url . '/api/customers/'. $gadaian['nokp'])->json();
@endphp
<td><input type="checkbox" id="checkgadai" autocomplete="off" data-nokp="{{ $gadaian['nokp'] }}" data-nama="{{ $customer_info[0]['nama'] }}" data-norujukan="{{$gadaian['norujukan']}}" data-kodcaw="{{ $gadaian['kodcaw'] }}" data-marhun="{{$gadaian['nilaimarhun']}}"></input></td>
<td>{{ $customer_info[0]['nama'] }}</td>
<td>{{ $gadaian['nokp'] }}</td>
<td>
@php
$marhun = Http::get($api_url . '/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="#belum_serah_modal"> {{$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>
<form action="{{ route('marhun.serah') }}" method="post">
@csrf
<input type="text" name="norujukanpilih" id="norujukanpilih" hidden>
<button type="submit" id="btn-serah" class='btn btn-primary' disabled>Serah Marhun</button>
</form>
</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(300000);
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
});
// $('#cetak_sag').click(function(){
// var kodcaw = $('#kodcaw').val();
// var norujukan = $('#norujukan_modal').val();
// $.ajax({
// url: api_url + '/api/gadai/norujukan/cetak/'+ kodcaw + '/' + norujukan,
// method: 'put',
// success: function(data){
// Swal.fire({
// icon: 'success',
// title: 'Berjaya!',
// text: 'Cetak SAG Berjaya'
// });
// },
// error: function(xhRequest, ErrorText, thrownError){
// Swal.fire({
// icon: 'error',
// title: 'Amaran!',
// text: 'Cetak SAG Tidak Berjaya'
// });
// console.log(xhRequest);
// }
// });
// });
// $('#pembelian_komuditi').click(function(){
// var kodcaw = $('#kodcaw').val();
// var norujukan = $('#norujukan_modal').val();
// $.ajax({
// url: api_url + '/api/gadai/norujukan/komuditi/'+ kodcaw + '/' + norujukan,
// method: 'put',
// success: function(data){
// Swal.fire({
// icon: 'success',
// title: 'Berjaya!',
// text: 'Pembelian Komuditi Berjaya'
// });
// },
// error: function(xhRequest, ErrorText, thrownError){
// Swal.fire({
// icon: 'error',
// title: 'Amaran!',
// text: 'Pembelian Komuditi Tidak Berjaya'
// });
// console.log(xhRequest);
// }
// });
// });
function cetakSAG(kodcaw,norujukan){
$.ajax({
url: api_url + 'gadai/norujukan/' + kodcaw + '/' + norujukan,
method:'get',
success: function(data){
console.log(data);
}
});
}
//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');
$('#pembelian_komuditi').attr('href','http://bsas-arrahn.test/pembelian/komuditi?norujukan='+norujukan);
$('#norujukan_modal').val(norujukan);
cetakSAG(kodcaw,norujukan);
$('#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><td>"+ marhun_detail['nota'] +"</td></tr>");
}
});
});
});
});
$('#belum_serah_modal').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){
$("#belum_serah").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><td>"+ marhun_detail['nota'] +"</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));
$("#btn-serah").prop('disabled', false);
var norujukanpilih = $('#norujukanpilih').val();
norujukanpilih += norujukan + ",";
$('#norujukanpilih').val(norujukanpilih);
}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));
var norujukanpilih = $('#norujukanpilih').val();
var sag;
sag = norujukan + ",";
norujukanpilih = norujukanpilih.replace('ALS201203-0001,', "");
$('#norujukanpilih').val(norujukanpilih);
}
var legchecked = $('input[id^=checkgadai]:checked').length;
if(legchecked == 0){
$("#btn-serah").prop('disabled', true);
}
});
</script>
@endsection