ordersprinter/gastsystem/php/menu.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2020-11-19 23:10:06 +01:00
<?php
require_once 'dbutils.php';
require_once 'config.php';
class Menu {
public static function getmenu($pdo) {
$sql = "SELECT value FROM %ossystem% WHERE item=?";
$result = DbUtils::fetchSqlAll($pdo, $sql, array('products'));
if (is_null($result) || (count($result) == 0)) {
return array("status" => "ERROR","msg" => "Keine Produktdefinition hinterlegt.");
}
$products = json_decode($result[0]["value"], true);
$sql = "SELECT value FROM %ossystem% WHERE item=?";
$result = DbUtils::fetchSqlAll($pdo, $sql, array('types'));
if (is_null($result) || (count($result) == 0)) {
return array("status" => "ERROR","msg" => "Keine Produktdefinition hinterlegt.");
}
$types = json_decode($result[0]["value"], true);
return array("status" => "OK","msg" => array("types" => $types,"products" => $products));
}
}
if (isset($_GET["command"])) {
$command = $_GET["command"];
$pdo = DbUtils::openDbAndReturnPdoStatic();
switch ($command) {
case "getmenu":
$ret = Menu::getmenu($pdo);
echo json_encode($ret);
break;
default:
break;
}
}