toutpratique/override/controllers/admin/AdminSearchController.php

110 lines
3.1 KiB
PHP
Raw Normal View History

2015-08-12 14:10:25 +02:00
<?php
class AdminSearchController extends AdminSearchControllerCore {
public function __construct()
{
parent::__construct();
}
2015-08-12 16:12:56 +02:00
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)));
}
2015-08-17 17:14:29 +02:00
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)));
}
2015-08-12 16:12:56 +02:00
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)));
}
2015-08-12 14:10:25 +02:00
}