200 lines
9.5 KiB
PHP
200 lines
9.5 KiB
PHP
|
@php
|
||
|
$route = explode('.', Route::currentRouteName());
|
||
|
@endphp
|
||
|
<div class="d-flex flex-column mb-17">
|
||
|
<div class="container-fluid mx-auto">
|
||
|
<div class="row">
|
||
|
<div class="col-6">
|
||
|
<div class="card shadow-sm">
|
||
|
<div class="card-header">
|
||
|
<h3 class="card-title">Data Lama</h3>
|
||
|
</div>
|
||
|
<div class="card-body">
|
||
|
@if($authorization->old_request)
|
||
|
@php
|
||
|
$data = json_decode($authorization->old_request, true);
|
||
|
@endphp
|
||
|
<table class="table table-bordered table-striped">
|
||
|
<tbody>
|
||
|
@foreach ($data as $key => $value)
|
||
|
@if($key=='status')
|
||
|
<tr>
|
||
|
<td>{{ $key }}</td>
|
||
|
<td>
|
||
|
@switch($value)
|
||
|
@case (0)
|
||
|
<span class="badge badge-light-primary">Waiting Approval</span>
|
||
|
@break
|
||
|
@case (1)
|
||
|
<span class="badge badge-light-success">Approved</span>
|
||
|
@break
|
||
|
@case (3)
|
||
|
<span class="badge badge-light-danger">Rejected</span>
|
||
|
@break
|
||
|
@endswitch
|
||
|
</td>
|
||
|
</tr>
|
||
|
@else
|
||
|
<tr>
|
||
|
<td>{{ $key }}</td>
|
||
|
<td>
|
||
|
@if(is_array($value))
|
||
|
@foreach($value as $k => $v)
|
||
|
<span class="badge badge-light-primary">{{ $v }}</span>
|
||
|
@endforeach
|
||
|
@else
|
||
|
{{ $value }}
|
||
|
@endif
|
||
|
</td>
|
||
|
</tr>
|
||
|
@endif
|
||
|
@endforeach
|
||
|
<tbody>
|
||
|
</table>
|
||
|
@endif
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col-6">
|
||
|
<div class="card shadow-sm">
|
||
|
<div class="card-header">
|
||
|
<h3 class="card-title">Data Baru</h3>
|
||
|
</div>
|
||
|
<div class="card-body">
|
||
|
@if($authorization->new_request)
|
||
|
@php
|
||
|
$data = json_decode($authorization->new_request, true);
|
||
|
@endphp
|
||
|
<table class="table table-bordered table-striped">
|
||
|
<tbody>
|
||
|
@foreach ($data as $key => $value)
|
||
|
@if($key=='status')
|
||
|
<tr>
|
||
|
<td>{{ $key }}</td>
|
||
|
<td>
|
||
|
@switch($value)
|
||
|
@case (0)
|
||
|
<span class="badge badge-light-primary">Waiting Approval</span>
|
||
|
@break
|
||
|
@case (1)
|
||
|
<span class="badge badge-light-success">Approved</span>
|
||
|
@break
|
||
|
@case (3)
|
||
|
<span class="badge badge-light-danger">Rejected</span>
|
||
|
@break
|
||
|
@endswitch
|
||
|
</td>
|
||
|
</tr>
|
||
|
@else
|
||
|
<tr>
|
||
|
<td>{{ $key }}</td>
|
||
|
<td>
|
||
|
@if(is_array($value))
|
||
|
@foreach($value as $k => $v)
|
||
|
<span class="badge badge-light-primary">{{ $v }}</span>
|
||
|
@endforeach
|
||
|
@else
|
||
|
{{ $value }}
|
||
|
@endif
|
||
|
</td>
|
||
|
</tr>
|
||
|
@endif
|
||
|
@endforeach
|
||
|
<tbody>
|
||
|
</table>
|
||
|
@endif
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="container mx-auto">
|
||
|
<form class="form_{{$route[0]}}" method="POST"
|
||
|
action="{{ route($route[0].'.update',['authorization' => $authorization->id]) }}">
|
||
|
@method('PUT')
|
||
|
@csrf
|
||
|
<!--begin::Input group-->
|
||
|
@if($authorization->status==0)
|
||
|
<!--begin::Actions-->
|
||
|
<div class="text-center mt-10">
|
||
|
<input type="hidden" name="id" value="{{ $authorization->id }}">
|
||
|
<input type="hidden" name="keterangan" id="keterangan">
|
||
|
<input type="hidden" name="status" id="status">
|
||
|
<a href="{{ route('authorization.index') }}" class="btn-cancel btn btn-light me-3 btn-sm">Cancel</a>
|
||
|
<button type="button" value="1" class="btn-approve btn btn-success me-3 btn-sm">Approve</button>
|
||
|
<button type="button" value="3" class="btn-tolak btn btn-danger btn-sm">Reject</button>
|
||
|
</div>
|
||
|
<!--end::Actions-->
|
||
|
@endif
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
@push('scripts')
|
||
|
<script type="text/javascript">
|
||
|
$(function () {
|
||
|
$(".btn-tolak").on('click', function (event) {
|
||
|
$("#status").val(3);
|
||
|
var form = $(this).closest("form");
|
||
|
event.preventDefault();
|
||
|
Swal.fire({
|
||
|
title: 'Are you sure?',
|
||
|
html: "Apakah Anda Akan Menolak {{ $authorization->description }} Ini!<br>Alasan Penolakan :",
|
||
|
icon: 'warning',
|
||
|
input: 'text',
|
||
|
showCancelButton: true,
|
||
|
confirmButtonColor: '#3085d6',
|
||
|
cancelButtonColor: '#d33',
|
||
|
confirmButtonText: 'Yes, Reject It!',
|
||
|
preConfirm: (keterangan) => {
|
||
|
if (!keterangan) {
|
||
|
Swal.showValidationMessage(
|
||
|
`Alasan Penolakan Wajib Diisi`
|
||
|
)
|
||
|
} else {
|
||
|
$("#keterangan").val(keterangan)
|
||
|
}
|
||
|
}
|
||
|
}).then((result) => {
|
||
|
if (result.isConfirmed) {
|
||
|
swal.fire({
|
||
|
title: "Success!",
|
||
|
text: "{{ $authorization->description }} Berhasil Ditolak.",
|
||
|
icon: "success",
|
||
|
confirmButtonClass: 'btn btn-primary',
|
||
|
buttonsStyling: false,
|
||
|
})
|
||
|
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
|
||
|
$(".btn-approve").on('click', function (event) {
|
||
|
event.preventDefault();
|
||
|
$("#status").val(1);
|
||
|
var form = $(this).closest("form");
|
||
|
|
||
|
Swal.fire({
|
||
|
title: 'Are you sure?',
|
||
|
html: "Apakah Anda Menyetujui {{ $authorization->description }} Ini!",
|
||
|
icon: 'warning',
|
||
|
showCancelButton: true,
|
||
|
confirmButtonColor: '#3085d6',
|
||
|
cancelButtonColor: '#d33',
|
||
|
confirmButtonText: 'Yes, Approve It!'
|
||
|
}).then((result) => {
|
||
|
if (result.isConfirmed) {
|
||
|
swal.fire({
|
||
|
title: "Success!",
|
||
|
text: "{{ $authorization->description }} Berhasil Di Approve.",
|
||
|
icon: "success",
|
||
|
confirmButtonClass: 'btn btn-primary',
|
||
|
buttonsStyling: false,
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
})
|
||
|
</script>
|
||
|
@endpush
|
||
|
|