Esempio n. 1
0
function rest_get($req)
{
    global $JSON;
    if (checkPrivileges($req[0]) == false) {
        return;
    }
    $resp = reqRouter($req, "GET");
    $response;
    switch ($resp) {
        case 1:
            global $routes;
            $order = @$routes[$req[0]]["orderBy"];
            if (isset($order)) {
                $response = sql_GET_ALL($req[0], [$order, "ASC"]);
            } else {
                $response = sql_GET_ALL($req[0], [$routes[$req[0]]['identifier'], "ASC"]);
            }
            break;
        case 2:
            $response = sql_GET($req);
            break;
        case 3:
            $response = sql_GET_ROW($req);
            break;
        case 4:
            $response = sql_GET_SORT($req, true);
            break;
        case 5:
            $response = sql_GET_SORT($req, false);
            break;
        case 6:
            $response = sql_GET_COLUMNS();
            break;
        case 7:
            $response = sql_GET_JOIN($JSON);
            break;
        case 8:
            $response = getPrice($JSON);
            break;
        case 9:
            $response = getByTime($req, $JSON);
            break;
        case 0:
        default:
            rest_error("Mal-Formed request, check url params", 400);
            return;
    }
    if (isset($response) && (is_array($response) && count($response) > 0)) {
        rest_success(json_encode($response));
    } else {
        rest_error("Empty Results, Check if item exists in dataBase, Check Url requested.", 404);
    }
    return 0;
}
Esempio n. 2
0
            }
            echo ']}';
        } else {
            echo '{"result":0,"message":"No transactions found"}';
        }
    }
    switch ($cmd) {
        case 1:
            transact();
            break;
        case 2:
            delete();
            break;
        case 3:
            getTransaction();
            break;
        case 4:
            getByTime();
            break;
        case 5:
            getByEmp();
            break;
        case 6:
            transactions();
            break;
        case 7:
            checkDiscount();
        default:
            break;
    }
}