';
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ public function mostrarCategorias($name, $prefijo, $idParentCategoria = 2) {
+ $sql = ' SELECT '
+ . ' c.id_category, c.id_parent, cl.name, s.id_category AS checked, s.margen '
+ . ' FROM '
+ . ' ' . _DB_PREFIX_ . 'category AS c '
+ . ' INNER JOIN ' . _DB_PREFIX_ . 'category_lang AS cl '
+ . ' ON '
+ . ' cl.id_category = c.id_category '
+ . ' AND cl.id_lang = ' . $this->idLang . ''
+ . ' AND c.id_shop_default = cl.id_shop '
+ . ' AND c.id_shop_default = ' . $this->idShop . ''
+ . ' LEFT JOIN ' . _DB_PREFIX_ . $prefijo . 'categorias AS s '
+ . ' ON s.id_category = c.id_category '
+ . ' WHERE '
+ . ' c.id_parent = ' . $idParentCategoria . ' '
+ . ' ORDER BY '
+ . ' c.id_parent, c.id_category ';
+ $categorias = Db::getInstance()->executeS($sql);
+ $html = '
';
+
+ $html .= '';
+ $this->formulario .= $html;
+ return $this;
+ }
+
+ private function getHijosTable($categoria, &$html, &$num, $prefijo) {
+ $numInterno = $num;
+ $sqlHijos = ' SELECT '
+ . ' c.id_category, c.id_parent, cl.name, s.id_category AS checked, s.margen '
+ . ' FROM '
+ . ' ' . _DB_PREFIX_ . 'category AS c '
+ . ' INNER JOIN ' . _DB_PREFIX_ . 'category_lang AS cl '
+ . ' ON '
+ . ' cl.id_category = c.id_category '
+ . ' AND cl.id_lang = ' . $this->idLang . ' '
+ . ' AND c.id_shop_default = cl.id_shop '
+ . ' AND c.id_shop_default = ' . $this->idShop . ' '
+ . ' LEFT JOIN ' . _DB_PREFIX_ . $prefijo . 'categorias AS s '
+ . ' ON s.id_category = c.id_category '
+ . ' WHERE '
+ . ' c.id_parent=' . $categoria['id_category'];
+
+ $categoriasHijos = Db::getInstance()->executeS($sqlHijos);
+ $num++;
+ foreach ($categoriasHijos AS $categoriaHijo) {
+ $checked = "";
+ $porcentaje = "";
+ if (!empty($categoriaHijo['checked']) && $categoriaHijo['checked'] != null) {
+ $checked = ' checked="checked"';
+ $porcentaje = $categoriaHijo['margen'];
+ }
+ $numClase = $num;
+ $html .= '
';
+ $this->getHijos($categoriaHijo, $html, $num);
+ }
+ $num = $numInterno;
+ }
+
+ /**
+ *
+ * @param string $name
+ * @param string $text
+ * @param int $defaultValue
+ * @param string $title
+ * @param boolean $active
+ * @param boolean $chosen
+ * @return $this
+ */
+ public function createSelectCategory($name, $text, $defaultValue, $title = '', $active = true, $chosen = false) {
+ $categories = Category::getHomeCategories($this->idLang, $active);
+ $html = '';
+ $html .= '
';
+ if ($chosen) {
+ $html .= '';
+ }
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ private function getHijos($id_parent, $defaultValue, &$html, &$num, $active) {
+ $numInterno = $num;
+ $categories = Category::getChildren($id_parent, $this->idLang, $active);
+ if (!$categories) {
+ return;
+ }
+ $num++;
+ foreach ($categories AS $category) {
+ $selected = '';
+ if ($category['id_category'] == $defaultValue) {
+ $selected = ' selected="selected"';
+ }
+ $html .= '
';
+ $this->getHijos($category['id_category'], $defaultValue, $html, $num, $active);
+ }
+ $num = $numInterno;
+ return true;
+ }
+
+ /**
+ * Crea un upload File.
+ * @param string $name Nombre del boton
+ * @param string $text Texto informativo
+ * @param string $title Titulo
+ * @return $this
+ */
+ public function createFormUploadFile($name, $text, $title = '') {
+ $html = '';
+ $html .= '
';
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ /**
+ * Crea una tabla dinamica.
+ * @param string $name Identificador de la tabla.
+ * @param string $table Nombre de la tabla en la base de datos.
+ * @param string[] $campos Nombres de los campos en base de datos.
+ * @param string[] $camposBusqueda Nombres de los campos en base de datos para las busquedas.
+ * @param string $url Ruta base.
+ * @param string $serverfile Archivo de destino en el servidor.
+ * @param string $contenidoCabecera Los "tr" para la cabecera.
+ * @param string[] $codigoFormateadores [id del formateador => Contenido de la funcion formateadora, recibe los parametros column y row].
+ * @param string $codigoEventoLoad Contenido de la funcion del evento load. La tabla viene en la variable grid. Tambien se dispone de e.
+ * @return $this
+ */
+ function createTableAjax($name, $table, $campos, $camposBusqueda, $url, $serverfile, $contenidoCabecera, $codigoFormateadores = array(), $codigoEventoLoad = '') {
+ $html = '
';
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ private function addExtras($extras) {
+ $html = '';
+ if ($extras && is_array($extras)) {
+ foreach ($extras AS $indice => $valor) {
+ $html .= $indice . '="' . $valor . '"';
+ }
+ }
+ return $html;
+ }
+
+ public function __toString() {
+ return $this->renderForm(true);
+ }
+
+ public function createCheckBoxManufacturer($name, $defaultValue) {
+ $manufacturers = Manufacturer::getManufacturers();
+ $html = '';
+ $numElementos = count($manufacturers);
+ $elementos = ceil($numElementos / 3);
+ $intercambio = array_flip($defaultValue);
+ $i = 0;
+ $html .= '
';
+ $html .= '
';
+
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param int $id_lang
+ * @param string $name
+ * @param string $text
+ * @param array $values
+ * @param string $title
+ * @return $this
+ */
+ public function createOptionStatuses($id_lang, $name, $text, $values, $title = '') {
+ $status = OrderState::getOrderStates($id_lang);
+ $html .= '
';
+
+ $this->formulario .= $html;
+ return $this;
+ }
+
+ /**
+ *
+ * @param string $name
+ * @param string $text
+ * @param int $defaultValue
+ * @param string $title
+ * @return $this
+ */
+ public function createSelectStatuses($idLang, $name, $text, $defaultValue, $title = '') {
+ $status = OrderState::getOrderStates($idLang);
+ $html = '
';
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string $name
+ * @param string $text
+ * @param int $defaultValue
+ * @param string $title
+ * @return $this
+ */
+ public function createSelectFeatures($idLang, $name, $text, $defaultValue, $title = '') {
+ $features = Feature::getFeatures($idLang);
+
+ $html = '
';
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string $name
+ * @param string $text
+ * @param int $defaultValue
+ * @param string $title
+ * @return $this
+ */
+ public function createSelectFeaturesValues($idLang, $name, $text, $defaultValue, $value, $title = '') {
+ $features = FeatureValueCore::getFeatureValuesWithLang($idLang, $value);
+ $html .= '
';
+ $this->formulario .= $html;
+
+ return $this;
+ }
+
+ /**
+ * Genera un select a partir de un array asociativo.
+ * @param string $name
+ * @param string $text
+ * @param array $datos
+ * @param string $claveId
+ * @param string $claveValores
+ * @param mixed $selectedValue
+ * @param string $title
+ * @param array $extras
+ * @return $this
+ */
+ public function createFormSelectFromArray($name, $text, $datos, $claveId, $claveValores, $selectedValue, $title = '', $extras = null) {
+ $datosFormateados = array();
+ foreach ($datos as $dato) {
+ $datosFormateados[$dato[$claveId]] = $dato[$claveValores];
+ }
+
+ return $this->createFormSelect($name, $text, $datosFormateados, $selectedValue, $title, $extras);
+ }
+
+}
diff --git b/imaxAcordeon.php a/imaxAcordeon.php
new file mode 100644
index 0000000..713665b
--- /dev/null
+++ a/imaxAcordeon.php
@@ -0,0 +1,58 @@
+context = Context::getContext();
+ $this->_path = $modulePath;
+ $this->addCSS('acordeon.css');
+ $this->addJS('acordeon.js');
+ }
+
+ /**
+ * CREA UN ACORDEN
+ * @param string $titulo Titulo del acordeon
+ * @param string $contenido Html con todo el contenido
+ * @param boolean $interno True si va a estar dentro de otro acordeon
+ */
+ function renderAcordeon($titulo, $contenido, $interno = false) {
+ $class = 'acordeon';
+ if ($interno != false) {
+ $class = 'acordeonInterno';
+ }
+ $html = '';
+ $html = '
';
+ $html .= '' . $titulo . ' ';
+ $html .= '';
+ $html .= $contenido;
+ $html .= ' ';
+ $html .= ' ';
+ return $html;
+ }
+
+ private function addCSS($css) {
+ $tab = Tools::getValue('tab', 0);
+ if (!$tab || ($tab && $tab != 'AdminSelfUpgrade')) {
+ if ($this->context->controller instanceof stdClass) {
+ $this->context->controller = new AdminModulesController();
+ }
+ $this->context->controller->addCss($this->_path . 'acordeon/' . $css, 'all');
+ }
+ return;
+ }
+
+ private function addJS($js) {
+ $tab = Tools::getValue('tab', 0);
+ if (!$tab || ($tab && $tab != 'AdminSelfUpgrade')) {
+ if ($this->context->controller instanceof stdClass) {
+ $this->context->controller = new AdminModulesController();
+ }
+ $this->context->controller->addJs($this->_path . 'acordeon/' . $js);
+ }
+ return;
+ }
+
+}
diff --git b/imaxaddcatbyfeature.php a/imaxaddcatbyfeature.php
new file mode 100644
index 0000000..0f766d6
--- /dev/null
+++ a/imaxaddcatbyfeature.php
@@ -0,0 +1,394 @@
+name = 'imaxaddcatbyfeature';
+ $this->tab = 'administration';
+ $this->version = '1.1';
+ $this->author = 'Informax';
+ $this->need_instance = 0;
+ $this->idManual = '';
+ $this->forceCheck = 0;
+ $this->sufijo = self::prefijo;
+ parent::__construct();
+ $this->displayName = $this->l('Informax add to category by feature');
+ $this->description = $this->l('Informax add to category by feature');
+
+ if (version_compare(_PS_VERSION_, '1.7.0.0 ', '>=')) {
+ $this->versionPS = 17;
+ $context = Context::getContext();
+ $this->idShop = $context->shop->id;
+ $this->idLang = $context->language->id;
+ } elseif (version_compare(_PS_VERSION_, '1.6.0.0 ', '>=')) {
+ $this->versionPS = 16;
+ $context = Context::getContext();
+ $this->idShop = $context->shop->id;
+ $this->idLang = $context->language->id;
+ } elseif (version_compare(_PS_VERSION_, '1.5.0.0 ', '>=')) {
+ $this->versionPS = 15;
+ $context = Context::getContext();
+ $this->idShop = $context->shop->id;
+ $this->idLang = $context->language->id;
+ } else {
+ $this->_html .= $this->l("La version minima de funcionamiento para nuestros modulos es la 1.5");
+ }
+ }
+
+ public function install() {
+ $directorioAdmin = getcwd();
+ if (is_file(dirname(__FILE__) . '/' . $this->name . '_cron.php') && !@copy(dirname(__FILE__) . '/imaxaddcatbyfeature_cron.php', $directorioAdmin . '/imaxaddcatbyfeature_cron.php')) {
+ $this->_errors[] = $this->l('Ha fallado al copiar el fichero de cron');
+ return false;
+ }
+ if (is_file(dirname(__FILE__) . '/' . $this->name . '_cron.php.imax') && !@copy(dirname(__FILE__) . '/imaxaddcatbyfeature_cron.php.imax', $directorioAdmin . '/imaxaddcatbyfeature_cron.php.imax')) {
+ $this->_errors[] = $this->l('Ha fallado al copiar el fichero de cron ofuscado');
+ return false;
+ }
+
+ include(dirname(__FILE__) . '/configuration.php');
+ foreach ($configuracion AS $indice => $valor) {
+ if (!Configuration::updateGlobalValue($indice, $valor)) {
+ return false;
+ }
+ }
+
+ if (!parent::install())
+ return false;
+
+ foreach ($hooks as $hook) {
+ if (!$this->registerHook($hook)) {
+ $this->_errors[] = $this->l('Ha fallado la instalacion del hook:') . ' ' . $hook;
+ return false;
+ }
+ }
+
+ include(dirname(__FILE__) . '/sql-install.php');
+ foreach ($sql as $s) {
+ if (!Db::getInstance()->execute($s)) {
+ $this->_errors[] = $this->l("Error al ejecutar") . $s;
+ return false;
+ }
+ }
+
+ if (!$this->installTab()) {
+ $this->_errors[] = $this->l('Error al instalar el tab');
+ return false;
+ }
+
+ return true;
+ }
+
+ public function uninstall() {
+ if (!parent::uninstall()) {
+ return false;
+ }
+
+ include(dirname(__FILE__) . '/sql-unninstall.php');
+ foreach ($sql as $s) {
+ if (!Db::getInstance()->execute($s)) {
+ $this->_errors[] = $this->l("Error al ejecutar") . $s;
+ return false;
+ }
+ }
+ $directorioAdmin = getcwd();
+
+ if (!unlink($directorioAdmin . '/imaxaddcatbyfeature_cron.php')) {
+ $this->_errors[] = $this->l('Error al borrar el fichero de Cron');
+ return false;
+ }
+
+ if (!$this->uninstallTab()) {
+ $this->_errors[] = $this->l('Error al eliminar el tab');
+ return false;
+ }
+
+ include(dirname(__FILE__) . '/configuration.php');
+ foreach ($configuracion AS $indice => $valor) {
+ if (Configuration::getGlobalValue($indice) !== FALSE) {
+ if (!Configuration::deleteByName($indice)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public function getContent() {
+ $this->getTxtFiles();
+ $this->addCSS('css.css');
+ //$this->addJS('jquery.dynatree.min.js');
+ $this->addJS('functions.js');
+ $this->addCSS('../skin/ui.dynatree.css');
+ $this->addCSS('publi.css');
+ $this->_html .= $this->createHelpHeader();
+ if (!empty($_POST))
+ $this->_html .= $this->_postProcess();
+
+ $this->_displayForm();
+ $this->_html .= $this->getModuleFooter();
+ return $this->_html;
+ }
+
+ private function _postProcess() {
+ $accion = Tools::getValue("accion");
+ $this->idTab = Tools::getValue("idTab");
+ $html = "";
+ switch ($accion) {
+ case 'gestionLicencia':
+ $this->forceCheck = 1;
+ if (Configuration::updateGlobalValue(self::prefijo . 'LICENCIA', trim(Tools::getValue('licencia')))) {
+ $html .= $this->displayConfirmation($this->l('Licencia guardada correctamente.'));
+ } else {
+ $html .= $this->displayError($this->l('Ha ocurrido un error al guardar la licencia.'));
+ }
+ break;
+
+ case 'configuracion':
+ if (Configuration::updateGlobalValue(self::prefijo . 'DIAS_NOVEDAD', trim(Tools::getValue('diasNovedad', 7))) &&
+ Configuration::updateGlobalValue(self::prefijo . 'CATS_NOVEDAD', serialize(explode(',', Tools::getValue('catList'))))) {
+ $html .= $this->displayConfirmation($this->l('Configuracion guardada correctamente.'));
+ } else {
+ $html .= $this->displayError($this->l('Ha ocurrido un error al guardar la configuracion.'));
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return $html;
+ }
+
+ public function _displayForm() {
+ return $this->displayFormTrait(array('_configuracion' => $this->l('Configuracion'), '_mostrarLicencia' => $this->l('Licencia')), '');
+ }
+
+ private function _mostrarLicencia() {
+ return $this->mostrarLicenciaTrait(2);
+ }
+
+ private function _configuracion() {
+ include_once(dirname(__FILE__) . '/functionsForm.php');
+ include_once(dirname(__FILE__) . '/imaxAcordeon.php');
+ $diasNovedad = Configuration::getGlobalValue(self::prefijo . 'DIAS_NOVEDAD');
+ $catsNovedad = unserialize(Configuration::getGlobalValue(self::prefijo . 'CATS_NOVEDAD'));
+ $token = Configuration::getGlobalValue(self::prefijo . 'TOKEN');
+ $arbol = '';
+ //
+
+ $acordeon = new imaxAcordeon($this->_path);
+
+ $form = new imaxForm($this, $this->_path);
+ $form->createHidden("accion", "configuracion");
+ $form->createHidden("idTab", "1");
+ $form->createHidden("catList", "");
+ $form->addToForm($this->l('Buscador:') .$this->crearSelectCategorias());
+
+ $form->createSubmitButton('opcionesConfiguracion', $this->l('Guardar'));
+ $html = $acordeon->renderAcordeon($this->l('Configuracion'), $form->renderForm());
+
+ unset($form);
+ $form = new imaxForm($this, $this->_path);
+ $form->createHidden("accion", "generar_token");
+ $form->createHidden("idTab", "1");
+
+ $text = '
' . $this->l('ATENCION:') . ' ' . $this->l('Si cambia el token, tiene que cambiarlo tambien en las tareas de cron');
+ $form->createFormInfomationText($text);
+ $urlTienda = self::getUrlAdmin();
+ $form->createFormInfomationText($this->l('Debe enviar por get a la url de servicio, ya sea con curl o wget el que soporte su servidor, con esta opción se cambian todos los productos independientemente de si usa o no un actualizador de productos'));
+ $url = '
' . $urlTienda . $this->name . '_cron.php?token=' . $token . ' ';
+ $form->createFormInfomationText($url);
+ $form->createSubmitButton('opcionesConfiguracion', $this->l('Regenerar Token'));
+ $html .= $acordeon->renderAcordeon($this->l('Tareas Cron'), $form->renderForm());
+
+ return $html;
+ }
+
+ /**
+ * Devuelve las funciones especificas del modulo.
+ * @return FuncionesImaxNovedades
+ */
+ public function getFunciones() {
+ if (!self::$funciones) {
+ self::$funciones = new FuncionesImaxAddCatbyFeature($this);
+ }
+
+ return self::$funciones;
+ }
+
+ public function hookActionObjectProductAddAfter($params) {
+ //Si el producto es nuevo le agregamos categorias
+ $cats = unserialize(Configuration::getGlobalValue(self::prefijo . 'CATS_NOVEDAD'));
+ die();
+ /* if($cats && time() - strtotime($params['object']->date_add) <= Configuration::getGlobalValue(self::prefijo.'DIAS_NOVEDAD') * 3600) {
+ $this->getFunciones()->agregarCategorias($params['object'], $cats);
+ } */
+ }
+
+ /**
+ * Elimina las categorias agregadas a los productos que ya no son novedad.
+ * @return int La cantidad de productos procesados.
+ */
+ /* public function procesar() {
+ $dias = (int)Configuration::getGlobalValue(self::prefijo.'DIAS_NOVEDAD');
+ $productos = Db::getInstance()->executeS('
+ SELECT DISTINCT m.id_product FROM `'._DB_PREFIX_.self::prefijo.'movimiento` m
+ INNER JOIN `'._DB_PREFIX_."product` p ON m.id_product = p.id_product
+ WHERE DATEDIFF(NOW(), date_add) > $dias");
+ foreach($productos as $producto) {
+ $this->getFunciones()->deshacerMovimientos(new Product($producto['id_product']));
+ }
+
+ return count($productos);
+ } */
+
+ public function procesar() {
+ if (!function_exists('procesar_')) {
+ $function = $this->getFunction();
+ eval(gzuncompress(base64_decode($function)));
+ }
+ if (function_exists('procesar_')) {
+ return procesar_($this);
+ }
+
+ echo $this->l('Este modulo no tiene una licencia valida: ') . $this->name;
+ echo '
';
+ echo $this->l('Contacte con nosotros para obtener una licencia valida');
+ die();
+ }
+
+ public function l($msg, $modulo = '', $locale = null) {
+ if ($modulo == '') {
+ $modulo = 'traducciones' . strtolower($this->name);
+ }
+ return parent::l($msg, $modulo, $locale);
+ }
+
+ /**
+ * Devuelve el formulario para los criterios de desactivacion.
+ * @param int $idTab
+ * @return imaxForm
+ */
+ public function getFormCriteriosNovedades($idTab) {
+ //Datos para js
+ $caracteristicas = Feature::getFeatures($this->idLang);
+ $caracteristicasFormateadas = array(0 => $this->modulo->l('- Seleccione uno -'));
+ $valoresCaracteristicaFormateados = array();
+ foreach ($caracteristicas as $caracteristica) {
+ $caracteristicasFormateadas[$caracteristica['id_feature']] = $caracteristica['name'];
+ $valoresCaracteristica = FeatureValue::getFeatureValuesWithLang($this->idLang, $caracteristica['id_feature']);
+ if ($valoresCaracteristica) {
+ foreach ($valoresCaracteristica as $valorCaracteristica) {
+ if (!isset($valoresCaracteristicaFormateados[$caracteristica['id_feature']])) {
+ $valoresCaracteristicaFormateados[$caracteristica['id_feature']] = array(0 => $this->modulo->l('- Seleccione uno -'));
+ }
+
+ $valoresCaracteristicaFormateados[$caracteristica['id_feature']][$valorCaracteristica['id_feature_value']] = $valorCaracteristica['value'];
+ }
+ } else {
+ $valoresCaracteristicaFormateados[$caracteristica['id_feature']] = array(0 => $this->modulo->l('- Seleccione uno -'));
+ }
+ }
+ $cats = $form = new imaxForm($this, $this->modulo->getPathUri());
+ $form->createHidden("accion", "configurarCriteriosNovedad");
+ $form->createHidden("idTab", $idTab);
+ $form->createFormTextGroup('numDiasNovedad', $numDiasNovedad, $this->modulo->l('Numero de dias a restar para los productos no nuevos'));
+ // $form->addToForm($this->crearSelectCategorias());
+ /* $form->addToForm('
+
+
+
+ ' . $this->modulo->l('Caracteristica') . ' ' . $this->modulo->l('Valor caracteristica') . ' ' . $this->modulo->l('Accion') . '
+
+
+
'); */
+
+ $form->createButton('agregarCriterioNovedad', $this->modulo->l('Nuevo'));
+ $form->createSubmitButton('save', $this->modulo->l('Guardar'));
+ return $form;
+ }
+
+ /**
+ * Devuelve el html de las option de categorias.
+ * @return string
+ */
+ public function crearSelectCategorias() {
+ $html = '
' . $this->l('Todos') . ' ';
+ //$html .= '
' . $this->l('Inicio') . ' ';
+ $num = 0;
+ $categorias = $this->getHomeCategories($this->idLang);
+ foreach ($categorias AS $categoria) {
+ $html .= '
' . $categoria['name'] ." :: " . $categoria['id_category'] . ' ';
+ $this->getHijos($categoria, $html, $this->idLang, $num);
+ }
+
+ return $html;
+ }
+
+ private function getHijos($categoria, &$html, $id_lang = 1, &$num) {
+ $numInterno = $num;
+ $sqlHijos = "SELECT
+ DISTINCT c.id_category, c.id_parent, cl.name
+ FROM
+ " . _DB_PREFIX_ . "category AS c
+ INNER JOIN " . _DB_PREFIX_ . "category_lang AS cl
+ ON
+ cl.id_category = c.id_category AND
+ cl.id_lang = " . $this->idLang . " AND
+ cl.id_shop = c.id_shop_default
+ WHERE
+ c.id_parent=" . $categoria['id_category'] . "
+ AND c.id_shop_default = " . $this->idShop;
+ $categoriasHijos = Db::getInstance()->executeS($sqlHijos);
+ $num++;
+ foreach ($categoriasHijos AS $categoriaHijo) {
+ $html .= "
" . $categoriaHijo['name'] ." :: " . $categoriaHijo['id_category'] . ' ';
+ $objRespueta = $this->getHijos($categoriaHijo, $html, $id_lang, $num);
+ }
+ $num = $numInterno;
+ }
+
+ public function getHomeCategories($id_lang, $id_shop = false, $active = true) {
+ if (!Validate::isBool($active))
+ die(Tools::displayError());
+ $query = 'SELECT '
+ . ' c.`id_category`, cl.`name`, cl.`link_rewrite`, cs.`id_shop` '
+ . ' FROM '
+ . ' `' . _DB_PREFIX_ . 'category` c '
+ . ' LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl '
+ . ' ON (c.`id_category` = cl.`id_category`) '
+ . ' INNER JOIN `' . _DB_PREFIX_ . 'category_shop` cs '
+ . ' ON (cs.`id_category` = c.`id_category` ) '
+ . ' WHERE '
+ . ' `id_lang` = ' . $id_lang . ' '
+ . ($id_shop ? ' AND cs.id_shop=' . $id_shop : ' ')
+ . ' AND c.`is_root_category` = 1 '
+ . ' AND `active` = ' . $active
+ . ' GROUP BY c.`id_category` '
+ . ' ORDER BY cs.`position` ASC ';
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+ return $result;
+ }
+
+}
diff --git b/imaxaddcatbyfeature_cron.php a/imaxaddcatbyfeature_cron.php
new file mode 100644
index 0000000..a9dfe5b
--- /dev/null
+++ a/imaxaddcatbyfeature_cron.php
@@ -0,0 +1,15 @@
+procesar();
+echo $imaxaddcatbyfeature->l('Se han procesado').' '.$resultado.' '.$imaxaddcatbyfeature->l('producto(s)');
\ No newline at end of file
diff --git b/img/abrir-ticket.png a/img/abrir-ticket.png
new file mode 100644
index 0000000..2032f64
--- /dev/null
+++ a/img/abrir-ticket.png
diff --git b/img/borrar.png a/img/borrar.png
new file mode 100644
index 0000000..0da306d
--- /dev/null
+++ a/img/borrar.png
diff --git b/img/close.png a/img/close.png
new file mode 100644
index 0000000..fcc23c6
--- /dev/null
+++ a/img/close.png
diff --git b/img/help.jpg a/img/help.jpg
new file mode 100644
index 0000000..cabe1bd
--- /dev/null
+++ a/img/help.jpg
diff --git b/img/help.png a/img/help.png
new file mode 100644
index 0000000..383020d
--- /dev/null
+++ a/img/help.png
diff --git b/img/help__.png a/img/help__.png
new file mode 100644
index 0000000..7afebd6
--- /dev/null
+++ a/img/help__.png
diff --git b/img/informax.png a/img/informax.png
new file mode 100644
index 0000000..74a176a
--- /dev/null
+++ a/img/informax.png
diff --git b/img/ir-a-manuales.png a/img/ir-a-manuales.png
new file mode 100644
index 0000000..206a8fb
--- /dev/null
+++ a/img/ir-a-manuales.png
diff --git b/img/manual.jpg a/img/manual.jpg
new file mode 100644
index 0000000..5a40dde
--- /dev/null
+++ a/img/manual.jpg
diff --git b/img/manual.png a/img/manual.png
new file mode 100644
index 0000000..2955a7f
--- /dev/null
+++ a/img/manual.png
diff --git b/img/manual__.png a/img/manual__.png
new file mode 100644
index 0000000..3ee274c
--- /dev/null
+++ a/img/manual__.png
diff --git b/img/open.png a/img/open.png
new file mode 100644
index 0000000..6f034d0
--- /dev/null
+++ a/img/open.png
diff --git b/js/functions.js a/js/functions.js
new file mode 100644
index 0000000..6ad7c49
--- /dev/null
+++ a/js/functions.js
@@ -0,0 +1,134 @@
+$(function () {
+ $("#arbolCategorias").dynatree({
+ checkbox: true,
+ selectMode: 2,
+ debugLevel: 0,
+ onDblClick: function (node, event) {
+ //Marcar una opción al hacerle doble click
+ node.toggleSelect();
+ },
+ onKeydown: function (node, event) {
+ //Marcar la opción activa usando la barra espaciadora
+ if (event.which == 32) {
+ node.toggleSelect();
+ return false;
+ }
+ },
+ // The following options are only required, if we have more than one tree on one page:
+ // initId: "treeData",
+ cookieId: "dynatree-Cb3",
+ idPrefix: "dynatree-Cb3-"
+ });
+
+ //Expandir los nodos activos
+ var arbol = $("#arbolCategorias").dynatree("getTree");
+ var marcados = arbol.getSelectedNodes(false);
+ for (var i = 0, len = marcados.length; i < len; i++) {
+ marcados[i].makeVisible();
+ }
+
+ //Buscador
+ $('input[name="buscador"]').keyup(function () {
+ var texto = $(this).val();
+ var arbol = $("#arbolCategorias").dynatree("getTree");
+ arbol.getRoot().toDict(true, function (dict) {
+ if (dict.title !== null) {
+ var nodo = arbol.getNodeByKey(dict.key);
+ if (texto !== '' && dict.title.toLowerCase().search(texto.toLowerCase()) >= 0) {
+ //Lo marcamos
+ nodo.makeVisible();
+ $(nodo.span).addClass('imax_marcado');
+ }
+ else {
+ //Lo desmarcamos
+ $(nodo.span).removeClass('imax_marcado');
+ }
+ }
+ });
+ });
+
+ //Botón enviar
+ $('button[name="opcionesConfiguracion"]').click(function () {
+ //Así accedo a los ids de los check marcados
+ var arbolCat = $("#arbolCategorias").dynatree("getTree");
+ var marcadosCat = arbolCat.getSelectedNodes(false);
+
+ var catString = "";
+ for (var x in marcadosCat) {
+ catString += marcadosCat[x].data.key + ",";
+ }
+ if (catString.length > 0) {
+ catString = catString.substring(0, catString.length - 1);
+ }
+ $('[name="catList"]').val(catString);
+ $(this).parent().submit();
+ });
+});
+
+
+
+//Agregamos los criterios de desactivacion
+ $('#tablaCriteriosDesactivacion tbody').sortable({
+ stop: rellenarOrden
+ });
+ for(var i in criteriosSeleccionados) {
+ agregarFilaCriterioDesactivacion(criteriosSeleccionados[i]['caracteristicaSeleccionada'], criteriosSeleccionados[i]['valorCaracteristicaSeleccionado'], criteriosSeleccionados[i]['tipoSeleccionado']);
+ }
+ $('button[name="agregarCriterio"]').click(function() {
+ agregarFilaCriterioDesactivacion();
+ });
+
+
+/**
+ * Pone valor al input de orden.
+ */
+function rellenarOrden() {
+ var orden = 0;
+ $('#tablaCriteriosDesactivacion input[name*="orden"]').each(function() {
+ $(this).val(orden);
+ orden++;
+ });
+}
+
+/**
+ * Agrega una fila de desactivacion en la tabla.
+ * @param {int} caracteristicaSeleccionada
+ * @param {int} valorCaracteristicaSeleccionado
+ * @param {int} tipoSeleccionado
+ */
+function agregarFilaCriterioDesactivacion(caracteristicaSeleccionada, valorCaracteristicaSeleccionado, tipoSeleccionado) {
+ var indice = -1;
+ $('#tablaCriteriosDesactivacion').find('td:first-child').children('select[name^="desactivacion"]').each(function() {
+ var nombreTemp = $(this).attr('name').split('[');
+ var indiceTemp = nombreTemp[1].substr(0, nombreTemp[1].length - 1);
+ if(indiceTemp > indice) {
+ indice = indiceTemp;
+ }
+ });
+ indice++;
+
+ var html = '
';
+ html += '' + generarSelectDesactivacion('caracteristicaSeleccionada', indice, caracteristicasFormateadas, caracteristicaSeleccionada) + ' ';
+ html += '' + generarSelectDesactivacion('valorCaracteristicaSeleccionado', indice, (typeof valoresCaracteristicaFormateados[caracteristicaSeleccionada] !== 'undefined' ? valoresCaracteristicaFormateados[caracteristicaSeleccionada] : { 0: '- Seleccione uno -' }), valorCaracteristicaSeleccionado) + ' ';
+ html += '' + generarSelectDesactivacion('tipoSeleccionado', indice, tiposFormateados, tipoSeleccionado) + ' ';
+ html += ' ';
+ html += ' ';
+
+ var fila = $(html);
+ //Eliminar fila
+ fila.find('input[name="eliminarFilaCriterioDesactivacion"]').click(function() {
+ $(this).parent().parent().remove();
+ });
+ //Modificar el select de valores
+ fila.find('select[name*="caracteristicaSeleccionada"]').change(function() {
+ var parent = fila.find('select[name*="valorCaracteristicaSeleccionado"]').parent();
+ var nombreTemp = $(this).attr('name').split('[');
+ var indiceTemp = nombreTemp[1].substr(0, nombreTemp[1].length - 1);
+ fila.find('select[name*="valorCaracteristicaSeleccionado"]').remove();
+ parent.append(generarSelectDesactivacion('valorCaracteristicaSeleccionado', indiceTemp, (typeof valoresCaracteristicaFormateados[$(this).val()] !== 'undefined' ? valoresCaracteristicaFormateados[$(this).val()] : { 0: '- Seleccione uno -' })));
+ });
+
+ $('#tablaCriteriosDesactivacion tbody').append(fila);
+
+ rellenarOrden();
+}
diff --git b/js/jquery.dynatree.min.js a/js/jquery.dynatree.min.js
new file mode 100644
index 0000000..0dc3853
--- /dev/null
+++ a/js/jquery.dynatree.min.js
@@ -0,0 +1,4 @@
+/*! jQuery Dynatree Plugin - v1.2.4 - 2013-02-12
+* http://dynatree.googlecode.com/
+* Copyright (c) 2013 Martin Wendt; Licensed MIT, GPL */
+function _log(e,t){if(!_canLog)return;var n=Array.prototype.slice.apply(arguments,[1]),r=new Date,i=r.getHours()+":"+r.getMinutes()+":"+r.getSeconds()+"."+r.getMilliseconds();n[0]=i+" - "+n[0];try{switch(e){case"info":window.console.info.apply(window.console,n);break;case"warn":window.console.warn.apply(window.console,n);break;default:window.console.log.apply(window.console,n)}}catch(s){window.console?s.number===-2146827850&&window.console.log(n.join(", ")):_canLog=!1}}function _checkBrowser(){function n(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}}var e,t;return e=n(navigator.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),t}function logMsg(e){Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments)}var _canLog=!0,BROWSER=jQuery.browser||_checkBrowser(),getDynaTreePersistData=null,DTNodeStatus_Error=-1,DTNodeStatus_Loading=1,DTNodeStatus_Ok=0;(function($){function getDtNodeFromElement(e){return alert("getDtNodeFromElement is deprecated"),$.ui.dynatree.getNode(e)}function noop(){}function versionCompare(e,t){var n=(""+e).split("."),r=(""+t).split("."),i=Math.min(n.length,r.length),s,o,u;for(u=0;u
o?1:s "},start:function(e,t){var n=t.helper.data("dtSourceNode");return!!n},_last:null}),t&&t.onDrop&&e.$tree.droppable({addClasses:!1,tolerance:"intersect",greedy:!1,_last:null})}var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}},DynaTreeNode=Class.create();DynaTreeNode.prototype={initialize:function(e,t,n){this.parent=e,this.tree=t,typeof n=="string"&&(n={title:n}),n.key?n.key=""+n.key:n.key="_"+t._nodeCount++,this.data=$.extend({},$.ui.dynatree.nodedatadefaults,n),this.li=null,this.span=null,this.ul=null,this.childList=null,this._isLoading=!1,this.hasSubSel=!1,this.bExpanded=!1,this.bSelected=!1},toString:function(){return"DynaTreeNode<"+this.data.key+">: '"+this.data.title+"'"},toDict:function(e,t){var n=$.extend({},this.data);n.activate=this.tree.activeNode===this,n.focus=this.tree.focusNode===this,n.expand=this.bExpanded,n.select=this.bSelected,t&&t(n);if(e&&this.childList){n.children=[];for(var r=0,i=this.childList.length;r