333 lines
12 KiB
JavaScript
333 lines
12 KiB
JavaScript
function csrf_token()
|
|
{
|
|
return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
|
}
|
|
|
|
async function fetchLoanRemaining(containerID, passport_serie, passport_id, account_number) {
|
|
if (! passport_serie || ! passport_id || ! account_number) {
|
|
Nova.error('Maglumat ýetmezçiligi bar');
|
|
return;
|
|
}
|
|
|
|
let cardHistoryDetailContainer = document.getElementById(containerID);
|
|
|
|
let formData = new FormData();
|
|
formData.append('passport_serie', passport_serie);
|
|
formData.append('passport_id', passport_id);
|
|
formData.append('account_number', account_number);
|
|
|
|
Nova.$progress.start()
|
|
|
|
Nova.request().post('/api/fetch-loan-remaining', formData).then(response => {
|
|
let result = response.data;
|
|
console.log(result)
|
|
|
|
if (result.errCode != 0) {
|
|
Nova.error(result.message)
|
|
|
|
cardHistoryDetailContainer.innerHTML = `
|
|
<h3><strong>${result.message}</strong></h3>
|
|
`;
|
|
|
|
return;
|
|
}
|
|
|
|
cardHistoryDetailContainer.innerHTML = `
|
|
<h4>Şahamça: <strong>${result.branchName}</strong></h4>
|
|
<h4>Müşderi: <strong>${result.clientName}</strong></h4>
|
|
<h4 class="mb-4">Şertnama belgisi: <strong>${result.docNum}</strong></h4>
|
|
|
|
<h4>Jemi karzyň möçberi: <strong>${result.docSum}</strong></h4>
|
|
|
|
<h4>Karz boýunça jemi galyndy: <strong>${result.balans}</strong></h4>
|
|
<h4>Hasaplama göterim (şu aý üçin): ${result.percentBalance}</h4>
|
|
<h4>Hasaplanan esasy bergi (şu aý üçin): ${result.docMonthSum}</h4>
|
|
|
|
<h4>Jemi tölenen möçberi: <strong>${result.docPayed}</strong></h4>
|
|
`;
|
|
})
|
|
.catch(error => console.log('error', error))
|
|
.finally(() => {
|
|
Nova.$progress.done()
|
|
});
|
|
}
|
|
|
|
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);
|
|
|
|
let formData = new FormData();
|
|
formData.append('passport_serie', passport_serie);
|
|
formData.append('passport_id', passport_id);
|
|
|
|
Nova.$progress.start()
|
|
|
|
Nova.request().post('/api/fetch-loan-history', formData).then(response => {
|
|
let result = response.data;
|
|
|
|
let recipients = Array.from(result.recipient);
|
|
|
|
if (recipients.length < 1) {
|
|
Nova.error('Karz taryhy ýok')
|
|
cardHistoryDetailContainer.innerHTML = `<strong><h3>Karz taryhy ýok</h3></strong>`;
|
|
|
|
return;
|
|
}
|
|
|
|
cardHistoryDetailContainer.innerHTML = `
|
|
<h4>Müşderi: <strong>${recipients[0].MUSDERI_DOLY_ADY}</strong></h4>
|
|
|
|
<p>
|
|
<ul>
|
|
${recipients.map(recipient => {
|
|
return `<li style="background: #a3c1f5;color: black;" class="p-3 relative rounded-lg">
|
|
Bellik: <strong>${recipient.BELLIK}</strong> <br />
|
|
Möçberi: <strong>${recipient.MOCBERI}</strong> <br />
|
|
Karz berilen senesi: <strong>${recipient.KARZ_BERLEN_SENESI}</strong> <br />
|
|
Karz sonky senesi: <strong>${recipient.KARZ_SONKY_SENESI}</strong> <br />
|
|
Karz göterimi: <strong>${recipient.KARZ_GOTERIMI}%</strong> <br />
|
|
</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) {
|
|
if (! passport_serie || ! passport_id || ! card_number || ! card_expiry_date) {
|
|
Nova.error('Maglumat ýetmezçiligi bar');
|
|
return;
|
|
}
|
|
|
|
let cardHistoryDetailContainer = document.getElementById(containerID);
|
|
|
|
let formData = new FormData();
|
|
formData.append('passport_serie', passport_serie);
|
|
formData.append('passport_id', passport_id);
|
|
formData.append('card_number', card_number);
|
|
formData.append('card_expiry_date', card_expiry_date);
|
|
|
|
Nova.$progress.start()
|
|
|
|
Nova.request().post('/api/fetch-card-history', formData).then(response => {
|
|
let result = response.data;
|
|
|
|
if (result.errCode != 0) {
|
|
Nova.error(result.message)
|
|
|
|
cardHistoryDetailContainer.innerHTML = `
|
|
<h3><strong>${result.message}</strong></h3>
|
|
`;
|
|
|
|
return;
|
|
}
|
|
|
|
let insideTemplate = ``;
|
|
Array.from(result.transactions).map(transaction => {
|
|
insideTemplate += `<li style="background: #a3c1f5;color: black;padding-top: 2.4em;" class="p-3 relative rounded-lg mb-2">
|
|
<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>`
|
|
})
|
|
|
|
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>${insideTemplate}</ul></p>
|
|
`;
|
|
})
|
|
.catch(error => console.log('error', error))
|
|
.finally(() => {
|
|
Nova.$progress.done()
|
|
});
|
|
}
|
|
|
|
// window.LaravelNovaWizardStore = {
|
|
// data: {
|
|
// steps: 0,
|
|
// currentStep: 1,
|
|
// },
|
|
|
|
// fields: {
|
|
// buttonsContainerElement: {},
|
|
// cancelFormButton: {},
|
|
// createFormButton: {},
|
|
// prevButtonElement: {},
|
|
// nextButtonElement: {},
|
|
// },
|
|
|
|
// nextStep() {
|
|
// if (this.data.steps > 0 && this.data.currentStep < this.data.steps) {
|
|
// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'none';
|
|
|
|
// this.data.currentStep++;
|
|
|
|
// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'inherit';
|
|
|
|
// return;
|
|
// }
|
|
|
|
// if (this.data.currentStep === this.data.steps) {
|
|
// this.hideNextButton()
|
|
// this.showFormSubmitButton()
|
|
// } else {
|
|
// this.hideFormSubmitButton()
|
|
// this.showNextButton()
|
|
// }
|
|
// },
|
|
|
|
// prevStep() {
|
|
// if (this.data.currentStep > 1) {
|
|
// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'none';
|
|
|
|
// this.data.currentStep--;
|
|
|
|
// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'inherit';
|
|
// }
|
|
// },
|
|
|
|
// hideNovaFormButtons() {
|
|
// this.fields.cancelFormButton = document.querySelector('button[dusk="cancel-create-button"]');
|
|
// this.fields.createFormButton = document.querySelector('button[dusk="create-button"]');
|
|
|
|
// this.fields.buttonsContainerElement = this.fields.createFormButton.parentNode;
|
|
// this.hideFormSubmitButton();
|
|
// this.hideFormCancelButton();
|
|
// },
|
|
|
|
// addWizardButtons() {
|
|
// this.fields.buttonsContainerElement.insertAdjacentHTML('afterbegin', this.nextButtonTemplate());
|
|
// this.fields.buttonsContainerElement.insertAdjacentHTML('afterbegin', this.prevButtonTemplate());
|
|
|
|
// this.fields.nextButtonElement = document.getElementById('laravel-nova-wizard-next-button');
|
|
// this.fields.prevButtonElement = document.getElementById('laravel-nova-wizard-prev-button');
|
|
|
|
// this.fields.nextButtonElement.addEventListener('click', () => {
|
|
// this.nextStep()
|
|
// })
|
|
|
|
// this.fields.prevButtonElement.addEventListener('click', () => {
|
|
// this.prevStep()
|
|
// })
|
|
// },
|
|
|
|
// nextButtonTemplate() {
|
|
// return `
|
|
// <button type="button" id="laravel-nova-wizard-next-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">
|
|
// <span class="flex items-center gap-1">Next</span>
|
|
// </button>
|
|
// `;
|
|
// },
|
|
|
|
// prevButtonTemplate() {
|
|
// return `
|
|
// <button type="button" id="laravel-nova-wizard-prev-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-red-500 border-red-500 hover:[&:not(:disabled)]:border-primary-400 text-white dark:text-gray-900">
|
|
// <span class="flex items-center gap-1">Previus</span>
|
|
// </button>
|
|
// `;
|
|
// },
|
|
|
|
// hidePrevButton() {
|
|
// this.fields.prevButtonElement.style.display = 'none'
|
|
// },
|
|
|
|
// showPrevButton() {
|
|
// this.fields.prevButtonElement.style.display = 'inherit'
|
|
// },
|
|
|
|
// hideNextButton() {
|
|
// this.fields.nextButtonElement.style.display = 'none'
|
|
// },
|
|
|
|
// showNextButton() {
|
|
// this.fields.nextButtonElement.style.display = 'inherit'
|
|
// },
|
|
|
|
// showFormSubmitButton() {
|
|
// this.fields.createFormButton.style.display = 'inherit';
|
|
// },
|
|
|
|
// hideFormSubmitButton() {
|
|
// this.fields.createFormButton.style.display = 'none';
|
|
// },
|
|
|
|
// hideFormCancelButton() {
|
|
// this.fields.cancelFormButton.style.display = 'none';
|
|
// }
|
|
// };
|
|
|
|
// function setupMultiStepWizard() {
|
|
// let refreshIntervalId = setInterval(() => {
|
|
// let formElement = document.querySelector('form');
|
|
|
|
// if (formElement) {
|
|
// clearInterval(refreshIntervalId)
|
|
|
|
// // Div container
|
|
// let fieldsContainerElement = formElement.firstChild;
|
|
// // Div elements
|
|
// let fieldElements = Array.from(fieldsContainerElement.children);
|
|
|
|
// // if there a less than 2 divs, no need to wizard it!
|
|
// if (fieldElements.length < 2) {
|
|
// return;
|
|
// }
|
|
|
|
// LaravelNovaWizardStore.data.steps = fieldElements.length;
|
|
// LaravelNovaWizardStore.hideNovaFormButtons()
|
|
// LaravelNovaWizardStore.addWizardButtons()
|
|
|
|
// let loopCount = 0;
|
|
// fieldElements.forEach(item => {
|
|
// loopCount++;
|
|
// item.setAttribute('wizard-step', loopCount)
|
|
|
|
// if (loopCount === 1) {
|
|
// return;
|
|
// }
|
|
|
|
// item.style.display = 'none'
|
|
// })
|
|
// }
|
|
// }, 300);
|
|
// }
|
|
|
|
// Nova.$on('liftedOff', () => {
|
|
// if (Nova.$router.page.component === 'Nova.Create') {
|
|
// setupMultiStepWizard()
|
|
// }
|
|
// })
|
|
|
|
// Nova.$router.on('success', (event) => {
|
|
// if (event.detail.page.component === 'Nova.Create') {
|
|
// setupMultiStepWizard()
|
|
// }
|
|
// })
|
|
|
|
// document.addEventListener('inertia:navigate', () => {
|
|
// console.log('page is updating')
|
|
// })
|
|
|
|
// // when app is booting
|
|
// Nova.booting((app, store) => {})
|