89 lines
4.3 KiB
PHP
89 lines
4.3 KiB
PHP
@extends('layouts.app_operasi')
|
||
|
||
@section('content')
|
||
<div class="container-fluid">
|
||
<div class="row justify-content-center">
|
||
<div class="col-md-10">
|
||
<nav aria-label="breadcrumb">
|
||
<ol class="breadcrumb pb-3">
|
||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||
<li class="breadcrumb-item active" aria-current="page">Ciri Cawangan</li>
|
||
</ol>
|
||
</nav>
|
||
|
||
@if(session()->has('message'))
|
||
<div class="alert alert-success">{{ session('message') }}</div>
|
||
@endif
|
||
@if(session()->has('error'))
|
||
<div class="alert alert-danger">{{ session('error') }}</div>
|
||
@endif
|
||
|
||
<div class="card">
|
||
<div class="card-header d-flex justify-content-between align-items-center">
|
||
<h5 class="mb-0">Ciri Cawangan</h5>
|
||
<span class="text-muted">{{ count($cawangan) }} cawangan</span>
|
||
</div>
|
||
<div class="card-body table-responsive">
|
||
<table id="featureTable" class="table table-striped table-hover table-sm">
|
||
<thead class="thead-dark">
|
||
<tr>
|
||
<th>Kod</th>
|
||
<th>Cawangan</th>
|
||
@foreach($keys as $key)
|
||
<th class="text-center">{{ $labels[$key] ?? $key }}</th>
|
||
@endforeach
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@forelse($cawangan as $row)
|
||
<tr>
|
||
<td>{{ $row['kodcaw'] ?? '-' }}</td>
|
||
<td>{{ $row['details_caw'] ?? '-' }}</td>
|
||
@foreach($keys as $key)
|
||
@php
|
||
$on = !empty(($row['features'] ?? [])[$key]);
|
||
@endphp
|
||
<td class="text-center">
|
||
<form method="post" action="{{ route('admin.features.update') }}" class="mb-0 d-inline"
|
||
@if($on) onsubmit="return confirm('Nyahaktifkan {{ $labels[$key] ?? $key }} untuk {{ $row['kodcaw'] }}?');" @endif>
|
||
@csrf
|
||
<input type="hidden" name="kodcaw" value="{{ $row['kodcaw'] }}">
|
||
<input type="hidden" name="feature" value="{{ $key }}">
|
||
<input type="hidden" name="enabled" value="{{ $on ? 0 : 1 }}">
|
||
<button type="submit" class="btn btn-sm {{ $on ? 'btn-success' : 'btn-secondary' }}">
|
||
{{ $on ? 'Aktif' : 'Tidak aktif' }}
|
||
</button>
|
||
</form>
|
||
</td>
|
||
@endforeach
|
||
</tr>
|
||
@empty
|
||
<tr>
|
||
<td colspan="{{ 2 + count($keys) }}" class="text-center text-muted">Tiada cawangan.</td>
|
||
</tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
$(function () {
|
||
if ($.fn.DataTable && $('#featureTable tbody tr').length && !$('#featureTable tbody td[colspan]').length) {
|
||
$('#featureTable').DataTable({
|
||
pageLength: 25,
|
||
order: [[0, 'asc']],
|
||
language: {
|
||
search: 'Cari:',
|
||
lengthMenu: 'Papar _MENU_',
|
||
info: '_START_–_END_ daripada _TOTAL_',
|
||
paginate: { previous: 'Sebelum', next: 'Seterusnya' }
|
||
}
|
||
});
|
||
}
|
||
});
|
||
</script>
|
||
@endsection
|