* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminOrdersStates extends AdminTab { public function __construct() { $this->table = 'order_state'; $this->className = 'OrderState'; $this->lang = true; $this->edit = true; $this->delete = true; $this->colorOnBackground = true; $this->fieldImageSettings = array('name' => 'icon', 'dir' => 'os'); $this->imageType = 'gif'; $this->fieldsDisplay = array( 'id_order_state' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 130), 'logo' => array('title' => $this->l('Icon'), 'align' => 'center', 'image' => 'os', 'orderby' => false, 'search' => false), 'send_email' => array('title' => $this->l('Send e-mail to customer'), 'align' => 'center', 'icon' => array('1' => 'enabled.gif', '0' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false), 'invoice' => array('title' => $this->l('Invoice'), 'align' => 'center', 'icon' => array('1' => 'enabled.gif', '0' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false), 'template' => array('title' => $this->l('E-mail template'), 'width' => 100)); parent::__construct(); } public function postProcess() { global $cookie; if (Tools::isSubmit('submitAdd'.$this->table)) { $_POST['invoice'] = Tools::getValue('invoice'); $_POST['logable'] = Tools::getValue('logable'); $_POST['send_email'] = Tools::getValue('send_email'); $_POST['hidden'] = Tools::getValue('hidden'); if (!$_POST['send_email']) { $languages = Language::getLanguages(false); foreach ($languages AS $language) $_POST['template_'.$language['id_lang']] = ''; } parent::postProcess(); } elseif (isset($_GET['delete'.$this->table])) { $orderState = new OrderState((int)($_GET['id_order_state']), $cookie->id_lang); if (!$orderState->isRemovable()) $this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.'); else parent::postProcess(); } elseif (isset($_POST['submitDelorder_state'])) { foreach ($_POST[$this->table.'Box'] AS $selection) { $orderState = new OrderState((int)($selection), $cookie->id_lang); if (!$orderState->isRemovable()) { $this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.'); break; } } if (empty($this->_errors)) parent::postProcess(); } else parent::postProcess(); } private function getTemplates($iso_code) { $array = array(); if (!file_exists(PS_ADMIN_DIR.'/../mails/'.$iso_code)) return false; $templates = scandir(PS_ADMIN_DIR.'/../mails/'.$iso_code); foreach ($templates AS $template) if (!strncmp(strrev($template), 'lmth.', 5)) $array[] = substr($template, 0, -5); return $array; } public function displayForm($isMainTab = true) { global $currentIndex; parent::displayForm(); if (!($obj = $this->loadObject(true))) return; echo '
'; } }