function basket() { if ($_POST) { $basket = new Basket(); $basket->toOrder(); $this->redirect('/cabinet/basket/thanks/'); } else { if (Funcs::$uri[2] == 'delivery') { $seo['seo_title'] = 'Условия доставки'; Funcs::setMeta($seo); $basket = new Basket(); $data['order'] = $basket->getOrder(); $data['delivery'] = $basket->getDelivery($data['order']); View::render('cabinet/delivery', $data); } elseif (Funcs::$uri[2] == 'thanks') { $seo['seo_title'] = 'Благодарим вас за заказ!'; Funcs::setMeta($seo); View::render('basket/thanks'); } else { $data['seo_title'] = 'Корзина'; Funcs::setMeta($data); $basket = new Basket(); $data['order'] = $basket->getOrder(); //$data['delivery']=$basket->getDelivery($data['order']); //$data['payment']=$basket->getOrder($data['order']); View::render('cabinet/basket', $data); } } }
/** * Process the Products * * @param Basket $basket * @return array */ public function products(Basket $basket) { $products = []; foreach ($basket->products() as $product) { $products[] = ['sku' => $product->sku, 'name' => $product->name, 'price' => $product->price, 'rate' => $product->rate, 'quantity' => $product->quantity, 'freebie' => $product->freebie, 'taxable' => $product->taxable, 'delivery' => $product->delivery, 'coupons' => $product->coupons, 'tags' => $product->tags, 'discount' => $product->discount, 'category' => $product->category, 'total_value' => $this->reconciler->value($product), 'total_discount' => $this->reconciler->discount($product), 'total_delivery' => $this->reconciler->delivery($product), 'total_tax' => $this->reconciler->tax($product), 'subtotal' => $this->reconciler->subtotal($product), 'total' => $this->reconciler->total($product)]; } return $products; }
public function add() { $this->template->title = 'Cart :: Add'; $this->template->metaDescription = ''; $this->template->content = View::factory('cart')->bind('cart', $cart); $p_id = $_POST['p_id']; $this->cart = $this->session->get('Basket'); $cart = new Basket(); $item = new Item(); $item->id = $p_id; $cart->add($item); url::redirect('/cart'); }
/** * * @return float */ public function getPrice(Basket $basket) { $items = $basket->getItems(); $sumPrice = 0; /* @var $item Item */ foreach ($items as $item) { $discount = $item->getProductDiscount(); $discountPrice = $discount->getDiscountPrice($item); $discountAmount = $discount->getDiscountAmount($item); $sumPrice += $discountPrice * $discountAmount; } return $sumPrice; }
public function __construct(Service $service) { $this->db = $db; //Выборка всех категорий для меню т.к. используются на всех страницах публичной части $this->category = $service->get('category_mapper')->getAll(); $this->basket_info = Basket::getBasketInfo(); }
function buildContent() { $harmoni = Harmoni::Instance(); $basket = Basket::instance(); $basket->removeAllItems(); RequestContext::locationHeader($harmoni->request->quickURL("basket", "view")); }
public function indexAction() { $basket = Basket::getBasket(); //При удалении товара if ($_GET['del_item']) { Basket::deleteProductFromBasket($_GET['del_item']); } //Подтверждеение заказа if ($_POST['confirm_order']) { //Для получеения общей суммы заказа $basket_info = Basket::getBasketInfo(); //Создаем и заполняем доменный объект заказа $order = new Order(); $order->id = uniqid(); //ID (Primary Key) для заказов генерируем сами $order->user_id = intval($_SESSION['user_id']); $order->delivery = $_POST['delivery']; $order->pay = $_POST['pay']; $order->total_sum = $basket_info['total_sum']; $order->status = 'processing'; //Статус по-умолчанию, "В обработке" $order->date = date('Y-m-d H:i:s', time()); $order->products = $basket; //Сохраняем заказ $this->service->get('order_mapper')->save($order); //Очищаем корзину и редиректим Basket::cleanBasket(); $_SESSION['message'] = 'Спасибо за покупку. Ваш заказ принят в обработку. Данные отправлены на почту'; header('Location: /basket'); exit; } $view_data['basket'] = $basket; $view_data['title'] = 'Корзина покупателя'; $this->service->get('view')->render('basket.tpl.php', $view_data); }
/** * Build the content for this action * * @return boolean * @access public * @since 5/5/06 */ function execute() { $harmoni = Harmoni::Instance(); $basket = Basket::instance(); $basket->removeAllItems(); print $basket->getSmallBasketHtml(); exit; }
public function loadBasket($id) { $model = Basket::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'Запись не найдена.'); } if ($model->user_id !== Yii::app()->user->id) { $this->error403(); } return $model; }
public function process() { $sql = 'INSERT INTO finance_transactions (amount, description, timestamp, account) VALUES (:amount, :title, now(), :account) '; $stmt = DatabaseFactory::getInstance()->prepare($sql); foreach (Basket::getContents() as $basketItem) { $stmt->bindValue(':amount', $basketItem['cost']); $stmt->bindValue(':title', '(given cash) ' . $basketItem['title'] . ' ticket for ' . $basketItem['username']); $stmt->bindValue(':account', $this->getElementValue('username')); $stmt->execute(); Events::setSignupStatus($basketItem['userId'], $basketItem['eventId'], 'CASH_IN_POST'); } }
public function actionView($id) { self::validateAdmin(); $order = Order::getOrderById($id); $productQuantity = json_decode($order['products'], true); $productId = array_keys($productQuantity); $products = Products::getProductlistById($productId); $totalPrice = Basket::getTotalPrice($products, $productQuantity); $total = array_sum($totalPrice); require_once ROOT . '/views/admin_order/view.php'; return true; }
/** * Answer the assets to display in the slideshow * * @return object AssetIterator * @access public * @since 5/4/06 */ function getAssets() { $assets = array(); $repositoryManager = Services::getService("Repository"); $basket = Basket::instance(); $basket->clean(); $basket->reset(); while ($basket->hasNext()) { $assets[] = $repositoryManager->getAsset($basket->next()); } $iterator = new HarmoniIterator($assets); return $iterator; }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("basket"); $idManager = Services::getService("Id"); $authZ = Services::getService("AuthZ"); $basket = Basket::instance(); $assetId = $idManager->getId(RequestContext::value("asset_id")); $basket->moveUp($assetId); $harmoni->request->endNamespace(); RequestContext::locationHeader($harmoni->request->quickURL("basket", "view")); }
/** * Check Authorizations * * @return boolean * @access public * @since 9/27/05 */ function isAuthorizedToExecute() { $harmoni = Harmoni::instance(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $basket = Basket::instance(); $basket->reset(); $view = $idManager->getId("edu.middlebury.authorization.view"); $this->_exportList = array(); while ($basket->hasNext()) { $id = $basket->next(); if ($authZ->isUserAuthorized($view, $id)) { $this->_exportList[] = $id; } } if (count($this->_exportList) > 0) { return true; } else { return false; } }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK */ function update($fieldName) { $idManager = Services::getService("Id"); $ok = parent::update($fieldName); // then, check if any "buttons" or anything were pressed to add/remove elements $this->_addFromBasketButton->update($fieldName . "_addfrombasket"); if ($this->_addFromBasketButton->getAllValues()) { $basket = Basket::instance(); $basket->reset(); while ($basket->hasNext()) { $assetId = $basket->next(); $element =& $this->_addElement(); $element['_assetId'] = new AssetComponent(); $element['_assetId']->setParent($this); $element['_assetId']->setValue($assetId); } $basket->removeAllItems(); $this->rebuildPositionSelects(); } return $ok; }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("basket"); $idManager = Services::getService("Id"); $authZ = Services::getService("AuthZ"); $basket = Basket::instance(); $viewAZ = $idManager->getId("edu.middlebury.authorization.view"); $assetIdList = RequestContext::value("assets"); $assetIdArray = explode(",", trim($assetIdList)); foreach ($assetIdArray as $id) { $assetId = $idManager->getId($id); try { if ($authZ->isUserAuthorized($viewAZ, $assetId)) { $basket->addItem($assetId); } } catch (UnknownIdException $e) { $basket->addItem($assetId); } } $harmoni->request->endNamespace(); $harmoni->history->goBack("polyphony/basket"); }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function execute() { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("basket"); $idManager = Services::getService("Id"); $authZ = Services::getService("AuthZ"); $basket = Basket::instance(); $viewAZ = $idManager->getId("edu.middlebury.authorization.view"); $assetIdList = RequestContext::value("assets"); $assetIdArray = explode(",", trim($assetIdList)); foreach ($assetIdArray as $id) { $assetId = $idManager->getId($id); try { if ($authZ->isUserAuthorized($viewAZ, $assetId)) { $basket->addItem($assetId); } } catch (UnknownIdException $e) { $basket->addItem($assetId); } } $harmoni->request->endNamespace(); print $basket->getSmallBasketHtml(); exit; }
public function step4() { $tree = array('name' => $_SESSION['iuser']['upload']['title']); $id = Tree::addTree($_SESSION['iuser']['upload']['spec'], $tree, 'catalog'); if (file_exists($_SESSION['iuser']['upload']['filecover']['path']) && file_exists($_SESSION['iuser']['upload']['filepages']['path'])) { $dir = $_SERVER['DOCUMENT_ROOT'] . IUSER_DIR . md5('fotouser' . $_SESSION['iuser']['id']) . '/'; if (!file_exists($dir)) { mkdir($dir, 0777); } $dir = $dir . md5('fotobook' . $id) . '/'; mkdir($dir, 0777); for ($file2i = 0; $file2i < 2; $file2i++) { if ($file2i == 0) { $filename = explode('.', $_SESSION['iuser']['upload']['filecover']['name']); $filesource = $_SESSION['iuser']['upload']['filecover']['path']; } else { $filename = explode('.', $_SESSION['iuser']['upload']['filepages']['name']); $filesource = $_SESSION['iuser']['upload']['filepages']['path']; } $raz = $filename[count($filename) - 1]; unset($filename[count($filename) - 1]); $filename = implode('', $filename); $filenameraz = Funcs::Transliterate($filename) . '.' . $raz; $dirfile = $dir . $filenameraz; $x = 0; $i = 1; while ($x == 0) { if (file_exists($dirfile)) { $filenameraz = Funcs::Transliterate($filename) . $i . '.' . $raz; $dirfile = $dir . md5($filename) . '/' . $filenameraz; } else { $x = 1; } $i++; } copy($filesource, $dirfile); chmod($dirfile, 0777); unlink($filesource); if ($file2i == 0) { $filename1 = $filenameraz; } else { $filename2 = $filenameraz; } } } $price = Basket::getPrice('session'); $sql = ' INSERT INTO {{catalog}} SET tree=' . $id . ', description=\'' . $_SESSION['iuser']['upload']['description'] . '\', phrase=\'' . $_SESSION['iuser']['upload']['phrase'] . '\', author=\'' . $_SESSION['iuser']['upload']['author'] . '\', private=' . $_SESSION['iuser']['upload']['private'] . ', booksize=' . $_SESSION['iuser']['upload']['booksize'] . ', countpage=' . $_SESSION['iuser']['upload']['countpage'] . ', binding=' . $_SESSION['iuser']['upload']['binding'] . ', paper=' . $_SESSION['iuser']['upload']['paper'] . ', price=' . $price . ', filecover=\'' . $filename1 . '\', filepages=\'' . $filename2 . '\', vendor=' . $_SESSION['iuser']['id'] . ' '; DB::exec($sql); unset($_SESSION['iuser']['upload']); $_SESSION['iuser']['upload']['id'] = $id; $_SESSION['iuser']['upload']['price'] = $price; Upload::addGallery($id, $filename1, $filename2, $dir); Email::uploadSend(); }
<?php Login::restrictFront(); $token1 = mt_rand(); $token2 = Login::string2hash($token1); Session::setSession('token2', $token2); $objBasket = new Basket(); $out = array(); $session = Session::getSession('basket'); if (!empty($session)) { $objCatalogue = new Catalogue(); foreach ($session as $key => $value) { $out[$key] = $objCatalogue->getProduct($key); } } require_once "_header.php"; ?> <h1>Order summary</h1> <?php if (!empty($out)) { ?> <div id="big_basket"> <form action="" method="post" id="frm_basket"> <table cellpadding="0" cellspacing="0" border="0" class="tbl_repeat"> <tr>
<?php defined('SYSPATH') or die('No direct access allowed.'); ?> <?php $db = new Database(); $id = $this->uri->segment(3); $order = Order::getOrderByID($id); $_order = ORM::factory('order', $id); $user = ORM::factory('user')->where('id', $order->user_id)->find(); $shipping = ORM::factory('user_shipping_info')->where('id', $order->shippingID)->find(); $billing = ORM::factory('user_billing_info')->where('id', $order->billingID)->find(); //$user = User::getUserByID($order->user_id); $order_products = Basket::getBasketContentForOrder($id); //var_dump($order_products[0]); $order_statuses = Order::getOrderStatusByID($id); $order_id = $_order->getOrderId(); function order_status() { $status = array(1 => "Pending", 2 => "Processed", 3 => "Denied", 4 => "Shipped", 5 => "Delivered", 6 => "Canceled", 7 => "Refund"); return $status; } function status_filter($id) { switch ($id) { case 1: return "Pending"; case 2: return "Processed"; case 3:
<?php $id = Url::getParam('id'); if (!empty($id)) { $objOrder = new Order(); $order = $objOrder->getOrder($id); if (!empty($order)) { $items = $objOrder->getOrderItems($id); $objCatalogue = new Catalogue(); $objUser = new User(); $user = $objUser->getUser($order['client']); $objCountry = new Country(); $objBusiness = new Business(); $business = $objBusiness->getBusiness(); $objBasket = new Basket(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Invoice</title> <meta name="description" content="" /> <meta name="keywords" content="" /> <meta http-equiv="imagetoolbar" content="no" /> <link href="/css/invoice.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper">
?> </th> <th class="goods-page-price"><?php echo Yii::t('app', 'Цена'); ?> </th> <th class="goods-page-total" colspan="2"><?php echo Yii::t('app', 'Итоговая сумма'); ?> </th> </tr> <?php foreach ($baskets as $i => $basket) { ?> <?php Basket::addPriceToSummary($basket->product, $basket->count); ?> <tr> <td class="goods-page-image"> <a href="<?php echo $this->createUrl('/store/product/view/id/'); ?> /<?php echo $basket->product->id; ?> " class="fancybox-button" rel="photos-lib"> <?php $imgUrl = $basket->product->getMainPicture() != NULL ? MSmarty::attachment_get_file_name($basket->product->getMainPicture()->secret_name, $basket->product->getMainPicture()->raw_name, $basket->product->getMainPicture()->file_ext, '_main', 'products') : Yii::app()->theme->baseUrl . '/public/store/default-no-image.png'; ?> <?php
<b>Товаров <?php echo $order['count']; ?> .</b>Общая сумма заказа без учета стоимости доставки<br/> <a href="/basket/" class="font11">Изменить заказ в корзине</a> <span class="price"><b><?php echo number_format($order['sum'], 0, ',', ' '); ?> <span class="rub">a</span></b></span> </li> </ul> <div class="hr"></div> <h6>Ваши данные</h6> <p> <?php echo implode(', ', Basket::getMyData()); ?> <br /> <a href="/basket/information/" class="font11">Изменить данные</a> </p> </div> <div class="right-coll"> <form class="delivery_info" method="post" id="deliveryform"> <h6>Адрес</h6> <table class="default steps-table"> <tr> <td>Регион</td> <td> <div class="select" style="width: 200px;"> <div class="select-val"><?php echo $region;
<?php include 'vars.php'; $basket = new Basket(); if ($_GET['action'] == 0) { $_SESSION["basket"] = $basket->add_basket($_POST['price'], $_SESSION["basket"]); } elseif ($_GET['action'] == 1) { $basket->del_basket($_SESSION['basket']); } elseif ($_GET['action'] == 2) { $basket->pay_basket(); } header('Location: index.php'); class Basket { public function add_basket($produit, $tableau) { //Si le produit n'existe pas dans le tableau je l'ajoute if (!array_key_exists($produit, $tableau)) { $tableau[$produit] = 1; } else { $tmp = $tableau[$produit] + 1; $tableau[$produit] = $tmp; } return $tableau; } public function del_basket($tableau) { //On detruit la variable $_SESSION['basket'] unset($_SESSION['basket']); } public function pay_basket()
/** * Remove a pet from a user's basket * @return boolean true on successful insertion or false otherwise */ public static function removeFromBasket() { $post = Core\Input::post(); if (isset($post['userId']) && isset($post['petId'])) { $basket = new Basket($post['userId'], array()); $res = $basket->removePet($post['petId']); if ($res) { return json_encode($post); } } return false; }
public static function getBasket() { print View::getRenderEmpty('basket/basketinc', Basket::getOrder()); }
/** * Execute the Action * * @param object Harmoni $harmoni * @return mixed * @access public * @since 4/25/05 */ function execute() { $xLayout = new XLayout(); $yLayout = new YLayout(); $harmoni = Harmoni::instance(); $mainScreen = new Container($yLayout, BLOCK, 1); // :: Top Row :: // The top row for the logo and status bar. $headRow = new Container($xLayout, HEADER, 1); // The logo $logo = new Component("\n<a href='" . MYPATH . "/'> <img src='" . LOGO_URL . "' \n\t\t\t\t\t\t\tstyle='border: 0px;' alt='" . _("Concerto Logo'") . "/> </a>", BLANK, 1); $headRow->add($logo, null, null, LEFT, TOP); // Language Bar $harmoni->history->markReturnURL("polyphony/language/change"); $languageText = "\n<form action='" . $harmoni->request->quickURL("language", "change") . "' method='post'>"; $harmoni->request->startNamespace("polyphony"); $languageText .= "\n\t<div style='text-align: center'>\n\t<select name='" . $harmoni->request->getName("language") . "'>"; $harmoni->request->endNamespace(); $langLoc = Services::getService('Lang'); $currentCode = $langLoc->getLanguage(); $languages = $langLoc->getLanguages(); ksort($languages); foreach ($languages as $code => $language) { $languageText .= "\n\t\t<option value='" . $code . "'" . ($code == $currentCode ? " selected='selected'" : "") . ">"; $languageText .= $language . "</option>"; } $languageText .= "\n\t</select>"; $languageText .= "\n\t<input type='submit' />"; $languageText .= "\n\t</div>\n</form>"; $languageBar = new Component($languageText, BLANK, 1); $headRow->add($languageBar, null, null, LEFT, TOP); // Pretty Login Box $loginRow = new Container($yLayout, OTHER, 1); $headRow->add($loginRow, null, null, RIGHT, TOP); ob_start(); $authN = Services::getService("AuthN"); $agentM = Services::getService("Agent"); $idM = Services::getService("Id"); $authTypes = $authN->getAuthenticationTypes(); $users = ''; while ($authTypes->hasNext()) { $authType = $authTypes->next(); $id = $authN->getUserId($authType); if (!$id->isEqual($idM->getId('edu.middlebury.agents.anonymous'))) { $agent = $agentM->getAgent($id); $exists = false; foreach (explode("+", $users) as $user) { if ($agent->getDisplayName() == $user) { $exists = true; } } if (!$exists) { if ($users == '') { $users .= $agent->getDisplayName(); } else { $users .= " + " . $agent->getDisplayName(); } } } } if ($users != '') { print "\n<div style='text-align: right'><small>"; if (count(explode("+", $users)) == 1) { print _("User: "******"\t"; } else { print _("Users: ") . $users . "\t"; } print "<a href='" . $harmoni->request->quickURL("auth", "logout") . "'>" . _("Log Out") . "</a></small></div>"; } else { // set bookmarks for success and failure $harmoni->history->markReturnURL("polyphony/display_login"); $harmoni->history->markReturnURL("polyphony/login_fail", $harmoni->request->quickURL("user", "main")); $harmoni->request->startNamespace("harmoni-authentication"); $usernameField = $harmoni->request->getName("username"); $passwordField = $harmoni->request->getName("password"); $harmoni->request->endNamespace(); $harmoni->request->startNamespace("polyphony"); print "\n<div style='text-align: right'>" . "\n<form action='" . $harmoni->request->quickURL("auth", "login") . "' align='right' method='post'><small>" . "\n\t" . _("Username:"******" <input type='text' size='8' \n\t\t\t\t\tname='{$usernameField}'/>" . "\n\t" . _("Password:"******" <input type='password' size ='8' \n\t\t\t\t\tname='{$passwordField}'/>" . "\n\t <input type='submit' value='Log In' />" . "\n</small></form></div>\n"; $harmoni->request->endNamespace(); } $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, TOP); // User tools ob_start(); print "<div style='font-size: small; margin-top: 8px;'>"; print "<a href='" . $harmoni->request->quickURL("user", "main") . "'>"; print _("User Tools"); print "</a>"; print " | "; print "<a href='" . $harmoni->request->quickURL("admin", "main") . "'>"; print _("Admin Tools"); print "</a>"; print "</div>"; $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, BOTTOM); //Add the headerRow to the mainScreen $mainScreen->add($headRow, "100%", null, LEFT, TOP); // :: Center Pane :: $centerPane = $mainScreen->add(new Container($xLayout, OTHER, 1), "100%", null, LEFT, TOP); // use the result from previous actions if ($harmoni->printedResult) { $contentDestination = new Container($yLayout, OTHER, 1); $centerPane->add($contentDestination, null, null, LEFT, TOP); $contentDestination->add(new Block($harmoni->printedResult, 1), null, null, TOP, CENTER); $harmoni->printedResult = ''; } else { $contentDestination = $centerPane; } // use the result from previous actions if (is_object($harmoni->result)) { $contentDestination->add($harmoni->result, null, null, CENTER, TOP); } else { if (is_string($harmoni->result)) { $contentDestination->add(new Block($harmoni->result, STANDARD_BLOCK), null, null, CENTER, TOP); } } // Menu Column $menuColumn = $centerPane->add(new Container($yLayout, OTHER, 1), "140px", null, LEFT, TOP); // Main menu $menuGenerator = new ConcertoMenuGenerator(); $menuColumn->add($menuGenerator->generateMainMenu(), "140px", null, LEFT, TOP); // RSS Links $outputHandler = $harmoni->getOutputHandler(); if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction()) && RequestContext::value('collection_id')) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'))); $title = _("RSS feed of the most recently added Assets"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'), 'order' => 'modification')); $title = _("RSS feed of the most recently changed Assets"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } /* if (preg_match("/^collections\..+$/", $harmoni->getCurrentAction())) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('collection', 'rss_all_latest'); $title = _("RSS feed of the most recently added Assets across all Collections"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('collections', 'rss_all_latest', array('order' => 'modification')); $title = _("RSS feed of the most recently changed Assets across all Collections"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } */ if (preg_match("/^exhibitions\\.browse_exhibition\$/", $harmoni->getCurrentAction()) && RequestContext::value('exhibition_id')) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('exhibition_id' => RequestContext::value('exhibition_id'))); $title = _("RSS feed of the most recently added Slideshows in this Exhibition"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification', 'exhibition_id' => RequestContext::value('exhibition_id'))); $title = _("RSS feed of the most recently changed Slideshows in this Exhibition"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } /* if (preg_match("/^exhibitions\.browse$/", $harmoni->getCurrentAction())) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows'); $title = _("RSS feed of the most recently added Slideshows across all Exhibitions"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification')); $title = _("RSS feed of the most recently changed Slideshows across all Exhibitions"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } */ // Basket $basket = Basket::instance(); if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction())) { $menuColumn->add(AssetPrinter::getMultiEditOptionsBlock(), "100%", null, LEFT, TOP); } $menuColumn->add($basket->getSmallBasketBlock(EMPHASIZED_BLOCK), "100%", null, LEFT, TOP); // Collection Tags if (preg_match("/^(collection|asset|tags)\\./", $harmoni->getCurrentAction()) && $this->getCurrentRepository()) { $harmoni->request->passthrough("collection_id"); $harmoni->request->passthrough("asset_id"); $menuColumn->add(new Block("<strong>" . _("Tags in this Collection: ") . "</strong>" . TagAction::getTagCloudForRepository($this->getCurrentRepository(), 'concerto'), EMPHASIZED_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->forget("collection_id"); $harmoni->request->forget("asset_id"); } // :: Footer :: $footer = new Container(new XLayout(), FOOTER, 1); $helpText = "<a target='_blank' href='"; $helpText .= $harmoni->request->quickURL("help", "browse_help"); $helpText .= "'>" . _("Help") . "</a>"; $footer->add(new UnstyledBlock($helpText), "50%", null, LEFT, BOTTOM); if (!isset($_SESSION['ConcertoVersion'])) { $document = new DOMDocument(); // attempt to load (parse) the xml file if ($document->load(MYDIR . "/doc/raw/changelog/changelog.xml")) { $versionElems = $document->getElementsByTagName("version"); $latest = $versionElems->item(0); $_SESSION['ConcertoVersion'] = $latest->getAttribute('number'); if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $latest->getAttribute('date'), $matches)) { $_SESSION['ConcertoCopyrightYear'] = $matches[1]; } else { $_SESSION['ConcertoCopyrightYear'] = $latest->getAttribute('date'); } } else { $_SESSION['ConcertoVersion'] = "2.x.x"; $_SESSION['ConcertoCopyrightYear'] = "2006"; } } $footerText = "<a href='" . $harmoni->request->quickURL('window', 'changelog') . "' target='_blank'>Concerto v." . $_SESSION['ConcertoVersion'] . "</a> "; $footerText .= "©" . $_SESSION['ConcertoCopyrightYear'] . " Middlebury College <a href='http://concerto.sourceforge.net'>"; $footerText .= _("about"); $footerText .= "</a>"; $footer->add(new UnstyledBlock($footerText), "50%", null, RIGHT, BOTTOM); $mainScreen->add($footer, "100%", null, RIGHT, BOTTOM); return $mainScreen; }
if (!$basket) { $basket = new Basket(); $basket->price = 0; $basket->productCount = 0; $basket->status = Basket::STATUS_UNPAYED; $basket->date = date('Y-m-d H:i:s'); $basket->sessionId = Session::getId(); $basket->save(); } // find prodcudt $product = Product::find(Input::get('id')); // add product to pasket products $bp = new BasketProduct(); $bp->basketId = $basket->id; $bp->productId = $product->id; $bp->count = Input::get('count'); $bp->price = $product->price; $bp->save(); // $row = DB::table('basket_product')->select(DB::raw('SUM(price) as p'), DB::raw('SUM(count) as c'))->where('basketId', '=', $basket->id)->first(); // $basket->price = $row->p; $basket->productCount = $row->c; $basket->save(); // return ['cost' => $row->p, 'count' => $row->c]; }]); Route::get('basket/product-list', ['as' => 'basket.list', function () { $basket = Basket::where('sessionId', '=', Session::getId())->first(); return View::make('basket.list')->with('basket', $basket); }]);
/** * testFindAllWithConditionInChildQuery * * @return void */ public function testFindAllWithConditionInChildQuery() { $this->loadFixtures('Basket', 'FilmFile'); $TestModel = new Basket(); $recursive = 3; $result = $TestModel->find('all', compact('recursive')); $expected = array(array('Basket' => array('id' => 1, 'type' => 'nonfile', 'name' => 'basket1', 'object_id' => 1, 'user_id' => 1), 'FilmFile' => array('id' => '', 'name' => '')), array('Basket' => array('id' => 2, 'type' => 'file', 'name' => 'basket2', 'object_id' => 2, 'user_id' => 1), 'FilmFile' => array('id' => 2, 'name' => 'two'))); $this->assertEquals($expected, $result); }
public function addProduct() { if ($this->validate()) { $exist_basket = Yii::app()->db->createCommand()->select('*')->from('basket')->where('user_id = :user_id AND product_id = :product_id', array(':user_id' => Yii::app()->user->id, ':product_id' => $this->product_id))->queryRow(); if (!$exist_basket) { $this->user_id = Yii::app()->user->id; $this->date_create = time(); $this->price = $this->product->price; if ($this->save(false)) { return true; } else { return false; } } else { Basket::model()->findByPk($exist_basket['id'])->saveCounters(array('count' => $this->count)); return true; } } else { //return $this->errors; } }