Przygotowanie
commit
6335e35940
|
@ -0,0 +1,5 @@
|
||||||
|
serwer/node_modules
|
||||||
|
serwer/app/package-lock.json
|
||||||
|
serwer/package-lock.json
|
||||||
|
serwer/.env
|
||||||
|
serwer/prod.env
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cd serwer
|
||||||
|
# Funkcja do sprawdzania dostępności polecenia
|
||||||
|
command_exists() {
|
||||||
|
command -v "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Funkcja do uruchamiania polecenia na różnych systemach
|
||||||
|
run_command() {
|
||||||
|
if [ "$OS" = "Windows_NT" ]; then
|
||||||
|
cmd.exe /C "$1"
|
||||||
|
else
|
||||||
|
eval "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sprawdzenie systemu operacyjnego
|
||||||
|
if [ "$OS" = "Windows_NT" ]; then
|
||||||
|
echo "Wykryto system Windows."
|
||||||
|
WINDOWS=true
|
||||||
|
else
|
||||||
|
echo "Wykryto system Unix/MacOS."
|
||||||
|
WINDOWS=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sprawdź czy jest dostępne `docker compose`
|
||||||
|
if command_exists "docker" && docker compose version >/dev/null 2>&1; then
|
||||||
|
echo "Docker Compose dostępny jako 'docker compose'."
|
||||||
|
COMPOSE_COMMAND="docker compose"
|
||||||
|
|
||||||
|
# Sprawdź czy jest dostępne `docker-compose`
|
||||||
|
elif command_exists "docker-compose"; then
|
||||||
|
echo "Docker Compose dostępny jako 'docker-compose'."
|
||||||
|
COMPOSE_COMMAND="docker-compose"
|
||||||
|
|
||||||
|
# Jeśli brak obu, wyświetl komunikat i zakończ
|
||||||
|
else
|
||||||
|
echo "Docker Compose nie jest zainstalowany. Zainstaluj go przed uruchomieniem tego skryptu."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Uruchomienie docker compose up
|
||||||
|
if [ "$WINDOWS" = true ]; then
|
||||||
|
run_command "$COMPOSE_COMMAND up --build -d"
|
||||||
|
else
|
||||||
|
$COMPOSE_COMMAND up --build -d
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Docker Compose został uruchomiony pomyślnie."
|
||||||
|
else
|
||||||
|
echo "Wystąpił błąd podczas uruchamiania Docker Compose."
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -0,0 +1,21 @@
|
||||||
|
Domyślne dane dostępowe:
|
||||||
|
|
||||||
|
```
|
||||||
|
Login: szef
|
||||||
|
Hasło: szef
|
||||||
|
```
|
||||||
|
|
||||||
|
Domyślnie działa na ADRESIP:8880
|
||||||
|
|
||||||
|
## Jeżeli chcesz korzystać za darmo, w stopka musi pozostać niezmieniona, a także widoczna na każdej stronie z wyjątkiem stron druku list
|
||||||
|
|
||||||
|
# WOŚP APP by KRY008
|
||||||
|
Pomocnik dla sztabu przy rozliczeniach wolontariuszy
|
||||||
|
|
||||||
|
## Wymagania
|
||||||
|
- Docker desktop (wybrać Docker Personal na stronie https://www.docker.com/products/docker-desktop i założyć darmowe konto)
|
||||||
|
|
||||||
|
## Instalacja
|
||||||
|
Uruchomić skrypt odpowiednio dla systemu operacyjnego:
|
||||||
|
- Windows: `windows.bat`
|
||||||
|
- MacOS lub Linux: `macOs-i-Linux.sh`
|
|
@ -0,0 +1,22 @@
|
||||||
|
#Dockerfile
|
||||||
|
# Użycie oficjalnego obrazu Node.js
|
||||||
|
FROM node:20
|
||||||
|
|
||||||
|
# Ustawienie katalogu roboczego w kontenerze
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# Kopiowanie plików aplikacji
|
||||||
|
COPY app/ ./
|
||||||
|
COPY prod.env .env
|
||||||
|
|
||||||
|
# Instalowanie zależności
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Ustawienie zmiennej środowiskowej (opcjonalnie)
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Ekspozycja portu (jeśli aplikacja tego wymaga)
|
||||||
|
EXPOSE 8880
|
||||||
|
|
||||||
|
# Uruchomienie aplikacji
|
||||||
|
CMD ["npm", "start"]
|
|
@ -0,0 +1,16 @@
|
||||||
|
FROM mysql:8.0
|
||||||
|
|
||||||
|
# Definiowanie argumentów, które można przekazać z docker-compose.yml
|
||||||
|
ARG MYSQL_ROOT_PASSWORD
|
||||||
|
ARG MYSQL_DATABASE
|
||||||
|
ARG MYSQL_USER
|
||||||
|
ARG MYSQL_PASSWORD
|
||||||
|
|
||||||
|
# Ustawienie zmiennych środowiskowych na podstawie argumentów
|
||||||
|
ENV MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
|
||||||
|
ENV MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||||
|
ENV MYSQL_USER=${MYSQL_USER}
|
||||||
|
ENV MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
||||||
|
|
||||||
|
# Kopiowanie skryptu SQL do inicjalizacji bazy danych
|
||||||
|
COPY app/baza-import.sql /docker-entrypoint-initdb.d/
|
|
@ -0,0 +1,182 @@
|
||||||
|
const express = require('express');
|
||||||
|
const route = express.Router();
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
require('dotenv').config();
|
||||||
|
//mysql
|
||||||
|
var mysql = require('mysql2');
|
||||||
|
var con = mysql.createConnection({
|
||||||
|
host: process.env.MYSQLHOST,
|
||||||
|
user: process.env.MYSQLUSER,
|
||||||
|
password: process.env.MYSQLPASS,
|
||||||
|
port : process.env.MYSQLPORT,
|
||||||
|
database: process.env.MYSQLDB,
|
||||||
|
insecureAuth : true
|
||||||
|
|
||||||
|
});
|
||||||
|
con.connect(function(err) {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log('Connected!');
|
||||||
|
|
||||||
|
});
|
||||||
|
var cookie = require('cookie');
|
||||||
|
var app = express();
|
||||||
|
var bodyParser = require('body-parser');
|
||||||
|
app.use(bodyParser.urlencoded({
|
||||||
|
extended: true
|
||||||
|
}));
|
||||||
|
//import functions from func.js
|
||||||
|
const {makeid, loger} = require('./func.js');
|
||||||
|
|
||||||
|
//login via api
|
||||||
|
route.post('/', function(req, res) {
|
||||||
|
//in post there is login and password (already hashed)
|
||||||
|
console.log(req.body);
|
||||||
|
var login = req.body.login;
|
||||||
|
var password = req.body.password;
|
||||||
|
con.query('SELECT * FROM login WHERE login = ? AND haslo = ? AND aktywne = 1', [login, password], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
var token = makeid(32);
|
||||||
|
con.query('INSERT INTO tokeny (token, typ, userId) VALUES (?, 1, ?)', [token, result[0].id], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.cookie('token', token);
|
||||||
|
res.json({status: 'ok', token: token});
|
||||||
|
loger(fs, 'Użytkownik zalogował się do panelu, token: ' + token, 'info');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//send code 401
|
||||||
|
res.status(401).json({status: 'error'});
|
||||||
|
loger(fs, 'Użytkownik nie zalogował się do panelu, login: ' + login, 'error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
route.use(function(req, res, next) {
|
||||||
|
var cookies = cookie.parse(req.headers.cookie || '') || req.body.token || req.query.token || req.headers['x-access-token'];
|
||||||
|
var token = cookies.token;
|
||||||
|
con.query('SELECT * FROM tokeny, login WHERE token = ? AND tokeny.userId = login.id AND aktywny = 1', [token], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
req.user = result[0];
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
res.json({status: 'not logged', goTo: '/api'});
|
||||||
|
loger(fs, 'Użytkownik nie zalogował się do panelu, token: ' + token, 'error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
route.all("/test", function(req, res) {
|
||||||
|
res.json({status: 'ok'});
|
||||||
|
loger(fs, 'Użytkownik wykonał test', 'info');
|
||||||
|
});
|
||||||
|
|
||||||
|
route.get("/osobyLiczace", function(req, res) {
|
||||||
|
con.query('SELECT * FROM liczacy WHERE aktywne = 1', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
loger(fs, 'Użytkownik wyświetlił listę osób liczących', 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
route.post("/osobyLiczace", function(req, res) {
|
||||||
|
//sprawdzenie czy nie ma już takiej osoby
|
||||||
|
con.query('SELECT * FROM liczacy WHERE imie = ? AND nazwisko = ? AND aktywne = 1', [req.body.imie, req.body.nazwisko], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
res.json({status: 'error', message: 'Taka osoba już istnieje.'});
|
||||||
|
loger(fs, 'Użytkownik próbował dodać osobę liczącą, która już istnieje', 'error');
|
||||||
|
} else {
|
||||||
|
con.query('INSERT INTO liczacy (imie, nazwisko) VALUES (?, ?)', [req.body.imie, req.body.nazwisko], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json({status: 'ok'});
|
||||||
|
loger(fs, 'Użytkownik dodał osobę liczącą', 'info');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
route.get("/listaWolontariuszy", function(req, res) {
|
||||||
|
con.query('SELECT * FROM wolontariusz WHERE aktywny = 1', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
loger(fs, 'Użytkownik wyświetlił listę wolontariuszy', 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//edycja wolontariusza
|
||||||
|
route.put("/listaWolontariuszy", function(req, res) {
|
||||||
|
con.query('UPDATE wolontariusz SET imie = ?, nazwisko = ?, discord = ?, email = ?, telefon = ?, pesel = ?, terminal = ?, aktywny = ? WHERE id = ?', [req.body.imie, req.body.nazwisko, req.body.discord, req.body.email, req.body.telefon, req.body.pesel, req.body.terminal, req.body.aktywny, req.body.id], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json({status: 'ok'});
|
||||||
|
loger(fs, 'Użytkownik edytował wolontariusza', 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//dodanie rozliczenia
|
||||||
|
route.post("/rozlicz", function(req, res) {
|
||||||
|
//sprawdzenie czy nie ma już takiego wolontariusza
|
||||||
|
con.query('SELECT * FROM rozliczenie WHERE wolontariuszID = ? AND aktywne = 1', [req.body.wolontariuszID], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
res.json({status: 'error', message: 'Taki wolontariusz już rozliczony.'});
|
||||||
|
loger(fs, 'Użytkownik próbował dodać rozliczenie, które już istnieje ID: ' + req.body.wolontariuszID, 'error');
|
||||||
|
} else {
|
||||||
|
$sql = "INSERT INTO `rozliczenie` (`id`, `wolontariuszID`, `czasRozliczenia`, `terminal`, `sumaZTerminala`, `1gr`, `2gr`, `5gr`, `10gr`, `20gr`, `50gr`, `1zl`, `2zl`, `5zl`, `10zl`, `20zl`, `50zl`, `100zl`, `200zl`, `500zl`, `walutaObca`, `daryInne`, `uwagi`, `liczacy1`, `liczacy2`, `liczacy3`, `sala`, `weryfikowal`, `wpisaneDoBSS`, `ostatniaZmiana`, `aktywne`) ";
|
||||||
|
$sql += 'VALUES (NULL, ?, CURRENT_TIME(), ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,CURRENT_TIME(),1)';
|
||||||
|
con.query($sql, [req.body.wolontariuszID, req.body.terminal, req.body.sumaZTerminala, req.body['1gr'], req.body['2gr'], req.body['5gr'], req.body['10gr'], req.body['20gr'], req.body['50gr'], req.body['1zl'], req.body['2zl'], req.body['5zl'], req.body['10zl'], req.body['20zl'], req.body['50zl'], req.body['100zl'], req.body['200zl'], req.body['500zl'], req.body.walutaObca, req.body.daryInne, req.body.uwagi, req.body.liczacy1, req.body.liczacy2, req.body.liczacy3, req.body.sala, req.body.weryfikowal], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json({status: 'ok'});
|
||||||
|
loger(fs, 'Użytkownik dodał rozliczenie dla wolontariusza ID: ' + req.body.wolontariuszID, 'info');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//lista rozliczeń
|
||||||
|
route.get("/rozliczenia", function(req, res) {
|
||||||
|
con.query('SELECT * FROM rozliczenie WHERE aktywne = 1', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
loger(fs, 'Użytkownik wyświetlił listę rozliczeń', 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//edycja rozliczenia
|
||||||
|
route.put("/rozliczenia", function(req, res) {
|
||||||
|
con.query('UPDATE rozliczenie SET wolontariuszID = ?, czasRozliczenia = ?, terminal = ?, sumaZTerminala = ?, `1gr` = ?, `2gr` = ?, `5gr` = ?, `10gr` = ?, `20gr` = ?, `50gr` = ?, `1zl` = ?, `2zl` = ?, `5zl` = ?, `10zl` = ?, `20zl` = ?, `50zl` = ?, `100zl` = ?, `200zl` = ?, `500zl` = ?, walutaObca = ?, daryInne = ?, uwagi = ?, liczacy1 = ?, liczacy2 = ?, liczacy3 = ?, sala = ?, weryfikowal = ?, wpisaneDoBSS = ?, ostatniaZmiana = ? WHERE id = ?', [req.body.wolontariuszID, req.body.czasRozliczenia, req.body.terminal, req.body.sumaZTerminala, req.body['1gr'], req.body['2gr'], req.body['5gr'], req.body['10gr'], req.body['20gr'], req.body['50gr'], req.body['1zl'], req.body['2zl'], req.body['5zl'], req.body['10zl'], req.body['20zl'], req.body['50zl'], req.body['100zl'], req.body['200zl'], req.body['500zl'], req.body.walutaObca, req.body.daryInne, req.body.uwagi, req.body.liczacy1, req.body.liczacy2, req.body.liczacy3, req.body.sala, req.body.weryfikowal, req.body.wpisaneDoBSS, req.body.ostatniaZmiana, req.body.id], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json({status: 'ok'});
|
||||||
|
loger(fs, 'Użytkownik edytował rozliczenie ID: ' + req.body.id, 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//statystyki
|
||||||
|
route.get("/statystyki/zebranePrzezWolontariuszy", function(req, res) {
|
||||||
|
con.query('SELECT * FROM SumaZebranaPrzezWolontariuszy ORDER BY suma ASC', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
route.get("/statystyki/liczacy", function(req, res) {
|
||||||
|
con.query('SELECT * FROM sumaPrzeliczona ORDER BY sumaPrzeliczona DESC', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
route.get("/statystyki/rozliczenia", function(req, res) {
|
||||||
|
con.query('SELECT COUNT(*) AS liczba FROM rozliczenie WHERE aktywne = 1', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
route.get("/statystyki/rozliczenia/ostatnie", function(req, res) {
|
||||||
|
con.query('SELECT * FROM rozliczenie WHERE aktywne = 1 ORDER BY czasRozliczenia DESC LIMIT 10', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.json(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = route;
|
|
@ -0,0 +1,159 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS `liczacy` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`imie` varchar(255) NOT NULL,
|
||||||
|
`nazwisko` varchar(255) NOT NULL,
|
||||||
|
`aktywne` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
`qr` varchar(25) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `login` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`login` text NOT NULL,
|
||||||
|
`haslo` text NOT NULL,
|
||||||
|
`kto` text NOT NULL,
|
||||||
|
`aktywne` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `rozliczenie` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`wolontariuszID` int(11) NOT NULL,
|
||||||
|
`czasRozliczenia` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`terminal` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`sumaZTerminala` float DEFAULT NULL,
|
||||||
|
`1gr` int(11) DEFAULT NULL,
|
||||||
|
`2gr` int(11) DEFAULT NULL,
|
||||||
|
`5gr` int(11) DEFAULT NULL,
|
||||||
|
`10gr` int(11) DEFAULT NULL,
|
||||||
|
`20gr` int(11) DEFAULT NULL,
|
||||||
|
`50gr` int(11) DEFAULT NULL,
|
||||||
|
`1zl` int(11) DEFAULT NULL,
|
||||||
|
`2zl` int(11) DEFAULT NULL,
|
||||||
|
`5zl` int(11) DEFAULT NULL,
|
||||||
|
`10zl` int(11) DEFAULT NULL,
|
||||||
|
`20zl` int(11) DEFAULT NULL,
|
||||||
|
`50zl` int(11) DEFAULT NULL,
|
||||||
|
`100zl` int(11) DEFAULT NULL,
|
||||||
|
`200zl` int(11) DEFAULT NULL,
|
||||||
|
`500zl` int(11) DEFAULT NULL,
|
||||||
|
`walutaObca` text NOT NULL,
|
||||||
|
`daryInne` text DEFAULT NULL,
|
||||||
|
`uwagi` text DEFAULT NULL,
|
||||||
|
`liczacy1` int(11) NOT NULL,
|
||||||
|
`liczacy2` int(11) NOT NULL,
|
||||||
|
`liczacy3` int(11) DEFAULT NULL,
|
||||||
|
`sala` varchar(10) NOT NULL,
|
||||||
|
`weryfikowal` int(11) NOT NULL,
|
||||||
|
`wpisaneDoBSS` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`ostatniaZmiana` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||||
|
`aktywne` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `wolontariuszID` (`wolontariuszID`),
|
||||||
|
KEY `liczacy1` (`liczacy1`),
|
||||||
|
KEY `liczacy2` (`liczacy2`),
|
||||||
|
KEY `liczacy3` (`liczacy3`),
|
||||||
|
KEY `weryfikowal` (`weryfikowal`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(65,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona1` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona2` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona3` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `SumaZebranaPrzezWolontariuszy` (
|
||||||
|
`numerIdentyfikatora` varchar(8)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`suma` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `suma_przeliczona2` (
|
||||||
|
`ID_Liczącego` int(11)
|
||||||
|
,`Imię` varchar(255)
|
||||||
|
,`Nazwisko` varchar(255)
|
||||||
|
,`Suma_Przeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumy` (
|
||||||
|
`wolontariuszID` int(11)
|
||||||
|
,`suma` decimal(49,2)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `tokeny` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`token` text NOT NULL,
|
||||||
|
`czasAktywacji` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`typ` int(11) NOT NULL DEFAULT 1,
|
||||||
|
`userId` int(11) NOT NULL,
|
||||||
|
`aktywny` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `userId` (`userId`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `tokenyLiczacy` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`token` varchar(255) NOT NULL,
|
||||||
|
`typ` int(11) NOT NULL,
|
||||||
|
`userId` int(11) NOT NULL,
|
||||||
|
`czasAktywacji` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`aktywny` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wolontariusz` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`numerIdentyfikatora` varchar(8) NOT NULL,
|
||||||
|
`imie` varchar(255) NOT NULL,
|
||||||
|
`nazwisko` varchar(255) NOT NULL,
|
||||||
|
`discord` text NOT NULL,
|
||||||
|
`email` text NOT NULL,
|
||||||
|
`telefon` varchar(12) NOT NULL,
|
||||||
|
`pesel` varchar(11) NOT NULL,
|
||||||
|
`rodzic` varchar(255) NOT NULL DEFAULT 'BRAK',
|
||||||
|
`terminal` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`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,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona` AS SELECT `combinedData`.`idLiczacego` AS `idLiczacego`, `combinedData`.`imie` AS `imie`, `combinedData`.`nazwisko` AS `nazwisko`, sum(`combinedData`.`sumaPrzeliczona`) AS `sumaPrzeliczona` FROM (select `r`.`liczacy1` AS `idLiczacego`,`l`.`imie` AS `imie`,`l`.`nazwisko` AS `nazwisko`,sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` from (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy1` = `l`.`id`)) group by `r`.`liczacy1` union all select `r`.`liczacy2` AS `idLiczacego`,`l`.`imie` AS `imie`,`l`.`nazwisko` AS `nazwisko`,sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` from (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy2` = `l`.`id`)) group by `r`.`liczacy2` union all select `r`.`liczacy3` AS `idLiczacego`,`l`.`imie` AS `imie`,`l`.`nazwisko` AS `nazwisko`,sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` from (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy3` = `l`.`id`)) group by `r`.`liczacy3`) AS `combinedData` GROUP BY `combinedData`.`idLiczacego`, `combinedData`.`imie`, `combinedData`.`nazwisko` ;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona1`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona1` AS SELECT `r`.`liczacy1` AS `idLiczacego`, `l`.`imie` AS `imie`, `l`.`nazwisko` AS `nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy1` = `l`.`id`)) GROUP BY `r`.`liczacy1` ;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona2`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona2` AS SELECT `r`.`liczacy2` AS `idLiczacego`, `l`.`imie` AS `imie`, `l`.`nazwisko` AS `nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy2` = `l`.`id`)) GROUP BY `r`.`liczacy2` ;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona3`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona3` AS SELECT `r`.`liczacy3` AS `idLiczacego`, `l`.`imie` AS `imie`, `l`.`nazwisko` AS `nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy3` = `l`.`id`)) GROUP BY `r`.`liczacy3` ;
|
||||||
|
DROP TABLE IF EXISTS `SumaZebranaPrzezWolontariuszy`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `SumaZebranaPrzezWolontariuszy` AS SELECT `wolontariusz`.`numerIdentyfikatora` AS `numerIdentyfikatora`, `wolontariusz`.`imie` AS `imie`, `wolontariusz`.`nazwisko` AS `nazwisko`, `sumy`.`suma` AS `suma` FROM (`wolontariusz` join `sumy`) WHERE `wolontariusz`.`id` = `sumy`.`wolontariuszID` ORDER BY `wolontariusz`.`numerIdentyfikatora` ASC ;
|
||||||
|
DROP TABLE IF EXISTS `suma_przeliczona2`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `suma_przeliczona2` AS SELECT coalesce(`r`.`liczacy1`,`r`.`liczacy2`,`r`.`liczacy3`) AS `ID_Liczącego`, `l`.`imie` AS `Imię`, `l`.`nazwisko` AS `Nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `Suma_Przeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(coalesce(`r`.`liczacy1`,`r`.`liczacy2`,`r`.`liczacy3`) = `l`.`id`)) GROUP BY coalesce(`r`.`liczacy1`,`r`.`liczacy2`,`r`.`liczacy3`), `l`.`imie`, `l`.`nazwisko` ;
|
||||||
|
DROP TABLE IF EXISTS `sumy`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumy` AS SELECT `rozliczenie`.`wolontariuszID` AS `wolontariuszID`, sum(`rozliczenie`.`1gr` * 0.01 + `rozliczenie`.`2gr` * 0.02 + `rozliczenie`.`5gr` * 0.05 + `rozliczenie`.`10gr` * 0.1 + `rozliczenie`.`20gr` * 0.2 + `rozliczenie`.`50gr` * 0.5 + `rozliczenie`.`1zl` + `rozliczenie`.`2zl` * 2 + `rozliczenie`.`5zl` * 5 + `rozliczenie`.`10zl` * 10 + `rozliczenie`.`20zl` * 20 + `rozliczenie`.`50zl` * 50 + `rozliczenie`.`100zl` * 100 + `rozliczenie`.`200zl` * 200 + `rozliczenie`.`500zl` * 500) AS `suma` FROM `rozliczenie` GROUP BY `rozliczenie`.`wolontariuszID` ;
|
||||||
|
|
||||||
|
INSERT INTO `login` (`id`, `login`, `haslo`, `kto`, `aktywne`) VALUES
|
||||||
|
(NULL, 'szef', '0c1aba4f114d80faa3b08016fe94443462adadd7', 'Szef Sztabu', 1);
|
|
@ -0,0 +1,156 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS `liczacy` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`imie` varchar(255) NOT NULL,
|
||||||
|
`nazwisko` varchar(255) NOT NULL,
|
||||||
|
`aktywne` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
`qr` varchar(25) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `login` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`login` text NOT NULL,
|
||||||
|
`haslo` text NOT NULL,
|
||||||
|
`kto` text NOT NULL,
|
||||||
|
`aktywne` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `rozliczenie` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`wolontariuszID` int(11) NOT NULL,
|
||||||
|
`czasRozliczenia` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`terminal` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`sumaZTerminala` float DEFAULT NULL,
|
||||||
|
`1gr` int(11) DEFAULT NULL,
|
||||||
|
`2gr` int(11) DEFAULT NULL,
|
||||||
|
`5gr` int(11) DEFAULT NULL,
|
||||||
|
`10gr` int(11) DEFAULT NULL,
|
||||||
|
`20gr` int(11) DEFAULT NULL,
|
||||||
|
`50gr` int(11) DEFAULT NULL,
|
||||||
|
`1zl` int(11) DEFAULT NULL,
|
||||||
|
`2zl` int(11) DEFAULT NULL,
|
||||||
|
`5zl` int(11) DEFAULT NULL,
|
||||||
|
`10zl` int(11) DEFAULT NULL,
|
||||||
|
`20zl` int(11) DEFAULT NULL,
|
||||||
|
`50zl` int(11) DEFAULT NULL,
|
||||||
|
`100zl` int(11) DEFAULT NULL,
|
||||||
|
`200zl` int(11) DEFAULT NULL,
|
||||||
|
`500zl` int(11) DEFAULT NULL,
|
||||||
|
`walutaObca` text NOT NULL,
|
||||||
|
`daryInne` text DEFAULT NULL,
|
||||||
|
`uwagi` text DEFAULT NULL,
|
||||||
|
`liczacy1` int(11) NOT NULL,
|
||||||
|
`liczacy2` int(11) NOT NULL,
|
||||||
|
`liczacy3` int(11) DEFAULT NULL,
|
||||||
|
`sala` varchar(10) NOT NULL,
|
||||||
|
`weryfikowal` int(11) NOT NULL,
|
||||||
|
`wpisaneDoBSS` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`ostatniaZmiana` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||||
|
`aktywne` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `wolontariuszID` (`wolontariuszID`),
|
||||||
|
KEY `liczacy1` (`liczacy1`),
|
||||||
|
KEY `liczacy2` (`liczacy2`),
|
||||||
|
KEY `liczacy3` (`liczacy3`),
|
||||||
|
KEY `weryfikowal` (`weryfikowal`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1;
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(65,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona1` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona2` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumaPrzeliczona3` (
|
||||||
|
`idLiczacego` int(11)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`sumaPrzeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `SumaZebranaPrzezWolontariuszy` (
|
||||||
|
`numerIdentyfikatora` varchar(8)
|
||||||
|
,`imie` varchar(255)
|
||||||
|
,`nazwisko` varchar(255)
|
||||||
|
,`suma` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `suma_przeliczona2` (
|
||||||
|
`ID_Liczącego` int(11)
|
||||||
|
,`Imię` varchar(255)
|
||||||
|
,`Nazwisko` varchar(255)
|
||||||
|
,`Suma_Przeliczona` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS `sumy` (
|
||||||
|
`wolontariuszID` int(11)
|
||||||
|
,`suma` decimal(49,2)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `tokeny` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`token` text NOT NULL,
|
||||||
|
`czasAktywacji` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`typ` int(11) NOT NULL DEFAULT 1,
|
||||||
|
`userId` int(11) NOT NULL,
|
||||||
|
`aktywny` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `userId` (`userId`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `tokenyLiczacy` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`token` varchar(255) NOT NULL,
|
||||||
|
`typ` int(11) NOT NULL,
|
||||||
|
`userId` int(11) NOT NULL,
|
||||||
|
`czasAktywacji` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`aktywny` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wolontariusz` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`numerIdentyfikatora` varchar(8) NOT NULL,
|
||||||
|
`imie` varchar(255) NOT NULL,
|
||||||
|
`nazwisko` varchar(255) NOT NULL,
|
||||||
|
`discord` text NOT NULL,
|
||||||
|
`email` text NOT NULL,
|
||||||
|
`telefon` varchar(12) NOT NULL,
|
||||||
|
`pesel` varchar(11) NOT NULL,
|
||||||
|
`rodzic` varchar(255) NOT NULL DEFAULT 'BRAK',
|
||||||
|
`terminal` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`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,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona` AS SELECT `combinedData`.`idLiczacego` AS `idLiczacego`, `combinedData`.`imie` AS `imie`, `combinedData`.`nazwisko` AS `nazwisko`, sum(`combinedData`.`sumaPrzeliczona`) AS `sumaPrzeliczona` FROM (select `r`.`liczacy1` AS `idLiczacego`,`l`.`imie` AS `imie`,`l`.`nazwisko` AS `nazwisko`,sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` from (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy1` = `l`.`id`)) group by `r`.`liczacy1` union all select `r`.`liczacy2` AS `idLiczacego`,`l`.`imie` AS `imie`,`l`.`nazwisko` AS `nazwisko`,sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` from (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy2` = `l`.`id`)) group by `r`.`liczacy2` union all select `r`.`liczacy3` AS `idLiczacego`,`l`.`imie` AS `imie`,`l`.`nazwisko` AS `nazwisko`,sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` from (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy3` = `l`.`id`)) group by `r`.`liczacy3`) AS `combinedData` GROUP BY `combinedData`.`idLiczacego`, `combinedData`.`imie`, `combinedData`.`nazwisko` ;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona1`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona1` AS SELECT `r`.`liczacy1` AS `idLiczacego`, `l`.`imie` AS `imie`, `l`.`nazwisko` AS `nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy1` = `l`.`id`)) GROUP BY `r`.`liczacy1` ;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona2`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona2` AS SELECT `r`.`liczacy2` AS `idLiczacego`, `l`.`imie` AS `imie`, `l`.`nazwisko` AS `nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy2` = `l`.`id`)) GROUP BY `r`.`liczacy2` ;
|
||||||
|
DROP TABLE IF EXISTS `sumaPrzeliczona3`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumaPrzeliczona3` AS SELECT `r`.`liczacy3` AS `idLiczacego`, `l`.`imie` AS `imie`, `l`.`nazwisko` AS `nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `sumaPrzeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(`r`.`liczacy3` = `l`.`id`)) GROUP BY `r`.`liczacy3` ;
|
||||||
|
DROP TABLE IF EXISTS `SumaZebranaPrzezWolontariuszy`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `SumaZebranaPrzezWolontariuszy` AS SELECT `wolontariusz`.`numerIdentyfikatora` AS `numerIdentyfikatora`, `wolontariusz`.`imie` AS `imie`, `wolontariusz`.`nazwisko` AS `nazwisko`, `sumy`.`suma` AS `suma` FROM (`wolontariusz` join `sumy`) WHERE `wolontariusz`.`id` = `sumy`.`wolontariuszID` ORDER BY `wolontariusz`.`numerIdentyfikatora` ASC ;
|
||||||
|
DROP TABLE IF EXISTS `suma_przeliczona2`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `suma_przeliczona2` AS SELECT coalesce(`r`.`liczacy1`,`r`.`liczacy2`,`r`.`liczacy3`) AS `ID_Liczącego`, `l`.`imie` AS `Imię`, `l`.`nazwisko` AS `Nazwisko`, sum(`r`.`1gr` * 0.01 + `r`.`2gr` * 0.02 + `r`.`5gr` * 0.05 + `r`.`10gr` * 0.1 + `r`.`20gr` * 0.2 + `r`.`50gr` * 0.5 + `r`.`1zl` * 1 + `r`.`2zl` * 2 + `r`.`5zl` * 5 + `r`.`10zl` * 10 + `r`.`20zl` * 20 + `r`.`50zl` * 50 + `r`.`100zl` * 100 + `r`.`200zl` * 200 + `r`.`500zl` * 500) AS `Suma_Przeliczona` FROM (`rozliczenie` `r` join `liczacy` `l` on(coalesce(`r`.`liczacy1`,`r`.`liczacy2`,`r`.`liczacy3`) = `l`.`id`)) GROUP BY coalesce(`r`.`liczacy1`,`r`.`liczacy2`,`r`.`liczacy3`), `l`.`imie`, `l`.`nazwisko` ;
|
||||||
|
DROP TABLE IF EXISTS `sumy`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `sumy` AS SELECT `rozliczenie`.`wolontariuszID` AS `wolontariuszID`, sum(`rozliczenie`.`1gr` * 0.01 + `rozliczenie`.`2gr` * 0.02 + `rozliczenie`.`5gr` * 0.05 + `rozliczenie`.`10gr` * 0.1 + `rozliczenie`.`20gr` * 0.2 + `rozliczenie`.`50gr` * 0.5 + `rozliczenie`.`1zl` + `rozliczenie`.`2zl` * 2 + `rozliczenie`.`5zl` * 5 + `rozliczenie`.`10zl` * 10 + `rozliczenie`.`20zl` * 20 + `rozliczenie`.`50zl` * 50 + `rozliczenie`.`100zl` * 100 + `rozliczenie`.`200zl` * 200 + `rozliczenie`.`500zl` * 500) AS `suma` FROM `rozliczenie` GROUP BY `rozliczenie`.`wolontariuszID` ;
|
|
@ -0,0 +1,443 @@
|
||||||
|
*
|
||||||
|
{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 14pt;
|
||||||
|
font-family: "Roboto", sans-serif;
|
||||||
|
}
|
||||||
|
a
|
||||||
|
{
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
#container
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
overflow:visible;
|
||||||
|
}
|
||||||
|
.menu
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.menu a
|
||||||
|
{
|
||||||
|
text-decoration: none;
|
||||||
|
color: #000;
|
||||||
|
font-size: larger;
|
||||||
|
margin: 0 10px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
a
|
||||||
|
{
|
||||||
|
transition: .25s;
|
||||||
|
}
|
||||||
|
a:hover
|
||||||
|
{
|
||||||
|
color: #ff0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content
|
||||||
|
{
|
||||||
|
margin: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
width: 100%;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
border-bottom: 1px solid #000;
|
||||||
|
border-top: 1px solid #000;
|
||||||
|
}
|
||||||
|
.content *
|
||||||
|
{
|
||||||
|
padding: 2px;
|
||||||
|
margin: 1px;
|
||||||
|
}
|
||||||
|
form
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.dane
|
||||||
|
{
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #000;
|
||||||
|
}
|
||||||
|
table.dane td
|
||||||
|
{
|
||||||
|
border: 1px solid #000;
|
||||||
|
padding: 5px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
table.dane th
|
||||||
|
{
|
||||||
|
border: 1px solid #000;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.dane tr:nth-child(2n)
|
||||||
|
{
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
table.dane tr:hover
|
||||||
|
{
|
||||||
|
background-color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.szerokie
|
||||||
|
{
|
||||||
|
width: calc(100% - 20px);
|
||||||
|
margin: 5px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
div.kafelki a
|
||||||
|
{
|
||||||
|
width: 200px;
|
||||||
|
height: 140px;
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 25px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
font-size: larger;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
div.kafelki a:hover
|
||||||
|
{
|
||||||
|
background-color: #ddd;
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.przewijanie
|
||||||
|
{
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: nowrap;
|
||||||
|
padding: 5px;
|
||||||
|
margin: 5px;
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stala, #suma, #suma2
|
||||||
|
{
|
||||||
|
/*stała szerokość liter w czcionce*/
|
||||||
|
font-family: "Courier New", Courier, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kafelki2
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
border-top: #000 1px solid;
|
||||||
|
border-bottom: #000 1px solid;
|
||||||
|
}
|
||||||
|
.kafelki2 .kafelek2
|
||||||
|
{
|
||||||
|
min-width: 200px;
|
||||||
|
min-height: 140px;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 25px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
font-size: larger;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
div.kafelki3
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
div.kafelki3 a
|
||||||
|
{
|
||||||
|
width: 230px;
|
||||||
|
height: 110px;
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 25px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
font-size: larger;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
div.kafelki3 a:hover
|
||||||
|
{
|
||||||
|
background-color: #ddd;
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
div.kafelki3 a img
|
||||||
|
{
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a span
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a.borderColorBlue
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(0, 183, 255);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorBlue:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(0, 183, 255, .4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a.borderColorGreen
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(0, 255, 0);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorGreen:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(0, 255, 0, .4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a.borderColorRed
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(255, 0, 0);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorRed:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(255, 0, 0, .4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a.borderColorYellow
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(255, 255, 0);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorYellow:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(255, 255, 0, .4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a.borderColorOrange
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(255, 165, 0);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorOrange:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(255, 165, 0, .4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.kafelki3 a.borderColorPurple
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(128, 0, 128);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorPurple:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(128, 0, 128, .4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorBlack
|
||||||
|
{
|
||||||
|
border: 1px solid rgb(0, 0, 0);
|
||||||
|
}
|
||||||
|
div.kafelki3 a.borderColorBlack:hover
|
||||||
|
{
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*input submit*/
|
||||||
|
input[type=submit]
|
||||||
|
{
|
||||||
|
min-width: 150px;
|
||||||
|
height: 30px;
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 25px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
font-size: larger;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #fff;
|
||||||
|
transition: .25s;
|
||||||
|
}
|
||||||
|
input[type=submit]:hover
|
||||||
|
{
|
||||||
|
background-color: #ddd;
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer
|
||||||
|
{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidenav {
|
||||||
|
height: 100%; /* 100% Full-height */
|
||||||
|
width: 0; /* 0 width - change this with JavaScript */
|
||||||
|
position: fixed; /* Stay in place */
|
||||||
|
z-index: 1; /* Stay on top */
|
||||||
|
top: 0; /* Stay at the top */
|
||||||
|
right: 0;
|
||||||
|
background-color: #FFF; /* Black*/
|
||||||
|
overflow-x: hidden; /* Disable horizontal scroll */
|
||||||
|
padding-top: 60px; /* Place content 60px from the top */
|
||||||
|
transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */
|
||||||
|
border-left: 1px solid #000;
|
||||||
|
box-shadow: 0 0 10px #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidenav .closebtn {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 25px;
|
||||||
|
font-size: 36px;
|
||||||
|
margin-left: 50px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidenav iframe
|
||||||
|
{
|
||||||
|
width: 80%;
|
||||||
|
height: 80%;
|
||||||
|
margin: 5px 5px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuOpen
|
||||||
|
{
|
||||||
|
/*top left */
|
||||||
|
position: fixed;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
width: 50px;
|
||||||
|
|
||||||
|
background-color: #fff;
|
||||||
|
font-size: xx-large;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #000;
|
||||||
|
transition: .25s;
|
||||||
|
/*rotate 90deg*/
|
||||||
|
transform: rotate(90deg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* on print */
|
||||||
|
@media print
|
||||||
|
{
|
||||||
|
.menu, footer, .sidenav, .menuOpen, .drukujBtn
|
||||||
|
{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.content
|
||||||
|
{
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.content *
|
||||||
|
{
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.szerokie
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
table.dane
|
||||||
|
{
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #000;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,463 @@
|
||||||
|
function headerHtml(tytul = 'WOŚP ELEKTRONIK') {
|
||||||
|
return '<!DOCTYPE html><html lang="pl"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>' + tytul +'</title><link rel="stylesheet" href="/style.css"></head><body><div id="container">';
|
||||||
|
}
|
||||||
|
function menuHtml($login = 0) {
|
||||||
|
var toReturn = '<div class="menu">';
|
||||||
|
toReturn += '<a href="#"><img src="'+ process.env.LOGO +'" height="50px"></a>';
|
||||||
|
if ($login == 1) {
|
||||||
|
toReturn += '<a href="/panel/home">Panel</a>';
|
||||||
|
toReturn += '<a href="/panel/rozlicz">Rozlicz</a>';
|
||||||
|
toReturn += '<a href="/panel/rozliczenia">Rozliczenia</a>';
|
||||||
|
toReturn += '<a href="/panel/potwierdz">Potwierdź rozliczenie</a>';
|
||||||
|
toReturn += '<a href="/panel/osobyLiczace">Osoby liczące</a>';
|
||||||
|
toReturn += '<a href="/panel/listaWolontariuszy">Lista wolontariuszy</a>';
|
||||||
|
toReturn += '<a href="/panel/druki">Druki</a>';
|
||||||
|
toReturn += '<a href="/panel/statystyki">Statystyki</a>';
|
||||||
|
toReturn += '<a href="/panel/logout">Wyloguj</a>';
|
||||||
|
} else if ($login == 2) {
|
||||||
|
//wróć js
|
||||||
|
toReturn += '<a onclick="wroc()">Wróć</a>';
|
||||||
|
toReturn += '<a href="/statystyki2">Statystyki</a>';
|
||||||
|
toReturn += '<a href="/login">Zaloguj</a>';
|
||||||
|
}
|
||||||
|
else if ($login == 3) {
|
||||||
|
toReturn += '<a href="/panel">Rozlicz wolontariusza</a>';
|
||||||
|
toReturn += '<a href="/statystyki2">Statystyki</a>';
|
||||||
|
toReturn += '<a href="/loginliczacy">Zaloguj</a>';
|
||||||
|
}
|
||||||
|
else if ($login == 4) {
|
||||||
|
toReturn += '<a href="/liczacy">Panel</a>';
|
||||||
|
toReturn += '<a href="/liczacy/rozlicz">Rozlicz</a>';
|
||||||
|
toReturn += '<a href="/liczacy/statystyki2">Statystyki</a>';
|
||||||
|
toReturn += '<a href="/liczacy/wyloguj">Wyloguj</a>';
|
||||||
|
} else {
|
||||||
|
toReturn += '<a href="/statystyki2">Statystyki</a>';
|
||||||
|
toReturn += '<a href="/login">Zaloguj</a>';
|
||||||
|
}
|
||||||
|
return toReturn + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function footerHtml(login = 0) {
|
||||||
|
var toReturn = '';
|
||||||
|
if(login == 1)
|
||||||
|
{
|
||||||
|
toReturn = '<div id="mySidenav" class="sidenav">';
|
||||||
|
toReturn += '<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>';
|
||||||
|
toReturn += '<iframe src="/panel/szybkieInfo"></iframe>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '<a><span onclick="openNav()" class="menuOpen">|||</span></a>';
|
||||||
|
toReturn += '<script>function openNav() {document.getElementById("mySidenav").style.width = "300px";}</script>';
|
||||||
|
toReturn += '<script>function closeNav() {document.getElementById("mySidenav").style.width = "0";}</script>';
|
||||||
|
}
|
||||||
|
if(login == 2)
|
||||||
|
{
|
||||||
|
toReturn = '<div id="mySidenav" class="sidenav">';
|
||||||
|
toReturn += '<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>';
|
||||||
|
toReturn += '<iframe src="/liczacy/szybkieInfo"></iframe>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '<a><span onclick="openNav()" class="menuOpen">|||</span></a>';
|
||||||
|
toReturn += '<script>function openNav() {document.getElementById("mySidenav").style.width = "300px";}</script>';
|
||||||
|
toReturn += '<script>function closeNav() {document.getElementById("mySidenav").style.width = "0";}</script>';
|
||||||
|
}
|
||||||
|
toReturn += '<script>function wroc() {history.back();}</script>';
|
||||||
|
toReturn += '<footer>';
|
||||||
|
if (new Date().getFullYear() > 2023)
|
||||||
|
toReturn += '<span>Stworzone przez <a href="https://kry008.xyz">KRY008</a> dla sztabu '+ process.env.SZTAB + ' © 2023-' + new Date().getFullYear() + '';
|
||||||
|
else
|
||||||
|
toReturn += '<span>Stworzone przez <a href="https://kry008.xyz">KRY008</a> dla sztabu '+ process.env.SZTAB + ' © 2023';
|
||||||
|
return toReturn + "<br>Wersja programu: " + process.env.VERSION + '</span></footer></div></body></html>';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeid(length) {
|
||||||
|
let result = '';
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const charactersLength = characters.length;
|
||||||
|
let counter = 0;
|
||||||
|
while (counter < length) {
|
||||||
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//sprawdzanie kiedy PESEL ma 18 lat, czy minęło 16 lat od daty urodzenia, data sprawdzenia to 28 stycznia 2024
|
||||||
|
function checkPesel(pesel) {
|
||||||
|
//pobierz datę urodzenia
|
||||||
|
// Wycinamy daty z numeru
|
||||||
|
var rok = parseInt(pesel.substring(0, 2), 10);
|
||||||
|
var miesiac = parseInt(pesel.substring(2, 4), 10) - 1;
|
||||||
|
var dzien = parseInt(pesel.substring(4, 6), 10);
|
||||||
|
// Pesel został wprowadzony w 20 wieku, ale zawiera modyfikatory na przysłość
|
||||||
|
// Miesiąc zawiera dodatkowe liczby dla dat z przyszłości.
|
||||||
|
if (miesiac > 80) {
|
||||||
|
rok = rok + 1800;
|
||||||
|
miesiac = miesiac - 80;
|
||||||
|
} else if (miesiac >= 60) {
|
||||||
|
rok = rok + 2200;
|
||||||
|
miesiac = miesiac - 60;
|
||||||
|
} else if (miesiac >= 40) {
|
||||||
|
rok = rok + 2100;
|
||||||
|
miesiac = miesiac - 40;
|
||||||
|
} else if (miesiac >= 20) {
|
||||||
|
rok = rok + 2000;
|
||||||
|
miesiac = miesiac - 20;
|
||||||
|
} else {
|
||||||
|
rok += 1900;
|
||||||
|
}
|
||||||
|
if( miesiac >=0 && miesiac < 12 && dzien > 0 && dzien < 32 ) {
|
||||||
|
// Daty sa ok. Teraz ustawiamy.
|
||||||
|
var urodzony = new Date();
|
||||||
|
urodzony.setFullYear(rok, miesiac, dzien);
|
||||||
|
} else {
|
||||||
|
var urodzony = false;
|
||||||
|
}
|
||||||
|
//sprawdź czy minęło 18 lat
|
||||||
|
var today = new Date(process.env.DATAFINALU);
|
||||||
|
var diff = today - urodzony;
|
||||||
|
var age = Math.floor(diff/31557600000);
|
||||||
|
if(age >= 16)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loger(fs, text, type = 'info') {
|
||||||
|
if(process.env.LOGS == '1')
|
||||||
|
{
|
||||||
|
var date = new Date();
|
||||||
|
var time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||||
|
console.log('[' + time + ']\t' + type + ': ' + text);
|
||||||
|
if(process.platform == 'win32')
|
||||||
|
fs.appendFileSync('logs\\' + date.getDate() + '-' + (date.getMonth() + 1) +'log.txt', '[' + time + ']\t' + type + ': ' + text + '\r\n');
|
||||||
|
else
|
||||||
|
fs.appendFileSync('logs/' + date.getDate() + '-' + (date.getMonth() + 1) +'log.txt', '[' + time + ']\t' + type + ': ' + text + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function peselToShow(pesel, nrId) {
|
||||||
|
//weź pierwsze 3 znaki nrId
|
||||||
|
nrId = nrId.substring(0, 3);
|
||||||
|
nrId = parseInt(nrId) % 9;
|
||||||
|
if (nrId == 0)
|
||||||
|
nrId = 4;
|
||||||
|
//pokaż co nrId znak, resztę zastąp x
|
||||||
|
var result = '';
|
||||||
|
var counter = 0;
|
||||||
|
while (counter < pesel.length) {
|
||||||
|
if (counter % nrId == 0)
|
||||||
|
result += pesel[counter] + ' ';
|
||||||
|
else
|
||||||
|
result += '█ ';
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//telefon, zwraca telefon w formacje +48XXXXXXXXX, możliwe podanie +48XXXXXXXXX/XXXXXXXXX/48XXXXXXXXX/XXX-XXX-XXX/XXX XXX XXX
|
||||||
|
function telefon(telefon, withLink = 0) {
|
||||||
|
telefon = telefon.replace(/\s/g, '');
|
||||||
|
telefon = telefon.replace(/-/g, '');
|
||||||
|
telefon = telefon.replace(/\//g, '');
|
||||||
|
if (telefon.substring(0, 1) == '+')
|
||||||
|
telefon = telefon.substring(1, telefon.length);
|
||||||
|
if (telefon.substring(0, 2) == '48')
|
||||||
|
telefon = telefon.substring(2, telefon.length);
|
||||||
|
if (telefon.substring(0, 3) == '0048')
|
||||||
|
telefon = telefon.substring(3, telefon.length);
|
||||||
|
if (telefon.length == 9)
|
||||||
|
telefon = '48' + telefon;
|
||||||
|
if (telefon.length == 11)
|
||||||
|
telefon = telefon.substring(2, telefon.length);
|
||||||
|
if (telefon.length == 12)
|
||||||
|
telefon = telefon.substring(3, telefon.length);
|
||||||
|
if (telefon.length == 0)
|
||||||
|
telefon = '000000000';
|
||||||
|
if(withLink == 1)
|
||||||
|
return '<a href="tel:' + telefon + '">' + telefon + '</a>';
|
||||||
|
else
|
||||||
|
return telefon;
|
||||||
|
}
|
||||||
|
|
||||||
|
//random color
|
||||||
|
function randomColor() {
|
||||||
|
var letters = '0123456789ABCDEF';
|
||||||
|
var color = '#';
|
||||||
|
var counter = 0;
|
||||||
|
while (counter < 6) {
|
||||||
|
color += letters[Math.floor(Math.random() * 16)];
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToDiscord(imie, nazwisko, suma, nickDC)
|
||||||
|
{
|
||||||
|
const { Webhook, MessageBuilder } = require('discord-webhook-node');
|
||||||
|
const hook = new Webhook(process.env.DISCORDWEBHOOK);
|
||||||
|
if(nickDC == 'BRAK')
|
||||||
|
{
|
||||||
|
const embed = new MessageBuilder()
|
||||||
|
.setTitle(imie + ' ' + nazwisko)
|
||||||
|
.setColor(randomColor())
|
||||||
|
.setAuthor("Bot by KRY008", "https://raw.githubusercontent.com/kry008/kry008.xyz/main/images/logo.webp", "https://kry008.xyz")
|
||||||
|
.setDescription('Dorzuca się kwotą: ' + suma + ' zł')
|
||||||
|
.setFooter('Rozliczenie', process.env.LOGO)
|
||||||
|
.setTimestamp();
|
||||||
|
//console.log(embed);
|
||||||
|
hook.send(embed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//mention user nickDC
|
||||||
|
const embed = new MessageBuilder()
|
||||||
|
.setTitle(imie + ' ' + nazwisko)
|
||||||
|
.setColor(randomColor())
|
||||||
|
.setAuthor("Bot by KRY008", "https://raw.githubusercontent.com/kry008/kry008.xyz/main/images/logo.webp", "https://kry008.xyz")
|
||||||
|
.setDescription('Dorzuca się kwotą: ' + suma + ' zł')
|
||||||
|
.setFooter('Rozliczenie' + nickDC, process.env.LOGO)
|
||||||
|
.setTimestamp();
|
||||||
|
//console.log(embed);
|
||||||
|
hook.send(embed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendEmail(imie, nazwisko, suma, email)
|
||||||
|
{
|
||||||
|
const nodemailer = require('nodemailer');
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: process.env.SMTPHOST,
|
||||||
|
port: process.env.SMTPPORT,
|
||||||
|
secure: true,
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTPLOGIN,
|
||||||
|
pass: process.env.SMTPPASS
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const mailOptions = {
|
||||||
|
from: process.env.SMTPLOGIN,
|
||||||
|
to: email,
|
||||||
|
subject: 'Twoje rozliczenie w ' + process.env.NRFINALU + '. Finale WOŚP',
|
||||||
|
html: '<img src="' + process.env.LOGO + '" height="150px" style="display: block; margin-left: auto; margin-right: auto;"><h1 style="text-align: center;">Rozliczenie</h1><h2 style="text-align: center;">Witaj ' + imie + ' ' + nazwisko + ',<br>Twoja suma z rozliczenia to: ' + suma + ' zł.</h2><p style="text-align: center;">Dziękujemy za udział w WOŚP!</p><p style="text-align: center;">Pozdrawiamy,<br>' + process.env.SZTAB + '</p>' + footerHtml()
|
||||||
|
};
|
||||||
|
transporter.sendMail(mailOptions, function(error, info){
|
||||||
|
if (error) {
|
||||||
|
console.log(error);
|
||||||
|
loger(fs, 'Błąd wysyłania maila do ' + imie + ' ' + nazwisko + ' (' + email + ')', 'error');
|
||||||
|
} else {
|
||||||
|
console.log('Email został wysłany: ' + info.response);
|
||||||
|
loger(fs, 'Email został wysłany do ' + imie + ' ' + nazwisko + ' (' + email + ') ' + info.response, 'info');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkSendEmail(email)
|
||||||
|
{
|
||||||
|
const nodemailer = require('nodemailer');
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: process.env.SMTPHOST,
|
||||||
|
port: process.env.SMTPPORT,
|
||||||
|
secure: true,
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTPLOGIN,
|
||||||
|
pass: process.env.SMTPPASS
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const mailOptions = {
|
||||||
|
from: process.env.SMTPLOGIN,
|
||||||
|
to: email,
|
||||||
|
subject: 'Twoje rozliczenie w ' + process.env.NRFINALU + '. Finale WOŚP',
|
||||||
|
html: '<img src="' + process.env.LOGO + '" height="150px" style="display: block; margin-left: auto; margin-right: auto;"><h1 style="text-align: center;">Rozliczenie</h1><h2 style="text-align: center;">Witaj Test,<br>Twoja suma z rozliczenia to: 0 zł.</h2><p style="text-align: center;">Dziękujemy za udział w WOŚP!</p><p style="text-align: center;">Pozdrawiamy,<br>' + process.env.SZTAB + '</p>' + footerHtml()
|
||||||
|
};
|
||||||
|
transporter.sendMail(mailOptions, function(error, info){
|
||||||
|
if (error) {
|
||||||
|
console.log(error);
|
||||||
|
loger(fs, 'Błąd wysyłania maila', 'error');
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
console.log('Email został wysłany: ' + info.response);
|
||||||
|
loger(fs, 'Email został wysłany do', 'info');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function baza()
|
||||||
|
{
|
||||||
|
var toSend = `CREATE TABLE IF NOT EXISTS \`liczacy\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`imie\` varchar(255) NOT NULL,
|
||||||
|
\`nazwisko\` varchar(255) NOT NULL,
|
||||||
|
\`aktywne\` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
\`qr\` varchar(25) NOT NULL,
|
||||||
|
PRIMARY KEY (\`id\`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS \`login\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`login\` text NOT NULL,
|
||||||
|
\`haslo\` text NOT NULL,
|
||||||
|
\`kto\` text NOT NULL,
|
||||||
|
\`aktywne\` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (\`id\`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS \`rozliczenie\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`wolontariuszID\` int(11) NOT NULL,
|
||||||
|
\`czasRozliczenia\` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
\`terminal\` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
\`sumaZTerminala\` float DEFAULT NULL,
|
||||||
|
\`1gr\` int(11) DEFAULT NULL,
|
||||||
|
\`2gr\` int(11) DEFAULT NULL,
|
||||||
|
\`5gr\` int(11) DEFAULT NULL,
|
||||||
|
\`10gr\` int(11) DEFAULT NULL,
|
||||||
|
\`20gr\` int(11) DEFAULT NULL,
|
||||||
|
\`50gr\` int(11) DEFAULT NULL,
|
||||||
|
\`1zl\` int(11) DEFAULT NULL,
|
||||||
|
\`2zl\` int(11) DEFAULT NULL,
|
||||||
|
\`5zl\` int(11) DEFAULT NULL,
|
||||||
|
\`10zl\` int(11) DEFAULT NULL,
|
||||||
|
\`20zl\` int(11) DEFAULT NULL,
|
||||||
|
\`50zl\` int(11) DEFAULT NULL,
|
||||||
|
\`100zl\` int(11) DEFAULT NULL,
|
||||||
|
\`200zl\` int(11) DEFAULT NULL,
|
||||||
|
\`500zl\` int(11) DEFAULT NULL,
|
||||||
|
\`walutaObca\` text NOT NULL,
|
||||||
|
\`daryInne\` text DEFAULT NULL,
|
||||||
|
\`uwagi\` text DEFAULT NULL,
|
||||||
|
\`liczacy1\` int(11) NOT NULL,
|
||||||
|
\`liczacy2\` int(11) NOT NULL,
|
||||||
|
\`liczacy3\` int(11) DEFAULT NULL,
|
||||||
|
\`sala\` varchar(10) NOT NULL,
|
||||||
|
\`weryfikowal\` int(11) NOT NULL,
|
||||||
|
\`wpisaneDoBSS\` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
\`ostatniaZmiana\` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||||
|
\`aktywne\` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (\`id\`),
|
||||||
|
KEY \`wolontariuszID\` (\`wolontariuszID\`),
|
||||||
|
KEY \`liczacy1\` (\`liczacy1\`),
|
||||||
|
KEY \`liczacy2\` (\`liczacy2\`),
|
||||||
|
KEY \`liczacy3\` (\`liczacy3\`),
|
||||||
|
KEY \`weryfikowal\` (\`weryfikowal\`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
CREATE TABLE IF NOT EXISTS \`sumaPrzeliczona\` (
|
||||||
|
\`idLiczacego\` int(11)
|
||||||
|
,\`imie\` varchar(255)
|
||||||
|
,\`nazwisko\` varchar(255)
|
||||||
|
,\`sumaPrzeliczona\` decimal(65,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS \`sumaPrzeliczona1\` (
|
||||||
|
\`idLiczacego\` int(11)
|
||||||
|
,\`imie\` varchar(255)
|
||||||
|
,\`nazwisko\` varchar(255)
|
||||||
|
,\`sumaPrzeliczona\` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS \`sumaPrzeliczona2\` (
|
||||||
|
\`idLiczacego\` int(11)
|
||||||
|
,\`imie\` varchar(255)
|
||||||
|
,\`nazwisko\` varchar(255)
|
||||||
|
,\`sumaPrzeliczona\` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS \`sumaPrzeliczona3\` (
|
||||||
|
\`idLiczacego\` int(11)
|
||||||
|
,\`imie\` varchar(255)
|
||||||
|
,\`nazwisko\` varchar(255)
|
||||||
|
,\`sumaPrzeliczona\` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS \`SumaZebranaPrzezWolontariuszy\` (
|
||||||
|
\`numerIdentyfikatora\` varchar(8)
|
||||||
|
,\`imie\` varchar(255)
|
||||||
|
,\`nazwisko\` varchar(255)
|
||||||
|
,\`suma\` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS \`suma_przeliczona2\` (
|
||||||
|
\`ID_Liczącego\` int(11)
|
||||||
|
,\`Imię\` varchar(255)
|
||||||
|
,\`Nazwisko\` varchar(255)
|
||||||
|
,\`Suma_Przeliczona\` decimal(49,2)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS \`sumy\` (
|
||||||
|
\`wolontariuszID\` int(11)
|
||||||
|
,\`suma\` decimal(49,2)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS \`tokeny\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`token\` text NOT NULL,
|
||||||
|
\`czasAktywacji\` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
\`typ\` int(11) NOT NULL DEFAULT 1,
|
||||||
|
\`userId\` int(11) NOT NULL,
|
||||||
|
\`aktywny\` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (\`id\`),
|
||||||
|
KEY \`userId\` (\`userId\`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS \`tokenyLiczacy\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`token\` varchar(255) NOT NULL,
|
||||||
|
\`typ\` int(11) NOT NULL,
|
||||||
|
\`userId\` int(11) NOT NULL,
|
||||||
|
\`czasAktywacji\` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
\`aktywny\` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (\`id\`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS \`wolontariusz\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`numerIdentyfikatora\` varchar(8) NOT NULL,
|
||||||
|
\`imie\` varchar(255) NOT NULL,
|
||||||
|
\`nazwisko\` varchar(255) NOT NULL,
|
||||||
|
\`discord\` text NOT NULL,
|
||||||
|
\`email\` text NOT NULL,
|
||||||
|
\`telefon\` varchar(12) NOT NULL,
|
||||||
|
\`pesel\` varchar(11) NOT NULL,
|
||||||
|
\`rodzic\` varchar(255) NOT NULL DEFAULT 'BRAK',
|
||||||
|
\`terminal\` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
\`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,
|
||||||
|
PRIMARY KEY (\`id\`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
DROP TABLE IF EXISTS \`sumaPrzeliczona\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`sumaPrzeliczona\` AS SELECT \`combinedData\`.\`idLiczacego\` AS \`idLiczacego\`, \`combinedData\`.\`imie\` AS \`imie\`, \`combinedData\`.\`nazwisko\` AS \`nazwisko\`, sum(\`combinedData\`.\`sumaPrzeliczona\`) AS \`sumaPrzeliczona\` FROM (select \`r\`.\`liczacy1\` AS \`idLiczacego\`,\`l\`.\`imie\` AS \`imie\`,\`l\`.\`nazwisko\` AS \`nazwisko\`,sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`sumaPrzeliczona\` from (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(\`r\`.\`liczacy1\` = \`l\`.\`id\`)) group by \`r\`.\`liczacy1\` union all select \`r\`.\`liczacy2\` AS \`idLiczacego\`,\`l\`.\`imie\` AS \`imie\`,\`l\`.\`nazwisko\` AS \`nazwisko\`,sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`sumaPrzeliczona\` from (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(\`r\`.\`liczacy2\` = \`l\`.\`id\`)) group by \`r\`.\`liczacy2\` union all select \`r\`.\`liczacy3\` AS \`idLiczacego\`,\`l\`.\`imie\` AS \`imie\`,\`l\`.\`nazwisko\` AS \`nazwisko\`,sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`sumaPrzeliczona\` from (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(\`r\`.\`liczacy3\` = \`l\`.\`id\`)) group by \`r\`.\`liczacy3\`) AS \`combinedData\` GROUP BY \`combinedData\`.\`idLiczacego\`, \`combinedData\`.\`imie\`, \`combinedData\`.\`nazwisko\` ;
|
||||||
|
DROP TABLE IF EXISTS \`sumaPrzeliczona1\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`sumaPrzeliczona1\` AS SELECT \`r\`.\`liczacy1\` AS \`idLiczacego\`, \`l\`.\`imie\` AS \`imie\`, \`l\`.\`nazwisko\` AS \`nazwisko\`, sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`sumaPrzeliczona\` FROM (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(\`r\`.\`liczacy1\` = \`l\`.\`id\`)) GROUP BY \`r\`.\`liczacy1\` ;
|
||||||
|
DROP TABLE IF EXISTS \`sumaPrzeliczona2\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`sumaPrzeliczona2\` AS SELECT \`r\`.\`liczacy2\` AS \`idLiczacego\`, \`l\`.\`imie\` AS \`imie\`, \`l\`.\`nazwisko\` AS \`nazwisko\`, sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`sumaPrzeliczona\` FROM (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(\`r\`.\`liczacy2\` = \`l\`.\`id\`)) GROUP BY \`r\`.\`liczacy2\` ;
|
||||||
|
DROP TABLE IF EXISTS \`sumaPrzeliczona3\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`sumaPrzeliczona3\` AS SELECT \`r\`.\`liczacy3\` AS \`idLiczacego\`, \`l\`.\`imie\` AS \`imie\`, \`l\`.\`nazwisko\` AS \`nazwisko\`, sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`sumaPrzeliczona\` FROM (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(\`r\`.\`liczacy3\` = \`l\`.\`id\`)) GROUP BY \`r\`.\`liczacy3\` ;
|
||||||
|
DROP TABLE IF EXISTS \`SumaZebranaPrzezWolontariuszy\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`SumaZebranaPrzezWolontariuszy\` AS SELECT \`wolontariusz\`.\`numerIdentyfikatora\` AS \`numerIdentyfikatora\`, \`wolontariusz\`.\`imie\` AS \`imie\`, \`wolontariusz\`.\`nazwisko\` AS \`nazwisko\`, \`sumy\`.\`suma\` AS \`suma\` FROM (\`wolontariusz\` join \`sumy\`) WHERE \`wolontariusz\`.\`id\` = \`sumy\`.\`wolontariuszID\` ORDER BY \`wolontariusz\`.\`numerIdentyfikatora\` ASC ;
|
||||||
|
DROP TABLE IF EXISTS \`suma_przeliczona2\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`suma_przeliczona2\` AS SELECT coalesce(\`r\`.\`liczacy1\`,\`r\`.\`liczacy2\`,\`r\`.\`liczacy3\`) AS \`ID_Liczącego\`, \`l\`.\`imie\` AS \`Imię\`, \`l\`.\`nazwisko\` AS \`Nazwisko\`, sum(\`r\`.\`1gr\` * 0.01 + \`r\`.\`2gr\` * 0.02 + \`r\`.\`5gr\` * 0.05 + \`r\`.\`10gr\` * 0.1 + \`r\`.\`20gr\` * 0.2 + \`r\`.\`50gr\` * 0.5 + \`r\`.\`1zl\` * 1 + \`r\`.\`2zl\` * 2 + \`r\`.\`5zl\` * 5 + \`r\`.\`10zl\` * 10 + \`r\`.\`20zl\` * 20 + \`r\`.\`50zl\` * 50 + \`r\`.\`100zl\` * 100 + \`r\`.\`200zl\` * 200 + \`r\`.\`500zl\` * 500) AS \`Suma_Przeliczona\` FROM (\`rozliczenie\` \`r\` join \`liczacy\` \`l\` on(coalesce(\`r\`.\`liczacy1\`,\`r\`.\`liczacy2\`,\`r\`.\`liczacy3\`) = \`l\`.\`id\`)) GROUP BY coalesce(\`r\`.\`liczacy1\`,\`r\`.\`liczacy2\`,\`r\`.\`liczacy3\`), \`l\`.\`imie\`, \`l\`.\`nazwisko\` ;
|
||||||
|
DROP TABLE IF EXISTS \`sumy\`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW \`sumy\` AS SELECT \`rozliczenie\`.\`wolontariuszID\` AS \`wolontariuszID\`, sum(\`rozliczenie\`.\`1gr\` * 0.01 + \`rozliczenie\`.\`2gr\` * 0.02 + \`rozliczenie\`.\`5gr\` * 0.05 + \`rozliczenie\`.\`10gr\` * 0.1 + \`rozliczenie\`.\`20gr\` * 0.2 + \`rozliczenie\`.\`50gr\` * 0.5 + \`rozliczenie\`.\`1zl\` + \`rozliczenie\`.\`2zl\` * 2 + \`rozliczenie\`.\`5zl\` * 5 + \`rozliczenie\`.\`10zl\` * 10 + \`rozliczenie\`.\`20zl\` * 20 + \`rozliczenie\`.\`50zl\` * 50 + \`rozliczenie\`.\`100zl\` * 100 + \`rozliczenie\`.\`200zl\` * 200 + \`rozliczenie\`.\`500zl\` * 500) AS \`suma\` FROM \`rozliczenie\` GROUP BY \`rozliczenie\`.\`wolontariuszID\` ;
|
||||||
|
|
||||||
|
`;
|
||||||
|
return toSend;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.headerHtml = headerHtml;
|
||||||
|
exports.menuHtml = menuHtml;
|
||||||
|
exports.footerHtml = footerHtml;
|
||||||
|
exports.makeid = makeid;
|
||||||
|
exports.checkPesel = checkPesel;
|
||||||
|
exports.loger = loger;
|
||||||
|
exports.peselToShow = peselToShow;
|
||||||
|
exports.telefon = telefon;
|
||||||
|
exports.sendToDiscord = sendToDiscord;
|
||||||
|
exports.sendEmail = sendEmail;
|
||||||
|
exports.checkSendEmail = checkSendEmail;
|
||||||
|
exports.baza = baza;
|
|
@ -0,0 +1,328 @@
|
||||||
|
|
||||||
|
//dot.env
|
||||||
|
require('dotenv').config();
|
||||||
|
var mysql = require('mysql2');
|
||||||
|
|
||||||
|
var con = mysql.createConnection({
|
||||||
|
host: process.env.MYSQLHOST,
|
||||||
|
user: process.env.MYSQLUSER,
|
||||||
|
password: process.env.MYSQLPASS,
|
||||||
|
port: process.env.MYSQLPORT,
|
||||||
|
database: process.env.MYSQLDB,
|
||||||
|
insecureAuth: true
|
||||||
|
});
|
||||||
|
|
||||||
|
let attempts = 0;
|
||||||
|
const maxAttempts = 5;
|
||||||
|
|
||||||
|
function tryConnect() {
|
||||||
|
con.connect(function (err) {
|
||||||
|
if (err) {
|
||||||
|
attempts++;
|
||||||
|
console.log(`Attempt ${attempts} failed: ${err.message}`);
|
||||||
|
if (attempts < maxAttempts) {
|
||||||
|
console.log('Retrying...');
|
||||||
|
setTimeout(tryConnect, 2500); // Odczekaj 2.5 sekundy przed kolejną próbą
|
||||||
|
} else {
|
||||||
|
console.error('Failed to connect after 10 attempts.');
|
||||||
|
process.exit(1); // Zakończ aplikację
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Connected!');
|
||||||
|
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var express = require('express');
|
||||||
|
var cookie = require('cookie');
|
||||||
|
var app = express();
|
||||||
|
var bodyParser = require('body-parser');
|
||||||
|
app.use(bodyParser.urlencoded({
|
||||||
|
extended: true
|
||||||
|
}));
|
||||||
|
|
||||||
|
const fileUpload = require('express-fileupload');
|
||||||
|
|
||||||
|
app.use(fileUpload({
|
||||||
|
useTempFiles: true, // Użycie tymczasowych plików
|
||||||
|
tempFileDir: '/tmp/', // Ścieżka do katalogu tymczasowego
|
||||||
|
limits: { fileSize: 10 * 1024 * 1024 } // Maksymalny rozmiar pliku: 10 MB
|
||||||
|
}));
|
||||||
|
|
||||||
|
//import functions from func.js
|
||||||
|
const {headerHtml, menuHtml, footerHtml, makeid, loger} = require('./func.js');
|
||||||
|
|
||||||
|
const panelRoutes = require('./panelRoutes.js');
|
||||||
|
const liczacy = require('./liczacy.js');
|
||||||
|
//const apiRoutes = require('./apiRoutes');
|
||||||
|
|
||||||
|
app.get('/', function(req, res) {
|
||||||
|
res.redirect('/panel');
|
||||||
|
});
|
||||||
|
app.all('/*', function(req, res, next) {
|
||||||
|
//save to file, route, coockies, date, time
|
||||||
|
var date = new Date();
|
||||||
|
var day = date.getDate();
|
||||||
|
var month = date.getMonth() + 1;
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var hour = date.toLocaleTimeString();
|
||||||
|
var minute = date.toLocaleTimeString();
|
||||||
|
var second = date.toLocaleTimeString();
|
||||||
|
var time = hour + ':' + minute + ':' + second;
|
||||||
|
var fullDate = year + '-' + month + '-' + day;
|
||||||
|
var route = req.originalUrl;
|
||||||
|
var cookies = req.headers.cookie;
|
||||||
|
var userAgent = req.headers['user-agent'];
|
||||||
|
var toSave = fullDate + '\t' + time + '\t' + route + '\t' + cookies || req.body.token || req.query.token || req.headers['x-access-token'] + '\t' + userAgent + '\n';
|
||||||
|
loger(fs, toSave, 'info');
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
//send style.css from html folder
|
||||||
|
app.get('/style.css', function(req, res) {
|
||||||
|
res.sendFile(__dirname + '/css/style.css');
|
||||||
|
});
|
||||||
|
|
||||||
|
//static files
|
||||||
|
app.use(express.static('static'));
|
||||||
|
|
||||||
|
app.get('/login', function(req, res) {
|
||||||
|
var toReturn = headerHtml();
|
||||||
|
toReturn += menuHtml();
|
||||||
|
toReturn += '<div class="content">';
|
||||||
|
toReturn += '<h1>Logowanie</h1>';
|
||||||
|
toReturn += '<form action="/login" method="POST">';
|
||||||
|
toReturn += '<input type="text" name="login" placeholder="Login">';
|
||||||
|
toReturn += '<input type="password" name="password" placeholder="Hasło">';
|
||||||
|
toReturn += '<input type="submit" value="Zaloguj">';
|
||||||
|
toReturn += '</form>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml();
|
||||||
|
res.send(toReturn);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post('/login', function(req, res) {
|
||||||
|
var login = req.body.login;
|
||||||
|
var password = req.body.password;
|
||||||
|
//sprawdź czy istnieje taki login i hasło
|
||||||
|
con.query('SELECT * FROM login WHERE login = ? AND haslo = SHA1(?) AND aktywne = 1', [login, password], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
//utwórz token
|
||||||
|
var token = makeid(32);
|
||||||
|
//zapisz token do bazy
|
||||||
|
con.query('INSERT INTO tokeny (token, typ, userId) VALUES (?, 1, ?)', [token, result[0].id], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
//ustaw ciasteczko
|
||||||
|
res.setHeader('Set-Cookie', cookie.serialize('token', token, {
|
||||||
|
httpOnly: true,
|
||||||
|
maxAge: 60 * 60 * 24 * 7 // 1 week
|
||||||
|
}));
|
||||||
|
res.redirect('/panel')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
//niepoprawne dane
|
||||||
|
res.redirect('/login');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/loginliczacy', function(req, res) {
|
||||||
|
//pobierz kod, 10 znaków i sprawdź czy istnieje w liczacy w polu qr
|
||||||
|
var toReturn = headerHtml();
|
||||||
|
toReturn += menuHtml();
|
||||||
|
toReturn += '<div class="content">';
|
||||||
|
toReturn += '<h1>Logowanie osoby liczącej</h1>';
|
||||||
|
toReturn += '<form action="/loginliczacy" method="POST">';
|
||||||
|
toReturn += '<input type="password" name="password" placeholder="Hasło">';
|
||||||
|
toReturn += '<input type="submit" value="Zaloguj">';
|
||||||
|
toReturn += '</form>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml();
|
||||||
|
res.send(toReturn);
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/loginliczacy', function(req, res) {
|
||||||
|
var password = req.body.password;
|
||||||
|
//sprawdź czy istnieje taki login i hasło
|
||||||
|
con.query('SELECT * FROM liczacy WHERE qr = ? AND aktywne = 1', [password], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
//utwórz token
|
||||||
|
var token = makeid(32);
|
||||||
|
//zapisz token do bazy
|
||||||
|
con.query('INSERT INTO tokenyLiczacy (token, typ, userId) VALUES (?, 1, ?)', [token, result[0].id], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
//ustaw ciasteczko
|
||||||
|
res.setHeader('Set-Cookie', cookie.serialize('liczacy', token, {
|
||||||
|
httpOnly: true,
|
||||||
|
maxAge: 60 * 60 * 24 * 7 // 1 week
|
||||||
|
}));
|
||||||
|
res.redirect('/liczacy')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
//niepoprawne dane
|
||||||
|
res.redirect('/loginliczacy');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
app.all("/panel", function(req, res) {
|
||||||
|
//redirect to /panel/home
|
||||||
|
res.redirect('/panel/home');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.use('/panel', panelRoutes);
|
||||||
|
app.use('/liczacy', liczacy);
|
||||||
|
//app.use('/api', apiRoutes);
|
||||||
|
|
||||||
|
app.all('/statystyki2', function(req, res) {
|
||||||
|
var toReturn = headerHtml("Statystyki");
|
||||||
|
toReturn += menuHtml(0);
|
||||||
|
//make script to refresh every 5 seconds, and full screen this page
|
||||||
|
toReturn += '<script>';
|
||||||
|
toReturn += "var elem = document.documentElement;"
|
||||||
|
toReturn += "if (elem.requestFullscreen) {";
|
||||||
|
toReturn += "elem.requestFullscreen();";
|
||||||
|
toReturn += "} else if (elem.mozRequestFullScreen) {";
|
||||||
|
toReturn += "elem.mozRequestFullScreen();";
|
||||||
|
toReturn += "} else if (elem.webkitRequestFullscreen) {";
|
||||||
|
toReturn += "elem.webkitRequestFullscreen();";
|
||||||
|
toReturn += "} else if (elem.msRequestFullscreen) {";
|
||||||
|
toReturn += "elem.msRequestFullscreen();";
|
||||||
|
toReturn += "}";
|
||||||
|
toReturn += 'setTimeout(function() {';
|
||||||
|
toReturn += 'window.location.reload(1);';
|
||||||
|
toReturn += '}, 5000);';
|
||||||
|
toReturn += '</script>';
|
||||||
|
|
||||||
|
toReturn += '<div class="kafelki2">';
|
||||||
|
toReturn += '<div class="kafelek2">';
|
||||||
|
toReturn += '<h2>Całkowita suma</h2>';
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
//wypisz sumę zebranych pieniędzy, sumę poszczególnych nominałów
|
||||||
|
//pobierz wszystkie rozliczenia
|
||||||
|
con.query('SELECT * FROM rozliczenie WHERE aktywne = 1', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
var suma = 0;
|
||||||
|
var sumaTerminal = 0;
|
||||||
|
var suma1gr = 0;
|
||||||
|
var suma2gr = 0;
|
||||||
|
var suma5gr = 0;
|
||||||
|
var suma10gr = 0;
|
||||||
|
var suma20gr = 0;
|
||||||
|
var suma50gr = 0;
|
||||||
|
var suma1zl = 0;
|
||||||
|
var suma2zl = 0;
|
||||||
|
var suma5zl = 0;
|
||||||
|
var suma10zl = 0;
|
||||||
|
var suma20zl = 0;
|
||||||
|
var suma50zl = 0;
|
||||||
|
var suma100zl = 0;
|
||||||
|
var suma200zl = 0;
|
||||||
|
var suma500zl = 0;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
suma += row['1gr'] + row['2gr'] * 2 + row['5gr'] * 5 + row['10gr'] * 10 + row['20gr'] * 20 + row['50gr'] * 50 + row['1zl'] * 100 + row['2zl'] * 200 + row['5zl'] * 500 + row['10zl'] * 1000 + row['20zl'] * 2000 + row['50zl'] * 5000 + row['100zl'] * 10000 + row['200zl'] * 20000 + row['500zl'] * 50000;
|
||||||
|
sumaTerminal += row.sumaZTerminala;
|
||||||
|
suma1gr += row['1gr'];
|
||||||
|
suma2gr += row['2gr'];
|
||||||
|
suma5gr += row['5gr'];
|
||||||
|
suma10gr += row['10gr'];
|
||||||
|
suma20gr += row['20gr'];
|
||||||
|
suma50gr += row['50gr'];
|
||||||
|
suma1zl += row['1zl'];
|
||||||
|
suma2zl += row['2zl'];
|
||||||
|
suma5zl += row['5zl'];
|
||||||
|
suma10zl += row['10zl'];
|
||||||
|
suma20zl += row['20zl'];
|
||||||
|
suma50zl += row['50zl'];
|
||||||
|
suma100zl += row['100zl'];
|
||||||
|
suma200zl += row['200zl'];
|
||||||
|
suma500zl += row['500zl'];
|
||||||
|
});
|
||||||
|
toReturn += '<tr><td>Suma</td><td>' + suma/100.0 + ' zł</td></tr>';
|
||||||
|
toReturn += '<tr><td>Suma z terminali</td><td>' + sumaTerminal + ' zł</td></tr>';
|
||||||
|
toReturn += '<tr><td>1 gr</td><td>' + suma1gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>2 gr</td><td>' + suma2gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>5 gr</td><td>' + suma5gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>10 gr</td><td>' + suma10gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>20 gr</td><td>' + suma20gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>50 gr</td><td>' + suma50gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>1 zł</td><td>' + suma1zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>2 zł</td><td>' + suma2zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>5 zł</td><td>' + suma5zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>10 zł</td><td>' + suma10zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>20 zł</td><td>' + suma20zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>50 zł</td><td>' + suma50zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>100 zł</td><td>' + suma100zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>200 zł</td><td>' + suma200zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>500 zł</td><td>' + suma500zl + '</td></tr>';
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '<div class="kafelek2">';
|
||||||
|
toReturn += '<h2>Top 10 wolontariuszy</h2>';
|
||||||
|
//SELECT * FROM `SumaZebranaPrzezWolontariuszy` ORDER BY `SumaZebranaPrzezWolontariuszy`.`suma` ASC LIMIT 10;
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><th>Wolontariusz</th><th>Suma</th></tr>';
|
||||||
|
con.query('SELECT numerIdentyfikatora, imie, nazwisko, suma FROM `SumaZebranaPrzezWolontariuszy` ORDER BY `SumaZebranaPrzezWolontariuszy`.`suma` ASC LIMIT 10;', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
toReturn += '<tr><td>' + row.numerIdentyfikatora + '</td><td>' + row.suma + '</td></tr>';
|
||||||
|
});
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '<div class="kafelek2">';
|
||||||
|
//który liczący najwięcej liczył
|
||||||
|
toReturn += '<h2>Najwięcej puszek przeliczonych</h2>';
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><th>Liczący</th><th>Suma</th></tr>';
|
||||||
|
con.query("SELECT idLiczacego, imie, nazwisko, sumaPrzeliczona FROM `sumaPrzeliczona` ORDER BY `sumaPrzeliczona`.`sumaPrzeliczona` DESC LIMIT 10;", function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
toReturn += '<tr><td>' + row.idLiczacego + '</td><td>' + row.sumaPrzeliczona + '</td></tr>';
|
||||||
|
});
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml();
|
||||||
|
res.send(toReturn);
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.all('/logout', function(req, res) {
|
||||||
|
//sprawdź czy token istnieje i jest aktywny
|
||||||
|
var cookies = cookie.parse(req.headers.cookie || '');
|
||||||
|
var token = cookies.token;
|
||||||
|
con.query('UPDATE tokeny SET aktywny = 0 WHERE token = ?', [token], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.redirect('/panel/login');
|
||||||
|
loger(fs, 'Wylogowano użytkownika ' + req.user.kto, 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//404
|
||||||
|
app.all('/*', function(req, res, next) {
|
||||||
|
var toReturn = headerHtml();
|
||||||
|
toReturn += menuHtml(2);
|
||||||
|
toReturn += '<div class="content">';
|
||||||
|
toReturn += '<h1>404</h1>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml();
|
||||||
|
res.status(404).send(toReturn);
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
app.listen(process.env.PORT || 8880, function() {
|
||||||
|
console.log('Example app listening on port http://localhost:' + process.env.PORT || 8880 + '!');
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tryConnect();
|
|
@ -0,0 +1,453 @@
|
||||||
|
const express = require('express');
|
||||||
|
const liczacy = express.Router();
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
require('dotenv').config();
|
||||||
|
//mysql
|
||||||
|
var mysql = require('mysql2');
|
||||||
|
var con = mysql.createConnection({
|
||||||
|
host: process.env.MYSQLHOST,
|
||||||
|
user: process.env.MYSQLUSER,
|
||||||
|
password: process.env.MYSQLPASS,
|
||||||
|
port : process.env.MYSQLPORT,
|
||||||
|
database: process.env.MYSQLDB,
|
||||||
|
insecureAuth : true
|
||||||
|
});
|
||||||
|
con.connect(function(err) {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log('Connected!');
|
||||||
|
});
|
||||||
|
var cookie = require('cookie');
|
||||||
|
var app = express();
|
||||||
|
var bodyParser = require('body-parser');
|
||||||
|
app.use(bodyParser.urlencoded({
|
||||||
|
extended: true
|
||||||
|
}));
|
||||||
|
//import functions from func.js
|
||||||
|
const {headerHtml, menuHtml, footerHtml, checkPesel, loger, telefon, sendToDiscord, sendEmail} = require('./func.js');
|
||||||
|
liczacy.use(function(req, res, next) {
|
||||||
|
var cookies = cookie.parse(req.headers.cookie || '');
|
||||||
|
var liczacy = cookies.liczacy;
|
||||||
|
con.query('SELECT * FROM tokenyLiczacy, liczacy WHERE token = ? AND aktywny = 1 AND tokenyLiczacy.userId = liczacy.id', [liczacy], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
//get from result imie
|
||||||
|
req.user = result[0];
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
res.redirect('/loginliczacy');
|
||||||
|
loger(fs, 'Nieudana próba dostępu do panelu liczącego przy użyciu tokenu: ' + liczacy, 'warning');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
liczacy.get('/', function(req, res) {
|
||||||
|
var toReturn = headerHtml();
|
||||||
|
toReturn += menuHtml(4);
|
||||||
|
toReturn += '<div class="content">';
|
||||||
|
toReturn += '<h1>Panel</h1>';
|
||||||
|
toReturn += '<h2>Witaj ' + req.user.imie + '</h2>';
|
||||||
|
toReturn += '<div class="kafelki3">';
|
||||||
|
toReturn += '<a class="borderColorBlue" href="/liczacy/rozlicz">Rozlicz wolontariusza</a>';
|
||||||
|
toReturn += '<a class="borderColorPurple" href="/liczacy/wyloguj">Wyloguj się</a>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml(2);
|
||||||
|
res.send(toReturn);
|
||||||
|
})
|
||||||
|
|
||||||
|
liczacy.all('/statystyki2', function(req, res) {
|
||||||
|
var toReturn = headerHtml("Statystyki");
|
||||||
|
toReturn += menuHtml(4);
|
||||||
|
//make script to refresh every 5 seconds, and full screen this page
|
||||||
|
toReturn += '<script>';
|
||||||
|
toReturn += "var elem = document.documentElement;"
|
||||||
|
toReturn += "if (elem.requestFullscreen) {";
|
||||||
|
toReturn += "elem.requestFullscreen();";
|
||||||
|
toReturn += "} else if (elem.mozRequestFullScreen) {";
|
||||||
|
toReturn += "elem.mozRequestFullScreen();";
|
||||||
|
toReturn += "} else if (elem.webkitRequestFullscreen) {";
|
||||||
|
toReturn += "elem.webkitRequestFullscreen();";
|
||||||
|
toReturn += "} else if (elem.msRequestFullscreen) {";
|
||||||
|
toReturn += "elem.msRequestFullscreen();";
|
||||||
|
toReturn += "}";
|
||||||
|
toReturn += 'setTimeout(function() {';
|
||||||
|
toReturn += 'window.location.reload(1);';
|
||||||
|
toReturn += '}, 5000);';
|
||||||
|
toReturn += '</script>';
|
||||||
|
|
||||||
|
toReturn += '<div class="kafelki2">';
|
||||||
|
toReturn += '<div class="kafelek2">';
|
||||||
|
toReturn += '<h2>Całkowita suma</h2>';
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
//wypisz sumę zebranych pieniędzy, sumę poszczególnych nominałów
|
||||||
|
//pobierz wszystkie rozliczenia
|
||||||
|
con.query('SELECT * FROM rozliczenie WHERE aktywne = 1', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
var suma = 0;
|
||||||
|
var sumaTerminal = 0;
|
||||||
|
var suma1gr = 0;
|
||||||
|
var suma2gr = 0;
|
||||||
|
var suma5gr = 0;
|
||||||
|
var suma10gr = 0;
|
||||||
|
var suma20gr = 0;
|
||||||
|
var suma50gr = 0;
|
||||||
|
var suma1zl = 0;
|
||||||
|
var suma2zl = 0;
|
||||||
|
var suma5zl = 0;
|
||||||
|
var suma10zl = 0;
|
||||||
|
var suma20zl = 0;
|
||||||
|
var suma50zl = 0;
|
||||||
|
var suma100zl = 0;
|
||||||
|
var suma200zl = 0;
|
||||||
|
var suma500zl = 0;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
suma += row['1gr'] + row['2gr'] * 2 + row['5gr'] * 5 + row['10gr'] * 10 + row['20gr'] * 20 + row['50gr'] * 50 + row['1zl'] * 100 + row['2zl'] * 200 + row['5zl'] * 500 + row['10zl'] * 1000 + row['20zl'] * 2000 + row['50zl'] * 5000 + row['100zl'] * 10000 + row['200zl'] * 20000 + row['500zl'] * 50000;
|
||||||
|
sumaTerminal += row.sumaZTerminala;
|
||||||
|
suma1gr += row['1gr'];
|
||||||
|
suma2gr += row['2gr'];
|
||||||
|
suma5gr += row['5gr'];
|
||||||
|
suma10gr += row['10gr'];
|
||||||
|
suma20gr += row['20gr'];
|
||||||
|
suma50gr += row['50gr'];
|
||||||
|
suma1zl += row['1zl'];
|
||||||
|
suma2zl += row['2zl'];
|
||||||
|
suma5zl += row['5zl'];
|
||||||
|
suma10zl += row['10zl'];
|
||||||
|
suma20zl += row['20zl'];
|
||||||
|
suma50zl += row['50zl'];
|
||||||
|
suma100zl += row['100zl'];
|
||||||
|
suma200zl += row['200zl'];
|
||||||
|
suma500zl += row['500zl'];
|
||||||
|
});
|
||||||
|
toReturn += '<tr><td>Suma</td><td>' + suma/100.0 + ' zł</td></tr>';
|
||||||
|
toReturn += '<tr><td>Suma z terminali</td><td>' + sumaTerminal + ' zł</td></tr>';
|
||||||
|
toReturn += '<tr><td>1 gr</td><td>' + suma1gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>2 gr</td><td>' + suma2gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>5 gr</td><td>' + suma5gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>10 gr</td><td>' + suma10gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>20 gr</td><td>' + suma20gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>50 gr</td><td>' + suma50gr + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>1 zł</td><td>' + suma1zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>2 zł</td><td>' + suma2zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>5 zł</td><td>' + suma5zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>10 zł</td><td>' + suma10zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>20 zł</td><td>' + suma20zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>50 zł</td><td>' + suma50zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>100 zł</td><td>' + suma100zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>200 zł</td><td>' + suma200zl + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>500 zł</td><td>' + suma500zl + '</td></tr>';
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '<div class="kafelek2">';
|
||||||
|
toReturn += '<h2>Top 10 wolontariuszy</h2>';
|
||||||
|
//SELECT * FROM `SumaZebranaPrzezWolontariuszy` ORDER BY `SumaZebranaPrzezWolontariuszy`.`suma` ASC LIMIT 10;
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><th>Wolontariusz</th><th>Suma</th></tr>';
|
||||||
|
con.query('SELECT numerIdentyfikatora, imie, nazwisko, suma FROM `SumaZebranaPrzezWolontariuszy` ORDER BY `SumaZebranaPrzezWolontariuszy`.`suma` ASC LIMIT 10;', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
toReturn += '<tr><td>' + row.numerIdentyfikatora + '</td><td>' + row.suma + '</td></tr>';
|
||||||
|
});
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '<div class="kafelek2">';
|
||||||
|
//który liczący najwięcej liczył
|
||||||
|
toReturn += '<h2>Najwięcej puszek przeliczonych</h2>';
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><th>Liczący</th><th>Suma</th></tr>';
|
||||||
|
con.query("SELECT idLiczacego, imie, nazwisko, sumaPrzeliczona FROM `sumaPrzeliczona` ORDER BY `sumaPrzeliczona`.`sumaPrzeliczona` DESC LIMIT 10;", function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
toReturn += '<tr><td>' + row.idLiczacego + '</td><td>' + row.sumaPrzeliczona + '</td></tr>';
|
||||||
|
});
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml();
|
||||||
|
res.send(toReturn);
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
liczacy.get('/rozlicz', function(req, res) {
|
||||||
|
var toReturn = headerHtml("Lista wolontariuszy do rozliczenia");
|
||||||
|
toReturn += menuHtml(4);
|
||||||
|
toReturn += '<div class="content">';
|
||||||
|
toReturn += '<h1>Rozlicz</h1>';
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr>';
|
||||||
|
toReturn += '<th>Numer</th>';
|
||||||
|
toReturn += '<th>Imię</th>';
|
||||||
|
toReturn += '<th>Nazwisko</th>';
|
||||||
|
toReturn += '<th>Terminal</th>';
|
||||||
|
toReturn += '<th>Rodzic</th>';
|
||||||
|
toReturn += '<th>Opcje</th>';
|
||||||
|
toReturn += '</tr>';
|
||||||
|
//pobierz osoby liczące
|
||||||
|
con.query('SELECT * FROM wolontariusz WHERE aktywny = 1 AND id NOT IN (SELECT wolontariuszID FROM rozliczenie WHERE aktywne = 1) ORDER BY numerIdentyfikatora ASC', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
toReturn += '<tr>';
|
||||||
|
toReturn += '<td>' + row.numerIdentyfikatora + '</td>';
|
||||||
|
toReturn += '<td>' + row.imie + '</td>';
|
||||||
|
toReturn += '<td>' + row.nazwisko + '</td>';
|
||||||
|
toReturn += '<td>' + (row.terminal == 1 ? '<b>Tak</b>' : 'Nie') + '</td>';
|
||||||
|
if(row.rodzic == "BRAK")
|
||||||
|
toReturn += '<td> </td>';
|
||||||
|
else
|
||||||
|
toReturn += '<td style="color: red; font-weight: bold;">' + row.rodzic + '</td>';
|
||||||
|
toReturn += '<td><a href="/liczacy/rozliczWolontariusza?id=' + row.id + '">Rozlicz</a></td>';
|
||||||
|
toReturn += '</tr>';
|
||||||
|
});
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml(2);
|
||||||
|
res.send(toReturn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
liczacy.get('/rozliczWolontariusza', function(req, res) {
|
||||||
|
var idWolontariusza = req.query.id;
|
||||||
|
//pobierz dane wolontariusza, wyświetl formularz rozliczenia
|
||||||
|
var toReturn = headerHtml("Rozlicz wolontariusza");
|
||||||
|
toReturn += menuHtml(4);
|
||||||
|
toReturn += '<div class="content">';
|
||||||
|
toReturn += '<h1>Rozlicz wolontariusza</h1>';
|
||||||
|
toReturn += '<form action="/liczacy/rozliczWolontariusza?id=' + idWolontariusza + '" method="POST">';
|
||||||
|
con.query('SELECT * FROM wolontariusz WHERE id = ?', [idWolontariusza], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if (result.length > 0) {
|
||||||
|
toReturn += "<h2>" + result[0].imie + " " + result[0].nazwisko + "</h2>";
|
||||||
|
toReturn += "<h3>ID: " + result[0].numerIdentyfikatora + "</h3>";
|
||||||
|
toReturn += '<h2>Suma: <span id="suma2">0</span> zł</h2>';
|
||||||
|
//pokaż formularz do wpisywania zebranej kwoaty i monet (sumę liczy program, użytkownik podaje ilość monet)
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><td>Suma</td><td><input type="number" name="weryfikacjaSuma" step="0.01"></td></tr>';
|
||||||
|
toReturn += '<tr>';
|
||||||
|
toReturn += '<th>Waluta</th>';
|
||||||
|
toReturn += '<th>Ilość</th>';
|
||||||
|
toReturn += '</tr>';
|
||||||
|
toReturn += '<tr><td>1 gr</td><td><input type="number" name="1gr" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>2 gr</td><td><input type="number" name="2gr" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>5 gr</td><td><input type="number" name="5gr" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>10 gr</td><td><input type="number" name="10gr" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>20 gr</td><td><input type="number" name="20gr" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>50 gr</td><td><input type="number" name="50gr" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>1 zł</td><td><input type="number" name="1zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>2 zł</td><td><input type="number" name="2zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>5 zł</td><td><input type="number" name="5zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>10 zł</td><td><input type="number" name="10zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>20 zł</td><td><input type="number" name="20zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>50 zł</td><td><input type="number" name="50zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>100 zł</td><td><input type="number" name="100zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>200 zł</td><td><input type="number" name="200zl" value="0"></td></tr>';
|
||||||
|
toReturn += '<tr><td>500 zł</td><td><input type="number" name="500zl" value="0"></td></tr>';
|
||||||
|
//kwota z terminala
|
||||||
|
toReturn += '<tr><td>Kwota z terminala</td><td><input type="number" name="terminal" step="0.01" value="0"></td></tr>';
|
||||||
|
//waluta obca, tekstarea
|
||||||
|
toReturn += '<tr><td>Waluta obca</td><td><textarea name="walutaObca"></textarea></td></tr>';
|
||||||
|
//dary inne, tekstarea
|
||||||
|
toReturn += '<tr><td>Dary inne</td><td><textarea name="daryInne"></textarea></td></tr>';
|
||||||
|
//uwagi, tekstarea
|
||||||
|
toReturn += '<tr><td>Uwagi</td><td><textarea name="uwagi"></textarea></td></tr>';
|
||||||
|
//sala
|
||||||
|
toReturn += '<tr><td>Sala</td><td><input type="text" name="sala" value="główna"></td></tr>';
|
||||||
|
//liczący 1
|
||||||
|
toReturn += '<tr><td>Liczący 1</td><td>' + req.user.imie + ' ' + req.user.nazwisko + '</td></tr>';
|
||||||
|
console.log(req.user);
|
||||||
|
|
||||||
|
toReturn += '<input type="hidden" name="liczacy1" value="' + req.user.id + '">';
|
||||||
|
|
||||||
|
//liczący 2
|
||||||
|
toReturn += '<tr><td>Liczący 2</td><td><select name="liczacy2">';
|
||||||
|
//pobierz wszystkich liczących
|
||||||
|
con.query('SELECT * FROM liczacy WHERE aktywne = 1 ORDER BY nazwisko ASC', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
//jeżeli id liczącego == req.user.id, pomiń
|
||||||
|
if(row.id == req.user.id) return;
|
||||||
|
toReturn += '<option value="' + row.id + '">' + row.imie + ' ' + row.nazwisko + '</option>';
|
||||||
|
});
|
||||||
|
toReturn += '</select></td></tr>';
|
||||||
|
//liczący 3
|
||||||
|
toReturn += '<tr><td>Liczący 3</td><td><select name="liczacy3">';
|
||||||
|
toReturn += '<option value="0">BRAK</option>';
|
||||||
|
//pobierz wszystkich liczących
|
||||||
|
con.query('SELECT * FROM liczacy WHERE aktywne = 1 ORDER BY nazwisko ASC', function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
if(row.id == req.user.id) return;
|
||||||
|
toReturn += '<option value="' + row.id + '">' + row.imie + ' ' + row.nazwisko + '</option>';
|
||||||
|
});
|
||||||
|
toReturn += '</select></td></tr>';
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '<input type="submit" id="zapisz" value="Zapisz" disabled>';
|
||||||
|
toReturn += '<h2>Suma: <span id="suma">0</span> zł</h2>';
|
||||||
|
toReturn += '<script>';
|
||||||
|
toReturn += 'var suma = 0;';
|
||||||
|
toReturn += 'function updateSum() {';
|
||||||
|
toReturn += 'suma = 0;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("1gr")[0].value);';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("2gr")[0].value) * 2;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("5gr")[0].value) * 5;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("10gr")[0].value) * 10;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("20gr")[0].value) * 20;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("50gr")[0].value) * 50;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("1zl")[0].value) * 100;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("2zl")[0].value) * 200;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("5zl")[0].value) * 500;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("10zl")[0].value) * 1000;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("20zl")[0].value) * 2000;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("50zl")[0].value) * 5000;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("100zl")[0].value) * 10000;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("200zl")[0].value) * 20000;';
|
||||||
|
toReturn += 'suma += parseInt(document.getElementsByName("500zl")[0].value) * 50000;';
|
||||||
|
toReturn += 'suma += parseFloat(document.getElementsByName("terminal")[0].value) * 100;';
|
||||||
|
toReturn += 'document.getElementById("suma").innerHTML = suma/100.0;';
|
||||||
|
toReturn += 'document.getElementById("suma2").innerHTML = suma/100.0;';
|
||||||
|
toReturn += 'if (suma == Math.floor(Number(document.getElementsByName("weryfikacjaSuma")[0].value)*100)) {';
|
||||||
|
toReturn += 'document.getElementsByName("weryfikacjaSuma")[0].style.backgroundColor = "#00ff44";';
|
||||||
|
toReturn += 'document.getElementById("zapisz").disabled = false;';
|
||||||
|
toReturn += '} else {';
|
||||||
|
toReturn += 'document.getElementsByName("weryfikacjaSuma")[0].style.backgroundColor = "#ff0000";';
|
||||||
|
toReturn += 'document.getElementById("zapisz").disabled = true;';
|
||||||
|
toReturn += '}';
|
||||||
|
toReturn += '}';
|
||||||
|
toReturn += 'updateSum();';
|
||||||
|
toReturn += 'document.getElementsByName("1gr")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("2gr")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("5gr")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("10gr")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("20gr")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("50gr")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("1zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("2zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("5zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("10zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("20zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("50zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("100zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("200zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("500zl")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("terminal")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += 'document.getElementsByName("weryfikacjaSuma")[0].addEventListener("input", updateSum);';
|
||||||
|
toReturn += '</script>';
|
||||||
|
|
||||||
|
toReturn += '</form>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
toReturn += footerHtml(2);
|
||||||
|
res.send(toReturn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
liczacy.post('/rozliczWolontariusza', function(req, res) {
|
||||||
|
//weryfikowal to numer id z tokenu
|
||||||
|
var idWolontariusza = req.query.id;
|
||||||
|
var idLiczacy1 = req.body.liczacy1;
|
||||||
|
var idLiczacy2 = req.body.liczacy2;
|
||||||
|
var idLiczacy3 = req.body.liczacy3 == 0 ? null : req.body.liczacy3;
|
||||||
|
var sala = req.body.sala;
|
||||||
|
var uwagi = req.body.uwagi;
|
||||||
|
var daryInne = req.body.daryInne;
|
||||||
|
var walutaObca = req.body.walutaObca;
|
||||||
|
var terminal = req.body.terminal > 0 ? 1 : 0;
|
||||||
|
var gr1 = req.body['1gr'];
|
||||||
|
var gr2 = req.body['2gr'];
|
||||||
|
var gr5 = req.body['5gr'];
|
||||||
|
var gr10 = req.body['10gr'];
|
||||||
|
var gr20 = req.body['20gr'];
|
||||||
|
var gr50 = req.body['50gr'];
|
||||||
|
var zl1 = req.body['1zl'];
|
||||||
|
var zl2 = req.body['2zl'];
|
||||||
|
var zl5 = req.body['5zl'];
|
||||||
|
var zl10 = req.body['10zl'];
|
||||||
|
var zl20 = req.body['20zl'];
|
||||||
|
var zl50 = req.body['50zl'];
|
||||||
|
var zl100 = req.body['100zl'];
|
||||||
|
var zl200 = req.body['200zl'];
|
||||||
|
var zl500 = req.body['500zl'];
|
||||||
|
var sumaZTerminala = req.body.terminal;
|
||||||
|
//zapisz dane do bazy
|
||||||
|
$sql = "INSERT INTO `rozliczenie` (`id`, `wolontariuszID`, `czasRozliczenia`, `terminal`, `sumaZTerminala`, `1gr`, `2gr`, `5gr`, `10gr`, `20gr`, `50gr`, `1zl`, `2zl`, `5zl`, `10zl`, `20zl`, `50zl`, `100zl`, `200zl`, `500zl`, `walutaObca`, `daryInne`, `uwagi`, `liczacy1`, `liczacy2`, `liczacy3`, `sala`, `weryfikowal`, `wpisaneDoBSS`, `ostatniaZmiana`, `aktywne`) ";
|
||||||
|
$sql += 'VALUES (NULL, ?, CURRENT_TIME(), ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,CURRENT_TIME(),1)';
|
||||||
|
con.query($sql, [idWolontariusza, terminal, sumaZTerminala, gr1, gr2, gr5, gr10, gr20, gr50, zl1, zl2, zl5, zl10, zl20, zl50, zl100, zl200, zl500, walutaObca, daryInne, uwagi, idLiczacy1, idLiczacy2, idLiczacy3, sala], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
if(process.env.DISCORD == "TAK")
|
||||||
|
{
|
||||||
|
con.query('SELECT * FROM wolontariusz WHERE id = ?', [idWolontariusza], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
var suma = Number(gr1) +Number(gr2)*2 + Number(gr5)*5 + Number(gr10)*10 + Number(gr20)*20 + Number(gr50)*50 + Number(zl1)*100 + Number(zl2)*200 + Number(zl5)*500 + Number(zl10)*1000 + Number(zl20)*2000 + Number(zl50)*5000 + Number(zl100)*10000 + Number(zl200)*20000 + Number(zl500)*50000 + Number(sumaZTerminala)*100;
|
||||||
|
sendToDiscord(result[0].imie, result[0].nazwisko, suma/100, result[0].discord);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(process.env.SENDEMAILS == "TAK")
|
||||||
|
{
|
||||||
|
con.query('SELECT * FROM wolontariusz WHERE id = ?', [idWolontariusza], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
var suma = Number(gr1) +Number(gr2)*2 + Number(gr5)*5 + Number(gr10)*10 + Number(gr20)*20 + Number(gr50)*50 + Number(zl1)*100 + Number(zl2)*200 + Number(zl5)*500 + Number(zl10)*1000 + Number(zl20)*2000 + Number(zl50)*5000 + Number(zl100)*10000 + Number(zl200)*20000 + Number(zl500)*50000 + Number(sumaZTerminala)*100;
|
||||||
|
sendEmail(result[0].imie, result[0].nazwisko, suma/100, result[0].email);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
res.redirect('/liczacy/rozliczenia#'+idWolontariusza);
|
||||||
|
loger(fs, 'Rozliczono wolontariusza o id: ' + idWolontariusza, 'info');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
liczacy.get("/szybkieInfo", function(req, res) {
|
||||||
|
var toReturn = '<link rel="stylesheet" href="/style.css">';
|
||||||
|
toReturn += '<div class="side">';
|
||||||
|
toReturn += '<h1>Szybkie informacje</h1>';
|
||||||
|
//sprawdź ile jest wolontariuszy oraz ilu jest rozliczonych
|
||||||
|
var iloscWolontariuszy = 0;
|
||||||
|
var iloscRozliczonych = 0;
|
||||||
|
var iloscLiczących = 0;
|
||||||
|
con.query("SELECT * FROM `wolontariusz` WHERE `aktywny` = 1", function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
iloscWolontariuszy = result.length;
|
||||||
|
con.query("SELECT * FROM `rozliczenie` WHERE `aktywne` = 1", function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
iloscRozliczonych = result.length;
|
||||||
|
con.query("SELECT * FROM `liczacy` WHERE `aktywne` = 1", function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
iloscLiczących = result.length;
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><td>Ilość wolontariuszy</td><td>' + iloscWolontariuszy + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>Ilość rozliczonych</td><td>' + iloscRozliczonych + '</td></tr>';
|
||||||
|
toReturn += '<tr><td>Ilość liczących</td><td>' + iloscLiczących + '</td></tr>';
|
||||||
|
toReturn += '</table>';
|
||||||
|
//ostatni rozliczony
|
||||||
|
toReturn += '<h2>Ostatnio rozliczeni</h2>';
|
||||||
|
toReturn += '<table class="dane">';
|
||||||
|
toReturn += '<tr><th>Wolontariusz</th><th>Suma</th></tr>';
|
||||||
|
con.query("SELECT * FROM `rozliczenie`, `wolontariusz` WHERE `rozliczenie`.`wolontariuszID` = `wolontariusz`.`id` AND `rozliczenie`.`aktywne` = 1 ORDER BY `rozliczenie`.`czasRozliczenia` DESC LIMIT 5", function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
result.forEach(function(row) {
|
||||||
|
toReturn += '<tr><td>' + row.numerIdentyfikatora + '</td><td>' + (row['1gr'] + row['2gr'] * 2 + row['5gr'] * 5 + row['10gr'] * 10 + row['20gr'] * 20 + row['50gr'] * 50 + row['1zl'] * 100 + row['2zl'] * 200 + row['5zl'] * 500 + row['10zl'] * 1000 + row['20zl'] * 2000 + row['50zl'] * 5000 + row['100zl'] * 10000 + row['200zl'] * 20000 + row['500zl'] * 50000 + row.sumaZTerminala * 100)/100.0 + ' zł</td></tr>';
|
||||||
|
});
|
||||||
|
toReturn += '</table>';
|
||||||
|
toReturn += '</div>';
|
||||||
|
res.send(toReturn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
liczacy.all('/wyloguj', function(req, res) {
|
||||||
|
//tokenyLiczacy ustaw aktywny na 0
|
||||||
|
con.query('UPDATE tokenyLiczacy SET aktywny = 0 WHERE userId = ?', [req.user.id], function(err, result) {
|
||||||
|
if (err) throw err;
|
||||||
|
res.clearCookie('liczacy');
|
||||||
|
res.redirect('/loginliczacy');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = liczacy;
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "wosp",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node index.js",
|
||||||
|
"test": "nodemon index.js"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "kry008",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": "^1.20.2",
|
||||||
|
"cookie": "^0.6.0",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"discord-webhook-node": "^1.1.8",
|
||||||
|
"dotenv": "^16.3.1",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"mysql2": "^3.12.0",
|
||||||
|
"nodemailer": "^6.9.8",
|
||||||
|
"nodemon": "^3.0.2",
|
||||||
|
"csv-parser": "^3.0.0",
|
||||||
|
"express-fileupload": "^1.5.1",
|
||||||
|
"strip-bom-stream": "^4.0.0"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 119 KiB |
|
@ -0,0 +1,29 @@
|
||||||
|
version: '3.8'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "${APP_PORT}:${APP_PORT}"
|
||||||
|
volumes:
|
||||||
|
- ./prod.env:/usr/src/app/.env
|
||||||
|
- ./logs:/usr/src/app/logs
|
||||||
|
- ./tmp:/usr/src/app/tmp
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
db:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.db
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||||
|
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||||
|
MYSQL_USER: ${MYSQL_USER}
|
||||||
|
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "${DB_PORT}:3306"
|
||||||
|
volumes:
|
||||||
|
- ./app/baza-import.sql:/docker-entrypoint-initdb.d/baza.sql
|
|
@ -0,0 +1,56 @@
|
||||||
|
@echo off
|
||||||
|
cd serwer
|
||||||
|
|
||||||
|
REM Funkcja do sprawdzania dostępności polecenia
|
||||||
|
:command_exists
|
||||||
|
where %1 >nul 2>nul
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
exit /b 0
|
||||||
|
) else (
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Sprawdzenie systemu operacyjnego
|
||||||
|
if "%OS%"=="Windows_NT" (
|
||||||
|
echo Wykryto system Windows.
|
||||||
|
set WINDOWS=true
|
||||||
|
) else (
|
||||||
|
echo Wykryto system Unix/MacOS.
|
||||||
|
set WINDOWS=false
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Sprawdź czy jest dostępne `docker compose`
|
||||||
|
call :command_exists docker
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
docker compose version >nul 2>nul
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo Docker Compose dostępny jako 'docker compose'.
|
||||||
|
set COMPOSE_COMMAND=docker compose
|
||||||
|
) else (
|
||||||
|
call :command_exists docker-compose
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo Docker Compose dostępny jako 'docker-compose'.
|
||||||
|
set COMPOSE_COMMAND=docker-compose
|
||||||
|
) else (
|
||||||
|
echo Docker Compose nie jest zainstalowany. Zainstaluj go przed uruchomieniem tego skryptu.
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo Docker Compose nie jest zainstalowany. Zainstaluj go przed uruchomieniem tego skryptu.
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Uruchomienie docker compose up
|
||||||
|
if "%WINDOWS%"=="true" (
|
||||||
|
%COMPOSE_COMMAND% up --build -d
|
||||||
|
) else (
|
||||||
|
%COMPOSE_COMMAND% up --build -d
|
||||||
|
)
|
||||||
|
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo Docker Compose został uruchomiony pomyślnie.
|
||||||
|
) else (
|
||||||
|
echo Wystąpił błąd podczas uruchamiania Docker Compose.
|
||||||
|
exit /b 1
|
||||||
|
)
|
Loading…
Reference in New Issue