599 lines
18 KiB
PHP
599 lines
18 KiB
PHP
@extends('layouts.app_operasi')
|
|
|
|
@section('content')
|
|
|
|
<div class="modal fade" id="kelulusan_pampasan_modal">
|
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<!-- Modal Header -->
|
|
<div class="modal-header">
|
|
<h4 class="text-center">Maklumat Lanjut</h4>
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
</div>
|
|
<!-- Modal body -->
|
|
<div class="modal-body">
|
|
|
|
<div class="row col-12 text-center">
|
|
<div class="row col-7">
|
|
<label>Nombor Rujukan : </label>
|
|
<span id="norujukan_pampasan"> </span>
|
|
</div>
|
|
</div>
|
|
<div class="row col-12 text-center">
|
|
<div class="row col-7">
|
|
<label>Nama : </label>
|
|
<span id="namalanjut_pampasan"> </span>
|
|
</div>
|
|
|
|
<div class="row col-5">
|
|
<label>Kad Pengenalan : </label>
|
|
<span id="nokplanjut_pampasan"> </span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
<div class="col-12">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<tbody>
|
|
<tr>
|
|
<th class="bg-secondary text-white" scope="row" style="width: 30%;">Nilai Marhun</th>
|
|
<td id="nilaiMarhun">text</td>
|
|
</tr>
|
|
<tr>
|
|
<th class="bg-secondary text-white" scope="row" style="width: 30%;">Baki Pembiayaan</th>
|
|
<td id="pembiayaan"></td>
|
|
</tr>
|
|
<tr>
|
|
<th class="bg-secondary text-white" scope="row" style="width: 30%;">Jumlah Pampasan</th>
|
|
<td id="jumlahPampasan"></td>
|
|
</tr>
|
|
<tr>
|
|
<th class="bg-secondary text-white" scope="row" style="width: 30%;">Keuntungan</th>
|
|
<td id="keuntungan"></td>
|
|
</tr>
|
|
<tr>
|
|
<th class="bg-secondary text-white" scope="row" style="width: 30%;">Ansuran Pembiayaan</th>
|
|
<td id="bayaranAnsuran"></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</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="kelulusanmodal">
|
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<!-- Modal Header -->
|
|
<div class="modal-header">
|
|
<h4 class="text-center">Maklumat Lanjut</h4>
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
</div>
|
|
<!-- Modal body -->
|
|
<div class="modal-body">
|
|
|
|
<div class="row col-12 text-center">
|
|
<div class="row col-7">
|
|
<label>Nama : </label>
|
|
<span id="namalanjut"> </span>
|
|
</div>
|
|
|
|
<div class="row col-5">
|
|
<label>Kad Pengenalan : </label>
|
|
<span id="nokplanjut"> </span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
|
|
<div class="col-lg-6 col-xl-4 col-12">
|
|
<!-- small box -->
|
|
<div class="small-box bg-info">
|
|
<div class="inner">
|
|
<h4 id="pinjterkumpul"></h4>
|
|
<p>Pembiayaan Terkumpul</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-money-bill-wave"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-6 col-xl-4 col-12">
|
|
<!-- small box -->
|
|
<div class="small-box bg-success">
|
|
<div class="inner">
|
|
<h4 id="bilaktif"></h4>
|
|
<p>Pembiayaan Belum Selesai</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-thumbs-up"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-lg-6 col-xl-4 col-12">
|
|
<!-- small box -->
|
|
<div class="small-box bg-danger">
|
|
<div class="inner">
|
|
<h4 id="billelong"></h4>
|
|
<p>Bilangan Lelong</p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="fas fa-gavel"></i>
|
|
</div>
|
|
</div>
|
|
</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="container col-12">
|
|
<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 active" aria-current="page">Kelulusan</li>
|
|
</ol>
|
|
</nav>
|
|
|
|
<div class="card-body text-center">
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-2 justify-content-start">
|
|
</div>
|
|
<div class="col-8 mt-3 justify-content-center">
|
|
</div>
|
|
<div class="col-2">
|
|
</div>
|
|
</div>
|
|
|
|
<table class='table mt-2 table-striped table-hover' id='table-kelulusan' style="width:100%;">
|
|
<thead class="thead-dark">
|
|
<tr>
|
|
<th>No Rujukan</th>
|
|
<th>Cawangan</th>
|
|
<th>Teller</th>
|
|
<th>Komen</th>
|
|
<th>Status</th>
|
|
<th>Nilai Pembiayaan</th>
|
|
<th>Ansuran</th>
|
|
<th>Nilai Marhun</th>
|
|
<th>Berat</th>
|
|
<th>Margin</th>
|
|
<th>Tindakan</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($arraykelulusan as $index=>$k)
|
|
<tr>
|
|
@php
|
|
$targetModal = '#kelulusanmodal';
|
|
$targetModal = strtolower($k['status']) == 'kelulusan pengeluaran pampasan' ? '#kelulusan_pampasan_modal' : $targetModal;
|
|
|
|
@endphp
|
|
<td><a href="#" data-toggle="modal" data-target="{{$targetModal}}" data-kodcawangan="{{ $k['cawangankod'] }}" data-norujukan="{{ $k['norujukan'] }}">{{ $k['norujukan'] }} </a></td>
|
|
<td>{{ $k['cawangan'] }}</td>
|
|
<td>{{ $k['namateller'] }}</td>
|
|
<th>{{ $k['komen'] }}</th>
|
|
<td>{{ $k['status'] }}</td>
|
|
<td>{{ number_format($k['pinjaman'],2) }}</td>
|
|
@if(isset($k['ansuran']) && $k['ansuran'] != 0)
|
|
<td>{{ number_format($k['ansuran'],2) }}</td>
|
|
@else
|
|
<td></td>
|
|
@endif
|
|
<td>{{ $k['nilaimarhun'] }}</td>
|
|
<td>{{ $k['berat'] }}</td>
|
|
<td>{{ $k['margin'] }}</td>
|
|
<td><button class="btn btn-primary mr-2" onclick="updatelulus(this)" data-taglulus="{{ isset($k['mohonid']) ? true : false }}" data-kodcaw="{{ $k['cawangankod'] }}" data-norujukan="{{ $k['norujukan'] }}" data-siri="{{ isset($k['siri']) ? $k['siri'] : $k['recno'] }}" data-status="{{ $k['status'] ?? '' }}"><i class="fas fa-thumbs-up"></i></button>
|
|
<button class="btn btn-danger" onclick="updatebatal(this)" data-taglulus="{{ isset($k['mohonid']) ? true : false }}" data-kodcaw="{{ $k['cawangankod'] }}" data-norujukan="{{ $k['norujukan'] }}" data-siri="{{ isset($k['siri']) ? $k['siri'] : $k['recno'] }}"><i class="fas fa-thumbs-down"></i></button>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="row mt-4 d-flex justify-content-end">
|
|
|
|
<a href="{{ route ('operasi.rekodlepas') }}" class="btn btn-info mr-3">Rekod Lulus</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
var tablekelulusan = $('#table-kelulusan').DataTable({
|
|
"scrollX": true
|
|
});
|
|
|
|
let api = "{{ config('api.url') }}";
|
|
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
minimumFractionDigits: 2
|
|
});
|
|
|
|
var audio = new Audio("{{ asset('sound/3.wav') }}");
|
|
|
|
if (tablekelulusan.data().any()) {
|
|
audio.play();
|
|
audio.addEventListener('ended', function() {
|
|
this.currentTime = 0;
|
|
this.play();
|
|
}, false);
|
|
} else {
|
|
audio.loop = false;
|
|
audio.muted = true;
|
|
}
|
|
|
|
|
|
$('#kelulusanmodal').on('show.bs.modal', function(event) {
|
|
let button = $(event.relatedTarget);
|
|
let norujukan = $(button).data('norujukan');
|
|
let kodcaw = $(button).data('kodcawangan');
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: api + '/api/gadai/norujukan/' + norujukan,
|
|
dataType: 'json',
|
|
success: function(datagadaiwithnorujukan) {
|
|
|
|
let nokp = datagadaiwithnorujukan[0][0].nokp;
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: api + '/api/customers/' + nokp,
|
|
dataType: 'json',
|
|
success: function(datagadaiwithnokp) {
|
|
|
|
let nama = datagadaiwithnokp.nama;
|
|
|
|
$('#namalanjut').text(nama);
|
|
$('#nokplanjut').text(nokp);
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: api + '/api/gadai/customers/' + nokp + '/outstandingsemasa/' + kodcaw,
|
|
dataType: 'json',
|
|
success: function(outstandingsemasa) {
|
|
|
|
$('#pinjterkumpul').text('RM' + formatter.format(outstandingsemasa));
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
var err = eval("(" + xhr.responseText + ")");
|
|
alert(xhr.responseText);
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: api + '/api/customers/' + nokp + '/gadai/belum_tebus',
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
let bilanganaktif = 0;
|
|
if (data == null) {
|
|
bilanganaktif = 0;
|
|
} else {
|
|
bilanganaktif = data[0].length;
|
|
}
|
|
|
|
$('#bilaktif').text(bilanganaktif);
|
|
|
|
|
|
}
|
|
});
|
|
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: api + '/api/customers/' + nokp + '/gadai/lelong',
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
|
|
let bilanganlelong = 0;
|
|
|
|
if (data == null) {
|
|
bilanganlelong = 0;
|
|
} else {
|
|
bilanganlelong = data.length;
|
|
}
|
|
|
|
|
|
$('#billelong').text(bilanganlelong);
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
async function updatelulus(e) {
|
|
|
|
const {
|
|
value: katalaluan
|
|
} = await Swal.fire({
|
|
title: 'Masukkan Katalaluan Semula',
|
|
input: 'password',
|
|
inputPlaceholder: 'Katalaluan',
|
|
confirmButtonText: 'Hantar',
|
|
showCancelButton: true,
|
|
cancelButtonText: 'Batal',
|
|
allowOutsideClick: true
|
|
})
|
|
|
|
let dataminta = '';
|
|
|
|
$.ajax({
|
|
method: 'get',
|
|
url: "{{ route('operasi.getmintasemulakelulusan') }}",
|
|
async: false,
|
|
data: {
|
|
passsemula: katalaluan
|
|
},
|
|
success: function(data) {
|
|
if (data == "False") {
|
|
dataminta = data;
|
|
}
|
|
}
|
|
});
|
|
|
|
if (dataminta == 'False') {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Pengesahan Katalaluan Tidak Berjaya'
|
|
})
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
|
|
// var { value: komenkelulusan } = await Swal.fire({
|
|
// title: 'Masukkan Komen!',
|
|
// input: 'radio',
|
|
// customClass: {
|
|
// input: 'custom-radio'
|
|
// },
|
|
// inputOptions: {
|
|
// 'Pelanggan Baru': 'Pelanggan Baru',
|
|
// 'Pelanggan Tetap': 'Pelanggan Tetap',
|
|
// 'Rekod Gadaian Baik': 'Rekod Gadaian Baik',
|
|
// 'Lain2': 'Lain-Lain'
|
|
// },
|
|
// confirmButtonText: 'Hantar',
|
|
// showCancelButton:false,
|
|
// allowOutsideClick: false
|
|
// })
|
|
|
|
// if(komenkelulusan === 'Lain2')
|
|
// {
|
|
// var { value: komenkelulusan } = await Swal.fire({
|
|
// title: 'Masukkan Komen!',
|
|
// input: 'text',
|
|
// inputPlaceholder: 'Komen',
|
|
// confirmButtonText: 'Hantar',
|
|
// showCancelButton:false,
|
|
// allowOutsideClick: false
|
|
// });
|
|
// }
|
|
|
|
const {
|
|
value: komenkelulusan
|
|
} = await Swal.fire({
|
|
title: 'Masukkan Komen!',
|
|
input: 'text',
|
|
inputPlaceholder: 'Komen',
|
|
confirmButtonText: 'Hantar',
|
|
showCancelButton: false,
|
|
allowOutsideClick: false
|
|
})
|
|
|
|
let norujukan = $(e).data('norujukan');
|
|
let cawangankod = $(e).data('kodcaw');
|
|
let siri = $(e).data('siri');
|
|
let namaoperasi = "{{ Auth::user()->name }}";
|
|
let teller = $(e).closest('tr').children('td:eq(2)').text();
|
|
let taglulus = $(e).data('taglulus');
|
|
let status = $(e).data('status');
|
|
|
|
teller = String(teller);
|
|
|
|
let requestData = {
|
|
"_token": "{{ csrf_token() }}",
|
|
"taglulus": taglulus,
|
|
"norujukan": norujukan,
|
|
"kodcaw": cawangankod,
|
|
"komenkelulusan": komenkelulusan,
|
|
"siri": siri,
|
|
'namaoperasi': namaoperasi,
|
|
'teller': teller
|
|
};
|
|
|
|
if (status === 'Kelulusan Pengeluaran Pampasan') {
|
|
requestData.actions = 'Pengesahan Pembayaran Pampasan';
|
|
}
|
|
|
|
$.ajax({
|
|
method: 'put',
|
|
url: "{{ route('operasi.updatekelulusan') }}",
|
|
data: requestData,
|
|
success: function(data) {
|
|
console.log(data);
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Pengesahan Berjaya'
|
|
}).then(function() {
|
|
location.reload();
|
|
});
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
var err = eval("(" + xhr.responseText + ")");
|
|
alert(xhr.responseText);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
async function updatebatal(e) {
|
|
const {
|
|
value: katalaluan
|
|
} = await Swal.fire({
|
|
title: 'Masukkan Katalaluan Semula',
|
|
input: 'password',
|
|
inputPlaceholder: 'Katalaluan',
|
|
confirmButtonText: 'Hantar',
|
|
showCancelButton: true,
|
|
cancelButtonText: 'Batal',
|
|
allowOutsideClick: true
|
|
})
|
|
|
|
let dataminta = '';
|
|
|
|
$.ajax({
|
|
method: 'get',
|
|
url: "{{ route('operasi.getmintasemulakelulusan') }}",
|
|
async: false,
|
|
data: {
|
|
passsemula: katalaluan
|
|
},
|
|
success: function(data) {
|
|
if (data == "False") {
|
|
dataminta = data;
|
|
}
|
|
}
|
|
});
|
|
|
|
if (dataminta == 'False') {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Pengesahan Katalaluan Tidak Berjaya'
|
|
})
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
|
|
const {
|
|
value: komenkelulusan
|
|
} = await Swal.fire({
|
|
title: 'Masukkan Komen',
|
|
input: 'text',
|
|
inputPlaceholder: 'Komen',
|
|
confirmButtonText: 'Hantar',
|
|
showCancelButton: false,
|
|
allowOutsideClick: false
|
|
})
|
|
|
|
let norujukan = $(e).data('norujukan');
|
|
let siri = $(e).data('siri');
|
|
let cawangankod = $(e).data('kodcaw');
|
|
let namaoperasi = "{{ Auth::user()->name }}";
|
|
let teller = $(e).closest('tr').children('td:eq(2)').text();
|
|
|
|
teller = String(teller);
|
|
|
|
$.ajax({
|
|
method: 'put',
|
|
url: "{{ route('operasi.updatekelulusan') }}",
|
|
data: {
|
|
"_token": "{{ csrf_token() }}",
|
|
"norujukan": norujukan,
|
|
"siri": siri,
|
|
"kodcaw": cawangankod,
|
|
"komenkelulusan": komenkelulusan,
|
|
"pembatalan": "batal",
|
|
'namaoperasi': namaoperasi,
|
|
'teller': teller
|
|
},
|
|
success: function(data) {
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Pengesahan Berjaya'
|
|
}).then(function() {
|
|
location.reload();
|
|
|
|
});
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
var err = eval("(" + xhr.responseText + ")");
|
|
alert(xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#kelulusan_pampasan_modal').on('show.bs.modal', async function(event) {
|
|
const triggerModalButton = event.relatedTarget;
|
|
const norujukan = triggerModalButton.dataset.norujukan;
|
|
const kodcaw = triggerModalButton.dataset.kodcawangan;
|
|
|
|
const pampasan = await fetch(api + `/api/pampasan?norujukan=${norujukan}&kodcaw=${kodcaw}`)
|
|
.then(response => response.json())
|
|
.then(x => x.data.pop());
|
|
|
|
const barangkes = await fetch(api + `/api/palsu/laporan?kodcaw=${kodcaw}`)
|
|
.then(response => response.json())
|
|
.then(x => x.filter(x => x.norujukan == norujukan))
|
|
.then(x => x.pop());
|
|
|
|
const tebus = await fetch(api + `/api/tebus/norujukan/${kodcaw}/${norujukan}`)
|
|
.then(response => response.json())
|
|
.then(x => x[0]);
|
|
|
|
const customer = await fetch(api + `/api/customers/${barangkes.nokp}`)
|
|
.then(response => response.json());
|
|
|
|
const formatMYR = (value) => {
|
|
return new Intl.NumberFormat('ms-MY', {
|
|
style: 'currency',
|
|
currency: 'MYR'
|
|
}).format(value);
|
|
};
|
|
|
|
document.getElementById('norujukan_pampasan').textContent = norujukan;
|
|
document.getElementById('namalanjut_pampasan').textContent = customer.nama;
|
|
document.getElementById('nokplanjut_pampasan').textContent = customer.kpbaru;
|
|
document.getElementById('nilaiMarhun').textContent = formatMYR(barangkes.nilaimarhun);
|
|
document.getElementById('pembiayaan').textContent = formatMYR(barangkes.pembiayaan);
|
|
document.getElementById('jumlahPampasan').innerHTML = '<strong>' + formatMYR(barangkes.nilaimarhun - barangkes.pembiayaan - barangkes.untung) + '</strong>';
|
|
document.getElementById('keuntungan').textContent = formatMYR(barangkes.untung);
|
|
document.getElementById('bayaranAnsuran').textContent = formatMYR(tebus.pinjaman - (tebus.bakipjm - tebus.bakiupah));
|
|
|
|
});
|
|
</script>
|
|
@endsection |