toutpratique/override/controllers/admin/AdminSearchController.php
2015-08-13 09:59:25 +02:00

77 lines
2.1 KiB
PHP

<?php
class AdminSearchController extends AdminSearchControllerCore {
public function __construct()
{
parent::__construct();
}
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 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')).'%"' : '' ).'
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)));
}
}