language->id; $sql = ' SELECT x.id_cmsps_extrafields_value as id, lx.value as content FROM `'._DB_PREFIX_.'cmsps_extrafields_value` x LEFT JOIN `'._DB_PREFIX_.'cmsps_extrafields_value_lang` lx ON x.`id_cmsps_extrafields_value` = lx.`id_cmsps_extrafields_value` AND lx.id_lang = '.$id_lang.' WHERE 1 AND x.id_group = '.Cms_ExtraFields::TACHES.' '.( Tools::getValue('q') != '' ? ' AND lx.value LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' GROUP BY x.id_cmsps_extrafields_value'; if ($id_shop) { $sql.= ' AND lx.`id_shop` = '.(int)$id_shop; } $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } public function displayAjaxgetRelationPostSupport() { if(!class_exists('Cms_ExtraFields')) { require _PS_MODULE_DIR.'cms_extrafields/cms_extrafields.php'; } $id_lang = Context::getContext()->language->id; $sql = ' SELECT x.id_cmsps_extrafields_value as id, lx.value as content FROM `'._DB_PREFIX_.'cmsps_extrafields_value` x LEFT JOIN `'._DB_PREFIX_.'cmsps_extrafields_value_lang` lx ON x.`id_cmsps_extrafields_value` = lx.`id_cmsps_extrafields_value` AND lx.id_lang = '.$id_lang.' WHERE 1 AND x.id_group = '.Cms_ExtraFields::SUPPORT.' '.( Tools::getValue('q') != '' ? ' AND lx.value LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' GROUP BY x.id_cmsps_extrafields_value'; if ($id_shop) { $sql.= ' AND lx.`id_shop` = '.(int)$id_shop; } $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } public function displayAjaxgetRelationPostsCms() { $id_lang = Context::getContext()->language->id; $sql = ' SELECT c.id_post as id, lc.title as content FROM `'._DB_PREFIX_.'cmsps_posts` c LEFT JOIN `'._DB_PREFIX_.'cmsps_posts_lang` lc ON c.`id_post` = lc.`id_post` AND lc.id_lang = '.$id_lang.' WHERE 1 '.( Tools::getValue('q') != '' ? ' AND lc.title LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' GROUP BY c.id_post'; if ($id_shop) { $sql.= ' AND lc.`id_shop` = '.(int)$id_shop; } $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } public function displayAjaxgetRelationPostsProduct() { $id_lang = Context::getContext()->language->id; $sql = ' SELECT p.id_product as id, pl.name as content FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product` AND pl.id_lang = '.$id_lang.' WHERE 1 '.( Tools::getValue('q') != '' ? ' AND pl.name LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' GROUP BY p.id_product'; if ($id_shop) { $sql.= ' AND pl.`id_shop` = '.(int)$id_shop; } $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } public function displayAjaxgetRelationCmsPack() { $sql = ' SELECT p.id_pack as id, p.title as content FROM `'._DB_PREFIX_.'cms_pack` p WHERE 1 '.( Tools::getValue('q') != '' ? ' AND p.title LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' GROUP BY p.id_pack'; $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } public function displayAjaxgetRelationPostsEdito() { $id_lang = Context::getContext()->language->id; $sql = ' SELECT c.id_edito as id, lc.title as content FROM `'._DB_PREFIX_.'cmsps_editos` c LEFT JOIN `'._DB_PREFIX_.'cmsps_editos_lang` lc ON c.`id_edito` = lc.`id_edito` AND lc.id_lang = '.$id_lang.' WHERE 1 '.( Tools::getValue('q') != '' ? ' AND lc.title LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' GROUP BY c.id_edito'; if ($id_shop) { $sql.= ' AND lc.`id_shop` = '.(int)$id_shop; } $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } public function displayAjaxgetRelationCategoryCms($search = '', $id_lang = null, $id_shop = null) { $id_lang = Context::getContext()->language->id; $sql = ' SELECT c.id_category as id, lc.title as content FROM `'._DB_PREFIX_.'cmsps_categories` c LEFT JOIN `'._DB_PREFIX_.'cmsps_categories_lang` lc ON c.`id_category` = lc.`id_category` AND lc.id_lang = '.$id_lang.' LEFT JOIN `'._DB_PREFIX_.'cmsps_categories_shop` ls ON c.`id_category` = ls.`id_category` WHERE 1 '.( Tools::getValue('q') != '' ? ' AND lc.title LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).' AND c.`id_parent` = 0 GROUP BY c.id_category'; if ($id_shop) { $sql.= ' AND ls.`id_shop` = '.(int)$id_shop; } $res = Db::getInstance()->executeS($sql); die(json_encode(array('results' => $res))); } }