1.added page that shows margin mutu harga emas.

2. change in gadaian page that have static 75% and 80% max pinjam turn to manipulate value of max pinjam based on mutu emas
This commit is contained in:
Hafifie PKB
2026-03-04 09:40:01 +08:00
parent 66b8f7f195
commit 73db8b97d7
7 changed files with 297 additions and 77 deletions
@@ -317,4 +317,25 @@ class OperasiController extends Controller
$auth_user = Auth::user(); $auth_user = Auth::user();
event(new KomoditiNotify('lulus',$auth_user['cawangan'])); event(new KomoditiNotify('lulus',$auth_user['cawangan']));
} }
public function marginmutu()
{
$auth_user = Auth::user();
$api_url = config('api.url');
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
// Get MaxMutuEmas data from API
$maxmutuemas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/maxmutuemas')->json();
return view('operasi.marginmutu', compact('cawangan_info', 'api_url', 'maxmutuemas'));
}
public function editMarginMutu()
{
$auth_user = Auth::user();
$api_url = config('api.url');
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
return view('operasi.edit_marginmutu', compact('cawangan_info', 'api_url'));
}
} }
@@ -567,6 +567,7 @@
total_berat = 0; total_berat = 0;
total_kuantiti = 0; total_kuantiti = 0;
var marhun_details = ''; var marhun_details = '';
var array_mutu = [];
tablemarhun.clear().draw(); tablemarhun.clear().draw();
$.each(data,function(index,marhun){ $.each(data,function(index,marhun){
$.each(marhun,function(index,marhun_detail){ $.each(marhun,function(index,marhun_detail){
@@ -576,6 +577,7 @@
jumlah_nilai_marhun += Number(marhun_detail['n_marhun']); jumlah_nilai_marhun += Number(marhun_detail['n_marhun']);
status_tag_permata = marhun_detail['tag_permata'] == 1 ? 'Ada' : ''; status_tag_permata = marhun_detail['tag_permata'] == 1 ? 'Ada' : '';
total_kuantiti += Number(marhun_detail['bil']); total_kuantiti += Number(marhun_detail['bil']);
array_mutu.push([marhun_detail['karat'], marhun_detail['n_marhun']]);
tablemarhun.row.add([ tablemarhun.row.add([
counter, counter,
marhun_detail['recno'], marhun_detail['recno'],
@@ -659,6 +661,10 @@
$.ajax({ $.ajax({
method:'GET', method:'GET',
url: api_url + '/api/maxpinjaman', url: api_url + '/api/maxpinjaman',
data: {
'mutu': array_mutu,
'total_nilai_marhun': total_nilai_marhun,
},
success:function(data){ success:function(data){
$.each(data,function(index,pinjaman){ $.each(data,function(index,pinjaman){
+84 -76
View File
@@ -526,60 +526,63 @@
closeOnSelect: false closeOnSelect: false
}); });
var total_nilai_marhun = 0; var total_nilai_marhun = 0;
var total_berat = 0; var total_berat = 0;
var total_kuantiti = 0; var total_kuantiti = 0;
var kadarupah = 0; var kadarupah = 0;
var jumlah_marhun = 0; var jumlah_marhun = 0;
var jumlah_nilai_marhun = 0; var jumlah_nilai_marhun = 0;
var pinjaman_pelulus = 0; var pinjaman_pelulus = 0;
var pinjaman_teller = 0; var pinjaman_teller = 0;
function marhuntable(data){
var counter = 1; function marhuntable(data) {
total_nilai_marhun = 0; var counter = 1;
total_berat = 0; total_nilai_marhun = 0;
total_kuantiti = 0; total_berat = 0;
var marhun_details = ''; total_kuantiti = 0;
jumlah_nilai_marhun = 0; var marhun_details = '';
tablemarhun.clear().draw(); var array_mutu = [];
$.each(data,function(index,marhun){ jumlah_nilai_marhun = 0;
$.each(marhun,function(index,marhun_detail){ tablemarhun.clear().draw();
total_nilai_marhun = total_nilai_marhun + Number(marhun_detail['n_marhun']); $.each(data, function(index, marhun) {
total_berat = total_berat + Number(marhun_detail['berat']); $.each(marhun, function(index, marhun_detail) {
marhun_details = marhun_details + marhun_detail['bil'] + " " + marhun_detail['marhun'] +","; total_nilai_marhun = total_nilai_marhun + Number(marhun_detail['n_marhun']);
jumlah_nilai_marhun += Number(marhun_detail['n_marhun']); total_berat = total_berat + Number(marhun_detail['berat']);
status_tag_permata = marhun_detail['tag_permata'] == 1 ? 'Ada' : ''; marhun_details = marhun_details + marhun_detail['bil'] + " " + marhun_detail['marhun'] + ",";
total_kuantiti += Number(marhun_detail['bil']); jumlah_nilai_marhun += Number(marhun_detail['n_marhun']);
tablemarhun.row.add([ status_tag_permata = marhun_detail['tag_permata'] == 1 ? 'Ada' : '';
counter, total_kuantiti += Number(marhun_detail['bil']);
marhun_detail['recno'], array_mutu.push([marhun_detail['karat'], marhun_detail['n_marhun']]);
marhun_detail['marhun'], tablemarhun.row.add([
formatter.format(marhun_detail['n_marhun']), counter,
marhun_detail['karat'], marhun_detail['recno'],
formatter.format(marhun_detail['berat']), marhun_detail['marhun'],
marhun_detail['bil'], formatter.format(marhun_detail['n_marhun']),
marhun_detail['nota'], marhun_detail['karat'],
marhun_detail['harga'], formatter.format(marhun_detail['berat']),
status_tag_permata, marhun_detail['bil'],
marhun_detail['berat_batu_permata'], marhun_detail['nota'],
"<div class='buttonpunya text-center'><button onclick='editmarhun(this)' class='btn btn-primary'><i class='fas fa-edit'></i></button> <button onclick='deletemarhun(this)' class='btn btn-danger'><i class='fas fa-trash-alt'></i></button></div>" marhun_detail['harga'],
]).draw(); status_tag_permata,
counter = counter + 1; marhun_detail['berat_batu_permata'],
"<div class='buttonpunya text-center'><button onclick='editmarhun(this)' class='btn btn-primary'><i class='fas fa-edit'></i></button> <button onclick='deletemarhun(this)' class='btn btn-danger'><i class='fas fa-trash-alt'></i></button></div>"
]).draw();
counter = counter + 1;
});
}); });
}); $('#totalberattable').text(formatter.format(total_berat));
$('#totalberattable').text(formatter.format(total_berat)); $('#totalkuantititable').text(total_kuantiti);
$('#totalkuantititable').text(total_kuantiti); $('#totalnilaimarhuntable').text(formatter.format(jumlah_nilai_marhun));
$('#totalnilaimarhuntable').text(formatter.format(jumlah_nilai_marhun)); $('#bilangan_marhun').val(formatter.format(counter - 1));
$('#bilangan_marhun').val(formatter.format(counter-1)); $('#bilangan_jumlah_kuantiti').val(formatter.format(total_kuantiti));
$('#bilangan_jumlah_kuantiti').val(formatter.format(total_kuantiti)); $('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun)); // if(total_nilai_marhun > 0 && total_nilai_marhun < 401){
// if(total_nilai_marhun > 0 && total_nilai_marhun < 401){ // kadarupah = 1.2/100;
// kadarupah = 1.2/100; // }else if(total_nilai_marhun >= 401 && total_nilai_marhun < 2001){
// }else if(total_nilai_marhun >= 401 && total_nilai_marhun < 2001){ // kadarupah = 1.5/100;
// kadarupah = 1.5/100; // }else if(total_nilai_marhun >= 2001 ){
// }else if(total_nilai_marhun >= 2001 ){ // kadarupah = 1.7/100;
// kadarupah = 1.7/100; // }
// }
$.ajax({ $.ajax({
method:'GET', method:'GET',
@@ -600,27 +603,31 @@
$('#kadarkeuntungan').val(formatter.format(kadarupah)); $('#kadarkeuntungan').val(formatter.format(kadarupah));
$('#kuantiti_marhun').val(formatter.format(jumlah_marhun)); $('#kuantiti_marhun').val(formatter.format(jumlah_marhun));
$.ajax({ $.ajax({
method:'GET', method: 'GET',
url: api_url + '/api/maxpinjaman', url: api_url + '/api/maxpinjaman',
success:function(data){ data: {
$.each(data,function(index,pinjaman){ 'mutu': array_mutu,
if(pinjaman['user_type'] == 'teller'){ 'total_nilai_marhun': total_nilai_marhun,
pinjaman_teller = Number(pinjaman['max']); },
} success: function(data) {
if(pinjaman['user_type'] == 'khazanah'){ $.each(data, function(index, pinjaman) {
pinjaman_pelulus = Number(pinjaman['max']); if (pinjaman['user_type'] == 'teller') {
} pinjaman_teller = Number(pinjaman['max']);
}); }
$('.span-pinjaman-max-pelulus').text(formatter.format(pinjaman_pelulus) + ' %'); if (pinjaman['user_type'] == 'khazanah') {
$('.span-pinjaman-max').text(formatter.format(pinjaman_teller) + ' %'); pinjaman_pelulus = Number(pinjaman['max']);
var max_teller = total_nilai_marhun * (pinjaman_teller/100); }
var max_pelulus = total_nilai_marhun * (pinjaman_pelulus/100); });
$('#pembiayaan_max_teller').val(formatter.format(max_teller.toFixed(2))); $('.span-pinjaman-max-pelulus').text(formatter.format(pinjaman_pelulus) + ' %');
$('#pembiyaan_max_pelulus').val(formatter.format(max_pelulus.toFixed(2))); $('.span-pinjaman-max').text(formatter.format(pinjaman_teller) + ' %');
} var max_teller = total_nilai_marhun * (pinjaman_teller / 100);
}); var max_pelulus = total_nilai_marhun * (pinjaman_pelulus / 100);
} $('#pembiayaan_max_teller').val(formatter.format(max_teller.toFixed(2)));
$('#pembiyaan_max_pelulus').val(formatter.format(max_pelulus.toFixed(2)));
}
});
}
$('#pinjaman').on('input',function(){ $('#pinjaman').on('input',function(){
var pinjaman = Number(this.value); var pinjaman = Number(this.value);
@@ -859,8 +866,9 @@
var batu_permata_array = $('#batupermata').val(); var batu_permata_array = $('#batupermata').val();
var tag_permata = $('input[id=tagpermata]').is(':checked') ? 1 : 0; var tag_permata = $('input[id=tagpermata]').is(':checked') ? 1 : 0;
var beratpermata = $('#beratpermata').val(); var beratpermata = $('#beratpermata').val();
var kuantiti = $('#kuantiti').val(); var kuantiti = $('#kuantiti').val();
if(kuantiti > 10) if(kuantiti > 10)
{ {
@@ -0,0 +1,119 @@
@extends('layouts.app_operasi')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<nav aria-label="breadcrumb">
<ol class="breadcrumb pb-3">
<li class="breadcrumb-item"><a href="{{ url('/') }}">Home</a></li>
<li class="breadcrumb-item"><a href="{{ url('operasi/parameter') }}">Parameter</a></li>
<li class="breadcrumb-item"><a href="{{ url('operasi/marginmutu') }}">Margin Mutu Emas</a></li>
<li class="breadcrumb-item active" aria-current="page">Edit Margin Mutu</li>
</ol>
</nav>
<div class="card-body">
<h4 class="text-center mb-4">Edit Margin Mutu Emas</h4>
<form id="editMarginForm">
@csrf
<input type="hidden" id="recno" name="recno">
<div class="form-group">
<label for="karat">Karat</label>
<input type="text" class="form-control" id="karat" name="karat" readonly>
</div>
<div class="form-group">
<label for="keterangan">Keterangan</label>
<input type="text" class="form-control" id="keterangan" name="keterangan" readonly>
</div>
<div class="form-group">
<label for="teller">Teller (%)</label>
<input type="number" step="0.01" class="form-control" id="teller" name="teller" required>
</div>
<div class="form-group">
<label for="pc">PC (%)</label>
<input type="number" step="0.01" class="form-control" id="pc" name="pc" required>
</div>
<div class="form-group">
<label for="operasi">Operasi (%)</label>
<input type="number" step="0.01" class="form-control" id="operasi" name="operasi" required>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Update</button>
<a href="{{ route('operasi.marginmutu') }}" class="btn btn-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
// Get data from URL parameters
const urlParams = new URLSearchParams(window.location.search);
$('#recno').val(urlParams.get('recno'));
$('#karat').val(urlParams.get('karat'));
$('#keterangan').val(urlParams.get('keterangan'));
$('#teller').val(urlParams.get('teller'));
$('#pc').val(urlParams.get('pc'));
$('#operasi').val(urlParams.get('operasi'));
$('#editMarginForm').on('submit', function(e) {
e.preventDefault();
const formData = {
recno: $('#recno').val(),
karat: $('#karat').val(),
keterangan: $('#keterangan').val(),
teller: $('#teller').val(),
pc: $('#pc').val(),
operasi: $('#operasi').val(),
_token: $('input[name="_token"]').val()
};
$.ajax({
url: '{{ config("api.url") }}/api/maxmutuemas/update',
type: 'POST',
data: formData,
success: function(response) {
if(response.status === 'success') {
Swal.fire({
title: 'Berjaya!',
text: 'Data berhasil diupdate!',
icon: 'success',
confirmButtonText: 'OK'
}).then((result) => {
window.location.href = '{{ route("operasi.marginmutu") }}';
});
} else {
Swal.fire({
title: 'Error!',
text: response.message,
icon: 'error',
confirmButtonText: 'OK'
});
}
},
error: function(xhr) {
Swal.fire({
title: 'Error!',
text: 'Error updating data: ' + xhr.responseText,
icon: 'error',
confirmButtonText: 'OK'
});
}
});
});
});
</script>
@endsection
@@ -0,0 +1,64 @@
@extends('layouts.app_operasi')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<nav aria-label="breadcrumb">
<ol class="breadcrumb pb-3">
<li class="breadcrumb-item"><a href="{{ url('/') }}">Home</a></li>
<li class="breadcrumb-item"><a href="{{ url('operasi/parameter') }}">Parameter</a></li>
<li class="breadcrumb-item active" aria-current="page">Margin Mutu Emas</li>
</ol>
</nav>
<div class="card-body text-center">
<div class="mt-3">
<table class='table table-striped table-hover' id='table-marginmutu' style="width:100%;">
<thead class="thead-dark">
<tr>
<th>Bil</th>
<th>Karat</th>
<th>Keterangan</th>
<th>Teller (%)</th>
<th>PC (%)</th>
<th>Operasi (%)</th>
<th>Tarikh Update</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@foreach($maxmutuemas as $index=>$mme)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $mme['karat'] }}</td>
<td>{{ $mme['keterangan'] }}</td>
<td>{{ $mme['teller'] }}%</td>
<td>{{ $mme['pc'] }}%</td>
<td>{{ $mme['operasi'] }}%</td>
<td>{{ \Carbon\Carbon::parse($mme['tarikhupdate'])->format('d/m/Y') }}</td>
<td>
<a href="{{ route('operasi.marginmutu.edit') }}?recno={{ $mme['recno'] }}&karat={{ $mme['karat'] }}&keterangan={{ $mme['keterangan'] }}&teller={{ $mme['teller'] }}&pc={{ $mme['pc'] }}&operasi={{ $mme['operasi'] }}"
class="btn btn-sm btn-warning">Edit</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var table_marginmutu = $('#table-marginmutu').DataTable({
"pageLength": 25,
"order": [[ 0, "asc" ]]
});
</script>
@endsection
+1 -1
View File
@@ -16,7 +16,7 @@
<div class="card-body text-center"> <div class="card-body text-center">
<a href="{{ route('operasi.hargaemas') }}" class="btn btn-info btn-lg">Harga Emas</a> <a href="{{ route('operasi.hargaemas') }}" class="btn btn-info btn-lg">Harga Emas</a>
<a href="{{ route('operasi.margin') }}" class="btn btn-info btn-lg">Margin Pembiayaan</a> <a href="{{ route('operasi.margin') }}" class="btn btn-info btn-lg">Margin Pembiayaan</a>
<a href="#" class="btn btn-info btn-lg">Contoh 2</a> <a href="{{ route('operasi.marginmutu') }}" class="btn btn-info btn-lg">Margin Mutu Emas</a>
</div> </div>
</div> </div>
</div> </div>
+2
View File
@@ -360,6 +360,8 @@ Route::post('operasi/kakitangan/edit/store',['as'=>'operasi.kakitangan.edit.stor
Route::get('/operasi/margin',['as'=>'operasi.margin','uses'=>'OperasiController@margin'])->middleware('auth','operasi'); Route::get('/operasi/margin',['as'=>'operasi.margin','uses'=>'OperasiController@margin'])->middleware('auth','operasi');
Route::get('/operasi/marginmutu',['as'=>'operasi.marginmutu','uses'=>'OperasiController@marginmutu'])->middleware('auth','operasi');
Route::get('/operasi/marginmutu/edit',['as'=>'operasi.marginmutu.edit','uses'=>'OperasiController@editMarginMutu'])->middleware('auth','operasi');
Route::get('/komoditi',['as'=>'komuditi','uses'=>'KomuditiController@index']); Route::get('/komoditi',['as'=>'komuditi','uses'=>'KomuditiController@index']);
Route::get('/komoditi/rekod',['as'=>'rekod.komoditi','uses'=>'KomuditiController@rekodKomoditi']); Route::get('/komoditi/rekod',['as'=>'rekod.komoditi','uses'=>'KomuditiController@rekodKomoditi']);