public function __construct($title = '') { parent::__construct($title); switch ($this->Url) { case 'addToCart': $id = getPost('id'); $_SESSION['cart'][$id] = Db_Product::getWithTrans($id); $_SESSION['cart'][$id]['qty'] = 1; $this->TPL->display('/parts/widgets/header/shopping-cart'); die; break; case 'removeFromCart': $id = getPost('id'); unset($_SESSION['cart'][$id]); $this->TPL->display('/parts/widgets/header/shopping-cart'); die; break; case 'setProductQty': $id = getPost('id'); $qty = getPost('qty'); $_SESSION['cart'][$id]['qty'] = $qty; die; break; case 'checkTransExists': $key = getPost('key'); $id = getPost('id'); if (Db_Trans::checkKey($key, $id)) { echo '1'; } else { echo '0'; } die; break; case 'filter': $types = isset($_POST['types']) ? getPost('types') : array(); $colors = isset($_POST['colors']) ? getPost('colors') : array(); $brands = isset($_POST['brands']) ? getPost('brands') : array(); $price = getPost('price'); $products = Db_Product::filter($types, $colors, $brands, $price); if (empty($products)) { die; } $this->TPL->assign('products', $products); $this->TPL->display('/parts/section/category/category-v1-grid'); die; break; case 'saveOrder': if (!isset($_SESSION['cart']) || empty($_SESSION['cart'])) { die; } $first_name = getPost('first_name'); $last_name = getPost('last_name'); $address = getPost('address'); $city = getPost('city'); $email = getPost('email'); $mobile = getPost('mobile'); $Order = new Db_Orders(); $Order->first_name = $first_name; $Order->last_name = $last_name; $Order->address = $address; $Order->city = $city; $Order->email = $email; $Order->mobile = $mobile; $Order->date_add = date('Y-m-d H:i:s'); $Order->status = 'new'; $Order->save(); foreach ($_SESSION['cart'] as $product) { $Product = new Db_OrderProducts(); $Product->op_order_id = $Order->id; $Product->op_product_id = $product['id']; $Product->op_coupon = '10%'; $Product->op_qty = $product['qty']; $Product->save(); } $this->_S->Set('buy', true); unset($_SESSION['cart']); die; break; } }
private function CheckIdExist() { if (!Db_Trans::checkExists($this->Id, 'id')) { $this->Msg->SetMsg($this->_T('error_id_not_exist') . ' ' . $this->Id); $this->Msg->SetError(true); $this->Redirect($this->PageUrl); } }
public function __construct($title) { if ($title != '') { $this->setTitle($title); } $this->CurrentUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $accepted_langs = array('ro', 'ru'); // If the lang was sent as parameter if (isset($GLOBALS['lang']) && $GLOBALS['lang'] != '') { // If the lang is accepted if (!in_array(strtolower($GLOBALS['lang']), $accepted_langs)) { $this->Redirect(FOLDER . '/'); } } $Languages = Db_Language::getAllObjects(); $this->FOLDER = FOLDER; $this->Msg = new Message(); $this->Action = isset($GLOBALS['action']) ? $GLOBALS['action'] : ''; $this->Id = isset($GLOBALS['id']) ? (int) $GLOBALS['id'] : 0; $this->sId = isset($GLOBALS['sid']) ? (int) $GLOBALS['sid'] : 0; $this->CategId = isset($GLOBALS['cat']) ? (int) $GLOBALS['cat'] : 0; $this->Search = isset($GLOBALS['search']) ? (int) $GLOBALS['search'] : 0; $this->Back = isset($GLOBALS['back']) ? (int) $GLOBALS['back'] : 0; $this->CurrentPage = isset($GLOBALS['cpage']) ? (int) $GLOBALS['cpage'] : ''; $this->Page = isset($GLOBALS['page']) ? $GLOBALS['page'] : ''; $this->Url = isset($GLOBALS['url']) ? $GLOBALS['url'] : ''; $this->SPage = isset($GLOBALS['spage']) ? $GLOBALS['spage'] : ''; $this->PageUrl = ADMIN_FOLDER . '/' . $this->Page . '/' . $this->SPage . '/'; $this->OauthToken = isset($_GET['oauth_token']) ? $_GET['oauth_token'] : ''; $this->OauthVerifier = isset($_GET['oauth_verifier']) ? $_GET['oauth_verifier'] : ''; $this->DB = new Db_MySQL(); $this->DB->connect(DB_HOST, DB_USER, DB_PASS); $this->DB->selectDb(DB_NAME); $this->_S =& $GLOBALS['_S']; $this->LOG =& $GLOBALS['LOG']; $this->MENUS =& $GLOBALS['MENUS']; $this->SUBMENUS =& $GLOBALS['SUBMENUS']; $this->MenuActive = $this->Page . '/' . $this->SPage; $this->SetLang(); $LangLocalUrl = strtolower($this->Lang) == 'ro' ? '/' . strtolower($this->Lang) : '/' . strtolower($this->Lang); $this->TPL =& $GLOBALS['TPL']; $this->TPL->assign('CurrentUrl', $this->CurrentUrl); $this->TPL->assign('FOLDER', $this->FOLDER); $this->TPL->assign('LangLocalUrl', $LangLocalUrl); $this->TPL->assign('MenuActive', $this->MenuActive); $this->TPL->assign('PageUrl', $this->PageUrl); $this->TPL->assign('sId', $this->sId); $this->TPL->assign('MENUS', $this->MENUS); $this->TPL->assign('SUBMENUS', $this->SUBMENUS); $this->TPL->assign('Page', $this->Page); $this->TPL->assign('SPage', $this->SPage); $this->TPL->assign('Lang', $this->Lang); $this->TPL->assign('LangId', $this->LangId); $this->TPL->assign('Languages', $Languages); $this->TPL->assign('Not', $this->Not); $this->TPL->tplsDefaultPath = str_replace("_", "/", get_called_class()); $this->SetCSS(); $this->SetJS(); $request_uri = $_SERVER['REQUEST_URI']; $url = explode('/', $request_uri); if (in_array($url[1], array('ro', 'ru', 'en'))) { $request_uri = substr($request_uri, 3); } $this->TPL->assign('request_uri', $request_uri); global $TRANS; $TRANS = Db_Trans::getTrans(); }