From 5e3210454931071d66d8bb71a07cc5cfeadeaf94 Mon Sep 17 00:00:00 2001 From: kry008 Date: Fri, 3 Jan 2025 08:43:27 +0100 Subject: [PATCH] wydawanie puszek --- serwer/app/baza-import.sql | 1 + serwer/app/baza.sql | 1 + serwer/app/func.js | 1 + serwer/app/panelRoutes.js | 20 ++++++++++++-------- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/serwer/app/baza-import.sql b/serwer/app/baza-import.sql index 4db1676..703592d 100644 --- a/serwer/app/baza-import.sql +++ b/serwer/app/baza-import.sql @@ -131,6 +131,7 @@ CREATE TABLE IF NOT EXISTS `wolontariusz` ( `ostatniaZmiana` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `aktywny` tinyint(4) NOT NULL DEFAULT 1, `zaznacz` int(11) NOT NULL DEFAULT 0, + `puszkaWydana` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB; DROP TABLE IF EXISTS `sumaPrzeliczona`; diff --git a/serwer/app/baza.sql b/serwer/app/baza.sql index 6fcccf9..04cb511 100644 --- a/serwer/app/baza.sql +++ b/serwer/app/baza.sql @@ -131,6 +131,7 @@ CREATE TABLE IF NOT EXISTS `wolontariusz` ( `ostatniaZmiana` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `aktywny` tinyint(4) NOT NULL DEFAULT 1, `zaznacz` int(11) NOT NULL DEFAULT 0, + `puszkaWydana` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1; DROP TABLE IF EXISTS `sumaPrzeliczona`; diff --git a/serwer/app/func.js b/serwer/app/func.js index 379e5a9..642d3bf 100644 --- a/serwer/app/func.js +++ b/serwer/app/func.js @@ -425,6 +425,7 @@ CREATE TABLE IF NOT EXISTS \`wolontariusz\` ( \`ostatniaZmiana\` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), \`aktywny\` tinyint(4) NOT NULL DEFAULT 1, \`zaznacz\` int(11) NOT NULL DEFAULT 0, + \`puszkaWydana\` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (\`id\`) ) ENGINE=InnoDB; DROP TABLE IF EXISTS \`sumaPrzeliczona\`; diff --git a/serwer/app/panelRoutes.js b/serwer/app/panelRoutes.js index fbf9d6f..4bede14 100644 --- a/serwer/app/panelRoutes.js +++ b/serwer/app/panelRoutes.js @@ -113,7 +113,6 @@ panelRouter.get('/osobyLiczace', function(req, res) { loger(fs, 'Wyświetlono listę osób liczących', 'info'); }); }); - panelRouter.get('/kod', function(req, res) { var id = req.query.id; //SELECT qr FROM liczacy WHERE id = ? @@ -141,10 +140,6 @@ panelRouter.get('/kod', function(req, res) { } }); }); - - - - panelRouter.get('/dodajOsobeLiczaca', function(req, res) { var toReturn = headerHtml(); toReturn += menuHtml(1); @@ -206,7 +201,12 @@ panelRouter.get('/listaWolontariuszy', function(req, res) { result.forEach(function(row) { //jeżeli zaznacz, to kolor wiersza na rgba(0, 255, 0, 0.5) toReturn += ''; - toReturn += '' + row.numerIdentyfikatora + ''; + toReturn += ''; + if(row.puszkaWydana == 1) + toReturn += '' + row.numerIdentyfikatora + ''; + else + toReturn += row.numerIdentyfikatora; + toReturn += ''; toReturn += '' + row.imie + ''; toReturn += '' + row.nazwisko + ''; toReturn += '' + row.discord + ''; @@ -254,6 +254,7 @@ panelRouter.get('/edytujWolontariusza', function(req, res) { toReturn += 'PESEL'; toReturn += 'Terminal'; toReturn += 'Rodzic'; + toReturn += 'Puszka wydana'; toReturn += ''; toReturn += ''; toReturn += ''; @@ -272,9 +273,10 @@ panelRouter.post('/edytujWolontariusza', function(req, res) { var telefon = req.body.telefon; var pesel = req.body.pesel; var terminal = req.body.terminal == 1 ? 1 : 0; + var puszka = req.body.puszka == 1 ? 1 : 0; var rodzic = req.body.rodzic; //zapisz dane - con.query('UPDATE wolontariusz SET imie = ?, nazwisko = ?, discord = ?, email = ?, telefon = ?, pesel = ?, terminal = ?, rodzic = ? WHERE id = ?', [imie, nazwisko, discord, email, telefon, pesel, terminal, rodzic, id], function(err, result) { + con.query('UPDATE wolontariusz SET imie = ?, nazwisko = ?, discord = ?, email = ?, telefon = ?, pesel = ?, terminal = ?, rodzic = ?, puszkaWydana = ? WHERE id = ?', [imie, nazwisko, discord, email, telefon, pesel, terminal, rodzic, puszka, id], function(err, result) { if (err) throw err; res.redirect('/panel/listaWolontariuszy'); loger(fs, 'Edytowano wolontariusza o id: ' + id, 'info'); @@ -297,6 +299,7 @@ panelRouter.get('/dodajWolontariusza', function(req, res) { toReturn += 'Terminal'; toReturn += 'Rodzic'; toReturn += 'Zaznacz na liście'; + toReturn += 'Puszka wydana'; toReturn += ''; toReturn += ''; toReturn += ''; @@ -316,6 +319,7 @@ panelRouter.post('/dodajWolontariusza', function(req, res) { var terminal = req.body.terminal == 1 ? 1 : 0; var rodzic = req.body.rodzic; var zaznacz = req.body.zaznacz == 1 ? 1 : 0; + var puszka = req.body.puszka == 1 ? 1 : 0; con.query('SELECT * FROM wolontariusz WHERE numerIdentyfikatora = ? OR pesel = ?', [numerIdentyfikatora, pesel], function(err, result) { if (err) throw err; if (result.length > 0) { @@ -324,7 +328,7 @@ panelRouter.post('/dodajWolontariusza', function(req, res) { loger(fs, 'Nieudana próba dodania wolontariusza o numerze identyfikatora: ' + numerIdentyfikatora + ' lub peselu: ' + pesel.substring(0, 3) + '########', 'warning'); } else { //nie istnieje - con.query('INSERT INTO wolontariusz (numerIdentyfikatora, imie, nazwisko, discord, email, telefon, pesel, terminal, rodzic, zaznacz) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [numerIdentyfikatora, imie, nazwisko, discord, email, telefon, pesel, terminal, rodzic, zaznacz], function(err, result) { + con.query('INSERT INTO wolontariusz (numerIdentyfikatora, imie, nazwisko, discord, email, telefon, pesel, terminal, rodzic, zaznacz, puszkaWydana) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [numerIdentyfikatora, imie, nazwisko, discord, email, telefon, pesel, terminal, rodzic, zaznacz, puszka], function(err, result) { if (err) throw err; res.redirect('/panel/listaWolontariuszy'); loger(fs, 'Dodano wolontariusza o numerze identyfikatora: ' + numerIdentyfikatora + ' i peselu: ' + pesel.substring(0, 3) + '########', 'info');