public function RightColumnContent() { switch ($this->Action) { case 'view': $this->CheckIdExist(); $Object = Db_Orders::getObjectById($this->Id); $this->TPL->assign('Object', $Object); break; case 'delete': if ($this->Id != 0) { Db_Orders::deleteByField('id', $this->Id); $this->Msg->SetMsg($this->_T('success_item_deleted')); $this->Redirect($this->PageUrl); } break; case 'save': if ($this->Id != 0) { $this->CheckIdExist(); } $Object = new Db_Orders($this->DB, $this->Id, 'id'); $Object->save(); $id = $Object->id; $this->Msg->SetMsg($this->_T('success_item_saved')); $this->Redirect($this->PageUrl . '?action=view&id=' . $id); break; default: $Objects = Db_Orders::getObjects(); $ListGrid = false; if ($Objects) { $ListGrid = new TGrid(); $ListGrid->Spacing = 0; $ListGrid->Width = '100%'; $ListGrid->SetClass('table table-bordered table-highlight-head'); $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Prenume'), $this->_T('Nume'), $this->_T('Adresa'), $this->_T('Telefon'), $this->_T('Data cumpararii')); $ListGrid->BeginBody(); foreach ($Objects as $Object) { $Grid_TR = new TGrid_TTR(); $Grid_TD = new TGrid_TTD($Object['id'] . ' ( <a href="' . $this->PageUrl . '?action=view&id=' . $Object['id'] . '">' . $this->_T('see') . '</a> )'); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['first_name']); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['last_name']); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['address']); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['mobile']); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['date_add']); $Grid_TR->Add($Grid_TD); $ListGrid->AddTR($Grid_TR); } $ListGrid->EndBody(); $ListGrid = $ListGrid->Html(); } $this->TPL->assign('ListGrid', $ListGrid); break; } $msg = $this->Msg->Html(); $this->TPL->assign('msg', $msg); $this->TPL->assign('Action', $this->Action); $result = $this->TPL->display(null, true); $this->Msg->Clear(); return $result; }
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; } }