add feature search name and middleware changes to fix the resit for khazanah

This commit is contained in:
Hafifie PKB
2024-04-02 01:43:20 +08:00
parent 86e16ec1d4
commit 3180b0b10b
21 changed files with 4769 additions and 93 deletions
+6 -2
View File
@@ -9,7 +9,7 @@
</style>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-10">
<nav aria-label="breadcrumb">
<ol class="breadcrumb pb-3">
@@ -18,6 +18,8 @@
</ol>
</nav>
<input type="hidden" id="roles_avatar" value="{{ Auth::user()->roles }}"></input>
<div class="card">
<div class="card-body">
<div class="text-center">
@@ -26,11 +28,12 @@
<div class="row justify-content-center">
<div class="col-md-9">
<div class="input-group my-3">
<input type="text" class="form-control" id="noic" name="noic" placeholder="No Kad Pengenalan Pelanggan" aria-label="No Kad Pengenalan Pelanggan" autocomplete="off" value="{{$search == false ? '' : $noic ?? ''}}" aria-describedby="button-addon2">
<input type="text" class="typeahead form-control" id="noic" name="noic" placeholder="No Kad Pengenalan Pelanggan" aria-label="No Kad Pengenalan Pelanggan" autocomplete="off" value="{{$search == false ? '' : $noic ?? ''}}" aria-describedby="button-addon2">
<div class="input-group-append">
<select class="form-select" id="customerIDType" name="customerIDType" class="form-control">
<option value="nokp" {{ $idtype == 'nokp' ? 'selected' : ''}}>Kad Pengenalan</option>
<option value="passport" {{ $idtype == 'passport' ? 'selected' : ''}}>Passport</option>
<option value="name">Nama</option>
</select>
</div>
<div class="input-group-append">
@@ -305,6 +308,7 @@
</div>
</div>
</div>
<script src="{{ asset('js/searchName.js') }}"></script>
<script>
var api_url = "<?php echo $api_url ?>";
var search = "<?php echo $search ?>";
@@ -338,8 +338,15 @@
function triggersubmit()
{
Swal.fire({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
didOpen: function () {
Swal.showLoading();
}
});
$("#terima_transaksi").prop('disabled', true);
$('#form-pendahuluan').trigger('submit');
}
@@ -358,6 +365,16 @@
'no' : nom,
'kodlaluan' : teller
},
beforeSend: function(){
Swal.fire({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
didOpen: function () {
Swal.showLoading();
}
});
},
success:function(data){
window.location.href = "{{ route('khazanah.serahan') }}";
}
@@ -344,6 +344,14 @@
function triggersubmit()
{
Swal.fire({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
didOpen: function () {
Swal.showLoading();
}
});
$("#lulus_btn").prop('disabled', true);
$('#form-pendahuluan').trigger('submit');
}
@@ -363,6 +371,16 @@
'no' : nom,
'kodlaluan' : teller
},
beforeSend: function(){
Swal.fire({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
didOpen: function () {
Swal.showLoading();
}
});
},
success:function(data){
window.location.href = "{{ route('khazanah.pendahulu') }}";
}
+59 -17
View File
@@ -498,6 +498,30 @@
minimumFractionDigits: 2
});
async function checkPS(norujukan){
let gadai_tawarruq = fetch(api_url + '/api/gadai/norujukan/' + norujukan );
return response = await gadai_tawarruq
.then(response => response.json())
.then(response => response[0][0])
.then(gadaian => {
return { historygadaian: gadaian.historygadaian, tag_tebus: gadaian.tag_tebus };
})
.then(data => {
if(data.historygadaian == '0' || data.historygadaian === null || data.historygadaian.length === 0) {
return false;
}else{
if(data.tag_tebus == 'AT'){
return true;
}else{
return false;
}
}
return true;
})
}
function checkserah(data){
var urlpenebusan = $(data).data("url");
var norujukan = $(data).data("norujukan");
@@ -540,7 +564,7 @@ $.each(data,function(index,gadai_detail){
},
success:function(upahsemasa){
if(jenistebus == "belum_tebus"){
var urlroute = '{{ route("penebusan.khazanah", ":id") }}';
var urlroute = '{{ route("penebusan", ":id") }}';
urlroute = urlroute.replace(':id', gadai_detail["norujukan"]);
if(gadai_detail['lelong_tawarruq'] == 0){
@@ -580,11 +604,11 @@ $.each(data,function(index,gadai_detail){
}
let table_norujukan = gadai_detail["norujukan"];
let radio_action = "onclick=checkCanChangeGadaianDetail(" + "'" + table_norujukan + "'" + ")";
// let radio_action = "onclick=checkCanChangeGadaianDetail(" + "'" + table_norujukan + "'" + ")";
if(gadai_detail["percentpinj"] != 0)
xtawarruq.row.add([
'<input type="radio" value='+ gadai_detail["norujukan"] + ' ' + radio_action +' name="belum"/>',
'<input type="radio" value='+ gadai_detail["norujukan"] + ' name="belum"/>',
'<a href="#" onclick="checkserah(this)" data-pinjaman='+ gadai_detail['pinjaman'] +' data-hargajualan='+ gadai_detail['hargajualan'] +' data-norujukan='+ gadai_detail['norujukan'] +' data-url=' + urlroute +'>' + gadai_detail['norujukan'] + '</a>',
gadai_detail['t_gadai'],
tarikh_matang,
@@ -625,9 +649,9 @@ $.each(data,function(index,gadai_detail){
}
let table_norujukan = gadai_detail["norujukan"];
let radio_action = "onclick=checkCanChangeGadaianDetail(" + "'" + table_norujukan + "'" + ")";
// let radio_action = "onclick=checkCanChangeGadaianDetail(" + "'" + table_norujukan + "'" + ")";
tablegadai.row.add([
'<input type="radio" value='+ gadai_detail["norujukan"] + ' ' + radio_action +' name="belum"/>',
'<input type="radio" value='+ gadai_detail["norujukan"] + ' name="belum"/>',
'<a href="#" onclick="checkserah(this)" data-pinjaman='+ gadai_detail['pinjaman'] +' data-hargajualan='+ gadai_detail['hargajualan'] +' data-norujukan='+ gadai_detail['norujukan'] +' data-url=' + urlroute +'>' + gadai_detail['norujukan'] + '</a>',
gadai_detail['t_gadai'],
tarikh_matang,
@@ -775,7 +799,7 @@ $.each(data,function(index,gadai_detail){
});
});
function histfunc(){
async function histfunc(){
if($("input[name='options']:checked").val() == 'belum_tebus'){
let histid = $('input[name="belum"]:checked').val();
if(histid == null){
@@ -785,14 +809,26 @@ $.each(data,function(index,gadai_detail){
text: 'Sila pilih salah satu SAG'
});
}else{
Swal.fire({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
didOpen: function () {
Swal.showLoading()
}
});
let checkps = await checkPS(histid);
$.ajax({
method:'get',
url:'{{ route("gadai.history.khazanah") }}',
data:{ "norujukan" : histid},
success:function(data)
{
Swal.close();
$('#historytebusModal').modal();
historytebustable(data);
historytebustable(data,checkps);
},error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
@@ -802,7 +838,7 @@ $.each(data,function(index,gadai_detail){
method: 'get',
url: api_url + '/api/transaction/' + histid,
success: function(data){
historybayarantable(data);
historybayarantable(data,checkps);
}
});
$.ajax({
@@ -816,6 +852,8 @@ $.each(data,function(index,gadai_detail){
}else if($("input[name='options']:checked").val() == 'sudah_tebus'){
let histid = $('input[name="sudahtebus"]:checked').val();
let checkps = await checkPS(histid);
if(histid == null){
Swal.fire({
icon: 'error',
@@ -830,7 +868,7 @@ $.each(data,function(index,gadai_detail){
data:{ "norujukan" : histid},
success:function(data){
$('#historytebusModal').modal();
historytebustable(data);
historytebustable(data,checkps);
},error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
@@ -921,7 +959,6 @@ $.each(data,function(index,gadai_detail){
{
var count = Object.keys(data).length;
console.log(histid);
if(count > 0)
{
Swal.fire({
@@ -1053,13 +1090,12 @@ $.each(data,function(index,gadai_detail){
"ordering": false
});
function historytebustable(data){
function historytebustable(data,checkps = false){
var counter = 1;
historytebusbayaran.clear().draw();
$.each(data,function(index,tebusaz){
switch(tebusaz['jenistebus']) {
case 'P':
var urlroute = '{{ route("resit.khazanah.tambahpinjam", ":id") }}';
@@ -1074,11 +1110,19 @@ $.each(data,function(index,gadai_detail){
}else{
if(tebusaz['historygadaian'] != '' || tebusaz['historygadaian'] != 0 || tebusaz['historygadaian'] != null){
// if(tebusaz['historygadaian'] != '' || tebusaz['historygadaian'] != 0 || tebusaz['historygadaian'] != null){
// var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
// urlroute = urlroute.replace(':id', tebusaz['norujukan']);
// }else{
// var urlroute = '{{ route("resit.khazanah.tebus", ":id") }}';
// urlroute = urlroute.replace(':id', tebusaz['norujukan']);
// }
if(checkps){
var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
}else{
var urlroute = '{{ route("resit.khazanah.tebus", ":id") }}';
var urlroute = '{{ route("resit.tebus", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
}
@@ -1098,7 +1142,7 @@ $.each(data,function(index,gadai_detail){
historytebusbayaran.row.add([
counter,
tebusaz['norujukan'],
tebusaz['jenistebus'],
(checkps && tebusaz['jenistebus'] == 'A') ? 'PS' : (tebusaz['jenistebus'] == 'A') ? 'PS' : tebusaz['jenistebus'],
tebusaz['pinjaman'],
tebusaz['jbg'],
tebusaz['t_tebus'],
@@ -1237,7 +1281,6 @@ $.each(data,function(index,gadai_detail){
$('#poskod').change(function(){
var poskod = this.value;
console.log(poskod);
$.ajax({
method:'GET',
url:api_url+'/api/poskod/'+poskod,
@@ -1248,7 +1291,6 @@ $.each(data,function(index,gadai_detail){
url:api_url+'/api/negeri/'+kodnegeri,
method:'GET',
success:function(negeri){
console.log(negeri);
$('#kodnegeri').val(negeri['negeri']);
}
});