buat upah buat ubah wakil

This commit is contained in:
MUHD HAFIFIE
2021-04-18 15:50:18 +08:00
parent 6a193465a8
commit f01f2615dd
4 changed files with 434 additions and 213 deletions
+128 -14
View File
@@ -8,6 +8,7 @@
@section('content')
@include('modal.historytebus')
@include('modal.wakil')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12 col-lg-12">
@@ -756,6 +757,49 @@
});
}
function daftarwakilfunction(nokp)
{
$('#nokp').val(nokp);
$.ajax({
method:'GET',
url: "{{ route('wakil.caricustomer') }}",
data:{ "icno" : nokp },
success:function(data){
$('#WakilModal').modal();
$('#nama').val('');
$('#alamat').val(data['']);
$('#notel').val(data['']);
//get first wakil
$.ajax({
method:'GET',
url: "{{ route('wakil.first') }}",
success:function(getfirstwakil)
{
let firstwakil = parseInt(getfirstwakil);
$('#nowakil').val(firstwakil+1);
}
});
if(data != 'no-data')
{
$('#nama').val(data['nama']);
$('#alamat').val(data['alamat1']);
$('#notel').val(data['telefon']);
$('#nopelanggan').val(data['nopelanggan']);
}
},error: function (request, status, error) {
console.log(request.responseText);
}
});
}
function ubahfunc(e){
@@ -835,7 +879,7 @@
let mohon = "Ubah Wakil";
let norujukan = $('input[name="sudahtebus"]:checked').val();
console.log(mohon + ' ' + norujukan);
// console.log(mohon + ' ' + norujukan);
$.ajax({
method:'post',
@@ -853,6 +897,7 @@
}
});
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
cluster: 'ap1',
encrypted: true
@@ -861,7 +906,7 @@
var channel = pusher.subscribe('notice-ubahhapus');
channel.bind('my-ubahhapus', function(data) {
if(data.norujukan == ubahid)
if(data.norujukan == norujukan)
{
if(data.kelulusan == 'lulus')
{
@@ -897,23 +942,92 @@
if(amaun)
{
$.ajax({
method:'post',
method:'get',
url: api_url + '/api/getwakil/' + kodcaw + '/' + amaun,
data: {
// "_token": "{{ csrf_token() }}",
// "norujukan" : ubahid,
// "mohon" : mohon
},
success:function(data){
if(data.length > 0)
{
let namawakilsedia = data[0]['nama'];
let nokpwakilsedia = data[0]['nokp'];
let nowakilsedia = data[0]['nowakil'];
console.log(data[0]['nama']);
console.log(data[0]['nokp']);
const PengesahanAkhirWakil = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success ml-1',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
});
PengesahanAkhirWakil.fire({
title: 'Pengesahan Akhir Wakil!',
html: '<b class="text-danger">' + namawakilsedia + '</b><br><b class="text-danger">' + nokpwakilsedia + '</b>',
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Benar',
cancelButtonText: 'Salah',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
method:'put',
async:false,
url: api_url + '/api/ubahwakil/' + kodcaw,
data:{ 'nowakil' : nowakilsedia,
'norujukan' : norujukan},
success:function(data){
},error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
if(data === 1)
{
Swal.fire({
icon: 'success',
title: 'Berjaya!',
text: 'Penukaran Wakil berjaya'
}).then(async function(){
return true;
location.reload();
});
}else{
Swal.fire({
icon: 'info',
title: 'Pemberitahuan!',
text: 'Wakil telah didaftarkan dengan IC tersebut!'
}).then(async function(){
return true;
location.reload();
});
}
}
});
}else if (result.dismiss === Swal.DismissReason.cancel){
PengesahanAkhirWakil.fire(
'Batal',
'Tidak Berjaya Mengesahkan Wakil!',
'error'
)
}
});
}else{
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false,
confirmButtonText: '<i class="fa fa-thumbs-up"></i> Daftar Wakil!',
icon: 'info',
title: 'Maklumat anda tiada dalam senarai wakil! Tekan button Daftar untuk mendaftar!'
}).then(function(){
daftarwakilfunction(amaun);
});
}
},error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
});
}
});