<?php $response = ''; if (isset($_GET['f'])) { include_once 'databaseHelper.php'; switch ($_GET['f']) { case 'getProduct': if ((int) $_GET['p'] > 0) { include_once '../models/product.php'; $product = new Product((int) $_GET['p']); $response['label'] = $product->getLabel(); $response['price'] = $product->getPrice(); } break; } } echo json_encode($response) . "\n";
<?php include_once '/models/product.php'; $productModel = new Product(); $productIdGridArray = $productModel->returnProductGridAsArray(); $productGrid = ''; if ($productIdGridArray) { foreach ($productIdGridArray as $productRow) { $productGrid .= '<tr>'; if (count($productRow) > 0) { foreach ($productRow as $productId) { if ($productId > 0) { $product = new Product($productId); $productGrid .= '<td onclick="addProductToRegister(\'' . $product->getId() . '\')"><a class="product">' . $product->getLabel() . '</a></td>'; } else { $productGrid .= '<td></td>'; } } } $productGrid .= '</tr>'; } } include_once '/views/register.php';
include_once '/models/product.php'; include_once '/models/receipt.php'; $checkoutProductsTable = ''; $checkoutTotalPrice = 0; $receiptId = 0; if (isset($_POST) && count($_POST['products']) > 0) { $Receipt = new Receipt(); $checkoutProductsTable .= '<table>'; foreach ($_POST['products'] as $productId => $productAmount) { $product = new Product($productId); $productPriceExVat = number_format($product->getPrice() * 0.06, 2); $productTotalPrice = number_format($product->getPrice() * $productAmount, 2); $productTotalPriceExVat = number_format($productTotalPrice * 0.06, 2); $checkoutTotalPrice = number_format($checkoutTotalPrice + $productTotalPrice, 2); $Receipt->addProduct($productId, $product->getLabel(), $product->getPrice(), $productPriceExVat, $productAmount, $productTotalPrice, $productTotalPriceExVat); $checkoutProductsTable .= '<tr>'; $checkoutProductsTable .= '<td>' . $product->getLabel() . '</td>'; $checkoutProductsTable .= '<td>' . $product->getPrice() . '</td>'; $checkoutProductsTable .= '<td>' . $productAmount . '</td>'; $checkoutProductsTable .= '<td>' . $productTotalPrice . '</td>'; $checkoutProductsTable .= '</tr>'; } $checkoutProductsTable .= '<tr><td colspan="4"> </td></tr>'; $checkoutProductsTable .= '<tr> <td>Totaal</td> <td colspan="2"> </td> <td>' . $checkoutTotalPrice . '</td> </tr>'; $checkoutProductsTable .= '<tr><td colspan="4"> </td></tr>'; $checkoutProductsTable .= '<tr><td> </td><td>BTW</td><td colspan="2"> </td></tr>';