Example #1
0
require_once 'config.php';
require_once '../class/Steps.class.php';
$steps = new Step($pdo);
if (isset($_GET['action'])) {
    $action = $_GET['action'];
    // Get all steps
    if ($action == "getSteps") {
        $allSteps = $steps->getSteps();
        echo $allSteps;
    }
} else {
    if (isset($_POST['action'])) {
        $action = $_POST['action'];
        if ($action == "createStep") {
            $newStep = $steps->createStep();
            echo $newStep;
        }
        if (isset($_POST['id'])) {
            $id = $_POST['id'];
            if ($action == "startStep") {
                $theStep = $steps->startStep($id);
                echo $theStep;
            }
            if ($action == "stopStep") {
                $theStep = $steps->stopStep($id);
                echo $theStep;
            }
            if ($action == "ifStartedStep") {
                $theStep = $steps->getState($id);
                echo $theStep;