/** * Edits a reservation * * @param - int $id The reservation-ID * @param - $item_id,$auto_accept,$max_users,$start_at,$end_at,$subscribe_until,$notes * @return - FALSE if there is something wrong with the dates, TRUE if everything went perfectly * */ function edit_reservation($id, $item_id, $auto_accept, $max_users, $start_at, $end_at, $subscribe_from, $subscribe_until, $notes, $timepicker) { $id = Database::escape_string($id); if (!Rsys::item_allow($item_id, 'm_reservation')) { return false; } $stamp_start = Rsys::mysql_datetime_to_timestamp($start_at); $stamp_end = Rsys::mysql_datetime_to_timestamp($end_at); $stamp_start_date = date('Y-m-d', $stamp_start); $stamp_end_date = date('Y-m-d', $stamp_end); if (Rsys::check_date_edit($item_id, $stamp_start, $stamp_end, $start_at, $end_at, $id) != 0) { return 1; } if ($subscribe_until != 0) { $stamp_until = Rsys::mysql_datetime_to_timestamp($subscribe_until); if ($stamp_until > $stamp_start) { return 2; } } $sql = "SELECT timepicker, subscribers FROM " . Rsys::getTable("reservation") . " WHERE id='" . $id . "'"; $result = Database::fetch_array(Database::query($sql)); if ($result[0] == 0 && $result[1] > $max_users) { return 3; } if ($stamp_start_date != $stamp_end_date && $timepicker == '1') { return 4; } if ($auto_accept == 1) { $sql = "SELECT dummy FROM " . Rsys::getTable("subscription") . " WHERE reservation_id='" . $id . "'"; $result = Database::query($sql); while ($array = Database::fetch_array($result, 'NUM')) { Rsys::set_accepted($array[0], 1); } } else { $auto_accept = 0; } $sql = "UPDATE " . Rsys::getTable("reservation") . " SET item_id='" . Database::escape_string($item_id) . "',auto_accept='" . Database::escape_string($auto_accept) . "',max_users='" . ($max_users > 1 ? $max_users : 1) . "',start_at='" . Database::escape_string($start_at) . "',end_at='" . Database::escape_string($end_at) . "',subscribe_from='" . Database::escape_string($subscribe_from) . "',subscribe_until='" . Database::escape_string($subscribe_until) . "',notes='" . Database::escape_string($notes) . "' WHERE id='" . $id . "'"; Database::query($sql); return 0; }
$table->set_header(1, get_lang('ResourceTypeName'), true); $table->set_header(2, get_lang('StartDate'), true); $table->set_header(3, get_lang('EndDate'), true); $table->set_header(4, get_lang('SubscribedPerson'), true); $table->set_header(5, get_lang('SubscribedStartDate'), true); $table->set_header(6, get_lang('SubscribedEndDate'), true); $table->set_header(7, get_lang('Accept'), true); $table->display(); break; case 'accept': $NoSearchResults = get_lang('NoReservation'); if (empty($_GET['rid'])) { $_GET['rid'] = $_POST['rid']; } if ($_GET['switch'] == 'edit') { Rsys::set_accepted($_GET['dummy'], $_GET['set']); } if ($_GET['switch'] == 'delete') { Rsys::delete_subscription($_GET['rid'], $_GET['dummy']); } $interbreadcrumb[] = array("url" => "mysubscriptions.php", "name" => get_lang('Booking')); $interbreadcrumb[] = array("url" => "m_reservation.php", "name" => get_lang('ManageBookingPeriods')); Display::display_header(get_lang('AutoAccept')); api_display_tool_title(get_lang('AutoAccept')); $table = new SortableTable('accepting', array('Rsys', 'get_num_waiting_users'), array('Rsys', 'get_table_waiting_users'), 1); $table->set_additional_parameters(array('rid' => $_GET['rid'], 'action' => 'accept')); $table->set_header(0, '', false, array('style' => 'width:10px')); $table->set_header(1, get_lang('SubscribedPerson'), true); $table->set_header(2, get_lang('Class'), true); $table->set_header(3, get_lang('SubscribedStartDate'), false); $table->set_header(4, get_lang('SubscribedEndDate'), false);