diff --git a/admin-dev/tabs/AdminShipping.php b/admin-dev/tabs/AdminShipping.php deleted file mode 100644 index 43eedcbec..000000000 --- a/admin-dev/tabs/AdminShipping.php +++ /dev/null @@ -1,310 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class AdminShipping extends AdminTab -{ - private $_fieldsHandling; - - public function __construct() - { - $this->context = Context::getContext(); - $this->table = 'delivery'; - $this->_fieldsHandling = array( - 'PS_SHIPPING_HANDLING' => array('title' => $this->l('Handling charges'), 'suffix' => $this->context->currency, 'validation' => 'isPrice', 'cast' => 'floatval'), - 'PS_SHIPPING_FREE_PRICE' => array('title' => $this->l('Free shipping starts at'), 'suffix' => $this->context->currency, 'validation' => 'isPrice', 'cast' => 'floatval'), - 'PS_SHIPPING_FREE_WEIGHT' => array('title' => $this->l('Free shipping starts at'), 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'validation' => 'isUnsignedFloat', 'cast' => 'floatval'), - 'PS_SHIPPING_METHOD' => array('title' => $this->l('Billing'), 'validation' => 'isBool', 'cast' => 'intval')); - - parent::__construct(); - } - - public function postProcess() - { - /* Handling settings */ - if (Tools::isSubmit('submitHandling'.$this->table)) - { - if ($this->tabAccess['edit'] === '1') - { - /* Check required fields */ - foreach ($this->_fieldsHandling AS $field => $values) - if (($value = Tools::getValue($field)) == false AND (string)$value != '0') - $this->_errors[] = Tools::displayError('field').' '.$values['title'].' '.Tools::displayError('is required.'); - - /* Check field validity */ - foreach ($this->_fieldsHandling AS $field => $values) - if (Tools::getValue($field)) - { - $function = $values['validation']; - if (!Validate::$function(Tools::getValue($field))) - $this->_errors[] = Tools::displayError('field').' '.$values['title'].' '.Tools::displayError('is invalid.'); - } - - /* Update configuration values */ - if (!sizeof($this->_errors)) - { - foreach ($this->_fieldsHandling AS $field => $values) - { - $function = $values['cast']; - Configuration::updateValue($field, call_user_func($function, Tools::getValue($field))); - } - - Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - - /* Shipping fees */ - elseif (Tools::isSubmit('submitFees'.$this->table)) - { - if ($this->tabAccess['edit'] === '1') - { - if (($id_carrier = (int)(Tools::getValue('id_carrier'))) AND $id_carrier == ($id_carrier2 = (int)(Tools::getValue('id_carrier2')))) - { - $carrier = new Carrier($id_carrier); - if (Validate::isLoadedObject($carrier)) - { - /* Get configuration values */ - $shipping_method = $carrier->getShippingMethod(); - $rangeTable = $carrier->getRangeTable(); - - $carrier->deleteDeliveryPrice($rangeTable); - $currentList = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier); - - /* Build prices list */ - $priceList = array(); - foreach ($_POST AS $key => $value) - if (strstr($key, 'fees_')) - { - $tmpArray = explode('_', $key); - - $price = number_format(abs(str_replace(',', '.', $value)), 6, '.', ''); - $current = 0; - foreach ($currentList as $item) - if ($item['id_zone'] == $tmpArray[1] && $item['id_'.$rangeTable] == $tmpArray[2]) - $current = $item; - if ($current && $price == $current['price']) - continue; - - $priceList[] = array( - 'id_range_price' => ($shipping_method == Carrier::SHIPPING_METHOD_PRICE) ? (int)$tmpArray[2] : null, - 'id_range_weight' => ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) ? (int)$tmpArray[2] : null, - 'id_carrier' => (int)$carrier->id, - 'id_zone' => (int)$tmpArray[1], - 'price' => $price, - ); - } - /* Update delivery prices */ - $carrier->addDeliveryPrice($priceList); - Tools::redirectAdmin(self::$currentIndex.'&conf=6&id_carrier='.$carrier->id.'&token='.$this->token); - } - else - $this->_errors[] = Tools::displayError('An error occurred while updating fees (cannot load carrier object).'); - } - elseif (isset($id_carrier2)) - { - $_POST['id_carrier'] = $id_carrier2; - } - else - $this->_errors[] = Tools::displayError('An error occurred while updating fees (cannot load carrier object).'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - } - - public function display() - { - $this->displayFormHandling(); - $this->displayFormFees(); - } - - public function displayFormHandling() - { - $confKeys = $this->_fieldsHandling; - foreach ($confKeys AS $key => $confKey) - $getConf[] = $key; - $confValues = Configuration::getMultiple($getConf); - unset($confKeys['PS_SHIPPING_METHOD']); - - echo ' -
'; - } - - public function displayFormFees() - { - $carrierArray = array(); - $id_carrier = Tools::getValue('id_carrier'); - - $carriers = Carrier::getCarriers(Configuration::get('PS_LANG_DEFAULT'), true , false,false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); - foreach ($carriers AS $carrier) - if (!$carrier['is_free']) - $carrierArray[] = array( - 'id' => $carrier['id_carrier'], - 'display' => '' - ); - if (count($carrierArray)) - { - if (!$id_carrier) - $id_carrier = (int)$carrierArray[0]['id']; - $carrierSelected = new Carrier($id_carrier); - } - - echo '