$order['client'] = $user['uid']; $order['snack_2'] = 1; new_order($order); // get the new user balance $user = get_user_by_uid($user['uid']); send_headers(); $response = array("version" => $version, "response" => "OK", "uid" => $user['uid'], "balance" => floatval($user['balance'])); echo json_encode($response); } else { forbidden(); } } } elseif ('coffees' == $_GET['uri']) { send_headers(); $today = get_coffees_today(); $month = get_coffees_this_month(); $all = get_coffees(); $coffees = array("today" => intval($today), "month" => intval($month), "all" => intval($all)); $response = array("version" => $version, "response" => $coffees); echo json_encode($response); } elseif ('permissions' == $_GET['uri'] && isset($_GET['uid']) && isset($_GET['id'])) { send_headers(); $permission = get_permission($_GET['uid'], $_GET['id']); echo json_encode($permission); } elseif ('permissions' == $_GET['uri'] && isset($_GET['id'])) { send_headers(); $permissions = get_reader_permissions($_GET['id']); echo json_encode($permissions); } elseif ('orders' == $_GET['uri'] && isset($_GET['id'])) { send_headers(); $orders = get_all_orders_by_uid($_GET['id']);
function dashboard_json_action() { header('Content-type: application/json; charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); $coffees_today = get_coffees_today(); $coffees_month = get_coffees_this_month(); $money_today = get_money_spent_today(); $money_month = get_money_spent_this_month(); $json = array("coffees_today" => $coffees_today, "coffees_month" => $coffees_month, "money_today" => $money_today, "money_month" => $money_month); echo json_encode($json); }