lang = TRUE; parent::__construct(); } public function displayForm($isMainTab=TRUE) { global $currentIndex, $cookie; parent::displayForm(); $iso = Language::getIsoById((int)($cookie->id_lang)); $divLangName = 'name¤legend¤description'; echo '
'; } public function display() { global $cookie, $currentIndex; $this->curshipping = null; if($id = Tools::getValue('id')) { $shipping = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'privatesale_shipping_lang` WHERE `id_shipping` = '.(int) $id); if(count($shipping) > 0) { $this->curshipping = array('id' => $id, 'name' => array()); foreach($shipping as $t) { $this->curshipping['name'][$t['id_lang']] = $t['value']; $this->curshipping['legend'][$t['id_lang']] = $t['legend']; $this->curshipping['description'][$t['id_lang']] = $t['description']; } } else { Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesShipping')); } } $this->displayForm(); echo ''; } function postProcess() { global $cookie, $currentIndex; if(Tools::isSubmit('submitShippingAdd')) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_shipping` VALUES ( DEFAULT ) '); $id_shipping = 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_shipping_lang` VALUES ( '.$id_shipping.', '.$language['id_lang'].', "'.pSQL($name).'" ) '); } else { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_shipping_lang` VALUES ( '.$id_shipping.', '.$language['id_lang'].', "" ) '); } } } elseif(Tools::isSubmit('submitShippingUpdate') && $id_shipping = (int) Tools::getValue('id_shipping')) { if(count(Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'privatesale_shipping` WHERE `id_shipping` = '.$id_shipping) ) > 0) { Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_shipping_lang` WHERE `id_shipping` = '.$id_shipping.' '); foreach(Language::getLanguages(FALSE) as $language) { if($name = Tools::getValue('name_'.$language['id_lang'])) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_shipping_lang` VALUES ( '.$id_shipping.', '.$language['id_lang'].', "'.pSQL($name).'" ) '); } else { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'privatesale_shipping_lang` VALUES ( '.$id_shipping.', '.$language['id_lang'].', "" ) '); } } } } elseif(isset($_GET['delete']) && $id_shipping = Tools::getValue('id')) { Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_shipping_lang` WHERE `id_shipping` = '.(int) $id_shipping.' '); Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_shipping_sale` WHERE `id_shipping` = '.(int) $id_shipping.' '); Db::getInstance()->Execute(' DELETE FROM `'._DB_PREFIX_.'privatesale_shipping` WHERE `id_shipping` = '.(int) $id_shipping.' '); Tools::redirectAdmin($currentIndex.'&token='.Tools::getAdminTokenLite('AdminPrivateSalesShipping')); } } }