Files
kaunter/resources/views/pembiayaan_online/pc/senarai.blade.php
T

305 lines
15 KiB
PHP

@extends('layouts.app')
@section('content')
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-md-12">
<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">Pembiayaan Online</li>
</ol>
</nav>
<div class="mb-3">
<a href="{{ route('pembiayaan.online.pc.paid') }}" class="btn btn-success">
Tally PAID / Blast
</a>
<a href="{{ route('pembiayaan.online.pc.topup') }}" class="btn btn-warning">
Had / Modal Online
</a>
</div>
@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
@php
$isMissing = !empty($modal['missing']);
$isClosed = (int)($modal['ditutup'] ?? 0) === 1;
$pendingReq = $modal['pending_request'] ?? null;
if (is_object($pendingReq)) {
$pendingReq = json_decode(json_encode($pendingReq), true);
}
@endphp
@if($isClosed)
<div class="alert alert-dark">Modal online hari ini sudah ditutup (EOD).</div>
@elseif($isMissing)
<div class="alert alert-warning mb-3">
Belum ada had modal online hari ini.
@if($pendingReq)
Permohonan RM {{ number_format((float)($pendingReq['amaun'] ?? 0), 2) }}
daripada {{ $pendingReq['dimohon_oleh'] ?? '-' }} masih <b>PENDING</b>.
@else
Mohon had di
<a href="{{ route('pembiayaan.online.pc.topup') }}">Had Modal Online</a>.
@endif
</div>
@elseif($pendingReq)
<div class="alert alert-info mb-3">
Permohonan tambah RM {{ number_format((float)($pendingReq['amaun'] ?? 0), 2) }}
daripada {{ $pendingReq['dimohon_oleh'] ?? '-' }} menunggu kelulusan Operasi.
<a href="{{ route('pembiayaan.online.pc.topup') }}">Semak</a>
</div>
@endif
<div class="row mb-3">
<div class="col-md-4">
<div class="card">
<div class="card-body text-center">
<div class="text-muted">Modal Online Hari Ini</div>
<h4 class="mb-0">
@if(!empty($modal['missing']))
Belum ada had
@else
Baki RM {{ number_format((float)($modal['baki'] ?? 0), 2) }}
@endif
</h4>
<small>
@if(!empty($modal['missing']))
Tunggu kelulusan Operasi
@else
Digunakan RM {{ number_format((float)($modal['digunakan'] ?? 0), 2) }}
/ Had RM {{ number_format((float)($modal['had'] ?? 0) + (float)($modal['tambah'] ?? 0), 2) }}
@endif
</small>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body text-center">
<div class="text-muted">Queue PC</div>
<h4 class="mb-0">{{ count($lines) }} rekod</h4>
<small>Jumlah RM {{ number_format((float)($queue['jumlah'] ?? 0), 2) }}</small>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body text-center">
<div class="text-muted">Slot Cadangan</div>
<h4 class="mb-0">{{ $slot['slot'] ?? '-' }}</h4>
<small>{{ $slot['nota'] ?? '' }}</small>
</div>
</div>
</div>
</div>
<div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">Senarai Menunggu (PENDING / REJECTED)</h5>
<button type="button" class="btn btn-primary" id="btnSubmitBatch" disabled>Hantar Batch ke Operasi</button>
</div>
<div class="card-body">
<form id="formSubmitBatch" method="post" action="{{ route('pembiayaan.online.pc.submit') }}">
@csrf
<input type="hidden" name="slot" value="{{ $slot['slot'] ?? 'BATCH1' }}">
<div class="table-responsive">
<table class="table table-striped table-hover table-sm text-center" id="queueTable">
<thead class="thead-dark">
<tr>
<th><input type="checkbox" id="checkAll"></th>
<th>Status</th>
<th>SAG</th>
<th>Pelanggan</th>
<th>No KP</th>
<th>Bank</th>
<th>No Akaun</th>
<th>Pinjaman (RM)</th>
<th>Sebab Tolak</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@forelse($lines as $line)
<tr class="{{ ($line['status'] ?? '') === 'REJECTED_PC' ? 'table-warning' : '' }}">
<td>
<input type="checkbox" class="row-check" name="ids[]" value="{{ $line['id'] }}">
</td>
<td>
@if(($line['status'] ?? '') === 'REJECTED_PC')
<span class="badge badge-danger">REJECTED</span>
@else
<span class="badge badge-secondary">PENDING</span>
@endif
</td>
<td>{{ $line['norujukan'] ?? '-' }}</td>
<td class="text-left">{{ $line['nama_pelanggan'] ?? '-' }}</td>
<td>{{ $line['nokp'] ?? '-' }}</td>
<td>{{ $line['nama_bank'] ?? $line['kodbank'] ?? '-' }}</td>
<td>{{ $line['noakaun'] ?? '-' }}</td>
<td class="text-right">{{ number_format((float)($line['pinjaman'] ?? 0), 2) }}</td>
<td class="text-left small">{{ $line['reject_reason'] ?? '-' }}</td>
<td>
<button type="button" class="btn btn-sm btn-info btn-edit"
data-id="{{ $line['id'] }}"
data-kodbank="{{ $line['kodbank'] ?? '' }}"
data-noakaun="{{ $line['noakaun'] ?? '' }}"
data-namaakaun="{{ $line['nama_akaun'] ?? '' }}"
data-namabank="{{ $line['nama_bank'] ?? '' }}"
data-nota="{{ $line['nota'] ?? '' }}"
data-norujukan="{{ $line['norujukan'] ?? '' }}">
Edit
</button>
</td>
</tr>
@empty
<tr>
<td colspan="10">Tiada rekod dalam queue.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
<h5 class="mb-0">Sejarah Batch</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover table-sm text-center">
<thead class="thead-dark">
<tr>
<th>Batch No</th>
<th>Tarikh</th>
<th>Slot</th>
<th>Bil</th>
<th>Jumlah (RM)</th>
<th>Status</th>
<th>Dihantar Oleh</th>
<th></th>
</tr>
</thead>
<tbody>
@forelse($batches as $batch)
<tr>
<td>{{ $batch['batch_no'] ?? '-' }}</td>
<td>{{ $batch['tarikh'] ?? '-' }}</td>
<td>{{ $batch['slot'] ?? '-' }}</td>
<td>{{ $batch['bilangan'] ?? 0 }}</td>
<td class="text-right">{{ number_format((float)($batch['jumlah_keseluruhan'] ?? 0), 2) }}</td>
<td><span class="badge badge-info">{{ $batch['status'] ?? '-' }}</span></td>
<td>{{ $batch['pc_submitted_by'] ?? '-' }}</td>
<td>
<a class="btn btn-sm btn-secondary"
href="{{ route('pembiayaan.online.pc.batch', ['batchId' => $batch['id']]) }}">
Lihat
</a>
</td>
</tr>
@empty
<tr>
<td colspan="8">Belum ada batch.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
{{-- Edit modal --}}
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<form method="post" id="editForm" action="">
@csrf
@method('PUT')
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Kemaskini Bank <span id="editNorujukan"></span></h5>
<button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Bank</label>
<select name="kodbank" id="editKodbank" class="form-control" required>
<option value="">-- Pilih Bank --</option>
@foreach($banks as $bank)
<option value="{{ $bank['abbreviation'] }}" data-nama="{{ $bank['name'] }}">
{{ $bank['name'] }}
</option>
@endforeach
</select>
<input type="hidden" name="nama_bank" id="editNamabank">
</div>
<div class="form-group">
<label>No. Akaun</label>
<input type="text" name="noakaun" id="editNoakaun" class="form-control" required>
</div>
<div class="form-group">
<label>Nama Akaun</label>
<input type="text" name="nama_akaun" id="editNamaakaun" class="form-control">
</div>
<div class="form-group">
<label>Nota</label>
<textarea name="nota" id="editNota" class="form-control" rows="2"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
<button type="submit" class="btn btn-primary">Simpan</button>
</div>
</div>
</form>
</div>
</div>
<script>
function syncSubmitButton() {
var n = $('.row-check:checked').length;
$('#btnSubmitBatch').prop('disabled', n === 0);
$('#btnSubmitBatch').text(n ? ('Hantar Batch ke Operasi (' + n + ')') : 'Hantar Batch ke Operasi');
}
$('#checkAll').on('change', function () {
$('.row-check').prop('checked', this.checked);
syncSubmitButton();
});
$(document).on('change', '.row-check', syncSubmitButton);
$('#btnSubmitBatch').on('click', function () {
if ($('.row-check:checked').length === 0) return;
if (!confirm('Hantar rekod dipilih ke Operasi?')) return;
$('#formSubmitBatch').submit();
});
$('.btn-edit').on('click', function () {
var id = $(this).data('id');
$('#editForm').attr('action', "{{ url('/pembiayaan-online/pc/lines') }}/" + id);
$('#editNorujukan').text($(this).data('norujukan'));
$('#editKodbank').val($(this).data('kodbank'));
$('#editNoakaun').val($(this).data('noakaun'));
$('#editNamaakaun').val($(this).data('namaakaun'));
$('#editNamabank').val($(this).data('namabank'));
$('#editNota').val($(this).data('nota'));
$('#editModal').modal('show');
});
$('#editKodbank').on('change', function () {
$('#editNamabank').val($('#editKodbank option:selected').data('nama') || '');
});
</script>
@endsection