checkfuehrung: mehrere Einträge pro Tag behandeln
This commit is contained in:
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
@@ -37,6 +37,15 @@
|
|||||||
"pathMappings": {
|
"pathMappings": {
|
||||||
"/var/www/html": "${workspaceFolder}/sternwarte"
|
"/var/www/html": "${workspaceFolder}/sternwarte"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug checkfuehrung.js",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/sternwarte/checkfuehrung/checkfuehrung.js",
|
||||||
|
"args": ["-d", "2"],
|
||||||
|
"cwd": "${workspaceFolder}/sternwarte/checkfuehrung",
|
||||||
|
"console": "integratedTerminal"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -898,6 +898,7 @@ class RepoKalender
|
|||||||
{
|
{
|
||||||
const TBL = 'kalender';
|
const TBL = 'kalender';
|
||||||
|
|
||||||
|
|
||||||
public static function getEntries(string $start, string $end): array
|
public static function getEntries(string $start, string $end): array
|
||||||
{
|
{
|
||||||
$s = date('Ymd', strtotime($start));
|
$s = date('Ymd', strtotime($start));
|
||||||
@@ -905,6 +906,14 @@ class RepoKalender
|
|||||||
return DB::all("SELECT * FROM " . self::TBL . " WHERE start >= ? AND start <= ?", [$s, $e]);
|
return DB::all("SELECT * FROM " . self::TBL . " WHERE start >= ? AND start <= ?", [$s, $e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getOneEntry(string $start): array
|
||||||
|
{
|
||||||
|
$end = new DateTime($start);
|
||||||
|
$end->modify('+1 day');
|
||||||
|
$end = $end->format('Y-m-d');
|
||||||
|
return RepoKalender::getEntries($start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
public static function insert(array $data): bool
|
public static function insert(array $data): bool
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO " . self::TBL . " (start, end, title, description) VALUES (?, ?, ?, ?)";
|
$sql = "INSERT INTO " . self::TBL . " (start, end, title, description) VALUES (?, ?, ?, ?)";
|
||||||
@@ -1078,6 +1087,7 @@ class Commands
|
|||||||
'UPDATE_KALENDER_BEO' => 'Kalender-Eintrag BEOS aktualisieren',
|
'UPDATE_KALENDER_BEO' => 'Kalender-Eintrag BEOS aktualisieren',
|
||||||
'GET_FDATES' => 'Führungstermine für Kalenderansicht',
|
'GET_FDATES' => 'Führungstermine für Kalenderansicht',
|
||||||
'GET_CALENTRIES' => 'Kalendereinträge abrufen',
|
'GET_CALENTRIES' => 'Kalendereinträge abrufen',
|
||||||
|
'GET_ONEENTRY' => 'einen Kalendereintrag abrufen',
|
||||||
'PUT_CALENTRY' => 'Kalendereintrag erstellen',
|
'PUT_CALENTRY' => 'Kalendereintrag erstellen',
|
||||||
'DEL_CALENTRY' => 'Kalendereintrag löschen',
|
'DEL_CALENTRY' => 'Kalendereintrag löschen',
|
||||||
'GET_YEARS' => 'Liste verfügbare Jahre (Statistik)',
|
'GET_YEARS' => 'Liste verfügbare Jahre (Statistik)',
|
||||||
@@ -1438,6 +1448,9 @@ Spendenbescheinigung: \t" . $info['spende'] . "
|
|||||||
case 'GET_CALENTRIES':
|
case 'GET_CALENTRIES':
|
||||||
if (!isset($input['start'], $input['end'])) respondError('start and end required');
|
if (!isset($input['start'], $input['end'])) respondError('start and end required');
|
||||||
respond(RepoKalender::getEntries($input['start'], $input['end']));
|
respond(RepoKalender::getEntries($input['start'], $input['end']));
|
||||||
|
case 'GET_ONEENTRY':
|
||||||
|
if (!isset($input['date'])) respondError('date required');
|
||||||
|
respond(RepoKalender::getOneEntry($input['date']));
|
||||||
case 'PUT_CALENTRY':
|
case 'PUT_CALENTRY':
|
||||||
RepoKalender::insert($input['data']);
|
RepoKalender::insert($input['data']);
|
||||||
respond(['success' => true]);
|
respond(['success' => true]);
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Dieses Programm kann auch die Überwachung machen, dass Einträge in der DB gel
|
|||||||
|
|
||||||
|
|
||||||
Versions:
|
Versions:
|
||||||
|
V 1.0.2 2026-03-01 rxf
|
||||||
|
- Mehrere Führungen am gleichen Tag werden nun alle verarbeitet (je eine E-Mail pro Eintrag).
|
||||||
|
|
||||||
V 1.0.1 2025-11-17 rxf
|
V 1.0.1 2025-11-17 rxf
|
||||||
- Übergabe der Tage bis zu 'gestern' als Commandline Parameter: '-d x'. Ohne -d wird 1 angesetzt.
|
- Übergabe der Tage bis zu 'gestern' als Commandline Parameter: '-d x'. Ohne -d wird 1 angesetzt.
|
||||||
|
|
||||||
@@ -61,30 +64,44 @@ const transporter = DEVELOP ? nodemailer.createTransport({
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Ajax-Call, um die Daten von der DBase zu holen
|
// Daten aus der DB holen und für jeden Eintrag eine E-Mail senden
|
||||||
async function fetchDatafromDB(conn,termin) {
|
async function fetchDatafromDB(conn, termin) {
|
||||||
let result;
|
|
||||||
let id;
|
|
||||||
let query = "select mitarbeiter,id from SoFue2 where DATE(wtermin) = '" + termin + "' and status = 2";
|
|
||||||
try {
|
try {
|
||||||
result = await conn.query(query);
|
const query = "select mitarbeiter,id from SoFue2 where DATE(wtermin) = '" + termin + "' and status = 2";
|
||||||
if (result[0].length == 0) {
|
const [rows] = await conn.query(query);
|
||||||
|
|
||||||
|
if (rows.length === 0) {
|
||||||
console.log("Keine Führung gewesen");
|
console.log("Keine Führung gewesen");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ma = result[0][0].mitarbeiter;
|
|
||||||
id = result[0][0].id;
|
console.log(`${rows.length} Führung(en) gefunden für ${termin}`);
|
||||||
query = "select vorname,email_1 from beos where name = '" + ma + "'";
|
|
||||||
result = await conn.query(query);
|
for (const row of rows) {
|
||||||
|
const ma = row.mitarbeiter;
|
||||||
|
const id = row.id;
|
||||||
|
const beoQuery = "select vorname,email_1 from beos where name = '" + ma + "'";
|
||||||
|
const [beoRows] = await conn.query(beoQuery);
|
||||||
|
|
||||||
|
if (beoRows.length === 0) {
|
||||||
|
console.log(`Kein BEO-Eintrag gefunden für Mitarbeiter: ${ma} (id=${id})`);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
catch(err) {
|
|
||||||
|
send2BEO({
|
||||||
|
name: beoRows[0].vorname,
|
||||||
|
email: (beoRows[0].email_1).toLowerCase(),
|
||||||
|
date: termin,
|
||||||
|
id: id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
conn.end();
|
conn.end();
|
||||||
}
|
}
|
||||||
let erg = result[0];
|
|
||||||
send2BEO({name: erg[0].vorname, email: erg[0].email_1, date: termin, id: id});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,9 +133,13 @@ function send2BEO(info) {
|
|||||||
async function main() {
|
async function main() {
|
||||||
// console.log(DB_host, DB_port, DB_user, DB_pass, DB_dbase);
|
// console.log(DB_host, DB_port, DB_user, DB_pass, DB_dbase);
|
||||||
console.log('Start: ' + moment().format('YYYY-MM-DD HH:mm'))
|
console.log('Start: ' + moment().format('YYYY-MM-DD HH:mm'))
|
||||||
const connection = await mysql.createConnection({
|
const connection = await mysql.createConnection(DEVELOP ? {
|
||||||
// host: DB_host,
|
host: DB_host,
|
||||||
// port: DB_port,
|
port: DB_port,
|
||||||
|
user: DB_user,
|
||||||
|
password: DB_pass,
|
||||||
|
database: DB_dbase,
|
||||||
|
} : {
|
||||||
user: DB_user,
|
user: DB_user,
|
||||||
password: DB_pass,
|
password: DB_pass,
|
||||||
database: DB_dbase,
|
database: DB_dbase,
|
||||||
|
|||||||
Reference in New Issue
Block a user