<?php require "settings.php"; require "mysql-connector.php"; require LIB_DIR . "/core/template.php"; $content = json_decode($_POST["order"]); $content->{"standalone"} = true; $headers = "Content-Type: text/html; charset=utf-8\n"; $mailContent = renderTemplateToString("purchase-order", $content); $name = $content->{"name"}; $time = $content->{"orderDate"}; $subject = "Bestellung von {$name} um {$time}"; mail(ORDER_MAIL_TO, $subject, $mailContent, $headers); mail($content->{"mail"}, "Kopie ihrer {$subject}", $mailContent, $headers); $article = getPageContents(10); $article["siteBase"] = SITE_BASE; renderTemplate("page-base", $article);
function renderTemplate($templateName, $model) { header("Content-Type: text/html; charset=UTF-8"); echo renderTemplateToString($templateName, $model); }
if (!empty($amount)) { $product = $allItems[$id]; if (!$product) { continue; } $product["amount"] = $amount; $totalPrice = $amount * $product["price"]; $toPay += $totalPrice; $product["totalPrice"] = formatPrice($totalPrice); $product["price"] = formatPrice($product["price"]); $order[] = $product; } } date_default_timezone_set("Europe/Berlin"); $_POST["orderDate"] = date("d.m.Y H:i:s"); $_POST["itemsOrdered"] = $order; $_POST["toPay"] = formatPrice($toPay); $purchaseOrder = renderTemplateToString("purchase-order", $_POST); $article = getPageContents(9); $article["siteBase"] = SITE_BASE; renderTemplate("page-base", array("title" => $article["title"], "content" => $article["content"], "siteBase" => SITE_BASE, "orderData" => json_encode($_POST), "orderDetails" => $purchaseOrder, "onConfirmOrderPage" => true)); function loadProducts() { global $mysqli; $p = array(); $res = $mysqli->query("select id, title, description, category, price from jube_items order by id"); while ($row = $res->fetch_assoc()) { $p[$row["id"]] = array("id" => $row["id"], "title" => $row["title"], "description" => $row["description"], "price" => $row["price"], "category" => $row["category"]); } return $p; }