This commit is contained in:
@@ -1436,31 +1436,39 @@
|
|||||||
// =========================================================================
|
// =========================================================================
|
||||||
// 4. UI INTERACTIONS & UTILITIES
|
// 4. UI INTERACTIONS & UTILITIES
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
function borrowItem(itemId) {
|
async function borrowItem(itemId) {
|
||||||
const selectedItem = (libraryItems || []).find(item => item._id === itemId);
|
const selectedItem = (libraryItems || []).find(item => item._id === itemId);
|
||||||
if (selectedItem && selectedItem.LibraryDisplayStatus === 'damaged') {
|
if (selectedItem && selectedItem.LibraryDisplayStatus === 'damaged') {
|
||||||
alert('Dieses Medium ist als defekt/zerstört markiert und kann nicht ausgeliehen werden.');
|
await customAlert('Dieses Medium ist als defekt/zerstört markiert und kann nicht ausgeliehen werden.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultCardId = activeStudentCardId || '';
|
const defaultCardId = activeStudentCardId || '';
|
||||||
const cardId = (window.prompt('Bitte Bibliotheksausweis-ID eingeben:', defaultCardId) || '').trim().toUpperCase();
|
const promptCardResult = await customPrompt('Bitte Bibliotheksausweis-ID eingeben:', defaultCardId);
|
||||||
|
if (promptCardResult === null) return;
|
||||||
|
|
||||||
|
const cardId = promptCardResult.trim().toUpperCase();
|
||||||
if (!cardId) {
|
if (!cardId) {
|
||||||
alert('Ausleihe abgebrochen: Für Bibliotheksmedien ist eine gültige Bibliotheksausweis-ID erforderlich.');
|
await customAlert('Ausleihe abgebrochen: Für Bibliotheksmedien ist eine gültige Bibliotheksausweis-ID erforderlich.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setActiveStudentCard(cardId);
|
setActiveStudentCard(cardId);
|
||||||
|
|
||||||
const durationInput = (window.prompt('Ausleihdauer in Tagen (optional):') || '').trim();
|
const promptDurationResult = await customPrompt('Ausleihdauer in Tagen (optional):');
|
||||||
|
if (promptDurationResult === null) return;
|
||||||
|
const durationInput = promptDurationResult.trim();
|
||||||
|
|
||||||
const maxAvailable = Math.max(1, parseInt(selectedItem?.AvailableGroupedCount || selectedItem?.Quantity || 1, 10) || 1);
|
const maxAvailable = Math.max(1, parseInt(selectedItem?.AvailableGroupedCount || selectedItem?.Quantity || 1, 10) || 1);
|
||||||
const countPrompt = (window.prompt(`Anzahl ausleihen? (Standard: 1, verfügbar: ${maxAvailable})`, '1') || '').trim();
|
const countPromptResult = await customPrompt(`Anzahl ausleihen? (Standard: 1, verfügbar: ${maxAvailable})`, '1');
|
||||||
let borrowCount = parseInt(countPrompt || '1', 10);
|
if (countPromptResult === null) return;
|
||||||
|
|
||||||
|
let borrowCount = parseInt(countPromptResult.trim() || '1', 10);
|
||||||
if (!Number.isFinite(borrowCount) || borrowCount < 1) {
|
if (!Number.isFinite(borrowCount) || borrowCount < 1) {
|
||||||
borrowCount = 1;
|
borrowCount = 1;
|
||||||
}
|
}
|
||||||
if (borrowCount > maxAvailable) {
|
if (borrowCount > maxAvailable) {
|
||||||
alert(`Es sind nur ${maxAvailable} Exemplar(e) verfügbar.`);
|
await customAlert(`Es sind nur ${maxAvailable} Exemplar(e) verfügbar.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user