multisite('approve_entry_handler.php')); $form->setAttributes($attributes); $hidden_inputs = array('action' => 'approve', 'id' => $target_id, 'series' => ($is_series) ? 1 : 0, 'returl' => $returl); $form->addHiddenInputs($hidden_inputs); $element = new ElementInputSubmit(); $element->setAttribute('value', get_vocab('approve')); $form->addElement($element); $form->render(); // reject $form = new Form(Form::METHOD_POST); $attributes = array('action' => multisite("view_entry.php?$query_string")); $form->setAttributes($attributes); $hidden_inputs = array('action' => 'reject', 'returl' => $returl); $form->addHiddenInputs($hidden_inputs); $element = new ElementInputSubmit(); $element->setAttribute('value', get_vocab('reject')); $form->addElement($element); $form->render(); // more info $info_time = ($is_series) ? $row['repeat_info_time'] : $row['entry_info_time']; $info_user = ($is_series) ? $row['repeat_info_user'] : $row['entry_info_user']; if (empty($info_time)) { $info_title = get_vocab("no_request_yet"); } else { $info_title = get_vocab("last_request") . ' ' . time_date_string($info_time); if (!empty($info_user)) { $info_title .= " " . get_vocab("by") . " $info_user"; } } $form = new Form(Form::METHOD_POST); $attributes = array('action' => multisite("view_entry.php?$query_string")); $form->setAttributes($attributes); $hidden_inputs = array('action' => 'more_info', 'returl' => $returl); $form->addHiddenInputs($hidden_inputs); $element = new ElementInputSubmit(); $element->setAttributes(array('value' => get_vocab('more_info'), 'title' => $info_title)); $form->addElement($element); $form->render(); } else { // get the area settings for this room get_area_settings(get_area($row['room_id'])); // if enough time has passed since the last reminder // output a "Remind Admin" button, otherwise nothing if ($reminders_enabled && (working_time_diff(time(), $last_reminded) >= $reminder_interval)) { $form = new Form(Form::METHOD_POST); $attributes = array('action' => multisite('approve_entry_handler.php')); $form->setAttributes($attributes); $hidden_inputs = array('action' => 'remind', 'id' => $row['id'], 'returl' => $returl); $form->addHiddenInputs($hidden_inputs); $element = new ElementInputSubmit(); $element->setAttribute('value', get_vocab('remind_admin')); $form->addElement($element); $form->render(); } else { echo " "; } } } function display_table_head() : void { echo "\n"; echo "\n"; // We give some columns a type data value so that the JavaScript knows how to sort them echo " \n"; echo "" . get_vocab("entry") . "\n"; echo "" . get_vocab("createdby") . "\n"; echo "" . get_vocab("area") . "\n"; echo "" . get_vocab("room") . "\n"; echo "" . get_vocab("start_date") . "\n"; echo "" . get_vocab("duration") . "\n"; echo "" . get_vocab("end_date") . "\n"; echo "" . get_vocab("action") . "\n"; echo "\n"; echo "\n"; } // display the table head for a subtable function display_subtable_head(array $row) : void { echo "\n"; echo "\n"; // We give some columns a type data value so that the JavaScript knows how to sort them echo " \n"; // reservation name, with a link to the view_entry page echo '' . escape_html($row['name']) ."\n"; // create_by, area and room names echo "" . escape_html($row['create_by']) . "\n"; echo "" . escape_html($row['area_name']) . "\n"; echo "" . escape_html($row['room_name']) . "\n"; echo "" . get_vocab("series") . "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; } // display the title row for a series function display_series_title_row(array $row) : void { echo "\n"; echo " \n"; // reservation name, with a link to the view_entry page echo '' . escape_html($row['name']) ."\n"; // create_by, area and room names echo "" . escape_html(auth()->getDisplayName($row['create_by'])) . "\n"; echo "" . escape_html($row['area_name']) . "\n"; echo "" . escape_html($row['room_name']) . "\n"; echo ""; // for sorting echo ""; echo get_vocab("series"); echo "\n"; echo " \n"; echo " \n"; echo "\n"; display_buttons($row, true); echo "\n"; echo "\n"; } // display an entry in a row function display_entry_row(array $row) : void { global $view; echo "\n"; echo " \n"; // reservation name, with a link to the view_entry page echo ""; echo '' . escape_html($row['name']) ."\n"; // create_by, area and room names echo "" . escape_html(auth()->getDisplayName($row['create_by'])) . "\n"; echo "" . escape_html($row['area_name']) . "\n"; echo "" . escape_html($row['room_name']) . "\n"; // start date, with a link to the calendar view $link = getdate($row['start_time']); echo ""; // for sorting echo ""; $vars = array('view' => $view, 'year' => $link['year'], 'month' => $link['mon'], 'day' => $link['mday'], 'area' => $row['area_id'], 'room' => $row['room_id']); $query = http_build_query($vars, '', '&'); echo ''; $link_str = date_string(!empty($row['enable_periods']), $row['start_time'], $row['area_id']); echo escape_html($link_str) . ""; $duration = get_duration($row['start_time'], $row['end_time'], !empty($row['enable_periods']), $row['area_id'], false); $duration_seconds = $row['end_time'] - $row['start_time'] - cross_dst($row['start_time'], $row['end_time']); echo "" . escape_html($duration['duration'] . " " . get_vocab($duration['dur_units'])) . "\n"; // End date $end_date_str = date_string(!empty($row['enable_periods']), $row['end_time'], $row['area_id'], true); echo "" . escape_html($end_date_str) . "\n"; // action buttons echo "\n"; display_buttons($row, false); echo "\n"; echo "\n"; } // Check the user is authorised for this page checkAuthorised(this_page()); $mrbs_user = session()->getCurrentUser(); $mrbs_username = (isset($mrbs_user)) ? $mrbs_user->username : null; $context = array( 'view' => $view, 'view_all' => $view_all, 'year' => $year, 'month' => $month, 'day' => $day, 'area' => $area, 'room' => isset($room) ? $room : null ); print_header($context); echo "

" . get_vocab("pending") . "

\n"; // Get a list of all bookings awaiting approval // We are only interested in areas where approval is required $sql_approval_enabled = some_area_predicate('approval_enabled'); $sql = "SELECT E.id, E.name, E.description, E.room_id, E.start_time, E.end_time, E.create_by, " . db()->syntax_timestamp_to_unix("E.timestamp") . " AS last_updated, E.reminded, E.repeat_id, M.room_name, M.area_id, A.area_name, A.enable_periods, E.info_time AS entry_info_time, E.info_user AS entry_info_user, T.info_time AS repeat_info_time, T.info_user AS repeat_info_user FROM " . _tbl('room') . " AS M, " . _tbl('area') . " AS A, " . _tbl('entry') . " AS E LEFT JOIN " . _tbl('repeat') . " AS T ON E.repeat_id=T.id WHERE E.room_id = M.id AND M.area_id = A.id AND M.disabled = 0 AND A.disabled = 0 AND $sql_approval_enabled AND (E.status&" . STATUS_AWAITING_APPROVAL . " != 0)"; // We want entries for a series to appear together so that we can display // them as a separate table below the main entry for the series. $sql .= " ORDER BY repeat_id, start_time"; $res = db()->query($sql); $rows = array(); while (false !== ($row = $res->next_row_keyed())) { row_cast_columns($row, 'entry'); // Turn these columns into ints (some MySQL drivers will return a string, // and they won't have been caught by row_cast_columns() as they are derived results). $row['last_updated'] = intval($row['last_updated']); $row['entry_info_time'] = intval($row['entry_info_time']); $row['repeat_info_time'] = intval($row['repeat_info_time']); // And this comes from the area table $row['area_id'] = intval($row['area_id']); if ((compare_usernames($row['create_by'], $mrbs_username) === 0) || is_book_admin($row['room_id'])) { $rows[] = $row; } } if (count($rows) == 0) { echo "

" .get_vocab("none_outstanding") . "

\n"; } else // display them in a table { echo "
\n"; echo "\n"; display_table_head(); echo "\n"; $last_repeat_id = null; $is_series = false; foreach ($rows as $row) { if ($row['repeat_id'] != $last_repeat_id) // there's some kind of change { $last_repeat_id = $row['repeat_id']; if ($is_series) { // end the last series table if there was one $is_series = false; echo "
\n"; } if (!empty($row['repeat_id'])) { // we're starting a new series $is_series = true; // Put in the title row display_series_title_row($row); echo "\n"; echo ""; $table_id = "subtable_" . $row['repeat_id']; echo "
\n"; echo "\n"; display_subtable_head($row); echo "\n"; } } display_entry_row($row); } if ($is_series) { // if we were in a series, then close the sub-table echo "
\n"; } echo "\n"; echo "\n"; echo "\n"; } print_footer();