Beispiel #1
0
 private function appendIfNotFound($children, $tmp, $appendTo = array())
 {
     foreach ($children as $child) {
         $index = '';
         if ($child['PageID'] != -1) {
             $index = Cible_FunctionsPages::getPageNameByID($child['PageID']);
         } else {
             $index = $child['Link'];
         }
         if (!empty($index) && !isset($tmp[$index])) {
             $tmp[$index] = '';
             array_push($appendTo, array('ID' => $child['ID'], 'Title' => strip_tags($child['Title']), 'Link' => $child['Link'], 'PageID' => $child['PageID'], 'Placeholder' => $child['Placeholder']));
             if (!empty($child['child'])) {
                 $index = count($appendTo) - 1;
                 $appendTo[$index]['child'] = $child['child'];
             }
         }
     }
     return $appendTo;
 }
Beispiel #2
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');
         }
     }
 }
Beispiel #3
0
    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');
        //$exception = $errors->exception;
        Zend_Registry::set('baseUrl', $this->getFrontController()->getBaseUrl());
        switch ($errors->type) {
            // if it is a controller error
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
                // grab the controller, action and settings requested by the user
                $ParamsArray = $errors->request->getParams();
                if ($this->_request->controller == "robots.txt") {
                    $this->robotsAction();
                    $this->_helper->layout()->disableLayout();
                    $this->_helper->viewRenderer->setNoRender(true);
                    //Cible_FunctionsRobots::robotsAction();
                    exit;
                }
                $ControllerName = $ParamsArray['controller'];
                $ActionName = $ParamsArray['action'];
                // check if the name of the controller is in the database
                $Pages = new PagesIndex();
                $Select = $Pages->select()->setIntegrityCheck(false)->from('PagesIndex')->join('Languages', 'Languages.L_ID = PagesIndex.PI_LanguageID')->join('Pages', 'Pages.P_ID = PagesIndex.PI_PageID')->join('Page_Themes', 'Page_Themes.PT_ID = Pages.P_ThemeID')->join('Views', 'Views.V_ID = Pages.P_ViewID')->where('PagesIndex.PI_PageIndex = ?', $ControllerName)->where('PI_Status = 1')->limit(1);
                $Row = $Pages->fetchRow($Select);
                // if the controller is found in the database
                if (count($Row) == 1) {
                    // call page controller to display blocks
                    $this->_helper->actionStack('index', 'page', 'default', array('Row' => $Row, 'Param' => $ParamsArray));
                    // does not render the page Error404
                    $this->disableView();
                } else {
                    $session = new Cible_Sessions();
                    $currentLanguageID = !empty($session->languageID) ? $session->languageID : $this->_config->defaultInterfaceLanguage;
                    $page_not_found_id = $this->_config->page_not_found->pageID;
                    $pageIndexName = Cible_FunctionsPages::getPageNameByID($page_not_found_id, $currentLanguageID);
                    // check if the name of the controller is in the database
                    $Pages = new PagesIndex();
                    $Select = $Pages->select()->setIntegrityCheck(false)->from('PagesIndex')->join('Languages', 'Languages.L_ID = PagesIndex.PI_LanguageID')->join('Pages', 'Pages.P_ID = PagesIndex.PI_PageID')->join('Page_Themes', 'Page_Themes.PT_ID = Pages.P_ThemeID')->join('Views', 'Views.V_ID = Pages.P_ViewID')->where('PagesIndex.PI_PageIndex = ?', $pageIndexName)->where('PI_Status = 1')->limit(1);
                    $Row = $Pages->fetchRow($Select);
                    if (count($Row) == 1) {
                        // call page controller to display blocks
                        $this->_helper->actionStack('index', 'page', 'default', array('Row' => $Row, 'Param' => $ParamsArray));
                        // does not render the page Error404
                        $this->disableView();
                    } else {
                        $this->disableLayout();
                        echo "404 Page not found.";
                    }
                    $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
                }
                break;
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // does not render the page Error404
                $this->disableLayout();
                $this->disableView();
                echo "Erreur d'action   ";
                break;
            default:
                // application error; display error page, but don't change
                // status code
                // ...
                // Log the exception:
                $exception = $errors->exception;
                /*$log = new Zend_Log(
                      new Zend_Log_Writer_Stream(
                          '/tmp/applicationException.log'
                      )
                  );
                  $log->debug($exception->getMessage() . "\n" .
                              $exception->getTraceAsString());
                  */
                echo <<<End_of_error
                    <p>
                    <strong>Error</strong>
                    {$exception->getMessage()}
                    </p>
                    <p>
                    <strong>Stack Trace</strong>
                    {$exception->getTraceAsString()}
                    </p>
End_of_error;
                break;
        }
    }
Beispiel #4
0
 public function listcollectionsAction()
 {
     $langId = Zend_Registry::get('languageID');
     $oSubCategories = new SubCategoriesObject();
     $subCategories = $oSubCategories->getSubCatAsCollections($langId);
     $page = Cible_FunctionsPages::getPageNameByID(14080, $langId);
     $this->view->assign('collections', $subCategories);
     $this->view->assign('page', $page);
 }
Beispiel #5
0
 /**
  * Generate the sub menu list = Children of the menu
  *
  * @param array $tree                An array with all the menu data.
  * @param bool  $addFirstLastClasses Set CSS class for the first and last li
  * @param int   $level               Used to exclude duplicate style by
  * level.
  *
  * @return string
  */
 protected function generateList($tree, $addFirstLastClasses = false, $level = 1)
 {
     $content = '';
     $menuContent = '';
     $i = 1;
     $item_number = count($tree);
     $current_page = '';
     foreach ($tree as $object) {
         if (isset($object)) {
             $tmp = '';
             $object['Title'] = htmlentities($object['Title']);
             $nbElem = 0;
             $liclass = array();
             $url = $link = empty($object['PageID']) || $object['PageID'] == -1 ? $object['Link'] : Cible_FunctionsPages::getPageNameByID($object['PageID'], Zend_Registry::get('languageID'));
             if ($object['PageID'] > 0 && !empty($object['Link'])) {
                 $link = $link . $object['Link'];
             }
             $external = false;
             if (empty($link)) {
                 $link = 'javascript:void(0)';
                 array_push($liclass, 'placeholder');
             } else {
                 if (substr($link, 0, 4) == 'http') {
                     $link = "{$link}";
                     $external = true;
                 } else {
                     $link = "{$this->view->baseUrl()}/{$link}";
                 }
             }
             //if ($external)
             //    $menuContent = "<a href='{$link}' class='level-{$level}' target='_blank'>{$object['Title']}</a>\r\n";
             if (isset($object['loadImage']) && (bool) $object['loadImage'] && $this->_startLevel == 1 && !$this->_isSiteMap) {
                 $folder = 'menu';
                 $config = Zend_Registry::get('config');
                 $imgPrefix = $config->menu->image->thumb->maxWidth . 'x' . $config->menu->image->thumb->maxHeight . '_';
                 if ($object['Placeholder'] == 2) {
                     $imgPrefix = $config->catalog->subcategory->thumb->maxWidth . 'x' . $config->catalog->subcategory->thumb->maxHeight . '_';
                     $folder = 'catalog/sub-categories';
                 }
                 $imgFolder = $this->view->baseUrl() . '/data/images/' . $folder . '/' . $object['ID'] . "/";
                 $source = $imgFolder . $imgPrefix . $object['menuImage'];
                 $menuContent = "<p class='imgMenuCont'>";
                 if (!empty($object['menuImage'])) {
                     if ($external) {
                         $menuContent .= "<a href='{$link}' class='level-{$level}' target='_blank'>";
                     } else {
                         $menuContent .= "<a href='{$link}' class='level-{$level}'>";
                     }
                     $menuContent .= $this->view->image($source, array('alt' => $object['Title']));
                     $menuContent .= "</a>\r\n";
                 } else {
                     if ($external) {
                         $menuContent .= "<a href='{$link}' class='level-{$level}' target='_blank'>";
                     } else {
                         $menuContent .= "<a href='{$link}' class='level-{$level}'>";
                     }
                     $menuContent .= $this->view->clientImage('pix.gif', array('alt' => $object['Title'], 'style' => 'height:91px;'));
                     $menuContent .= "</a>\r\n";
                 }
                 $menuContent .= "&nbsp;";
                 $menuContent .= "</p>";
                 if ((bool) $object['menuImgAndTitle']) {
                     $menuContent .= "<p class='imgTitle'>";
                     $menuContent .= "<a href='{$link}' class='level-{$level}'>";
                     $menuContent .= $object['Title'];
                     $menuContent .= "</a>\r\n";
                     $menuContent .= "</p>";
                 }
             } else {
                 $menuContent = "<a href='{$link}' class='level-{$level}'>{$object['Title']}</a>\r\n";
             }
             $tmp .= $menuContent;
             if (!empty($object['child']) && is_array($object['child']) && !$this->_disable_nesting) {
                 $addPositionArrow = $this->_hasMenuImage($object['child']);
                 if ($addPositionArrow && $level == 1 && !$this->_isSiteMap) {
                     $this->_nbChild = count($object['child']);
                     $tmp .= "<div id='positionArrow-{$object['ID']}' class='positionArrow {$object['Style']}'>";
                     $tmp .= "";
                     $tmp .= "</div>";
                 }
                 if ($object['Placeholder'] == 2 && empty($this->html)) {
                     $this->title = $object['Title'];
                     $this->level = $level;
                     $this->limit = 8;
                     $this->html = $this->_addListAllLink($link);
                 } else {
                     $properties = get_class_vars(get_class($this));
                     $this->limit = $properties['limit'];
                     $this->html = "";
                 }
                 $tmp .= "<ul class='level-{$level}'>\r\n";
                 $tmp .= $this->generateList($object['child'], $addFirstLastClasses, $level + 1);
                 $tmp .= $this->html;
                 $tmp .= "</ul>\r\n";
             }
             if (!empty($this->_liClass)) {
                 array_push($liclass, $this->_liClass);
             }
             $tmpArray = array();
             if (count($this->_parentsMenuId)) {
                 $tmpArray = $this->_parentsMenuId;
             }
             if ($url == $this->_selectedPage || in_array($object['ID'], $tmpArray)) {
                 //$test = $this->_getParentsMenuId($object);
                 array_push($liclass, 'selected');
                 if ($level > Zend_Registry::get('selectedItemMenuLevel')) {
                     $selectedItemMenuID = $object['ID'];
                     Zend_Registry::set('selectedItemMenuLevel', $level);
                     Zend_Registry::set('selectedItemMenuID', $selectedItemMenuID);
                     $session = new Zend_Session_Namespace('breadcrumb');
                     if ($i == $this->limit) {
                         array_push($liclass, 'lastFirstLine');
                     }
                 }
             }
             $separatorClass = "";
             if ($addFirstLastClasses) {
                 if ($i == 1) {
                     array_push($liclass, 'first');
                     $separatorClass = 'first';
                 }
                 if ($i == $item_number) {
                     array_push($liclass, 'last');
                     $separatorClass = 'last';
                 }
             }
             array_push($liclass, "level-{$level}");
             if (!empty($object['Style'])) {
                 array_push($liclass, $object['Style']);
             }
             if ($this->_addEnclosure) {
                 $content .= "<li class='left" . ($url == $this->_selectedPage ? ' selectedLeft' : '') . "'></li>";
             }
             $current_class = count($liclass) > 0 ? "class='" . implode(' ', $liclass) . "'" : '';
             $content .= "<li {$current_class} id='" . $this->_parent_alt_id . "{$object['ID']}'>" . $tmp . "</li>\r\n";
             if ($this->_addEnclosure) {
                 $content .= "<li class='right" . ($url == $this->_selectedPage ? ' selectedRight' : '') . "'></li>";
             }
             if ($this->_addSeparator) {
                 $content .= "<li class='verticalSeparator " . $separatorClass . "'>" . $this->_addSeparator . "</li>";
             }
             if ($i > $this->limit && $this->_startLevel == 1 && !$this->_isSiteMap) {
                 $content .= $this->html;
                 $content .= "</ul>\r\n";
                 $content .= "<ul class='level-{$this->level} repeat'>\r\n";
                 $this->html = "";
             }
             $i++;
         }
     }
     return $content;
 }
Beispiel #6
0
 /**
  * Set default values and the first level container (ul)
  *
  * @param Mixed $menu    If String: Fecth menu data according its name.<br/>
  *                       If Array: It must contain the menu tree.
  *
  * @param array $options Options to manage menu behaviour<br />
  *                       Ex: disable_nesting => true, parentAltId => (string)
  *
  * @return string html code to display the menu and is children
  */
 public function subMenu($options = array())
 {
     if (isset($options['addEnclosure'])) {
         $this->_addEnclosure = $options['addEnclosure'];
     }
     if ($this->view->selectedPage) {
         $this->_selectedPage = $this->view->selectedPage;
     } elseif (Zend_Registry::isRegistered('selectedPage')) {
         $this->_selectedPage = Zend_Registry::get('selectedPage');
     } else {
         $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
         $this->_selectedPage = $params['controller'];
         if ($params['controller'] == 'index') {
             $this->_selectedPage = Cible_FunctionsPages::getPageNameByID(1);
         }
     }
     $oPages = new PagesObject();
     $pageData = $oPages->pageIdByController($this->_selectedPage);
     $this->_selectedPageId = $pageData['P_ID'];
     $menuData = $oPages->getRelatedMenu($this->_selectedPageId);
     $parentId = 0;
     if (!$menuData) {
         $parentId = $oPages->getParentRelatedID($this->_selectedPageId);
         $parentName = $oPages->getParentRelatedName($parentId);
         $menuData = $oPages->getRelatedMenu($parentId);
         $this->_selectedPageId = $parentId;
         $parentId = $menuData['MID_ParentID'];
         $this->view->assign('selectedPage', $parentName);
         //echo $parentName;
     }
     $_menu = new MenuObject($menuData['MID_MenuId']);
     if ($menuData['MID_ParentID'] == 0) {
         $parentId = $menuData['MID_ID'];
     } else {
         $menuItem = $_menu->getMenuItemByPageId($this->_selectedPageId);
         if ($menuItem) {
             $this->_getParentsMenuId($menuItem, $_menu);
         }
         if ($parentId == 0) {
             $parentId = $this->_parentsMenuId[0];
         }
     }
     if (!empty($options['parentId'])) {
         $parentId = $options['parentId'];
     }
     if (preg_match('/useCatalog/', $menuData['MID_Style'])) {
         $menu_item['Placeholder'] = 2;
         $collections = new SubCategoriesObject();
         //                $menuCatalog = $this->getMenuItemByPageId( null, 'collections');
         $catalogMenu = $collections->buildCatalogMenu($menu_item, array('nesting' => 1));
         $tree = $catalogMenu['child'];
         //               $first = $this->populate($menuCatalog['MID_ID']);
         //               $childCombined = array();
         //                   $childCombined = array_merge($catalogMenu['child'], $first);
         //                   $catalog['child'] = $childCombined;
     } elseif (!empty($parentId)) {
         $tree = $_menu->populate($parentId);
     }
     $tree['MID_MenuID'] = $menuData['MID_MenuId'];
     $tree['MID_ParentId'] = $parentId;
     return $tree;
 }
Beispiel #7
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));
     }
 }