added coupon codes and final price

This commit is contained in:
Alec Höfler 2022-05-03 12:34:39 +02:00
parent 1760bf69e4
commit 74a08a4c46
No known key found for this signature in database
GPG key ID: BE83D6C1099F2835
2 changed files with 34 additions and 8 deletions

View file

@ -27,15 +27,16 @@ try {
//Primary SQL Statement
$statement = $pdo->prepare("SELECT zf_bap_orders.*,zbs.name as zbs_name
$statement = $pdo->prepare("SELECT zf_bap_orders.*,zbs.name as zbs_name,zbc.code as zbc_code, zbc.discount_percent as zbc_percent
FROM zf_bap_orders
JOIN zf_bap_schemes zbs on zf_bap_orders.scheme_id = zbs.scheme_id
WHERE code = :code AND status_id = :status_id");
JOIN zf_bap_events zbs on zf_bap_orders.event_id = zbs.event_id
LEFT JOIN zf_bap_coupons zbc on zf_bap_orders.coupon_id = zbc.coupon_id
WHERE zf_bap_orders.code = :code AND zf_bap_orders.status_id = :status_id");
//Bind parameters
$statement->bindParam("code", $_GET["code"]); // "Auth" 2
$expected_status = 2; // 2 equals "is paid"
$statement->bindParam(":status_id", $expected_status); //Only show, if ticket is paid
$statement->bindParam("status_id", $expected_status); //Only show, if ticket is paid
//Execute Statement and fetch Data
$statement->execute();
@ -63,7 +64,9 @@ foreach ($seats as $seat) {
$seat_html .= $seat["place_name"] . " (" . $seat["place_price"] . "€), "; // results in e.g. 'Reihe 1, Platz 2 (5€)'
}
// QR Code with Ticket Information
//Generate Coupon Badge
$rabatt = ($row2["coupon_id"]!=0) ? $row2["zbc_code"] . ' (-' . $row2["zbc_percent"].'%)' : "-";
//Build HTML Site, which will be converted into a PDF
$data = '<!doctype html>
<html lang="de-AT">
@ -92,6 +95,8 @@ $data = '<!doctype html>
</style>
</head>
<body class="container">
<img src="https://www.borg-kindberg.at/zauberfloete/wp-content/uploads/2022/05/cropped-MicrosoftTeams-image.png" height="150px" style="float: right;" />
<br/>
<h1>Ihre Zauberflöte - Tickets</h1>
<table>
<tr>
@ -106,6 +111,10 @@ $data = '<!doctype html>
<td class="td_desc">Bestelldatum</td>
<td>' . $row2["date"] . '</td>
</tr>
<tr>
<td class="td_desc">Rabattcode</td>
<td>' . $rabatt . '</td>
</tr>
<tr>
<td class="td_desc">Kontakt</td>
<td>' . $row2["email"] . "&nbsp;/ &nbsp;" . $row2["phone"] . '</td>
@ -122,6 +131,10 @@ $data = '<!doctype html>
<td class="td_desc">Zahlung</td>
<td>' . $zahlung . '</td>
</tr>
<tr>
<td class="td_desc">Finaler Preis</td>
<td>' . $row2["total_price"] . '</td>
</tr>
</table>
<div style="padding: 15px; "></div>
<img src="' . (new QRCode)->render('https://borg-kindberg.at/zf-print/ticket-check.php?order_id='.$row2["order_id"]."&code=".$row2["code"]) . '" alt="QR Code" style="height:200px;" />

View file

@ -20,10 +20,12 @@ echo 'Exception abgefangen: ', $ex->getMessage(), "\n<br/>";
//Primary SQL Statement
$statement = $pdo->prepare("SELECT zf_bap_orders.*,zbs.name as zbs_name
$statement = $pdo->prepare("SELECT zf_bap_orders.*,zbs.name as zbs_name,zbc.code as zbc_code, zbc.discount_percent as zbc_percent
FROM zf_bap_orders
JOIN zf_bap_schemes zbs on zf_bap_orders.scheme_id = zbs.scheme_id
WHERE code = :code AND status_id = :status_id");
JOIN zf_bap_events zbs on zf_bap_orders.event_id = zbs.event_id
LEFT JOIN zf_bap_coupons zbc on zf_bap_orders.coupon_id = zbc.coupon_id
WHERE zf_bap_orders.code = :code AND zf_bap_orders.status_id = :status_id");
//Bind parameters
$statement->bindParam("code", $_GET["code"]); // "Auth" 2
@ -51,6 +53,9 @@ foreach ($seats as $seat) {
$seat_html .= $seat["place_name"] . " (" . $seat["place_price"] . "€), "; // results in e.g. 'Reihe 1, Platz 2 (5€)'
}
//Generate Coupon Badge
$rabatt = ($row2["coupon_id"]!=0) ? $row2["zbc_code"] . ' (-' . $row2["zbc_percent"].'%)' : "-";
echo '<html>
<head>
<meta charset="UTF-8">
@ -91,6 +96,10 @@ echo '<html>
<td class="td_desc">Vorstellung</td>
<td>' . $row2["zbs_name"] . '</td>
</tr>
<tr>
<td class="td_desc">Rabattcode</td>
<td>' . $rabatt . '</td>
</tr>
<tr>
<td class="td_desc">Platz</td>
<td>' . $seat_html . '</td>
@ -99,6 +108,10 @@ echo '<html>
<td class="td_desc">Zahlung</td>
<td>' . $zahlung . '</td>
</tr>
<tr>
<td class="td_desc">Finaler Preis</td>
<td>' . $row2["total_price"] . '</td>
</tr>
</table>
</body>
</html>';