You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2014/09/11 18:01:49 UTC

svn commit: r1624325 [6/13] - in /vcl/trunk/web: ./ .ht-inc/ .ht-inc/authmethods/ css/ js/ js/resources/

Modified: vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/requests.php?rev=1624325&r1=1624324&r2=1624325&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/requests.php (original)
+++ vcl/trunk/web/.ht-inc/requests.php Thu Sep 11 16:01:48 2014
@@ -36,1655 +36,2475 @@ define("IMAGEIDERR", 1 << 5);
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \fn newReservation()
+/// \fn viewRequests
 ///
-/// \brief prints form for submitting a new reservation
+/// \brief prints user's reservations
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function newReservation() {
-	global $submitErr, $user, $mode, $skin;
-	$timestamp = processInputVar("stamp", ARG_NUMERIC);
-	$imageid = processInputVar("imageid", ARG_STRING, getUsersLastImage($user['id']));
-	$length = processInputVar("length", ARG_NUMERIC);
-	$day = processInputVar("day", ARG_STRING);
-	$hour = processInputVar("hour", ARG_NUMERIC);
-	$minute = processInputVar("minute", ARG_NUMERIC);
-	$meridian = processInputVar("meridian", ARG_STRING);
-	$imaging = getContinuationVar('imaging', processInputVar('imaging', ARG_NUMERIC, 0));
-
-	if(! $submitErr) {
-		if($imaging)
-			print "<H2>Create / Update an Image</H2>\n";
-		else
-			print _("<H2>New Reservation</H2><br>\n");
-	}
-
-	if($imaging) {
-		$resources = getUserResources(array("imageAdmin"));
-		if(empty($resources['image'])) {
-			print "You don't have access to any base images from which to create ";
-			print "new images.<br>\n";
-			return;
-		}
-		if($length == '')
-			$length = 480;
+function viewRequests() {
+	global $user, $inContinuation, $mode, $skin;
+	if($inContinuation)
+		$lengthchanged = getContinuationVar('lengthchanged', 0);
+	else
+		$lengthchanged = processInputVar('lengthchanged', ARG_NUMERIC, 0);
+	$incPaneDetails = processInputVar('incdetails', ARG_NUMERIC, 0);
+	$refreqid = processInputVar('reqid', ARG_NUMERIC, 0);
+	$requests = getUserRequests("all");
+	$images = getImages();
+	$computers = getComputers();
+	$resources = getUserResources(array("imageAdmin"));
+
+	$text = '';
+
+	$newbtnh = '';
+	if(in_array("imageCheckOut", $user["privileges"]) ||
+	   in_array("imageAdmin", $user["privileges"])) {
+		$newbtnh .= "<button id=\"newrequestbtn\" dojoType=\"dijit.form.Button\">\n";
+		$newbtnh .= "  " . _("New Reservation") . "\n";
+		$newbtnh .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
+		$newbtnh .= "    showNewResDlg();\n";
+		$newbtnh .= "  </script>\n";
+		$newbtnh .= "</button><br><br>\n";
 	}
-	else {
-		$resources = getUserResources(array("imageAdmin", "imageCheckOut"));
-		$resources["image"] = removeNoCheckout($resources["image"]);
+
+	if($mode != 'AJviewRequests') {
+		print "<H2>" . _("Current Reservations") . "</H2>\n";
+		if(count($requests) == 0)
+			print "<span id=\"noresspan\">\n";
+		else
+			print "<span id=\"noresspan\" class=\"hidden\">\n";
+		if($newbtnh == '')
+			print _("You have no current reservations and do not have access to create new ones.") . "<br><br>\n";
+		else
+			print _("You have no current reservations.") . "<br><br>\n";
+		print "</span>\n";
+		print $newbtnh;
 	}
 
-	if((! in_array("imageCheckOut", $user["privileges"]) &&
-	   ! in_array("imageAdmin", $user["privileges"])) ||
-	   empty($resources['image'])) {
-		print _("You don't have access to any environments and, therefore, cannot ");
-		print _("make any reservations.<br>\n");
+	if($newbtnh == '')
 		return;
-	}
-	if($imaging) {
-		print "Please select the environment you will be updating or using as a ";
-		print "base for a new image:<br>\n";
-	}
-	else
-		print _("Please select the environment you want to use from the list:<br>\n");
 
-	$images = getImages();
-	$maxTimes = getUserMaxTimes();
-	if(! $imaging) {
-		print "<script language=javascript>\n";
-		print "var defaultMaxTime = {$maxTimes['initial']};\n";
-		print "var maxTimes = {\n";
-		foreach(array_keys($resources['image']) as $imgid) {
-			if(array_key_exists($imgid, $images))
-				print "   $imgid: {$images[$imgid]['maxinitialtime']},\n";
-		}
-		print "   0: 0\n"; // this is because IE doesn't like the last item having a ',' after it
-		print "};\n";
-		print "</script>\n";
-	}
-
-	print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
-	// list of images
-	uasort($resources["image"], "sortKeepIndex");
-	printSubmitErr(IMAGEIDERR);
-	if($submitErr & IMAGEIDERR)
-		print "<br>\n";
-	if($imaging) {
-		if(USEFILTERINGSELECT && count($resources['image']) < FILTERINGSELECTTHRESHOLD) {
-			print "      <select dojoType=\"dijit.form.FilteringSelect\" id=imagesel ";
-			print "onChange=\"updateWaitTime(1);\" tabIndex=1 style=\"width: 400px\" ";
-			print "queryExpr=\"*\${0}*\" highlightMatch=\"all\" autoComplete=\"false\" ";
-			print "name=imageid>\n";
-			foreach($resources['image'] as $id => $image) {
-				if($image == 'No Image')
-					continue;
-				if($id == $imageid)
-					print "        <option value=\"$id\" selected>$image</option>\n";
+	if($mode != 'AJviewRequests')
+		print "<div id=subcontent>\n";
+
+	$refresh = 0;
+	$connect = 0;
+	$failed = 0;
+
+	$normal = '';
+	$imaging = '';
+	$long = '';
+	$server = '';
+	$pendingcnt = 0;
+	$reqids = array();
+	if(checkUserHasPerm('View Debug Information'))
+		$nodes = getManagementNodes();
+	if($count = count($requests)) {
+		$now = time();
+		for($i = 0, $failed = 0, $timedout = 0, $text = '', $showcreateimage = 0, $cluster = 0;
+		   $i < $count;
+		   $i++, $failed = 0, $timedout = 0, $text = '', $cluster = 0) {
+			if($requests[$i]['forcheckout'] == 0 &&
+			   $requests[$i]['forimaging'] == 0)
+				continue;
+			if(count($requests[$i]['reservations']))
+				$cluster = 1;
+			$cdata = array('requestid' => $requests[$i]['id']);
+			$reqids[] = $requests[$i]['id'];
+			$imageid = $requests[$i]["imageid"];
+			$text .= "  <TR valign=top id=reqrow{$requests[$i]['id']}>\n";
+			if(requestIsReady($requests[$i]) && $requests[$i]['useraccountready']) {
+				$connect = 1;
+				# request is ready, print Connect! and End buttons
+				$cont = addContinuationsEntry('AJconnectRequest', $cdata, SECINDAY);
+				$text .= getViewRequestHTMLitem('connectbtn', $cont);
+				if($requests[$i]['serveradmin']) {
+					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
+					$text .= getViewRequestHTMLitem('deletebtn', $cont);
+				}
 				else
-					print "        <option value=\"$id\">$image</option>\n";
+					$text .= "    <TD></TD>\n";
 			}
-			print "      </select>\n";
-		}
-		else
-			printSelectInput('imageid', $resources['image'], $imageid, 1, 0, 'imagesel', "onChange=\"updateWaitTime(1);\"");
-	}
-	else {
-		if(USEFILTERINGSELECT && count($resources['image']) < FILTERINGSELECTTHRESHOLD) {
-			print "      <select dojoType=\"dijit.form.FilteringSelect\" id=imagesel ";
-			print "onChange=\"selectEnvironment();\" tabIndex=1 style=\"width: 400px\" ";
-			print "queryExpr=\"*\${0}*\" highlightMatch=\"all\" autoComplete=\"false\" ";
-			print "name=imageid>\n";
-			foreach($resources['image'] as $id => $image) {
-				if($image == 'No Image')
-					continue;
-				if($id == $imageid)
-					print "        <option value=\"$id\" selected>$image</option>\n";
+			elseif($requests[$i]["currstateid"] == 5) {
+				# request has failed
+				$text .= getViewRequestHTMLitem('failedblock', $requests[$i]['id']);
+				if($requests[$i]['serveradmin']) {
+					$cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
+					$text .= getViewRequestHTMLitem('removebtn', $cont);
+				}
 				else
-					print "        <option value=\"$id\">$image</option>\n";
+					$text .= "    <TD></TD>\n";
+				$failed = 1;
 			}
-			print "      </select>\n";
-		}
-		else
-			printSelectInput('imageid', $resources['image'], $imageid, 1, 0, 'imagesel', "onChange=\"selectEnvironment();\"");
-	}
-	print "<br><br>\n";
+			elseif(datetimeToUnix($requests[$i]["start"]) < $now) {
+				# other cases where the reservation start time has been reached
+				if(($requests[$i]["currstateid"] == 12 &&
+				   $requests[$i]['laststateid'] == 11) ||
+					$requests[$i]["currstateid"] == 11 ||
+					($requests[$i]["currstateid"] == 14 &&
+					$requests[$i]["laststateid"] == 11)) {
+					# request has timed out
+					$text .= getViewRequestHTMLitem('timeoutblock');
+					$timedout = 1;
+					if($requests[$i]['serveradmin']) {
+						$cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
+						$text .= getViewRequestHTMLitem('removebtn', $cont);
+					}
+					else
+						$text .= "    <TD></TD>\n";
+				}
+				else {
+					# computer is loading, print Pending... and Delete button
+					# TODO figure out a different way to estimate for reboot and reinstall states
+					# TODO if user account not ready, print accurate information in details
+					$pendingcnt++;
+					$remaining = 1;
+					if(isComputerLoading($requests[$i], $computers)) {
+						if(datetimeToUnix($requests[$i]["daterequested"]) >=
+						   datetimeToUnix($requests[$i]["start"])) {
+							$startload = datetimeToUnix($requests[$i]["daterequested"]);
+						}
+						else {
+							$startload = datetimeToUnix($requests[$i]["start"]);
+						}
+						$imgLoadTime = getImageLoadEstimate($imageid);
+						if($imgLoadTime == 0)
+							$imgLoadTime = $images[$imageid]['reloadtime'] * 60;
+						$tmp = ($imgLoadTime - ($now - $startload)) / 60;
+						$remaining = sprintf("%d", $tmp) + 1;
+						if($remaining < 1) {
+							$remaining = 1;
+						}
+					}
+					$data = array('text' => '');
+					if($requests[$i]['currstateid'] != 26 &&
+					   $requests[$i]['currstateid'] != 27 &&
+					   $requests[$i]['currstateid'] != 28 &&
+					   $requests[$i]['currstateid'] != 24 &&
+					   ($requests[$i]["currstateid"] != 14 ||
+					   ($requests[$i]['laststateid'] != 26 &&
+					    $requests[$i]['laststateid'] != 27 &&
+					    $requests[$i]['laststateid'] != 28 &&
+					    $requests[$i]['laststateid'] != 24)))
+						$data['text'] = _("<br>Est:&nbsp;") . $remaining . _("&nbsp;min remaining\n");
+					$text .= getViewRequestHTMLitem('pendingblock', $requests[$i]['id'], $data);
+					$refresh = 1;
+					if($requests[$i]['serveradmin'] && $requests[$i]['laststateid'] != 24) {
+						$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
+						$text .= getViewRequestHTMLitem('deletebtn', $cont);
+					}
+					else
+						$text .= "    <TD></TD>\n";
+				}
+			}
+			else {
+				# reservation is in the future
+				$text .= "    <TD></TD>\n";
+				if($requests[$i]['serveradmin']) {
+					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
+					$text .= getViewRequestHTMLitem('deletebtn', $cont);
+				}
+				else
+					$text .= "    <TD></TD>\n";
+			}
+			if(! $failed && ! $timedout) {
+				# print edit button
+				$editcont = addContinuationsEntry('AJeditRequest', $cdata, SECINDAY);
+				$imgcont = addContinuationsEntry('AJstartImage', $cdata, SECINDAY);
+				if($requests[$i]['serveradmin']) {
+					$text .= getViewRequestHTMLitem('openmoreoptions');
+					$text .= getViewRequestHTMLitem('editoption', $editcont);
+					if(array_key_exists($imageid, $resources['image']) && ! $cluster &&            # imageAdmin access, not a cluster,
+					   ($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8)) { # reservation has been in inuse state
+						$text .= getViewRequestHTMLitem('endcreateoption', $imgcont);
+					}
+					/*else
+						$text .= getViewRequestHTMLitem('endcreateoptiondisable');*/
+					// TODO uncomment the following when live imaging works
+					// TODO add a check to ensure it is a VM
+					if(array_key_exists($imageid, $resources['image']) && ! $cluster &&
+					   $requests[$i]['server'] && ($requests[$i]['currstateid'] == 8 ||
+						($requests[$i]['currstateid'] == 14 && $requests[$i]['laststateid'] == 8))) {
+						$chkcdata = $cdata;
+						$chkcdata['checkpoint'] = 1;
+						$imgcont = addContinuationsEntry('AJstartImage', $chkcdata, SECINDAY);
+						$text .= getViewRequestHTMLitem('checkpointoption', $imgcont);
+					}
+					elseif($requests[$i]['server'] && $requests[$i]['currstateid'] == 24)
+						$text .= getViewRequestHTMLitem('checkpointoptiondisable');
+					if($requests[$i]['currstateid'] == 8 ||
+					   (! $cluster &&
+					   $requests[$i]['OSinstalltype'] != 'none' &&
+					   $requests[$i]['currstateid'] != 3 &&
+					   $requests[$i]['laststateid'] != 3 &&
+					   $requests[$i]['currstateid'] != 13 &&
+					   $requests[$i]['laststateid'] != 13 &&
+					   $requests[$i]['currstateid'] != 24 &&
+					   $requests[$i]['laststateid'] != 24 &&
+					   $requests[$i]['currstateid'] != 16 &&
+					   $requests[$i]['laststateid'] != 16 &&
+					   $requests[$i]['currstateid'] != 26 &&
+					   $requests[$i]['laststateid'] != 26 &&
+					   $requests[$i]['currstateid'] != 28 &&
+						$requests[$i]['laststateid'] != 28 &&
+					   $requests[$i]['currstateid'] != 27 &&
+					   $requests[$i]['laststateid'] != 27)) {
+						$cont = addContinuationsEntry('AJrebootRequest', $cdata, SECINDAY);
+						$text .= getViewRequestHTMLitem('rebootoption', $cont);
+						$cont = addContinuationsEntry('AJshowReinstallRequest', $cdata, SECINDAY);
+						$text .= getViewRequestHTMLitem('reinstalloption', $cont);
+					}
+					else {
+						$text .= getViewRequestHTMLitem('rebootoptiondisable');
+						$text .= getViewRequestHTMLitem('reinstalloptiondisable');
+					}
+					$text .= "       </div>\n";
+					$text .= "     </div>\n";
+					$text .= getViewRequestHTMLitem('timeoutdata', $requests[$i]['id'], $requests[$i]);
+					$text .= "    </TD>\n";
+				}
+				else {
+					$text .= "    <TD>";
+					$text .= getViewRequestHTMLitem('timeoutdata', $requests[$i]['id'], $requests[$i]);
+					$text .= "</TD>\n";
+				}
+			}
+			else
+				$text .= "    <TD></TD>\n";
 
-	$imagenotes = getImageNotes($imageid);
-	$desc = '';
-	if(! preg_match('/^\s*$/', $imagenotes['description'])) {
-		$desc = preg_replace("/\n/", '<br>', $imagenotes['description']);
-		$desc = preg_replace("/\r/", '', $desc);
-		$desc = _("<strong>Image Description</strong>:<br>\n") . "$desc<br><br>\n";
-	}
-	print "<div id=imgdesc>$desc</div>\n";
+			# print name of server request
+			if($requests[$i]['server']) {
+				if($requests[$i]['servername'] == '')
+					$text .= getViewRequestHTMLitem('servername', $requests[$i]['prettyimage']);
+				else
+					$text .= getViewRequestHTMLitem('servername', $requests[$i]['servername']);
+			}
 
-	print "<fieldset id=whenuse class=whenusefieldset>\n";
-	if($imaging)
-		print "<legend>When would you like to start the imaging process?</legend>\n";
-	else
-		print _("<legend>When would you like to use the application?</legend>\n");
-	print "&nbsp;&nbsp;&nbsp;<INPUT type=radio name=time id=timenow ";
-	print "onclick='updateWaitTime(0);' value=now checked>";
-	print _("<label for=\"timenow\">Now</label><br>\n");
-	print "&nbsp;&nbsp;&nbsp;<INPUT type=radio name=time value=future ";
-	print "onclick='updateWaitTime(0);' id=\"laterradio\">";
-	print _("<label for=\"laterradio\">Later:</label>\n");
-	if(array_key_exists($imageid, $images))
-		$maxlen = $images[$imageid]['maxinitialtime'];
-	else
-		$maxlen = 0;
-	if($submitErr) {
-		$hour24 = $hour;
-		if($hour24 == 12) {
-			if($meridian == "am") {
-				$hour24 = 0;
-			}
-		}
-		elseif($meridian == "pm") {
-			$hour24 += 12;
-		}
-		list($month, $day, $year) = explode('/', $day);
-		$stamp = datetimeToUnix("$year-$month-$day $hour24:$minute:00");
-		$day = date('l', $stamp);
-		printReserveItems(1, $imaging, $length, $maxlen, $day, $hour, $minute, $meridian);
-	}
-	else {
-		if(empty($timestamp))
-			$timestamp = unixFloor15(time() + 4500);
-		$timeArr = explode(',', date('l,g,i,a', $timestamp));
-		printReserveItems(1, $imaging, $length, $maxlen, $timeArr[0], $timeArr[1], $timeArr[2], $timeArr[3]);
-	}
-	print "</fieldset>\n";
-
-	print "<div id=waittime class=hidden></div><br>\n";
-	$cont = addContinuationsEntry('submitRequest', array('imaging' => $imaging), SECINDAY, 1, 0);
-	print "<INPUT type=hidden name=continuation value=\"$cont\">\n";
-	if($imaging)
-		print "<INPUT id=newsubmit type=submit value=\"Create Imaging Reservation\" ";
-	else
-		print _("<INPUT id=newsubmit type=submit value=\"Create Reservation\" ");
-	print "onClick=\"return checkValidImage();\">\n";
-	print "<INPUT type=hidden id=testjavascript value=0>\n";
-	print "</FORM>\n";
-	$cont = addContinuationsEntry('AJupdateWaitTime', array('imaging' => $imaging));
-	print "<INPUT type=hidden name=waitcontinuation id=waitcontinuation value=\"$cont\">\n";
+			# print name of image, add (Testing) if it is the test version of an image
+			if(!$requests[$i]['server']) {
+				$data = array('addtest' => 0);
+				if($requests[$i]["test"])
+					$data['addtest'] = 1;
+				$text .= getViewRequestHTMLitem('imagename', $requests[$i]['prettyimage'], $data);
+			}
 
-	print "<div dojoType=dijit.Dialog\n";
-	print "      id=\"suggestedTimes\"\n";
-	print "      title=\"" . _("Available Times") . "\"\n";
-	print "      duration=250\n";
-	print "      draggable=true>\n";
-	print "   <div id=\"suggestloading\" style=\"text-align: center\">";
-	print "<img src=\"themes/$skin/css/dojo/images/loading.gif\" ";
-	print "style=\"vertical-align: middle;\"> " . _("Loading...") . "</div>\n";
-	print "   <div id=\"suggestContent\"></div>\n";
-	print "   <input type=\"hidden\" id=\"suggestcont\">\n";
-	print "   <input type=\"hidden\" id=\"selectedslot\">\n";
-	print "   <div align=\"center\">\n";
-	print "   <button id=\"suggestDlgBtn\" dojoType=\"dijit.form.Button\" disabled>\n";
-	print "     " . _("Use Selected Time") . "\n";
-	print "	   <script type=\"dojo/method\" event=\"onClick\">\n";
-	print "       useSuggestedSlot();\n";
-	print "     </script>\n";
-	print "   </button>\n";
-	print "   <button id=\"suggestDlgCancelBtn\" dojoType=\"dijit.form.Button\">\n";
-	print "     " . _("Cancel") . "\n";
-	print "	   <script type=\"dojo/method\" event=\"onClick\">\n";
-	print "       dijit.byId('suggestDlgBtn').set('disabled', true);\n";
-	print "       showDijitButton('suggestDlgBtn');\n";
-	print "       dijit.byId('suggestDlgCancelBtn').set('label', '" . _("Cancel") . "');\n";
-	print "       dijit.byId('suggestedTimes').hide();\n";
-	print "       dojo.byId('suggestContent').innerHTML = '';\n";
-	print "     </script>\n";
-	print "   </button>\n";
-	print "   </div>\n";
-	print "</div>\n";
-}
+			# print start time
+			if(! $requests[$i]['server']) {
+				$data = array('start' => $requests[$i]['start'],
+				              'requested' => $requests[$i]['daterequested']);
+				$text .= getViewRequestHTMLitem('starttime', '', $data);
+			}
 
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn AJupdateWaitTime()
-///
-/// \brief generates html update for ajax call to display estimated wait time
-/// for current selection on new reservation page
-///
-////////////////////////////////////////////////////////////////////////////////
-function AJupdateWaitTime() {
-	global $user, $requestInfo;
-	# proccess length
-	$length = processInputVar('length', ARG_NUMERIC);
-	$times = getUserMaxTimes();
-	$imaging = getContinuationVar('imaging');
-	if(empty($length) ||
-	   ($length > $times['initial'] && ! $imaging ) ||
-		($length > $times['initial'] && $imaging && $length > 720)) {
-		return;
-	}
-	# process imageid
-	$imageid = processInputVar('imageid', ARG_NUMERIC);
-	$resources = getUserResources(array("imageAdmin", "imageCheckOut"));
-	$validImageids = array_keys($resources['image']);
-	if(! in_array($imageid, $validImageids))
-		return;
+			# print end time
+			$data = array('end' => $requests[$i]['end']);
+			$text .= getViewRequestHTMLitem('endtime', '', $data);
 
-	$desconly = processInputVar('desconly', ARG_NUMERIC, 1);
+			# print date requested
+			if(! $requests[$i]['server'])
+				$text .= getViewRequestHTMLitem('requesttime', $requests[$i]['daterequested']);
 
-	$imagenotes = getImageNotes($imageid);
-	if(! preg_match('/^\s*$/', $imagenotes['description'])) {
-		$desc = preg_replace("/\n/", '<br>', $imagenotes['description']);
-		$desc = preg_replace("/\r/", '', $desc);
-		$desc = preg_replace("/'/", '&#39;', $desc);
-		print _("dojo.byId('imgdesc').innerHTML = '<strong>Image Description</strong>:<br>");
-		print "$desc<br><br>'; ";
-	}
+			# print server request details
+			if($requests[$i]['server']) {
+				$data = array('owner' => getUserUnityID($requests[$i]['userid']),
+				              'requesttime' => $requests[$i]['daterequested'],
+				              'admingroup' => $requests[$i]['serveradmingroup'],
+				              'logingroup' => $requests[$i]['serverlogingroup'],
+				              'image' => $requests[$i]['prettyimage'],
+				              'starttime' => $requests[$i]['start']);
+				if($requests[$i]['currstateid'] == 14)
+				  $data['stateid'] = $requests[$i]['laststateid'];
+				else
+				  $data['stateid'] = $requests[$i]['currstateid'];
+				$text .= getViewRequestHTMLitem('serverdetails', $requests[$i]['id'], $data);
+			}
 
-	if($desconly) {
-		if($imaging)
-			print "if(dojo.byId('newsubmit')) dojo.byId('newsubmit').value = 'Create Imaging Reservation';";
-		else
-			print _("if(dojo.byId('newsubmit')) dojo.byId('newsubmit').value = 'Create Reservation';");
-		return;
+			if(checkUserHasPerm('View Debug Information')) {
+				if(! is_null($requests[$i]['vmhostid'])) {
+					$query = "SELECT c.hostname "
+					       . "FROM computer c, " 
+					       .      "vmhost v "
+					       . "WHERE v.id = {$requests[$i]['vmhostid']} AND "
+					       .       "v.computerid = c.id";
+					$qh = doQuery($query, 101);
+					$row = mysql_fetch_assoc($qh);
+					$vmhost = $row['hostname'];
+				}
+				$text .= "    <TD align=center><a id=\"req{$requests[$i]['id']}\" ";
+				$text .= "tabindex=0>{$requests[$i]["id"]}</a>\n";
+				$text .= "<div dojoType=\"vcldojo.HoverTooltip\" connectId=\"req{$requests[$i]['id']}\">";
+				$text .= "<strong>Mgmt node</strong>: {$nodes[$requests[$i]["managementnodeid"]]['hostname']}<br>\n";
+				$text .= "<strong>Computer ID</strong>: {$requests[$i]['computerid']}<br>\n";
+				$text .= "<strong>Comp hostname</strong>: {$computers[$requests[$i]["computerid"]]["hostname"]}<br>\n";
+				$text .= "<strong>Comp IP</strong>: {$requests[$i]["IPaddress"]}<br>\n";
+				$text .= "<strong>Comp State ID</strong>: {$computers[$requests[$i]["computerid"]]["stateid"]}<br>\n";
+				$text .= "<strong>Comp Type</strong>: {$requests[$i]['comptype']}<br>\n";
+				if(! is_null($requests[$i]['vmhostid']))
+					$text .= "<strong>VM Host</strong>: $vmhost<br>\n";
+				$text .= "<strong>Current State ID</strong>: {$requests[$i]["currstateid"]}<br>\n";
+				$text .= "<strong>Last State ID</strong>: {$requests[$i]["laststateid"]}<br>\n";
+				$text .= "</div></TD>\n";
+			}
+			$text .= "  </TR>\n";
+			if($requests[$i]['server'])
+				$server .= $text;
+			elseif($requests[$i]['forimaging'])
+				$imaging .= $text;
+			elseif($requests[$i]['longterm'])
+				$long .= $text;
+			else
+				$normal .= $text;
+		}
 	}
 
-	$images = getImages();
-	$now = time();
-	$start = unixFloor15($now);
-	$end = $start + $length * 60;
-	if($start < $now)
-		$end += 15 * 60;
-	$imagerevisionid = getProductionRevisionid($imageid);
-	$rc = isAvailable($images, $imageid, $imagerevisionid, $start, $end);
-	semUnlock();
-	if($rc < 1) {
-		$cdata = array('now' => 1,
-		               'start' => $start, 
-		               'end' => $end,
-		               'server' => 0,
-		               'imageid' => $imageid);
-		$cont = addContinuationsEntry('AJshowRequestSuggestedTimes', $cdata);
-		if(array_key_exists('subimages', $images[$imageid]) &&
-		   count($images[$imageid]['subimages']))
-			print "dojo.byId('suggestcont').value = 'cluster';";
+	if(! empty($normal)) {
+		if(! empty($imaging) || ! empty($long))
+			$text .= _("You currently have the following <strong>normal</strong> reservations:<br>\n");
 		else
-			print "dojo.byId('suggestcont').value = '$cont';";
-		print "if(dojo.byId('newsubmit')) {";
-		print "if(dojo.byId('newsubmit').value != _('View Available Times')) ";
-		print "resbtntxt = dojo.byId('newsubmit').value; ";
-		print "dojo.byId('newsubmit').value = _('View Available Times');";
-		print "}";
-	}
-	print "dojo.byId('waittime').innerHTML = ";
-	if($rc == -2)
-		print _("'<font color=red>Selection not currently available due to scheduled system downtime for maintenance</font>'; ");
-	elseif($rc < 1) {
-		print _("'<font color=red>Selection not currently available</font>'; ");
-		print "showSuggestedTimes(); ";
+			$text .= _("You currently have the following normal reservations:<br>\n");
+		if($lengthchanged) {
+			$text .= _("<font color=red>NOTE: The maximum allowed reservation ");
+			$text .= _("length for one of these reservations was less than the ");
+			$text .= _("length you submitted, and the length of that reservation ");
+			$text .= _("has been adjusted accordingly.</font>\n");
+		}
+		$text .= "<table id=reslisttable summary=\"lists reservations you currently have\" cellpadding=5>\n";
+		$text .= "  <TR>\n";
+		$text .= "    <TD colspan=3></TD>\n";
+		$text .= _("    <TH>Environment</TH>\n");
+		$text .= _("    <TH>Starting</TH>\n");
+		$text .= _("    <TH>Ending</TH>\n");
+		$text .= _("    <TH>Initially requested</TH>\n");
+		if(checkUserHasPerm('View Debug Information'))
+			$text .= _("    <TH>Req ID</TH>\n");
+		$text .= "  </TR>\n";
+		$text .= $normal;
+		$text .= "</table>\n";
 	}
-	elseif(array_key_exists(0, $requestInfo['loaded']) &&
-		   $requestInfo['loaded'][0]) {
-			print _("'Estimated load time: &lt; 1 minute';");
+	if(! empty($imaging)) {
+		if(! empty($normal))
+			$text .= "<hr>\n";
+		$text .= _("You currently have the following <strong>imaging</strong> reservations:<br>\n");
+		$text .= "<table id=imgreslisttable summary=\"lists imaging reservations you currently have\" cellpadding=5>\n";
+		$text .= "  <TR>\n";
+		$text .= "    <TD colspan=3></TD>\n";
+		$text .= _("    <TH>Environment</TH>\n");
+		$text .= _("    <TH>Starting</TH>\n");
+		$text .= _("    <TH>Ending</TH>\n");
+		$text .= _("    <TH>Initially requested</TH>\n");
+		$computers = getComputers();
+		if(checkUserHasPerm('View Debug Information'))
+			$text .= "    <TH>Req ID</TH>\n";
+		$text .= "  </TR>\n";
+		$text .= $imaging;
+		$text .= "</table>\n";
 	}
-	else {
-		$loadtime = (int)(getImageLoadEstimate($imageid) / 60);
-		if($loadtime == 0)
-			print _("'Estimated load time: &lt; ") . "{$images[$imageid]['reloadtime']}" . _(" minutes';");
-		else
-			printf(_("'Estimated load time: &lt; %2.0f minutes';"), $loadtime + 1);
+	if(! empty($long)) {
+		if(! empty($normal) || ! empty($imaging))
+			$text .= "<hr>\n";
+		$text .= _("You currently have the following <strong>long term</strong> reservations:<br>\n");
+		$text .= "<table id=\"longreslisttable\" summary=\"lists long term reservations you currently have\" cellpadding=5>\n";
+		$text .= "  <TR>\n";
+		$text .= "    <TD colspan=3></TD>\n";
+		$text .= _("    <TH>Environment</TH>\n");
+		$text .= _("    <TH>Starting</TH>\n");
+		$text .= _("    <TH>Ending</TH>\n");
+		$text .= _("    <TH>Initially requested</TH>\n");
+		$computers = getComputers();
+		if(checkUserHasPerm('View Debug Information'))
+			$text .= "    <TH>Req ID</TH>\n";
+		$text .= "  </TR>\n";
+		$text .= $long;
+		$text .= "</table>\n";
 	}
-	if($rc > 0) {
-		if($imaging)
-			print "if(dojo.byId('newsubmit')) dojo.byId('newsubmit').value = 'Create Imaging Reservation';";
-		else
-			print _("if(dojo.byId('newsubmit')) dojo.byId('newsubmit').value = 'Create Reservation';");
+	if(! empty($server)) {
+		if(! empty($normal) || ! empty($imaging) || ! empty($long))
+			$text .= "<hr>\n";
+		$text .= _("You currently have the following <strong>server</strong> reservations:<br>\n");
+		$text .= "<table id=\"longreslisttable\" summary=\"lists server reservations you currently have\" cellpadding=5>\n";
+		$text .= "  <TR>\n";
+		$text .= "    <TD colspan=3></TD>\n";
+		$text .= "    <TH>" . _("Name") . "</TH>\n";
+		$text .= _("    <TH>Ending</TH>\n");
+		$computers = getComputers();
+		$text .= "    <TH>" . _("Details") . "</TH>\n";
+		if(checkUserHasPerm('View Debug Information'))
+			$text .= "    <TH>" . _("Req ID") . "</TH>\n";
+		$text .= "  </TR>\n";
+		$text .= $server;
+		$text .= "</table>\n";
 	}
-}
 
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn AJshowRequestSuggestedTimes()
-///
-/// \brief builds html to display list of available times the selected image
-/// can be used
-///
-////////////////////////////////////////////////////////////////////////////////
-function AJshowRequestSuggestedTimes() {
-	global $user;
-	$data = array();
-	$start = getContinuationVar('start');
-	$end = getContinuationVar('end');
-	$imageid = getContinuationVar('imageid');
-	$now = getContinuationVar('now');
-	$server = getContinuationVar('server');
-	$ip = getContinuationVar('ip', '');
-	$mac = getContinuationVar('mac', '');
-	$requestid = getContinuationVar('requestid', '');
-	$extendonly = getContinuationVar('extendonly', 0);
-	if($now && $start < time()) {
-		# $start should have been decreased by 15 minutes
-		$start = $start + 900;
+	# connect div
+	if($connect) {
+		$text .= _("<br><br>Click the <strong>");
+		$text .= _("Connect!</strong> button to get further ");
+		$text .= _("information about connecting to the reserved system. You must ");
+		$text .= _("click the button from a web browser running on the same computer ");
+		$text .= _("from which you will be connecting to the remote computer; ");
+		$text .= _("otherwise, you may be denied access to the machine.\n");
 	}
-	if($server)
-		$slots = findAvailableTimes($start, $end, $imageid, $user['id'], 0,
-		                            $requestid, $extendonly, $ip, $mac);
-	else
-		$slots = findAvailableTimes($start, $end, $imageid, $user['id'], 1,
-		                            $requestid, $extendonly);
-	$data['status'] = 'success';
-	if($requestid != '') {
-		$reqdata = getRequestInfo($requestid, 0);
-		if(is_null($reqdata)) {
-			$data['status'] = 'resgone';
-			sendJSON($data);
-			return;
-		}
+
+	if($refresh) {
+		$text .= _("<br><br>This page will automatically update ");
+		$text .= _("every 20 seconds until the <font color=red><i>Pending...</i>");
+		$text .= _("</font> reservation is ready.\n");
 	}
-	if(empty($slots)) {
-		$data['html'] = _("There are no available times that<br>the selected image can be used.<br><br>");
-		$data['status'] = 'error';
-		sendJSON($data);
-		return;
+
+	if($failed) {
+		$text .= _("<br><br>An error has occurred that has kept one of your reservations ");
+		$text .= _("from being processed. We apologize for any inconvenience ");
+		$text .= _("this may have caused.\n");
 	}
 
-	$data['data'] = $slots;
-	$html = '';
-	$html .= "<table summary=\"available time slots\" class=\"collapsetable\">";
-	if($extendonly) {
-		$slot = array_pop($slots);
-		$maxextend = $slot['duration'] - (datetimeToUnix($reqdata['end']) - datetimeToUnix($reqdata['start']));
-		if($maxextend < 900) {
-			$data['html'] = _('This reservation can no longer be extended due to<br>')
-			              . _('a reservation immediately following yours.<br><br>');
-			$data['status'] = 'noextend';
-			sendJSON($data);
-			return;
-		}
-		$html .= "<tr>";
-		$html .= "<td></td>";
-		$html .= "<th>" . _("End Time") . "</th>";
-		$html .= "<th>" . _("Extend By") . "</th>";
-		$html .= "</tr>";
-		$cnt = 0;
-		$e = datetimeToUnix($reqdata['end']);
-		$slots = array();
-		for($cnt = 0, $amount = 900, $e = datetimeToUnix($reqdata['end']) + 900;
-		    $cnt < 15 && $amount <= $maxextend && $amount < 7200;
-		    $cnt++, $amount += 900, $e += 900) {
-			$end = strftime('%x %l:%M %P', $e);
-			$extenstion = getReservationExtenstion($amount / 60);
-			if($cnt % 2)
-				$html .= "<tr class=\"tablerow0\">";
-			else
-				$html .= "<tr class=\"tablerow1\">";
-			$html .= "<td><input type=\"radio\" name=\"slot\" value=\"$e\" ";
-			$html .= "id=\"slot$amount\" onChange=\"setSuggestSlot('$e');\"></td>";
-			$html .= "<td><label for=\"slot$amount\">$end</label></td>";
-			$html .= "<td style=\"padding-left: 8px;\">";
-			$html .= "<label for=\"slot$amount\">$extenstion</label></td></tr>";
-			$slots[$e] = array('duration' => $amount,
-			                   'startts' => $slot['startts']);
-		}
-		for(; $cnt < 15 && $amount <= $maxextend;
-		    $cnt++, $amount += 3600, $e += 3600) {
-			$end = strftime('%x %l:%M %P', $e);
-			$extenstion = getReservationExtenstion($amount / 60);
-			if($cnt % 2)
-				$html .= "<tr class=\"tablerow0\">";
-			else
-				$html .= "<tr class=\"tablerow1\">";
-			$html .= "<td><input type=\"radio\" name=\"slot\" value=\"$e\" ";
-			$html .= "id=\"slot$amount\" onChange=\"setSuggestSlot('$e');\"></td>";
-			$html .= "<td><label for=\"slot$amount\">$end</label></td>";
-			$html .= "<td style=\"padding-left: 8px;\">";
-			$html .= "<label for=\"slot$amount\">$extenstion</label></td></tr>";
-			$slots[$e] = array('duration' => $amount,
-			                   'startts' => $slot['startts']);
-		}
-		$data['data'] = $slots;
-	}
-	else {
-		$html .= "<tr>";
-		$html .= "<td></td>";
-		$html .= "<th>" . _("Start Time") . "</th>";
-		$html .= "<th>" . _("Duration") . "</th>";
-		if(checkUserHasPerm('View Debug Information'))
-			$html .= "<th>" . _("Comp. ID") . "</th>";
-		$html .= "</tr>";
-		$cnt = 0;
-		foreach($slots as $key => $slot) {
-			$cnt++;
-			$start = strftime('%x %l:%M %P', $slot['startts']);
-			if(($slot['startts'] - time()) + $slot['startts'] + $slot['duration'] >= 2114402400)
-				# end time >= 2037-01-01 00:00:00
-				$duration = 'indefinite';
-			else
-				$duration = getReservationLength($slot['duration'] / 60);
-			if($cnt % 2)
-				$html .= "<tr class=\"tablerow0\">";
-			else
-				$html .= "<tr class=\"tablerow1\">";
-			$html .= "<td><input type=\"radio\" name=\"slot\" value=\"$key\" id=\"slot$key\" ";
-			$html .= "onChange=\"setSuggestSlot('{$slot['startts']}');\"></td>";
-			$html .= "<td><label for=\"slot$key\">$start</label></td>";
-			$html .= "<td style=\"padding-left: 8px;\">";
-			$html .= "<label for=\"slot$key\">$duration</label></td>";
-			if(checkUserHasPerm('View Debug Information'))
-				$html .= "<td style=\"padding-left: 8px;\">{$slot['compid']}</td>";
-			$html .= "</tr>";
-			if($cnt >= 15)
-				break;
-		}
-	}
-	$html .= "</table>";
-	$data['html'] = $html;
-	$cdata = array('slots' => $slots);
-	sendJSON($data);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn submitRequest()
-///
-/// \brief checks to see if the request can fit in the schedule; adds it if
-/// it fits; notifies the user either way
-///
-////////////////////////////////////////////////////////////////////////////////
-function submitRequest() {
-	global $submitErr, $user, $HTMLheader, $mode, $printedHTMLheader;
+	$cont = addContinuationsEntry('AJviewRequests', array(), SECINDAY);
+	$text .= "<INPUT type=hidden id=resRefreshCont value=\"$cont\">\n";
 
-	if($mode == 'submitTestProd') {
-		$data = getContinuationVar();
-		$data["revisionid"] = $_POST['revisionid'];
-		# TODO check for valid revisionids for each image
-		if(! empty($data["revisionid"])) {
-			foreach($data['revisionid'] as $val) {
-				foreach($val as $val2) {
-					if(! is_numeric($val2) || $val2 < 0) {
-						unset($data['revisionid']);
-						break 2; // TODO make sure this breaks as far as needed
-					}
-				}
-			}
-		}
-	}
-	else {
-		$data = processRequestInput(1);
-	}
-	$imaging = $data['imaging'];
-	if($submitErr) {
-		$printedHTMLheader = 1;
-		print $HTMLheader;
-		if($imaging)
-			print "<H2>Create / Update an Image</H2>\n";
-		else
-			print _("<H2>New Reservation</H2>\n");
-		newReservation();
-		print getFooter();
-		return;
-	}
-	// if user attempts to make a reservation for an image he does not have
-	//   access to, just make it for the first one he does have access to
-	$resources = getUserResources(array("imageAdmin", "imageCheckOut"));
-	$validImageids = array_keys($resources['image']);
-	if(! in_array($data['imageid'], $validImageids))
-		$data['imageid'] = array_shift($validImageids);
+	$text .= "</div>\n";
+	if($mode != 'AJviewRequests') {
+		$text .= newReservationHTML();
 
-	$showrevisions = 0;
-	$subimages = 0;
-	$images = getImages();
-	$revcount = count($images[$data['imageid']]['imagerevision']);
-	if($revcount > 1)
-		$showrevisions = 1;
-	if($images[$data['imageid']]['imagemetaid'] != NULL &&
-	   count($images[$data['imageid']]['subimages'])) {
-		$subimages = 1;
-		foreach($images[$data['imageid']]['subimages'] as $subimage) {
-			$revcount = count($images[$subimage]['imagerevision']);
-			if($revcount > 1)
-				$showrevisions = 1;
-		}
-	}
+		$text .= newReservationConfigHTML();
 
-	if($data["time"] == "now") {
-		$nowArr = getdate();
-		if($nowArr["minutes"] == 0) {
-			$subtract = 0;
-			$add = 0;
-		}
-		elseif($nowArr["minutes"] < 15) {
-			$subtract = $nowArr["minutes"] * 60;
-			$add = 900;
-		}
-		elseif($nowArr["minutes"] < 30) {
-			$subtract = ($nowArr["minutes"] - 15) * 60;
-			$add = 900;
-		}
-		elseif($nowArr["minutes"] < 45) {
-			$subtract = ($nowArr["minutes"] - 30) * 60;
-			$add = 900;
-		}
-		elseif($nowArr["minutes"] < 60) {
-			$subtract = ($nowArr["minutes"] - 45) * 60;
-			$add = 900;
-		}
-		$start = time() - $subtract;
-		$start -= $start % 60;
-		$nowfuture = "now";
-	}
-	else {
-		$add = 0;
-		$hour = $data["hour"];
-		if($data["hour"] == 12) {
-			if($data["meridian"] == "am") {
-				$hour = 0;
-			}
-		}
-		elseif($data["meridian"] == "pm") {
-			$hour = $data["hour"] + 12;
-		}
-
-		$tmp = explode('/', $data["day"]);
-		$start = mktime($hour, $data["minute"], "0", $tmp[0], $tmp[1], $tmp[2]);
-		if($start < time()) {
-			$printedHTMLheader = 1;
-			print $HTMLheader;
-			if($imaging)
-				print "<H2>Create / Update an Image</H2>\n";
-			else
-				print _("<H2>New Reservation</H2>\n");
-			print _("<font color=\"#ff0000\">The time you requested is in the past.");
-			print _(" Please select \"Now\" or use a time in the future.</font><br>\n");
-			$submitErr = 5000;
-			newReservation();
-			print getFooter();
-			return;
-		}
-		$nowfuture = "future";
-	}
-	if($data["ending"] == "length")
-		$end = $start + $data["length"] * 60 + $add;
-	else {
-		$end = datetimeToUnix($data["enddate"]);
-		if($end % (15 * 60))
-			$end = unixFloor15($end) + (15 * 60);
-	}
+		/*$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"imageRevisionDlg\"\n";
+		$text .= "      title=\"" . _("Select Image Revisions") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true\n";
+		$text .= "      width=\"50%\"\n";
+		#$text .= "      height=\"80%\">\n";
+		#$text .= "      style=\"height: 80%; width: 50%;\">\n";
+		$text .= "      style=\"width: 50%;\">\n";
+		#$text .= "<div dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\" style=\"width: 100%; height: 90%;\">\n";
+		#$text .= "<div dojoType=\"dijit.layout.ContentPane\" region=\"top\" style=\"height: 25px;\">\n";
+		$text .= _("There are multiple versions of this environment available.");
+		$text .= "<br>" . _("Please select the version you would like to check out:");
+		#$text .= "\n</div>\n"; # ContentPane
+		#$text .= " <div dojoType=\"dijit.layout.ContentPane\" region=\"center\">\n";
+		#$text .= "   <div id=\"imageRevisionContent\"></div>\n";
+		$text .= "   <div id=\"imageRevisionContent\" style=\"height: 85%; overflow: auto;\"></div>\n";
+		#$text .= "</div>\n"; # ContentPane
+		#$text .= " <div dojoType=\"dijit.layout.ContentPane\" region=\"bottom\" style=\"height: 25px;\">\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"imageRevBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "    " . _("Create Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitNewReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('imageRevisionDlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n"; # center
+		#$text .= "</div>\n"; # ContentPane
+		#$text .= "</div>\n"; # BorderContainer
+		$text .= "</div>\n"; # Dialog*/
 
-	// get semaphore lock
-	if(! semLock())
-		abort(3);
+		$text .= "<div dojoType=dojox.layout.FloatingPane\n";
+		$text .= "      id=resStatusPane\n";
+		$text .= "      resizable=true\n";
+		$text .= "      closable=true\n";
+		$text .= "      title=\"" . _("Detailed Reservation Status") . "\"\n";
+		$text .= "      style=\"width: 350px; ";
+		$text .=               "height: 280px; ";
+		$text .=               "position: absolute; ";
+		$text .=               "left: 0px; ";
+		$text .=               "top: 0px; ";
+		$text .=               "visibility: hidden; ";
+		$text .=               "border: solid 1px #7EABCD;\"\n";
+		$text .= ">\n";
+		$text .= "<script type=\"dojo/method\" event=minimize>\n";
+		$text .= "  this.hide();\n";
+		$text .= "</script>\n";
+		$text .= "<script type=\"dojo/method\" event=close>\n";
+		$text .= "  this.hide();\n";
+		$text .= "  return false;\n";
+		$text .= "</script>\n";
+		$text .= "<div id=resStatusText></div>\n";
+		$text .= "<input type=hidden id=detailreqid value=0>\n";
+		$text .= "</div>\n";
 
-	if(array_key_exists('revisionid', $data) &&
-	   array_key_exists($data['imageid'], $data['revisionid']) &&
-	   array_key_exists(0, $data['revisionid'][$data['imageid']])) {
-		$revisionid = $data['revisionid'][$data['imageid']][0];
-	}
-	else
-		$revisionid = getProductionRevisionid($data['imageid']);
-	$availablerc = isAvailable($images, $data["imageid"], $revisionid, $start,
-	                           $end, 0, 0, 0, $imaging);
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"endResDlg\"\n";
+		$text .= "      title=\"" . _("Delete Reservation") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true\n";
+		$text .= "      style=\"width: 300px;\">\n";
+		$text .= "   <div id=\"endResDlgContent\"></div>\n";
+		$text .= "   <input type=\"hidden\" id=\"endrescont\">\n";
+		$text .= "   <input type=\"hidden\" id=\"endresid\">\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"endResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "    " . _("Delete Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitDeleteReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('endResDlg').hide();\n";
+		$text .= "       dojo.byId('endResDlgContent').innerHTML = '';\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
 
-	$max = getMaxOverlap($user['id']);
-	if($availablerc != 0 && checkOverlap($start, $end, $max)) {
-		$printedHTMLheader = 1;
-		print $HTMLheader;
-		if($imaging)
-			print "<H2>Create / Update an Image</H2>\n";
-		else
-			print _("<H2>New Reservation</H2>\n");
-		if($max == 0) {
-			print _("<font color=\"#ff0000\">The time you requested overlaps with ");
-			print _("another reservation you currently have.  You are only allowed ");
-			print _("to have a single reservation at any given time. Please select ");
-			print _("another time to use the application. If you are finished with ");
-			print _("an active reservation, click \"Current Reservations\", ");
-			print _("then click the \"End\" button of your active reservation.");
-			print "</font><br><br>\n";
-		}
-		else {
-			print _("<font color=\"#ff0000\">The time you requested overlaps with ");
-			print _("another reservation you currently have.  You are allowed ");
-			print _("to have ") . "$max" . _(" overlapping reservations at any given time. ");
-			print _("Please select another time to use the application. If you are ");
-			print _("finished with an active reservation, click \"Current ");
-			print _("Reservations\", then click the \"End\" button of your active ");
-			print _("reservation.</font><br><br>\n");
-		}
-		$submitErr = 5000;
-		newReservation();
-		print getFooter();
-		return;
-	}
-	// if user is owner of the image and there is a test version of the image
-	#   available, ask user if production or test image desired
-	if($mode != "submitTestProd" && $showrevisions &&
-	   ($images[$data["imageid"]]["ownerid"] == $user["id"] || checkUserHasPerm('View Debug Information'))) {
-		#unset($data["testprod"]);
-		$printedHTMLheader = 1;
-		print $HTMLheader;
-		if($imaging)
-			print "<H2>Create / Update an Image</H2>\n";
-		else
-			print _("<H2>New Reservation</H2>\n");
-		if($subimages) {
-			print _("This is a cluster environment. At least one image in the ");
-			print _("cluster has more than one version available. Please select ");
-			print _("the version you desire for each image listed below:<br>\n");
-		}
-		else {
-			print _("There are multiple versions of this environment available.  Please ");
-			print _("select the version you would like to check out:<br>\n");
-		}
-		print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post><br>\n";
-		if(! array_key_exists('subimages', $images[$data['imageid']]))
-			$images[$data['imageid']]['subimages'] = array();
-		array_unshift($images[$data['imageid']]['subimages'], $data['imageid']);
-		$cnt = 0;
-		foreach($images[$data['imageid']]['subimages'] as $subimage) {
-			print "{$images[$subimage]['prettyname']}:<br>\n";
-			print "<table summary=\"lists versions of the selected environment, one must be selected to continue\">\n";
-			print "  <TR>\n";
-			print "    <TD></TD>\n";
-			print "    <TH>" . _("Version") . "</TH>\n";
-			print "    <TH>" . _("Creator") . "</TH>\n";
-			print "    <TH>" . _("Created") . "</TH>\n";
-			print "    <TH>" . _("Currently in Production") . "</TH>\n";
-			print "  </TR>\n";
-			foreach($images[$subimage]['imagerevision'] as $revision) {
-				print "  <TR>\n";
-				// if revision was selected or it wasn't selected but it is the production revision, show checked
-				if((array_key_exists('revisionid', $data) &&
-				   array_key_exists($subimage, $data['revisionid']) &&
-					array_key_exists($cnt, $data['revisionid'][$subimage]) &&
-				   $data['revisionid'][$subimage][$cnt] == $revisionid['id']) ||
-				   $revision['production'])
-					print "    <TD align=center><INPUT type=radio name=revisionid[$subimage][$cnt] value={$revision['id']} checked></TD>\n";
-				else
-					print "    <TD align=center><INPUT type=radio name=revisionid[$subimage][$cnt] value={$revision['id']}></TD>\n";
-				print "    <TD align=center>{$revision['revision']}</TD>\n";
-				print "    <TD align=center>{$revision['user']}</TD>\n";
-				print "    <TD align=center>{$revision['prettydate']}</TD>\n";
-				if($revision['production'])
-					print _("    <TD align=center>Yes</TD>\n");
-				else
-					print _("    <TD align=center>No</TD>\n");
-				print "  </TR>\n";
-			}
-			print "</table>\n";
-			$cnt++;
-		}
-		$cont = addContinuationsEntry('submitTestProd', $data);
-		print "<br><INPUT type=hidden name=continuation value=\"$cont\">\n";
-		if($imaging)
-			print "<INPUT type=submit value=\"Create Imaging Reservation\">\n";
-		else
-			print _("<INPUT type=submit value=\"Create Reservation\">\n");
-		print "</FORM>\n";
-		print getFooter();
-		return;
-	}
-	if($availablerc == -1) {
-		$printedHTMLheader = 1;
-		print $HTMLheader;
-		if($imaging)
-			print _("<H2>Create / Update an Image</H2>\n");
-		else
-			print _("<H2>New Reservation</H2>\n");
-		print _("You have requested an environment that is limited in the number ");
-		print _("of concurrent reservations that can be made. No further ");
-		print _("reservations for the environment can be made for the time you ");
-		print _("have selected. Please select another time to use the ");
-		print _("environment.<br>");
-		addLogEntry($nowfuture, unixToDatetime($start), 
-		            unixToDatetime($end), 0, $data["imageid"]);
-		print getFooter();
-	}
-	elseif($availablerc > 0) {
-		$requestid = addRequest($imaging, $data["revisionid"]);
-		if($data["time"] == "now") {
-			$cdata = array('lengthchanged' => $data['lengthchanged']);
-			$cont = addContinuationsEntry('viewRequests', $cdata);
-			header("Location: " . BASEURL . SCRIPT . "?continuation=$cont");
-			return;
-		}
-		else {
-			if($data["minute"] == 0)
-				$data["minute"] = "00";
-			$printedHTMLheader = 1;
-			print $HTMLheader;
-			if($imaging)
-				print _("<H2>Create / Update an Image</H2>\n");
-			else
-				print _("<H2>New Reservation</H2>\n");
-			if($data["ending"] == "length") {
-				$time = prettyLength($data["length"]);
-				if($data['testjavascript'] == 0 && $data['lengthchanged']) {
-					print _("<font color=red>NOTE: The maximum allowed reservation ");
-					print _("length for this environment is ") . "$time" . _(", and the length of ");
-					print _("this reservation has been adjusted accordingly.</font>\n");
-					print "<br><br>\n";
-				}
-				print _("Your request to use <b>") . $images[$data["imageid"]]["prettyname"];
-				print _("</b> on ") . prettyDatetime($start) . _(" for ") . "$time" . _(" has been ");
-				print _("accepted.<br><br>\n");
-			}
-			else {
-				print _("Your request to use <b>") . $images[$data["imageid"]]["prettyname"];
-				print _("</b> starting ") . prettyDatetime($start) . _(" and ending ");
-				print prettyDatetime($end) . _(" has been accepted.<br><br>\n");
-			}
-			print _("When your reservation time has been reached, the <strong>");
-			print _("Current Reservations</strong> page will have further ");
-			print _("instructions on connecting to the reserved computer.  If you ");
-			print _("would like to modify your reservation, you can do that from ");
-			print _("the <b>Current Reservations</b> page as well.<br>\n");
-			print getFooter();
-		}
-	}
-	else {
-		$cdata = array('imageid' => $data['imageid'],
-		               'length' => $data['length'],
-		               'showmessage' => 1,
-		               'imaging' => $imaging);
-		$cont = addContinuationsEntry('selectTimeTable', $cdata);
-		addLogEntry($nowfuture, unixToDatetime($start), 
-		            unixToDatetime($end), 0, $data["imageid"]);
-		header("Location: " . BASEURL . SCRIPT . "?continuation=$cont");
-	}
-}
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"remResDlg\"\n";
+		$text .= "      title=\"" . _("Remove Reservation") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "   <div id=\"remResDlgContent\"></div>\n";
+		$text .= "   <input type=\"hidden\" id=\"remrescont\">\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"remResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Remove Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitRemoveReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('remResDlg').hide();\n";
+		$text .= "       dojo.byId('remResDlgContent').innerHTML = '';\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
 
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn viewRequests
-///
-/// \brief prints user's reservations
-///
-////////////////////////////////////////////////////////////////////////////////
-function viewRequests() {
-	global $user, $inContinuation, $mode, $skin;
-	if($inContinuation)
-		$lengthchanged = getContinuationVar('lengthchanged', 0);
-	else
-		$lengthchanged = processInputVar('lengthchanged', ARG_NUMERIC, 0);
-	$incPaneDetails = processInputVar('incdetails', ARG_NUMERIC, 0);
-	$refreqid = processInputVar('reqid', ARG_NUMERIC, 0);
-	$requests = getUserRequests("all");
-	$images = getImages();
-	$computers = getComputers();
-	$resources = getUserResources(array("imageAdmin"));
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"editResDlg\"\n";
+		$text .= "      title=\"" . _("Modify Reservation") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "    <script type=\"dojo/connect\" event=onHide>\n";
+		$text .= "      hideEditResDlg();\n";
+		$text .= "    </script>\n";
+		$text .= "   <div id=\"editResDlgContent\"></div>\n";
+		$text .= "   <input type=\"hidden\" id=\"editrescont\">\n";
+		$text .= "   <input type=\"hidden\" id=\"editresid\">\n";
+		$text .= "   <div id=\"editResDlgErrMsg\" class=\"rederrormsg\"></div>\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"editResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Modify Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitEditReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\" id=\"editResCancelBtn\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('editResDlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
 
-	if(count($requests) == 0) {
-		if($mode == 'AJviewRequests')
-			print "document.body.style.cursor = 'default';";
-		$text  = _("<H2>Current Reservations</H2>");
-		$text .= _("You have no current reservations.<br>");
-		if($mode == 'AJviewRequests')
-			print(setAttribute('subcontent', 'innerHTML', $text));
-		else
-			print $text;
-		return;
-	}
-	if($mode != 'AJviewRequests')
-		print "<div id=subcontent>\n";
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"rebootdlg\"\n";
+		$text .= "      title=\"" . _("Reboot Reservation") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "    <script type=\"dojo/connect\" event=onHide>\n";
+		$text .= "      hideRebootResDlg();\n";
+		$text .= "    </script>\n";
+		$text .= "   <div id=\"rebootResDlgContent\">" . _("You can select either a ");
+		$text .= _("soft or a hard reboot. A soft reboot<br>issues a reboot ");
+		$text .= _("command to the operating system. A hard reboot<br>is akin to ");
+		$text .= _("toggling the power switch on a computer. After<br>issuing the ");
+		$text .= _("reboot, it may take several minutes before the<br>machine is ");
+		$text .= _("available again. It is also possible that it will<br>not come ");
+		$text .= _("back up at all. Are you sure you want to continue?") . "<br><br></div>\n";
+		$text .= "   <div id=\"rebootRadios\" style=\"margin-left: 90px;\">\n";
+		$text .= "   <input type=\"radio\" name=\"reboottype\" id=\"softreboot\" checked>\n";
+		$text .= "   <label for=\"softreboot\">" . _("Soft Reboot") . "</label><br>\n";
+		$text .= "   <input type=\"radio\" name=\"reboottype\" id=\"hardreboot\">\n";
+		$text .= "   <label for=\"hardreboot\">" . _("Hard Reboot") . "</label><br><br>\n";
+		$text .= "   </div>\n";
+		$text .= "   <input type=\"hidden\" id=\"rebootrescont\">\n";
+		$text .= "   <div id=\"rebootResDlgErrMsg\" class=\"rederrormsg\"></div>\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"rebootResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Reboot Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitRebootReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('rebootdlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
 
-	$refresh = 0;
-	$connect = 0;
-	$failed = 0;
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"reinstalldlg\"\n";
+		$text .= "      title=\"" . _("Reinstall Reservation") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "    <script type=\"dojo/connect\" event=onHide>\n";
+		$text .= "      hideReinstallResDlg();\n";
+		$text .= "    </script>\n";
+		$text .= "   <div id=\"reinstallloading\" style=\"text-align: center\">";
+		$text .= "<img src=\"themes/$skin/css/dojo/images/loading.gif\" ";
+		$text .= "style=\"vertical-align: middle;\"> " . _("Loading...") . "</div>\n";
+		$text .= "   <div id=\"reinstallResDlgContent\"></div>\n";
+		$text .= "   <input type=\"hidden\" id=\"reinstallrescont\">\n";
+		$text .= "   <div id=\"reinstallResDlgErrMsg\" class=\"rederrormsg\"></div>\n";
+		$text .= "   <div align=\"center\" id=\"reinstallbtns\" class=\"hidden\">\n";
+		$text .= "   <button id=\"reinstallResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Reinstall Reservation") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitReinstallReservation();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('reinstalldlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"suggestedTimes\"\n";
+		$text .= "      title=\"" . _("Available Times") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "   <div id=\"suggestloading\" style=\"text-align: center\">";
+		$text .= "<img src=\"themes/$skin/css/dojo/images/loading.gif\" ";
+		$text .= "style=\"vertical-align: middle;\"> " . _("Loading...") . "</div>\n";
+		$text .= "   <div id=\"suggestContent\"></div>\n";
+		$text .= "   <input type=\"hidden\" id=\"suggestcont\">\n";
+		$text .= "   <input type=\"hidden\" id=\"selectedslot\">\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"suggestDlgBtn\" dojoType=\"dijit.form.Button\" disabled>\n";
+		$text .= "     " . _("Use Selected Time") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       useSuggestedEditSlot();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button id=\"suggestDlgCancelBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('suggestDlgBtn').set('disabled', true);\n";
+		$text .= "       dojo.removeClass('suggestDlgBtn', 'hidden');\n";
+		$text .= "       showDijitButton('suggestDlgBtn');\n";
+		$text .= "       dijit.byId('suggestDlgCancelBtn').set('label', '" . _("Cancel") . "');\n";
+		$text .= "       dijit.byId('suggestedTimes').hide();\n";
+		$text .= "       dojo.byId('suggestContent').innerHTML = '';\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"startimagedlg\"\n";
+		$text .= "      title=\"" . _("Create / Update Image") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "    <script type=\"dojo/connect\" event=onHide>\n";
+		$text .= "      hideStartImageDlg();\n";
+		$text .= "    </script>\n";
+		$text .= "<div id=\"imageendrescontent\">\n";
+		$text .=   "<H2>" . _("Create / Update an Image") . "</H2>\n";
+		$text .= "</div>\n"; # imageendrescontent
+		$text .= "<div id=\"imagekeeprescontent\">\n";
+		$text .=   "<H2>" . _("Keep Reservation &amp; Create / Update an Image") . "</H2>\n";
+		$h  =   _("This process will create a new image or new revision of the image while allowing you to keep your reservation. The node will be taken <b>offline</b> during the image capture process.");
+		$h .=   "\n \n";
+		$h .=   "<strong>" . _("NOTE: The same sanitizing that occurs during normal image capture will take place. This includes things such as deleting temporary files, cleaning out firewall rules, removing user home space, and removing user accounts.");
+		$h .=   "\n</strong> \n";
+		$h .=   _("After the imaging occurs, you will be able to connect to the reservation again. The image will appear to you as if you had just made a new reservation for it.");
+		$h .=   "\n \n";
+		$text .= preg_replace("/(.{1,80}([ \n]|$))/", '\1<br>', $h);
+		$text .= "</div>\n"; # imagekeeprescontent
+		$text .=   _("Are you creating a new image or updating an existing image?") . "<br><br>\n";
+		$text .= "<input type=radio name=imgmode id=newimage value=\"\" checked>\n";
+		$text .= "<label for=newimage>" . _("Creating New Image") . "</label><br>\n";
+		$text .= "<input type=radio name=imgmode id=updateimage value=\"\">\n";
+		$text .= "<label for=updateimage id=\"updateimagelabel\">";
+		$text .= _("Update Existing Image") . "</label>";
+		$text .= "<br><br>\n";
+		$text .= "   <div align=\"center\" id=\"imagebtns\">\n";
+		$text .= "   <button id=\"imageDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Submit") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitCreateUpdateImage();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('startimagedlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"connectDlg\"\n";
+		$text .= "      title=\"" . _("Connect") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      autofocus=false\n";
+		$text .= "      draggable=true\n";
+		$text .= "      width=\"500px\"\n";
+		$text .= "      style=\"width: 500px;\">\n";
+		$text .= "   <div dojoType=\"dijit.layout.ContentPane\" id=\"connectDlgContent\" style=\"overflow: auto;\"></div>\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Close") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('connectDlg').hide();\n";
+		$text .= "       dojo.byId('connectDlgContent').innerHTML = '';\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"timeoutdlg\"\n";
+		$text .= "      title=\"" . _("Reservation Timed Out") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=false>\n";
+		$text .= _("This reservation has timed out<br>and is no longer available.") . "<br><br>\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Okay") . "\n";
+		$text .= "	   <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('timeoutdlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		$text .= "<input type=hidden id=addresourcecont>\n";
+		$obj = new Image();
+		$text .= $obj->addEditDialogHTML(1);
+
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"updateimagedlg\"\n";
+		$text .= "      title=\"" . _("Update Existing Image") . "\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "    <script type=\"dojo/connect\" event=onHide>\n";
+		$text .= "      hideUpdateImageDlg();\n";
+		$text .= "    </script>\n";
+		$text .= "   <div id=\"updateimageDlgContent\">\n";
+		$text .= "      <h3>New Revision Comments</h3>\n";
+		$text .= "      Enter any notes for yourself and other admins about the current ";
+		$text .= "      state of the image.<br>\nThese are optional and are not visible ";
+		$text .= "      to end users:<br>\n";
+		$text .= "      <textarea dojoType=\"dijit.form.Textarea\" id=\"newcomments\" ";
+		$text .= "      style=\"width: 400px; text-align: left;\">\n\n</textarea>\n";
+		$text .= "      <h3>Previous Revision Comments</h3>\n";
+		$text .= "      <div id=\"previouscomments\"></div>\n";
+		$text .= "   </div>\n";
+		$text .= "   <div align=\"center\">\n";
+		$text .= "   <button id=\"updateImageDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Submit") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       submitUpdateImage();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("Cancel") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('updateimagedlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		$text .= "<div dojoType=dijit.Dialog\n";
+		$text .= "      id=\"clickthroughdlg\"\n";
+		$text .= "      duration=250\n";
+		$text .= "      draggable=true>\n";
+		$text .= "   <div id=\"clickthroughDlgContent\">\n";
+		$text .= "   </div>\n";
+		$text .= "   <div align=\"center\" id=\"imagebtns\">\n";
+		$text .= "   <button id=\"clickthroughDlgBtn\" dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("I agree") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       clickThroughAgree();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
+		$text .= "     " . _("I do not agree") . "\n";
+		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
+		$text .= "       dijit.byId('clickthroughdlg').hide();\n";
+		$text .= "       dijit.byId('addeditdlg').hide();\n";
+		$text .= "       dijit.byId('updateimagedlg').hide();\n";
+		$text .= "     </script>\n";
+		$text .= "   </button>\n";
+		$text .= "   </div>\n";
+		$text .= "</div>\n";
+
+		print $text;
+	}
+	else {
+		$text = str_replace("\n", ' ', $text);
+		$text = str_replace("('", "(\'", $text);
+		$text = str_replace("')", "\')", $text);
+		print "document.body.style.cursor = 'default';";
+		if(count($requests) == 0)
+			print "dojo.removeClass('noresspan', 'hidden');";
+		else
+			print "dojo.addClass('noresspan', 'hidden');";
+		if($refresh)
+			print "refresh_timer = setTimeout(resRefresh, 20000);\n";
+		print(setAttribute('subcontent', 'innerHTML', $text));
+		print "AJdojoCreate('subcontent');";
+		if($incPaneDetails) {
+			$text = detailStatusHTML($refreqid);
+			print(setAttribute('resStatusText', 'innerHTML', $text));
+		}
+		print "checkResGone(" . json_encode($reqids) . ");";
+		if($pendingcnt)
+			print "document.title = '$pendingcnt Pending :: VCL :: Virtual Computing Lab';";
+		else
+			print "document.title = 'VCL :: Virtual Computing Lab';";
+		return;
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn getViewRequestHTMLitem($item, $var1, $data)
+///
+/// \param $item - name of HTML section to be generated
+/// \param $var1 - generic variable to be used in HTML
+/// \param $data - an array of any extra data to be used in HTML
+///
+/// \return a string of HTML
+///
+/// \brief generates HTML for a specific portion of the current reservations
+/// page
+///
+////////////////////////////////////////////////////////////////////////////////
+function getViewRequestHTMLitem($item, $var1='', $data=array()) {
+	$r = '';
+	if($item == 'connectbtn') {
+		$r .= "    <TD>\n";
+		$r .= dijitButton('', _("Connect!"), "connectRequest('$var1');");
+		$r .= "    </TD>\n";
+		return $r;
+	}
+	if($item == 'deletebtn') {
+		$r .= "    <TD>\n";
+		$r .= "      <button dojoType=\"dijit.form.Button\">\n";
+		$r .= _(        "Delete Reservation\n");
+		$r .= "        <script type=\"dojo/method\" event=\"onClick\">\n";
+		$r .= "          endReservation('$var1');\n";
+		$r .= "        </script>\n";
+		$r .= "      </button>\n";
+		$r .= "    </TD>\n";
+		return $r;
+	}
+	if($item == 'failedblock') {
+		$r .= "    <TD nowrap>\n";
+		$r .= "      <span class=scriptonly>\n";
+		$r .= "      <span class=compstatelink>";
+		$r .= "<a onClick=\"showResStatusPane($var1); return false;\" ";
+		$r .= "href=\"#\">" . _("Reservation failed") . "</a></span>\n";
+		$r .= "      </span>\n";
+		$r .= "      <noscript>\n";
+		$r .= "      <span class=scriptoff>\n";
+		$r .= "      <span class=compstatelink>";
+		$r .= _("Reservation failed") . "</span>\n";
+		$r .= "      </span>\n";
+		$r .= "      </noscript>\n";
+		$r .= "    </TD>\n";
+		return $r;
+	}
+	if($item == 'removebtn') {
+		$r .= "    <TD>\n";
+		$r .= "      <button dojoType=\"dijit.form.Button\">\n";
+		$r .= "        " . _("Remove") . "\n";
+		$r .= "        <script type=\"dojo/method\" event=\"onClick\">\n";
+		$r .= "          removeReservation('$var1');\n";
+		$r .= "        </script>\n";
+		$r .= "      </button>\n";
+		$r .= "    </TD>\n";
+		return $r;
+	}
+	if($item == 'timeoutblock') {
+		$r .= "    <TD>\n";
+		$r .= "      <span class=compstatelink>" . _("Reservation has timed out") . "</span>\n";
+		$r .= "    </TD>\n";
+		return $r;
+	}
+	if($item == 'pendingblock') {
+		$r .= "    <TD>\n";
+		$r .= "      <span class=scriptonly>\n";
+		$r .= "      <span class=compstatelink><i>";
+		$r .= "<a onClick=\"showResStatusPane($var1); ";
+		$r .= "return false;\" href=\"#\">" . _("Pending...") . "</a></i></span>\n";
+		$r .= "      </span>\n";
+		$r .= "      <noscript>\n";
+		$r .= "      <span class=scriptoff>\n";
+		$r .= "      <span class=compstatelink>";
+		$r .= "<i>" . _("Pending...") . "</i></span>\n";
+		$r .= "      </span>\n";
+		$r .= "      </noscript>\n";
+		if(! empty($data['text']))
+			$r .= "      {$data['text']}";
+		$r .= "    </TD>\n";
+		return $r;
+	}
+	if($item == 'openmoreoptions') {
+		$r .= "    <TD align=right>\n";
+		$r .= "      <div dojoType=\"dijit.form.DropDownButton\">\n";
+		$r .= "        <span>" . _("More Options") . "...</span>\n";
+		$r .= "        <div dojoType=\"dijit.Menu\">\n";
+		return $r;
+	}
+	if($item == 'editoption') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Edit") . "\"\n";
+		$r .= "               onClick=\"editReservation('$var1');\">\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'endcreateoption') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("End Reservation & Create Image") . "\"\n";
+		$r .= "               onClick=\"startImage('$var1');\">\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'endcreateoptiondisable') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("End Reservation & Create Image") . "\" disabled\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'checkpointoption') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Keep Reservation & Create Image") . "\"\n";
+		$r .= "               onClick=\"startImage('$var1');\">\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'checkpointoptiondisable') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Keep Reservation & Create Image") . "\" disabled\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'rebootoption') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Reboot") . "\">\n";
+		$r .= "            <script type=\"dojo/method\" event=\"onClick\">\n";
+		$r .= "              rebootRequest('$var1');\n";
+		$r .= "            </script>\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'rebootoptiondisable') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Reboot") . "\" disabled>\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'reinstalloption') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Reinstall") . "\">\n";
+		$r .= "            <script type=\"dojo/method\" event=\"onClick\">\n";
+		$r .= "              showReinstallRequest('$var1');\n";
+		$r .= "            </script>\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'reinstalloptiondisable') {
+		$r .= "          <div dojoType=\"dijit.MenuItem\"\n";
+		$r .= "               iconClass=\"noicon\"\n";
+		$r .= "               label=\"" . _("Reinstall") . "\" disabled>\n";
+		$r .= "          </div>\n";
+		return $r;
+	}
+	if($item == 'imagename') {
+		$r .= "    <TD>" . str_replace("'", "&#39;", $var1);
+		if($data['addtest'])
+			$r .= _(" (Testing)");
+		$r .= "</TD>\n";
+		return $r;
+	}
+	if($item == 'starttime') {
+		if(datetimeToUnix($data['start']) < datetimeToUnix($data['requested']))
+			$r .= "    <TD>" . prettyDatetime($data['requested'], 1) . "</TD>\n";
+		else
+			$r .= "    <TD>" . prettyDatetime($data['start'], 1) . "</TD>\n";
+		return $r;
+	}
+	if($item == 'endtime') {
+		if($data['end'] == '2038-01-01 00:00:00')
+			$r .= "    <TD>" . _("(none)") . "</TD>\n";
+		else
+			$r .= "    <TD>" . prettyDatetime($data['end'], 1) . "</TD>\n";
+		return $r;
+	}
+	if($item == 'requesttime') {
+		$r .= "    <TD>" . prettyDatetime($var1, 1) . "</TD>\n";
+		return $r;
+	}
+	if($item == 'servername') {
+		$r .= "    <TD>$var1</TD>\n";
+		return $r;
+	}
+	if($item == 'serverdetails') {
+		$r .= "<TD>\n";
+		$r .= "<a id=\"serverdetails$var1\" tabindex=0>";
+		$r .= "<img alt=\"details\" src=\"images/list.gif\"></a>\n";
+		$r .= "<div dojoType=\"vcldojo.HoverTooltip\" connectId=\"";
+		$r .= "serverdetails$var1\">\n";
+		$r .= "<strong>" . _("Owner") . "</strong>:" . " {$data['owner']}<br>\n";
+		$r .= "<strong>" . _("Environment") . "</strong>:" . " {$data['image']}<br>\n";
+		$r .= "<strong>" . _("Start Time") . "</strong>: " . prettyDatetime($data['starttime'], 1) . "<br>\n";
+		$r .= "<strong>" . _("Initially Requested") . "</strong>: " . prettyDatetime($data['requesttime'], 1) . "<br>\n";
+		if(empty($data['admingroup']))
+			$r .= "<strong>" . _("Admin User Group") . "</strong>: (" . _("none") . ")<br>\n";
+		else
+			$r .= "<strong>" . _("Admin User Group") . "</strong>:" . " {$data['admingroup']}<br>\n";
+		if(empty($data['logingroup']))
+			$r .= "<strong>" . _("Access User Group") . "</strong>: " . _("(none)") . "<br>\n";
+		else
+			$r .= "<strong>" . _("Access User Group") . "</strong>:" . " {$data['logingroup']}<br>\n";
+		if($data['stateid'] == 8)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("In Use") . "\n";
+		elseif($data['stateid'] == 24)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Checkpointing") . "\n";
+		elseif($data['stateid'] == 5)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Failed") . "\n";
+		elseif($data['stateid'] == 13)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("New") . "\n";
+		elseif($data['stateid'] == 28)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Hard Rebooting") . "\n";
+		elseif($data['stateid'] == 26)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Soft Rebooting") . "\n";
+		elseif($data['stateid'] == 27)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Reinstalling") . "\n";
+		elseif($data['stateid'] == 6)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Loading") . "\n";
+		elseif($data['stateid'] == 3)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("In Use") . "\n";
+		elseif($data['stateid'] == 11)
+			$r .= "<strong>" . _("Status") . "</strong>: " . _("Timed Out") . "\n";
+		$r .= "</div>\n";
+		$r .= "</TD>\n";
+		return $r;
+	}
+	if($item == 'timeoutdata') {
+		if($data['currstateid'] == 8 ||
+		   ($data['currstateid'] == 14 && $data['laststateid'] == 8)) {
+			$end = datetimeToUnix($data['end']) + 15;
+			$r .= "     <input type=\"hidden\" class=\"timeoutvalue\" value=\"$end\">\n";
+		}
+		else {
+			$timeout = getReservationNextTimeout($data['resid']);
+			if(! is_null($timeout))
+				$r .= "     <input type=\"hidden\" class=\"timeoutvalue\" value=\"$timeout\">\n";
+		}
+		return $r;
+	}
+}
 
-	$normal = '';
-	$imaging = '';
-	$long = '';
-	$server = '';
-	$reqids = array();
-	if(checkUserHasPerm('View Debug Information'))
-		$nodes = getManagementNodes();
-	if($count = count($requests)) {
-		$now = time();
-		for($i = 0, $failed = 0, $timedout = 0, $text = '', $showcreateimage = 0, $cluster = 0;
-		   $i < $count;
-		   $i++, $failed = 0, $timedout = 0, $text = '', $cluster = 0) {
-			if($requests[$i]['forcheckout'] == 0 &&
-			   $requests[$i]['forimaging'] == 0)
-				continue;
-			if(count($requests[$i]['reservations']))
-				$cluster = 1;
-			$cdata = array('requestid' => $requests[$i]['id']);
-			$reqids[] = $requests[$i]['id'];
-			$imageid = $requests[$i]["imageid"];
-			$text .= "  <TR valign=top id=reqrow{$requests[$i]['id']}>\n";
-			if(requestIsReady($requests[$i]) && $requests[$i]['useraccountready']) {
-				$connect = 1;
-				# request is ready, print Connect! and End buttons
-				$cont = addContinuationsEntry('connectRequest', $cdata, SECINDAY);
-				$text .= getViewRequestHTMLitem('connectbtn', $cont);
-				if($requests[$i]['serveradmin']) {
-					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
-					$text .= getViewRequestHTMLitem('deletebtn', $cont);
-				}
-				else
-					$text .= "    <TD></TD>\n";
-			}
-			elseif($requests[$i]["currstateid"] == 5) {
-				# request has failed
-				$text .= getViewRequestHTMLitem('failedblock', $requests[$i]['id']);
-				if($requests[$i]['serveradmin']) {
-					$cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
-					$text .= getViewRequestHTMLitem('removebtn', $cont);
-				}
-				else
-					$text .= "    <TD></TD>\n";
-				$failed = 1;
-			}
-			elseif(datetimeToUnix($requests[$i]["start"]) < $now) {
-				# other cases where the reservation start time has been reached
-				if(($requests[$i]["currstateid"] == 12 &&
-				   $requests[$i]['laststateid'] == 11) ||
-					$requests[$i]["currstateid"] == 11 ||
-					($requests[$i]["currstateid"] == 14 &&
-					$requests[$i]["laststateid"] == 11)) {
-					# request has timed out
-					$text .= getViewRequestHTMLitem('timeoutblock');
-					$timedout = 1;
-					if($requests[$i]['serveradmin']) {
-						$cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
-						$text .= getViewRequestHTMLitem('removebtn', $cont);
-					}
-					else
-						$text .= "    <TD></TD>\n";
-				}
-				else {
-					# computer is loading, print Pending... and Delete button
-					# TODO figure out a different way to estimate for reboot and reinstall states
-					# TODO if user account not ready, print accurate information in details
-					$remaining = 1;
-					if(isComputerLoading($requests[$i], $computers)) {
-						if(datetimeToUnix($requests[$i]["daterequested"]) >=
-						   datetimeToUnix($requests[$i]["start"])) {
-							$startload = datetimeToUnix($requests[$i]["daterequested"]);
-						}
-						else {
-							$startload = datetimeToUnix($requests[$i]["start"]);
-						}
-						$imgLoadTime = getImageLoadEstimate($imageid);
-						if($imgLoadTime == 0)
-							$imgLoadTime = $images[$imageid]['reloadtime'] * 60;
-						$tmp = ($imgLoadTime - ($now - $startload)) / 60;
-						$remaining = sprintf("%d", $tmp) + 1;
-						if($remaining < 1) {
-							$remaining = 1;
-						}
-					}
-					$data = array('text' => '');
-					if($requests[$i]['currstateid'] != 26 &&
-					   $requests[$i]['currstateid'] != 27 &&
-					   $requests[$i]['currstateid'] != 28 &&
-					   ($requests[$i]["currstateid"] != 14 ||
-					   ($requests[$i]['laststateid'] != 26 &&
-					    $requests[$i]['laststateid'] != 27 &&
-					    $requests[$i]['laststateid'] != 28)))
-						$data['text'] = _("<br>Est:&nbsp;") . $remaining . _("&nbsp;min remaining\n");
-					$text .= getViewRequestHTMLitem('pendingblock', $requests[$i]['id'], $data);
-					$refresh = 1;
-					if($requests[$i]['serveradmin']) {
-						$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
-						$text .= getViewRequestHTMLitem('deletebtn', $cont);
-					}
-					else
-						$text .= "    <TD></TD>\n";
-				}
-			}
-			else {
-				# reservation is in the future
-				$text .= "    <TD></TD>\n";
-				if($requests[$i]['serveradmin']) {
-					$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
-					$text .= getViewRequestHTMLitem('deletebtn', $cont);
-				}
-				else
-					$text .= "    <TD></TD>\n";
-			}
-			if(! $failed && ! $timedout) {
-				# print edit button
-				$editcont = addContinuationsEntry('AJeditRequest', $cdata, SECINDAY);
-				$imgcont = addContinuationsEntry('startImage', $cdata, SECINDAY);
-				$imgurl = BASEURL . SCRIPT . "?continuation=$imgcont";
-				if($requests[$i]['serveradmin']) {
-					$text .= getViewRequestHTMLitem('openmoreoptions');
-					$text .= getViewRequestHTMLitem('editoption', $editcont);
-					if(array_key_exists($imageid, $resources['image']) && ! $cluster &&            # imageAdmin access, not a cluster,
-					   ($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8)) { # reservation has been in inuse state
-						$data = array('doescape' => 0);
-						if($mode == 'AJviewRequests')
-							$data['doescape'] = 1;
-						$text .= getViewRequestHTMLitem('endcreateoption', $imgurl, $data);
-					}
-					/*else
-						$text .= getViewRequestHTMLitem('endcreateoptiondisable');*/
-					// todo uncomment the following when live imaging works
-					// todo add a check to ensure it is a VM
-					/*if($requests[$i]['server'] && ($requests[$i]['currstateid'] == 8 ||
-						($requests[$i]['currstateid'] == 14 && $requests[$i]['laststateid'] == 8))) {
-						$cont = addContinuationsEntry('startCheckpoint', $cdata, SECINDAY);
-						$url = BASEURL . SCRIPT . "?continuation=$cont";
-						$data = array('doescape' => 0);
-						if($mode == 'AJviewRequests')
-							$data['doescape'] = 1;
-						$text .= getViewRequestHTMLitem('checkpointoption', $imgurl, $data);
-					}
-					elseif($requests[$i]['server'] && $requests[$i]['currstateid'] == 24)
-						$text .= getViewRequestHTMLitem('checkpointoptiondisable');*/
-					if($requests[$i]['currstateid'] == 8 ||
-					   (! $cluster &&
-					   $requests[$i]['OSinstalltype'] != 'none' &&
-					   $requests[$i]['currstateid'] != 3 &&
-					   $requests[$i]['laststateid'] != 3 &&
-					   $requests[$i]['currstateid'] != 13 &&
-					   $requests[$i]['laststateid'] != 13 &&
-					   $requests[$i]['currstateid'] != 24 &&
-					   $requests[$i]['laststateid'] != 24 &&
-					   $requests[$i]['currstateid'] != 16 &&
-					   $requests[$i]['laststateid'] != 16 &&
-					   $requests[$i]['currstateid'] != 26 &&
-					   $requests[$i]['laststateid'] != 26 &&
-					   $requests[$i]['currstateid'] != 28 &&
-						$requests[$i]['laststateid'] != 28 &&
-					   $requests[$i]['currstateid'] != 27 &&
-					   $requests[$i]['laststateid'] != 27)) {
-						$cont = addContinuationsEntry('AJrebootRequest', $cdata, SECINDAY);
-						$text .= getViewRequestHTMLitem('rebootoption', $cont);
-						$cont = addContinuationsEntry('AJshowReinstallRequest', $cdata, SECINDAY);
-						$text .= getViewRequestHTMLitem('reinstalloption', $cont);
-					}
-					else {
-						$text .= getViewRequestHTMLitem('rebootoptiondisable');
-						$text .= getViewRequestHTMLitem('reinstalloptiondisable');
-					}
-					$text .= "       </div>\n";
-					$text .= "     </div>\n";
-					$text .= getViewRequestHTMLitem('timeoutdata', $requests[$i]['id'], $requests[$i]);
-					$text .= "    </TD>\n";
-				}
-				else {
-					$text .= "    <TD>";
-					$text .= getViewRequestHTMLitem('timeoutdata', $requests[$i]['id'], $requests[$i]);
-					$text .= "</TD>\n";
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn newReservationHTML()
+///
+/// \return html
+///
+/// \brief generates HTML for dialog for creating new reservation
+///
+////////////////////////////////////////////////////////////////////////////////
+function newReservationHTML() {
+	global $user, $skin;
+
+	$forimaging = getContinuationVar('imaging', processInputVar('imaging', ARG_NUMERIC, 0));
+	$checkout = getUserResources(array("imageAdmin", "imageCheckOut"));
+	$imaging = getUserResources(array("imageAdmin"));
+	$server = getUserResources(array("serverCheckOut"), array("available"));
+
+	$imagedata = getImages();
+	$baseaccess = 0;
+	$imagingaccess = 0;
+	$serveraccess = 0;
+	$images = array();
+	$serverimages = array();
+	$dorevisionscont = 0;
+	if(in_array('imageAdmin', $user['privileges']) &&
+	   count($imaging['image'])) {
+		$imagingaccess = 1;
+	}
+	if(in_array('imageCheckOut', $user['privileges']) &&
+	   count($checkout['image'])) {
+		$baseaccess = 1;
+		foreach($checkout['image'] as $id => $name) {
+			$images[$id] = array('name' => $name,
+			                     'basic' => 1,
+			                     'imaging' => 0,
+			                     'server' => 1,
+			                     'checkout' => 1,
+			                     'maxinitialtime' => 0,
+			                     'revisions' => 0);
+			if(array_key_exists($id, $imagedata) &&
+			   ! $imagedata[$id]["forcheckout"])
+				$images[$id]['checkout'] = 0;
+			if($imagingaccess && array_key_exists($id, $imaging['image']))
+				$images[$id]['imaging'] = 1;
+			if(array_key_exists($id, $imagedata) &&
+			   $imagedata[$id]["maxinitialtime"] != 0)
+				$images[$id]['maxinitialtime'] = $imagedata[$id]['maxinitialtime'];
+			$subowner = 0;
+			if(array_key_exists($id, $imagedata) &&
+			   $imagedata[$id]['imagemetaid'] != NULL &&
+				count($imagedata[$id]['subimages'])) {
+				foreach($imagedata[$id]['subimages'] as $subid) {
+					if(array_key_exists($subid, $imagedata) &&
+					   $imagedata[$subid]['ownerid'] == $user['id'] &&
+					   count($imagedata[$subid]['imagerevision']) > 1)
+						$subowner = 1;
 				}
 			}
-			else
-				$text .= "    <TD></TD>\n";
-
-			# print name of server request
-			if($requests[$i]['server']) {
-				if($requests[$i]['servername'] == '')
-					$text .= getViewRequestHTMLitem('servername', $requests[$i]['prettyimage']);
-				else
-					$text .= getViewRequestHTMLitem('servername', $requests[$i]['servername']);
-			}
-
-			# print name of image, add (Testing) if it is the test version of an image
-			if(!$requests[$i]['server']) {
-				$data = array('addtest' => 0);
-				if($requests[$i]["test"])
-					$data['addtest'] = 1;
-				$text .= getViewRequestHTMLitem('imagename', $requests[$i]['prettyimage'], $data);
-			}
-
-			# print start time
-			if(! $requests[$i]['server']) {
-				$data = array('start' => $requests[$i]['start'],
-				              'requested' => $requests[$i]['daterequested']);
-				$text .= getViewRequestHTMLitem('starttime', '', $data);
-			}
-
-			# print end time
-			$data = array('end' => $requests[$i]['end']);
-			$text .= getViewRequestHTMLitem('endtime', '', $data);
-
-			# print date requested
-			if(! $requests[$i]['server'])
-				$text .= getViewRequestHTMLitem('requesttime', $requests[$i]['daterequested']);
-
-			# print server request details
-			if($requests[$i]['server']) {
-				$data = array('owner' => getUserUnityID($requests[$i]['userid']),
-				              'requesttime' => $requests[$i]['daterequested'],
-				              'admingroup' => $requests[$i]['serveradmingroup'],
-				              'logingroup' => $requests[$i]['serverlogingroup'],
-				              'image' => $requests[$i]['prettyimage'],
-				              'starttime' => $requests[$i]['start']);
-				if($requests[$i]['currstateid'] == 14)
-				  $data['stateid'] = $requests[$i]['laststateid'];
-				else
-				  $data['stateid'] = $requests[$i]['currstateid'];
-				$text .= getViewRequestHTMLitem('serverdetails', $requests[$i]['id'], $data);
+			if($subowner || 
+			   (array_key_exists($id, $imagedata) &&
+			   count($imagedata[$id]['imagerevision']) > 1 &&
+			   ($imagedata[$id]['ownerid'] == $user['id'] ||
+				checkUserHasPerm('View Debug Information')))) {

[... 3057 lines stripped ...]