Ejemplo n.º 1
0
 /**
  * public function edit
  *
  */
 public function editParams()
 {
     $this->onlyAdmin(true);
     if ($this->formSubmitted('shopParamsEditor')) {
         //Saves the datas
         // Bills bottom text
         $this->setParam('billBottomText', stripslashes($_POST['billBottomText']));
         if ($this->getParam('activateShop', true) != isset($_POST['activateShop'])) {
             $renewSitemap = true;
         } else {
             $renewSitemap = false;
         }
         // Enables tthe only shop
         $this->setParam('activateShop', isset($_POST['activateShop']));
         if (isset($_POST['activateShop'])) {
             $this->helper->addClassesSharedMethods('sh_html', 'construct', __CLASS__);
         } else {
             $this->helper->removeClassesSharedMethods('sh_html', 'construct', __CLASS__);
         }
         sh_browser::setHidden(SH_SHOPIMAGES_FOLDER, !isset($_POST['activateShop']));
         // Format of the prices and currency
         $this->setParam('monney_format', $_POST['monney_format']);
         $this->setParam('currency', $_POST['currency']);
         // Taxes
         $this->setParam('taxes', $_POST['taxes']);
         $this->setParam('taxRate', str_replace(array(',', '%'), array('.', ''), $_POST['taxRate']));
         $this->setParam('showTaxSymbol', isset($_POST['showTaxSymbol']));
         $this->setParam('paymentRequiresConnexion', isset($_POST['paymentRequiresConnexion']));
         $this->setParam('forceUserToCheckConditions', isset($_POST['forceUserToCheckConditions']));
         $this->setParam('conditions', $_POST['conditions']);
         // State of the cart
         if ($this->linker->payment->getActivePaymentModesCount() > 0) {
             $this->setParam('selling>activated', isset($_POST['sellingActivated']));
         }
         $command_mail = str_replace(array(',', ';', '/', '\\', '"'), "\n", stripslashes($_POST['command_mail']));
         $command_mail = explode("\n", $command_mail);
         $mailer = $this->linker->mailer->get();
         if (is_array($command_mail)) {
             foreach ($command_mail as $oneMail) {
                 if ($mailer->checkAddress($oneMail)) {
                     $checkedMails .= $separator . $oneMail;
                     $separator = "\n";
                 }
             }
         }
         if ($checkedMails == '') {
             $datas = $this->linker->user->getData();
             $checkedMails = $datas['mail'];
         }
         $this->setParam('command_mail', $checkedMails);
         // Manages the quantity
         $this->setParam('showQuantity', isset($_POST['showQuantity']));
         $this->setParam('hideNullQuantityProducts', isset($_POST['hideNullQuantityProducts']));
         // Saves the commands parts
         if (trim($_POST['command_logo']) != self::$default_logo) {
             $logo = trim($_POST['command_logo']);
         } else {
             $logo = '';
         }
         $this->setI18n(self::I18N_BILLFOOTER, $_POST['command_footer']);
         $this->setI18n(self::I18N_BILLHEADLINE, $_POST['command_headLine']);
         $this->setI18n(self::I18N_BILLHEADLINE, $_POST['command_headLine']);
         $this->setI18n(self::I18N_BILLCUSTOMERSERVICE, $_POST['command_customerService']);
         $this->setParam('command>logo', $logo);
         $this->setParam('command>companyName', stripslashes($_POST['command_companyName']));
         $this->setParam('command>companyAddress', stripslashes($_POST['command_companyAddress']));
         $this->setParam('billColor', $_POST['billColor']);
         $this->setParam('bill_number_format', $_POST['bill_number_format']);
         // Finaly writes the params
         $this->writeParams();
         if ($renewSitemap) {
             $this->linker->sitemap->renew();
         }
     }
     if ($this->getParam('activateShop', true) === true) {
         $values['activateShop']['checked'] = 'checked';
     }
     if ($this->linker->payment->getActivePaymentModesCount() > 0) {
         if ($this->getParam('selling>activated') === true) {
             $values['sellingActivated']['checked'] = 'checked';
         }
     } else {
         $values['sellingActivated']['checked'] = 'disabled';
     }
     if ($this->getParam('forceUserToCheckConditions', true)) {
         $values['forceUserToCheckConditions']['checked'] = 'checked';
     }
     $values['conditions']['file'] = $this->getParam('conditions', '');
     $values['command_mail']['value'] = $this->getParam('command_mail');
     if ($this->getParam('showQuantity') === true) {
         $values['showQuantity']['checked'] = 'checked';
     }
     if ($this->getParam('hideNullQuantityProducts') === true) {
         $values['hideNullQuantityProducts']['checked'] = 'checked';
     }
     $values['command']['bill_number_format'] = $this->getParam('bill_number_format', '[YEAR4][MONTH2][DAYOFMONTH2]-[INCREMENT3]');
     // Monney format
     $monneyFormats = $this->getParam('monney_formats_listing');
     $monneyFormat = $this->getParam('monney_format', array());
     foreach (array_keys($monneyFormats) as $name) {
         if ($name == $monneyFormat) {
             $state = 'selected';
         } else {
             $state = '';
         }
         $values['monneyFormats'][] = array('name' => $name, 'state' => $state);
     }
     // Currency
     $currency = $this->getParam('currency');
     $currencies = $this->getParam('currencies', array());
     foreach ($currencies as $cName => $cValue) {
         if ($cName == $currency) {
             $state = 'selected';
         } else {
             $state = '';
         }
         $values['currencies'][] = array('id' => $cName, 'name' => $cValue['name'], 'value' => $cValue['name'] . ' (' . $cValue['symbol'] . ')', 'state' => $state);
     }
     // Taxes
     $values['taxes'][0]['value'] = 'TTC';
     $values['taxes'][0]['text'] = $this->getI18n('prices_showTTC');
     $values['taxes'][1]['value'] = 'HT';
     $values['taxes'][1]['text'] = $this->getI18n('prices_showHT');
     if ($this->getParam('taxes', 'TTC') === 'HT') {
         $values['taxes'][1]['selected'] = 'selected';
         $ht = true;
     } else {
         $values['taxes'][0]['selected'] = 'selected';
     }
     $values['tax']['rate'] = $this->getParam('taxRate', 19.6);
     if ($this->getParam('showTaxSymbol', false)) {
         $values['showTaxSymbol']['state'] = 'checked';
     }
     if ($this->getParam('paymentRequiresConnexion', true)) {
         $values['paymentRequiresConnexion']['state'] = 'checked';
     }
     $values['activateMail']['checked'] = 'disabled';
     $values['activateCom']['checked'] = 'disabled';
     $billColors = $this->getParam('billColors');
     foreach ($billColors as $id => $billColor) {
         $values['billColors'][] = array('id' => $id, 'color' => dechex($billColor[0]) . dechex($billColor[1]) . dechex($billColor[2]));
     }
     $values['bill']['color'] = $this->getParam('billColor', 0);
     // Saves the commands parts
     $logo = $this->getParam('command>logo', '');
     $values['command']['logo'] = $logo;
     $values['command']['companyName'] = $this->getParam('command>companyName');
     $values['command']['companyAddress'] = $this->getParam('command>companyAddress');
     $values['billForm']['bottomText'] = $this->getParam('billBottomText');
     $this->render('edit_params', $values);
 }