Esempio n. 1
0
    $form_field = $label != "" ? "  <label for=\"" . $formelement . "\">" . $label . "</label>\n" : "";
    $form_field .= "  <textarea name=\"" . $formelement . "\" cols=\"" . $cols . "\" rows=\"" . $rows . "\">";
    if (isset($_REQUEST[$formelement])) {
        $form_field .= $_REQUEST[$formelement];
    } elseif (isset($db_value) && !isset($_REQUEST[$formelement])) {
        $form_field .= $db_value;
    } else {
        $form_field .= "";
    }
    $form_field .= "</textarea>\n";
    return $form_field;
}
$cust_no = $_SESSION['custom_num'];
$cust_email = $_SESSION['email'];
// echo $cust_email;  Za debugiranje - trazenje gresaka
$myCheckout = new db_stock_cart($_SESSION['custom_num']);
if (isset($_GET['action']) && $_GET['action'] == "cancel") {
    $myCheckout->cancel_order();
}
if (isset($_GET['add']) && $_GET['add'] == "Update") {
    if ($myCheckout->check_against_stock($_GET['stock'], $_GET['quantity'])) {
        $myCheckout->update_row($_GET['row_id'], $_GET['quantity']);
    }
}
if (isset($_GET['submit'])) {
    $myCheckout->update_shipment($_GET['address'], $_GET['postal_code'], $_GET['place'], $_GET['country']);
    if ($_GET['submit'] == "Order now!") {
        $address = $_GET['address'];
        $postal_code = $_GET['postal_code'];
        $place = $_GET['place'];
        $country = $_GET['country'];
Esempio n. 2
0
    $z = "INSERT INTO current(email) VALUES('{$e}')";
    $w = mysqli_query($dbc, $z);
}
include './includes/header.html';
$prod_conn = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $prod_conn);
$query_new = "SELECT * FROM stock ORDER BY art_no";
$res_new = mysql_query($query_new);
$row_new = mysql_fetch_assoc($res_new);
$cust_sql = "SELECT id,email FROM current WHERE id = 1";
$cust_result = mysql_query($cust_sql) or die(mysql_error());
$cust = mysql_fetch_object($cust_result);
$_SESSION['custom_num'] = $cust->id;
$_SESSION['email'] = $cust->email;
mysql_free_result($cust_result);
$myCart = new db_stock_cart($_SESSION['custom_num']);
if (isset($_GET['add']) || isset($_GET['product'])) {
    if ($myCart->check_against_stock($_GET['stock'], 1)) {
        $myCart->handle_cart_row($_GET['art_no'], $_GET['product'], 1, $_GET['price']);
    }
}
$num_rows = $myCart->get_number_of_records();
if (isset($_GET['action']) && $_GET['action'] == "checkout") {
    if ($num_rows > 0) {
        header("Location: " . CHECKOUT);
    } else {
        $myCart->error = "Vasa kosarica je trenutno prazna!";
    }
}
?>
<h2>Dodavanje Proizvoda u kosaricu</h2>
Esempio n. 3
0
require "stock.php";
require './includes/config1.inc.php';
require MYSQL;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    include './includes/login.inc.php';
}
include './includes/header.html';
if (isset($_SESSION['user_id'])) {
    if (isset($_GET['kraj'])) {
        if ($_GET['kraj'] == 'Zavrsite') {
            ?>

 <?php 
        }
    }
    $myConfirm = new db_stock_cart($_SESSION['custom_num']);
    if ($myConfirm->get_number_of_records() == 0) {
        header("Location: " . PROD_IDX);
    }
    // uputi korisnika nazad ako vise nema narudbi
    $myConfirm->show_ordered_rows();
    $myConfirm->set_shipment_data();
    $sql_errors = 0;
    foreach ($myConfirm->order_array as $val) {
        $update_stock = sprintf("UPDATE stock SET amount = amount - %d, last_buy = NOW() WHERE art_no = '%s'", $val['quantity'], $val['product_id']);
        if (!mysql_query($update_stock)) {
            $sql_errors++;
        }
    }
    if ($sql_errors == 0) {
        $myConfirm->close_order();