partial update create kpi and progress bar
This commit is contained in:
212
resources/views/kpi/targets/index.blade.php
Normal file
212
resources/views/kpi/targets/index.blade.php
Normal file
@@ -0,0 +1,212 @@
|
||||
@extends('layouts.backapp')
|
||||
|
||||
@section('content')
|
||||
<div class="kt-content kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">
|
||||
<div class="kt-container kt-container--fluid kt-grid__item kt-grid__item--fluid">
|
||||
<div class="kt-portlet kt-portlet--mobile">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Manajemen Target KPI
|
||||
</h3>
|
||||
</div>
|
||||
<div class="kt-portlet__head-toolbar">
|
||||
<div class="kt-portlet__head-actions">
|
||||
<a href="{{ route('kpi.targets.create') }}" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i> Tambah Target
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kt-portlet__body">
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ session('success') }}
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(session('error'))
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
{{ session('error') }}
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered" id="kpiTargetsTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Mekanik</th>
|
||||
<th>Target</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($targets as $target)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $target->user->name }}</td>
|
||||
<td>{{ number_format($target->target_value) }}</td>
|
||||
<td>
|
||||
@if($target->is_active)
|
||||
<span class="badge badge-success">Aktif</span>
|
||||
@else
|
||||
<span class="badge badge-secondary">Nonaktif</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group" role="group">
|
||||
<a href="{{ route('kpi.targets.show', $target->id) }}"
|
||||
class="btn btn-sm btn-info" title="Detail">
|
||||
<i class="fas fa-eye"></i>
|
||||
</a>
|
||||
<a href="{{ route('kpi.targets.edit', $target->id) }}"
|
||||
class="btn btn-sm btn-warning" title="Edit">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-{{ $target->is_active ? 'warning' : 'success' }}"
|
||||
onclick="toggleStatus({{ $target->id }})"
|
||||
title="{{ $target->is_active ? 'Nonaktifkan' : 'Aktifkan' }}">
|
||||
<i class="fas fa-{{ $target->is_active ? 'pause' : 'play' }}"></i>
|
||||
</button>
|
||||
<form action="{{ route('kpi.targets.destroy', $target->id) }}"
|
||||
method="POST"
|
||||
style="display: inline;"
|
||||
onsubmit="return confirm('Yakin ingin menghapus target ini?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-danger" title="Hapus">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">Tidak ada data target KPI</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if($targets->hasPages())
|
||||
<div class="d-flex justify-content-center">
|
||||
{{ $targets->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filter Modal -->
|
||||
<div class="modal fade" id="filterModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Filter Target KPI</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="{{ route('kpi.targets.index') }}" method="GET">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Mekanik</label>
|
||||
<select name="user_id" class="form-control">
|
||||
<option value="">Semua Mekanik</option>
|
||||
@foreach($mechanics as $mechanic)
|
||||
<option value="{{ $mechanic->id }}"
|
||||
{{ request('user_id') == $mechanic->id ? 'selected' : '' }}>
|
||||
{{ $mechanic->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Status</label>
|
||||
<select name="is_active" class="form-control">
|
||||
<option value="">Semua Status</option>
|
||||
<option value="1" {{ request('is_active') == '1' ? 'selected' : '' }}>Aktif</option>
|
||||
<option value="0" {{ request('is_active') == '0' ? 'selected' : '' }}>Nonaktif</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
||||
<button type="submit" class="btn btn-primary">Filter</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('javascripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Initialize DataTable
|
||||
$('#kpiTargetsTable').DataTable({
|
||||
"pageLength": 25,
|
||||
"order": [[0, "asc"]],
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.10.24/i18n/Indonesian.json"
|
||||
}
|
||||
});
|
||||
|
||||
// Auto hide alerts after 5 seconds
|
||||
setTimeout(function() {
|
||||
$('.alert').fadeOut('slow');
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
function toggleStatus(targetId) {
|
||||
if (confirm('Yakin ingin mengubah status target ini?')) {
|
||||
$.ajax({
|
||||
url: '{{ route("kpi.targets.toggle-status", ":id") }}'.replace(':id', targetId),
|
||||
type: 'POST',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: response.message,
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
}).then(function() {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: response.message
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: 'Terjadi kesalahan saat mengubah status'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user