public function init_all_reservation_info($reservation_idx) { $this->init_technicians(); $this->assign('subitems', ReserveDatabaseAPI::get_reserve_subitems($reservation_idx)); $this->assign('subitemlist', ReserveDatabaseAPI::get_subitems()); $this->assign('messages', ReserveDatabaseAPI::get_messages($reservation_idx)); $this->assign('equipment', ReserveDatabaseAPI::get_equipment($reservation_idx)); $equipment = ReserveDatabaseAPI::get_equipment($reservation_idx); $this->assign('equipment', $equipment); $equipment_info = ReserveDatabaseAPI::get_equipment_info($equipment); $this->assign('equipment_info', $equipment_info); $this->assign('reservation_idx', $reservation_idx); $this->assign('reservation', ReserveDatabaseAPI::by_id($reservation_idx)); }
function email_user_approved($reservation_idx) { //emails the user when thier loan has been approved $reserve = ReserveDatabaseAPI::by_id($reservation_idx); $reservation = $reserve[$reservation_idx]; $index = $reserve[$reservation_idx]['building_idx']; $categories = ReserveDatabaseAPI::categories(); $locations = ReserveDatabaseAPI::locations(); $email = new \PSUSmarty(); $email->assign('categories', $categories); $email->assign('locations', $locations); $email->assign('reserve', $reservation); $contents = $email->fetch($GLOBALS['TEMPLATES'] . '/email.user.approve.tpl'); return PSU::mail($reserve[$reservation_idx]['email'], 'Media Request Approved!', $contents, self::headers()); }
<?php respond('/', function ($request, $response, $app) { $app->tpl->assign('step', $_SESSION['cts']['step']); $app->tpl->assign('announcements', ReserveDatabaseAPI::get_current_announcements()); $app->tpl->display('user-home.tpl'); }); respond('/delete', function ($request, $response, $app) { unset($_SESSION['cts']); $response->redirect($GLOBALS['BASE_URL'] . '/user/'); }); respond('/help', function ($request, $response, $app) { $app->tpl->display('help.tpl'); });
$app->tpl->display('history-pending.tpl'); }); //end pending respond('/search/id/[i:id]', function ($request, $response, $app) { $reservation_idx = (int) $request->id; $app->tpl->assign('locations', ReserveDatabaseAPI::locations()); $app->tpl->assign('reservation_idx', $reservation_idx); $app->tpl->assign('reservation', ReserveDatabaseAPI::by_id($reservation_idx)); $app->tpl->display('history-reservation.tpl'); }); //end reservation/search/ respond('/copy/[i:id]', function ($request, $response, $app) { $reservation_idx = (int) $request->id; $app->tpl->assign('locations', ReserveDatabaseAPI::locations()); $app->tpl->assign('reservation_idx', $reservation_idx); $reserve = ReserveDatabaseAPI::by_id($reservation_idx); unset($_SESSION['cts']); $_SESSION['cts']['first_name'] = $reserve[$reservation_idx]['fname']; $_SESSION['cts']['last_name'] = $reserve[$reservation_idx]['lname']; $_SESSION['cts']['phone'] = $reserve[$reservation_idx]['phone']; $_SESSION['cts']['email'] = $reserve[$reservation_idx]['email']; $_SESSION['cts']['title'] = $reserve[$reservation_idx]['title']; $_SESSION['cts']['start_date'] = date('m/d/Y', strtotime($reserve[$reservation_idx]['start_date'])); $_SESSION['cts']['end_date'] = date('m/d/Y', strtotime($reserve[$reservation_idx]['end_date'])); $_SESSION['cts']['location'] = $reserve[$reservation_idx]['building_idx']; $_SESSION['cts']['comments'] = $reserve[$reservation_idx]['memo']; $_SESSION['cts']['room'] = $reserve[$reservation_idx]['room']; $_SESSION['cts']['starthour'] = date("g", strtotime($reserve[$reservation_idx]['start_time'])); $_SESSION['cts']['startminute'] = date("i", strtotime($reserve[$reservation_idx]['start_time'])); $_SESSION['cts']['startampm'] = date("A", strtotime($reserve[$reservation_idx]['start_time'])); $_SESSION['cts']['endhour'] = date("g", strtotime($reserve[$reservation_idx]['end_time']));
$response->redirect($GLOBALS['BASE_URL'] . '/reserve/'); }); //end new reservation respond('POST', '/success', function ($request, $response, $app) { //when the user has finally confirmed their reservation if (count($_SESSION['cts']['equipment']) <= 0) { //check to make sure that there is at least one equipment item selected $_SESSION['errors'][] = "Please select at least one item from the list of equipment."; $response->redirect($GLOBALS['BASE_URL'] . '/reserve/equipment'); } //put the data in the correct form before inserting it into the database $currtime = date('Y-n-j G:i:s'); $categories = ReserveDatabaseAPI::categories(); $start_time = date("H:i:s", strtotime($_SESSION['cts']['start_time'])); $end_time = date("H:i:s", strtotime($_SESSION['cts']['end_time'])); $start_date = date("Y-m-d", strtotime($_SESSION['cts']['start_date'])); $end_date = date("Y-m-d", strtotime($_SESSION['cts']['end_date'])); foreach ($_SESSION['cts']['equipment'] as $i) { $name = $categories[$i]; $equipment .= $name . ", "; } $data = array($_SESSION['wp_id'], $_SESSION['cts']['last_name'], $_SESSION['cts']['first_name'], $_SESSION['cts']['phone'], $_SESSION['cts']['email'], $currtime, $start_date, $start_time, $end_date, $end_time, $_SESSION['cts']['comments'], $_SESSION['cts']['location'], $_SESSION['cts']['room'], $_SESSION['cts']['title'], $_SESSION['cts']['reserve_type'], $equipment, "pending"); $insert_id = ReserveDatabaseAPI::insert_reservation($data); //mail the user and the cts staff CTSEmailAPI::email_user($_SESSION['cts']); CTSEmailAPI::email_CTS($_SESSION['cts'], $insert_id); unset($_SESSION['cts']); //delete the cts session array $app->tpl->display('success.tpl'); }); //end success
function gantt_view_by_equipment($items, $dates) { //this function takes the list of equipment, grabs the reservations //from the dates given and returns a list with the reservation //start date, end date and index with the glpi_id of the equipment as the key $reservations = self::reservation_by_range_equipment($dates); //grab the equipment list for said week foreach ($reservations as $reservation) { //grab the list of equipment from all of the reservations $equipment[] = ReserveDatabaseAPI::get_equipment($reservation); } foreach ($items as $item) { //grab the glpi id from the item $glpi_id = $item['psu_name']; } return $equipment; }
}); //end reservation/searach/id respond('/reservation/addmessage/[i:id]', function ($request, $response, $app) { //adding a message to a loan $username = $_SESSION['username']; $message = $request->message; $message = filter_var($message, FILTER_SANITIZE_STRING); $reservation_idx = $request->id; ReserveDatabaseAPI::add_message($reservation_idx, $message, $username); $response->redirect($GLOBALS['BASE_URL'] . '/admin/reservation/search/id/' . $reservation_idx); }); //add message to reservation respond('/reservation/search/[a:action]', function ($request, $response, $app) { //searching the reservations by their specfic filters //send the data to the search function $data = ReserveDatabaseAPI::search($request); if ($data['redirect_url']) { //if there was a redirect url in the data, redirect the user there $response->redirect($data['redirect_url']); } //otherwise assign the title and reservations $app->tpl->assign('title', $data['title']); $app->tpl->assign('reservation', $data['reservations']); $app->tpl->display('reservation.tpl'); }); //end reservation/search/action respond('/statistics', function ($request, $response, $app) { $statistics = ReserveDatabaseAPI::statistics(); $app->tpl->assign('statistics', $statistics); $app->tpl->display('statistics.tpl'); });
public function search($request) { define('ONE_DAY', 60 * 60 * 24); //defining what one day is $week = date('w'); //define the current week switch ($request->action) { case "nextweek": $start_date = date('Y-m-d', time() - ($week - 7) * ONE_DAY); $end_date = date('Y-m-d', time() - ($week - 13) * ONE_DAY); $fixed_start_date = self::fix_date($start_date); $fixed_end_date = self::fix_date($end_date); $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; //add the dates to the date array, four dates are needed for testing the date ranges //and for proper use with adodb binding $dates = array('start_date' => $start_date, 'end_date' => $end_date, 'start_date2' => $start_date, 'end_date2' => $end_date); $reservation = self::by_date_range($dates); break; case "thisweek": //this shows the information for this week $start_date = date('Y-m-d', time() - $week * ONE_DAY); $end_date = date('Y-m-d', time() - ($week - 6) * ONE_DAY); //add the dates to the date array, four dates are needed for testing the date ranges //and for proper use with adodb binding $dates = array('start_date' => $start_date, 'end_date' => $end_date, 'start_date2' => $start_date, 'end_date2' => $end_date); $fixed_start_date = self::fix_date($start_date); $fixed_end_date = self::fix_date($end_date); $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; $reservation = self::by_date_range($dates); break; case "daterange": $start_date = $request->param('from_date'); $start_date = date('Y-m-d', strtotime($start_date)); $end_date = $request->param('to_date'); $end_date = date('Y-m-d', strtotime($end_date)); $fixed_start_date = ReserveDatabaseAPI::fix_date($start_date); $fixed_end_date = ReserveDatabaseAPI::fix_date($end_date); //add the dates to the date array, four dates are needed for testing the date ranges //and for proper use with adodb binding $dates = array('start_date' => $start_date, 'end_date' => $end_date, 'start_date2' => $start_date, 'end_date2' => $end_date); $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; $reservation = self::by_date_range($dates); break; case "lastweek": //this shows the information from last week $start_date = date('Y-m-d', time() - ($week + 7) * ONE_DAY); $end_date = date('Y-m-d', time() - ($week + 1) * ONE_DAY); $fixed_start_date = self::fix_date($start_date); $fixed_end_date = self::fix_date($end_date); //add the dates to the date array, four dates are needed for testing the date ranges //and for proper use with adodb binding $dates = array('start_date' => $start_date, 'end_date' => $end_date, 'start_date2' => $start_date, 'end_date2' => $end_date); $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; $reservation = self::by_date_range($dates); break; case "today": //this shows the information from today, which is default $start_date = date('Y-m-d'); $fixed_start_date = self::fix_date($start_date); $title = "Reservations for today - {$fixed_start_date}"; $reservation = self::by_date($start_date); break; case "yesterday": //this shows the information from yesterday $start_date = date('Y-m-d', strtotime("-1 day")); $fixed_start_date = self::fix_date($start_date); $title = "Reservations for yesterday - {$fixed_start_date}"; $reservation = self::by_date($start_date); break; case "tommorrow": //this shows the information from tomorrow $start_date = date('Y-m-d', strtotime("+1 day")); $fixed_start_date = self::fix_date($start_date); $title = "Reservations for tomorrow - {$fixed_start_date}"; $reservation = self::by_date($start_date); break; case "pending": //this shows any loans that are pending $query = "pending"; $title = "Pending Reservations"; $reservation = self::by_status($query); break; case "loaned": //this shows any loans that are pending $query = "loaned out"; $title = "Loaned Reservations"; $reservation = self::by_status($query); break; case "outstanding": //this shows any loans that are pending $end_date = date('Y-m-d'); $title = "Outstanding Reservations"; $reservation = self::by_outstanding($end_date); break; case "missing": //this shows any loans that are pending $query = "missing-equipment"; $title = "Missing Reservations"; $reservation = self::by_status($query); break; case "detailed": //this searches between two dates if ($start_date = $request->param('from_date')) { $start_date = date('Y-m-d', strtotime($start_date)); $args['start_date'] = $start_date; $fixed_start_date = self::fix_date($start_date); } if ($end_date = $request->param('to_date')) { $end_date = date('Y-m-d', strtotime($end_date)); $args['end_date'] = $end_date; $fixed_end_date = self::fix_date($end_date); } if ($first_name = $request->param('first_name')) { $args['first_name'] = $first_name; } if ($last_name = $request->param('last_name')) { $args['last_name'] = $last_name; } if ($location = $request->param('location')) { $args['location'] = $location; } if ($reservation_id = $request->param('reservation_id')) { $args['reservation_id'] = $reservation_id; } if (count($args) < 1) { $_SESSION['errors'][] = 'You need to specify at least one criteria.'; $redirect_url = $GLOBALS['BASE_URL'] . '/admin/reservation'; } else { $reservation = self::search_reservation($args); } if ($start_date && $end_date) { //only change the title if there is a start and end date $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; } break; case "thisreservation": $dates = ReserveDatabaseAPI::get_dates($request->id); $fixed_start_date = ReserveDatabaseAPI::fix_date($dates['start_date']); $fixed_end_date = ReserveDatabaseAPI::fix_date($dates['end_date']); $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; break; default: //if there was no parameter, return the dates and reservations for today if ($request->id) { //if there is a request id, load the dates from the reservation $dates = ReserveDatabaseAPI::get_dates($request->id); $fixed_start_date = ReserveDatabaseAPI::fix_date($dates['start_date']); $fixed_end_date = ReserveDatabaseAPI::fix_date($dates['end_date']); $title = "Reservations from {$fixed_start_date} to {$fixed_end_date}"; } else { //if there is not a request id, load today as the default date $start_date = date('Y-m-d'); $end_date = date('Y-m-d'); $dates = array('start_date' => $start_date, 'end_date' => $end_date); $fixed_start_date = self::fix_date($start_date); $title = "Reservations for today - {$fixed_start_date}"; $reservation = self::by_date($start_date); } break; } //end switch $data = array('title' => $title, 'dates' => $dates, 'redirect_url' => $redirect_url, 'reservations' => $reservation); return $data; }