DONE: add komoditi page for khazanah, update certs to include all three certs into one file
This commit is contained in:
@@ -56,6 +56,19 @@ class KomuditiController extends Controller
|
||||
return redirect()->route('komuditi');
|
||||
}
|
||||
|
||||
/**
|
||||
* Khazanah branch list of BSAS commodity orders.
|
||||
*/
|
||||
public function khazanahBsas()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])
|
||||
->json();
|
||||
|
||||
return view('homepage.khazanah.bsas_komoditi', compact('cawangan_info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy BSAS eCert layout preview (bid, OTC, STB, then one commodity schedule).
|
||||
*/
|
||||
@@ -193,9 +206,8 @@ class KomuditiController extends Controller
|
||||
[$time, $date] = $this->splitBsasDateTime((string) ($ecert['PURCHASETIMEDATE'] ?? ''));
|
||||
|
||||
return $this->certificatePage(
|
||||
'Certificate of Bid',
|
||||
'Certificate of Purchase',
|
||||
'This is to certify that the following bid transaction has been executed<br>through the Bursa Suq Al-Sila\' in accordance with the<br>Rules of Bursa Suq Al-Sila\'.',
|
||||
'Generated for Ar-Rahn / Koperasi Permodalan Kelantan Berhad · BSAS Bid Certificate',
|
||||
$ecert,
|
||||
$orderMeta,
|
||||
array_merge([
|
||||
@@ -212,9 +224,8 @@ class KomuditiController extends Controller
|
||||
[$time, $date] = $this->splitBsasDateTime((string) ($ecert['REPORTINGTIMEDATE'] ?? ''));
|
||||
|
||||
$page = $this->certificatePage(
|
||||
'Certificate of Purchase',
|
||||
'Certificate of Murabahah',
|
||||
'This is to certify that the following transaction has been executed<br>through the Bursa Suq Al-Sila\' in accordance with the<br>Rules of Bursa Suq Al-Sila\'.',
|
||||
'Generated for Ar-Rahn / Koperasi Permodalan Kelantan Berhad · BSAS OTC Certificate',
|
||||
$ecert,
|
||||
$orderMeta,
|
||||
array_merge([
|
||||
@@ -240,7 +251,6 @@ class KomuditiController extends Controller
|
||||
return $this->certificatePage(
|
||||
'Certificate of Sale',
|
||||
'This is to certify that the following sale transaction has been executed<br>through the Bursa Suq Al-Sila\' in accordance with the<br>Rules of Bursa Suq Al-Sila\'.',
|
||||
'Generated for Ar-Rahn / Koperasi Permodalan Kelantan Berhad · BSAS STB Certificate',
|
||||
$ecert,
|
||||
$orderMeta,
|
||||
array_merge([
|
||||
@@ -251,12 +261,11 @@ class KomuditiController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
protected function certificatePage(string $title, string $statement, string $footerNote, array $ecert, array $orderMeta, array $rows): array
|
||||
protected function certificatePage(string $title, string $statement, array $ecert, array $orderMeta, array $rows): array
|
||||
{
|
||||
return [
|
||||
'title' => $title,
|
||||
'statement' => $statement,
|
||||
'footer_note' => $footerNote,
|
||||
'ecert_no' => $ecert['ECERTNO'] ?? ($orderMeta['e_cert_no'] ?? '-'),
|
||||
'currency' => $ecert['CURRENCY'] ?? 'MYR',
|
||||
'rows' => $rows,
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<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">Komoditi BSAS</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<div class="card-header text-center">{{ __('Rekod Komoditi BSAS') }}</div>
|
||||
<div class="card-body text-center">
|
||||
<div class="row justify-content-between mb-4">
|
||||
<div class="col text-left">
|
||||
<div class="form-group d-flex align-items-center">
|
||||
<label for="limit_view_bsas" style="width: 600px" class="mb-0">Had Paparan Rekod BSAS</label>
|
||||
<select onchange="loadBsasRecord()" name="limit_view_bsas" id="limit_view_bsas" class="form-control">
|
||||
<option selected value="20">20</option>
|
||||
<option value="100">100</option>
|
||||
<option value="500">500</option>
|
||||
<option value="1000">1000</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col text-right">
|
||||
<button type="button" class="btn btn-primary" id="refresh_bsas" title="Muat Semula">
|
||||
<i class="fas fa-sync-alt" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="spinner-border" role="status" id="loading-spinner-bsas" style="display:none;">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
<x-datatable
|
||||
id="rekod_bsas"
|
||||
filename="Rekod_Komoditi_BSAS"
|
||||
class="text-center"
|
||||
:columns="['Bil', 'Tarikh', 'UUID', 'No Rujukan', 'Cawangan', 'Pembeli', 'Bid Value', 'Murabaha', 'eCert No', 'Status', 'Oleh', 'Tindakan']"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
|
||||
let api = "{{ api_url_for_browser() }}";
|
||||
let kodcaw = "{{ Auth::user()->cawangan }}";
|
||||
|
||||
var tablebsas = initErahnDatatable('#rekod_bsas', {
|
||||
pageLength: 1000,
|
||||
bLengthChange: false,
|
||||
deferRender: true,
|
||||
order: [[1, 'desc']],
|
||||
});
|
||||
|
||||
$('#refresh_bsas').on('click', function () {
|
||||
loadBsasRecord();
|
||||
});
|
||||
|
||||
$(function () {
|
||||
loadBsasRecord();
|
||||
});
|
||||
|
||||
function bsasStatusBadge(status) {
|
||||
var label = status || '-';
|
||||
var cls = 'secondary';
|
||||
if (status === 'confirmed') cls = 'success';
|
||||
else if (status === 'failed') cls = 'danger';
|
||||
else if (status === 'submitted' || status === 'pending') cls = 'warning';
|
||||
return '<span class="badge badge-' + cls + '">' + label + '</span>';
|
||||
}
|
||||
|
||||
function formatBsasDateTime(value) {
|
||||
if (!value) {
|
||||
return '-';
|
||||
}
|
||||
var date = new Date(value);
|
||||
if (isNaN(date.getTime())) {
|
||||
return value;
|
||||
}
|
||||
var pad = function (n) { return String(n).padStart(2, '0'); };
|
||||
return date.getFullYear() + '-' +
|
||||
pad(date.getMonth() + 1) + '-' +
|
||||
pad(date.getDate()) + ' ' +
|
||||
pad(date.getHours()) + ':' +
|
||||
pad(date.getMinutes()) + ':' +
|
||||
pad(date.getSeconds());
|
||||
}
|
||||
|
||||
function bsasEcertAction(row) {
|
||||
var ecertNo = row['e_cert_no'] || '';
|
||||
var hasEcert = !!(row['has_bid_ecert'] || row['has_otc_ecert'] || row['has_stb_ecert']);
|
||||
var uuid = row['uuid'] || '';
|
||||
|
||||
if (!hasEcert || !uuid) {
|
||||
return '<span class="text-muted">-</span>';
|
||||
}
|
||||
|
||||
var url = "{{ url('/khazanah/komoditi/bsas/ecert') }}/" + encodeURIComponent(uuid);
|
||||
return '<a class="btn btn-sm btn-outline-primary" href="' + url + '" target="_blank" title="Lihat eCert ' + ecertNo + '">' +
|
||||
'<i class="fa fa-print" aria-hidden="true"></i> eCert' +
|
||||
'</a>';
|
||||
}
|
||||
|
||||
function loadBsasRecord() {
|
||||
var selectedLimitView = $('#limit_view_bsas').find(':selected').val();
|
||||
|
||||
$('#loading-spinner-bsas').show();
|
||||
tablebsas.clear().draw();
|
||||
$.ajax({
|
||||
method: 'get',
|
||||
url: api + '/api/komuditi/bsas/orders',
|
||||
data: {
|
||||
'limit_view': selectedLimitView,
|
||||
'kodcaw': kodcaw,
|
||||
},
|
||||
success: function (rekod) {
|
||||
var bilcount = 0;
|
||||
$.each(rekod, function (index, row) {
|
||||
bilcount++;
|
||||
var ecertNo = row['e_cert_no'] || '-';
|
||||
if ((row['has_bid_ecert'] || row['has_otc_ecert'] || row['has_stb_ecert']) && row['uuid']) {
|
||||
ecertNo = '<a href="{{ url('/khazanah/komoditi/bsas/ecert') }}/' + encodeURIComponent(row['uuid']) + '" target="_blank">' +
|
||||
(row['e_cert_no'] || 'eCert') +
|
||||
'</a>';
|
||||
}
|
||||
|
||||
tablebsas.row.add([
|
||||
bilcount,
|
||||
formatBsasDateTime(row['created_at']),
|
||||
row['uuid'] || '-',
|
||||
row['norujukan'] || '-',
|
||||
row['kodcaw'] || '-',
|
||||
row['otc_counter_party'] || '-',
|
||||
formatter.format(Number(row['bid_value'] || 0)),
|
||||
formatter.format(Number(row['otc_murabaha_value'] || 0)),
|
||||
ecertNo,
|
||||
bsasStatusBadge(row['status']),
|
||||
row['created_by'] || '-',
|
||||
bsasEcertAction(row),
|
||||
]).draw(false);
|
||||
});
|
||||
tablebsas.draw();
|
||||
$('#loading-spinner-bsas').hide();
|
||||
},
|
||||
error: function () {
|
||||
$('#loading-spinner-bsas').hide();
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Gagal memuatkan rekod BSAS'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
@@ -282,6 +282,10 @@
|
||||
<a href="{{ route('khazanah.indexwakil') }}"
|
||||
class="btn btn-info btn-lg btn-block mb-3">Surat Wakil</a>
|
||||
</div>
|
||||
<div class="col-4 px-2">
|
||||
<a href="{{ route('khazanah.bsas') }}"
|
||||
class="btn btn-info btn-lg btn-block mb-3">Komoditi BSAS</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -297,7 +297,6 @@
|
||||
</div>
|
||||
|
||||
<x-print.bsas.footer
|
||||
:note="$certificate['footer_note'] ?? ''"
|
||||
:page="$index + 1"
|
||||
:total="$pageTotal"
|
||||
/>
|
||||
|
||||
@@ -253,6 +253,8 @@ Route::post('/kakitangan/harian',['as'=>'kakitangan.harian','uses'=>'KakitanganC
|
||||
Route::get('/lelong',['as'=>'lelong','uses'=>'LelongController@lelong']);
|
||||
|
||||
Route::get('/khazanah/harga_emas',['as'=>'khazanah.harga_emas','uses'=>'HargaEmasController@index'])->middleware('auth','khazanah');
|
||||
Route::get('/khazanah/komoditi/bsas',['as'=>'khazanah.bsas','uses'=>'KomuditiController@khazanahBsas'])->middleware('auth','khazanah');
|
||||
Route::get('/khazanah/komoditi/bsas/ecert/{uuid}',['as'=>'khazanah.bsas.ecert','uses'=>'KomuditiController@showBsasEcert'])->middleware('auth','khazanah');
|
||||
|
||||
//Request Teller Batal Route
|
||||
Route::get('/requestbatal',['as'=>'request.pembatalan','uses'=>'KhazanahController@RequestPembatalan'])->middleware('auth','khazanah');
|
||||
|
||||
Reference in New Issue
Block a user