public function renderView() { if (!isset($_SESSION['cart'])) { $cart = new Cart(); $_SESSION['cart'] = serialize($cart); } foreach ($this->model->getUris() as $key => $value) { if (preg_match("#^{$value}\$#", $this->uriView)) { if ($this->model->getView($key) === "PageView") { $pagecontroller = new PageController($this->additionalParam); $pagecontroller->renderView(); } else { if ($this->model->getView($key) === "ProductView") { $productscontroller = new ProductsController(); $productscontroller->renderView(); } else { if ($this->model->getView($key) === "SingleProductView") { $singleproductcontroller = new SingleProductController($this->additionalParam); $singleproductcontroller->renderView(); } else { if ($this->model->getView($key) === "LoginView") { $logincontroller = new LoginController($this->additionalParam); $logincontroller->renderView(); } else { if ($this->model->getView($key) === "CustomerView") { $customercontroller = new CustomerController(); $customercontroller->renderView(); } else { if ($this->model->getView($key) === "CartView") { $cartcontroller = new CartController($this->additionalParam); $cartcontroller->renderView(); } else { if ($this->model->getView($key) === "ContactView") { $contactcontroller = new ContactController($this->additionalParam); $contactcontroller->renderView(); } else { if ($this->model->getView($key) === "RegisterView") { $registrationcontroller = new RegistrationController($this->additionalParam); $registrationcontroller->renderView(); } else { if ($this->model->getView($key) === "CheckoutView") { $checkoutcontroller = new CheckoutController($this->additionalParam); $checkoutcontroller->renderView(); } else { $useView = $this->model->getView($key); $view = new $useView(); $view->render(); } } } } } } } } } } } }
public function getPageContent() { $username = ""; if (isset($_SESSION[Session::USER])) { $user = unserialize($_SESSION[Session::USER]); $username = $user->getFirstname() . " " . $user->getLastname(); } $hidden = $username === "" ? CSS::HIDDEN : ""; $template = $this->getTemplateEngine()->readTemplate($this->getTemplate()); $template = $this->getTemplateEngine()->replaceTag("number", CartController::size(), $template); $template = $this->getTemplateEngine()->replaceTag("hidden", $hidden, $template); $template = $this->getTemplateEngine()->replaceTag("username", $username, $template); return $template; }
/** * Overwrite the abstract function from Superclass. * If we are on a system which can send e-mails, send * a e-mail to the user's address. */ public function handleRequestInMain() { $cart = new CartModel(); if ($cart->size() <= 0) { $this->redirect("cart.php"); } if ($this->sendMail()) { $this->getView()->setMsgClass(CSS::MSG_SUCCESS); $this->getView()->setMsgKey("success"); CartController::clean(); } else { $this->getView()->setMsgClass(CSS::MSG_ERROR); $this->getView()->setMsgKey("failure"); } }
public function getPageContent() { $template = $this->getTemplateEngine()->readTemplate($this->getTemplate()); $products = $this->getModel()->getProducts(); if (count($products) === 1) { $product = $products[0]; $template = $this->getTemplateEngine()->replaceTag("id", $product->getId(), $template); $template = $this->getTemplateEngine()->replaceTag("classification", $product->getClassification(), $template); $template = $this->getTemplateEngine()->replaceTag("type", $product->getType(), $template); $template = $this->getTemplateEngine()->replaceTag("imgname", $product->getImgname(), $template); $template = $this->getTemplateEngine()->replaceTag("name", $product->getName(), $template); $template = $this->getTemplateEngine()->replaceTag("price", StringUtils::formatAmount($product->getPrice()), $template); $template = $this->getTemplateEngine()->replaceTag("description", nl2br($product->getDescription()), $template); $template = $this->getTemplateEngine()->replaceTag("options", $this->renderOptions($product), $template); $again = ""; if (CartController::hasProduct($product)) { $again = CSS::CART_ADD_AGAIN; } $template = $this->getTemplateEngine()->replaceTag("again", $again, $template); } return $template; }
<?php require_once 'Autoloader.php'; // create a new controller for the shop's cart $controller = new CartController(); // let the controller handle the request $controller->handleRequest(); // render the page and print it echo $controller->displayPage();
if (isset($_POST["lang"])) { echo OutlineController::handleLanguageChange($_POST["lang"]); } else { if (isset($_POST["logout"])) { echo FooterController::logout(); } else { if (isset($_POST["productId"]) && isset($_POST["command"])) { $id = intval($_POST["productId"]); $cmd = $_POST["command"]; $data = isset($_POST["data"]) ? $_POST["data"] : null; switch ($cmd) { case CartModel::CMD_ADD: CartController::addById($id, $data); break; case CartModel::CMD_REMOVE: CartController::removeById($id); break; default: Logger::error("unknown command '" . $cmd . "' for cart received!"); } } else { if (isset($_POST["emailExists"])) { echo RegisterController::checkEmail($_POST["emailExists"]); } else { if (isset($_POST["deleteProduct"])) { DeleteController::delete(intval($_POST["deleteProduct"])); } } } } }
?> &do=logout">Đăng xuất</a> <?php } else { echo "<td><a class='lnk' href='" . $contextPath . $strUrl . "?do=logout'>Đăng xuất</a></td>"; } } ?> <span style="color:#FFFFFF;font-weight:bold">|</span> <a class="lnk" href="<?php echo $contextPath; ?> view/user/cart.php">Giỏ hàng(<?php include_once $contextPath . "controller/CartController.php"; $check = CartController::CountProductID_Of_CartByUserID($_SESSION["curUser"][0]); if ($check != null) { echo $check; } else { echo "0"; } ?> ) </a> </div> </div> <div id="menu" class="menu"> <ul id="nav"> <li id="selected"><a href="<?php echo $contextPath; ?>
echo "<br>********amount cart of userid productid=" . $check[3]; //$rs=CartController::UpdateCart($_SESSION["curUser"][0],$_SESSION["cart"][$i],($check[3]+$_POST[$str])); $rs = CartController::UpdateCart($_SESSION["curUser"][0], $_SESSION["cart"][$i], $_POST[$str]); } else { $rs = CartController::AddCart($_SESSION["curUser"][0], $_SESSION["cart"][$i], $_POST[$str]); } if ($rs == null) { $flag = "false"; echo "<br>flag=" . $flag; } } } } else { $deleteAllCart = CartController::GetCartByUserID($_SESSION["curUser"][0]); for ($i = 0; $i < count($deleteAllCart); $i++) { $rs = CartController::Delete($deleteAllCart[$i][0]); if ($rs == null) { $flag = "false"; } } } if ($flag == "false") { Utils::redirect("../view/user/cart.php?addcart=failed"); } else { Utils::redirect("../view/user/cart.php?addcart=successful"); } } if (isset($fLogin) && $fLogin == false) { echo "<script language='javascript' type='text/javascript'>"; echo "document.getElementById('messRegister').innerHTML='Bạn đã nhập sai tên hoặc mật khẩu';"; echo "document.getElementById('messRegister').style.color='blue';";
$productImage = ProductImageController::GetImageOfProductFromProductID($_SESSION["cart"][$i]); $totalmoney += $product_detail[4]; if ($i % 2 == 0) { echo "<tr style='background-color: rgb(239, 239, 239);'>"; } else { echo "<tr style='background-color: rgb(255, 255, 255);'>"; } //Image echo "<td style='border-right:solid 1px #D3D3D3; padding:4px;' width='35px' align='center'><a href='' ><img src='" . $contextPath . $productImage[1] . "'width='80px'/></a></td>"; //productID echo "<td align='center' style='border-right:solid 1px #D3D3D3; padding:4px;' width='20px'>\r\n\t\t\t\t\t\t\t <a href='product-detail.php?productid=" . $product_detail[0] . "&type=" . $product_detail[2] . "'><b style='color:blue;'>" . $product_detail[0] . "</b></a></td>"; //product Name echo "<td style='border-right:solid 1px #D3D3D3; padding:4px;'>" . $product_detail[1] . "</td>"; //Quantity if (isset($_SESSION["curUser"]) && $_SESSION["curUser"][0] > 0) { $quantityofUser = CartController::GetCartByUserIDAndProductId($_SESSION["curUser"][0], $product_detail[0]); if ($quantityofUser[3] > 0) { echo "<td align='center' style='border-right:solid 1px #D3D3D3; padding:4px;' width='10px'>\r\n\t\t\t\t\t\t\t\t<input type='text' onkeypress='return keypress(event);' name='txtQuantity" . $i . "' id='txtQuantity" . $i . "' size='5' value='" . $quantityofUser[3] . "' /></td>"; } else { echo "<td align='center' style='border-right:solid 1px #D3D3D3; padding:4px;' width='10px'>\r\n\t\t\t\t\t\t\t\t<input type='text' onkeypress='return keypress(event);' name='txtQuantity" . $i . "' id='txtQuantity" . $i . "' size='5' value='1' /></td>"; } } else { echo "<td align='center' style='border-right:solid 1px #D3D3D3; padding:4px;' width='10px'>\r\n\t\t\t\t\t\t\t<input type='text' onkeypress='return keypress(event);' name='txtQuantity" . $i . "' id='txtQuantity" . $i . "' size='5' value='1' /></td>"; } //money echo "<td style='border-right:solid 1px #D3D3D3;padding:4px;'>" . Utils::convert_Money($product_detail[4]) . "(VND)</td>"; echo "<td style='border-right:solid 1px #D3D3D3; padding:4px;'>" . Utils::convert_Money($product_detail[4]) . "(VND)</td>"; echo "<td style='border-right:solid 1px #D3D3D3; padding:4px;' width='10px' align='center'>"; $btn = "btnDelete" . $i; //echo "<bt>btn=".$btn; echo "<input type='image' src='" . $contextPath . "template/images/delete.png'' name='" . $btn . "' id='" . $btn . "' width='15px' height='15px' value='" . $product_detail[0] . "' onclick='DeleteCart(" . $product_detail[0] . ");'/>";
BaseController::check_if_admin(); } $routes->get('/', function () { DefaultController::index(); }); $routes->get('/info', function () { DefaultController::info(); }); $routes->post('/ostoskori/:id/lisaa', function ($id) { CartController::add($id); }); $routes->post('/ostoskori/:id/poista', function ($id) { CartController::delete($id); }); $routes->post('/ostoskori/tyhjenna', function () { CartController::deleteAll(); }); $routes->get('/kassa', function () { OrdersController::add_form(); }); $routes->post('/kassa', function () { OrdersController::add(); }); $routes->get('/tilaukset/:id/muokkaa', 'check_logged_in', function ($id) { OrdersController::edit_form($id); }); $routes->post('/tilaukset/:id/muokkaa', 'check_logged_in', 'check_if_admin', function ($id) { OrdersController::edit($id); }); $routes->get('/tilaushistoria', 'check_logged_in', function () { OrdersController::get_orders();