コード例 #1
0
ファイル: RetailersObject.php プロジェクト: anunay/stentors
 public function save($id, $data, $langId)
 {
     $oAddress = new AddressObject();
     $profile = parent::findData(array('R_GenericProfileId' => $id));
     $currentAddr = $profile[0]['R_RetailerAddressId'];
     $retailerId = $profile[0]['R_RetailerProfileId'];
     $retailer = $data['retailerForm'];
     //If customer doesn't want to add data on website, set to false the field name
     switch ($retailer['isDistributeur']) {
         case 1:
             $retailerData = array('R_Status' => $retailer['isDistributeur']);
             break;
         case 2:
             if ($currentAddr > 0) {
                 $retailerData = array('R_Active' => $retailer['R_Active'], 'R_Status' => $retailer['isDistributeur']);
                 $oAddress->save($currentAddr, $retailer, 1);
                 $oAddress->save($currentAddr, $data['retailerFormEn'], 2);
             } else {
                 $addressId = $oAddress->insert($retailer, 1);
                 $oAddress->save($addressId, $data['retailerFormEn'], 2);
                 $retailerData = array('R_GenericProfileId' => $id, 'R_RetailerAddressId' => $addressId, 'R_Status' => $retailer['isDistributeur'], 'R_Active' => $retailer['R_Active']);
             }
             break;
         default:
             break;
     }
     parent::save($retailerId, $retailerData, $langId);
 }
コード例 #2
0
 public function save($id, $data, $langId)
 {
     $billId = 0;
     $shipId = 0;
     if (isset($data['addressFact'])) {
         $oAdress = new AddressObject();
         $addrBill = $data['addressFact'];
         $addrShip = $data['addressShipping'];
     }
     if (!empty($addrBill)) {
         $billId = $oAdress->save($addrBill['MP_BillingAddrId'], $addrBill, $langId);
         if ($addrShip['duplicate'] == 1) {
             $addrBill['A_Duplicate'] = $billId;
             $shipId = $oAdress->save($addrShip['MP_ShippingAddrId'], $addrBill, $langId);
         } else {
             $addrShip['A_Duplicate'] = 0;
             $shipId = $oAdress->save($addrShip['MP_ShippingAddrId'], $addrShip, $langId);
         }
         $data['MP_BillingAddrId'] = $billId;
         $data['MP_ShippingAddrId'] = $shipId;
     }
     $oYears = new YearsParticipateObject();
     $oYears->manageData($id, $data['MP_YearsParticipate']);
     $data['MP_BirthDate'] = $data['MP_BirthDateDt'];
     $years = $this->calculateAge($data['MP_BirthDate']);
     $data['MP_Age'] = $years;
     $data['MP_PassportExpiracyDate'] = $data['MP_PassportExpiracyDateDt'];
     if ($data['MP_BirthDate'] != $data['MP_PassportBirthDate']) {
         $data['MP_PassportBirthDate'] = $data['MP_BirthDate'];
     }
     parent::save($id, $data, $langId);
 }
コード例 #3
0
 public function save($id, $data, $langId)
 {
     $addrId = 0;
     if (isset($data[$this->_formDataName])) {
         $oAdress = new AddressObject();
         $addr = $data[$this->_formDataName];
         //            $addrShip = $data['addressShipping'];
     }
     if (!empty($addr)) {
         $addrId = $oAdress->save($data[$this->_addressField], $addr, $langId);
         //            if ($addrShip['duplicate'] == 1)
         //            {
         //                $addrBill['A_Duplicate'] = $billId;
         //                $shipId = $oAdress->save($addrShip['MP_ShippingAddrId'], $addrBill, $langId);
         //            }
         //            else
         //            {
         //                $addrShip['A_Duplicate'] = 0;
         //                $shipId = $oAdress->save($addrShip['MP_ShippingAddrId'], $addrShip, $langId);
         //            }
         if (empty($data[$this->_addressField])) {
             $data[$this->_addressField] = $addrId;
         }
         //            $data['MP_ShippingAddrId'] = $shipId;
     }
     parent::save($id, $data, $langId);
 }
コード例 #4
0
 public function save($id, $data, $langId)
 {
     $addrId = 0;
     if (isset($data[$this->_formDataName])) {
         $oAdress = new AddressObject();
         $addr = $data[$this->_formDataName];
         //            $addrShip = $data['addressShipping'];
     }
     if (!empty($addr)) {
         $addrId = $oAdress->save($data[$this->_addressField], $addr, $langId);
     } else {
         $addrId = $oAdress->insert($data[$this->_formDataName], $langId);
     }
     if (empty($data[$this->_addressField])) {
         $data[$this->_addressField] = $addrId;
     }
     parent::save($id, $data, $langId);
 }
コード例 #5
0
ファイル: IndexController.php プロジェクト: anunay/stentors
 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);
     }
 }
コード例 #6
0
ファイル: IndexController.php プロジェクト: anunay/stentors
 /**
  * Create a new account or edit an existing one.
  *
  * @return void
  */
 public function becomeclientAction()
 {
     // Test if the user is already connected.
     $account = Cible_FunctionsGeneral::getAuthentication();
     // Set the default status to an account creation and not editing one
     $_edit = false;
     // Instantiate the user profiles
     $profile = new MemberProfile();
     $newsletterProfile = new NewsletterProfile();
     $memberData = array();
     $accountValidate = true;
     //Set Default id for states and cities
     $config = Zend_Registry::get('config');
     $current_state = $config->address->default->states;
     $currentCity = '';
     $notifyAdmin = array();
     // Get users data if he is already logged
     if ($account) {
         if ($account['status'] == 2 || $this->_request->isPost()) {
             $_edit = true;
             $memberData = $profile->findMember(array('email' => $account['email']));
             $newsletterData = $newsletterProfile->findMember(array('email' => $account['email']));
             $oAddress = new AddressObject();
             if (!empty($memberData['addrBill'])) {
                 $billAddr = $oAddress->populate($memberData['addrBill'], $this->_defaultInterfaceLanguage);
             }
             if (!empty($memberData['addrShip'])) {
                 $shipAddr = $oAddress->populate($memberData['addrShip'], $this->_defaultInterfaceLanguage);
             }
             $oRetailer = new RetailersObject();
             $onWeb = $oRetailer->getRetailerInfos($memberData['member_id'], $this->_defaultInterfaceLanguage);
             $memberData['AI_FirstTel'] = $billAddr['AI_FirstTel'];
             $memberData['AI_SecondTel'] = $billAddr['AI_SecondTel'];
             $memberData['A_Fax'] = $billAddr['A_Fax'];
             if (isset($billAddr['AI_WebSite'])) {
                 $memberData['AI_WebSite'] = $billAddr['AI_WebSite'];
             }
             $memberData['addressFact'] = $billAddr;
             if (!$shipAddr['A_Duplicate']) {
                 $shipAddr['duplicate'] = 0;
             }
             $memberData['addressShipping'] = $shipAddr;
             $current_state = $billAddr['A_StateId'] . self::SEPARATOR . $shipAddr['A_StateId'] . self::SEPARATOR;
             $currentCity = $billAddr['A_CityId'] . self::SEPARATOR . $shipAddr['A_CityId'] . self::SEPARATOR;
             if ($onWeb && !empty($onWeb['R_AddressId'])) {
                 $webAddr = $oAddress->populate($onWeb['R_AddressId'], $this->_defaultInterfaceLanguage);
                 $webAddr['isDistributeur'] = $onWeb['R_Status'];
                 $memberData['addressDetaillant'] = $webAddr;
                 $current_state .= $webAddr['A_StateId'] . '||';
                 $currentCity .= $webAddr['A_CityId'] . '||';
             }
             //            if (empty($this->view->step))
             $this->view->headTitle($this->view->getClientText('account_modify_page_title'));
         }
     }
     $this->view->assign('accountValidate', $accountValidate);
     $options = $_edit ? array('mode' => 'edit') : array();
     $_edit ? $this->view->assign('mode', 'edit') : $this->view->assign('mode', 'add');
     // Instantiate the form for account management
     $form = new FormBecomeClient($options);
     //$_captcha = $form->getElement('captcha');
     $countries = Cible_FunctionsGeneral::getCountries();
     $addressFields = array();
     $return = $this->_getParam('return');
     if ($return && isset($_COOKIE['returnUrl'])) {
         $returnUrl = $_COOKIE['returnUrl'];
         $this->view->assign('return', $returnUrl);
     }
     $this->view->assign('selectedCity', $currentCity);
     $this->view->assign('selectedState', $current_state);
     $addressFields = array_unique($addressFields);
     // Test if the users has ticked the aggreement checkbox
     $agreementError = isset($_POST['termsAgreement']) && $_POST['termsAgreement'] != 1 ? true : false;
     if ($_edit) {
         $agreementError = false;
     }
     $this->view->assign('agreementError', $agreementError);
     // Actions when form is submitted
     if ($this->_request->isPost() && array_key_exists('submit', $_POST)) {
         $formData = $this->_request->getPost();
         // Test if the email already exists and password is the same
         if ($_edit) {
             $subFormI = $form->getSubForm('identification');
             if ($formData['identification']['email'] != $memberData['email']) {
                 $findEmail = $profile->findMember(array('email' => $formData['identification']['email']));
                 if ($findEmail) {
                     $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
                     $emailNotFoundInDBValidator->setMessage($this->view->getClientText('validation_message_email_already_exists'), 'recordFound');
                     $subFormI->getElement('email')->addValidator($emailNotFoundInDBValidator);
                 }
             }
             if (empty($formData['identification']['password']) && empty($formData['identification']['passwordConfirmation'])) {
                 $subFormI->getElement('password')->clearValidators()->setRequired(false);
                 $subFormI->getElement('passwordConfirmation')->clearValidators()->setRequired(false);
             }
         }
         $oAddress = new AddressObject();
         // Get the addresses data to insert
         $addressFact = $formData['addressFact'];
         $addressShipping = $formData['addressShipping'];
         //            $addressRetailer = $formData['addressDetaillant'];
         //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('addressDetaillant')->getElement('AI_Name')->clearValidators()->setRequired(false);
         if ($form->isValid($formData) && !$agreementError) {
             //remove addresses
             unset($formData['addressFact'], $formData['addressShipping'], $formData['addressDetaillant']);
             // merge all subform fields for the member profile table
             $formData = $this->_mergeFormData($formData);
             //get the last data to merge in the billing address
             //                $addressFact['A_Fax']        = $formData['A_Fax'];
             //                $addressFact['AI_FirstTel']  = $formData['AI_FirstTel'];
             //                $addressFact['AI_SecondTel'] = $formData['AI_SecondTel'];
             //                $addressFact['AI_WebSite']   = $formData['AI_WebSite'];
             if (!empty($formData['password'])) {
                 $password = $formData['password'];
                 $formData['password'] = md5($password);
             }
             if (!$_edit) {
                 // Do the processing here
                 $validatedEmail = Cible_FunctionsGeneral::generatePassword();
                 $path = Zend_Registry::get('web_root') . '/';
                 $hash = md5(session_id());
                 $duration = 0;
                 $cookie = array('lastName' => utf8_encode($formData['lastName']), 'firstName' => utf8_encode($formData['firstName']), 'email' => $formData['email'], 'hash' => $hash, 'status' => 0);
                 $formData['hash'] = $hash;
                 $formData['validatedEmail'] = $validatedEmail;
                 /// $this->save($memberId, $data);
                 //Add addresses process and retrive id for memberProfiles
                 $idBillingAddr = $oAddress->insert($addressFact, $this->_defaultInterfaceLanguage);
                 if ($addressShipping['duplicate'] == 1) {
                     $addressFact['A_Duplicate'] = $idBillingAddr;
                     $idShippingAddr = $oAddress->insert($addressFact, $this->_defaultInterfaceLanguage);
                 } else {
                     $idShippingAddr = $oAddress->insert($addressShipping, $this->_defaultInterfaceLanguage);
                 }
                 $formData['addrBill'] = $idBillingAddr;
                 $formData['addrShip'] = $idShippingAddr;
                 $profile->addMember($formData);
                 $memberData = $profile->findMember(array('email' => $formData['email']));
                 $idMember = $memberData['member_id'];
                 //                    if ($addressRetailer['isDistributeur'] == 2)
                 //                    {
                 //                        $oRetailer = new RetailersObject();
                 //                        $idRetailerAddr = $oAddress->insert($addressRetailer, $this->_defaultInterfaceLanguage);
                 //
                 //                        $retailerData = array(
                 //                            'R_GenericProfileId' => $idMember,
                 //                            'R_AddressId' => $idRetailAddr,
                 //                            'R_Status' => $addressRetailer['isDistributeur']
                 //                        );
                 //
                 //                        $oRetailer->insert($retailerData, $this->_defaultInterfaceLanguage);
                 //                    }
                 setcookie("authentication", json_encode($cookie), $duration, $path);
                 $data = array('firstName' => $memberData['firstName'], 'lastName' => $memberData['lastName'], 'email' => $memberData['email'], 'language' => $formData['language'], 'validatedEmail' => $formData['validatedEmail'], 'password' => $password);
                 $options = array('send' => true, 'isHtml' => true, 'to' => $formData['email'], 'moduleId' => $this->_moduleID, 'event' => 'newAccount', 'type' => 'email', 'recipient' => 'client', 'data' => $data);
                 $oNotification = new Cible_Notifications_Email($options);
                 //                    $notifyAdmin = array();
                 $this->view->assign('needConfirm', true);
                 $this->renderScript('index/confirm-email.phtml');
             } else {
                 if (empty($formData['password'])) {
                     unset($formData['password']);
                 }
                 $oAddress->save($billAddr['A_AddressId'], $addressFact, $this->_defaultInterfaceLanguage);
                 if ($addressShipping['duplicate'] == 1) {
                     $addressFact['A_Duplicate'] = $billAddr['A_AddressId'];
                     $oAddress->save($shipAddr['A_AddressId'], $addressFact, $this->_defaultInterfaceLanguage);
                 } else {
                     $addressShipping['A_Duplicate'] = 0;
                     $oAddress->save($shipAddr['A_AddressId'], $addressShipping, $this->_defaultInterfaceLanguage);
                 }
                 //                    $retailerData = array(
                 //                        'R_Status' => $addressRetailer['isDistributeur']);
                 //
                 //                    switch ($addressRetailer['isDistributeur'])
                 //                    {
                 //                        case 1:
                 //                            if (!empty($onWeb))
                 //                            {
                 //                                $retailerData = array(
                 //                                    'R_Status' => $addressRetailer['isDistributeur']);
                 //                                $oRetailer->save($onWeb['R_ID'], $retailerData, $this->_defaultInterfaceLanguage);
                 //                            }
                 //                            break;
                 //                        case 2:
                 //                            if (!empty($webAddr))
                 //                            {
                 //                                $retailerData = array(
                 //                                    'R_Status' => $addressRetailer['isDistributeur']);
                 //                    $oAddress->save($webAddr['A_AddressId'], $addressRetailer, $this->_defaultInterfaceLanguage);
                 //                    $oRetailer->save($onWeb['R_ID'], $retailerData, $this->_defaultInterfaceLanguage);
                 //                            }
                 //                            else
                 //                            {
                 //                                $addressId = $oAddress->insert($addressRetailer, $this->_defaultInterfaceLanguage);
                 //                                $retailerData = array(
                 //                                    'R_GenericProfileId' => $memberID,
                 //                                    'R_AddressId' => $addressId,
                 //                                    'R_Status' => $addressRetailer['isDistributeur']
                 //                                );
                 //                                $oRetailer->insert($retailerData, $this->_defaultInterfaceLanguage);
                 //                            }
                 //                            break;
                 //                        default:
                 //                            break;
                 //                    }
                 $profile->updateMember($memberData['member_id'], $formData);
                 if ($formData['email'] != $memberData['email']) {
                     $validatedEmail = Cible_FunctionsGeneral::generatePassword();
                     $formData['validatedEmail'] = $validatedEmail;
                     $profile->updateMember($memberData['member_id'], $formData);
                     $data = array('firstName' => $formData['firstName'], 'lastName' => $formData['lastName'], 'email' => $formData['email'], 'language' => $formData['language'], 'validatedEmail' => $formData['validatedEmail']);
                     $options = array('send' => true, 'isHtml' => true, 'to' => $formData['email'], 'moduleId' => $this->_moduleID, 'event' => 'editResend', 'type' => 'email', 'recipient' => 'client', 'data' => $data);
                     $oNotification = new Cible_Notifications_Email($options);
                     $this->view->assign('needConfirm', true);
                     $this->renderScript('index/confirm-email.phtml');
                 } else {
                     $authentication = json_decode($_COOKIE['authentication'], true);
                     $path = Zend_Registry::get('web_root') . '/';
                     $duration = 0;
                     $cookie = array('lastName' => utf8_encode($formData['lastName']), 'firstName' => utf8_encode($formData['firstName']), 'email' => $authentication['email'], 'language' => $formData['language'], 'hash' => $authentication['hash'], 'status' => 2);
                     setcookie("authentication", json_encode($cookie), $duration, $path);
                     $this->view->assign('messages', array($this->view->getCibleText('form_account_modified_message')));
                     $this->view->assign('updatedName', $formData['firstName']);
                 }
                 $data = array('identification' => $memberData, 'addressFact' => $billAddr, 'addressShipping' => $shipAddr);
                 $notifyAdmin = $this->_testDataForNotification($this->_request->getPost(), $data);
                 // Notify admin
                 if (count($notifyAdmin) > 0) {
                     $data = array('firstName' => $formData['firstName'], 'lastName' => $formData['lastName'], 'email' => $formData['email'], 'NEWID' => $memberData['member_id'], 'language' => $formData['language'], 'validatedEmail' => $formData['validatedEmail'], 'form' => $form->populate($_POST), 'notifyAdmin' => $notifyAdmin);
                     $options = array('send' => true, 'isHtml' => true, 'moduleId' => $this->_moduleID, 'event' => 'editAccount', 'type' => 'email', 'recipient' => 'admin', 'data' => $data);
                     $oNotification = new Cible_Notifications_Email($options);
                 }
                 $this->_redirect(Cible_FunctionsCategories::getPagePerCategoryView(0, 'modify_inscription', $this->_moduleID));
             }
             if (!empty($formData['newsletterSubscription'])) {
                 $newsletterCategory = $formData['newsletterSubscription'] ? $this->_config->newsletter->default->categoryID : '';
                 $newsletterProfile->updateMember($memberData['member_id'], array('newsletter_categories' => $newsletterCategory));
             }
         } else {
             $form->populate($_POST);
         }
     } else {
         if ($_edit && empty($this->view->step)) {
             if (!empty($newsletterData['newsletter_categories'])) {
                 $memberData['newsletterSubscription'] = 1;
             }
             $form->populate($memberData);
         }
     }
     $this->view->assign('form', $form);
 }