File "api-punti-vendita-dettaglio.inc.php"
Full Path: /srv/www/www.cadoro.it/src/controllers/api-punti-vendita-dettaglio.inc.php
File size: 1.04 KB
MIME-type: text/x-php
Charset: utf-8
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: text/json; charset="UTF-8"');
# GET
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$store = models\Store::get_by_id($id);
if (!$store) {
not_found_json();
}
$result = array(
"store" => $store->json(),
);
$result['store']['openings'] = $store->openings();
$result['store']['buoni'] = array_map(function ($b) {
return array(
"i" => file_exists("../www/images/buoni-pasto/" . $b['id'] . ".jpg") ? CDN_URL . "/images/buoni-pasto/" . $b['id'] . ".jpg" : null,
"t" => trim($b['title']),
);
}, $store->buonipasto());
$result['store']['flyers'] = array_map(function ($f) {
return $f->json();
}, models\Flyer::get(array("store" => $store, "dates" => 1)));
# JSON output
echo json_encode($result);
}
# DEFAULT
else {
header('HTTP/1.0 400 Bad Request', true, 400);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array("error" => "unsupported method"));
}
?>