diff --git a/admin-dev/ajax-tab.php b/admin-dev/ajax-tab.php index 77a09f2b8..f3aa7caea 100755 --- a/admin-dev/ajax-tab.php +++ b/admin-dev/ajax-tab.php @@ -36,6 +36,8 @@ if (!isset($_POST['controller']) && isset($_POST['tab'])) $_POST['controller'] = strtolower($_POST['tab']); if (!isset($_REQUEST['controller']) && isset($_REQUEST['tab'])) $_REQUEST['controller'] = strtolower($_REQUEST['tab']); - +// Retrocompatibility with 1.4 +$_REQUEST['ajaxMode'] = $_POST['ajaxMode'] = $_GET['ajaxMode'] = $_REQUEST['ajax'] = $_POST['ajax'] = $_GET['ajax'] = 1; + Dispatcher::getInstance()->setControllerDirectories(array(_PS_ADMIN_DIR_.'/tabs/', _PS_ADMIN_CONTROLLER_DIR_)); Dispatcher::getInstance()->dispatch(); \ No newline at end of file diff --git a/admin-dev/tabs/AdminCustomerThreads.php b/admin-dev/tabs/AdminCustomerThreads.php index 941259f6f..7e50e20f9 100644 --- a/admin-dev/tabs/AdminCustomerThreads.php +++ b/admin-dev/tabs/AdminCustomerThreads.php @@ -120,7 +120,6 @@ class AdminCustomerThreads extends AdminTab } if (isset($_POST['id_employee_forward'])) { - // Todo: need to avoid doubles $messages = Db::getInstance()->executeS(' SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname FROM '._DB_PREFIX_.'customer_thread ct diff --git a/admin-dev/tabs/AdminDiscounts.php b/admin-dev/tabs/AdminDiscounts.php deleted file mode 100644 index 5f49c14f3..000000000 --- a/admin-dev/tabs/AdminDiscounts.php +++ /dev/null @@ -1,532 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7060 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class AdminDiscounts extends AdminTab -{ - public function __construct() - { - $this->context = Context::getContext(); - $this->table = 'discount'; - $this->className = 'Discount'; - $this->lang = true; - $this->edit = true; - $this->delete = true; - $this->_select = 'dtl.`name` AS discount_type, - IF(a.id_discount_type = '.(int)Discount::PERCENT.', CONCAT(a.value, " %"), - IF(a.id_discount_type = '.(int)Discount::AMOUNT.', CONCAT(a.value, " ", c.sign), - "--")) as strvalue'; - $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'currency` c ON (c.`id_currency` = a.`id_currency`) - LEFT JOIN `'._DB_PREFIX_.'discount_type` dt ON (dt.`id_discount_type` = a.`id_discount_type`) - LEFT JOIN `'._DB_PREFIX_.'discount_type_lang` dtl ON (dt.`id_discount_type` = dtl.`id_discount_type` AND dtl.`id_lang` = '.(int)$this->context->language->id.')'; - - $typesArray = array(); - $types = Discount::getDiscountTypes($this->context->language->id); - foreach ($types AS $type) - $typesArray[$type['id_discount_type']] = $type['name']; - - $this->fieldsDisplay = array( - 'id_discount' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('Code'), 'width' => 85, 'prefix' => '', 'suffix' => '', 'filter_key' => 'a!name'), - 'shop_name' => array('title' => $this->l('Shop'), 'width' => 85, 'filter_key' => 's!name'), - 'description' => array('title' => $this->l('Description'), 'width' => 100, 'filter_key' => 'b!description'), - 'discount_type' => array('title' => $this->l('Type'), 'type' => 'select', 'select' => $typesArray, 'filter_key' => 'dt!id_discount_type'), - 'strvalue' => array('title' => $this->l('Value'), 'width' => 50, 'align' => 'right', 'filter_key' => 'a!value'), - 'quantity' => array('title' => $this->l('Qty'), 'width' => 40, 'align' => 'right'), - 'date_to' => array('title' => $this->l('To'), 'width' => 60, 'type' => 'date', 'align' => 'right'), - 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), - ); - - $this->optionsList = array( - 'general' => array( - 'title' => $this->l('Discounts options'), - 'fields' => array( - 'PS_VOUCHERS' => array('title' => $this->l('Enable vouchers:'), 'desc' => $this->l('Allow the use of vouchers in shop'), 'cast' => 'intval', 'type' => 'bool'), - ), - ), - ); - - parent::__construct(); - } - - protected function copyFromPost(&$object, $table) - { - parent::copyFromPost($object, $table); - - $object->cumulable = (!isset($_POST['cumulable']) ? false : true); - $object->cumulable_reduction = (!isset($_POST['cumulable_reduction']) ? false : true); - } - - public function postProcess() - { - $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; - - if ($discountName = Tools::getValue('name') AND Validate::isDiscountName($discountName) AND Discount::discountExists($discountName, Tools::getValue('id_discount'))) - $this->_errors[] = Tools::displayError('A voucher of this name already exists. Please choose another name.'); - - if (Tools::getValue('submitAdd'.$this->table)) - { - if (Tools::getValue('id_discount_type') == 0) - $this->_errors[] = Tools::displayError('Please set a type for this voucher.'); - if (Tools::getValue('id_discount_type') == Discount::AMOUNT AND Tools::getValue('id_currency') == 0) - $this->_errors[] = Tools::displayError('Please set a currency for this voucher.'); - if ((Tools::getValue('id_discount_type') == Discount::PERCENT || Tools::getValue('id_discount_type') == 2) && !Tools::getValue('value')) - $this->_errors[] = Tools::displayError('Please set a amount for this voucher.'); - if (!Validate::isBool_Id(Tools::getValue('id_target'))) - $this->_errors[] = Tools::displayError('Invalid customer or group ID field'); - else - { - $rules = explode('_', Tools::getValue('id_target')); - /* In form, there is one field for two differents fields in object*/ - $_POST[($rules[0] ? 'id_group' : 'id_customer')] = $rules[1]; - } - /* Checking fields validity */ - $this->validateRules(); - if (!sizeof($this->_errors)) - { - $id = (int)(Tools::getValue($this->identifier)); - /* Object update */ - if (isset($id) AND !empty($id)) - { - if ($this->tabAccess['edit'] === '1') - { - $object = new $this->className($id); - if (Validate::isLoadedObject($object)) - { - /* Specific to objects which must not be deleted */ - if ($this->deleted AND $this->beforeDelete($object)) - { - $object->deleted = 1; - $object->update(); - $objectNew = new $this->className(); - $this->copyFromPost($objectNew, $this->table); - $result = $objectNew->add(); - if (Validate::isLoadedObject($objectNew)) - $this->afterDelete($objectNew, $object->id); - } - else - { - if (($categories = Tools::getValue('categoryBox')) === false OR (!empty($categories) AND !is_array($categories))) - $this->_errors[] = Tools::displayError('Please set a category for this voucher.'); - $this->copyFromPost($object, $this->table); - $result = $object->update(true, false, $categories); - } - if (!$result) - $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.''; - elseif ($this->postImage($object->id)) - { - if ($back = Tools::getValue('back')) - Tools::redirectAdmin(urldecode($back).'&conf=4'); - if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1') - Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&updatescene&token='.$token); - Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&token='.$token); - } - } - else - $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - - /* Object creation */ - else - { - if ($this->tabAccess['add'] === '1') - { - $object = new $this->className(); - $this->copyFromPost($object, $this->table); - $categories = Tools::getValue('categoryBox', null); - if (!$object->add(true, false, $categories)) - $this->_errors[] = Tools::displayError('An error occurred while creating object.').' '.$this->table.''; - elseif (($_POST[$this->identifier] = $object->id /* voluntary */) AND $this->postImage($object->id) AND $this->_redirect) - { - if ($customer = new Customer($object->id_customer) AND Validate::isLoadedObject($customer)) - { - if (Validate::isEmail($customer->email)) - { - $data = array( - '{firstname}' => $customer->firstname, - '{lastname}' => $customer->lastname, - '{email}' => $customer->email, - '{voucher_num}' => $object->name); - - @Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'voucher_new', Mail::l('New voucher'), $data, $customer->email, $customer->firstname.' '.$customer->lastname); - } - } - elseif ($group = new Group($object->id_group) AND Validate::isLoadedObject($group)) - { - $customer = null; - $customers = $group->getCustomers(); - - if ($customers) - foreach ($customers as $customer) - { - $data = array( - '{firstname}' => $customer['firstname'], - '{lastname}' => $customer['lastname'], - '{email}' => $customer['email'], - '{voucher_num}' => $object->name); - - @Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'voucher_new', Mail::l('New voucher'), $data, $customer['email'], $customer['firstname'].' '.$customer['lastname']); - } - } - - Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&token='.$token); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to add here.'); - } - } - $this->_errors = array_unique($this->_errors); - } - else - return parent::postProcess(); - } - - public function displayForm($isMainTab = true) - { - parent::displayForm(); - - if (!($obj = $this->loadObject(true))) - return; - - echo ' - -