* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7263 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminRangePrice extends AdminTab { public function __construct() { $this->table = 'range_price'; $this->className = 'RangePrice'; $this->lang = false; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'id_range_price' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'carrier_name' => array('title' => $this->l('Carrier'), 'align' => 'center', 'width' => 25, 'filter_key' => 'ca!name'), 'delimiter1' => array('title' => $this->l('From'), 'width' => 86, 'price' => true, 'align' => 'right'), 'delimiter2' => array('title' => $this->l('To'), 'width' => 86, 'price' => true, 'align' => 'right')); $this->_join = 'LEFT JOIN '._DB_PREFIX_.'carrier ca ON (ca.`id_carrier` = a.`id_carrier`)'; $this->_select = 'ca.`name` AS carrier_name'; $this->_where = 'AND ca.`deleted` = 0'; parent::__construct(); } public function displayListContent($token = NULL) { foreach ($this->_list as $key => $list) if ($list['carrier_name'] == '0') $this->_list[$key]['carrier_name'] = Configuration::get('PS_SHOP_NAME'); parent::displayListContent($token); } public function postProcess() { if (isset($_POST['submitAdd'.$this->table]) AND Tools::getValue('delimiter1') >= Tools::getValue('delimiter2')) $this->_errors[] = Tools::displayError('Invalid range'); else parent::postProcess(); } public function displayForm($isMainTab = true) { global $currentIndex; parent::displayForm(); if (!($obj = $this->loadObject(true))) return; $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $carrierArray = array(); $carriers = Carrier::getCarriers((int)(Configuration::get('PS_LANG_DEFAULT')), true , false,false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $id_carrier = Tools::getValue('id_carrier', $obj->id_carrier); foreach ($carriers AS $carrier) if (!$carrier['is_free']) $carrierArray[] = '*'; echo '
'.($obj->id ? '' : '').'
'.$this->l('Price ranges').'
'; if (count($carrierArray)) { echo '

'.$this->l('Carrier to which this range will be applied').'

'; } else echo '
'.$this->l('There isn\'t any carrier available for a price range.').'
'; echo '
'.$currency->getSign('left').''.$currency->getSign('right').'*

'.$this->l('Range start (included)').'

'.$currency->getSign('left').''.$currency->getSign('right').'*

'.$this->l('Range end (excluded)').'

* '.$this->l('Required field').'
'; } }