mirror of
https://github.com/Matewoo/pdf-writer.git
synced 2026-11-18 18:42:50 +01:00
add daily soup
This commit is contained in:
+16
-8
@@ -50,9 +50,13 @@ db.exec(`
|
||||
date_title TEXT,
|
||||
daily_main TEXT,
|
||||
daily_side TEXT,
|
||||
halal BOOLEAN,
|
||||
veggi BOOLEAN,
|
||||
daily_price TEXT
|
||||
daily_halal BOOLEAN,
|
||||
daily_veggi BOOLEAN,
|
||||
daily_price TEXT,
|
||||
daily_soup TEXT,
|
||||
soup_halal BOOLEAN,
|
||||
soup_veggi BOOLEAN,
|
||||
soup_price TEXT
|
||||
)
|
||||
`);
|
||||
|
||||
@@ -112,8 +116,8 @@ app.post('/save-week-daily', (req, res) => {
|
||||
const { week, entries } = req.body;
|
||||
|
||||
const insert = db.prepare(`
|
||||
INSERT OR REPLACE INTO daily_entries (date, week, day_index, date_title, daily_main, daily_side, halal, veggi, daily_price)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT OR REPLACE INTO daily_entries (date, week, day_index, date_title, daily_main, daily_side, daily_halal, daily_veggi, daily_price, daily_soup, soup_halal, soup_veggi, soup_price)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`);
|
||||
|
||||
const transaction = db.transaction((entries) => {
|
||||
@@ -125,9 +129,13 @@ app.post('/save-week-daily', (req, res) => {
|
||||
entry.dateTitle,
|
||||
entry.dailyMain,
|
||||
entry.dailySide,
|
||||
entry.halal,
|
||||
entry.veggi,
|
||||
entry.dailyPrice
|
||||
entry.dailyHalal,
|
||||
entry.dailyVeggi,
|
||||
entry.dailyPrice,
|
||||
entry.dailySoup,
|
||||
entry.soupHalal,
|
||||
entry.soupVeggi,
|
||||
entry.soupPrice
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -31,15 +31,23 @@
|
||||
for (let i = 0; i < 5; i++) {
|
||||
document.write(`
|
||||
<div id="dayForm${i}" class="day-form ${i === 0 ? 'active' : ''}">
|
||||
<input type="text" class="input-field-20" name="dateTitle${i}" style="bottom: 60.5%; left: 13.4%" placeholder="Datum">
|
||||
<select class="input-field-19-h" name="halalVeggi${i}" style="bottom: 43.5%; left: 58%">
|
||||
<input type="text" class="input-field-20" name="dateTitle${i}" style="bottom: 65.5%; left: 13.2%" placeholder="Datum">
|
||||
<select class="input-field-19-h" name="dailyHalalVeggi${i}" style="bottom: 56.5%; left: 41.5%">
|
||||
<option value="" style="color:red;">----</option>
|
||||
<option value="halal" style="color:#00B050;">„HALAL“</option>
|
||||
<option value="veggi" style="color:#00B050;">„veggi“</option>
|
||||
</select>
|
||||
<input type="text" class="input-field-19-b" name="dailyMain${i}" style="bottom: 30.5%; left: 13.4%" placeholder="Tagesgericht">
|
||||
<input type="text" class="input-field-19" name="dailySide${i}" style="bottom: 24%; left: 13.4%" placeholder="Beilage">
|
||||
<input type="text" class="input-field-14-i" name="dailyPrice${i}" style="bottom: 13.3%; left: 13.4%" placeholder="Preis">
|
||||
<input type="text" class="input-field-19-b" name="dailyMain${i}" style="bottom: 48%; left: 13.2%" placeholder="Tagesgericht">
|
||||
<input type="text" class="input-field-19" name="dailySide${i}" style="bottom: 41.2%; left: 13.2%" placeholder="Beilage">
|
||||
<input type="text" class="input-field-14-i" name="dailyPrice${i}" style="bottom: 33.3%; left: 13.2%" placeholder="Preis">
|
||||
|
||||
<select class="input-field-19-h" name="soupHalalVeggi${i}" style="bottom: 22.7%; left: 32.5%">
|
||||
<option value="" style="color:red;">----</option>
|
||||
<option value="halal" style="color:#00B050;">„HALAL“</option>
|
||||
<option value="veggi" style="color:#00B050;">„veggi“</option>
|
||||
</select>
|
||||
<input type="text" class="input-field-19-b" name="dailySoup${i}" style="bottom: 14.5%; left: 13.2%" placeholder="Tagessuppe">
|
||||
<input type="text" class="input-field-14-i" name="soupPrice${i}" style="bottom: 6.3%; left: 13.2%" placeholder="Preis">
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,8 @@ function saveWeek() {
|
||||
currentDate.setDate(currentDate.getDate() + i);
|
||||
|
||||
// Anpassen der Werte entsprechend der daily_entries Tabelle
|
||||
const halalVeggiValue = document.querySelector(`select[name="halalVeggi${i}"]`).value;
|
||||
const dailyHalalVeggiValue = document.querySelector(`select[name="dailyHalalVeggi${i}"]`).value;
|
||||
const soupHalalVeggiValue = document.querySelector(`select[name="soupHalalVeggi${i}"]`).value;
|
||||
const entry = {
|
||||
date: currentDate.toISOString().split('T')[0],
|
||||
week: week,
|
||||
@@ -108,14 +109,20 @@ function saveWeek() {
|
||||
dateTitle: document.querySelector(`input[name="dateTitle${i}"]`).value,
|
||||
dailyMain: document.querySelector(`input[name="dailyMain${i}"]`).value,
|
||||
dailySide: document.querySelector(`input[name="dailySide${i}"]`).value,
|
||||
halal: halalVeggiValue === 'halal' ? 1 : 0,
|
||||
veggi: halalVeggiValue === 'veggi' ? 1 : 0,
|
||||
dailyPrice: document.querySelector(`input[name="dailyPrice${i}"]`).value
|
||||
dailyHalal: dailyHalalVeggiValue === 'halal' ? 1 : 0,
|
||||
dailyVeggi: dailyHalalVeggiValue === 'veggi' ? 1 : 0,
|
||||
dailyPrice: document.querySelector(`input[name="dailyPrice${i}"]`).value,
|
||||
dailySoup: document.querySelector(`input[name="dailySoup${i}"]`).value,
|
||||
soupHalal: soupHalalVeggiValue === 'halal' ? 1 : 0,
|
||||
soupVeggi: soupHalalVeggiValue === 'veggi' ? 1 : 0,
|
||||
soupPrice: document.querySelector(`input[name="soupPrice${i}"]`).value
|
||||
};
|
||||
|
||||
entries.push(entry);
|
||||
}
|
||||
|
||||
console.log('Saving week data:', { week, entries });
|
||||
|
||||
fetch('/save-week-daily', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -142,8 +149,11 @@ function loadWeekData(week) {
|
||||
document.querySelector(`input[name="dateTitle${i}"]`).value = '';
|
||||
document.querySelector(`input[name="dailyMain${i}"]`).value = '';
|
||||
document.querySelector(`input[name="dailySide${i}"]`).value = '';
|
||||
document.querySelector(`select[name="halalVeggi${i}"]`).value = '';
|
||||
document.querySelector(`select[name="dailyHalalVeggi${i}"]`).value = '';
|
||||
document.querySelector(`input[name="dailyPrice${i}"]`).value = '';
|
||||
document.querySelector(`input[name="dailySoup${i}"]`).value = '';
|
||||
document.querySelector(`select[name="soupHalalVeggi${i}"]`).value = '';
|
||||
document.querySelector(`input[name="soupPrice${i}"]`).value = '';
|
||||
}
|
||||
|
||||
// Fill input fields with loaded data
|
||||
@@ -152,18 +162,29 @@ function loadWeekData(week) {
|
||||
const dayIndex = entry.day_index;
|
||||
const dateTitleInput = document.querySelector(`input[name="dateTitle${dayIndex}"]`);
|
||||
const dailyPriceInput = document.querySelector(`input[name="dailyPrice${dayIndex}"]`);
|
||||
const halalVeggiSelect = document.querySelector(`select[name="halalVeggi${dayIndex}"]`);
|
||||
const dailyHalalVeggiSelect = document.querySelector(`select[name="dailyHalalVeggi${dayIndex}"]`);
|
||||
const soupPriceInput = document.querySelector(`input[name="soupPrice${dayIndex}"]`);
|
||||
const soupHalalVeggiSelect = document.querySelector(`select[name="soupHalalVeggi${dayIndex}"]`);
|
||||
|
||||
dateTitleInput.value = entry.date_title;
|
||||
document.querySelector(`input[name="dailyMain${dayIndex}"]`).value = entry.daily_main;
|
||||
document.querySelector(`input[name="dailySide${dayIndex}"]`).value = entry.daily_side;
|
||||
dailyPriceInput.value = entry.daily_price;
|
||||
if (entry.halal) {
|
||||
halalVeggiSelect.value = 'halal';
|
||||
} else if (entry.veggi) {
|
||||
halalVeggiSelect.value = 'veggi';
|
||||
document.querySelector(`input[name="dailySoup${dayIndex}"]`).value = entry.daily_soup;
|
||||
soupPriceInput.value = entry.soup_price;
|
||||
if (entry.daily_halal) {
|
||||
dailyHalalVeggiSelect.value = 'halal';
|
||||
} else if (entry.daily_veggi) {
|
||||
dailyHalalVeggiSelect.value = 'veggi';
|
||||
} else {
|
||||
halalVeggiSelect.value = '';
|
||||
dailyHalalVeggiSelect.value = '';
|
||||
}
|
||||
if (entry.soup_halal) {
|
||||
soupHalalVeggiSelect.value = 'halal';
|
||||
} else if (entry.soup_veggi) {
|
||||
soupHalalVeggiSelect.value = 'veggi';
|
||||
} else {
|
||||
soupHalalVeggiSelect.value = '';
|
||||
}
|
||||
|
||||
// Automatically fill dateTitle if empty
|
||||
@@ -182,6 +203,9 @@ function loadWeekData(week) {
|
||||
if (!dailyPriceInput.value) {
|
||||
dailyPriceInput.value = "6,50 € / 4,80 €";
|
||||
}
|
||||
if (!soupPriceInput.value) {
|
||||
soupPriceInput.value = "3,50 € / 2,50 €";
|
||||
}
|
||||
});
|
||||
|
||||
// Automatically fill dateTitle, dailyPrice if not in DB
|
||||
@@ -189,6 +213,7 @@ function loadWeekData(week) {
|
||||
if (!loadedDays.has(i)) {
|
||||
const dateTitleInput = document.querySelector(`input[name="dateTitle${i}"]`);
|
||||
const dailyPriceInput = document.querySelector(`input[name="dailyPrice${i}"]`);
|
||||
const soupPriceInput = document.querySelector(`input[name="soupPrice${i}"]`);
|
||||
|
||||
if (!dateTitleInput.value) {
|
||||
const currentDate = new Date(currentWeek);
|
||||
@@ -204,6 +229,9 @@ function loadWeekData(week) {
|
||||
if (!dailyPriceInput.value) {
|
||||
dailyPriceInput.value = "6,50 € / 4,80 €";
|
||||
}
|
||||
if (!soupPriceInput.value) {
|
||||
soupPriceInput.value = "3,50 € / 2,50 €";
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user