Example #1
0
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();
    $noimaging = 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'])) {
                if ($imagedata[$id]['rootaccess'] == 1 || $imagedata[$id]['ownerid'] == $user['id']) {
                    $images[$id]['imaging'] = 1;
                } else {
                    $noimaging[$id] = 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;
                    }
                }
            }
            if ($subowner || array_key_exists($id, $imagedata) && count($imagedata[$id]['imagerevision']) > 1 && ($imagedata[$id]['ownerid'] == $user['id'] || checkUserHasPerm('View Debug Information'))) {
                $images[$id]['revisions'] = 1;
                $dorevisionscont = 1;
            }
        }
    }
    if (in_array('serverCheckOut', $user['privileges']) && count($checkout['image'])) {
        $serveraccess = 1;
        $extraimages = getServerProfileImages($user['id']);
        foreach ($extraimages as $id => $name) {
            if (!array_key_exists($id, $images)) {
                $images[$id] = array('name' => $name, 'basic' => 0, 'imaging' => 0, 'server' => 1, 'checkout' => 1, 'maxinitialtime' => 0, 'revisions' => 0);
                if (array_key_exists($id, $imagedata) && !$imagedata[$id]["forcheckout"]) {
                    $images[$id]['checkout'] = 0;
                }
                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;
                        }
                    }
                }
                if ($subowner || array_key_exists($id, $imagedata) && count($imagedata[$id]['imagerevision']) > 1 && ($imagedata[$id]['ownerid'] == $user['id'] || checkUserHasPerm('View Debug Information'))) {
                    $images[$id]['revisions'] = 1;
                    $dorevisionscont = 1;
                }
            }
        }
    }
    $imageid = getUsersLastImage($user['id']);
    if (is_null($imageid) && count($images)) {
        $tmp = array_keys($images);
        $imageid = $tmp[0];
    }
    uasort($images, "sortKeepIndex");
    $groupid = getUserGroupID('Specify End Time', 1);
    $members = getUserGroupMembers($groupid);
    if (array_key_exists($user['id'], $members)) {
        $openend = 1;
    } else {
        $openend = 0;
    }
    $groupid = getUserGroupID('Allow No User Check', 1);
    $members = getUserGroupMembers($groupid);
    if (array_key_exists($user['id'], $members)) {
        $nousercheck = 1;
    } else {
        $nousercheck = 0;
    }
    $cdata = array('baseaccess' => $baseaccess, 'imagingaccess' => $imagingaccess, 'serveraccess' => $serveraccess, 'openend' => $openend, 'nousercheck' => $nousercheck, 'imaging' => $forimaging, 'noimaging' => $noimaging);
    $debug = processInputVar('debug', ARG_NUMERIC, 0);
    if ($debug && checkUserHasPerm('View Debug Information')) {
        $cdata['debug'] = 1;
    }
    $h = '';
    $h = "<div dojoType=dijit.Dialog\n";
    $h .= "      id=\"newResDlg\"\n";
    $h .= "      title=\"" . i("New Reservation") . "\"\n";
    $h .= "      duration=250\n";
    $h .= "      draggable=true>\n";
    $h .= "   <input type=\"hidden\" id=\"openend\" value=\"{$openend}\">\n";
    $h .= "   <div id=\"newResDlgContent\">\n";
    /*$cbtn  = "   <div align=\"center\"><br>\n";
    	$cbtn .= "   <button dojoType=\"dijit.form.Button\">\n";
    	$cbtn .= "     " . i("Close") . "\n";
    	$cbtn .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
    	$cbtn .= "       dijit.byId('newResDlg').hide();\n";
    	$cbtn .= "     </script>\n";
    	$cbtn .= "   </button>\n";
    	$cbtn .= "   </div>\n"; # center
    
    	if($forimaging) {
    		$h .= "<h2>" . i("Create / Update an Image") . "</h2>\n";
    		if($imagingaccess == 0) {
    			$h .= i("You don't have access to any base images from which to create new images.") . "<br>\n";
    			return $h . $cbtn;
    		}
    	}
    	else*/
    $h .= "<h2>" . i("New Reservation") . "</h2>\n";
    if (!count($images)) {
        $h .= i("You do not have access to any images.");
        $h .= "<br><br>\n";
        $h .= "   <div align=\"center\"><br>\n";
        $h .= "   <button dojoType=\"dijit.form.Button\">\n";
        $h .= "     " . i("Close") . "\n";
        $h .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $h .= "       dijit.byId('newResDlg').hide();\n";
        $h .= "     </script>\n";
        $h .= "   </button>\n";
        $h .= "   </div>\n";
        # center
        $h .= "</div>\n";
        # newResDlgContent
        $h .= "</div>\n";
        # newResDlg
        return $h;
    }
    $chk = array('base' => '', 'imaging' => '', 'server' => '');
    if (!$baseaccess && $serveraccess) {
        $chk['server'] = 'checked';
    } elseif ($forimaging) {
        $chk['imaging'] = 'checked';
    } else {
        $chk['base'] = 'checked';
    }
    $showradios = 0;
    if ($baseaccess + $imagingaccess + $serveraccess > 1) {
        $showradios = 1;
    }
    if ($showradios) {
        $h .= i("Reservation type:") . "<br>\n";
    }
    $h .= "<span";
    if (!$baseaccess || $showradios == 0) {
        $h .= " class=\"hidden\"";
    }
    $h .= "><input type=\"radio\" id=\"basicrdo\" name=\"restype\" ";
    $h .= "onclick=\"selectResType();\" {$chk['base']}>\n";
    $h .= "<label for=\"basicrdo\">" . i("Basic Reservation");
    $h .= "</label></span>\n";
    $h .= "<span";
    if (!$imagingaccess || $showradios == 0) {
        $h .= " class=\"hidden\"";
    }
    $h .= "><input type=\"radio\" id=\"imagingrdo\" name=\"restype\" ";
    $h .= "onclick=\"selectResType();\" {$chk['imaging']}>\n";
    $h .= "<label for=\"imagingrdo\">" . i("Imaging Reservation");
    $h .= "</label></span>\n";
    $h .= "<span";
    if (!$serveraccess || $showradios == 0) {
        $h .= " class=\"hidden\"";
    }
    $h .= "><input type=\"radio\" id=\"serverrdo\" name=\"restype\" ";
    $h .= "onclick=\"selectResType();\" {$chk['server']}>\n";
    $h .= "<label for=\"serverrdo\">" . i("Server Reservation");
    $h .= "</label></span>\n";
    if ($showradios) {
        $h .= "<br><br>\n";
    }
    $h .= "<span id=\"deployprofileslist\" class=\"hidden\">\n";
    $h .= "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"profilesstore\" ";
    $h .= "data=\"profilesstoredata\"></div>\n";
    $h .= i("Profile:") . " ";
    $h .= "<select dojoType=\"dijit.form.Select\" id=\"deployprofileid\" ";
    $h .= "onChange=\"deployProfileChanged();\" sortByLabel=\"true\"></select><br>\n";
    $h .= "<fieldset>\n";
    $h .= "<legend>" . i("Description:") . "</legend>\n";
    $h .= "<div id=\"deploydesc\"></div>\n";
    $h .= "</fieldset>\n";
    $cont = addContinuationsEntry('AJserverProfileData', array('mode' => 'checkout'));
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"deployFetchProfilesBtn\">\n";
    $h .= "\t" . i("Apply Profile") . "\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $h .= "\t\tgetServerProfileData('{$cont}', 'deployprofileid', getServerProfileDataDeployCB);\n";
    $h .= "\t</script>\n";
    $h .= "</button>";
    $h .= "<br><br>\n";
    $h .= "<input type=\"hidden\" id=\"appliedprofileid\" value=\"0\">\n";
    $h .= "</span>\n";
    # deployprofileslist
    $h .= "<div id=\"deployprofilediv\">\n";
    # directions
    $h .= "<span id=\"nrdirections\">";
    $h .= i("Please select the environment you want to use from the list:");
    $h .= "<br></span>\n";
    # javascript for max duration and image store
    $maxTimes = getUserMaxTimes();
    $maximaging = $maxTimes['initial'];
    if ($imagingaccess && $maxTimes['initial'] < MAXINITIALIMAGINGTIME) {
        $maximaging = MAXINITIALIMAGINGTIME;
    }
    $h .= "<script type=\"text/javascript\">\n";
    $h .= "var defaultMaxTime = {$maxTimes['initial']};\n";
    $h .= "var maximaging = {$maximaging};\n";
    $h .= "var images = {identifier: 'id',\n";
    $h .= "label: 'name',\n";
    $h .= "items: [\n";
    $lines = array();
    foreach ($images as $id => $img) {
        $lines[] = "   {id: {$id}, name: '{$img['name']}', basic: {$img['basic']}, " . "imaging: {$img['imaging']}, server: {$img['server']}, " . "checkout: {$img['checkout']}, revisions: {$img['revisions']}, " . "maxinitialtime: {$img['maxinitialtime']}}";
    }
    $h .= implode(",\n", $lines);
    $h .= "\n]};\n";
    $h .= "var lastimageid = {$imageid};\n";
    $h .= "var imagingaccess = {$imagingaccess};\n";
    $h .= "</script>\n";
    $cdata['maxinitial'] = $maxTimes['initial'];
    # image
    $h .= "<span class=\"labeledform\">";
    $h .= resourceStore('image', 1, 'detailimagestore');
    $h .= "<div dojoType=\"dojo.data.ItemFileWriteStore\" data=\"images\" ";
    $h .= "jsId=\"imagestore\"></div>\n";
    $h .= "<select dojoType=\"dijit.form.FilteringSelect\" id=\"deployimage\" ";
    $h .= "style=\"width: 400px\" required=\"true\" store=\"imagestore\" ";
    $h .= "queryExpr=\"*\${0}*\" ";
    if ($forimaging) {
        $h .= "query=\"{imaging: 1}\" ";
    } else {
        $h .= "query=\"{basic: 1, checkout: 1}\" ";
    }
    $h .= "highlightMatch=\"all\" autoComplete=\"false\" ";
    $h .= "invalidMessage=\"Please select a valid environment\" ";
    $h .= "onChange=\"selectEnvironment();\" tabIndex=1></select>\n";
    $h .= "</span><br><br>\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>" . i("Image Description") . "</strong>:<br>\n" . "{$desc}<br><br>\n";
    }
    $h .= "<div id=imgdesc>{$desc}</div>\n";
    # name
    $h .= "<div id=\"newreslabelfields\">\n";
    $h .= "<span id=\"nrnamespan\" class=\"hidden\">\n";
    $h .= "<label for=\"deployname\">" . i("Reservation Name:") . "</label>\n";
    $h .= "<span class=\"labeledform\">\n";
    $h .= "<input type=\"text\" id=\"deployname\" style=\"width: 400px\" ";
    $h .= "dojoType=\"dijit.form.ValidationTextBox\" ";
    $h .= "regExp=\"^([-a-zA-Z0-9_\\. ]){0,255}\$\" invalidMessage=\"";
    $h .= i('The reservation name can only contain letters, numbers, spaces, dashes(-), underscores(_), and periods(.) and can be up to 255 characters long');
    $h .= "\"></span><br></span>\n";
    $h .= "<span id=\"nrservergroupspan\" class=\"hidden\">";
    # admin group
    if ($user['showallgroups']) {
        $admingroups = getUserGroups();
    } else {
        $admingroups = getUserGroups(0, $user['affiliationid']);
    }
    $h .= "<label for=\"deployadmingroup\">";
    $h .= i("Admin User Group:") . "</label><span class=\"labeledform\">";
    if (USEFILTERINGSELECT && count($admingroups) < FILTERINGSELECTTHRESHOLD) {
        $h .= "<select dojoType=\"dijit.form.FilteringSelect\" id=\"deployadmingroup\" ";
        $h .= "style=\"width: 400px\" queryExpr=\"*\${0}*\" required=\"true\" ";
        $h .= "highlightMatch=\"all\" autoComplete=\"false\">\n";
    } else {
        $h .= "<select id=\"deployadmingroup\">\n";
    }
    $h .= "  <option value=\"0\">None</option>\n";
    foreach ($admingroups as $id => $group) {
        if ($group['name'] == 'None' || preg_match('/^None@.*$/', $group['name'])) {
            continue;
        }
        $h .= "  <option value=\"{$id}\">{$group['name']}</option>\n";
    }
    $h .= "</select></span><br>\n";
    $h .= "<div id=\"admingrpnote\" class=\"hidden\" ";
    $h .= "style=\"width: 400px; margin: 3px 0 3px 10.5em; padding: 1px; border: 1px solid;\">";
    $h .= i("Administrative access has been disabled for this image. Users in the Admin User Group will have control of the reservaion on the Reservations page but will not have administrative access within the reservation.");
    $h .= "</div>\n";
    # login group
    $logingroups = $admingroups;
    $h .= "<label for=\"deploylogingroup\">";
    $h .= i("Access User Group:") . "</label><span class=\"labeledform\">";
    if (USEFILTERINGSELECT && count($logingroups) < FILTERINGSELECTTHRESHOLD) {
        $h .= "<select dojoType=\"dijit.form.FilteringSelect\" id=\"deploylogingroup\" ";
        $h .= "style=\"width: 400px\" queryExpr=\"*\${0}*\" required=\"true\" ";
        $h .= "highlightMatch=\"all\" autoComplete=\"false\">\n";
    } else {
        $h .= "<select id=\"deploylogingroup\">\n";
    }
    $h .= "  <option value=\"0\">None</option>\n";
    foreach ($logingroups as $id => $group) {
        if ($group['name'] == 'None' || preg_match('/^None@.*$/', $group['name'])) {
            continue;
        }
        $h .= "  <option value=\"{$id}\">{$group['name']}</option>\n";
    }
    $h .= "</select></span><br></span>\n";
    # fixed MAC
    /*$h .= "<span id=\"nrmacaddrspan\">\n";
    	$h .= "<label for=\"deployfixedMAC\">";
    	$h .= i("Fixed MAC Address:") . "</label>\n";
    	$h .= "<span class=\"labeledform\">\n";
    	$h .= "<input type=\"text\" id=\"deployfixedMAC\" style=\"width: 200px\" ";
    	$h .= "dojoType=\"dijit.form.ValidationTextBox\" ";
    	$h .= "regExp=\"([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})\">(optional)</span>";
    	$h .= "<br></span>\n";*/
    # monitored
    /*$h .= "<span id=\"nrmonitoredspan\">\n";
    	$h .= "<label for=\"deploymonitored\">" . i("Monitored:") . "</label>\n";
    	$h .= "<span class=\"labeledform\"><input type=\"checkbox\" ";
    	$h .= "id=\"deploymonitored\" dijit.form.CheckBox\"></span><br></span>\n";*/
    # fixed IP block
    $h .= "<div id=\"nrfixedipdiv2\" class=\"hidden\">\n";
    $h .= "<div id=\"nrfixedipdiv\">\n";
    # ip addr
    $regip1 = "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
    $regip4 = "{$regip1}\\.{$regip1}\\.{$regip1}\\.{$regip1}";
    $h .= "<label for=\"deployfixedIP\">" . i("Fixed IP Address:") . "</label>\n";
    $h .= "<span class=\"labeledform\"><input type=\"text\" ";
    $h .= "id=\"deployfixedIP\" style=\"width: 180px\" ";
    $h .= "dojoType=\"dijit.form.ValidationTextBox\" regExp=\"{$regip4}\" ";
    $h .= "onKeyUp=\"checkFixedSet('deploy');\">" . i("(optional)") . "</span><br>\n";
    # netmask
    $h .= "<label for=\"deploynetmask\">" . i("Netmask:") . "</label>\n";
    $h .= "<span class=\"labeledform\"><input type=\"text\" ";
    $h .= "id=\"deploynetmask\" style=\"width: 180px\" ";
    $h .= "dojoType=\"dijit.form.ValidationTextBox\" regExp=\"{$regip4}\" ";
    $h .= "validator=\"validateNetmask\" onKeyUp=\"fetchRouterDNS('deploy');\" ";
    $h .= "disabled></span><br>\n";
    # router
    $h .= "<label for=\"deployrouter\">" . i("Router:") . "</label>\n";
    $h .= "<span class=\"labeledform\"><input type=\"text\" ";
    $h .= "id=\"deployrouter\" style=\"width: 180px\" ";
    $h .= "dojoType=\"dijit.form.ValidationTextBox\" regExp=\"{$regip4}\" ";
    $h .= "disabled></span><br>\n";
    # dns servers
    $h .= "<label for=\"deploydns\">" . i("DNS Server(s):") . "</label>\n";
    $h .= "<span class=\"labeledform\"><input type=\"text\" ";
    $h .= "id=\"deploydns\" style=\"width: 180px\" ";
    $h .= "dojoType=\"dijit.form.ValidationTextBox\" ";
    $h .= "regExp=\"({$regip4})(,{$regip4}){0,2}\" disabled></span><br>\n";
    $h .= "</div>\n";
    # nrfixedipdiv
    $h .= "<br><br>";
    $h .= "</div>\n";
    # nrfixedipdiv2
    $h .= "</div>\n";
    # newreslabelfields
    $h .= "<span id=\"nousercheckspan\"";
    if (!$nousercheck) {
        $h .= " class=\"hidden\"";
    }
    $h .= ">\n";
    if ($nousercheck) {
        $h .= labeledFormItem('nousercheck', i('Disable timeout for disconnected users'), 'check', '', '', '1');
    }
    $h .= "<br></span>";
    $h .= "<span id=\"whentitlebasic\">";
    $h .= i("When would you like to use the environment?");
    $h .= "</span>\n";
    $h .= "<span id=\"whentitleimaging\" class=\"hidden\">";
    $h .= i("When would you like to start the imaging process?");
    $h .= "</span>\n";
    $h .= "<span id=\"whentitleserver\" class=\"hidden\">";
    $h .= i("When would you like to deploy the server?");
    $h .= "</span>";
    $h .= "<br>\n";
    # duration radios
    $h .= "&nbsp;&nbsp;&nbsp;";
    $h .= "<input type=\"radio\" id=\"startnow\" name=\"deploystart\" ";
    $h .= "onclick=\"setStartNow();\" checked>\n";
    $h .= "<label for=\"startnow\">" . i("Now") . "</label><br>\n";
    $h .= "&nbsp;&nbsp;&nbsp;";
    $h .= "<input type=\"radio\" id=\"startlater\" name=\"deploystart\" ";
    $h .= "onclick=\"setStartLater();\">\n";
    $h .= "<label for=\"startlater\">" . i("Later:") . "</label>\n";
    # limited start
    $days = getReserveDayData();
    $h .= "<span id=\"limitstart\">\n";
    $h .= selectInputHTML('day', $days, 'deploystartday', "onChange='setStartLater();'");
    $h .= "&nbsp;" . i("At") . "&nbsp;\n";
    $tmpArr = array();
    for ($i = 1; $i < 13; $i++) {
        $tmpArr[$i] = $i;
    }
    $timestamp = unixFloor15(time() + 4500);
    $timeArr = explode(',', date('g,i,a', $timestamp));
    $h .= selectInputHTML('hour', $tmpArr, 'deployhour', "onChange='setStartLater();'", $timeArr[0]);
    $minutes = array("0" => "00", "15" => "15", "30" => "30", "45" => "45");
    $h .= selectInputHTML('minute', $minutes, 'deploymin', "onChange='setStartLater();'", $timeArr[1]);
    $h .= selectInputHTML('meridian', array("am" => "a.m.", "pm" => "p.m."), 'deploymeridian', "onChange='setStartLater();'", $timeArr[2]);
    $h .= "</span>\n";
    # any start
    $h .= "<span id=\"anystart\" class=\"hidden\">\n";
    $h .= "<div dojoType=\"dijit.form.DateTextBox\" ";
    $h .= "id=\"deploystartdate\" onChange=\"setStartLater();\" ";
    $h .= "style=\"width: 88px;\"></div>\n";
    $h .= "<div id=\"deploystarttime\" dojoType=\"dijit.form.TimeTextBox\" ";
    $h .= "style=\"width: 88px\" onChange=\"setStartLater();\"></div>\n";
    $h .= "</span>\n";
    $h .= "<small>(" . date('T') . ")</small><br><br>\n";
    $h .= "<span id=\"endlbl\"";
    if (!$openend) {
        $h .= " class=\"hidden\"";
    }
    $h .= ">" . i("Ending:") . "<br></span>\n";
    # ending by duration
    $h .= "<span id=\"durationend\">\n";
    $h .= "&nbsp;&nbsp;&nbsp;";
    if ($openend) {
        $h .= "<input type=\"radio\" id=\"endduration\" name=\"deployend\" ";
        $h .= "onclick=\"setEndDuration();\">\n";
        $h .= "<label for=\"endduration\">";
    }
    $h .= i("Duration");
    if ($openend) {
        $h .= ":&nbsp;</label>\n";
    }
    $maxtimes = getUserMaxTimes();
    if ($imaging && $maxtimes['initial'] < 720) {
        # make sure at least 12 hours available for imaging reservations
        $maxtimes['initial'] = 720;
    }
    $lengths = getReservationLengths($maxtimes['initial']);
    $h .= selectInputHTML('length', $lengths, 'reqlength', "onChange='updateWaitTime(0); setEndDuration(); durationChange();'", 60);
    $h .= "<br></span>\n";
    # ending is indefinite
    $h .= "<span id=\"indefiniteend\" class=\"hidden\">\n";
    if ($serveraccess) {
        $h .= "&nbsp;&nbsp;&nbsp;";
        $h .= "<input type=\"radio\" id=\"endindef\" name=\"deployend\" ";
        $h .= "onclick=\"setEndIndef();\">\n";
        $h .= "<label for=\"endindef\">" . i("Indefinite") . "</label><br>\n";
    }
    $h .= "</span>\n";
    # ending by date/time
    $h .= "<span id=\"specifyend\"";
    if (!$openend) {
        $h .= " class=\"hidden\"";
    }
    $h .= ">\n";
    if ($openend || $serveraccess) {
        $h .= "&nbsp;&nbsp;&nbsp;";
        $h .= "<input type=\"radio\" id=\"endat\" name=\"deployend\" ";
        $h .= "onclick=\"setEndAt();\">\n";
        $h .= "<label for=\"endat\">" . i("At this time:") . "</label>\n";
        $h .= "<div type=\"text\" dojoType=\"dijit.form.DateTextBox\" ";
        $h .= "id=\"deployenddate\" onChange=\"setEndAt();\" ";
        $h .= "style=\"width: 88px\"></div>\n";
        $h .= "<div type=\"text\" id=\"deployendtime\" dojoType=\"dijit.form.TimeTextBox\" ";
        $h .= "style=\"width: 88px\" onChange=\"setEndAt();\"></div>\n";
        $h .= "<small>(" . date('T') . ")</small><br>\n";
    }
    $h .= "</span><br>\n";
    $h .= "<div id=\"deployerr\" class=\"rederrormsg\"></div>\n";
    $h .= "<div id=\"waittime\"></div><br>\n";
    $h .= "</div>\n";
    # deployprofilediv
    $h .= "   </div>\n";
    $h .= "   <input type=\"hidden\" id=\"newrescont\">\n";
    $h .= "   <div align=\"center\">\n";
    /*$h .= "   <button id=\"newResDlgShowConfigBtn\" dojoType=\"dijit.form.Button\" ";
    	$h .= "class=\"hidden\">\n";
    	$h .= "    " . i("Configure System") . "\n";
    	$h .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
    	$h .= "       showConfigureSystem();\n";
    	$h .= "     </script>\n";
    	$h .= "   </button>\n";*/
    $h .= dijitButton('newResDlgBtn', i("Create Reservation"), "submitNewReservation();");
    $h .= dijitButton('', i("Cancel"), "dijit.byId('newResDlg').hide();");
    $h .= "   </div>\n";
    $cont = addContinuationsEntry('AJnewRequest', $cdata, SECINDAY);
    $h .= "<input type=\"hidden\" id=\"deploycont\" value=\"{$cont}\">\n";
    if ($serveraccess) {
        $cont = addContinuationsEntry('AJfetchRouterDNS');
        $h .= "<input type=\"hidden\" id=\"fetchrouterdns\" value=\"{$cont}\">\n";
    }
    $cont = addContinuationsEntry('AJupdateWaitTime', $cdata);
    $h .= "<INPUT type=\"hidden\" id=\"waitcontinuation\" value=\"{$cont}\">\n";
    $h .= "</div>\n";
    return $h;
}
Example #2
0
function confirmEditOrAddGroup($state)
{
    global $submitErr, $user;
    $data = processGroupInput(1);
    if ($submitErr) {
        editOrAddGroup($state);
        return;
    }
    $resourcetypes = getTypes("resources");
    $usergroups = getUserGroups();
    $affils = getAffiliations();
    $editname = getContinuationVar('editname', 1);
    if ($state) {
        if ($data["type"] == "user") {
            $title = "Add User Group";
            $question = "Add the following user group?";
            $target = "";
        } else {
            $title = "Add Resource Group";
            $question = "Add the following resource group?";
            $target = "#resources";
        }
        $nextmode = "submitAddGroup";
    } else {
        if ($data["type"] == "user") {
            $title = "Edit User Group";
            $question = "Submit changes to the user group?";
            $target = "";
        } else {
            $title = "Edit Resource Group";
            $question = "Submit changes to the resource group?";
            $target = "#resources";
        }
        $nextmode = "submitEditGroup";
    }
    print "<DIV align=center>\n";
    print "<H2>{$title}</H2>\n";
    print "{$question}<br><br>\n";
    if ($data['courseroll'] == 1 || $data['custom'] == 0 || $editname == 0) {
        if ($user['showallgroups']) {
            print "{$data['name']}@{$affils[$data['affiliationid']]}<br><br>\n";
        } else {
            print "{$data['name']}<br><br>\n";
        }
    }
    print "<TABLE>\n";
    if ($data["type"] == "resource") {
        print "  <TR>\n";
        print "    <TH align=right>Type:</TH>\n";
        print "    <TD>" . $resourcetypes["resources"][$data["resourcetypeid"]];
        print "</TD>\n";
        print "  </TR>\n";
    }
    if ($data['courseroll'] == 0 && $data['custom'] == 1 && $editname == 1) {
        print "  <TR>\n";
        print "    <TH align=right>Name:</TH>\n";
        if ($data['type'] == 'user' && ($user['showallgroups'] || $data['affiliationid'] != $user['affiliationid'])) {
            print "    <TD>{$data["name"]}@{$affils[$data['affiliationid']]}</TD>\n";
        } else {
            print "    <TD>{$data["name"]}</TD>\n";
        }
        print "  </TR>\n";
    }
    if ($data["type"] == "user") {
        if ($data['courseroll'] == 0 && $data['custom'] == 1) {
            print "  <TR>\n";
            print "    <TH align=right>Owner:</TH>\n";
            print "    <TD>" . $data["owner"] . "</TD>\n";
            print "  </TR>\n";
            print "  <TR>\n";
            print "    <TH align=right>Editable by:</TH>\n";
            if ($state == 0 && $data['editgroupid'] == 0) {
                $usergroups[0]['name'] = 'None';
            } elseif (!$user['showallgroups']) {
                $tmp = explode('@', $usergroups[$data["editgroupid"]]["name"]);
                if ($tmp[1] == $user['affiliation']) {
                    $usergroups[$data["editgroupid"]]["name"] = $tmp[0];
                }
            }
            print "    <TD>" . $usergroups[$data["editgroupid"]]["name"] . "</TD>\n";
            print "  </TR>\n";
        }
        $lengths = getReservationLengths(65535);
        print "  <TR>\n";
        print "    <TH align=right>Initial Max Time:</TH>\n";
        print "    <TD>{$lengths[$data["initialmax"]]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Total Max Time:</TH>\n";
        print "    <TD>{$lengths[$data["totalmax"]]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Max Extend Time:</TH>\n";
        print "    <TD>{$lengths[$data["maxextend"]]}</TD>\n";
        print "  </TR>\n";
        if (checkUserHasPerm('Set Overlapping Reservation Count')) {
            print "  <TR>\n";
            print "    <TH align=right>Max Overlapping Reservations:</TH>\n";
            print "    <TD>{$data["overlap"]}</TD>\n";
            print "  </TR>\n";
        }
    } else {
        print "  <TR>\n";
        print "    <TH align=right>Owning User Group:</TH>\n";
        if (!$user['showallgroups'] && preg_match("/^(.+)@{$user['affiliation']}\$/", $usergroups[$data['ownergroup']]['name'], $matches)) {
            print "    <TD>{$matches[1]}";
        } else {
            print "    <TD>" . $usergroups[$data["ownergroup"]]["name"];
        }
        print "</TD>\n";
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<TABLE>\n";
    print "  <TR valign=top>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "{$target}\" method=post>\n";
    $cont = addContinuationsEntry($nextmode, $data, SECINDAY, 0, 0);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=Submit>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "      <INPUT type=hidden name=mode value=viewGroups>\n";
    print "      <INPUT type=submit value=Cancel>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "</DIV>\n";
}