示例#1
0
include "Brain/UserControl.php";
include "header2.php";
include_once "Brain/ShoppingCart.php";
$cart = new SCart();
if (isset($_GET["error"])) {
    echo "<script> alert('Sorry, we only delivery two day after order.')</script>";
}
if (UserControl::checkState() && UserControl::getType() == 'c') {
    $cust = getCustomer(getInfo(UserControl::getUserNo())[ID]);
    if (isset($_POST[distNo], $_POST[custAddr], $_POST["sdate"])) {
        $date = strtotime($_POST["sdate"]);
        $minday = strtotime(date("Y-m-d", strtotime("+ 2 days")));
        if ($date < $minday) {
            header("Location: checkout.php?error=true");
        } else {
            if ($cart->checkout($_POST["sdate"], "100", $_POST[custAddr], $cust[custNo], $_POST[distNo])) {
                header("Location: shoppingcart.php?sucess=true");
            } else {
                echo "<script> alert('Sorry!');</script>";
            }
        }
    }
    $district = getAllDistricts();
    $box = "<select name='distNo'>";
    while ($row = $district->fetch_assoc()) {
        if ($row[distNo] == $cust[distNo]) {
            $box .= "<option selected value='" . $row[distNo] . "'>" . $row[distName] . "</option>";
        } else {
            $box .= "<option value='" . $row[distNo] . "'>" . $row[distName] . "</option>";
        }
    }