42 lines
823 B
PHP
42 lines
823 B
PHP
<?php
|
|
|
|
require_once(dirname(__FILE__).'../../../config/config.inc.php');
|
|
require_once(dirname(__FILE__).'../../../init.php');
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
|
switch (Tools::getValue('action')) {
|
|
case 'getCategories':
|
|
die(json_encode(getCategories()));
|
|
break;
|
|
|
|
default:
|
|
http_response_code(418);
|
|
die('I\'m a teapot');
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getCategories()
|
|
{
|
|
global $cookie;
|
|
$id_sale = Tools::getValue('sale');
|
|
if (!$id_sale) {
|
|
http_response_code(500);
|
|
return 'Category id not specified';
|
|
}
|
|
|
|
$db = Db::getInstance();
|
|
$sql = 'SELECT * FROM `ps_privatesale_category` pc LEFT JOIN `ps_category_lang` cl ON pc.`id_category` = cl.`id_category` WHERE pc.`id_sale` = '.$id_sale. 'AND cl.`id_lang` = '.$cookie->id_lang;
|
|
return $db->ExecuteS($sql);
|
|
} |