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

require_once "atc_training.class.php";
$ATC = new ATC_Training();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    try {
        if (isset($_GET['action']) && $_GET['action'] == 'delete') {
            $ATC->delete_lesson_from_timetable($_POST['lesson_id'], $_POST['year']);
        } else {
            $ATC->set_timetable($_POST['lesson_id'], $ATC->set_location($_POST['location_id'], $_POST['location'], null), $_POST['personnel_id'], $_POST['date'], date('Y-m-d H:i', strtotime('+45 minutes', strtotime($_POST['date']))), $_POST['group'], $_POST['dress_code']);
        }
    } catch (ATCExceptionInsufficientPermissions $e) {
        header("HTTP/1.0 401 Unauthorised");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (ATCExceptionDBError $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (ATCExceptionDBConn $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (ATCException $e) {
        header("HTTP/1.0 400 Bad Request");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (Exception $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }
    exit;
}
$ATC->gui_output_page_header('Training');
$_GET['year'] = isset($_GET['year']) && (int) $_GET['year'] ? (int) $_GET['year'] : date('Y');