Teilnehmerauswertung auf Ledger-Lesemodell umstellen

This commit is contained in:
2026-07-14 22:25:51 +02:00
parent 8688cc78db
commit 078f28551d
2 changed files with 328 additions and 218 deletions
+54
View File
@@ -265,6 +265,60 @@ function ledger_fetch_participant_summary_by_legacy_id(PDO $pdo, int $tenantId,
return $summaries[0] ?? null; return $summaries[0] ?? null;
} }
function ledger_mirror_legacy_consumption(PDO $pdo, int $tenantId, int $legacyConsumptionId): void
{
$stmt = $pdo->prepare(
"INSERT INTO ledger_entries
(tenant_id, participant_id, type, amount_cents, marks_count,
unit_price_cents, booked_at, source, note, legacy_table, legacy_id)
SELECT
p.tenant_id,
p.id,
'consumption',
-CAST(ROUND(v.Kosten * 100) AS SIGNED),
v.AnzahlStriche,
CAST(ROUND(v.KostenproStrich * 100) AS SIGNED),
v.Datum,
CASE
WHEN v.Eintragsart = 2 THEN 'legacy_web'
ELSE 'legacy_manual'
END,
CASE
WHEN v.Eintragsart IS NULL THEN NULL
ELSE CONCAT('Legacy Eintragsart: ', v.Eintragsart)
END,
'kl_Kaffeeverbrauch',
v.VerbrauchID
FROM kl_Kaffeeverbrauch v
JOIN participants p
ON p.tenant_id = ?
AND p.legacy_mitarbeiter_id = v.MitarbeiterID
WHERE v.VerbrauchID = ?
ON DUPLICATE KEY UPDATE
participant_id = VALUES(participant_id),
type = VALUES(type),
amount_cents = VALUES(amount_cents),
marks_count = VALUES(marks_count),
unit_price_cents = VALUES(unit_price_cents),
booked_at = VALUES(booked_at),
source = VALUES(source),
note = VALUES(note)"
);
$stmt->execute([$tenantId, $legacyConsumptionId]);
$check = $pdo->prepare(
"SELECT COUNT(*)
FROM ledger_entries
WHERE tenant_id = ?
AND legacy_table = 'kl_Kaffeeverbrauch'
AND legacy_id = ?"
);
$check->execute([$tenantId, $legacyConsumptionId]);
if ((int)$check->fetchColumn() !== 1) {
throw new RuntimeException('Der Legacy-Strich konnte nicht ins Ledger gespiegelt werden.');
}
}
/** /**
* Options: * Options:
* - participant_id: int * - participant_id: int
+269 -213
View File
@@ -1,242 +1,298 @@
<?php <?php
include "functions.php"; include "functions.php";
require_once __DIR__ . "/app/ledger.php";
app_require_csrf(); app_require_csrf();
$pdo = app_db_pdo();
$saasUser = saas_current_user($pdo);
$tenantId = 0;
$hasAccess = false;
$emailNorm = strtolower(trim($mailadress));
if ($saasUser !== null) {
$tenantId = (int)$saasUser['tenant_id'];
$emailNorm = strtolower(trim((string)$saasUser['email_norm']));
$hasAccess = true;
}
if (!$hasAccess && checkKaffeelisteAccess($conn, $mailadress)) {
$tenant = ledger_fetch_default_tenant($pdo);
if ($tenant !== null) {
$tenantId = (int)$tenant['id'];
$hasAccess = true;
}
}
$participant = null;
if ($hasAccess && $emailNorm !== '') {
$summaries = ledger_fetch_participant_summaries($pdo, $tenantId, [
'email_norms' => [$emailNorm],
]);
$participant = $summaries[0] ?? null;
}
$settings = $hasAccess ? saas_fetch_tenant_settings($pdo, $tenantId) : null;
$entryMessage = null;
$entryError = null;
function dashboard_money(int $cents): string
{
return saas_format_money_cents($cents) . ' €';
}
function dashboard_date(string $value): string
{
try {
return (new DateTimeImmutable($value))->format('d.m.Y');
} catch (Throwable $e) {
return $value;
}
}
function dashboard_current_name(?array $saasUser, ?array $participant, mixed $conn, string $mailadress): string
{
$name = trim((string)($saasUser['display_name'] ?? ''));
if ($name !== '') {
return $name;
}
$name = trim((string)($participant['display_name'] ?? ''));
if ($name !== '') {
return $name;
}
return trim((string)getUserName($conn, $mailadress));
}
function dashboard_paypal_action(string $template, string $amount): string
{
return trim($template) . $amount;
}
/**
* @return array{ok: bool, message?: string, error?: string}
*/
function dashboard_record_legacy_self_entry(PDO $pdo, array $participant, array $settings, mixed $marksValue): array
{
$legacyMitarbeiterId = $participant['legacy_mitarbeiter_id'] !== null
? (int)$participant['legacy_mitarbeiter_id']
: 0;
if ($legacyMitarbeiterId <= 0) {
return ['ok' => false, 'error' => 'Für diesen Teilnehmer ist die eigene Stricherfassung noch nicht verfügbar.'];
}
if ((int)$settings['self_entry_enabled'] !== 1) {
return ['ok' => false, 'error' => 'Die eigene Stricherfassung ist aktuell deaktiviert.'];
}
$marks = filter_var($marksValue, FILTER_VALIDATE_INT);
if ($marks !== 1 && $marks !== 2) {
return ['ok' => false, 'error' => 'Bitte einen oder zwei Striche auswählen.'];
}
$unitPriceCents = (int)$settings['mark_price_cents'];
if ($unitPriceCents <= 0) {
return ['ok' => false, 'error' => 'Der Preis pro Strich ist nicht gültig konfiguriert.'];
}
$bookedAt = date('Y-m-d H:i:s');
$cost = (($marks * $unitPriceCents) / 100);
$unitPrice = ($unitPriceCents / 100);
try {
$pdo->beginTransaction();
$stmt = $pdo->prepare(
'INSERT INTO kl_Kaffeeverbrauch
(MitarbeiterID, AnzahlStriche, Kosten, KostenproStrich, Datum, Eintragsart)
VALUES (?, ?, ?, ?, ?, 2)'
);
$stmt->execute([$legacyMitarbeiterId, $marks, $cost, $unitPrice, $bookedAt]);
$legacyConsumptionId = (int)$pdo->lastInsertId();
if ($legacyConsumptionId <= 0) {
throw new RuntimeException('Legacy-Strich konnte nicht angelegt werden.');
}
ledger_mirror_legacy_consumption($pdo, (int)$participant['tenant_id'], $legacyConsumptionId);
$pdo->commit();
} catch (Throwable $e) {
if ($pdo->inTransaction()) {
$pdo->rollBack();
}
return ['ok' => false, 'error' => 'Die Stricheintragung konnte nicht gespeichert werden.'];
}
return ['ok' => true, 'message' => 'Stricheintragung wurde erfolgreich eingetragen.'];
}
function dashboard_render_payments(array $entries): void
{
echo "<h4>Letzte Einzahlungen</h4>";
echo "<table><tr><th style='width:120px'>Datum</th><th>Einzahlung</th></tr>";
if ($entries === []) {
echo "<tr><td colspan='2'>Keine Einzahlungen vorhanden.</td></tr>";
}
foreach ($entries as $entry) {
echo "<tr>";
echo "<td>" . saas_html(dashboard_date((string)$entry['booked_at'])) . "</td>";
echo "<td>" . saas_html(dashboard_money((int)$entry['amount_cents'])) . "</td>";
echo "</tr>";
}
echo "</table>";
}
function dashboard_render_consumption(array $entries): void
{
echo "<h4>Letzte Striche</h4>";
echo "<table><tr><th style='width:120px'>Datum</th><th>Striche</th><th>Kosten</th></tr>";
if ($entries === []) {
echo "<tr><td colspan='3'>Keine Striche vorhanden.</td></tr>";
}
foreach ($entries as $entry) {
echo "<tr>";
echo "<td>" . saas_html(dashboard_date((string)$entry['booked_at'])) . "</td>";
echo "<td>" . number_format((int)($entry['marks_count'] ?? 0), 0, ',', '.') . "</td>";
echo "<td>" . saas_html(dashboard_money(abs((int)$entry['amount_cents']))) . "</td>";
echo "</tr>";
}
echo "</table>";
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
if ($hasAccess && $participant !== null && $settings !== null) {
$result = dashboard_record_legacy_self_entry($pdo, $participant, $settings, $_POST["anzahlStriche"] ?? null);
if ($result['ok']) {
$entryMessage = $result['message'] ?? null;
$participant = ledger_fetch_participant_summary($pdo, $tenantId, (int)$participant['participant_id']);
} else {
$entryError = $result['error'] ?? 'Die Stricheintragung konnte nicht gespeichert werden.';
}
} else {
$entryError = 'Die Stricheintragung konnte nicht gespeichert werden.';
}
}
$paymentEntries = $participant !== null
? ledger_fetch_recent_entries($pdo, $tenantId, [
'participant_id' => $participant['participant_id'],
'type' => 'payment',
'limit' => 100,
])
: [];
$consumptionEntries = $participant !== null
? ledger_fetch_recent_entries($pdo, $tenantId, [
'participant_id' => $participant['participant_id'],
'type' => 'consumption',
'limit' => 100,
])
: [];
include "header.php"; include "header.php";
include "headerline.php"; include "headerline.php";
include "nav.php"; include "nav.php";
?> ?>
<section id="banner">
<!-- Banner -->
<section id="banner">
<div class="content"> <div class="content">
<?php
if ($hasAccess && $participant !== null && $settings !== null) {
$balanceCents = (int)$participant['balance_cents'];
$balance = dashboard_money($balanceCents);
$currentName = dashboard_current_name($saasUser, $participant, $conn, $mailadress);
$selfEntryEnabled = (int)$settings['self_entry_enabled'] === 1
&& $participant['legacy_mitarbeiter_id'] !== null;
$paypalEnabled = (int)$settings['paypal_enabled'] === 1
&& trim((string)$settings['paypal_url_template']) !== '';
?>
<h2>Kaffeeliste</h2>
<?php if ($currentName !== ''): ?>
Hallo <?php echo saas_html($currentName); ?>!<br><br>
<?php endif; ?>
<?php if ($entryMessage !== null): ?>
<div class="hint-box success"><p><b><?php echo saas_html($entryMessage); ?></b><br>Du kannst den Eintrag weiter unten kontrollieren.</p></div><br>
<?php endif; ?>
<?php if ($entryError !== null): ?>
<div class="hint-box error"><p><b><?php echo saas_html($entryError); ?></b></p></div><br>
<?php endif; ?>
<?php <?php
if ($balanceCents > 0) {
if(checkKaffeelisteAccess($conn, $mailadress)){ echo "<p><b>Aktueller Stand: " . saas_html($balance) . " (Guthaben)</b></p>";
} elseif ($balanceCents < 0) {
echo "<h2>Kaffeeliste</h2>"; echo "<p><b>Aktueller Stand: " . saas_html($balance) . " (Schulden)</b></p>";
echo "Hallo " . getUserName($conn,$mailadress) . "!<br><br>"; } else {
// Funktion zum Berechnen der Gesamtausgabe und Gesamtstriche pro Mitarbeiter echo "<p><b>Aktueller Stand: " . saas_html($balance) . "</b></p>";
function berechneGesamtausgabe($email, $conn) {
// MitarbeiterID anhand der E-Mail-Adresse abrufen
$sqlMitarbeiterID = "SELECT MitarbeiterID FROM kl_Mitarbeiter WHERE Email = ?";
$stmtMitarbeiterID = sqlsrv_query($conn, $sqlMitarbeiterID, array($email));
$rowMitarbeiterID = sqlsrv_fetch_array($stmtMitarbeiterID, SQLSRV_FETCH_ASSOC);
if (!$rowMitarbeiterID) {
return null; // Mitarbeiter nicht gefunden
} }
?>
$mitarbeiterID = $rowMitarbeiterID["MitarbeiterID"]; <h2>Jahresübersicht</h2>
// Gesamteinzahlung pro Mitarbeiter Ausgabe im aktuellen Jahr: <?php echo saas_html(dashboard_money((int)$participant['year_costs_cents'])); ?><br>
$sqleinzahlung = "SELECT SUM(Betrag) AS Gesamteinzahlung FROM kl_Einzahlungen WHERE MitarbeiterID = ?"; Gesamtstriche im aktuellen Jahr: <?php echo number_format((int)$participant['year_marks'], 0, ',', '.'); ?><br>
$stmteinzahlung = sqlsrv_query($conn, $sqleinzahlung, array($mitarbeiterID)); <p>Gesamteinzahlung im aktuellen Jahr: <?php echo saas_html(dashboard_money((int)$participant['year_payments_cents'])); ?></p>
$roweinzahlung = sqlsrv_fetch_array($stmteinzahlung, SQLSRV_FETCH_ASSOC);
$gesamteinzahlung = $roweinzahlung['Gesamteinzahlung'];
// Gesamtausgabe für Kaffeeverbrauch pro Mitarbeiter <?php if ($selfEntryEnabled): ?>
$sqlAusgabe = "SELECT SUM(AnzahlStriche) AS Gesamtstriche, SUM(Kosten) AS Gesamtausgabe FROM kl_Kaffeeverbrauch WHERE MitarbeiterID = ?"; <h2>Eintrag in die Strichliste</h2>
$stmtAusgabe = sqlsrv_query($conn, $sqlAusgabe, array($mitarbeiterID)); <b>Hier kannst du einen oder zwei Striche für dich in der Kaffeeliste eintragen. <br>Dafür benötigst du keinen Eintrag auf der Liste durchführen.</b><br>
$rowAusgabe = sqlsrv_fetch_array($stmtAusgabe, SQLSRV_FETCH_ASSOC); Aktueller Preis pro Strich: <?php echo saas_html(dashboard_money((int)$settings['mark_price_cents'])); ?><br><br>
$gesamtausgabe = $rowAusgabe['Gesamtausgabe']; <ul class="actions">
$gesamtstriche = $rowAusgabe['Gesamtstriche']; <li>
$aktuellerStand = $gesamteinzahlung - $gesamtausgabe; <form method="post" action="index.php">
<button type="submit">Einen Strich eintragen</button>
// Gesamteinzahlung pro Mitarbeiter und Aktuellem Jahr <input type="hidden" name="anzahlStriche" value="1">
$sqleinzahlung = "SELECT SUM(Betrag) AS Gesamteinzahlung FROM kl_Einzahlungen WHERE MitarbeiterID = ? AND FORMAT(Datum, 'yyyy') = FORMAT(GETDATE(), 'yyyy') "; <?php echo app_csrf_field(); ?>
$stmteinzahlung = sqlsrv_query($conn, $sqleinzahlung, array($mitarbeiterID)); </form>
$roweinzahlung = sqlsrv_fetch_array($stmteinzahlung, SQLSRV_FETCH_ASSOC); </li>
$yeareinzahlung = $roweinzahlung['Gesamteinzahlung']; <li>
<form method="post" action="index.php">
// Gesamtausgabe für Kaffeeverbrauch pro Mitarbeiter und Aktuellem Jahr <button type="submit">Zwei Striche eintragen</button>
$sqlAusgabe = "SELECT SUM(AnzahlStriche) AS Gesamtstriche, SUM(Kosten) AS Gesamtausgabe FROM kl_Kaffeeverbrauch WHERE MitarbeiterID = ? AND FORMAT(Datum, 'yyyy') = FORMAT(GETDATE(), 'yyyy')"; <input type="hidden" name="anzahlStriche" value="2">
$stmtAusgabe = sqlsrv_query($conn, $sqlAusgabe, array($mitarbeiterID)); <?php echo app_csrf_field(); ?>
$rowAusgabe = sqlsrv_fetch_array($stmtAusgabe, SQLSRV_FETCH_ASSOC); </form>
$yearausgabe = $rowAusgabe['Gesamtausgabe']; </li>
$yearstriche = $rowAusgabe['Gesamtstriche']; </ul>
<?php endif; ?>
return array('Jahresausgabe' => $yearausgabe, 'Jahresstriche' => $yearstriche, 'Jahreseinzahlung' => $yeareinzahlung, 'Gesamtausgabe' => $gesamtausgabe, 'Gesamtstriche' => $gesamtstriche, 'Gesamteinzahlung' => $gesamteinzahlung, 'aktuellerStand' => $aktuellerStand);
#return array('Gesamtausgabe' => $gesamtausgabe, 'Gesamtstriche' => $gesamtstriche, 'Gesamteinzahlung' => $gesamteinzahlung, 'aktuellerStand' => $aktuellerStand);
<?php if ($paypalEnabled): ?>
<h2>PayPal-Einzahlungen</h2>
<b>Bezahle immer über die Freunde-Funktion von PayPal. Ansonsten stellen wir 20% des Betrags als Gebühr in Rechnung.</b><br>
<br>
<?php
$paypalTemplate = trim((string)$settings['paypal_url_template']);
if ($balanceCents < 0) {
$debtCents = abs($balanceCents);
$debtAmount = dashboard_money($debtCents);
echo '<form action="' . saas_html(dashboard_paypal_action($paypalTemplate, saas_format_money_cents($debtCents))) . '" target="_blank"><button type="submit">' . saas_html($debtAmount) . ' bezahlen</button></form>';
} }
function AusgabeletztenEinzahlungen($email, $conn) { ?>
// MitarbeiterID anhand der E-Mail-Adresse abrufen <ul class="actions">
$sqlMitarbeiterID = "SELECT TOP 20 MitarbeiterID FROM kl_Mitarbeiter WHERE Email = ?"; <li><form action="<?php echo saas_html(dashboard_paypal_action($paypalTemplate, '5')); ?>" target="_blank"><button type="submit">5,00 € einzahlen</button></form></li>
$stmtMitarbeiterID = sqlsrv_query($conn, $sqlMitarbeiterID, array($email)); <li><form action="<?php echo saas_html(dashboard_paypal_action($paypalTemplate, '10')); ?>" target="_blank"><button type="submit">10,00 € einzahlen</button></form></li>
$rowMitarbeiterID = sqlsrv_fetch_array($stmtMitarbeiterID, SQLSRV_FETCH_ASSOC); <li><form action="<?php echo saas_html(dashboard_paypal_action($paypalTemplate, '15')); ?>" target="_blank"><button type="submit">15,00 € einzahlen</button></form></li>
</ul>
<?php endif; ?>
if (!$rowMitarbeiterID) { <br><br>
return null; // Mitarbeiter nicht gefunden <?php
} dashboard_render_payments($paymentEntries);
$mitarbeiterID = $rowMitarbeiterID["MitarbeiterID"];
// Gesamteinzahlung pro Mitarbeiter
$sqleinzahlung = "SELECT Betrag,Datum FROM kl_Einzahlungen WHERE MitarbeiterID = ? ORDER BY Datum DESC ";
$stmteinzahlung = sqlsrv_query($conn, $sqleinzahlung, array($mitarbeiterID));
$ausgabe = "<h4>Letzte Einzahlungen</h4><table><tr><th style='width:120'>Datum</th><th>Einzahlung</th></tr>";
while ($row = sqlsrv_fetch_array($stmteinzahlung, SQLSRV_FETCH_ASSOC)) {
$ausgabe .= "<tr><td>" . date_format($row["Datum"],"d.m.Y") . "</td><td>" . number_format($row["Betrag"], 2, ',', '') . "€</td></tr>";
}
$ausgabe .= "</table>";
return $ausgabe;
}
function AusgabeletztenStriche($email, $conn) {
// MitarbeiterID anhand der E-Mail-Adresse abrufen
$sqlMitarbeiterID = "SELECT TOP 20 MitarbeiterID FROM kl_Mitarbeiter WHERE Email = ?";
$stmtMitarbeiterID = sqlsrv_query($conn, $sqlMitarbeiterID, array($email));
$rowMitarbeiterID = sqlsrv_fetch_array($stmtMitarbeiterID, SQLSRV_FETCH_ASSOC);
if (!$rowMitarbeiterID) {
return null; // Mitarbeiter nicht gefunden
}
$mitarbeiterID = $rowMitarbeiterID["MitarbeiterID"];
// Gesamteinzahlung pro Mitarbeiter
$sqleinzahlung = "SELECT AnzahlStriche,Kosten,Datum FROM kl_Kaffeeverbrauch WHERE MitarbeiterID = ? ORDER BY Datum DESC ";
$stmteinzahlung = sqlsrv_query($conn, $sqleinzahlung, array($mitarbeiterID));
$ausgabe = "<h4>Letzte Striche</h4><table ><tr><th style='width:120'>Datum</th><th>Striche</th><th>Kosten</th></tr>";
while ($row = sqlsrv_fetch_array($stmteinzahlung, SQLSRV_FETCH_ASSOC)) {
$ausgabe .= "<tr><td>" . date_format($row["Datum"],"d.m.Y") . "</td><td>" . $row["AnzahlStriche"] . "</td><td>" . number_format($row["Kosten"], 2, ',', '') . "€</td></tr>";
}
$ausgabe .= "</table>";
return $ausgabe;
}
// E-Mail-Adresse des Mitarbeiters (ersetze durch die tatsächliche E-Mail)
$email = $mailadress;
// Berechne Gesamtausgabe und Gesamtstriche für den Mitarbeiter
$result = berechneGesamtausgabe($email, $conn);
if ($result !== null) {
#echo "<h2>Gesamtausgabe und Gesamtstriche</h2>";
#echo "<p>E-Mail: $email</p>";
#echo "Gesamtausgabe: " . number_format($result['Gesamtausgabe'], 2, ',', '') . " €<br>";
#echo "Gesamtstriche: {$result['Gesamtstriche']}<br>";
#echo "<p>Gesamteinzahlung: " . number_format($result['Gesamteinzahlung'], 2, ',', '') . " €<br>";
$aktuellerstand = number_format($result['aktuellerStand'], 2, ',', '.');
if($result['aktuellerStand'] > 0){
echo "<p><b>Aktueller Stand: {$aktuellerstand} € (Guthaben)</p>";
}elseif($result['aktuellerStand'] < 0){
echo "<p><b>Aktueller Stand: {$aktuellerstand} € (Schulden)</p>";
}else{
echo "<p><b>Aktueller Stand: {$aktuellerstand} €</p>";
}
echo "</b>";
echo "<h2>Jahresübersicht</h2>";
echo "Ausgabe im aktuellem Jahr: " . number_format($result['Jahresausgabe'], 2, ',', '') . " €<br>";
echo "Gesamtstriche im aktuellem Jahr: {$result['Jahresstriche']}<br>";
echo "<p>Gesamteinzahlung im aktuellem Jahr: " . number_format($result['Jahreseinzahlung'], 2, ',', '') . " €<br>";
$sqlconfig = "SELECT paypaluse,paypallink,strichperweb FROM kl_config";
$stmtconfig = sqlsrv_query($conn, $sqlconfig, array($email));
$rowconfig = sqlsrv_fetch_array($stmtconfig, SQLSRV_FETCH_ASSOC);
if($rowconfig["strichperweb"] == 1){
// Kosten pro Strich auslesen
$sqlKostenproStrich = "SELECT KostenproStrich FROM kl_config ";
$stmtKostenproStrich = sqlsrv_query($conn, $sqlKostenproStrich);
$row = sqlsrv_fetch_array($stmtKostenproStrich, SQLSRV_FETCH_ASSOC);
$KostenproStrichtemp = $row["KostenproStrich"];
$KostenproStrich = number_format($KostenproStrichtemp, 2, ',', '');
echo "<h2>Eintrag in die Strichliste</h2>";
echo '<b>Hier kannst du einen oder zwei Striche für dich in der Kaffeeliste eintragen. <br>Dafür benötigst du keinen Eintrag auf der Liste durchführen.</b><br>Aktueller Preis pro Strich: '.$KostenproStrich . ' €<br><br>';
echo'<ul class="actions">
<li>';
echo '<form method="post" action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '"><button type="submit">Einen Strich eintragen</button><input type="hidden" name="anzahlStriche" value="1" >' . app_csrf_field() . '</form>';
echo '</li><li>';
echo '<form method="post" action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '"><button type="submit">Zwei Striche eintragen</button><input type="hidden" name="anzahlStriche" value="2" >' . app_csrf_field() . '</form>';
echo '</li></ul>';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Iteriere über alle Mitarbeiter
// Validierung könnte hier hinzugefügt werden
$anzahlStriche = $_POST["anzahlStriche"];
$anzahlStriche = (int)$anzahlStriche;
$kostenproStrich = floatval($KostenproStrichtemp);
$kosten = floatval($anzahlStriche * $KostenproStrichtemp);
$datum = date("Y-m-d H:i:s"); // Das aktuelle Datum verwenden
if($anzahlStriche != 0){
// SQL-Abfrage zum Einfügen der Daten
$sql = "INSERT INTO kl_Kaffeeverbrauch (MitarbeiterID, AnzahlStriche, Kosten, KostenproStrich, Datum, Eintragsart) VALUES (?, ?, ?, ?, ?, 2)";
$params = array(getUserId($conn,$email), $anzahlStriche, $kosten, $kostenproStrich, $datum);
$stmt = sqlsrv_query($conn, $sql, $params);
if ($stmt === false) {
die(print_r(sqlsrv_errors(), true));
}
echo '<div class="hint-box success"> <i class="fas fa-check-circle"></i> <p><b>Stricheintragung wurde erfolgreich eingetragen!</b><br>Du kannst den Eintrag weiter unten kontrollieren.</p> </div><br>';
}
}
}
if($rowconfig["paypaluse"] == 1){
echo "<h2>Paypal-Einzahlungen</h2>";
echo '<b>Bezahle immer über die Freunde-Funktion von Paypal. Ansonsten stellen wir 20% des Betrags als Gebühr in Rechnung.</b><br>';
$paypallink = trim($rowconfig["paypallink"]);
echo "<br>"; echo "<br>";
if($result['aktuellerStand'] < 0){ dashboard_render_consumption($consumptionEntries);
?>
echo '<form action="' . $paypallink .'' . $aktuellerstand . '" target="_blank" ><button type="submit">'. $aktuellerstand . ' € bezahlen</button></form>';
}
echo'<ul class="actions">
<li>';
echo '<form action="' . $paypallink .'5" target="_blank" ><button type="submit">5,00 € einzahlen</button></form>';
echo '</li><li>';
echo '<form action="' . $paypallink .'10" target="_blank" ><button type="submit">10,00 € einzahlen</button></form>';
echo '</li><li>';
echo '<form action="' . $paypallink .'15" target="_blank" ><button type="submit">15,00 € einzahlen</button></form>';
echo '</li></ul>';
}
echo "<br>";
echo "<br>";
echo AusgabeletztenEinzahlungen($email, $conn);
echo "<br>";
echo AusgabeletztenStriche($email, $conn);
?>
<br><br> <br><br>
<!-- Formular mit Button zum Anpassen des Namens -->
<form action="namenanpassen.php" method="get"> <form action="namenanpassen.php" method="get">
<button type="submit">Namensanpassung</button> <button type="submit">Namensanpassung</button>
</form> </form>
<?php <?php
} else { } elseif ($hasAccess) {
echo "<p>Mitarbeiter mit der E-Mail-Adresse $email wurde nicht gefunden.</p>"; echo "<h2>Kaffeeliste</h2>";
} echo "<p>Für dein Konto wurde im aktuellen Mandanten kein Teilnehmer gefunden.</p>";
} else {
echo "<h2>Sie haben keinen Zugang zu dieser Webseite</h2>";
}else{
echo "<h2>Sie haben keine Zugang zu dieser Webseite</h2>";
} }
?> ?>
</div> </div>
</section> </section>
<?php include "footer.php"; <?php include "footer.php"; ?>
?>