All pastes #628044 Raw Edit

janetgo1

public php v1 · immutable
·published 2007-07-20 18:12 UTC
rendered paste body
<?php // Global variables and functionsrequire_once("/home/csis/public_html/main/_includes/globals.php");restrictAccess("Rooms");$room_found = FALSE;$has_maintenance_history = FALSE;$has_support_ticket_history = FALSE;$has_inventory_items = FALSE;$room_id = "0";if(!empty($_GET['room_id']))	$room_id = $_GET['room_id'];$maintenance_to_display = 5;$tickets_to_display = 5;// Get Room info$sql = "SELECT * FROM csis.Rooms,csis.Buildings,csis.WirelessNetworkTypes			  WHERE Rooms.id={0}				 AND Rooms.building_id=Buildings.id				 AND Rooms.wireless_network_id=WirelessNetworkTypes.id";$safe_sql = prepareSQL($sql, array($room_id));$room_info = mysql_query($safe_sql) or dbError(mysql_error(), $safe_sql);$num_rows = mysql_num_rows($room_info);if($num_rows != 1) {	addError("no_room_found","Information for that room could not be found. Please try selecting another room.");} else {		$room_found = TRUE;		$room_id = mysql_result($room_info,0,"Rooms.id");				// Store Building Prefix, Room Number, and Last Editor to smaller variable name for easier-to-read code		$building_prefix = mysql_result($room_info,0,"Buildings.prefix");		$room_num = mysql_result($room_info,0,"Rooms.room");		$last_editor = mysql_result($room_info,0,"Rooms.edited_by");		// Get Inventory Items		$items_this_room_sql = "SELECT InventoryLocations.item_id                             FROM csis.InventoryLocations,csis.InventoryItems,															csis.InventoryModels,csis.InventoryTypes														WHERE InventoryLocations.item_id=InventoryItems.id														 AND InventoryItems.model_id=InventoryModels.id														 AND InventoryModels.type_id=InventoryTypes.id 														 AND InventoryLocations.room_id = {0}														 AND InventoryItems.status<>'Transferred'														 AND InventoryItems.status<>'Surveyed'														 AND InventoryItems.status<>'Deleted'														GROUP BY InventoryLocations.item_id														ORDER BY InventoryTypes.type ASC";		$safe_sql = prepareSQL($items_this_room_sql, array($room_id));		$items_this_room = mysql_query($safe_sql) or dbError(mysql_error(), $safe_sql);		$items_this_room_num_rows = mysql_num_rows($items_this_room);				if($items_this_room_num_rows > 0)			$had_inventory_items = TRUE;				// Get Maintenance history		$maintenance_sql = "SELECT * FROM csis.Maintenance WHERE room_id={0} ORDER BY time_maintained DESC";		$safe_sql = prepareSQL($maintenance_sql, array($room_id)) . " LIMIT " . $maintenance_to_display;		$maintenance_result = mysql_query($safe_sql) or dbError(mysql_error(), $safe_sql);		$maintenance_num_rows = mysql_num_rows($maintenance_result);				if($maintenance_num_rows > 0)			$has_maintenance_history = TRUE;					// Get Support Ticket history		$support_ticket_sql = "SELECT * FROM csis.SupportTickets WHERE room_id={0} ORDER BY time_added DESC";		$safe_sql = prepareSQL($support_ticket_sql, array($room_id)) . " LIMIT " . $tickets_to_display;		$support_tickets_result = mysql_query($safe_sql) or dbError(mysql_error(), $safe_sql);		$support_tickets_num_rows = mysql_num_rows($support_tickets_result);				if($support_tickets_num_rows > 0)			$has_support_ticket_history = TRUE;			}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">    <!-- InstanceBegin template="/Templates/at-unit-design1_blue.dwt" codeOutsideHTMLIsLocked="false" -->    <head>        <title>            Classroom Support Internal System (CSIS) - Rooms - <?php echo $building_prefix . " " . $room_num; ?>        </title>        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />        <style type="text/css">            @import url("<?php echo PATH_STYLESHEETS; ?>/design1_blue.css");            @import url("<?php echo PATH_STYLESHEETS; ?>/handheld.css") handheld;            <?php if($printer_friendly) { ?>						@import url("<?php echo PATH_STYLESHEETS; ?>/printerfriendly.css");						<?php } ?>        </style>        <script type="text/javascript" language="javascript">        if ((navigator.userAgent.indexOf("MSIE 5")!=-1) && (navigator.platform.indexOf("Mac")!=-1))        document.write("<style type=\"text/css\">@import url(<?php echo PATH_STYLESHEETS; ?>/ie5.css);</style>");        </script>    </head>    <body>		<?php require_once(PATH_INCLUDES."/header.php"); // Include header ?>		<?php require_once(PATH_INCLUDES."/menu.php"); // Include menu ?>                <div id="unitcontent">                    <div id="content">                        <a name="pagecontent" id="pagecontent"></a>                        <p>                            <a href="<?php echo BASE_URL; ?>">Classroom Support Internal System</a>                            &raquo; <a href="<?php echo BASE_URL; ?>/rooms/rooms.php">Rooms</a>														&raquo; <a href="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>"><?php echo $building_prefix . " " . $room_num; ?></a>                        </p>                        <h2>Rooms</h2>                        <?php if($errors) { echo "<p>\n"; printErrorsXHTML(); echo "\n</p>"; } ?>                        <h4>													<a href="<?php echo BASE_URL; ?>/rooms/zonelist.php">Zone List</a>													| <a href="<?php echo BASE_URL; ?>/rooms/buildsheets.php">Build Sheets</a>                        	<?php if(userLoggedIn("Rooms","Edit")) { // If user has Edit authorization, show link to Add Room ?>													| <a href="<?php echo BASE_URL; ?>/rooms/addroom.php?building_id=<?php echo $_GET['building_id']; ?>">Add Room</a>													| <a href="<?php echo BASE_URL; ?>/rooms/addbuilding.php">Add Building</a>													<?php if(!empty($_GET['building_id']) && $_GET['building_id'] != "All") { // If building selected, and building_id is not "All" ?>													| <a href="<?php echo BASE_URL; ?>/rooms/editbuilding.php?building_id=<?php echo $_GET['building_id']; ?>">Edit Building (<?php echo getBuildingPrefix($_GET['building_id']); ?>)</a>													<?php } // End if building selected and building_id is not "All" ?>													<?php } // End if user has Edit authorization ?>												</h4>                        												<p>Go to <a href="<?php echo BASE_URL; ?>/rooms/rooms.php">Building Selector</a>, <a href="<?php echo BASE_URL; ?>/rooms/rooms.php?building_id=All&view_type=CS+Classroom">CS Classrooms</a>, <a href="<?php echo BASE_URL; ?>/rooms/rooms.php?building_id=All&view_type=All">All Rooms</a></p>												<?php if($room_found) { // If room found, display the detailed information ?>													<table width="100%"  border="0" cellspacing="0" class="table-border1" summary="Room Information for <?php echo $building_prefix . " " . $room_num; ?>">														<tr>															<th class="left" scope="col" colspan="2">																<a href="<?php echo BASE_URL; ?>/rooms/rooms.php?building_id=<?php echo mysql_result($room_info,0,"Rooms.building_id"); ?>"><?php echo $building_prefix; ?></a> <?php echo $room_num; ?>															  <?php if(!empty($building_prefix) && !empty($room_num)) { ?>																- <a href="http://www.eng.ufl.edu/roomrequest/index.html?routine=room&sid=29&build=<?php echo $building_prefix; ?>&room=<?php echo $room_num; ?>" target="_blank">View Room Schedule</a>																<?php } // end if building field not empty ?>																<?php if(userLoggedIn("Rooms","Edit")) { // If user has Edit authorization, show link to Edit Room ?>																- <a href="<?php echo BASE_URL; ?>/rooms/editroom.php?room_id=<?php echo $_GET['room_id']; ?>">Edit Room</a>																<?php } // End if user has Edit authorization ?>															</th>														</tr>												                	<tr>					                		<td width="50%">Type:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.type"); ?></td>					                	</tr>					                	<tr>					                		<td>Capacity:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.capacity"); ?></td>					                	</tr>					                	<tr>					                		<td>Tech Podium:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.tech_podium"); ?></td>					                	</tr>					                	<tr>					                		<td>Wireless Network:</td>					                		<td><?php echo mysql_result($room_info,0,"WirelessNetworkTypes.wireless_network"); ?></td>					                	</tr>					                	<tr>					                		<td>TurningPoint Channel #:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.tpchannel"); ?></td>					                	</tr>					                	<tr>					                		<td>Ladder Height:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.ladder_height"); ?></td>					                	</tr>					                	  <tr>					                		<td>Xantech Model:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.xantech"); ?></td>                            </tr>                            <tr>					                		<td>Podium Upgrade:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.podium_upgrade"); ?></td>                            </tr>                            <tr>					                		<td>Status:</td>					                		<td><?php echo mysql_result($room_info,0,"Rooms.status"); ?></td>					                	</tr>	                          					                						                	<tr>					                		<td>Last Edited:</td>					                		<td><?php echo getLDAPFullName($last_editor); ?> - <?php echo getLDAPGatorlink($last_editor); ?> <br />											   					(<?php echo convertMysqlTimestamp(mysql_result($room_info,0,"Rooms.time_edited")); ?>)</td>					                	</tr>					                	<?php $notes = mysql_result($room_info,0,"Rooms.notes");															if(!empty($notes)) { // If there are Notes for this room, display them ?>					                	<tr>					                		<td colspan="2">Notes:</td>					                	</tr>					                	<tr>					                		<td colspan="2"><?php echo $notes; ?>&nbsp;</td>					                	</tr>					                	<?php } // End if there are Notes ?>													</table>																										<?php if(userLoggedIn("Inventory")) { // If user has View or Edit permissions for Inventory section ?>											    <br />													<table width="100%"  border="0" cellspacing="0" class="table-border1" summary="Inventory Items for <?php echo $building_prefix . " " . $room_num; ?>">																				<tr>															<th colspan="5">																Inventory Items																<?php if(userLoggedIn("Inventory","Edit")) { // If user has Edit authorization, show link to Add Inventory Item ?>																	- <a href="<?php echo BASE_URL; ?>/inventory/additem.php?room_id=<?php echo $_GET['room_id']; ?>">Add Inventory Item</a>																<?php } // End if user has Edit authorization ?>															</th>														<tr>														<?php if($had_inventory_items) {															$has_inventory_items = FALSE;															for($i=0; $i < $items_this_room_num_rows; $i++) { // Print all inventory items for this room																		$this_item_id = mysql_result($items_this_room,$i,"item_id");																		$latest_move_id = getLatestInventoryLocationID($this_item_id);																																				$inventory_sql = "SELECT InventoryLocations.time_moved, 																												InventoryLocations.room_id, InventoryLocations.item_id,																												InventoryTypes.type, InventoryBrands.brand, InventoryModels.model,																												InventoryItems.decal_prefix, InventoryItems.decal_num																											FROM csis.InventoryLocations,csis.InventoryTypes,																												csis.InventoryBrands,csis.InventoryModels,csis.InventoryItems																											WHERE InventoryLocations.item_id=InventoryItems.id																												AND InventoryItems.model_id=InventoryModels.id																												AND InventoryModels.type_id=InventoryTypes.id																												AND InventoryModels.brand_id=InventoryBrands.id																												AND InventoryLocations.id = {0}";																		$safe_sql = prepareSQL($inventory_sql, array($latest_move_id));																		$inventory_result = mysql_query($safe_sql) or dbError(mysql_error(), $safe_sql);																		$inventory_num_rows = mysql_num_rows($inventory_result);																		if($inventory_num_rows != 1) { // If query failed																			addError("inventory","Error occurred while retrieving last location for item #" . $this_item_id);																		} else { // If query succeeded and we got exactly one result																			$latest_room_id = mysql_result($inventory_result,0,"room_id");																			if($latest_room_id == $room_id) { // If latest location of this Item is this Room																				if(!$has_inventory_items) { // If first Item found																					$has_inventory_items = TRUE;														 ?>														<tr>															<th width="25%">Equipment Type</th>															<th width="18%">Brand Name</th>															<th width="20%">Model Number</th>															<th width="20%">Decal Number</th>															<th>&nbsp;</th>														<tr>														<?php } // End if first Item found?>														<tr>															<td><?php echo mysql_result($inventory_result,0,"InventoryTypes.type"); ?></td>															<td><?php echo mysql_result($inventory_result,0,"InventoryBrands.brand"); ?></td>															<td><?php echo mysql_result($inventory_result,0,"InventoryModels.model"); ?></td>															<td>																<?php $full_decal_num = mysql_result($inventory_result,0,"InventoryItems.decal_prefix");																		  $decal_num = mysql_result($inventory_result,0,"InventoryItems.decal_num");																			if(!(intval($decal_num) == 0 ))																				$full_decal_num .= $decal_num; ?>																<a href="<?php echo BASE_URL; ?>/inventory/itemdetail.php?item_id=<?php echo mysql_result($inventory_result,0,"InventoryLocations.item_id"); ?>"><?php echo $full_decal_num; ?></a>															</td>															<td><a href="<?php echo BASE_URL; ?>/inventory/moveitem.php?item_id=<?php echo mysql_result($inventory_result,0,"InventoryLocations.item_id"); ?>">Move</a></td>														</tr>														<?php 		} // End if latest location of this Item is this Room																		} // End if query failed														 			} // end for ?>														<?php } 														if(!$has_inventory_items) { ?>														<tr>															<td colspan="5">No Inventory Items Found</td>														</tr>														<?php } // end if has inventory ?>													</table>													<?php } // End if user has View or Edit permissions for Inventory section ?>																										<?php if(userLoggedIn("Maintenance")) { // If user has View or Edit permissions for Maintenance section ?>																								    <br />													<table width="100%"  border="0" cellspacing="0" class="table-border1" summary="Maintenance Information for <?php echo $building_prefix . " " . $room_num; ?>">																				<tr>															<th colspan="6">																Maintenance History																<?php if(userLoggedIn("Maintenance","Edit")) { // If user has Edit authorization, show link to Add Maintenance Record ?>																	- <a href="<?php echo BASE_URL; ?>/maintenance/maintainroom.php?room_id=<?php echo $_GET['room_id']; ?>">Add Maintenance Record</a>																<?php } // End if user has Edit authorization ?>															</th>														<tr>														<?php if($has_maintenance_history) { ?>														<tr>															<th width="18%">Time Added</th>															<th width="32%">Added By</th>															<th width="10%">Desk Count</th>															<th width="15%">Lamp Hours</th>															<th width="10%">Proj. Maint.</th>															<th>Condition</th>														<tr>																												<?php $i = 0;																	while($i < $maintenance_num_rows) { // Print all records of maintenance for this room ?>														<tr>															<?php $comments = mysql_result($maintenance_result,$i,"comments"); ?>															<td<?php if(!empty($comments)) echo " rowspan=\"2\""; ?>><?php echo convertMysqlTimestampNoTime(mysql_result($maintenance_result,$i,"time_maintained")); ?></td>															<td><?php echo getLDAPFullName(mysql_result($maintenance_result,$i,"maintained_by")); ?></td>															<td><?php echo mysql_result($maintenance_result,$i,"desk_count"); ?></td>															<td><?php echo mysql_result($maintenance_result,$i,"lamp_hours"); ?> <?php echo mysql_result($maintenance_result,$i,"lamp_hrs_percent"); ?></td>															<td><?php echo mysql_result($maintenance_result,$i,"projector_maintained"); ?></td>															<td><?php echo mysql_result($maintenance_result,$i,"condition"); ?></td>														</tr>														<?php if(!empty($comments)) { ?>														<tr>															<td colspan="5"><?php echo $comments; ?></td>														</tr>														<?php } ?>														<?php $i++; } // end while ?>														<tr>															<th colspan="6"><a href="<?php echo BASE_URL; ?>/rooms/maintenance_record_history.php?room_id=<?php echo $room_id; ?>">View Entire Maintenance Record History</a>														</tr>														<?php } else { ?>														<tr>															<td colspan="6">No Maintenance History Found</td>														</tr>														<?php } // end if has maintenance history ?>													</table>													<?php } // End if user has View or Edit permissions for Maintenance section ?>																										<?php if(userLoggedIn("Support Tickets")) { // If user has View or Edit permissions for Support Tickets section ?>											    <br />													<table width="100%"  border="0" cellspacing="0" class="table-border1" summary="Support Ticket Information for <?php echo $building_prefix . " " . $room_num; ?>">																				<tr>															<th colspan="3">																Support Ticket History																<?php if(userLoggedIn("Support Tickets","Edit")) { // If user has Edit authorization, show link to Add Support Ticket ?>																	- <a href="<?php echo BASE_URL; ?>/tickets/addticket.php?room_id=<?php echo $_GET['room_id']; ?>">Add Support Ticket</a>																<?php } // End if user has Edit authorization ?>															</th>														<tr>														<?php if($has_support_ticket_history) { // if support ticket history found ?>														<tr>															<th width="30%">Time Added</th>															<th width="45%">Description</th>															<th>Status</th>														<tr>																													<?php $i = 0;																	while($i < $support_tickets_num_rows) { // Print all records of support tickets for this room ?>														<tr>															<td width="30%"><?php echo convertMysqlTimestamp(mysql_result($support_tickets_result,$i,"time_added")); ?></td>															<td>																<a href="<?php echo BASE_URL; ?>/tickets/ticketdetail.php?ticket_id=<?php echo mysql_result($support_tickets_result,$i,"SupportTickets.id"); ?>"><?php $full_description = fixPreparedText(mysql_result($support_tickets_result,$i,"SupportTickets.description"));																$description = substr($full_description,0,50);																if(strlen($full_description) > 50)																	$description .= "...";																echo $description; ?></a>															</td>																                        		<?php $status = mysql_result($support_tickets_result,$i,"SupportTickets.status");																$ticket_class = "ticket_normal";																if($status == "New")																	$ticket_class = "ticket_new";																if($status == "In Progress")																	$ticket_class = "ticket_in_progress";																if($status == "Resolved")																	$ticket_class = "ticket_resolved";																if($status == "Closed by Issuer")																	$ticket_class = "ticket_closed_by_issuer"; ?>																													<th class="<?php echo $ticket_class; ?>"><?php echo mysql_result($support_tickets_result,$i,"status"); ?></th>															</tr>														<?php $i++; } // end while ?>														<tr>															<th colspan="5"><a href="<?php echo BASE_URL; ?>/rooms/support_ticket_history.php?room_id=<?php echo $room_id; ?>">View Entire Support Ticket History</a>														</tr>														<?php } else { ?>														<tr>															<td colspan="3">No Support Ticket History Found</td>														</tr>														<?php } // end if has support ticket history ?>													</table>													<?php } // End if user has View or Edit permissions for Support Tickets section ?>																	          	<?php } // end if room found ?>                    </div>                    <br style="clear:both;" />                </div>			<?php require_once(PATH_INCLUDES."/footer.php"); // Include footer ?>        </div>    </body></html>