wip
This commit is contained in:
50
app/Http/Controllers/Api/FetchLoanHistoryController.php
Normal file
50
app/Http/Controllers/Api/FetchLoanHistoryController.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class FetchLoanHistoryController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fetch loan history
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'passport_serie' => ['required', 'string', 'max:255'],
|
||||||
|
'passport_id' => ['required', 'string', 'max:255'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
|
curl_setopt_array($curl, [
|
||||||
|
CURLOPT_URL => 'http://10.3.158.102:9999/api/loan/history/info',
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_ENCODING => '',
|
||||||
|
CURLOPT_MAXREDIRS => 10,
|
||||||
|
CURLOPT_TIMEOUT => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||||
|
CURLOPT_POSTFIELDS => sprintf('{
|
||||||
|
"idSeria": "%s",
|
||||||
|
"idNo": "%s"
|
||||||
|
}',
|
||||||
|
$request->passport_serie,
|
||||||
|
$request->passport_id,
|
||||||
|
),
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
'Accept: application/json',
|
||||||
|
'Content-Type: application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
curl_close($curl);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,10 +91,18 @@ class LoanOrderMobileFieldsForDetail
|
|||||||
|
|
||||||
new Panel(__('Card'), [
|
new Panel(__('Card'), [
|
||||||
NovaCustomHtml::make(__('Data'), 'card_name')
|
NovaCustomHtml::make(__('Data'), 'card_name')
|
||||||
|
->canSeeWhen('systemUser', $resource)
|
||||||
->html(view('orders.loan.mobile.card-history', [
|
->html(view('orders.loan.mobile.card-history', [
|
||||||
'resource' => $resource,
|
'resource' => $resource,
|
||||||
])->render())
|
])->render()),
|
||||||
->fillUsing(NovaForm::fillEmpty()),
|
]),
|
||||||
|
|
||||||
|
new Panel(__('Karz taryhy'), [
|
||||||
|
NovaCustomHtml::make(__('Karz taryhy'), 'loan_history')
|
||||||
|
->canSeeWhen('systemUser', $resource)
|
||||||
|
->html(view('orders.loan.mobile.loan-history', [
|
||||||
|
'resource' => $resource,
|
||||||
|
])->render()),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
new Panel(__('Contact data'), [
|
new Panel(__('Contact data'), [
|
||||||
|
|||||||
@@ -321,5 +321,6 @@
|
|||||||
"Loan Card": "Karz karty",
|
"Loan Card": "Karz karty",
|
||||||
"Send payment": "Tölegi geçir",
|
"Send payment": "Tölegi geçir",
|
||||||
"Currencies": "Walýutalar",
|
"Currencies": "Walýutalar",
|
||||||
"Passport number": "Pasport nomeri"
|
"Passport number": "Pasport nomeri",
|
||||||
|
"Fetch loan history": "Karz taryhyny görmek"
|
||||||
}
|
}
|
||||||
|
|||||||
63
resources/js/vendor/nova/js/additional.js
vendored
63
resources/js/vendor/nova/js/additional.js
vendored
@@ -3,6 +3,69 @@ function csrf_token()
|
|||||||
return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchLoanHistory(containerID, passport_serie, passport_id) {
|
||||||
|
if (! passport_serie || ! passport_id) {
|
||||||
|
Nova.error('Maglumat ýetmezçiligi bar');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cardHistoryDetailContainer = document.getElementById(containerID);
|
||||||
|
|
||||||
|
var headers = new Headers();
|
||||||
|
headers.append('Accept', 'application/json');
|
||||||
|
|
||||||
|
var formdata = new FormData();
|
||||||
|
formdata.append('passport_serie', passport_serie);
|
||||||
|
formdata.append('passport_id', passport_id);
|
||||||
|
|
||||||
|
Nova.$progress.start()
|
||||||
|
|
||||||
|
fetch('/api/fetch-loan-history', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: headers,
|
||||||
|
body: formdata,
|
||||||
|
redirect: 'follow'
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(result => {
|
||||||
|
console.log({result: result})
|
||||||
|
if (result.errCode != 0) {
|
||||||
|
Nova.error(result.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// cardHistoryDetailContainer.innerHTML = `
|
||||||
|
// <h4>Müşderi: <strong>${result.clientName}</strong></h4>
|
||||||
|
// <h4>Şahamça: <strong>${result.depName}</strong></h4>
|
||||||
|
// <h4 class="mb-4">Şertnama belgisi: <strong>${result.cardAccountNumber}</strong></h4>
|
||||||
|
|
||||||
|
// <p>
|
||||||
|
// <ul>
|
||||||
|
// ${Array.from(result.transactions).map(transaction => {
|
||||||
|
// return `<li style="background: #a3c1f5;color: black;" class="p-3 relative rounded-lg">
|
||||||
|
// <strong>${transaction['actionName']}</strong> <strong>${transaction['opersum']}</strong> <strong>${transaction['currency']}</strong>
|
||||||
|
|
||||||
|
// <strong style="top: 0; right: 0;" class="absolute p-2">${transaction['opername']}</strong>
|
||||||
|
|
||||||
|
// <p><strong>${
|
||||||
|
// new Date(transaction['trandate']).toLocaleDateString('en-GB', {
|
||||||
|
// year: 'numeric',
|
||||||
|
// month: '2-digit',
|
||||||
|
// day: '2-digit',
|
||||||
|
// }).replaceAll('/', '.')
|
||||||
|
// }</strong></p>
|
||||||
|
// </li>`;
|
||||||
|
// })}
|
||||||
|
// </ul>
|
||||||
|
// </p>
|
||||||
|
// `;
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(error => console.log('error', error))
|
||||||
|
.finally(() => {
|
||||||
|
Nova.$progress.done()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchCardHistory(passport_serie, passport_id, card_number, card_expiry_date, containerID) {
|
async function fetchCardHistory(passport_serie, passport_id, card_number, card_expiry_date, containerID) {
|
||||||
if (! passport_serie || ! passport_id || ! card_number || ! card_expiry_date) {
|
if (! passport_serie || ! passport_id || ! card_number || ! card_expiry_date) {
|
||||||
Nova.error('Maglumat ýetmezçiligi bar');
|
Nova.error('Maglumat ýetmezçiligi bar');
|
||||||
|
|||||||
20
resources/views/orders/loan/mobile/loan-history.blade.php
Normal file
20
resources/views/orders/loan/mobile/loan-history.blade.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
@php
|
||||||
|
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="loan-history-container">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="border text-left appearance-none cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 relative disabled:cursor-not-allowed inline-flex items-center justify-center shadow h-9 px-3 bg-primary-500 border-primary-500 hover:[&:not(:disabled)]:bg-primary-400 hover:[&:not(:disabled)]:border-primary-400 text-white dark:text-gray-900"
|
||||||
|
onclick="fetchLoanHistory(
|
||||||
|
'loan-history-container',
|
||||||
|
'{{ $resource->passport_serie }}',
|
||||||
|
'{{ $resource->passport_id }}',
|
||||||
|
)">
|
||||||
|
<span class="flex items-center gap-1">Karz taryhyny ýükle</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div id="loan-history-container">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\Api\FetchLoanHistoryController;
|
||||||
use App\Http\Controllers\FetchCardHistoryController;
|
use App\Http\Controllers\FetchCardHistoryController;
|
||||||
use App\Http\Controllers\MetricsController;
|
use App\Http\Controllers\MetricsController;
|
||||||
use App\Http\Controllers\ProfileController;
|
use App\Http\Controllers\ProfileController;
|
||||||
@@ -24,6 +25,9 @@ use Illuminate\Support\Facades\Route;
|
|||||||
// Fetch card history...
|
// Fetch card history...
|
||||||
Route::post('fetch-card-history', [FetchCardHistoryController::class, 'index']);
|
Route::post('fetch-card-history', [FetchCardHistoryController::class, 'index']);
|
||||||
|
|
||||||
|
// Fetch loan history...
|
||||||
|
Route::get('fetch-loan-history', [FetchLoanHistoryController::class, 'index']);
|
||||||
|
|
||||||
// Auth...
|
// Auth...
|
||||||
Route::post('auth/register', [ApiAuthController::class, 'register']);
|
Route::post('auth/register', [ApiAuthController::class, 'register']);
|
||||||
Route::post('auth/login', [ApiAuthController::class, 'login']);
|
Route::post('auth/login', [ApiAuthController::class, 'login']);
|
||||||
|
|||||||
Reference in New Issue
Block a user