public function selectOneAction() { $authentication = Cible_FunctionsGeneral::getAuthentication(); if ($authentication) { $profile = new MemberProfile(); $memberInfos = $profile->findMember(array('email' => $authentication['email'])); $data = array('city' => $memberInfos['cityId'], 'country' => $memberInfos['country'], 'state' => $memberInfos['state']); $this->view->assign('selectedState', $data['state']); $this->view->assign('selectedCity', $data['city']); } $form = new FormRetailersSelectOne(); $this->view->assign('form', $form); if ($this->_request->isPost()) { } else { $form->populate($data); } $list = ''; $this->view->assign('list', $list); }
/** * Controller action to manage the details of the cart. * Update/delete items or load the list. * * @return void */ public function cartdetailsAction() { $account = Cible_FunctionsGeneral::getAuthentication(); if (!$account) { $this->_redirect(Cible_FunctionsPages::getPageNameByID(1, Zend_Registry::get('languageID'))); } $productData = array(); $cart = new Cart(); if ($this->_isXmlHttpRequest) { $this->disableLayout(); $this->disableView(); $action = $this->_getParam('do'); $productId = $this->_getParam('pId'); $itemId = $this->_getParam('itemId'); $quantity = $this->_getParam('quantity'); $size = $this->_getParam('size'); $category = $this->_getParam('category'); $disable = $this->_getParam('disable'); $cartId = $this->_getParam('cartItemsId'); if ($action == 'update' && !empty($productId)) { if (!empty($size)) { $cart->updateItem($productId, -1, array('CI_TailleID' => $size, 'CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId)); } elseif (!empty($category)) { $cart->updateItem($productId, -1, array('CI_CatTailleID' => $category, 'CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId)); } else { $oItem = new ItemsObject(); $oItem->setId($itemId); $amount = $oItem->getPrice($quantity); $cart->updateItem($productId, $quantity, array('CI_ItemID' => $itemId, 'CI_Total' => $amount, 'CI_CartItemsID' => $cartId)); } echo 'updated'; } elseif ($action == 'delete' && !empty($productId)) { if ($itemId && $cartId) { $cart->updateItem($productId, 0, array('CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId)); echo 'deletedRow'; } else { $cart->updateItem($productId); echo 'deleted'; } } elseif ($action == 'disable' && !empty($productId)) { $cart->updateItem($productId, -1, array('CI_IsToSend' => $disable, 'CI_ItemID' => $itemId)); } elseif ($action == 'addSize' && !empty($productId)) { $lastId = $cart->addSize(array('CI_ID' => $productId, 'CI_Quantity' => 1, 'CI_CatTailleID' => $category, 'CI_ItemID' => $itemId)); } elseif ($action == 'getSizes' && !empty($category)) { $oSize = new TailleObject(); $langId = $this->_getParam('langId'); $size = $oSize->getDataByCategoryTailleId($category, $langId); echo json_encode($size); exit; } } else { $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo(); $exclude = preg_match('/resume-order/', $url); if (!$exclude) { Cible_View_Helper_LastVisited::saveThis($url); } $urlBack = ''; $urlNextStep = ''; $urls = Cible_View_Helper_LastVisited::getLastVisited(); if (count($urls) > 1) { $urlBack = $urls[1]; } $account = Cible_FunctionsGeneral::getAuthentication(); $profile = new MemberProfile(); $memberData = $profile->findMember(array('email' => $account['email'])); $memberData = $profile->addTaxRate($memberData); // if ($memberData['validatedEmail'] == '') // $this->view->assign('valide', true); // else // $this->view->assign('valide', false); $cartData = $cart->getAllIds(); $allIds = $cartData['cartId']; if (count($allIds)) { $urlNextStep = $this->view->baseUrl() . '/' . Cible_FunctionsPages::getPageNameByID($this->_orderPageId, Zend_Registry::get('languageID')) . '/auth-order/'; } $this->view->assign('itemCount', count($allIds)); $this->view->assign('cartTotal', $cart->getTotalItem()); $oProduct = new ProductsCollection(); // $orderPageId = Cible_FunctionsCategories::getPagePerCategoryView(0, 'order', 17); $resume = false; if ($this->_registry->pageID == $this->_orderPageId) { $resume = true; } foreach ($allIds as $key => $id) { $itemId = $cartData['itemId'][$key]; $prodId = $cartData['prodId'][$key]; $productData[$id] = $oProduct->getDetails($prodId, $itemId, $resume); $cartDetails = $cart->getItem($id, $itemId); if ($resume) { $renderItem = $cart->renderResume($cartDetails, $itemId); } else { $renderItem = $cart->renderCartLine($cartDetails, $itemId); } $productData[$id]['items']['render'] = $renderItem; $productData[$id]['cart']['disable'] = $cartDetails['Disable']; $productData[$id]['cart']['promoId'] = $cartDetails['PromoId']; } $hasBonus = $oProduct->getBonus(); $orderParams = Cible_FunctionsGeneral::getParameters(); $parameters = array('nbPoint' => 0, 'taxeProv' => $memberData['taxProv'], 'taxeCode' => $memberData['taxCode'], 'tpsFee' => $orderParams['CP_ShippingFees'], 'limitTpsFee' => $orderParams['CP_ShippingFeesLimit'], 'CODFees' => $orderParams['CP_MontantFraisCOD'], 'noProvTax' => $memberData['noProvTax'], 'noFedTax' => $memberData['noFedTax']); if ($memberData['taxCode'] == 'QC') { $parameters['taxeFed'] = $orderParams['CP_TauxTaxeFed']; } if ($hasBonus) { $parameters['nbPoint'] = $orderParams['CP_BonusPointDollar']; } $this->view->assign('productData', $productData); $this->view->assign('urlBack', $urlBack); $this->view->assign('nextStep', $urlNextStep); $this->view->assign('step', 1); $this->view->assign('hasBonus', $oProduct->getBonus()); $this->view->assign('parameters', $parameters); if ($this->_registry->pageID == $this->_orderPageId) { $this->renderScript('index/cart-summary.phtml'); } else { $this->renderScript('index/cart-details.phtml'); } } }
/** * Get data if an user is already authenticated * * @return string $authentication user's data from cookie */ public static function getAuthentication() { $authentication = null; if (isset($_COOKIE['authentication'])) { $authentication = json_decode($_COOKIE['authentication'], true); $path = Zend_Registry::get('web_root') . '/'; $memberProfile = new MemberProfile(); $foundUser = $memberProfile->findMember(array('email' => $authentication['email'], 'hash' => $authentication['hash'], 'status' => $authentication['status'])); if (!$foundUser) { $authentication = null; setcookie('authentication', '', -1, $path); } } return $authentication; }
public function detailsarticleAction() { //$this->view->jQuery()->addJavascriptFile($this->view->locateFile('jquery.prettyPhoto.js', 'jquery')); //$this->view->headLink()->appendStylesheet($this->view->locateFile('prettyPhoto.css'), 'screen'); // Article ID and Newsletter ID $newsletterArticlesSelect = new NewsletterArticles(); $id = 0; $newsletterID = 0; $url = $this->_request->getPathInfo(); $fromEmail = (bool) preg_match('/-uid-[0-9]+/', $url); $user = Zend_Registry::get('user'); $memberId = 0; $titleUrl = Cible_FunctionsGeneral::getTitleFromPath($url); if ($titleUrl != "") { $id = $newsletterArticlesSelect->getArticleIdByName($titleUrl); $newsletterID = $newsletterArticlesSelect->getNewsletterIdByName($titleUrl); } if ($fromEmail) { $pos = strpos($url, '-uid-'); $uid = explode('-', substr($url, $pos)); $memberId = end($uid); $url = substr_replace($url, '', $pos); $path = Zend_Registry::get('web_root') . '/'; setcookie('uid_newsletter', (string) $memberId, 0, $path); } else { if (isset($_COOKIE['uid_newsletter'])) { $memberId = $_COOKIE['uid_newsletter']; } } if ($memberId == 0 && $user) { $oMember = new MemberProfile(); $member = $oMember->findMember(array('email' => $user['email'])); $memberId = $member['member_id']; } $back_to_newsletter = !empty($newsletterID) ? "/ID/{$newsletterID}" : ''; $blockID = $this->_getParam('BlockID'); $blockParams = Cible_FunctionsBlocks::getBlockParameters($blockID)->toArray(); $newsletterCategoryID = $blockParams[0]['P_Value']; if (!empty($id)) { $this->_params = array('moduleId' => $this->_moduleID, 'releaseId' => $newsletterID, 'memberId' => $memberId, 'articleId' => $id); $this->logDetailsread(); $newsletterSelect = new NewsletterReleases(); $select = $newsletterSelect->select(); $select->from('Newsletter_Releases')->where('NR_LanguageID = ?', Zend_Registry::get("languageID"))->where('NR_ID = ?', $newsletterID); $newsletterData = $newsletterSelect->fetchRow($select); $titleParution = $newsletterData['NR_Title']; $titleURLParution = $newsletterData['NR_ValUrl']; //var_dump($newsletterData); if ($newsletterData['NR_Online'] == 1) { // article info $select = $newsletterArticlesSelect->select(); $select->where('NA_ID = ?', $id); //$select->where('NA_ReleaseID = ?', $newsletterID); $newsletterArticlesData = $newsletterArticlesSelect->fetchAll($select); if (count($newsletterArticlesData) < 0) { $this->_redirect(Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8)); } $this->view->articles = $newsletterArticlesData->toArray(); $blockID = $this->_getParam('BlockID'); $blockParams = Cible_FunctionsBlocks::getBlockParameters($blockID)->toArray(); $newsletterCategoryID = $blockParams[0]['P_Value']; $this->view->assign('parution_title', $titleParution); $this->view->assign('parution_date', $newsletterData['NR_Date']); $this->view->assign('subscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8)); $this->view->assign('unsubscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8)); $this->view->assign('parutionURL', $titleURLParution); $this->view->assign('back_to_release', Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8)); //$this->view->assign('back_to_release', $this->view->baseUrl()."/".Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . $back_to_newsletter); $this->view->assign('archivesLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8) . '/categoryID/' . $newsletterCategoryID); } else { $this->view->articles = array(); $this->view->assign('parutionURL', $titleURLParution); $this->view->assign('subscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8)); $this->view->assign('unsubscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8)); $this->view->assign('back_to_release', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . $back_to_newsletter); $this->view->assign('archivesLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8) . '/categoryID/' . $newsletterCategoryID); } } else { $this->view->assign('subscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8)); $this->view->assign('unsubscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8)); $this->view->assign('back_to_release', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . $back_to_newsletter); $this->view->assign('parutionURL', $titleURLParution); $this->view->assign('archivesLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8) . '/categoryID/' . $newsletterCategoryID); $this->view->articles = array(); } }
private function _buildData($orderOnly = false) { $url = Cible_FunctionsCategories::getPagePerCategoryView(0, 'list_collections', 14); $this->view->headLink()->appendStylesheet($this->view->locateFile('cart.css')); $account = Cible_FunctionsGeneral::getAuthentication(); if (!$account) { $this->_redirect($url); } $oMember = new MemberProfile(); $user = $oMember->findMember($account); $orderId = $this->_getParam('qr'); $oOrder = new OrderCollection(); if ($orderId) { $oOrder->setOrderId($orderId); } $oOrder->setUserId($user['member_id']); $oOrder->setOrderOnly($orderOnly); $select = $oOrder->getData(); return $select; }