lang = TRUE; parent::__construct(); } public function displayForm($isMainTab=TRUE) { global $currentIndex, $cookie; parent::displayForm(); $iso = Language::getIsoById((int)($cookie->id_lang)); $divLangName = 'name¤short_name¤value¤value_max'; echo '
'.$this->l('Edit a delay').''; echo '
'; foreach($this->_languages as $language) { echo '
'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'name'); echo '
'; echo '
'; foreach($this->_languages as $language) { echo '
'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'short_name'); echo '
'; echo '
'; foreach($this->_languages as $language) { echo '
'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'value'); echo '
'; echo '
'; foreach($this->_languages as $language) { echo '
'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'value_max'); echo '
'; echo '

* Jours ouvrés

'; echo '
curdelay !== NULL? '': ' disabled="disabled"').' id="submitDelayUpdate" />
'; echo '
'; } public function display() { global $cookie, $currentIndex; $this->curdelay = null; if($id = Tools::getValue('id')) { $delay = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'privatesale_delay_lang` WHERE `id_delay` = '.(int) $id); if(count($delay) > 0) { $this->curdelay = array('id' => $id, 'name' => array()); foreach($delay as $t) { $this->curdelay['name'][$t['id_lang']] = $t['name']; $this->curdelay['short_name'][$t['id_lang']] = $t['short_name']; $this->curdelay['value'][$t['id_lang']] = $t['value']; $this->curdelay['value_max'][$t['id_lang']] = $t['value_max']; } } else { Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesDelay')); } } $this->displayForm(); echo '
'.$this->l('Delays list').' '; foreach(Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'privatesale_delay_lang` WHERE `id_lang` = '.(int) $cookie->id_lang.' ORDER BY `id_delay` ASC ') as $delay) { echo ''; } echo '
'.$this->l('ID').' '.$this->l('Name').' '.$this->l('Short name').' '.$this->l('Value').' '.$this->l('Value Max').' '.$this->l('Actions').'
'.$delay['id_delay'].' '.$delay['name'].' '.$delay['short_name'].' '.$delay['value'].' '.$delay['value_max'].'
'; } function postProcess() { global $cookie, $currentIndex; if(Tools::isSubmit('submitDelayAdd')) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_delay` VALUES ( DEFAULT ) '); $id_delay = Db::getInstance()->Insert_ID(); foreach(Language::getLanguages(FALSE) as $language) { if($name = Tools::getValue('name_'.$language['id_lang'])) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_delay_lang` VALUES ( '.$id_delay.', '.$language['id_lang'].', "'.pSQL($name).'", "'.pSQL(Tools::getValue('short_name_'.$language['id_lang'])).'", '.(int) Tools::getValue('value_'.$language['id_lang']).', '.(int) Tools::getValue('value_max'.$language['id_lang']).' ) '); } else { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_delay_lang` VALUES ( '.$id_delay.', '.$language['id_lang'].', "", "", 0, 0 ) '); } } } elseif(Tools::isSubmit('submitDelayUpdate') && $id_delay = (int) Tools::getValue('id_delay')) { if(count(Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'privatesale_delay` WHERE `id_delay` = '.$id_delay) ) > 0) { Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_delay_lang` WHERE `id_delay` = '.$id_delay.' '); foreach(Language::getLanguages(FALSE) as $language) { if($name = Tools::getValue('name_'.$language['id_lang'])) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_delay_lang` VALUES ( '.$id_delay.', '.$language['id_lang'].', "'.pSQL($name).'", "'.pSQL(Tools::getValue('short_name_'.$language['id_lang'])).'", '.(int) Tools::getValue('value_'.$language['id_lang']).', '.(int) Tools::getValue('value_max_'.$language['id_lang']).' ) '); } else { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_delay_lang` VALUES ( '.$id_delay.', '.$language['id_lang'].', "", "", 0, 0 ) '); } } } } elseif(isset($_GET['delete']) && $id_delay = Tools::getValue('id')) { Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_delay_lang` WHERE `id_delay` = '.(int) $id_delay.' '); Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_delay` WHERE `id_delay` = '.(int) $id_delay.' '); Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesDelay')); } } }