added resit for v3 and make it not allowed if it open other norujukan from other nokp
This commit is contained in:
@@ -154,22 +154,31 @@ class SemakController extends Controller
|
||||
return view('resit.resittebus',compact('transaction','gadai','cawangan_info','customers_info','penebusan','wakil','totaltransaction','totalBayaranAnsuran'));
|
||||
}
|
||||
|
||||
public function resit($id)
|
||||
public function resit($id,$company)
|
||||
{
|
||||
|
||||
$setapi = $company == 1
|
||||
? config('api.url')
|
||||
: config('api.url_koop');
|
||||
|
||||
$totaltransaction = 0;
|
||||
|
||||
$transaction = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/id/'. $id)->json();
|
||||
$transaction = Http::withOptions(['verify' => config('app.api_verify')])->get($setapi . '/api/transaction/id/'. $id)->json();
|
||||
|
||||
if(sizeof($transaction) != 0)
|
||||
$transaction = $transaction[0];
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $transaction['norujukan'])->json();
|
||||
if($transaction['nokp'] != Auth::user()->icno)
|
||||
{
|
||||
return response('not allowed', 403);
|
||||
}
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get($setapi . '/api/gadai/norujukan/'. $transaction['norujukan'])->json();
|
||||
|
||||
if(sizeof($gadai) != 0)
|
||||
$gadai = $gadai[0][0];
|
||||
|
||||
$customers_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $gadai['nokp'])->json();
|
||||
$customers_info = Http::withOptions(['verify' => config('app.api_verify')])->get($setapi . '/api/customers/'. $gadai['nokp'])->json();
|
||||
|
||||
// if(sizeof($customers_info) != 0)
|
||||
// $customers_info = $customers_info[0];
|
||||
|
||||
@@ -23,13 +23,13 @@ class BayaranHistoryService
|
||||
|
||||
$bayaranHistory = $CallableHttp->get('/api/transaction/'. $this->norujukan)->json();
|
||||
|
||||
$formatBayaranHistoryData = function ($x) {
|
||||
$formatBayaranHistoryData = function ($x) use($tagsyarikat) {
|
||||
if (sizeof($x) === 0) {
|
||||
return $x;
|
||||
}
|
||||
|
||||
$formatDate = fn($x) => Carbon::parse($x)->format('d/m/Y');
|
||||
$setResitAnsuranLink = fn($x) => route("resit.ansuran", $x);
|
||||
$setResitAnsuranLink = fn($x) => route("resit.ansuran", ['id' => $x, 'company' => $tagsyarikat]);
|
||||
|
||||
return array_map(function ($y) use ($formatDate, $setResitAnsuranLink) {
|
||||
$y['created_at'] = $formatDate($y['created_at']);
|
||||
|
||||
@@ -209,27 +209,17 @@
|
||||
@push('additional_js_scripts')
|
||||
<script>
|
||||
const showMarhunDetailModal = async function (event, tagsyarikat) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// document.getElementById('marhunLoader').style.display = 'flex';
|
||||
const norujukan = event.target.innerHTML;
|
||||
const loader = document.getElementById('load-arrahn');
|
||||
loader.classList.remove('d-none');
|
||||
|
||||
try {
|
||||
const data = await fetch('/api/pembiayaan-modal-data/' + norujukan + "/" + tagsyarikat)
|
||||
.then(x => x.json())
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
const loader = document.getElementById('load-arrahn');
|
||||
loader.classList.add('d-none');
|
||||
throw error;
|
||||
});
|
||||
const response = await fetch(`/api/pembiayaan-modal-data/${norujukan}/${tagsyarikat}`);
|
||||
const data = await response.json();
|
||||
|
||||
const loader = document.getElementById('load-arrahn');
|
||||
loader.classList.add('d-none');
|
||||
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
const formatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2 });
|
||||
|
||||
$('#pembiayaan').text('RM' + formatter.format(data.gadaianDetails.pinjaman));
|
||||
$('#bpembiayaan').text('RM' + formatter.format(data.gadaianDetails.bakipjm));
|
||||
@@ -246,21 +236,20 @@
|
||||
$('#pinjaman_modal').val(data.gadaianDetails.pinjaman);
|
||||
$('#marhunModal').modal('show');
|
||||
|
||||
const table_bayaran_history = $('#tablehistorybayaran').DataTable();
|
||||
const table_marhun = $('#biasa').DataTable();
|
||||
|
||||
$('#tablehistorybayaran').DataTable().clear().destroy();
|
||||
let table_bayaran_history = $('#tablehistorybayaran').DataTable();
|
||||
|
||||
$('#biasa').DataTable().clear().destroy();
|
||||
let table_marhun = $('#biasa').DataTable();
|
||||
|
||||
table_bayaran_history.clear();
|
||||
data.bayaranHistoryDetails.forEach((x, index) => {
|
||||
table_bayaran_history.row.add([
|
||||
index + 1,
|
||||
x.created_at,
|
||||
`RM ${x.duit_masuk} <a target='_blank' href="${x.resit_ansuran_link}" class='btn btn-info btn-sm'><span class='fas fa-print'></span></a>`,
|
||||
]).draw(false)
|
||||
]);
|
||||
});
|
||||
table_bayaran_history.draw();
|
||||
|
||||
table_marhun.clear();
|
||||
data.marhunDetails.forEach((x, index) => {
|
||||
table_marhun.row.add([
|
||||
index + 1,
|
||||
@@ -268,22 +257,14 @@
|
||||
x.berat,
|
||||
x.karat,
|
||||
`RM ${formatter.format(x.n_marhun)}`,
|
||||
x.nota
|
||||
]).draw(false)
|
||||
x.nota,
|
||||
]);
|
||||
});
|
||||
|
||||
// document.getElementById('marhunLoader').style.display = 'none';
|
||||
// const loader = document.getElementById('load-arrahn');
|
||||
loader.classList.add('d-none');
|
||||
|
||||
|
||||
table_marhun.draw();
|
||||
} catch (error) {
|
||||
const loader = document.getElementById('load-arrahn');
|
||||
console.error('Error fetching data:', error);
|
||||
// Hide loader in case of error
|
||||
// document.getElementById('marhunLoader').style.display = 'none';
|
||||
} finally {
|
||||
loader.classList.add('d-none');
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ Route::group(['middleware' => 'auth','verified'], function () {
|
||||
Route::get('/penyata/summaryarrahn/{kodcaw}/{norujukan}', 'App\Http\Controllers\SemakController@PenyataSummaryUpah')->name('penyata.summaryupah');
|
||||
|
||||
Route::get('/resit/tebus/{kodcaw}/{norujukan}',['as'=>'resit.tebus','uses'=>'App\Http\Controllers\SemakController@resittebus']);
|
||||
Route::get('/resit/{id}',['as'=>'resit.ansuran','uses'=>'App\Http\Controllers\SemakController@resit']);
|
||||
Route::get('/resit/{id}/{company}',['as'=>'resit.ansuran','uses'=>'App\Http\Controllers\SemakController@resit']);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user