function addEvent() { checkPerm('view'); require_once _base_ . '/lib/lib.form.php'; $lang =& DoceboLanguage::createInstance('reservation'); $out = $GLOBALS['page']; $out->setWorkingZone('content'); $man_res = new Man_Reservation(); if (isset($_GET['confirm'])) { $confirm = importVar('confirm', true, 0); $id_course = $_SESSION['idCourse']; $id_laboratory = importVar('id_laboratory', true, 0); $id_category = importVar('id_category', true, 0); $title = importVar('title', false, ''); $description = importVar('description', false, ''); $date = importVar('date', false, ''); $max_user = importVar('max_user', true, 0); $deadline = importVar('deadline', false, ''); $from_time_h = importVar('from_time_h', false, ''); $from_time_m = importVar('from_time_m', false, ''); $to_time_h = importVar('to_time_h', false, ''); $to_time_m = importVar('to_time_m', false, ''); $date = Format::dateDb($date, 'date'); $deadline = Format::dateDb($deadline, 'date'); if ($date) { $from_time = $from_time_h . ':' . $from_time_m . ':00'; } $to_time = $to_time_h . ':' . $to_time_m . ':00'; if ($date < date('Y-m-d') || $date < $deadline || $deadline < date('Y-m-d')) { Util::jump_to('index.php?modname=reservation&op=add_event&error=date&id_laboratory=' . $id_laboratory . '&id_category=' . $id_category . '&title=' . $title . '&description=' . $description . '&date=' . $_POST['date'] . '&max_user='******'&deadline=' . $_POST['deadline']); } if ($from_time >= $to_time) { Util::jump_to('index.php?modname=reservation&op=add_event&error=time&id_laboratory=' . $id_laboratory . '&id_category=' . $id_category . '&title=' . $title . '&description=' . $description . '&date=' . $_POST['date'] . '&max_user='******'&deadline=' . $_POST['deadline']); } if ($confirm) { $result = $man_res->addEvents($id_course, $id_laboratory, $id_category, $title, $description, $date, $max_user, $deadline, $from_time, $to_time); } if ($result) { Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=subscribed_user'); } Util::jump_to('index.php?modname=reservation&op=add_event&error=laboratory&id_laboratory=' . $id_laboratory . '&id_category=' . $id_category . '&title=' . $title . '&description=' . $description . '&date=' . $_POST['date'] . '&max_user='******'&deadline=' . $_POST['deadline']); } $out->add(getTitleArea($lang->def('_NEW_EVENT'), '', $lang->def('_EVENT')) . '<div class="std_block">'); $error = importVar('error', false, ''); if ($error !== '') { switch ($error) { case 'date': $out->add(getErrorUi($lang->def('_WRONG_DATE'))); break; case 'time': $out->add(getErrorUi($lang->def('_WRONG_TIME'))); break; case 'laboratory': $out->add(getErrorUi($lang->def('_LOCATION_BUSY'))); break; } } $out->add(Form::openForm('form_event', 'index.php?modname=reservation&op=add_event&confirm=1') . Form::openElementSpace() . Form::getTextfield($lang->def('_TITLE'), 'title', 'title', 255, isset($_GET['title']) ? $_GET['title'] : '') . Form::getTextarea($lang->def('_DESCRIPTION'), 'description', 'description', isset($_GET['description']) ? $_GET['description'] : '') . Form::getDropdown($lang->def('_LOCATION'), 'id_laboratory', 'id_laboratory', $man_res->getLaboratories(), isset($_GET['id_laboratory']) ? $_GET['id_laboratory'] : '0') . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $man_res->getCategory(), isset($_GET['id_category']) ? $_GET['id_category'] : '0') . Form::getDateField($lang->def('_DATE'), 'date', 'date', isset($_GET['date']) ? $_GET['date'] : '') . Form::getDateField($lang->def('_DEADLINE'), 'deadline', 'deadline', isset($_GET['deadline']) ? $_GET['deadline'] : '') . Form::getTextfield($lang->def('_MAX_USER'), 'max_user', 'max_user', 255, isset($_GET['max_user']) ? $_GET['max_user'] : '') . Form::getLineBox($lang->def('_FROM_TIME'), Form::getInputDropdown('', 'from_time_h', 'from_time_h', $man_res->getHours(), false, false) . ' : ' . Form::getInputDropdown('', 'from_time_m', 'from_time_m', $man_res->getMinutes(), false, false)) . Form::getLineBox($lang->def('_TO_TIME'), Form::getInputDropdown('', 'to_time_h', 'to_time_h', $man_res->getHours(), false, false) . ' : ' . Form::getInputDropdown('', 'to_time_m', 'to_time_m', $man_res->getMinutes(), false, false)) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('send_event', 'send_event', $lang->def('_NEW_EVENT')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm()); $out->add('</div>', 'content'); }