Buat Padam Kakitangan
This commit is contained in:
@@ -128,7 +128,7 @@
|
||||
@else
|
||||
@php
|
||||
$cawangan_staff = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $staff->cawangan)->json();
|
||||
echo ucwords($cawangan_staff['details_caw']);
|
||||
echo ($cawangan_staff) ? ucwords($cawangan_staff['details_caw']) : 'test';
|
||||
@endphp
|
||||
@endif
|
||||
</td>
|
||||
@@ -136,16 +136,18 @@
|
||||
@if($auth_user->roles == 'operasi')
|
||||
<a href="{{ route('kakitangan.tukartaraf',['id'=>$staff->id]) }}" class="btn btn-warning" title="Tukar Taraf"><i class="material-icons">edit</i></a>
|
||||
<a href="{{ route('kakitangan.tukarcawangan',['id'=>$staff->id]) }}" class="btn btn-info" title="Tukar Cawangan"><i class="material-icons">work</i></a>
|
||||
<a href="{{ route('operasi.kakitangan.edit',['id'=>$staff->id]) }}" class="btn btn-success" title="Edit Maklumat"><i class="material-icons">settings</i></a>
|
||||
<button type="button" class="btn btn-danger btn-delete" data-roles="{{ $auth_user->roles }}" data-staff-id="{{ $staff->id }}" data-token="{{ csrf_token() }}" title="Delete Kakitangan"><i class="material-icons">delete</i></button>
|
||||
@elseif($auth_user->roles == 'admin')
|
||||
<form method="post" action="{{ route('admin.kakitangan.delete') }}">
|
||||
{{ @csrf_field() }}
|
||||
{{-- <form method="post" action="{{ route('admin.kakitangan.delete') }}">
|
||||
{{ @csrf_field() }} --}}
|
||||
<input type="hidden" name="staff_id" value="{{ $staff->id }}"/>
|
||||
<a href="{{ route('admin.kakitangan.tukartaraf',['id'=>$staff->id]) }}" class="btn btn-warning" title="Tukar Taraf"><i class="material-icons">edit</i></a>
|
||||
<a href="{{ route('admin.kakitangan.tukarcawangan',['id'=>$staff->id]) }}" class="btn btn-info" title="Tukar Cawangan"><i class="material-icons">work</i></a>
|
||||
<a href="{{ route('admin.kakitangan.edit',['id'=>$staff->id]) }}" class="btn btn-success" title="Edit Maklumat"><i class="material-icons">settings</i></a>
|
||||
<a href="{{ route('admin.kakitangan.resetcredentials',['id'=>$staff->id]) }}" class="btn btn-primary" title="Reset Password"><i class="material-icons">restore</i></a>
|
||||
<button type="button" class="btn btn-danger btn-delete" data-staff-id="{{ $staff->id }}" data-token="{{ csrf_token() }}" title="Delete Kakitangan"><i class="material-icons">delete</i></button>
|
||||
</form>
|
||||
{{-- </form> --}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@@ -165,20 +167,57 @@
|
||||
var tablerekod = $('#rekod_kakitangan').DataTable();
|
||||
|
||||
$('.btn-delete').on('click', function(){
|
||||
var form = $(this).closest('form');
|
||||
Swal.fire(
|
||||
{
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!",
|
||||
// var form = $(this).closest('form');
|
||||
var roles = $(this).data('roles');
|
||||
var staff_id = $(this).data('staff-id');
|
||||
|
||||
var url_redirected = (roles == 'operasi') ? "{{ route('operasi.kakitangan.delete') }}" : "{{ route('admin.kakitangan.delete') }}";
|
||||
|
||||
Swal.fire({
|
||||
title: 'Padam Kakitangan Ini?',
|
||||
text: "Anda tidak boleh mengembalikan data ini balik selepas dipadamkan!",
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonClass: 'btn btn-danger',
|
||||
cancelButtonClass: 'btn btn-warning',
|
||||
confirmButtonText: 'Yes, delete it!',
|
||||
confirmButtonText: 'Padam!',
|
||||
cancelButtonText: 'Batal!',
|
||||
buttonsStyling: false
|
||||
}
|
||||
).then(function() {
|
||||
form.submit();
|
||||
}).then(function(result) {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$.ajax({
|
||||
method:'post',
|
||||
url: url_redirected,
|
||||
data: {
|
||||
"_token": "{{ csrf_token() }}",
|
||||
"staff_id" : staff_id
|
||||
},
|
||||
success:function(data){
|
||||
if(data == 'success')
|
||||
{
|
||||
if(roles == 'operasi')
|
||||
window.location.href = "{{ route('daftar.kakitangan') }}";
|
||||
else
|
||||
window.location.href = "{{ route('admin.daftar.kakitangan') }}";
|
||||
|
||||
Swal.fire({
|
||||
title: 'Memuatkan...',
|
||||
allowEscapeKey : false,
|
||||
allowOutsideClick: false,
|
||||
didOpen: function () {
|
||||
Swal.showLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
var err = eval("(" + xhr.responseText + ")");
|
||||
alert(xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).catch(swal.noop)
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user