Пример #1
0
// set from_date
if ($request_ok) {
    $from_date = strip_tags($_GET['from_date']);
}
// get the to_date or set it to the same value as from_date if not set by user
if (!isset($_GET['to_date']) || empty($_GET['to_date'])) {
    // if not set use from_date
    if ($request_ok) {
        $to_date = $from_date;
    }
} else {
    // use the user-given to_date value
    $to_date = strip_tags($_GET['to_date']);
}
// initialize TimeGrid class
$timegrid = new TimeGrid();
// get list of the categories
$categories = $timegrid->getCategories();
if ($request_ok) {
    // generate our grid
    $timegrid->setYWidth(10);
    $timegrid->setCategory($category);
    $timegrid->setFromDate($from_date);
    $timegrid->setToDate($to_date);
    $timegrid->createGrid();
}
?>

<html>
	<head>
Пример #2
0
<?php

require_once '../lib/TimeGrid.php';
$timegrid = new TimeGrid();
/*
@TODO Implement controller as a class with *Action() methods and do the rouing at index.php to prevent exit() calls and provide more clarity.
*/
// delete object
if (isset($_POST['action']) && $_POST['action'] == 'object_delete') {
    if (isset($_POST['object_id']) && is_numeric($_POST['object_id'])) {
        $object_id = intval($_POST['object_id']);
        if ($timegrid->deleteObject($object_id)) {
            echo json_encode(true);
            exit;
        }
        echo json_encode(false);
        exit;
    } else {
        echo json_encode(false);
        exit;
    }
}
// delete reservation
if (isset($_POST['action']) && $_POST['action'] == 'reservation_delete') {
    if (isset($_POST['reservation_id']) && is_numeric($_POST['reservation_id'])) {
        $reservation_id = intval($_POST['reservation_id']);
        if ($timegrid->deleteReservation($reservation_id)) {
            echo json_encode(true);
            exit;
        }
        echo json_encode(false);