Beispiel #1
0
require_once 'customer_functions.php';
if (isLoggedIn()) {
    $order = getCurrentOrder();
    if (!$order) {
        noItemsInCart();
    } else {
        $database = connectToDatabase();
        $query = "SELECT id FROM orderline WHERE order_id=" . $order;
        $result = mysqlQuery($query, $database);
        if (mysql_num_rows($result) < 1) {
            noItemsInCart();
        }
        while ($result_array = mysql_fetch_array($result)) {
            $orderlines++;
            displayOrderline($result_array[0], $orderlines);
            if (!isOrderlineFull($result_array[0])) {
                $incomplete++;
                renderError("This item is not full!");
            }
        }
        if (!$orderlines) {
            noItemsInCart();
        }
        if (!$incomplete) {
            orderComplete(0, $order, 1);
        } else {
            renderError("Please complete all incomplete items before checking out.");
        }
        echo "<br/><br/>";
    }
}
function getCurrentOrderline($order_id_in)
{
    if ($_GET['orderline_id']) {
        return $_GET['orderline_id'];
    }
    global $tables;
    $database = connectToDatabase();
    $query = "SELECT id FROM " . $tables['orderlines'] . " WHERE order_id=" . $order_id_in;
    $result = mysqlQuery($query, $database);
    $rows = mysql_num_rows($result);
    if ($rows <= 0) {
        return createNewOrderline($order_id_in);
    }
    for ($row = 0; $row < $rows; $row++) {
        $result_array = mysql_fetch_array($result);
        $orderline_id = $result_array[0];
        if (!isOrderlineFull($orderline_id)) {
            return $orderline_id;
        }
    }
    orderComplete($orderline_id, $order_id, 0, 1);
    return -1;
}