Ejemplo n.º 1
0
function placeOrder()
{
    // TODO: Do not die, display some useful links.
    $books = $_COOKIE['books'];
    if ($_SERVER['REQUEST_METHOD'] != 'POST' || empty($books)) {
        echo "<p class='center'>There is no order to place.</p>";
        return;
    }
    $connection = connect();
    if (!updateInventory($connection, $books)) {
        return;
    }
    $order_id = insertOrder($connection, $books);
    if (empty($order_id)) {
        return;
    }
    clearCart();
    // NOTE: this has to be called prior to any output.
    $payment_method = getPaymentMethodFromCardNumber($connection, $_POST['card_number']);
    $total_price_string = $_POST['total_price_string'];
    echo "\n      <p class='center'>Your credit card\n      <em><strong>{$payment_method}</strong></em>\n      is charged <em><strong>\${$total_price_string}</strong></em>.</p>\n      <p class='center'>\n      <a href='show_order.php?order_id={$order_id}'>\n      <em><strong>Order {$order_id}</strong></em></a>\n      is placed successfully.</p>";
    echo "<h2>Order Details</h2>";
    showOrderFromOrderId($connection, $order_id);
    mysql_close($connection);
}
<?php

require_once "../service/message_service.php";
require_once "../service/db_connect.php";
if (!isset($_POST["method"]) || empty($_POST["method"])) {
    header("Content-Type: application/json");
    echo json_encode(array("result" => "fail"));
    die;
}
$method = $_POST["method"];
switch ($method) {
    case 'insert':
        insertOrder();
        break;
    default:
        header("Content-Type: application/json");
        echo json_encode(array("result" => "no_method"));
        break;
}
function insertOrder()
{
    try {
        $dbh = dbConnect::getInstance()->dbh;
    } catch (PDOException $e) {
        print "Error!: " . $e->getMessage() . "<br/>";
        die;
    }
    $sql = 'insert into shirt_order ';
    $sql .= '(email, line_screen_price_1, line_screen_price_2, shirt_id_1, ';
    $sql .= 'shirt_id_2, qty_1, qty_2, order_status, order_date, amt, ';
    $sql .= 'screen_width_1, screen_height_1, screen_width_2, screen_height_2, color_area_1, color_area_2) ';
Ejemplo n.º 3
0
 function doIt()
 {
     lib_log("CSH", "----- Start -----\n");
     // Get current time and date
     $dtz = new DateTimeZone("Europe/Stockholm");
     //Your timezone
     $now = new DateTime(date("Y-m-d H:i:s"), $dtz);
     $snow = $now->format("Y-m-d H:i:s");
     //================================
     // Configuration
     //================================
     $waterIn_sid = 3;
     // 3
     $waterOut_sid = 1;
     // 1
     $smokeTemp_sid = 4;
     // 4
     $outdoorTemp_sid = 9;
     // Garage indoor
     $indoorTemp_sid = 2;
     // 2
     // Memories
     //-------------------------------
     $labelTargetTemperature = "CSH_targetTemperature";
     $labelLatestOrderTime = "CSH_latestOrderTime";
     //========================================================
     $targetTemp = (int) lib_recall($labelTargetTemperature);
     $lowWaterOut = $targetTemp - 1.0;
     //26.0;
     $highWaterOut = $targetTemp + 1.0;
     //28.0;
     $inertiaTime = 360;
     // sec
     // Recall time and date for latest order
     $prev = lib_recall($labelLatestOrderTime);
     if ($prev == 'void') {
         $prev = $snow;
         lib_remember($labelLatestOrderTime, $snow);
     }
     $diff = strtotime($snow) - strtotime($prev);
     lib_log("CSH", "==> {$snow} [{$prev}] {$diff}({$inertiaTime})\n");
     //========================================================
     $waterIn = lib_getLatestValue($waterIn_sid);
     if ($waterIn == SXN_NO_VALUE) {
         lib_log("CSH", "No value for WaterIn\n");
         return;
     }
     $waterOut = lib_getLatestValue($waterOut_sid);
     if ($waterOut == SXN_NO_VALUE) {
         lib_log("CSH", "No value for WaterOut\n");
         return;
     }
     if ($waterOut < $targetTemp - 7.0) {
         lib_log("CSH", "Un-realistic value for WaterOut\n");
         return;
     }
     $smokeTemp = lib_getLatestValue($smokeTemp_sid);
     if ($smokeTemp == SXN_NO_VALUE) {
         lib_log("CSH", "No value for SmokeTemp\n");
         return;
     }
     $outdoorTemp = lib_getLatestValue($outdoorTemp_sid);
     if ($outdoorTemp == SXN_NO_VALUE) {
         lib_log("CSH", "No value for OutdoorTemp\n");
     }
     $indoorTemp = lib_getLatestValue($indoorTemp_sid);
     if ($outdoorTemp == SXN_NO_VALUE) {
         lib_log("CSH", "No value for IndoorTemp\n");
     }
     //========================================================
     $energy = 100 * ($waterOut - $waterIn);
     $logmsg = "Indoor      = " . $indoorTemp . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "WaterIn     = " . $waterIn . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "WaterOut    = " . $waterOut . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "TargetTemp  = " . $targetTemp . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "lowTemp     = " . $lowWaterOut . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "highTemp    = " . $highWaterOut . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "OutdoorTemp = " . $outdoorTemp . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "SmokeTemp   = " . $smokeTemp . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "Energy      = " . $energy . "\n";
     lib_log("CSH", $logmsg);
     $freqBurnerOn = lib_recall("CSH_freqBurnerOn");
     $freqBurnerOff = lib_recall("CSH_freqBurnerOff");
     $logmsg = "Freq On     = " . $freqBurnerOn . "\n";
     lib_log("CSH", $logmsg);
     $logmsg = "Freq Off    = " . $freqBurnerOff . "\n";
     lib_log("CSH", $logmsg);
     $smokeDir = lib_recall("CSH_smokeDir");
     if ($smokeDir == 'void') {
         $smokeDir = 1;
     }
     if ($smokeDir == 1) {
         lib_log("CSH", "Burner ON\n");
     }
     if ($smokeDir == 2) {
         lib_log("CSH", "Burner OFF\n");
     }
     lib_log("CSH", "Action:");
     if ($smokeTemp > 42.0 && $smokeDir == 2) {
         lib_remember("CSH_smokeDir", 1);
         $timeBurnerOn = lib_recall("CSH_timeBurnerOn");
         $freqBurnerOn = (int) (strtotime($snow) - strtotime($timeBurnerOn)) / 60.0;
         // minutes
         lib_remember("CSH_timeBurnerOn", $snow);
         $logmsg = "Burner ON " . $freqBurnerOn . "\n";
         lib_log("CSH", $logmsg);
         lib_remember("CSH_freqBurnerOn", $freqBurnerOn);
     }
     if ($smokeTemp < 42.0 && $smokeDir == 1) {
         lib_remember("CSH_smokeDir", 2);
         $timeBurnerOff = lib_recall("CSH_timeBurnerOff");
         $freqBurnerOff = (int) (strtotime($snow) - strtotime($timeBurnerOff)) / 60.0;
         // minutes
         lib_remember("CSH_timeBurnerOff", $snow);
         $logmsg = "Burner OFF " . $freqBurnerOff . "\n";
         lib_log("CSH", $logmsg);
         lib_remember("CSH_freqBurnerOff", $freqBurnerOff);
     }
     if ($diff > $inertiaTime) {
         //echo("Algo: $delta<br>");
         lib_log("CSH", "Wake Up ");
         if ($smokeTemp > 26.0) {
             if ($waterOut < $lowWaterOut) {
                 lib_log("CSH", "C_UP");
                 $steps = ($highWaterOut + $lowWaterOut) / 2.0 - $waterOut;
                 $steps = round($steps * 4);
                 if ($steps < 1 || $steps > 50) {
                     $steps = 1;
                     $logmsg = "Error: Steps out of range " . $steps . "\n";
                     lib_log("CSH", $logmsg);
                 }
                 lib_log("CSH", " + ");
                 $order = "NBC_STEPPER_CTRL 1 " . $steps . " 20";
                 lib_log("CSH", $order);
                 insertOrder($waterOut_sid, $order);
                 lib_remember($labelLatestOrderTime, $snow);
             } else {
                 if ($waterOut > $highWaterOut) {
                     lib_log("CSH", "C_DOWN");
                     $steps = $waterOut - ($highWaterOut + $lowWaterOut) / 2.0;
                     $steps = round($steps * 4);
                     if ($steps < 1 || $steps > 50) {
                         $steps = 1;
                         $logmsg = "Error: Steps out of range " . $steps . "\n";
                         lib_log("CSH", $logmsg);
                     }
                     lib_log("CSH", " - ");
                     $order = "NBC_STEPPER_CTRL 2 " . $steps . " 20";
                     lib_log("CSH", $order);
                     insertOrder($waterOut_sid, $order);
                     lib_remember($labelLatestOrderTime, $snow);
                 } else {
                     lib_log("CSH", " Temperature within target ");
                 }
             }
         } else {
             if ($smokeTemp < 25.0) {
                 lib_log("CSH", "Heater is off ");
             }
             if ($waterOut < $waterIn) {
                 lib_log("CSH", "No heating is needed ");
             }
         }
     } else {
         lib_log("CSH", "Sleeping");
     }
     lib_log("CSH", "\n");
     lib_log("CSH", "-----End-----\n");
 }
Ejemplo n.º 4
0
    header("Location: index.php");
    die;
}
?>
</div>
<div id="content">
<div id="navigation">
<h3><u>Navigation</u></h3>
<?php 
include 'navigation.php';
?>
</div>
<div id="main">
<h4><a href="index.php">Home</a> -> Order Receipt</h4>
<?php 
$orderid = insertOrder($_POST, $_SESSION['cart'], $_SESSION['username']);
if (!$orderid) {
    // Something went wrong
    echo "<h2 style='color:red'>Order submit failed!</h2><br>";
    die;
}
if (isset($_SESSION['errmsg'])) {
    echo $_SESSION['errmsg'] . "<br>";
    unset($_SESSION['errmsg']);
}
echo "<p><h2>Thank you for shopping with us!<br>Your order ID is: " . $orderid . "</h2></p>";
showCartTable($_SESSION['cart'], TRUE);
// Display read only version of shopping cart table
?>
	
	
Ejemplo n.º 5
0
 $data["txtStartTime"] = implode(" ", array($_POST['txtStartTimeD'], $_POST['txtStartTimeT']));
 $data["txtEndTime"] = implode(" ", array($_POST['txtEndTimeD'], $_POST['txtEndTimeT']));
 $data["selRf"] = $_POST['selRf'];
 $data["selOS"] = $_POST['selOS'];
 $data["selApp"] = $_POST['selApp'];
 $data["txtLayoutPt"] = $_POST['txtLayoutPt'];
 $data["txtTextPt"] = $_POST['txtTextPt'];
 $data["txtFormat"] = $_POST['txtFormat'];
 $data["txtDiv"] = $_POST['txtDiv'];
 $data["selImg"] = $_POST['selImg'];
 $data["txtImgPt"] = $_POST['txtImgPt'];
 $data["txtAdPt"] = $_POST['txtAdPt'];
 $data["txtComment"] = $_POST['txtComment'];
 $data["txtDDate"] = implode(" ", array($_POST['txtDDateD'], $_POST['txtDDateT']));
 ## get inserted order id
 $data["orid"] = insertOrder($data, $db);
 ## loop through receiptfacts
 for ($i = 0; $i < count($data['selRf']); $i++) {
     if ($data['selRf'][$i] == 0) {
         continue;
     }
     if (!insertRf($data["orid"], $data['selRf'][$i], $db)) {
         header("location: " . ROOT . "error.html");
         exit;
     }
 }
 ## loop through applications
 for ($i = 0; $i < count($data['selApp']); $i++) {
     if ($data['selApp'][$i] == 0) {
         continue;
     }
Ejemplo n.º 6
0
<!--  the menu ordering part
*
***************************************************************-->
<div class="orderingPart">
    <!--<div class="orderingDiv">
        <span class="smallTitle"> Créez les commandes ici</span>
    </div>-->
	<header>
		<h1>Création des commandes</h1>
	</header>
    <?php 
/* TODO : use the validated data (still need to check if there was an idiot playing with the url)	*/
if (isset($_GET['validate'])) {
    echo "<div class='orderingOneColumn'>";
    insertOrder($_GET, $connectionObject);
    displayMealMenu($connectionObject);
    echo "</div>";
} else {
    if (empty($_GET["id_meal"])) {
        echo "<div class='orderingOneColumn'>";
        displayMealMenu($connectionObject);
        echo "</div>";
    } else {
        if (empty($_GET["id_specific_meal"])) {
            echo "<div class='orderingOneColumn'>\n\t\t\t\t<ul class='fixMargin'>";
            displayMealTypes($_GET["id_meal"], $connectionObject);
            echo "</ul>\n\t\t\t\t</div>";
        } else {
            echo "<div class='orderingOneColumn'>";
            include 'orderLogic/orderConfirming.php';