Beispiel #1
0
     $snacks = get_all_snacks();
     $response = array("version" => $version, "response" => $snacks);
     echo json_encode($response);
 } elseif ('jobs' == $_GET['uri'] && isset($_GET['id'])) {
     send_headers();
     $jobs = get_jobs_by_uid($_GET['id']);
     $response = array("version" => $version, "response" => $jobs);
     echo json_encode($response);
 } elseif ('equipments' == $_GET['uri'] && isset($_GET['id'])) {
     send_headers();
     $equipment = get_equipment_by_id($_GET['id']);
     $response = array("version" => $version, "response" => $equipment);
     echo json_encode($response);
 } elseif ('equipments' == $_GET['uri']) {
     send_headers();
     $equipments = get_all_equipments();
     echo json_encode($equipments);
 } elseif ('coffees' == $_GET['uri'] && isset($_GET['id'])) {
     // This is a payment request
     $user = get_user_by_uid($_GET['id']);
     if ($user && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $coffees_user_today = get_coffees_today_by_uid($user['uid']);
         $coffees_user_month = get_coffees_this_month_by_uid($user['uid']);
         $coffees = array("today" => intval($coffees_user_today), "this_month" => intval($coffees_user_month));
         send_headers();
         $response = array("version" => $version, "response" => "OK", "uid" => $user['uid'], "balance" => floatval($user['balance']), "coffees" => $coffees);
         echo json_encode($response);
     } else {
         if ($user) {
             $order = array();
             $order['client'] = $user['uid'];
Beispiel #2
0
function list_equipments_action($uid)
{
    // needed to set the tab active
    $extras_active = true;
    $equipments_active = true;
    if (user_is_admin($uid)) {
        // dealing with equipment add form
        if (isset($_POST['description']) && isset($_POST['name'])) {
            $equipment_added = get_equipment_by_id($_POST['id']);
            // equipment exists
            if ($equipment_added) {
                update_equipment($_POST['id'], $_POST['uid'], $_POST['name'], $_POST['description'], $_POST['hirer'], $_POST['end']);
            } else {
                add_equipment($_POST['uid'], $_POST['name'], $_POST['description'], $_POST['hirer'], $_POST['end']);
            }
        }
        // get all the equipments
        $equipments = get_all_equipments();
        $uids = get_all_uids();
        require 'templates/equipments.php';
    } else {
        require 'templates/login.php';
    }
}