DONE: feature flags by branches

This commit is contained in:
ISMAIL MASSERAN
2026-09-08 14:48:18 +08:00
parent b6e4cf79ef
commit 120c32f781
9 changed files with 217 additions and 40 deletions
+88
View File
@@ -0,0 +1,88 @@
@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
+3 -1
View File
@@ -28,6 +28,7 @@
<div class="form-group row col-12">
<input type="hidden" name="kodcaw" id="kodcaw" value="{{$cawangan_info['kodcaw']}}">
<input type="hidden" id="pembiayaan_online_enabled" value="{{ !empty(($cawangan_info['features'] ?? [])['pembiayaan_online']) ? '1' : '0' }}">
<input type="hidden" name="nokp" id="nokp" value="{{ $customer_info['kpbaru'] }}">
<input type="hidden" name="tag_anggota" id="tag_anggota" value="{{ $customer_info['tag_anggota'] ?? 0 }}">
@@ -1266,7 +1267,8 @@
}
function toggleCaraTerima(pinjaman) {
if (pinjaman >= 5000 && pinjaman <= 50000) {
var pembiayaanOnlineEnabled = $('#pembiayaan_online_enabled').val() === '1';
if (pembiayaanOnlineEnabled && pinjaman >= 5000 && pinjaman <= 50000) {
$('#cara_terima_section').show();
toggleBankOnlineSection();
} else {
@@ -16,6 +16,7 @@
<div class="card-body text-center">
<a href="{{ route('admin.daftar.kakitangan') }}" class="btn btn-info btn-lg">Kakitangan</a>
<a href="{{ route('admin.pelanggan') }}" class="btn btn-info btn-lg">Pelanggan</a>
<a href="{{ route('admin.features') }}" class="btn btn-info btn-lg">Ciri Cawangan</a>
<!-- <a href="{{ route('admin.poskod') }}" class="btn btn-info btn-lg">Poskod</a> -->
</div>
</div>
@@ -262,10 +262,12 @@
<a href="{{ url('pendahuluanserahan') }}"
class="btn btn-info btn-lg btn-block mb-3">Pendahuluan - Serahan</a>
</div>
@if(!empty(($cawangan_info['features'] ?? [])['pembiayaan_online']))
<div class="row">
<a href="{{ route('pembiayaan.online.pc') }}"
class="btn btn-info btn-lg btn-block mb-3">Pembiayaan Online</a>
</div>
@endif
<div class="row">
<a href="{{ route('khazanah.indexwakil') }}"
class="btn btn-info btn-lg btn-block mb-3">Surat Wakil</a>