/** * Render processing form && process saving data. */ public function getContent() { $html = ""; if (Tools::isSubmit('submit')) { if (!sizeof($this->_postErrors)) { $definedConfigs = array('theme' => '', 'class' => ''); foreach ($definedConfigs as $config => $key) { if (strlen($this->name . '_' . $config) >= 32) { echo $this->name . '_' . $config; } else { Configuration::updateValue($this->name . '_' . $config, Tools::getValue($config), true); } } $html .= '<div class="conf confirm">' . $this->l('Settings updated successful') . '</div>'; } else { foreach ($this->_postErrors as $err) { $html .= '<div class="alert error">' . $err . '</div>'; } } } elseif (isset($_GET['submitDeleteBlock'])) { if (Tools::getValue('id_loffc_block') && Validate::isLoadedObject($obj = new LofBlock(Tools::getValue('id_loffc_block'))) && $obj->delete()) { Tools::redirectAdmin($this->base_config_url . '&lofconf=1'); } else { Tools::redirectAdmin($this->base_config_url . '&lofconf=2'); } } elseif (Tools::isSubmit('submitDeleteData')) { $shops = Tools::getValue('shops'); $items = Db::getInstance()->ExecuteS(' SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_item`'); foreach ($items as $item) { $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_item_shop` WHERE `id_loffc_block_item` = ' . (int) $item['id_loffc_block_item'] . ' AND `id_shop` IN (' . implode(',', $shops) . ')'; Db::getInstance()->execute($sql); $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_item_shop` WHERE `id_loffc_block_item` = ' . (int) $item['id_loffc_block_item']; if (!($result = Db::getInstance()->executes($sql))) { $obj = new LofItem((int) $item['id_loffc_block_item']); $obj->delete(); } } $blocks = Db::getInstance()->ExecuteS(' SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block`'); if ($blocks) { foreach ($blocks as $block) { $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $block['id_loffc_block'] . ' AND `id_shop` IN (' . implode(',', $shops) . ')'; Db::getInstance()->execute($sql); $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $block['id_loffc_block']; if (!($result = Db::getInstance()->executes($sql))) { $obj = new LofBlock((int) $block['id_loffc_block']); $obj->delete(); } } } } $this->_params = new LofFooterCustomParams($this->name, $this->hookAssign); if (Tools::getValue('lofconf') == 1) { $html .= '<div class="conf confirm">' . $this->l('Delete Block successful') . '</div>'; } elseif (Tools::getValue('lofconf') == 2) { $html .= '<div class="alert error">' . $this->l('Delete Block error') . '</div>'; } if (sizeof($this->_postErrors)) { foreach ($this->_postErrors as $err) { $html .= '<div class="alert error">' . $err . '</div>'; } } return $html . $this->_getFormConfig(); }