Пример #1
0
<?php

respond('/', function ($request, $response, $app) {
    //create the time arrays
    //put the current cts session into the templace
    $app->tpl->assign('reserve', $_SESSION['cts']);
    //put the current session step variable into the template
    $app->tpl->assign('step', $_SESSION['cts']['step']);
    $app->tpl->display('event.tpl');
});
//end /
respond('/agreement', function ($request, $response, $app) {
    //display the reservation agreement for the user
    $app->tpl->assign('agreement', ReserveDatabaseAPI::get_reservation_agreement());
    $app->tpl->display('agreement.tpl');
});
respond('POST', '/confirm', function ($request, $response, $app) {
    //if posted to the confirmation page check to make sure there is at least one equipment item in the session
    if (count($_SESSION['cts']['equipment']) > 0) {
        $_SESSION['cts']['step'] = 2;
        //grab the location and category data
        $app->tpl->assign('locations', ReserveDatabaseAPI::locations());
        $app->tpl->assign('categories', ReserveDatabaseAPI::categories());
        $app->tpl->assign('step', $_SESSION['cts']['step']);
        $app->tpl->assign('reserve', $_SESSION['cts']);
        $app->tpl->display('confirm.tpl');
    } else {
        //if there wasn't at least one equipment item selected, send the user back to the equipment page
        $_SESSION['errors'][] = "Please select at least one item from the list of equipment.";
        $response->redirect($GLOBALS['BASE_URL'] . '/reserve/equipment');
    }