Пример #1
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');
         }
     }
 }
Пример #2
0
 /**
  * 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);
             }
         }
     }
 }
Пример #3
0
 /**
  * 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');
     }
 }
Пример #4
0
 public function orderAction()
 {
     $this->view->headLink()->prependStylesheet($this->view->LocateFile('cart.css'));
     $session = new Zend_Session_Namespace('order');
     $urlBack = '';
     $urlNextStep = '';
     $urls = Cible_View_Helper_LastVisited::getLastVisited();
     $profile = new MemberProfile();
     $oAddress = new AddressObject();
     $authentication = Cible_FunctionsGeneral::getAuthentication();
     $memberInfos = $profile->findMember(array('email' => $authentication['email']));
     $page = Cible_FunctionsCategories::getPagePerCategoryView(0, 'list_collections', 14);
     // If authentication is not present or if cart is empty, redirect to the cart page
     if (!is_null($authentication)) {
         //            $memberInfos = $profile->addTaxRate($memberInfos);
         if (!empty($memberInfos['addrBill'])) {
             $billAddr = $oAddress->populate($memberInfos['addrBill'], $this->_defaultInterfaceLanguage);
         }
         if (!empty($memberInfos['addrShip'])) {
             $shipAddr = $oAddress->populate($memberInfos['addrShip'], $this->_defaultInterfaceLanguage);
         }
         //            $oRetailer = new RetailersObject();
         //            $memberInfos['AI_FirstTel'] = $billAddr['AI_FirstTel'];
         //            $memberInfos['AI_SecondTel'] = $billAddr['AI_SecondTel'];
         //            $memberInfos['A_Fax'] = $billAddr['A_Fax'];
         if (isset($billAddr['AI_WebSite'])) {
             $memberInfos['AI_WebSite'] = $billAddr['AI_WebSite'];
         }
         $memberInfos['addressFact'] = $billAddr;
         if (isset($shipAddr['A_Duplicate']) && !$shipAddr['A_Duplicate']) {
             $shipAddr['duplicate'] = 0;
         }
         $memberInfos['addressShipping'] = $shipAddr;
         $current_state = $billAddr['A_StateId'] . '||' . $shipAddr['A_StateId'] . '||';
         $currentCity = $billAddr['A_CityId'] . '||' . $shipAddr['A_CityId'] . '||';
         //            $onWeb = $oRetailer->getRetailerInfos($memberInfos['member_id'], $this->_defaultInterfaceLanguage);
         //            if ($onWeb && !empty($onWeb['R_AddressId']))
         //            {
         //                $webAddr = $oAddress->populate($onWeb['R_AddressId'], $this->_defaultInterfaceLanguage);
         //
         //                $webAddr['isDistributeur'] = $onWeb['R_Status'];
         //                $memberInfos['addressDetaillant'] = $webAddr;
         //
         //                $current_state .= $webAddr['A_StateId'] . '||';
         //                $currentCity .= $webAddr['A_CityId'] . '||';
         //            }
         $return = $this->_getParam('return');
         if ($return && isset($_COOKIE['returnUrl'])) {
             $returnUrl = $_COOKIE['returnUrl'];
             $this->view->assign('return', $returnUrl);
         }
         $pageOrderName = Cible_FunctionsCategories::getPagePerCategoryView(0, 'order', $this->_moduleID);
         $tmp = explode('/', $pageOrderName);
         $tmp = array_unique($tmp);
         $pageOrderName = $tmp[0];
         $stepValues = array('auth-order' => array('step' => 2, 'next' => $pageOrderName . '/resume-order', 'prev' => ''), 'resume-order' => array('step' => 3, 'next' => $pageOrderName . '/send-order', 'prev' => 'auth-order'), 'send-order' => array('step' => 4, 'next' => '', 'prev' => 'resume-order'));
         $stepAction = $this->_getParam('action');
         $urlBack = $stepValues[$stepAction]['prev'];
         if (empty($stepValues[$stepAction]['prev']) && isset($urls[0])) {
             $urlBack = $urls[0];
         }
         $this->view->assign('step', $stepValues[$stepAction]['step']);
         $this->view->assign('nextStep', $stepValues[$stepAction]['next']);
         $this->view->assign('urlBack', $urlBack);
         $orderParams = Cible_FunctionsGeneral::getParameters();
         switch ($stepAction) {
             case 'resume-order':
                 if (empty($session->customer)) {
                     $this->_redirect(Cible_FunctionsPages::getPageNameByID(1));
                 }
                 // Create this form to fill with values used for the read-only rendering
                 $formOrder = new FormOrder(array('resume' => true));
                 // Store the state id in the session to allow tax calculation
                 $session->stateId = $billAddr['A_StateId'];
                 // Calculate totals to display and for the bill.
                 $totals = $this->calculateTotal($memberInfos);
                 $session->order['charge_total'] = $totals['total'];
                 $session->order['subTotal'] = $totals['subTot'];
                 $session->order['taxFed'] = $totals['taxFed'];
                 $session->order['taxProv'] = $totals['taxProv'];
                 $session->order['nbPoint'] = $totals['nbPoint'];
                 $session->order['shipFee'] = $orderParams['CP_ShippingFees'];
                 $session->order['limitShip'] = $orderParams['CP_ShippingFeesLimit'];
                 $session->order['CODFees'] = $orderParams['CP_MontantFraisCOD'];
                 $session->order['rateFed'] = 0;
                 if ($session->stateId == 11) {
                     $session->order['rateFed'] = $orderParams['CP_TauxTaxeFed'];
                 }
                 if (isset($session->customer['addressShipping']['duplicate']) && $session->customer['addressShipping']['duplicate']) {
                     unset($session->customer['addressShipping']);
                     $session->customer['addressShipping'] = $session->customer['addressFact'];
                 }
                 $dataBill = $this->getAddrData($session->customer['addressFact'], 'addressFact', $session);
                 $dataShip = $this->getAddrData($session->customer['addressShipping'], 'addressShipping', $session);
                 $salut = Cible_FunctionsGeneral::getSalutations($memberInfos['salutation'], Zend_Registry::get('languageID'));
                 if (isset($salut[$memberInfos['salutation']])) {
                     $session->customer['identification']['salutation'] = utf8_decode($salut[$memberInfos['salutation']]);
                 } else {
                     $session->customer['identification']['salutation'] = "-";
                 }
                 $formOrder->populate($session->customer);
                 $formOrder->getSubForm('addressShipping')->removeElement('duplicate');
                 $formOrder->getSubForm('identification')->removeElement('password');
                 $formOrder->getSubForm('identification')->removeElement('passwordConfirmation');
                 $formOrder->getSubForm('identification')->removeElement('noFedTax');
                 $formOrder->getSubForm('identification')->removeElement('noProvTax');
                 $formOrder->getSubForm('identification')->removeElement('AI_FirstTel');
                 $formOrder->getSubForm('identification')->removeElement('AI_SecondTel');
                 $formOrder->getSubForm('identification')->removeElement('AI_WebSite');
                 $formOrder->getSubForm('identification')->removeElement('A_Fax');
                 $readOnly = new Cible_View_Helper_FormReadOnly();
                 $readOnly->setAddSeparator(true);
                 $readOnly->setSeparatorClass('dotLine');
                 $readOnly->setListOpened(false);
                 $readOnly->setSeparatorPositon(array(1));
                 $readOnlyForm = $readOnly->subFormRender($formOrder);
                 $formPayment = new FormOrderPayment(array('readOnlyForm' => $readOnlyForm, 'payMean' => $session->customer['paymentMeans']));
                 //                    $formPayment->populate($session->order);
                 if ($this->_request->isPost() && array_key_exists('submit', $_POST)) {
                     $formData = $this->_request->getPost();
                     $session->customer['invoice'] = $formData;
                     //                        $session->customer['indentification'] = $memberInfos;
                     $this->_redirect($stepValues[$stepAction]['next']);
                 }
                 $session->customer['charge_total'] = sprintf('%.2f', $totals['total']);
                 $formPayment->populate($session->customer);
                 $this->view->assign('CODFees', $orderParams['CP_MontantFraisCOD']);
                 $this->view->assign('memberInfos', $memberInfos);
                 $this->view->assign('formOrder', $formPayment);
                 $this->renderScript('index/order-summary.phtml');
                 break;
             case 'send-order':
                 if ($this->_request->isPost()) {
                     //                        if ($this->_request->getParam('response_code') > 50)
                     if ($this->_request->getParam('response_code') < 50 && $this->_request->getParam('response_code') != 'null') {
                         $session->order['confirmation'] = $_POST;
                     } else {
                         $this->view->assign('errorValidation', $this->view->getClientText('card_payment_error_message'));
                         $session->customer['message'] = $this->view->getClientText('card_payment_error_message');
                         $this->_redirect($pageOrderName . '/' . $stepValues['resume-order']['prev'] . '/errorValidation/1');
                     }
                 }
                 $this->sendOrder();
                 $urlBack = $this->view->BaseUrl() . '/' . $page;
                 $this->view->assign('backHomeLink', $urlBack);
                 $this->renderScript('index/order-sent.phtml');
                 break;
             default:
                 //                    $oCart = new Cart();
                 //                    $cartHeader = $oCart->getCartData();
                 //                    $cartId = $oCart->getId();
                 //                    $files = $oCart->manageFileUpload();
                 $form = new FormOrderAddr(array('hasAccount' => $memberInfos['hasAccount']));
                 //                    $this->getAddrData($memberInfos['addressFact'], 'addressFact', $session);
                 //                    $address = array_merge($memberInfos['addressFact'], $session->customer['addressFact']);
                 //                    $form->getSubForm('addressFact')->populate($address);
                 //
                 //                    $readOnly = new Cible_View_Helper_FormReadOnly();
                 //                    $readOnly->setAddSeparator(true);
                 //                    $readOnly->setSeparatorClass('dotLine');
                 //                    $readOnly->setListOpened(true);
                 //                    $readOnly->setSeparatorPosition(array(1));
                 //                    $readOnlyForm = $readOnly->subFormRender($form, 'addressFact');
                 //
                 //                    $newForm = new FormOrderAddr(array('readOnlyBillAddr' => $readOnlyForm));
                 if ($this->_request->isPost()) {
                     $statePost = '';
                     $cityPost = '';
                     $data = $this->_request->getPost();
                     $currentCity = 0;
                     $current_state = $data['addressFact']['A_StateId'] . '||';
                     $current_state .= $data['addressShipping']['A_StateId'];
                     //                        $currentCity = (empty($cityPost)) ? substr($currentCity, 0, -1) : substr($cityPost, 0, -1);
                     //                        $current_state = (empty($statePost)) ? substr($current_state, 0, -1) : substr($statePost, 0, -1);
                     $memberInfos['selectedState'] = $session->customer['selectedState'];
                     $memberInfos['selectedCity'] = $session->customer['selectedCity'];
                 }
                 if ($this->_request->isPost() && array_key_exists('submit', $_POST)) {
                     $formData = $this->_request->getPost();
                     $formData['selectedState'] = $current_state;
                     $formData['selectedCity'] = $currentCity;
                     //Remove data validation if not a new address
                     $addrSource = $newForm->getSubForm('addressShipping')->getElement('addrSource')->getValue();
                     if ($addrSource == 1 || $addrSource == 3) {
                         $subFormShip = $form->getSubForm('addressShipping');
                         foreach ($subFormShip as $key => $value) {
                             $value->clearValidators()->setRequired(false);
                         }
                     }
                     //                        if ($formData['paymentMeans'] == 'compte' && !$memberInfos['hasAccount'])
                     //                        {
                     //                            $newForm->getElement('paymentMeans')->setErrors(array($this->view->getClientText('no_customer_account')));
                     //                            $formData['paymentMeans'] = null;
                     //                        }
                     if ($form->isValid($formData)) {
                         //                            if($formData['paymentMeans'] == 'cod')
                         //                                $session->order['cod'] = $formData['paymentMeans'];
                         //                            elseif(isset($session->order['cod']))
                         //                                unset($session->order['cod']);
                         $session->customer = $formData;
                         $session->customer['identification'] = $memberInfos;
                         $this->_redirect($stepValues[$stepAction]['next']);
                     } else {
                         $form->populate($formData);
                     }
                 } else {
                     $memberInfos['selectedState'] = $current_state;
                     $memberInfos['selectedCity'] = $currentCity;
                     $form->populate($memberInfos);
                 }
                 $this->view->assign('CODFees', $orderParams['CP_MontantFraisCOD']);
                 $this->view->assign('form', $form);
                 $this->view->assign('memberInfos', $memberInfos);
                 $this->view->assign('accountValidate', $memberInfos['validatedEmail']);
                 break;
         }
     } else {
         $this->_redirect(Cible_FunctionsPages::getPageNameByID(1));
     }
 }