Beispiel #1
0
<?php

$pagetitle = "My Availability";
require_once 'includes/header.php';
$a = new Availability();
if (Input::exists()) {
    try {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('date' => array('field_name' => 'Date', 'required' => true), 'from' => array('field_name' => 'Time From', 'required' => true, 'time_less' => 'to', 'time_same' => 'to'), 'to' => array('field_name' => 'Time Until', 'required' => true)));
        if ($validation->passed()) {
            $a->add(array('cid' => $user->data()->id, 'date' => Input::get('date'), 'time_from' => Input::get('from') . ':00', 'time_until' => Input::get('to') . ':00'));
            Session::flash('success', 'Availability added.');
            Redirect::to('./availability.php');
        } else {
            echo '<div class="row">
            <div class="col-md-6 col-md-offset-3">
              <div class="panel panel-danger">
                <div class="panel-heading">
                  <h3 class="panel-title">The following errors occured:</h3>
                </div>
                <div class="panel-body">';
            foreach ($validation->errors() as $error) {
                echo $error . '<br>';
            }
            echo '</div>
              </div>
            </div></div>
      ';
        }
    } catch (Exception $e) {
        echo $e->getMessage();