Beispiel #1
0
 public function printRegistrationAction()
 {
     $id = (int) $this->_getParam('id');
     $page = $this->_getParam('page');
     $lang = $this->_getParam('lang');
     if (!$lang) {
         $this->_registry->currentEditLanguage = $this->_defaultEditLanguage;
         $langId = $this->_defaultEditLanguage;
     } else {
         $langId = Cible_FunctionsGeneral::getLanguageID($lang);
         $this->_registry->currentEditLanguage = $langId;
     }
     if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) {
         $firstPData = array();
         $secPData = array();
         $oMember = new MemberProfilesObject();
         $oGeneric = new GenericProfilesObject();
         $oMedic = new MedicalProfilesObject();
         $oDiseasesD = new DiseasesDetailsObject();
         $oParent = new ParentProfilesObject();
         $oAddress = new AddressObject();
         $sections = $oMember->_sectionSrc();
         $memberData = $oMember->populate($id, $langId);
         $data = $oGeneric->populate($memberData['MP_GenericProfileId'], $langId);
         $medicData = $oMedic->populate($memberData['MP_GenericProfileId'], $langId);
         $allergies = $oMedic->_allergySrc();
         $diseases = $oMedic->_diseasesSrc();
         $diseasesDetails = $oDiseasesD->setFilters(array($oDiseasesD->getForeignKey() => $id));
         $diseasesDetails = $oDiseasesD->getAll();
         $memberData = array_merge($memberData, $data, $medicData);
         $this->view->title = 'Membre : ' . $memberData['GP_LastName'] . ' ' . $memberData['GP_FirstName'];
         $resp = $oParent->_listRespSrc();
         $roles = $oParent->_parentsProfileSrc();
         if (!empty($data['MP_FirstParent'])) {
             $firstPData = $oParent->populate($memberData['MP_FirstParent'], $langId);
             if (empty($firstPData)) {
                 $firstPData = $oParent->populate($memberData['MP_GenericProfileId'], $langId);
             }
             $data = $oGeneric->populate($firstPData['PP_GenericProfileId'], $langId);
             $firstPData = array_merge($firstPData, $data);
             $address = $oAddress->populate($firstPData['PP_AddressId'], $langId);
             $firstPData['address'] = $address;
         }
         if (!empty($data['MP_SecondParent'])) {
             $secPData = $oParent->populate($memberData['MP_SecondParent'], $langId);
             $data = $oGeneric->populate($secPData['PP_GenericProfileId'], $langId);
             $secPData = array_merge($secPData, $data);
             $address = $oAddress->populate($secPData['PP_AddressId'], $langId);
             $secPData['address'] = $address;
         }
         $this->view->dataMember = $memberData;
         $this->view->parents = array($firstPData, $secPData);
         $this->view->sections = $sections;
         $this->view->resp = $resp;
         $this->view->roles = $roles;
         $this->view->allergies = $allergies;
         $this->view->diseases = $diseases;
         $this->view->diseasesDetails = $diseasesDetails;
         $this->view->typeMedic = $oDiseasesD->_typeMedicSrc();
     }
 }
Beispiel #2
0
 public function editAction()
 {
     /*         * ********************************* */
     // variable
     $webAddr = array();
     $addressFields = array();
     $memberID = $this->_request->getParam('ID');
     $baseDir = $this->view->baseUrl();
     $billAddr = array();
     $shipAddr = array();
     $current_state = '';
     $currentCity = '';
     $returnModule = $this->_request->getParam('returnModule');
     $returnAction = $this->_request->getParam('returnAction');
     if ($returnModule != '' && $returnAction != '') {
         $cancelUrl = $this->view->url(array('module' => $returnModule, 'action' => $returnAction, 'ID' => null, 'returnModule' => null, 'returnAction' => null));
     } else {
         $cancelUrl = $this->view->url(array('action' => 'list', 'ID' => null));
     }
     $this->view->assign('memberID', $memberID);
     /*         * ********************************* */
     // newsletter categories
     $newsletterProfil = new NewsletterProfile();
     $newsletterMemberDetails = $newsletterProfil->getMemberDetails($memberID);
     //$this->view->assign('newsletterMemberDetails',$newsletterMemberDetails);
     $newsletterCategories = $this->view->GetAllNewsletterCategories();
     $newsletterCategories = $newsletterCategories->toArray();
     if (is_array($newsletterMemberDetails) && array_key_exists('newsletter_categories', $newsletterMemberDetails) && $newsletterMemberDetails['newsletter_categories'] != "") {
         $memberNewsletterCategories = $newsletterMemberDetails['newsletter_categories'];
         $memberNewsletterCategories = explode(',', $memberNewsletterCategories);
         $memberCat = array();
         foreach ($memberNewsletterCategories as $memberCategory) {
             $memberCat["chkNewsletter{$memberCategory}"] = 1;
         }
     } else {
         $memberCat = array();
     }
     $this->view->assign('memberNewsletterCategories', $memberCat);
     $this->view->assign('newsletterCategories', $newsletterCategories);
     // Form
     $form = new FormProfile(array('baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'langId' => $this->_defaultInterfaceLanguage, 'mode' => 'edit'));
     $this->view->assign('form', $form);
     $genericProfil = new GenericProfile();
     $genericMemberDetails = $genericProfil->getMemberDetails($memberID);
     $this->view->assign('genericMemberDetails', $genericMemberDetails);
     $membersProfil = new MemberProfile();
     $lang = $this->_defaultInterfaceLanguage;
     $membersDetails = $membersProfil->getMemberDetails($memberID);
     //Retailers data
     if ($form->getSubForm('membersForm')) {
         //            $oRetailers = new RetailersObject();
         $oAddress = new AddressObject();
         //            $retailerData = $oRetailers->getAll(null, true, $memberID);
         //            if (count($retailerData))
         //                $retailerAddr = $oAddress->getAll(null, true, $retailerData[0]['R_AddressId']);
         if (!empty($membersDetails['addrBill'])) {
             $billAddr = $oAddress->populate($membersDetails['addrBill'], $lang);
         }
         if (!empty($membersDetails['addrShip'])) {
             $shipAddr = $oAddress->populate($membersDetails['addrShip'], $lang);
         }
         //            $oRetailer = new RetailersObject();
         //            $onWeb = $oRetailer->getRetailerInfos($membersDetails['member_id'], $lang);
         //            if ($onWeb && !empty($onWeb['R_AddressId']))
         //            {
         //                $webAddrFr = $oAddress->populate($onWeb['R_AddressId'], 1);
         //                $webAddrEn = $oAddress->populate($onWeb['R_AddressId'], 2);
         //                $webAddr['isDistributeur-1'] = $onWeb['R_Status'];
         //                $form->getSubForm('retailerForm')->getElement('isDistributeur')->setValue($onWeb['R_Status']);
         //            }
         if (!empty($billAddr)) {
             $membersDetails['addressFact'] = $billAddr;
             //                $membersDetails['AI_FirstTel'] = $billAddr['AI_FirstTel'];
             //                $membersDetails['AI_SecondTel'] = $billAddr['AI_SecondTel'];
             //                $membersDetails['A_Fax'] = $billAddr['A_Fax'];
         }
         if (isset($shipAddr['A_Duplicate']) && !$shipAddr['A_Duplicate']) {
             $shipAddr['duplicate'] = 0;
         }
         if (!empty($shipAddr)) {
             $membersDetails['addressShipping'] = $shipAddr;
         }
         //            $membersDetails['retailerForm']    = $webAddrFr;
         //            $membersDetails['retailerFormEn']  = $webAddrEn;
         $memberForm = $form->getSubForm('membersForm');
         $stateBill = $memberForm->getSubForm('addressFact')->getElement('A_StateId');
         $stateShip = $memberForm->getSubForm('addressShipping')->getElement('A_StateId');
         $countries = Cible_FunctionsGeneral::getCountries();
         if (count($webAddr) > 0) {
             $membersDetails['AI_WebSite'] = $billAddr['AI_WebSite'];
             $current_state = $billAddr['A_StateId'] . $this->_separ . $shipAddr['A_StateId'] . $this->_separ . $webAddrFr['A_StateId'] . $this->_separ;
             $currentCity = $billAddr['A_CityId'] . $this->_separ . $shipAddr['A_CityId'] . $this->_separ . $webAddrFr['A_CityId'] . $this->_separ;
         } elseif (!empty($billAddr) && !empty($shipAddr)) {
             $current_state = $billAddr['A_StateId'] . $this->_separ . $shipAddr['A_StateId'] . $this->_separ;
             $currentCity = $billAddr['A_CityId'] . $this->_separ . $shipAddr['A_CityId'] . $this->_separ;
         }
     }
     if ($this->_request->isPost()) {
         $data = $this->_request->getPost();
         $currentCity = $data['retailerForm']['A_CityId'];
         $current_state = $data['membersForm']['addressFact']['A_StateId'] . $this->_separ;
         $current_state .= $data['membersForm']['addressShipping']['A_StateId'] . $this->_separ;
         $current_state .= $data['retailerForm']['A_StateId'];
         //            ksort($data);
         //            $tmpPostAddr   = $this->_statesCitiesList($data, $form);
         //            $currentCity   = substr($tmpPostAddr['currentCity'], 0, strlen($tmpPostAddr['currentCity'])-1);
         //            $current_state = substr($tmpPostAddr['currentState'], 0, strlen($tmpPostAddr['currentState'])-1);
     }
     $this->view->assign('selectedCity', $currentCity);
     $this->view->assign('selectedState', $current_state);
     $addressFields = array_unique($addressFields);
     //            if( $memberForm->getElement("isRetailer")->isChecked() ) {
     //                $this->view->headStyle()->appendStyle('dd.validatedBy { display: none }');
     //            }
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->getSubForm('membersForm')) {
             $oAddress = new AddressObject();
             // Get the addresses data to insert
             $addressFact = $formData['membersForm']['addressFact'];
             $addressShipping = $formData['membersForm']['addressShipping'];
             //                $addressRetailer   = $formData['retailerForm'];
             //                $addressRetailerEn = $formData['retailerFormEn'];
             //Remove data form form if the shipping address is the same as bill
             if ($addressShipping['duplicate'] == 1) {
                 $subFormShip = $form->getSubForm('addressShipping');
                 foreach ($subFormShip as $key => $value) {
                     $value->clearValidators()->setRequired(false);
                 }
                 unset($formData['addressShipping']);
             }
             //If customer doesn't want to add data on website, set to false the field name
             //                if ($addressRetailer['isDistributeur'] == 1)
             //                {
             //                    $form->getSubForm('retailerForm')->getElement('AI_Name')->clearValidators()->setRequired(false);
             //                    $form->getSubForm('retailerFormEn')->getElement('AI_Name')->clearValidators()->setRequired(false);
             //                }
             //                $form->removeSubForm('addressShipping');
         }
         if ($form->isValid($formData)) {
             if (array_key_exists('genericForm', $formData)) {
                 $genericForm = $formData['genericForm'];
                 $genericProfil = new GenericProfile();
                 $langId = $genericForm['language'];
                 $members = $genericProfil->findMembers(array('email' => $genericForm['email']));
                 if (count($members) == 1 and $members[0]['member_id'] == $memberID or count($members) == 0) {
                     $genericProfil->updateMember($memberID, $genericForm);
                 } else {
                     $form->getSubForm('genericForm')->getElement('email')->addError($this->view->getCibleText('validation_message_used_email'));
                     $cancelUrl = '';
                 }
             }
             if (array_key_exists('newsletterForm', $formData)) {
                 $newsletterForm = $formData['newsletterForm'];
                 $newsletterProfile = new NewsletterProfile();
                 $cat = "";
                 foreach ($newsletterForm as $item => $val) {
                     if ($val == 1) {
                         if ($cat == "") {
                             $cat = str_replace('chkNewsletter', '', $item);
                         } else {
                             $cat .= "," . str_replace('chkNewsletter', '', $item);
                         }
                     }
                 }
                 $newsletterProfile->updateMember($memberID, array('newsletter_categories' => $cat));
             }
             if (array_key_exists('membersForm', $formData)) {
                 $membersForm = $formData['membersForm'];
                 $langId = $this->_defaultInterfaceLanguage;
                 if (!empty($membersForm['password'])) {
                     $membersForm['password'] = md5($membersForm['password']);
                 } else {
                     $membersForm['password'] = $membersDetails['password'];
                 }
                 $memberProfil = new MemberProfile();
                 //get the last data to merge in the billing address
                 //                    $addressFact['A_Fax'] = $membersForm['A_Fax'];
                 //                    $addressFact['AI_FirstTel'] = $membersForm['AI_FirstTel'];
                 //                    $addressFact['AI_SecondTel'] = $membersForm['AI_SecondTel'];
                 //                    $addressFact['AI_WebSite'] = $membersForm['AI_WebSite'];
                 if (empty($billAddr['A_AddressId'])) {
                     $billAddr['A_AddressId'] = $oAddress->insert($addressFact, $langId);
                     $membersForm['addressFact']['addrBill'] = $billAddr['A_AddressId'];
                     $membersForm['addrBill'] = $billAddr['A_AddressId'];
                 } else {
                     $oAddress->save($billAddr['A_AddressId'], $addressFact, $langId);
                 }
                 if ($addressShipping['duplicate'] == 1) {
                     $addressFact['A_Duplicate'] = $billAddr['A_AddressId'];
                     if (empty($shipAddr['A_AddressId'])) {
                         $shipAddrId = $oAddress->insert($addressFact, $langId);
                         $membersForm['addressShipping']['addrShip'] = $shipAddrId;
                         $membersForm['addrShip'] = $shipAddrId;
                     } else {
                         $oAddress->save($shipAddr['A_AddressId'], $addressFact, $langId);
                     }
                 } else {
                     $addressShipping['A_Duplicate'] = 0;
                     if (empty($shipAddr['A_AddressId'])) {
                         $shipAddrId = $oAddress->insert($addressShipping, $langId);
                         $membersForm['addressShipping']['addrShip'] = $shipAddrId;
                         $membersForm['addrShip'] = $shipAddrId;
                     } else {
                         $oAddress->save($shipAddr['A_AddressId'], $addressShipping, $langId);
                     }
                 }
                 $memberProfil->updateMember($memberID, $membersForm);
                 //If customer doesn't want to add data on website, set to false the field name
                 //                    switch ($addressRetailer['isDistributeur'])
                 //                    {
                 //                        case 1:
                 //                            if (!empty($onWeb))
                 //                            {
                 //                                $retailerData = array(
                 //                                    'R_Status' => $addressRetailer['isDistributeur']);
                 //                                $oRetailer->save($onWeb['R_ID'], $retailerData, $langId);
                 //                            }
                 //                            break;
                 //                        case 2:
                 //                            if (!empty($webAddrFr))
                 //                            {
                 //                                $retailerData = array(
                 //                                    'R_Status' => $addressRetailer['isDistributeur']);
                 //                                $oAddress->save($webAddrFr['A_AddressId'], $addressRetailer, 1);
                 //                                $oAddress->save($webAddrFr['A_AddressId'], $addressRetailerEn, 2);
                 //                                $oRetailer->save($onWeb['R_ID'], $retailerData, $langId);
                 //                            }
                 //                            else
                 //                            {
                 //                                $addressId = $oAddress->insert($addressRetailer, 1);
                 //                                $oAddress->save($addressId, $addressRetailerEn, 2);
                 //                                $retailerData = array(
                 //                                    'R_GenericProfileId' => $memberID,
                 //                                    'R_AddressId' => $addressId,
                 //                                    'R_Status' => $addressRetailer['isDistributeur']
                 //                                );
                 //                                $oRetailer->insert($retailerData, $langId);
                 //                            }
                 //                            break;
                 //                        default:
                 //                            break;
                 //                    }
             }
             if ($cancelUrl != '') {
                 $this->_redirect(str_replace($baseDir, '', $cancelUrl));
             }
         }
     } else {
         $this->view->assign('membersDetails', $membersDetails);
         if ($genericMemberDetails) {
             $form->populate($genericMemberDetails);
         }
         if ($newsletterMemberDetails) {
             $form->populate($newsletterMemberDetails);
         }
         if ($membersDetails) {
             $form->populate($membersDetails);
         }
         if ($memberCat) {
             $form->populate($memberCat);
         }
         //                if( $form->getSubForm('membersForm')->getElement("isRetailer")->isChecked() ) {
         //                    $this->view->headStyle()->appendStyle('dd.validatedBy { display: none }');
         //                }
         $this->view->assign('form', $form);
     }
 }
Beispiel #3
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));
     }
 }