/** Grabs orderId from placeOrder() as session
 * @return bool
 */
function orderItem()
{
    $items = getCartItems($_SESSION['customerId']);
    global $DB;
    try {
        $stmt = $DB->prepare("INSERT INTO sales_order_item (sales_order_entity_id,name,price,qty)\nVALUES (:orderId,:itemName,:itemPrice,:itemQty)");
        foreach ($items as $item) {
            $stmt->bindParam(':orderId', $_SESSION['orderId']);
            $stmt->bindParam(':itemName', $item['name']);
            $stmt->bindParam(':itemPrice', $item['price']);
            $stmt->bindParam(':itemQty', $item['qty']);
            $bool = $stmt->execute();
        }
        return $bool;
    } catch (Exception $e) {
    }
}
require_once 'product_model.php';
require_once 'sample-data/category.php';
require_once 'config.php';
require_once 'login_model.php';
require_once 'cart_model.php';
require_once 'order_preview_model.php';
orderPreview();
?>



<?php 
$categories = mainCategory($DB);
isLoged();
loginTime();
$cartItems = getCartItems($_SESSION['customerId']);
$subtotal = 0;
$total = 0;
?>

<body>
<h2>Your information</h2>
<span>Email: <?php 
echo $_SESSION['email'];
?>
</span></br>
<span>Name: <?php 
echo $_SESSION['name'];
?>
</span></br>
<span>Last name: <?php 
Example #3
0
/**
 * Функция которая возвращает массив информации
 * о просматриваемой страничка с типом $type
 * и $id
 * @param null $type
 * @param null $id
 * @return array
 */
function getContent($type = null, $id = null)
{
    /*Если параметры null, то выводим страничку по умолчанию*/
    if ($type == null) {
        $type = DEFAULT_PAGE;
    }
    if (isset($_POST['new_submit']) && $_POST['new_submit']) {
        $type = NEW_SUBMIT_TYPE;
    }
    $loginStatus = LOGIN_ALREADY;
    if (isset($_GET['unlogin']) && $_GET['unlogin']) {
        unlogin();
        $loginStatus = LOGIN_EXIT;
    }
    if ($_POST['submit']) {
        $loginStatus = login($_POST['login'], $_POST['password']);
    }
    /*Инициализируем информацию в зависимости от типа */
    $array = array();
    switch ($type) {
        /*Если тип страницы - текстовая*/
        case TEXT_TYPE:
            /*Если id не инициализирован выводим главную.
            		Иначе страницу с id*/
            if ($id == null) {
                $id = MAIN_PAGE_TEXT_ID;
            }
            /*Получаем текст из базы*/
            $page = getTextContent($id);
            $array['content'] = $page['text'];
            break;
        case CATALOG_TYPE:
            /*Если id не инициаизирован */
            if (!($id > 0)) {
                /*Выбираем первый попавшийся театр*/
                $sql = "SELECT id from theatures LIMIT 1";
                $res = mysql_query($sql);
                $row = mysql_fetch_array($res);
                $id = $row['id'];
            }
            /*Получаем спектали из базы*/
            $items = getCatalogItems($id);
            //$parent_item = get;
            /*Вставляем их в ш для красивого вывода*/
            $array['content'] = (include 'templates/content/item/items.php');
            break;
        case ITEM_TYPE:
            $item = getItem($id);
            $array['content'] = (include 'templates/content/item/item_big.php');
            break;
        case NEW_REG_TYPE:
            $array['content'] = (include 'templates/content/login/newreg.php');
            break;
        case NEW_SUBMIT_TYPE:
            //Если пароли совпадают
            if ($_POST['new_password1'] == $_POST['new_password2']) {
                if (addNewUser($_POST['new_login'], $_POST['new_password2'])) {
                    $array['content'] = 'Поздравляем вы зарегистерированы';
                } else {
                    $array['content'] = 'Такой пользователь уже есть';
                }
            } else {
                $array['content'] = 'Пароли не совпадают';
            }
            break;
        case ADD_CART_TYPE:
            addToCart($id);
            $cartItems = getCartItems();
            $sum = calculateCart();
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
        case CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
            /*Удаляем одну штуку*/
        /*Удаляем одну штуку*/
        case REMOVE_CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            removeFromCart($id);
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
            /*Удаляем весь товар*/
        /*Удаляем весь товар*/
        case REMOVE_ITEM_CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            removeFromCart($id, CART_REMOVE_ALL);
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
        case CLEAR_CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            clearCart();
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
    }
    $user = getCurrentUser();
    $array['theatures'] = getCatalogCategories();
    $items = getCatalogCategories();
    $array['leftPanel'] = (include 'templates/content/catalog/catalogCategories.php');
    $array['rightPanel'] = (include 'templates/content/login/login.php');
    $array['banner_word'] = 'Театры';
    $array['title'] = 'Сайт';
    return $array;
}