function checkMyOrders($acc_id, $product_id)
{
    global $con;
    $sql = 'SELECT * FROM orders WHERE order_userid=' . $acc_id . ' AND order_status = "processing"';
    $run_data = mysqli_query($con, $sql);
    $rowcount = mysqli_num_rows($run_data);
    if ($rowcount == 1) {
        // Prihlaseny user uz ma objednavku v processing stave, tj. chcem najprv najst cislo tej objednavky a potom do nej pridat novy produkt
        $order_id = getOrderId($acc_id);
        // Doplnim do orderDetails produkt
        addProductToOrderDetails($order_id, $acc_id, $product_id);
    } else {
        createNewOrder($acc_id, $product_id);
    }
}
Example #2
0
        if (empty($_POST["deadline"])) {
            $deadline_error_1 = "Tähtaeg on kohustuslik";
        } else {
            if ($_POST["deadline"] < date("Y-m-d H:i:s")) {
                $deadline_error_2 = "Kuupäev peab olema tulevikus";
            } else {
                $deadline = cleanInput($_POST["deadline"]);
            }
        }
        if (empty($_POST["output"])) {
            $output_error = "Ilmumiskoht on kohustuslik";
        } else {
            $output = cleanInput($_POST["output"]);
        }
        if ($text_type_error == "" && $subject_error == "" && $target_group_error == "" && $description_error == "" && $source_error == "" && $length_error == "" && $deadline_error_1 == "" && $deadline_error_2 == "" && $output_error == "") {
            $m = createNewOrder($text_type, $subject, $target_group, $description, $source, $length, $deadline, $output);
            if ($m != "") {
                $text_type = "";
                $subject = "";
                $target_group = "";
                $description = "";
                $source = "";
                $length = "";
                $deadline = "";
                $output = "";
            }
        }
    }
}
function cleanInput($data)
{
Example #3
0
function checkout($conn)
{
    retireOrder($conn);
    createNewOrder($conn);
    echo 'Checkout Successful';
}
function getCurrentOrder()
{
    global $tables;
    $database = connectToDatabase();
    $query = "SELECT id FROM " . $tables['orders'] . " WHERE account_id=" . $_SESSION['id'] . " AND placed_date IS NULL";
    $result = mysqlQuery($query, $database);
    $rows = mysql_num_rows($result);
    if ($rows <= 0) {
        return createNewOrder($database);
    } else {
        if ($rows == 1) {
            $result_array = mysql_fetch_array($result);
            return $result_array[0];
        } else {
            while ($result_array = mysql_fetch_array($result)) {
                $query_2 = "DELETE FROM " . $tables['orders'] . " WHERE id=" . $result_array[0];
                mysqlQuery($query_2, $database);
            }
            return createNewOrder($database);
        }
    }
}