lang = TRUE; parent::__construct(); } public function displayForm($isMainTab=TRUE) { global $currentIndex, $cookie; parent::displayForm(); $iso = Language::getIsoById((int)($cookie->id_lang)); $divLangName = 'nameĀ¤format'; echo '
'; } public function display() { global $cookie, $currentIndex; $this->curfield = null; if($id = Tools::getValue('id')) { $field = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'privatesale_extrafield_lang` WHERE `id_field` = '.(int) $id); if(count($field) > 0) { $field_info = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'privatesale_extrafield` WHERE `id_field` = '.(int) $id); $this->curfield = array('id' => $id, 'type' => $field_info['type'], 'blank' => $field_info['blank'], 'name' => array()); foreach($field as $f) { $this->curfield['name'][$f['id_lang']] = $f['name']; $this->curfield['format'][$f['id_lang']] = $f['format']; } } else { Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesExtraFields')); } } $this->displayForm(); echo ''; } function postProcess() { global $cookie, $currentIndex; if(Tools::isSubmit('submitFieldAdd')) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_extrafield` VALUES ( DEFAULT, '.(int) Tools::getValue('type').', '.(int) (bool) Tools::getValue('blank').' ) '); $id_field = 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_extrafield_lang` VALUES ( '.$id_field.', '.$language['id_lang'].', "'.pSQL($name).'", "'.pSQL(Tools::getValue('format_'.$language['id_lang'], ''), TRUE).'" ) '); } else { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_extrafield_lang` VALUES ( '.$id_field.', '.$language['id_lang'].', "", "" ) '); } } } elseif(Tools::isSubmit('submitFieldUpdate') && $id_field = (int) Tools::getValue('id_field')) { if(count(Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'privatesale_extrafield` WHERE `id_field` = '.$id_field) ) > 0) { Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'privatesale_extrafield` SET `type` = '.(int) Tools::getValue('type').', `blank` = '.(int) (bool) Tools::getValue('blank').' WHERE `id_field` = '.$id_field.' '); Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_extrafield_lang` WHERE `id_field` = '.$id_field.' '); foreach(Language::getLanguages(FALSE) as $language) { if($name = Tools::getValue('name_'.$language['id_lang'])) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_extrafield_lang` VALUES ( '.$id_field.', '.$language['id_lang'].', "'.pSQL($name).'", "'.pSQL(Tools::getValue('format_'.$language['id_lang'], ''), TRUE).'" ) '); } else { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_extrafield_lang` VALUES ( '.$id_field.', '.$language['id_lang'].', "", "" ) '); } } } } elseif(isset($_GET['delete']) && $id_field = Tools::getValue('id')) { Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_extrafield_lang` WHERE `id_field` = '.(int) $id_field.' '); Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` WHERE `id_field` = '.(int) $id_field.' '); Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_extrafield` WHERE `id_field` = '.(int) $id_field.' '); Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesExtraFields')); } } }