DONE: optimize loading page on employee, append the online payment under same batch
This commit is contained in:
@@ -43,9 +43,6 @@
|
||||
<b>Cawangan</b>
|
||||
</div>
|
||||
<div class='col-md-7'>
|
||||
@php
|
||||
$cawangan_all = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/api/cawangan')->json();
|
||||
@endphp
|
||||
<select class="form-control" name="cawangan" data-placeholder="Pilih Cawangan" id="cawangan">
|
||||
<option disabled selected value> -- Pilih Cawangan -- </option>
|
||||
<option value="operasi">Operasi</option>
|
||||
@@ -106,81 +103,12 @@
|
||||
<div class="card-body text-center">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table id="rekod_kakitangan" class="table table-striped table-hover">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Bil</th>
|
||||
<th>Nama Staff</th>
|
||||
<th>Jawatan</th>
|
||||
<th>Cawangan</th>
|
||||
<th>Tindakan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($kakitangan as $index=>$staff)
|
||||
@if($staff->roles != 'admin')
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $staff->name }}</td>
|
||||
<td>{{ strtoupper($staff->roles) }}</td>
|
||||
<td>
|
||||
@if($staff->cawangan == 'operasi' || $staff->cawangan == 'callcenter' || $staff->cawangan == 'admin')
|
||||
{{ ucwords($staff->cawangan) }}
|
||||
@else
|
||||
@php
|
||||
$cawangan_staff = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $staff->cawangan)->json();
|
||||
echo (isset($cawangan_staff['details_caw'])) ? ucwords($cawangan_staff['details_caw']) : 'test';
|
||||
@endphp
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@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>
|
||||
@if(
|
||||
app()->environment(['local', 'staging'])
|
||||
&&
|
||||
in_array($auth_user->roles, ['admin'])
|
||||
&& $staff->roles != 'admin'
|
||||
&& $staff->id != $auth_user->id
|
||||
&& !(Auth::check() && method_exists(Auth::user(), 'isImpersonated') && Auth::user()->isImpersonated())
|
||||
)
|
||||
<form method="post" action="{{ route('impersonate.start', ['id' => $staff->id]) }}" style="display:inline;">
|
||||
@csrf
|
||||
<button type="button" class="btn btn-secondary btn-impersonate" data-staff-name="{{ $staff->name }}" title="Impersonate"><i class="material-icons">supervised_user_circle</i></button>
|
||||
</form>
|
||||
@endif
|
||||
<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() }} --}}
|
||||
<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>
|
||||
@if(
|
||||
app()->environment(['local', 'staging'])
|
||||
&&
|
||||
$staff->roles != 'admin'
|
||||
&& $staff->id != $auth_user->id
|
||||
&& !(Auth::check() && method_exists(Auth::user(), 'isImpersonated') && Auth::user()->isImpersonated())
|
||||
)
|
||||
<form method="post" action="{{ route('impersonate.start', ['id' => $staff->id]) }}" style="display:inline;">
|
||||
@csrf
|
||||
<button type="button" class="btn btn-secondary btn-impersonate" data-staff-name="{{ $staff->name }}" title="Impersonate"><i class="material-icons">supervised_user_circle</i></button>
|
||||
</form>
|
||||
@endif
|
||||
<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> --}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<x-datatable
|
||||
id="rekod_kakitangan"
|
||||
filename="Senarai_Kakitangan"
|
||||
:columns="['Bil', 'Tindakan', 'Nama Staff', 'Jawatan', 'Role Harian', 'Role Asal', 'Cawangan']"
|
||||
:skipExport="['Bil', 'Tindakan']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -189,8 +117,72 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
@php
|
||||
$isOperasi = $auth_user->roles == 'operasi';
|
||||
$canImpersonate = app()->environment(['local', 'staging'])
|
||||
&& $auth_user->roles === 'admin'
|
||||
&& !(Auth::check() && method_exists(Auth::user(), 'isImpersonated') && Auth::user()->isImpersonated());
|
||||
@endphp
|
||||
|
||||
var tablerekod = $('#rekod_kakitangan').DataTable();
|
||||
function escapeHtml(value) {
|
||||
return $('<div>').text(value == null ? '' : String(value)).html();
|
||||
}
|
||||
|
||||
function staffTindakanHtml(staff) {
|
||||
var id = staff.id;
|
||||
var html = '';
|
||||
|
||||
html += '<a href="' + staffRoutes.tukarTaraf.replace('__ID__', id) + '" class="btn btn-warning" title="Tukar Taraf"><i class="material-icons">edit</i></a> ';
|
||||
html += '<a href="' + staffRoutes.tukarCawangan.replace('__ID__', id) + '" class="btn btn-info" title="Tukar Cawangan"><i class="material-icons">work</i></a> ';
|
||||
html += '<a href="' + staffRoutes.edit.replace('__ID__', id) + '" class="btn btn-success" title="Edit Maklumat"><i class="material-icons">settings</i></a> ';
|
||||
|
||||
if (authRole === 'admin') {
|
||||
html += '<a href="' + staffRoutes.reset.replace('__ID__', id) + '" class="btn btn-primary" title="Reset Password"><i class="material-icons">restore</i></a> ';
|
||||
}
|
||||
|
||||
if (canImpersonate && id !== authUserId) {
|
||||
html += '<form method="post" action="' + staffRoutes.impersonate.replace('__ID__', id) + '" style="display:inline;">' +
|
||||
csrfField +
|
||||
'<button type="button" class="btn btn-secondary btn-impersonate" data-staff-name="' + escapeHtml(staff.name) + '" title="Impersonate"><i class="material-icons">supervised_user_circle</i></button>' +
|
||||
'</form> ';
|
||||
}
|
||||
|
||||
html += '<button type="button" class="btn btn-danger btn-delete" data-roles="' + authRole + '" data-staff-id="' + id + '" title="Delete Kakitangan"><i class="material-icons">delete</i></button>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
var authRole = @json($auth_user->roles);
|
||||
var authUserId = @json($auth_user->id);
|
||||
var canImpersonate = @json($canImpersonate);
|
||||
var csrfField = '<input type="hidden" name="_token" value="' + @json(csrf_token()) + '">';
|
||||
var staffRoutes = {
|
||||
tukarTaraf: @json($isOperasi ? route('kakitangan.tukartaraf', ['id' => '__ID__']) : route('admin.kakitangan.tukartaraf', ['id' => '__ID__'])),
|
||||
tukarCawangan: @json($isOperasi ? route('kakitangan.tukarcawangan', ['id' => '__ID__']) : route('admin.kakitangan.tukarcawangan', ['id' => '__ID__'])),
|
||||
edit: @json($isOperasi ? route('operasi.kakitangan.edit', ['id' => '__ID__']) : route('admin.kakitangan.edit', ['id' => '__ID__'])),
|
||||
reset: @json(route('admin.kakitangan.resetcredentials', ['id' => '__ID__'])),
|
||||
impersonate: @json(route('impersonate.start', ['id' => '__ID__']))
|
||||
};
|
||||
|
||||
var tablerekod = initErahnDatatable('#rekod_kakitangan', {
|
||||
columnDefs: [
|
||||
{ targets: 0, orderable: false, width: '40px' },
|
||||
{ targets: 1, orderable: false, searchable: false }
|
||||
]
|
||||
});
|
||||
|
||||
$.each(@json($kakitangan_rows), function (index, staff) {
|
||||
tablerekod.row.add([
|
||||
index + 1,
|
||||
staffTindakanHtml(staff),
|
||||
escapeHtml(staff.name),
|
||||
escapeHtml(staff.roles),
|
||||
escapeHtml(staff.role_harian),
|
||||
escapeHtml(staff.role_asal),
|
||||
escapeHtml(staff.cawangan)
|
||||
]);
|
||||
});
|
||||
tablerekod.draw();
|
||||
|
||||
$("#rekod_kakitangan").on('click', ".btn-delete", function(){
|
||||
//$('.btn-delete').on('click', function(){
|
||||
@@ -253,7 +245,7 @@
|
||||
var staffName = $(this).data('staff-name');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Menyamar sebagai Kakitangan?',
|
||||
title: 'Menyamar sebagai ' + staffName + '?',
|
||||
text: "Anda akan log masuk sebagai " + staffName + ".",
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
|
||||
Reference in New Issue
Block a user