Esempio n. 1
0
 public function getXMLFile($path = "", $lang = "")
 {
     $moduleID = 14;
     $db = Zend_Registry::get('db');
     $xmlString = "";
     $arrayForXML = array();
     $productCollection = new ProductsCollection(array('lang' => $lang));
     $select2 = $db->select()->distinct()->from('Blocks')->join('BlocksIndex', 'BlocksIndex.BI_BlockID = Blocks.B_ID')->join('ModuleCategoryViewPage', 'ModuleCategoryViewPage.MCVP_PageID = Blocks.B_PageID')->join('ModuleViews', 'ModuleViews.MV_ID = ModuleCategoryViewPage.MCVP_ViewID')->join('PagesIndex', 'PagesIndex.PI_PageID = ModuleCategoryViewPage.MCVP_PageID')->where('Blocks.B_ModuleID = ?', $moduleID)->where('PagesIndex.PI_LanguageID = ?', $lang)->where('ModuleCategoryViewPage.MCVP_ModuleID = ?', $moduleID)->where('Blocks.B_Online = 1')->where('BlocksIndex.BI_LanguageID =?', $lang)->order('Blocks.B_Position ASC');
     $Rows = $db->fetchAll($select2);
     foreach ($Rows as $row) {
         $details_page = $row['PI_PageIndex'];
         $list_page = Cible_FunctionsCategories::getPagePerCategoryView($row['MCVP_CategoryID'], 'list', $moduleID, $lang);
         if (in_array($row['MV_Name'], $this->_specificAction)) {
             $productArray = $productCollection->getProductsUrl();
             foreach ($productArray as $product) {
                 $arrayURL = array();
                 array_push($arrayURL, $path . "/" . $details_page . "/" . $product);
                 array_push($arrayURL, "0.5");
                 array_push($arrayURL, "weekly");
                 array_push($arrayURL, date("Y-m-d H:m:s"));
                 array_push($arrayForXML, $arrayURL);
             }
         }
     }
     return $arrayForXML;
 }
Esempio n. 2
0
 public function index()
 {
     if (isset($_SESSION['user_id']) || isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) {
         $sid = $_SESSION['user_id'];
         $products_collection = new ProductsCollection();
         $product = $products_collection->get($_GET['id']);
         $orders_collection = new OrdersCollection($_SESSION['user_id']);
         $orders = $orders_collection->get_all();
         $orders_is_accepted = 0;
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $orders = new OrderEntity();
             $orders->setName($_POST['name']);
             $orders->setEmail($_POST['email']);
             $orders->setPhone($_POST['phone']);
             $orders->setProductId($_GET['id']);
             $orders->setDate($_POST['date']);
             $orders->setIsComplete(0);
             $orders->setUserId($_POST['name']);
             $orders_collection = new OrdersCollection($_SESSION['user_id']);
             $orders_collection->save($orders);
         } else {
             $orders_is_accepted = 1;
         }
         $this->loadView('website/orders', array('orders' => $orders, 'sid' => $sid, 'product' => $product, 'orders_is_accepted' => $orders_is_accepted));
     } else {
         header('Location: index.php?frontcontroller=login');
     }
 }
Esempio n. 3
0
 public function index()
 {
     $pic = new ProductImageCollection($_GET['id']);
     $gallery = $pic->get_latest(3);
     $products_collection = new ProductsCollection();
     $product = $products_collection->get($_GET['id']);
     $this->loadView('website/product', array('product' => $product, 'gallery' => $gallery));
 }
Esempio n. 4
0
 public function index()
 {
     $products_collection = new ProductsCollection();
     $products = $products_collection->get_latest(4);
     $news_collection = new NewsCollection();
     $news = $news_collection->get_latest(3);
     $this->loadView('website/index', array('products' => $products, 'news' => $news));
 }
Esempio n. 5
0
 public function index()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         header('Location: index.php?frontcontroller=catalog&frontaction=index&search=' . $_POST['search'] . '&order=' . $_POST['order'] . '&p=1');
     }
     $products_collection = new ProductsCollection();
     $per_page = 3;
     $page = isset($_GET['p']) ? $_GET['p'] : 1;
     $search = isset($_GET['search']) ? $_GET['search'] : '';
     $order_by = isset($_GET['order']) ? $_GET['order'] : '';
     if ($search != '') {
         $products = $products_collection->get_filtered($search, $order_by, $per_page, ($page - 1) * $per_page);
     } else {
         $products = $products_collection->get_all($per_page, ($page - 1) * $per_page);
     }
     $total_count = $products_collection->getTotalCount();
     $page_count = ceil($total_count / $per_page);
     $this->loadView('website/catalog', array('products' => $products, 'total_count' => $total_count, 'page_count' => $page_count, 'order_by' => $order_by, 'search' => $search, 'page' => $page));
 }
Esempio n. 6
0
 /**
  * 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');
         }
     }
 }
Esempio n. 7
0
 public function listnewAction()
 {
     $this->view->params['actions'] = $this->_request->getPathInfo();
     $oProducts = new ProductsCollection($this->view->params);
     $blockParams = $oProducts->getBlockParams();
     $this->view->assign('productsList', $oProducts->getListOfAllNewProducts());
     //$this->view->assign('productsList', $oProducts->getList());
     $this->view->assign('params', $oProducts->getBlockParams());
 }
Esempio n. 8
0
 public function delete()
 {
     $products_collection = new ProductsCollection();
     $products_collection->delete($_GET['id']);
     header('Location: index.php?controller=products');
 }
Esempio n. 9
0
 /**
  * Build the breadcrumd for the catalog page.
  *
  * @param int $lang  <Optional> Id of the current language
  * 
  * @return string 
  */
 public function breadcrumbCatalog($level = 1, $showHome = true, $langId = null)
 {
     if ($langId == null) {
         $langId = Zend_Registry::get('languageID');
     }
     $_baseUrl = Zend_Registry::get('baseUrl');
     $_breadcrumb = array();
     $_first = true;
     $pathInfo = $this->view->request->getPathInfo();
     $oProducts = new ProductsCollection();
     $oProducts->setActions($pathInfo);
     $oProducts->getDataByName();
     $catId = $oProducts->getCatId();
     $subCatId = $oProducts->getSubCatId();
     $prodId = $oProducts->getProdId();
     if ($catId == null && $subCatId == null && $prodId == null) {
         $_breadcrumb = $this->view->breadcrumb(true) . "<b>" . $this->view->selectedPage . "</b>";
         return $_breadcrumb;
     } else {
         $pathElemts = $oProducts->getActions();
         if ($prodId) {
             $_class = '';
             $product = new ProductsObject();
             $details = $product->populate($prodId, $langId);
             if ($_first) {
                 $_class = 'current_page';
             }
             $link = $_first ? "<b>" . $details['PI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}/{$pathElemts[1]}/{$pathElemts[2]}' class='{$_class}'>{$details['PI_Name']}</a>";
             array_push($_breadcrumb, $link);
             if ($_first) {
                 $_first = false;
             }
         }
         if ($subCatId) {
             $_class = '';
             $object = new SubCategoriesObject();
             $details = $object->populate($subCatId, $langId);
             if ($_first) {
                 $_class = 'current_page';
             }
             $link = $_first ? "<b>" . $details['SCI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}/{$pathElemts[1]}' class='{$_class}'>{$details['SCI_Name']}</a>";
             array_push($_breadcrumb, $link);
             if ($_first) {
                 $_first = false;
             }
         }
         if ($catId) {
             $_class = '';
             $object = new CatalogCategoriesObject();
             $details = $object->populate($catId, $langId);
             if ($_first) {
                 $_class = 'current_page';
             }
             $link = $_first ? "<b>" . $details['CCI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}' class='{$_class}'>{$details['CCI_Name']}</a>";
             array_push($_breadcrumb, $link);
             if ($_first) {
                 $_first = false;
             }
         }
         $details = Cible_FunctionsPages::getPageDetails($this->view->currentPageID, $langId);
         $link = $_first ? '' : "<a href='{$_baseUrl}/{$details['PI_PageIndex']}' class='{$_class}'>{$details['PI_PageTitle']}</a>";
         array_push($_breadcrumb, $link);
         if ($showHome) {
             $homeDetails = Cible_FunctionsPages::getHomePageDetails();
             $link = "<a href='{$_baseUrl}/{$homeDetails['PI_PageIndex']}' class='{$_class}'>" . $homeDetails['PI_PageTitle'] . "</a>";
             array_push($_breadcrumb, $link);
         }
         $_breadcrumb = array_reverse($_breadcrumb);
         //var_dump($_breadcrumb);
         //            for($i=0;$i<$level;$i++){
         //                array_splice($_breadcrumb,$i+1,1);
         //            }
         // add the > after the breadcrumb when only on item is found
         if (count($_breadcrumb) == 1) {
             return "{$_breadcrumb[0]} > ";
         } else {
             return implode(' > ', $_breadcrumb);
         }
     }
 }
Esempio n. 10
0
 /**
  * Calculation of taxes and amounts for orders rendrering.
  *
  * @param array $memberInfos
  * @param bool $lines
  *
  * @return array
  */
 public function calculateTotal($memberInfos, $lines = false)
 {
     $session = new Zend_Session_Namespace('order');
     $data = array();
     $oCart = new Cart();
     $oItem = new ItemsObject();
     $oProd = new ProductsCollection();
     $subTotProv = 0;
     $subTotFed = 0;
     $subTot = 0;
     $total = 0;
     $taxProv = 0;
     $taxFed = 0;
     $tmpSum = 0;
     $nbPoint = 0;
     $cartData = $oCart->getAllIds();
     $orderParams = Cible_FunctionsGeneral::getParameters();
     if (!$memberInfos['noFedTax'] && $session->stateId == 11) {
         foreach ($cartData['cartId'] as $key => $id) {
             $itemId = $cartData['itemId'][$key];
             $prodId = $cartData['prodId'][$key];
             $itemDetails = $oItem->getAll(null, true, $itemId);
             $cartDetails = $oCart->getItem($id, $itemId, true);
             if ($itemDetails[0]['I_TaxFed']) {
                 $subTotFed += $cartDetails['Total'];
             }
         }
         $addShipFee = Cible_FunctionsGeneral::compareFloats($subTotFed, '<', $orderParams['CP_ShippingFeesLimit'], 2);
         if ($addShipFee) {
             $subTotFed += $orderParams['CP_ShippingFees'];
         }
         if (isset($session->order['cod'])) {
             $subTotFed += $orderParams['CP_MontantFraisCOD'];
         }
         $taxFed = Cible_FunctionsGeneral::federalTax($subTotFed);
     }
     if (!$memberInfos['noProvTax']) {
         foreach ($cartData['cartId'] as $key => $id) {
             $itemId = $cartData['itemId'][$key];
             $prodId = $cartData['prodId'][$key];
             $itemDetails = $oItem->getAll(null, true, $itemId);
             $cartDetails = $oCart->getItem($id, $itemId, true);
             if ($itemDetails[0]['I_TaxProv']) {
                 $subTotProv += $cartDetails['Total'];
             }
         }
         $addShipFee = Cible_FunctionsGeneral::compareFloats($subTotProv, '<', $orderParams['CP_ShippingFeesLimit'], 2);
         if ($addShipFee) {
             $subTotProv += $orderParams['CP_ShippingFees'];
         }
         if (isset($session->order['cod'])) {
             $subTotProv += $orderParams['CP_MontantFraisCOD'];
         }
         $taxProv = Cible_FunctionsGeneral::provinceTax($subTotProv);
     }
     foreach ($cartData['cartId'] as $key => $id) {
         $itemId = $cartData['itemId'][$key];
         $prodId = $cartData['prodId'][$key];
         $productData = $oProd->getDetails($prodId);
         $cartDetails = $oCart->getItem($id, $itemId, true);
         $subTot += $cartDetails['Total'];
         if ($oProd->getBonus()) {
             $nbPoint += ceil($cartDetails['Total'] * $orderParams['CP_BonusPointDollar']);
         }
     }
     $addShipFee = Cible_FunctionsGeneral::compareFloats($subTot, '<', $orderParams['CP_ShippingFeesLimit'], 2);
     if ($addShipFee) {
         $tmpSum += $orderParams['CP_ShippingFees'];
     }
     if (isset($session->order['cod'])) {
         $tmpSum += $orderParams['CP_MontantFraisCOD'];
     }
     $total = $subTot + $tmpSum + round($taxFed, 2) + round($taxProv, 2);
     $data = array('subTotProv' => $subTotProv, 'subTotFed' => $subTotFed, 'subTot' => $subTot, 'total' => $total, 'taxProv' => $taxProv, 'nbPoint' => $nbPoint, 'taxFed' => $taxFed);
     return $data;
 }