function modEvent() { checkPerm('view'); require_once _base_ . '/lib/lib.form.php'; $id_event = importVar('id_event', true, 0); $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 = importVar('id_course', true, 0); $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'); $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=mod_event&id_event=' . $id_event . '&error=date'); } if ($from_time >= $to_time) { Util::jump_to('index.php?modname=reservation&op=mod_event&id_event=' . $id_event . '&error=time'); } if ($confirm) { $result = $man_res->modEvent($id_event, $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=mod_event&id_event=' . $id_event . '&error=laboratory'); } $out->add(getTitleArea($lang->def('_SAVE'), '', $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; } } $event = array(); $event = $man_res->getEventInfo($id_event); $date = Format::date($event[EVENT_DATE], 'date'); $deadline = Format::date($event[EVENT_DEADLINE], 'date'); $from_time_h = $event[EVENT_FROM_TIME][0] . $event[EVENT_FROM_TIME][1]; $from_time_m = $event[EVENT_FROM_TIME][3] . $event[EVENT_FROM_TIME][4]; $to_time_h = $event[EVENT_TO_TIME][0] . $event[EVENT_TO_TIME][1]; $to_time_m = $event[EVENT_TO_TIME][3] . $event[EVENT_TO_TIME][4]; $out->add(Form::openForm('form_event', 'index.php?modname=reservation&op=mod_event&confirm=1') . Form::openElementSpace() . Form::getHidden('id_event', 'id_event', $event[EVENT_ID]) . Form::getHidden('id_course', 'id_course', $event[EVENT_ID_COURSE]) . Form::getTextfield($lang->def('_TITLE'), 'title', 'title', 255, $event[EVENT_TITLE]) . Form::getTextarea($lang->def('_DESCRIPTION'), 'description', 'description', $event[EVENT_DESCRIPTION]) . Form::getDropdown($lang->def('_LOCATION'), 'id_laboratory', 'id_laboratory', $man_res->getLaboratories(), $event[EVENT_ID_LABORATORY]) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $man_res->getCategory(), $event[EVENT_ID_CATEGORY]) . Form::getDateField($lang->def('_DATE'), 'date', 'date', $date) . Form::getDateField($lang->def('_DEADLINE'), 'deadline', 'deadline', $deadline) . Form::getTextfield($lang->def('_MAX_USER'), 'max_user', 'max_user', 255, $event[EVENT_MAX_USER]) . Form::getLineBox($lang->def('_FROM_TIME'), Form::getInputDropdown('', 'from_time_h', 'from_time_h', $man_res->getHours(), $from_time_h, false) . ' : ' . Form::getInputDropdown('', 'from_time_m', 'from_time_m', $man_res->getMinutes(), $from_time_m, false)) . Form::getLineBox($lang->def('_TO_TIME'), Form::getInputDropdown('', 'to_time_h', 'to_time_h', $man_res->getHours(), $to_time_h, false) . ' : ' . Form::getInputDropdown('', 'to_time_m', 'to_time_m', $man_res->getMinutes(), $to_time_m, false)) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('mod_event', 'mod_event', $lang->def('_SAVE')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm()); $out->add('</div>', 'content'); }