Merged in cherrypick/update_button_terima_gadai (pull request #174)

Cherrypick/update button terima gadai
This commit is contained in:
nurulnisha muhammad
2024-07-08 14:09:40 +00:00
committed by Muhd hafifie
3 changed files with 818 additions and 549 deletions
+4 -1
View File
@@ -155,7 +155,10 @@ class GadaianController extends Controller
public function store(Request $request){
$auth_user = Auth::user();
$total_nilai_marhun = $request->total_nilai_marhun;
//$total_nilai_marhun = $request->total_nilai_marhun;
//need to get total nilai marhun by api get from table marhun
$marhun = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/marhun/gadai/'. $auth_user['cawangan'] .'/'. $request->norujukan_gadai)->json();
$total_nilai_marhun = $marhun;
$total_nilai_marhun = str_replace(',','',$total_nilai_marhun);
$keuntungan_sebln = $request->keuntungan_sebulan;
$keuntungan_sebln = str_replace(',','',$keuntungan_sebln);
+442 -313
View File
@@ -507,47 +507,70 @@
return false;
}else{
if(bilangan_marhun_daftar<10){
//new added 190624 filter if gadaian already exist pinjaman not null
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
$('#daftar_marhun').modal('hide');
jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan);
},
error: function(xhRequest, ErrorText, thrownError){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Tambah Marhun Tidak Berjaya'
});
console.log(xhRequest);
}
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
$('#daftar_marhun').modal('hide');
jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan);
},
error: function(xhRequest, ErrorText, thrownError){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Tambah Marhun Tidak Berjaya'
});
console.log(xhRequest);
}
});
}
}
});
}else{
$("#tambah_marhun").prop('disabled', false);
@@ -619,47 +642,71 @@
return false;
}else{
if(bilangan_marhun_daftar < 10){
//new added 190624 filter if gadaian already registered pinjaman > 0
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan);
},
error: function(xhRequest, ErrorText, thrownError){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Tambah Marhun Tidak Berjaya'
});
console.log(xhRequest);
}
});
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan);
},
error: function(xhRequest, ErrorText, thrownError){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Tambah Marhun Tidak Berjaya'
});
console.log(xhRequest);
}
});
}
}
});
//end new added 190624
}else{
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
@@ -797,258 +844,340 @@
}
else{
if(pinjaman >= 10000 && pinjaman <= Number(pembiyaan_max_pelulus)){
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
if(pinjaman > Number(pembiyaan_max_pelulus)){
var errortext = "Tetapan margin melebihi " + pinjaman_pelulus + "% untuk Operasi!";
}
if(pinjaman >= 10000){
var errortext = "Pinjaman Melebihi 10,000";
}
//new added
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Operasi',
text: errortext,
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = errortext;
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah-Operasi.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('operasi.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
success:function(data)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan',
text: `Komen : ${data.komen}`
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan',
text: `Komen : ${data.komen}`
}).then(function(){
$("#terima_gadai").prop('disabled', false);
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#terima_gadai").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
//insert code asal
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
if(pinjaman > Number(pembiyaan_max_pelulus)){
var errortext = "Tetapan margin melebihi " + pinjaman_pelulus + "% untuk Operasi!";
}
if(pinjaman >= 10000){
var errortext = "Pinjaman Melebihi 10,000";
}
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Operasi',
text: errortext,
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = errortext;
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah-Operasi.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('operasi.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan',
text: `Komen : ${data.komen}`
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan',
text: `Komen : ${data.komen}`
}).then(function(){
$("#terima_gadai").prop('disabled', false);
return false;
});
}
}
});
}else if (result.dismiss === Swal.DismissReason.cancel){
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end insert code asal
}
}
});
}else if (result.dismiss === Swal.DismissReason.cancel){
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end new added
}else if(pinjaman > Number(pembiayaan_max_teller)){
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
//new added
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Khazanah',
text: "Tetapan margin melebihi " + pinjaman_teller + "% untuk Khazanah!",
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = "Pembiayaan Melebihi Margin " + pinjaman_teller + "%";
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('khazanah.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
//Try Pusher
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
// let message = JSON.stringify(data);
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
success:function(data)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan'
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan'
}).then(function(){
$("#terima_gadai").prop('disabled', false);
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#terima_gadai").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
//insert code asal
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Khazanah',
text: "Tetapan margin melebihi " + pinjaman_teller + "% untuk Khazanah!",
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = "Pembiayaan Melebihi Margin " + pinjaman_teller + "%";
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('khazanah.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
//Try Pusher
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
// let message = JSON.stringify(data);
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan'
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan'
}).then(function(){
$("#terima_gadai").prop('disabled', false);
return false;
});
}
}
});
} else if (result.dismiss === Swal.DismissReason.cancel) {
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end insert code asal
}
}
});
} else if (result.dismiss === Swal.DismissReason.cancel) {
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end new added
}
else if( pinjaman < 10000 && pinjaman <= Number(pembiayaan_max_teller)){
Swal.fire({
icon: 'success',
title: 'Berjaya!',
text: 'Gadaian Berjaya Disimpan'
});
//new added
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#terima_gadai").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
Swal.fire({
icon: 'success',
title: 'Berjaya!',
text: 'Gadaian Berjaya Disimpan'
});
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
}
}
});
//end new added
}
}
}
+372 -235
View File
@@ -723,7 +723,28 @@
}
if(bilangan_marhun_daftar<10){
//new added 190624 filter if gadaian already exist pinjaman not null
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
@@ -776,6 +797,12 @@
console.log(xhRequest);
}
});
}
}
});
//end new added 190624
}else{
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
@@ -871,7 +898,28 @@
}
if(bilangan_marhun_daftar < 10){
//new added 190624 filter if gadaian already registered pinjaman > 0
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
@@ -926,6 +974,12 @@
console.log(xhRequest);
}
});
}
}
});
//end new added 190624
}else{
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
@@ -1169,258 +1223,341 @@
}
else{
if(pinjaman >= 10000 && pinjaman <= Number(pembiyaan_max_pelulus)){
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
//new added
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
if(pinjaman > Number(pembiyaan_max_pelulus)){
var errortext = "Tetapan margin melebihi " + pinjaman_pelulus + "% untuk Operasi!";
}
if(pinjaman >= 10000){
var errortext = "Pinjaman Melebihi 10,000";
}
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Operasi',
text: errortext,
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = errortext;
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah-Operasi.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('operasi.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
success:function(data)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan',
text: `Komen : ${data.komen}`
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan',
text: `Komen : ${data.komen}`
}).then(function(){
$("#terima_gadai").prop('disabled', false);
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#terima_gadai").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
//insert code asal
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
if(pinjaman > Number(pembiyaan_max_pelulus)){
var errortext = "Tetapan margin melebihi " + pinjaman_pelulus + "% untuk Operasi!";
}
if(pinjaman >= 10000){
var errortext = "Pinjaman Melebihi 10,000";
}
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Operasi',
text: errortext,
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = errortext;
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah-Operasi.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('operasi.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan',
text: `Komen : ${data.komen}`
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan',
text: `Komen : ${data.komen}`
}).then(function(){
$("#terima_gadai").prop('disabled', false);
return false;
});
}
}
});
}else if (result.dismiss === Swal.DismissReason.cancel){
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end insert code asal
}
}
});
}else if (result.dismiss === Swal.DismissReason.cancel){
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end new added
}else if(pinjaman > Number(pembiayaan_max_teller)){
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
//new added
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Khazanah',
text: "Tetapan margin melebihi " + pinjaman_teller + "% untuk Khazanah!",
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = "Pembiayaan Melebihi Margin " + pinjaman_teller + "%";
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('khazanah.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
//Try Pusher
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
// let message = JSON.stringify(data);
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
success:function(data)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan'
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan'
}).then(function(){
$("#terima_gadai").prop('disabled', false);
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#terima_gadai").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
});
} else {
//insert code asal
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
swalWithBootstrapButtons.fire({
title: 'Dapatkan Pengesahan Khazanah',
text: "Tetapan margin melebihi " + pinjaman_teller + "% untuk Khazanah!",
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Hantar',
cancelButtonText: 'Batal',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
let norujukan = $('#norujukan').val();
let nm = parseFloat($('#total_nilai_marhun').val().replace(/[^0-9.-]+/g,""));let ber = $('#total_berat').val();let marg = $('.span-pinjaman').text();
let status = "Pembiayaan Melebihi Margin " + pinjaman_teller + "%";
let jumpinjam = $('#pinjaman').val();
let teller = "{{ Auth::user()->name }}";
Swal.fire({
title: 'Tunggu Pengesahan Daripada Khazanah.',
icon: 'info',
width: 600,
padding: '3em',
background: '#fffff',
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
})
let siricreated = 0;
$.ajax({
method:'post',
url: "{{ route('khazanah.createkelulusan') }}",
data: {
"_token": "{{ csrf_token() }}",
"norujukan" : norujukan,
"komen" : '',
"margin" : marg,
"berat" : ber,
"nilaimarhun" : nm,
"status" : status,
"jumpinjam" : jumpinjam,
"teller" : teller
},
success:function(data){
siricreated = data;
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
//Try Pusher
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('notice-kelulusan');
channel.bind('my-kelulusan', function(data) {
// let message = JSON.stringify(data);
if(data.norujukan == norujukan && data.siri == siricreated && data.teller == teller)
{
if(data.kelulusan == 'lulus')
{
Swal.fire({
icon: 'success',
title: 'Telah Disahkan'
}).then(function(){
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
});
}
else if(data.kelulusan == 'batal')
{
Swal.fire({
icon: 'warning',
title: 'Telah Dibatalkan'
}).then(function(){
$("#terima_gadai").prop('disabled', false);
return false;
});
}
}
});
} else if (result.dismiss === Swal.DismissReason.cancel) {
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end insert code asal
}
}
});
} else if (result.dismiss === Swal.DismissReason.cancel) {
$("#terima_gadai").prop('disabled', false);
swalWithBootstrapButtons.fire(
'Batal',
'Maklumat Gadaian Tidak Berjaya Disimpan',
'error'
)
}
});
event.preventDefault();
return false;
//end new added
}
else if( pinjaman < 10000 && pinjaman <= Number(pembiayaan_max_teller)){
Swal.fire({
icon: 'success',
title: 'Berjaya!',
text: 'Gadaian Berjaya Disimpan'
});
//new added
$.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#terima_gadai").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
//insert code asal
Swal.fire({
icon: 'success',
title: 'Berjaya!',
text: 'Gadaian Berjaya Disimpan'
});
$(func).attr("onSubmit","return true;");
$(func).submit();
return true;
//end insert code asal
}
}
});
//end new added
}
}
}