<?php

require "settings.php";
require "mysql-connector.php";
require LIB_DIR . "/core/template.php";
$allItems = loadProducts();
$order = array();
$toPay = 0;
while (list($id, $amount) = each($_POST["order"])) {
    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()
Exemple #2
0
				<?php 
echo $_SESSION['user'];
?>
				<a href="BuyCar.php?barcode=null&expiration=null"><img alt="enter to go buy car" src="../imagens/buyCar.png" width="100px" height="100px"/></a>
			</h1>
			<a href="CloseSession.php">Cerrar seccion</a>
		</div>
		<div>
			<?php 
include '../modelo/ProductDAO.php';
function loadProducts()
{
    $products = ProductDAO::getProducts();
    echo "<center><h1>.:Productos:.</h1><br>";
    echo "<table border=\"3px\">";
    foreach ($products as $product) {
        if ($product->getStock() > 0) {
            echo "<tr>";
            //create row
            echo "<td>\n\t\t\t\t\t\t\t\t<img src=\"../imagens/" . $product->getImage() . "\" alt=\"product image\" width=\"600px\" height=\"400px\"\\><br>\n\t\t\t\t\t\t\t\t<a href=\"Buy.php?barcode=" . $product->getBarcode() . "&expiration=" . $product->getExpiration() . "\">mostrar informacion</a><br>\n\t\t\t\t\t\t\t\t</td>";
            echo "</tr>";
        }
    }
    echo "</table></center>";
}
loadProducts();
?>
		</div>
	</body>
</html>
Exemple #3
0
require "settings.php";
require "mysql-connector.php";
require LIB_DIR . "/core/template.php";
require "admin/moddate.php";
$requestMapping = array("home" => 1, "produkte" => 2, "bestellung" => 3, "projekte" => 4, "links" => 5, "kontakt" => 6, "impressum" => 7, "agb" => 8);
$base = isset($base) ? $base : "home";
$id = $requestMapping[$base];
$res = getPageContents($id);
$viewModel = array("siteBase" => SITE_BASE, "title" => $res["title"], "content" => $res["content"], "lastModification" => getLastModificationDate());
if ($base == "produkte") {
    $viewModel["onProductPage"] = true;
    $viewModel["items"] = loadProducts();
} else {
    if ($base == "bestellung") {
        $viewModel["onOrderPage"] = true;
        $viewModel["items"] = loadProducts();
    }
}
renderTemplate("page-base", $viewModel);
function loadProducts()
{
    global $mysqli;
    $p = array();
    $res = $mysqli->query("select id, title, description, category, price, image from jube_items order by id");
    while ($row = $res->fetch_assoc()) {
        if (!$p[$row["category"]]) {
            $p[$row["category"]] = array();
        }
        $item = array("id" => $row["id"], "title" => $row["title"], "description" => $row["description"], "price" => formatPrice($row["price"]), "category" => $row["category"]);
        if (!empty($row["image"])) {
            $item["thumb"] = PUBLIC_MEDIA_DIR . $row["image"] . "/size_thumb.jpg";