File "punti-vendita-volantino.inc.php"
Full Path: /srv/www/www.cadoro.it/src/controllers/punti-vendita-volantino.inc.php
File size: 1.79 KB
MIME-type: text/x-php
Charset: utf-8
<?php
$store = models\Store::get_by_slug($slug);
if (!$store) {
not_found();
}
$flyer = models\Flyer::get_by_id($flyer);
if (!$flyer) {
not_found();
}
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && _request('prodotto')) {
$params = array(
"user_id" => $principal['id'],
"title" => _request('prodotto')
);
models\UserShoppingList::add($params);
exit;
}
$smarty->assign("store", $store);
$smarty->assign("flyer", $flyer);
$params = array(
"flyer_id" => $flyer['id'],
"store" => $store['id'],
"batch" => 12,
"offset" => _request('n'),
);
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
$labels = $categories = array();
} else {
$labels = $flyer->get_labels($params);
$categories = $flyer->get_categories($params);
}
$params['category'] = _request('categoria');
$params['label'] = _request('tipologia');
$products = models\FlyerProduct::get($params, $params['offset'], $params['batch']);
$params['count'] = models\FlyerProduct::get_count($params);
$query = http_build_query(array_filter(array("categoria" => $params['category'], "tipologia" => $params['label'])));
$params['batch_url'] = BASE_URL . $request_uri . "?" . ($query ? $query . "&" : "");
$smarty->assign("labels", $labels);
$smarty->assign("categories", $categories);
$smarty->assign("products", $products);
$smarty->assign("params", $params);
$smarty->assign("menu", "punti-vendita");
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
$smarty->display("punti-vendita-volantino-ajax.tmpl");
} else {
$smarty->display("punti-vendita-volantino.tmpl");
}
?>