/** * List products according given parameters. * This list is only for display purpose. No actions except Excel export. * * @return void */ public function listAction() { $img = $this->_getParam('img'); if (!empty($img)) { $this->downloadAction(); exit; } $this->view->params['actions'] = $this->_request->getPathInfo(); /* List products */ $oProducts = new ProductsCollection($this->view->params); $products = $oProducts->getList(); $searchCount = count($products); /* Params */ $subCategoryId = 0; $blockParams = $oProducts->getBlockParams(); $categorieId = $oProducts->getCatId(); $productId = $oProducts->getProdId(); $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo(); Cible_View_Helper_LastVisited::saveThis($url); if (!$productId) { if (!$categorieId) { $categorieId = $blockParams[1]; } // Zend_Registry::set('bg-body-id', $categorieId); $subCategoryId = $oProducts->getSubCatId(); if ($subCategoryId) { $oSubCat = new SubCategoriesObject(); $subCat = $oSubCat->populate($subCategoryId, Zend_Registry::get('languageID')); $this->view->subCatName = $subCat['SCI_Name']; } $searchWords = isset($this->view->params['keywords']) && $this->view->params['keywords'] != $this->view->getCibleText('form_search_catalog_keywords_label') ? $this->view->params['keywords'] : ''; /* Search form */ // $searchForm = new FormSearchCatalogue( // array( // 'categorieId' => $categorieId, // 'subCategoryId' => $subCategoryId, // 'keywords' => $searchWords) // ); // // $this->view->assign('searchForm', $searchForm); $oCategory = new CatalogCategoriesObject(); $category = $oCategory->populate($categorieId, $this->_registry->languageID); $this->_registry->set('category', $category); $lastSearch = array(); if (!empty($subCategoryId)) { $lastSearch['sousCatId'] = $subCategoryId; } if (!empty($searchWords)) { $lastSearch['keywords'] = $searchWords; } $this->view->assign('searchUrl', $lastSearch); $page = 1; $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($products)); $paginator->setItemCountPerPage($oProducts->getLimit()); if (isset($this->view->params['productId'])) { $productId = $this->view->params['productId']; $this->view->assign('productId', $productId); foreach ($products as $product) { if ($product['P_ID'] != $productId) { $page++; } else { break; } } } $filter = $oProducts->getFilter(); $paramPage = $this->_request->getParam('page'); $page = isset($paramPage) ? $this->_request->getParam('page') : ceil($page / $paginator->getItemCountPerPage()); $paginator->setCurrentPageNumber($page); $this->view->assign('categoryId', $categorieId); $this->view->assign('params', $oProducts->getBlockParams()); $this->view->assign('paginator', $paginator); $this->view->assign('keywords', $searchWords); $this->view->assign('searchCount', $searchCount); $this->view->assign('filter', $filter); if (isset($category['CCI_ValUrl'])) { echo $this->_registry->set('selectedCatalogPage', $category['CCI_ValUrl']); } } else { $this->_registry->set('category', $this->_registry->get('catId_')); $this->_registry->set('productCase', '1'); $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo(); Cible_View_Helper_LastVisited::saveThis($url); $this->_registry->set('selectedCatalogPage', $products['CCI_ValUrl']); $this->view->assign('productDetails', $products); $this->renderScript('index/detail-product.phtml'); } }
/** * 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'); } } }
/** * Edit action for the current object. * * @access public * * @return void */ public function editAction() { $this->view->headScript()->appendFile($this->view->locateFile('profile.js')); $imageSrc = ""; $id = (int) $this->_getParam($this->_ID); $page = (int) $this->_getParam('page'); $baseDir = $this->view->baseUrl() . "/"; $cancelUrl = $baseDir; $returnModule = $this->_getParam('returnModule'); $returnAction = $this->_getParam('returnAction'); if (!empty($returnModule)) { $cancelUrl .= $returnModule . '/'; } else { $cancelUrl .= $this->_moduleTitle . "/"; } $cancelUrl .= $this->_name . "/"; if (!empty($returnAction)) { $cancelUrl .= $returnAction . '/'; } else { $cancelUrl .= 'general/'; } $cancelUrl .= "page/" . $page; $config = Zend_Registry::get('config'); $current_state = $config->address->default->states; $currentCity = ''; $this->view->assign('selectedState', $current_state); $oDataName = $this->_objectList[$this->_currentAction]; $oData = new $oDataName(); if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) { $this->view->id = $id; if ($this->_isXmlHttpRequest) { $this->disableLayout(); } else { if (!empty($returnModule)) { Cible_View_Helper_LastVisited::emptyUrls(); } $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo(); Cible_View_Helper_LastVisited::saveThis($url); $urls = Cible_View_Helper_LastVisited::getLastVisited(); if (count($urls) > 1) { $this->view->urlBack = $this->view->baseUrl() . $urls[1]; } } $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/" . "page/" . $page; // Get data details $data = $oData->populate($id, $this->_defaultEditLanguage); // image src. if (!empty($data[$this->_imageSrc])) { $config = Zend_Registry::get('config')->toArray(); $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight']; $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth']; $this->view->assign('imageUrl', $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc])); $isNewImage = 'false'; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($formData[$this->_imageSrc] != $data[$this->_imageSrc]) { if ($formData[$this->_imageSrc] == "") { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; } else { $imageSrc = $this->_rootImgPath . $id . "/tmp/mcith/mcith_" . $formData[$this->_imageSrc]; } $isNewImage = 'true'; } else { if ($data[$this->_imageSrc] == "") { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; } else { $imageSrc = $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]); } } } else { if (empty($data[$this->_imageSrc])) { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; } else { $imageSrc = $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]); } } } // generate the form $options = array('moduleName' => $this->_moduleTitle . "/" . $this->_objectList[$this->_currentAction], 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $id, 'data' => $data, 'mode' => 'edit', 'isNewImage' => 'true'); if ($this->_isXmlHttpRequest) { $options['object'] = $oData; } $form = new $this->_formName($options); // if (!empty($this->_oMember)) // { // $memberData = $this->_oMember->getAll(null, true, $id); // if (!empty($memberData)) // { // $memberForm = new FormMembersProfile(); // $memberForm->populate($memberData[0]); // $form->addSubForm($memberForm, 'memberForm'); // $form->getSubForm('memberForm')->setAttrib('class','DtDdWrapper'); // // if ($this->_request->isPost()) // { // $form->getSubForm('memberForm')->populate($data); // } // } // } $this->view->form = $form; // Load data from profiles to build the tabs $tabsList = array(); if (!$this->_isXmlHttpRequest) { $objects = $this->_objectList; unset($objects[$this->_currentAction]); $tabForm = null; foreach ($objects as $key => $objName) { $obj = new $objName(); $isActive = $obj->findData(array($obj->getForeignKey() => $id)); $status = null; if (isset($isActive['MP_Status'])) { $status = $isActive['MP_Status']; } if (count($isActive) > 0 && $status != -2) { $action = $key . 'Action'; $params = $this->{$action}(true); // $this->getLogData($id, $key); // $this->view->assign('log', $logData); $tabForm = new $params['formName'](array('moduleName' => $this->_moduleTitle . "/" . $key, 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $id, 'object' => $obj, 'data' => $data, 'mode' => 'edit', 'isNewImage' => 'true')); $tabForm->populate($isActive); array_push($tabsList, array($key, $tabForm)); } } } $this->view->assign('tabsList', $tabsList); // action if (!$this->_request->isPost()) { $form->populate($data); if ($this->_isXmlHttpRequest) { $form->getElement('submitSave')->setAttrib('disabled', true); $render = $this->_name . '/formRenderer.phtml'; echo $this->view->render($render); exit; } } else { $addrOne = array(); $addrTwo = array(); $formData = $this->_request->getParams(); if ($this->_formatData && isset($formData['data'])) { $formData = $formData['data']; $formData = $this->_mergeFormData($formData); } if (isset($formData[$oData->getFormDataName()])) { $addrOne = $formData[$oData->getFormDataName()]; if (!empty($data[$oData->getAddressField()])) { $formData[$oData->getAddressField()] = $data[$oData->getAddressField()]; } else { $formData[$oData->getAddressField()] = ''; } } if (isset($formData['parentFormTwo']['duplicate'])) { $addrTwo = $formData['parentFormTwo']; if ($formData['parentFormTwo']['duplicate'] == 1) { $subFormShip = $form->getSubForm('parentFormTwo'); foreach ($subFormShip as $key => $value) { $value->clearValidators()->setRequired(false); } unset($formData['parentFormTwo']); } } if ($form->isValid($formData)) { if (empty($addrOne) && !$this->_formatData && !isset($formData['parentForm'])) { $formData = $this->_mergeFormData($formData); } else { $formData['parentFormTwo'] = $addrTwo; } if (isset($formData['isNewImage']) && $formData['isNewImage'] == 'true' && $form->getValue($this->_imageSrc) != '') { $config = Zend_Registry::get('config')->toArray(); $srcOriginal = $this->_imageFolder . $id . "/tmp/" . $form->getValue($this->_imageSrc); $originalMaxHeight = $config[$this->_moduleTitle]['image']['original']['maxHeight']; $originalMaxWidth = $config[$this->_moduleTitle]['image']['original']['maxWidth']; $originalName = str_replace($form->getValue($this->_imageSrc), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc)); $srcMedium = $this->_imageFolder . $id . "/tmp/medium_" . $form->getValue($this->_imageSrc); $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight']; $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth']; $mediumName = str_replace($form->getValue($this->_imageSrc), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc)); $srcThumb = $this->_imageFolder . $id . "/tmp/thumb_" . $form->getValue($this->_imageSrc); $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight']; $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth']; $thumbName = str_replace($form->getValue($this->_imageSrc), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc)); copy($srcOriginal, $srcMedium); copy($srcOriginal, $srcThumb); Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcMedium, 'maxWidth' => $mediumMaxWidth, 'maxHeight' => $mediumMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight)); rename($srcOriginal, $this->_imageFolder . $id . "/" . $originalName); rename($srcMedium, $this->_imageFolder . $id . "/" . $mediumName); rename($srcThumb, $this->_imageFolder . $id . "/" . $thumbName); } $oData->save($id, $formData, $this->getCurrentEditLanguage()); if (!empty($this->_oMember)) { $memberForm = $form->getSubForm('memberForm'); if (!empty($formData['MP_Password'])) { $formData['MP_Password'] = md5($formData['MP_Password']); } else { $formData['MP_Password'] = $memberData[0]['MP_Password']; } $this->_oMember->save($id, $formData, $this->_currentEditLanguage); } if ($this->_isXmlHttpRequest) { $this->disableView(); echo json_encode(true); } // redirect // $this->_redirect($returnUrl); } else { // $currentCity = $formData['retailerForm[A_CityId]']['']; if (isset($data['addressFact[A_StateId]'])) { $current_state = $data['addressFact[A_StateId]'] . $this->_separ; $current_state .= $data['addressShipping[A_StateId]'] . $this->_separ; $current_state .= $data['retailerForm[A_StateId]']; $this->view->assign('selectedSate', $current_state); } $this->disableView(); echo json_encode(false); } } } }