forked from pdxlibrary/LibRooms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_summary.php
153 lines (112 loc) · 5.34 KB
/
report_summary.php
1
<?phpsession_start();require_once("config/config.inc.php");require_once("config/strings.inc.php");require_once("includes/Database.php");require_once("load.php");require_once("includes/verify_access.php");restrict_access($db,array("staff","admin"));require_once("includes/header.php");print("<div id='PageTitle'>Summary Report</div>\n");print("<div class='breadcrumb'><a href='http://library.pdx.edu'>Home</a> » <a href='index.php'>Reserve a Study Room</a> » <a href='reports.php'>Reports</a> » Summary Report</div>\n");print("<br>\n");$select_transactions = "select * from transaction_log where log_message like 'Added a new reservation' and active like '1'";$res_transactions = $db->query($select_transactions);while($res_transactions->fetchInto($transaction)){ $all_transactions[$transaction->row_id] = $transaction->user_id;}$select_reservations = "select * from reservations where date >= '2012-09-24' and active like '1'";$res_reservations = $db->query($select_reservations);while($res_reservations->fetchInto($reservation)){ //print("id: $reservation->id - for: $reservation->user_id - by: ".$all_transactions[$reservation->id]."<br>\n"); if($reservation->user_id == 0 || $reservation->user_id == '') $no_assigned_user++; else if($all_transactions[$reservation->id] == 0 || $all_transactions[$reservation->id] == '') $no_created_by_user++; else if($all_transactions[$reservation->id] == $reservation->user_id) $patron_reserved++; else $otf++; $status[$reservation->status]++;}print("<h1>Stats since 9/24/2012</h1>\n");print("<hr width='50%' align='left'>\n");print("<h2>Total Reservations and Checkouts: <b>".number_format(array_sum($status))."</b></h2>\n");print("<br>\n");print("<h2>Completed: <b>".$status["Completed"]."</b><br>\n");print("<h2>Currently Checked Out: <b>".$status["Checked Out"]."</b><br>\n");print("<h2>Currently Scheduled: <b>".$status["Scheduled"]."</b><br>\n");print("<h2>Cancelled: <b>".$status["Cancelled"]."</b><br>\n");print("<br>\n");$patron_reserved_percent = round($patron_reserved/array_sum($status),4)*100;$otf_percent = round($otf/array_sum($status),4)*100;print("<h2>Reserved by Patron: <b>$patron_reserved ($patron_reserved_percent%)</b><br>\n");print("<h2>Reserved by Staff (on-the-fly checkouts): <b>$otf ($otf_percent%)</b><br>\n");require_once("includes/footer.php");/*$this_month_start = date("Y-m-01",strtotime('now'));$next_month_start = date("Y-m-01",strtotime('+1 month'));$last_month_start = date("Y-m-01",strtotime('-1 month'));$summary_data = get_summary_report_data($this_month_start,$next_month_start);$summary_data = get_summary_report_data($last_month_start,$this_month_start);exit(); $options = array(); $options['active'] = 1; $reservations = load_reservations($options); foreach($reservations as $reservation) { print("<tr><td align='center'>".date('m/d/Y',strtotime($reservation->date))."</td>"); print("<td align='center'>".$reservation->room->room_number."</td>"); print("<td align='center'>".date('g:ia',strtotime($reservation->sched_start_time))."</td>"); print("<td align='center'>".date('g:ia',strtotime($reservation->sched_end_time))."</td>"); if(strcmp($reservation->key_checkout_time,'')) print("<td align='center'>".date('g:ia',strtotime($reservation->key_checkout_time))."</td>"); else print("<td></td>"); $overdue_by = number_format(round((strtotime('now') - strtotime($reservation->sched_end_time))/(3600),2),2); print("<td align='center'>$overdue_by</td>"); $user = get_user_by_id($reservation->user_id); print("<td align='center'>".$user->patron_id."</td>"); print("<td align='center'>$reservation->status</td>"); print("<td align='center'><a href='reservation_details.php?reservation_id=$reservation->id'>details</a></td>"); print("</tr>\n"); } print("</tbody>\n"); print("</table>\n"); require_once("includes/footer.php");}else{ header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=study_rooms_usage_report.xls"); print("<table id='overdue_report_table' width='100%' border><thead><tr><th>Date</th><th>Room</th><th>Sched Start</th><th>Sched End</th><th>Checkout Time</th><th>Hours Overdue</th><th>Patron ID</th><th>Status</th>"); print("</tr></thead>\n"); print("<tbody>\n"); $options = array(); $options['active'] = 1; $options['overdue'] = 1; $reservations = load_reservations($options); foreach($reservations as $reservation) { print("<tr><td align='center'>".date('m/d/Y',strtotime($reservation->date))."</td>"); print("<td align='center'>".$reservation->room->room_number."</td>"); print("<td align='center'>".date('g:ia',strtotime($reservation->sched_start_time))."</td>"); print("<td align='center'>".date('g:ia',strtotime($reservation->sched_end_time))."</td>"); if(strcmp($reservation->key_checkout_time,'')) print("<td align='center'>".date('g:ia',strtotime($reservation->key_checkout_time))."</td>"); else print("<td></td>"); $overdue_by = number_format(round((strtotime('now') - strtotime($reservation->sched_end_time))/(3600),2),2); print("<td align='center'>$overdue_by</td>"); $user = get_user_by_id($reservation->user_id); print("<td align='center'>".$user->patron_id."</td>"); print("<td align='center'>$reservation->status</td>"); print("</tr>\n"); } print("</tbody>\n"); print("</table>\n");}*/?>