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 '
'; } 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 ' '; } 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')); } } }