Пример #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;
}
Пример #2
0
 function addEditDialogHTML()
 {
     # TODO add places for description fields
     global $user;
     # dialog for on page editing
     $configtypes = getConfigTypes();
     $h = '';
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"addeditdlg\"\n";
     $h .= "      title=\"Edit {$this->restypename}\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"addeditdlgcontent\">\n";
     # id
     $h .= "<input type=\"hidden\" id=\"editresid\">\n";
     # type
     $h .= "<label for=\"type\">Type:</label><span class=\"labeledform\">\n";
     $h .= selectInputHTML('', $configtypes, 'type', 'dojoType="dijit.form.Select" maxHeight="250" onChange="configSetType();"');
     $h .= "</span><br>\n";
     # config name
     $h .= "<label for=\"name\">Name:</label><span class=\"labeledform\"><input type=\"text\" dojoType=\"dijit.form.ValidationTextBox\" ";
     $h .= "id=\"name\" required=\"true\" invalidMessage=\"Name can only contain letters, numbers, ";
     $h .= "spaces, dashes(-), parenthesis, <br>and periods(.) and can be from 3 to 80 characters long\" ";
     $h .= "regExp=\"^([-a-zA-Z0-9\\. \\(\\)]){3,80}\$\" style=\"width: 300px\"></span><br>\n";
     # owner
     $h .= "<label for=\"owner\">Owner:</label><span class=\"labeledform\"><input type=\"text\" dojoType=\"dijit.form.ValidationTextBox\" ";
     $h .= "id=\"owner\" required=\"true\" invalidMessage=\"Unknown user\" style=\"width: 300px\" ";
     $h .= "validator=\"checkOwner\" onKeyPress=\"setOwnerChecking\" value=\"{$user['unityid']}@{$user['affiliation']}\"></span><br>\n";
     $cont = addContinuationsEntry('AJvalidateUserid');
     $h .= "<input type=\"hidden\" id=\"valuseridcont\" value=\"{$cont}\">\n";
     # optional
     $h .= "<label for=\"optionalchk\">Optional:</label>\n";
     $h .= "<span class=\"labeledform\"><input type=checkbox dojoType=dijit.form.CheckBox id=\"optionalchk\"></span><br>\n";
     # config data
     $h .= "<div id=\"configdatadiv\">\n";
     $h .= "<span id=\"datalabel\" style=\"font-weight: bold;\"></span>:<br>\n";
     $h .= "<textarea id=\"data\" style=\"width: 40em; height: 10em;\"></textarea>\n";
     $h .= "</div>\n";
     #configdatadiv
     # subimage extra
     $h .= "<div id=\"subimageextradiv\" class=\"hidden\"><br>\n";
     # subimage
     $h .= "<b>Subimages</b>:<br>\n";
     $resources = getUserResources(array("imageAdmin"));
     # TODO possibly populate this after page load
     if (USEFILTERINGSELECT && count($resources['image']) < FILTERINGSELECTTHRESHOLD) {
         $h .= selectInputHTML('', $resources['image'], 'subimageid', 'dojoType="dijit.form.FilteringSelect"');
     } else {
         $h .= selectInputHTML('', $resources['image'], 'subimageid', 'dojoType="dijit.form.Select" maxHeight="250"');
     }
     # add subimage button
     $h .= "<button dojoType=\"dijit.form.Button\" id=\"addsubimagebtn\">\n";
     $h .= "  Add Subimage\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    addCfgSubimage();\n";
     $h .= "  </script>\n";
     $h .= "</button>\n";
     # list of subimages
     $h .= "<div id=\"subimagegriddiv\">\n";
     # TODO - figure out how to get an embedded widget in a cell
     $h .= "<table dojoType=\"dojox.grid.DataGrid\" jsId=\"subimagegrid\" ";
     $h .= "style=\"width: 350px; height: 300px;\" ";
     $h .= "selectionMode=\"extended\" ";
     $h .= "sortInfo=\"1\">\n";
     $h .= "<thead>\n";
     $h .= "<tr>\n";
     $h .= "<th field=\"name\" width=\"270px\"></th>\n";
     $h .= "<th field=\"min\" width=\"30px\" editable=\"true\"></th>\n";
     $h .= "<th field=\"max\" width=\"30px\" editable=\"true\"></th>\n";
     $h .= "</tr>\n";
     $h .= "</thead>\n";
     $h .= "</table>\n";
     $h .= "</div>\n";
     # subimagegriddiv
     # remove subimages button
     $h .= "<button dojoType=\"dijit.form.Button\" id=\"remsubimagebtn\">\n";
     $h .= "  Remove Selected Subimage(s)\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    removeSubimages();\n";
     $h .= "  </script>\n";
     $h .= "</button><br><br>\n";
     $h .= "</div>\n";
     #subimageextradiv
     # vlan extra
     $h .= "<div id=\"vlanextradiv\" class=\"hidden\">\n";
     # vlan id
     $h .= "<label for=\"vlanid\">VLAN ID:</label>\n";
     $h .= "<span class=\"labeledform\"><input dojoType=\"dijit.form.NumberSpinner\" value=\"1\" ";
     $h .= "smallDelta=1 largeDelta=5 ";
     $h .= "constraints=\"{min:1, max:4095}\" id=\"vlanid\" required=\"true\" ";
     $h .= "style=\"width: 70px\"/></span><br>\n";
     $h .= "</div>\n";
     #vlanextradiv
     # config variables
     #$h .= "<div id=\"configvariables\" class=\"hidden\">\n";
     $h .= "<div id=\"configvariables\">\n";
     $h .= "<h3 align=\"center\">Config Variables</h3>\n";
     $h .= "<table summary=\"\"><tr valign=\"top\"><td>\n";
     # list of variables
     $h .= "<div id=\"configvariablegriddiv\">\n";
     $h .= "Select a variable:<br>\n";
     $h .= "<table dojoType=\"dojox.grid.DataGrid\" jsId=\"configvariablegrid\" ";
     $h .= "style=\"width: 150px; height: 125px;\" query=\"{inout: 1}\" ";
     $h .= "selectionMode=\"single\" ";
     $h .= "onSelected=\"configVarSelected\" ";
     $h .= "onCanSelect=\"configVarAllowSelection\" ";
     $h .= "sortInfo=\"1\">\n";
     $h .= "  <script type=\"dojo/connect\" event=\"onStyleRow\" args=\"row\">\n";
     $h .= "    configVarListStyle(row);\n";
     $h .= "  </script>\n";
     $h .= "<thead>\n";
     $h .= "<tr>\n";
     $h .= "<th field=\"name\" width=\"150px\"></th>\n";
     $h .= "</tr>\n";
     $h .= "</thead>\n";
     $h .= "</table>\n";
     $h .= "</div>\n";
     $h .= "<button dojoType=\"dijit.form.Button\" id=\"newcfgvarbtn\">\n";
     $h .= "  Add New Variable\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    addNewConfigVar();\n";
     $h .= "  </script>\n";
     $h .= "</button>\n";
     $h .= "</td><td>\n";
     # edit variable
     $h .= "<div id=\"editcfgvardiv\" class=\"hidden\">\n";
     # id
     $h .= "<input type=\"hidden\" id=\"varid\">\n";
     # name
     $h .= "<label for=\"varname\">Name:</label><span class=\"labeledform\">\n";
     $h .= "<input type=\"text\" dojoType=\"dijit.form.ValidationTextBox\" ";
     $h .= "id=\"varname\" required=\"true\" invalidMessage=\"Name can only contain letters, numbers, ";
     $h .= "spaces, dashes(-), parenthesis, <br>and periods(.) and can be from 3 to 80 characters long\" ";
     $h .= "regExp=\"^([-a-zA-Z0-9\\. \\(\\)]){3,80}\$\" style=\"width: 120px\" ";
     $h .= "onKeyPress=\"delayedUpdateConfigVariable\"></span><br>\n";
     # key
     $h .= "<label for=\"varidentifier\">Identifier:</label><span class=\"labeledform\">\n";
     $h .= "<input type=\"text\" dojoType=\"dijit.form.ValidationTextBox\" ";
     $h .= "id=\"varidentifier\" invalidMessage=\"Key can only contain letters, numbers, ";
     # TODO determine constraints, if any
     $h .= "dashes(-), underscores(_), <br>and percents(%) and can be from 3 to 20 characters long\" ";
     $h .= "regExp=\"^([-_A-Za-z0-9%]){3,20}\$\" style=\"width: 120px\" ";
     $h .= "onKeyPress=\"delayedUpdateConfigVariable\"></span><br>\n";
     # type
     $h .= "<label id=\"cfgvartypelbl\" for=\"vartypespan\">Type:</label><span class=\"labeledform\" id=\"vartypespan\">";
     $datatypes = getConfigDataTypes();
     $h .= selectInputHTML('', $datatypes, 'cfgvartype', 'dojoType="dijit.form.Select" maxHeight="250" onChange="setCfgVarType();"');
     $h .= "</span><br>\n";
     # value - bool
     $h .= "<span id=\"vartypeboolspan\">\n";
     $h .= "<label for=\"vartypebool\">Value:</label>\n";
     $h .= "<span class=\"labeledform\">";
     $h .= selectInputAutoDijitHTML('', array('true', 'false'), 'vartypebool', 'onChange="delayedUpdateConfigVariable();"');
     $h .= "</span><br>\n";
     $h .= "</span>\n";
     # vartypeboolspan
     # value - int
     $h .= "<span id=\"vartypeintspan\">\n";
     $h .= "<label for=\"vartypeint\">Value:</label>\n";
     $h .= "<span class=\"labeledform\"><input dojoType=\"dijit.form.NumberSpinner\" value=\"1\" ";
     $h .= "id=\"vartypeint\" intermediateChanges=\"true\" constraints=\"{places:0}\" ";
     $h .= "onChange=\"delayedUpdateConfigVariable\" style=\"width: 70px\"/>";
     $h .= "</span><br>\n";
     $h .= "</span>\n";
     # vartypeintspan
     # value - float
     $h .= "<span id=\"vartypefloatspan\">\n";
     $h .= "<label for=\"vartypefloat\">Value:</label>\n";
     $h .= "<span class=\"labeledform\"><input dojoType=\"dijit.form.NumberSpinner\" value=\"1\" ";
     $h .= "id=\"vartypefloat\" intermediateChanges=\"true\" ";
     $h .= "onChange=\"delayedUpdateConfigVariable\" style=\"width: 70px\"/>";
     $h .= "</span><br>\n";
     $h .= "</span>\n";
     # vartypefloatspan
     # value - string
     $h .= "<span id=\"vartypestringspan\" class=\"hidden\">\n";
     $h .= "<label for=\"vartypestring\">Value:</label><span class=\"labeledform\">\n";
     $h .= "<input type=\"text\" dojoType=\"dijit.form.ValidationTextBox\" ";
     $h .= "id=\"vartypestring\" invalidMessage=\"Value can only contain letters, numbers, ";
     # TODO determine constraints, if any, also update in requests.php
     $h .= "spaces, dashes(-), parenthesis, <br>slashes(/) and periods(.) and can be from 3 to 255 characters long\" ";
     $h .= "regExp=\"^([-a-zA-Z0-9\\. \\(\\)/]){3,255}\$\" style=\"width: 120px\" ";
     $h .= "onKeyPress=\"delayedUpdateConfigVariable\"></span><br>\n";
     $h .= "</span>\n";
     # vartypestringspan
     # value - text
     $h .= "<span id=\"vartypetextspan\" class=\"hidden\">\n";
     $h .= "<label for=\"vartypetext\">Value:</label><span class=\"labeledform\">\n";
     $h .= "<div dojoType=\"dijit.form.Textarea\" ";
     $h .= "id=\"vartypetext\" style=\"width: 240px\" ";
     # TODO determine constraints, if any
     $h .= "onKeyPress=\"delayedUpdateConfigVariable\"></div></span><br>\n";
     $h .= "</span>\n";
     # vartypetextspan
     # required
     $h .= "<label for=\"varrequired\">Required:</label>\n";
     $h .= "<span class=\"labeledform\"><input dojoType=\"dijit.form.CheckBox\" ";
     $h .= "type=\"checkbox\" id=\"varrequired\" onChange=\"updateConfigVariable\"></span><br>\n";
     # ask
     $h .= "<label for=\"varask\">Prompt for Value:</label>\n";
     # TODO need better label name
     $h .= "<span class=\"labeledform\"><input dojoType=\"dijit.form.CheckBox\" ";
     $h .= "type=\"checkbox\" id=\"varask\" onChange=\"updateConfigVariable\"></span><br>\n";
     # delete button
     $h .= "<span class=\"labeledform\">\n";
     $h .= "<button dojoType=\"dijit.form.Button\" disabled=\"true\" id=\"deletecfgvarbtn\">\n";
     $h .= "  Delete Variable\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    deleteConfigVariable();\n";
     $h .= "  </script>\n";
     $h .= "</button></span>\n";
     $h .= "</div>\n";
     # editcfgvardiv
     # undelete button
     $h .= "<div id=\"undeletecfgvardiv\" class=\"hidden labeledform\">\n";
     $h .= "<button dojoType=\"dijit.form.Button\">\n";
     $h .= "  Undelete Variable\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    undeleteConfigVariable();\n";
     $h .= "  </script>\n";
     $h .= "</button>\n";
     $h .= "</div>\n";
     # undeletecfgvardiv
     $h .= "</td></tr></table>\n";
     $h .= "</div>\n";
     # configvariables
     $h .= "</div>\n";
     # addeditdlgcontent
     $h .= "<div id=\"addeditdlgerrmsg\" class=\"nperrormsg\"></div>\n";
     $h .= "<div id=\"editdlgbtns\" align=\"center\">\n";
     $h .= "<button dojoType=\"dijit.form.Button\" id=\"addeditbtn\">\n";
     $h .= "  Confirm\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    saveResource();\n";
     $h .= "  </script>\n";
     $h .= "</button>\n";
     $h .= "<button dojoType=\"dijit.form.Button\">\n";
     $h .= "  Cancel\n";
     $h .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
     $h .= "    dijit.byId('addeditdlg').hide();\n";
     $h .= "  </script>\n";
     $h .= "</button>\n";
     $h .= "</div>\n";
     # editdlgbtns
     $h .= "</div>\n";
     return $h;
 }
Пример #3
0
function labeledFormItem($id, $label, $type, $constraints = '', $required = 1, $value = '', $errmsg = '', $validator = '', $extra = array(), $width = '', $help = '', $addbr = 1)
{
    if ($extra == '') {
        $extra = array();
    }
    $h = '';
    if ($required) {
        $required = 'true';
    } else {
        $required = 'false';
    }
    switch ($type) {
        case 'text':
            if ($width == '') {
                $width = '300px';
            }
            $h .= "<label for=\"{$id}\">{$label}:</label>\n";
            $h .= "<span class=\"labeledform\">\n";
            $h .= "<input type=\"text\" ";
            $h .= "dojoType=\"dijit.form.ValidationTextBox\" ";
            $h .= "required=\"{$required}\" ";
            if ($constraints != '') {
                $h .= "regExp=\"{$constraints}\" ";
            }
            if ($errmsg != '') {
                $h .= "invalidMessage=\"{$errmsg}\" ";
            }
            $h .= "style=\"width: {$width}\" ";
            if ($validator != '') {
                $h .= "validator=\"{$validator}\" ";
            }
            if ($value != '') {
                $h .= "value=\"{$value}\" ";
            }
            foreach ($extra as $key => $val) {
                $h .= "{$key}=\"{$val}\" ";
            }
            $h .= "id=\"{$id}\">";
            if ($help != '') {
                $h .= $help;
            }
            $h .= "</span>";
            if ($addbr) {
                $h .= "<br>";
            }
            $h .= "\n";
            break;
        case 'textarea':
            if ($width == '') {
                $width = '300px';
            }
            $h .= "<label for=\"{$id}\">{$label}:</label>\n";
            $h .= "<span class=\"labeledform\">\n";
            $h .= "<textarea ";
            $h .= "dojoType=\"dijit.form.Textarea\" ";
            $h .= "style=\"width: {$width}; text-align: left;\" ";
            foreach ($extra as $key => $val) {
                $h .= "{$key}=\"{$val}\" ";
            }
            $h .= "id=\"{$id}\">";
            $h .= $value;
            $h .= "</textarea>\n";
            if ($help != '') {
                $h .= $help;
            }
            $h .= "</span>";
            if ($addbr) {
                $h .= "<br>";
            }
            $h .= "\n";
            break;
        case 'spinner':
            if ($width == '') {
                $width = '70px';
            }
            $h .= "<label for=\"{$id}\">{$label}:</label>\n";
            $h .= "<span class=\"labeledform\">\n";
            $h .= "<input dojoType=\"dijit.form.NumberSpinner\" ";
            $h .= "required=\"{$required}\" ";
            $h .= "style=\"width: {$width}\" ";
            if ($value !== '') {
                $h .= "value=\"{$value}\" ";
            }
            if ($constraints != '') {
                $h .= "constraints=\"{$constraints}\" ";
            }
            foreach ($extra as $key => $val) {
                $h .= "{$key}=\"{$val}\" ";
            }
            $h .= "id=\"{$id}\">";
            if ($help != '') {
                $h .= $help;
            }
            $h .= "</span>";
            if ($addbr) {
                $h .= "<br>";
            }
            $h .= "\n";
            break;
        case 'select':
        case 'selectonly':
            if ($value == '') {
                $value = -1;
            }
            $h .= "<label for=\"{$id}\">{$label}:</label>\n";
            $h .= "<span class=\"labeledform\">\n";
            $flat = '';
            foreach ($extra as $key => $val) {
                $flat .= "{$key}=\"{$val}\" ";
            }
            if ($type == 'selectonly') {
                $h .= selectInputHTML('', $constraints, $id, "dojoType=\"dijit.form.Select\" maxHeight=\"250\" {$flat}", $value);
            } else {
                $h .= selectInputAutoDijitHTML('', $constraints, $id, $flat, $value);
            }
            if ($help != '') {
                $h .= $help;
            }
            $h .= "</span>";
            if ($addbr) {
                $h .= "<br>";
            }
            $h .= "\n";
            break;
        case 'check':
            $h .= "<label for=\"{$id}\">{$label}:</label>\n";
            $h .= "<span class=\"labeledform\">\n";
            $h .= "<input dojoType=\"dijit.form.CheckBox\" ";
            if ($value !== '') {
                $h .= "value=\"{$value}\" ";
            }
            foreach ($extra as $key => $val) {
                $h .= "{$key}=\"{$val}\" ";
            }
            $h .= "id=\"{$id}\">";
            if ($help != '') {
                $h .= $help;
            }
            $h .= "</span>";
            if ($addbr) {
                $h .= "<br>";
            }
            $h .= "\n";
            break;
    }
    return $h;
}
Пример #4
0
 function extraResourceFilters()
 {
     $h = '';
     # selected items menu
     $h .= "<div dojoType=\"dijit.form.DropDownButton\">\n";
     $h .= "<span>" . i("Actions for selected computers") . "</span>\n";
     $h .= "<div dojoType=\"dijit.Menu\" id=\"actionmenu\">\n";
     # change NAT
     $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
     $h .= "    <span>Change NAT</span>\n";
     $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
     $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
     $extra = array('onChange' => "toggleNAT('newnatenabled', 'newnathostid');");
     $h .= labeledFormItem('newnatenabled', i('Connect Using NAT'), 'check', '', '', '1', '', '', $extra);
     $nathosts = getNAThosts(0, 1);
     $disabled = array('disabled' => 'true');
     $h .= labeledFormItem('newnathostid', i('NAT Host'), 'select', $nathosts, '', '', '', '', $disabled);
     $cdata = $this->basecdata;
     $cont = addContinuationsEntry('AJcompNATchange', $cdata);
     $h .= "      <input type=\"hidden\" id=\"natchangecont\" value=\"{$cont}\"><br>\n";
     $h .= dijitButton('newnathostbtn', 'Confirm NAT Change', 'confirmNATchange();', 0);
     $h .= "    </div>\n";
     $h .= "  </div>\n";
     # change predictive loading module
     $premodules = getPredictiveModules();
     $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
     $h .= "    <span>Change Predictive Loading Module</span>\n";
     $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
     $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
     $h .= "      Change Predictive Loading Module to:<br>\n";
     $h .= selectInputAutoDijitHTML('', $premodules, 'newpredictivemoduleid');
     $cdata = $this->basecdata;
     $cont = addContinuationsEntry('AJcompPredictiveModuleChange', $cdata);
     $h .= "      <input type=\"hidden\" id=\"predictivemodulechangecont\" value=\"{$cont}\"><br>\n";
     $h .= dijitButton('', 'Confirm Predictive Loading Module Change', 'confirmPredictiveModuleChange();', 0);
     $h .= "    </div>\n";
     $h .= "  </div>\n";
     # change provisioning engine
     $provisioning = getProvisioning();
     $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
     $h .= "    <span>Change Provisioning Engine</span>\n";
     $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
     $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
     $h .= "      Change Provisioning Engine to:<br>\n";
     $h .= selectInputAutoDijitHTML('', $provisioning, 'newprovisioningid');
     $cdata = $this->basecdata;
     $cont = addContinuationsEntry('AJcompProvisioningChange', $cdata);
     $h .= "      <input type=\"hidden\" id=\"provisioningchangecont\" value=\"{$cont}\"><br>\n";
     $h .= dijitButton('', 'Confirm Provisioning Engine Change', 'confirmProvisioningChange();', 0);
     $h .= "    </div>\n";
     $h .= "  </div>\n";
     # change schedule
     $resources = getUserResources(array("scheduleAdmin"), array("manageGroup"));
     if (count($resources['schedule'])) {
         $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
         $h .= "    <span>Change Schedule</span>\n";
         $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
         $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
         $h .= "      Change schedule to:<br>\n";
         $h .= selectInputAutoDijitHTML('', $resources['schedule'], 'newscheduleid');
         $cont = addContinuationsEntry('AJcompScheduleChange', $this->basecdata);
         $h .= "      <input type=\"hidden\" id=\"schedulecont\" value=\"{$cont}\"><br>\n";
         $h .= dijitButton('', 'Confirm Schedule Change', 'confirmScheduleChange();', 0);
         $h .= "    </div>\n";
         $h .= "  </div>\n";
     }
     # change state
     $states = array("2" => "available", "23" => "hpc", "10" => "maintenance", "20" => "convert to vmhostinuse");
     $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
     $h .= "    <span>Change State</span>\n";
     $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
     $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
     $h .= "      Change state to:<br>\n";
     $h .= selectInputAutoDijitHTML('', $states, 'newstateid');
     $cdata = $this->basecdata;
     $cdata['states'] = $states;
     $cont = addContinuationsEntry('AJcompStateChange', $cdata);
     $h .= "      <input type=\"hidden\" id=\"statechangecont\" value=\"{$cont}\"><br>\n";
     $h .= dijitButton('', 'Confirm State Change', 'confirmStateChange();', 0);
     $h .= "    </div>\n";
     $h .= "  </div>\n";
     # delete
     $h .= "  <div dojoType=\"dijit.MenuItem\"\n";
     $h .= "       onClick=\"confirmDelete\">\n";
     $h .= "    Delete Computers\n";
     $cont = addContinuationsEntry('AJdeleteComputers', $this->basecdata);
     $h .= "      <input type=\"hidden\" id=\"deletecont\" value=\"{$cont}\"><br>\n";
     $h .= "  </div>\n";
     # generate /etc/hosts data
     $h .= "  <div dojoType=\"dijit.MenuItem\"\n";
     $h .= "       onClick=\"hostsData\">\n";
     $h .= "    Generate /etc/hosts Data\n";
     $cont = addContinuationsEntry('AJhostsData', $this->basecdata);
     $h .= "      <input type=\"hidden\" id=\"hostsdatacont\" value=\"{$cont}\"><br>\n";
     $h .= "  </div>\n";
     # generate private dhcpd data
     $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
     $h .= "    <span>Generate Private dhcpd Data</span>\n";
     $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
     $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
     $h .= "      Enter the Management Node Private IP Address:<br>\n";
     $h .= "      <input type=\"text\" dojoType=\"dijit.form.TextBox\" id=\"mnprivipaddr\" ";
     $h .= "required=\"false\"><br><br>\n";
     $h .= "      Select which NIC is used for the Private interface:<br>\n";
     $h .= "      <input type=\"radio\" name=\"prnic\" value=\"eth0\" id=\"preth0rdo\" ";
     $h .= "checked=\"checked\"><label for=\"eth0rdo\">eth0</label><br>\n";
     $h .= "      <input type=\"radio\" name=\"prnic\" value=\"eth1\" id=\"preth1rdo\">";
     $h .= "<label for=\"eth1rdo\">eth1</label><br>\n";
     $h .= dijitButton('', 'Generate Data', "generateDHCPdata('private');", 0);
     $cont = addContinuationsEntry('AJgenerateDHCPdata', $this->basecdata);
     $h .= "      <input type=\"hidden\" id=\"privatedhcpcont\" value=\"{$cont}\">\n";
     $h .= "    </div>\n";
     $h .= "  </div>\n";
     # generate public dhcpd data
     $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
     $h .= "    <span>Generate Public dhcpd Data</span>\n";
     $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
     $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
     $h .= "      Select which NIC is used for the Public interface:<br>\n";
     $h .= "      <input type=\"radio\" name=\"punic\" value=\"eth0\" id=\"pueth0rdo\">";
     $h .= "<label for=\"eth0rdo\">eth0</label><br>\n";
     $h .= "      <input type=\"radio\" name=\"punic\" value=\"eth1\" id=\"pueth1rdo\" ";
     $h .= "checked=\"checked\"><label for=\"eth1rdo\">eth1</label><br>\n";
     $h .= dijitButton('', 'Generate Data', "generateDHCPdata('public');", 0);
     $h .= "      <input type=\"hidden\" id=\"publicdhcpcont\" value=\"{$cont}\">\n";
     # use previous continuation
     $h .= "    </div>\n";
     $h .= "  </div>\n";
     # reload
     $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
     if (count($resources['image'])) {
         $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
         $h .= "    <span>Reload with an Image</span>\n";
         $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
         $h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
         $h .= "      Reload computers with the following image:<br>\n";
         $extra = 'autoComplete="false"';
         $h .= selectInputAutoDijitHTML('', $resources['image'], 'reloadimageid', $extra);
         $cont = addContinuationsEntry('AJreloadComputers', $this->basecdata);
         $h .= "      <input type=\"hidden\" id=\"reloadcont\" value=\"{$cont}\"><br>\n";
         $h .= dijitButton('', 'Confirm Reload Computers', 'confirmReload();', 0);
         $h .= "    </div>\n";
         $h .= "  </div>\n";
     }
     # show reservations
     $h .= "  <div dojoType=\"dijit.MenuItem\"\n";
     $h .= "       onClick=\"showReservations\">\n";
     $h .= "    Reservation Information\n";
     $cont = addContinuationsEntry('AJshowReservations', $this->basecdata);
     $h .= "      <input type=\"hidden\" id=\"showreservationscont\" value=\"{$cont}\"><br>\n";
     $h .= "  </div>\n";
     # show reservation history
     $h .= "  <div dojoType=\"dijit.MenuItem\"\n";
     $h .= "       onClick=\"showReservationHistory\">\n";
     $h .= "    Reservation History\n";
     $cont = addContinuationsEntry('AJshowReservationHistory', $this->basecdata);
     $h .= "      <input type=\"hidden\" id=\"showreservationhistorycont\" value=\"{$cont}\"><br>\n";
     $h .= "  </div>\n";
     $h .= "</div>\n";
     # close Menu
     $h .= "</div>\n";
     # close DropDownButton
     # computer groups
     $tmp = getUserResources(array($this->restype . 'Admin'), array('manageGroup'), 1);
     $groups = $tmp[$this->restype];
     $cont = addContinuationsEntry('AJfilterCompGroups', $this->basecdata);
     $h .= "<input type=\"hidden\" id=\"filtercompgroupscont\" value=\"{$cont}\">\n";
     $h .= "<div dojoType=\"dijit.form.DropDownButton\">\n";
     $h .= "  <span>Selected Computer Groups</span>\n";
     $h .= "  <div dojoType=\"dijit.TooltipDialog\" id=\"connectmethodttd\">\n";
     $size = 10;
     if (count($groups) < 10) {
         $size = count($groups);
     }
     $h .= selectInputHTML('', $groups, 'filtercompgroups', "onChange=\"delayedCompGroupFilterSelection();\" size=\"{$size}\"", -1, 0, 1);
     $h .= "  </div>\n";
     # tooltip dialog
     $h .= "</div>\n";
     # drop down button
     # refresh button
     $h .= dijitButton('', 'Refresh Computer Data', 'refreshcompdata(0);');
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"confirmactiondlg\"\n";
     $h .= "      duration=250\n";
     $h .= "      autofocus=false\n";
     $h .= "      draggable=true>\n";
     #$h .= "<div id=\"actionmsg\"></div>\n";
     $h .= "<div dojoType=\"dijit.layout.ContentPane\" id=\"actionmsg\"\n";
     $h .= "         style=\"background-color: white; padding: 5px;\">\n";
     $h .= "</div>\n";
     $h .= "<div id=\"complist\" style=\"overflow: auto;\"></div>\n";
     $h .= "<input type=\"hidden\" id=\"submitcont\">\n";
     $h .= "<div style=\"text-align: center;\">\n";
     $h .= "<span id=\"submitactionbtnspan\">\n";
     $h .= dijitButton('submitactionbtn', 'Submit', 'submitAction();', 0);
     $h .= "</span>\n";
     $h .= dijitButton('cancelactionbtn', 'Cancel', 'cancelAction();', 0);
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # confirmactiondlg
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"noschedulenoadd\"\n";
     $h .= "      title=\"Cannot Add Computers\"\n";
     $h .= "      duration=250\n";
     $h .= "      autofocus=false\n";
     $h .= "      draggable=true>\n";
     $h .= "All computers must have a schedule assigned to them. You do not<br>\n";
     $h .= "have to any schedules or no schedules exist. You must be granted<br>\n";
     $h .= "access to or create at least one schedule to be able to add computers.<br><br>\n";
     $h .= "<div style=\"text-align: center;\">\n";
     $h .= dijitButton('', 'Close', 'dijit.byId("noschedulenoadd").hide();', 0);
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # noschedulenoadd
     # filter table
     $h .= "<div id=\"extrafiltersdiv\" style=\"height: 65px;\"></div>\n";
     return $h;
 }
Пример #5
0
 function getHTML($globalopts)
 {
     global $user;
     $data = getVariablesRegex("^{$this->key}.*");
     $h = "<div class=\"configwidget\" style=\"width: 100%;\">\n";
     $h .= "<h3>{$this->name}</h3>\n";
     $h .= "<span class=\"siteconfigdesc\">\n";
     $h .= $this->desc;
     $h .= "<br><br></span>\n";
     $origvals = array();
     $affils = getAffiliations();
     if ($globalopts) {
         $key = $this->key;
         $prekey = $key;
         if (array_key_exists($key, $data)) {
             $val = $data[$key];
             $dispval = $data[$key];
             if ($this->scale60) {
                 $dispval = (int) ($dispval / 60);
             }
         } else {
             setVariable($key, $this->defaultval, 'none');
             $val = $this->defaultval;
             $dispval = $this->defaultval;
             if ($this->scale60) {
                 $dispval = (int) ($dispval / 60);
             }
         }
         $label = i('Global');
         unset_by_val(i('Global'), $affils);
     } else {
         $key = "{$this->key}|{$user['affiliation']}";
         if (array_key_exists($key, $data)) {
             $val = $data[$key];
             $dispval = $data[$key];
             if ($this->scale60) {
                 $dispval = (int) ($dispval / 60);
             }
         } elseif (array_key_exists($this->key, $data)) {
             $val = 0;
             # have to set it to something different so we recognize it changed when saving
             $dispval = $data[$this->key];
             if ($this->scale60) {
                 $dispval = (int) ($dispval / 60);
             }
         } else {
             setVariable($this->key, $this->defaultval, 'none');
             $val = 0;
             # have to set it to something different so we recognize it changed when saving
             $dispval = $this->defaultval;
             if ($this->scale60) {
                 $dispval = (int) ($dispval / 60);
             }
         }
         $label = $user['affiliation'];
         $prekey = $key;
         $key = str_replace('|', '_', $key);
     }
     $extra = array('smallDelta' => 1, 'largeDelta' => 10);
     $h .= labeledFormItem($key, $label, 'spinner', "{min:{$this->minval}, max:{$this->maxval}}", 1, $dispval, '', '', $extra, '', '', 0);
     $h .= "<br>\n";
     $origvals[$key] = array('key' => $prekey, 'val' => $val);
     if ($globalopts) {
         $h .= "<div id=\"{$this->domidbase}affildiv\">\n";
         foreach ($data as $prekey => $val) {
             if ($prekey == $this->key) {
                 continue;
             }
             $key = str_replace('|', '_', $prekey);
             $tmp = explode('|', $prekey);
             $label = $tmp[1];
             $dispval = $val;
             if ($this->scale60) {
                 $dispval = (int) ($dispval / 60);
             }
             $h .= "<span id=\"{$key}span\">\n";
             $h .= labeledFormItem($key, $label, 'spinner', "{min:{$this->minval}, max:{$this->maxval}}", 1, $dispval, '', '', $extra, '', '', 0);
             $h .= dijitButton("{$key}delbtn", i("Delete"), "{$this->jsname}.deleteAffiliationSetting('{$key}', '{$this->domidbase}');") . "<br>\n";
             $h .= "</span>\n";
             $origvals[$key] = array('key' => $prekey, 'val' => $val);
             unset_by_val($label, $affils);
         }
         $h .= "</div>\n";
         $h .= "<div id=\"{$this->domidbase}adddiv\"";
         if (!count($affils)) {
             $h .= " class=\"hidden\"";
         }
         $h .= ">\n";
         $newval = $this->defaultval;
         if ($this->scale60) {
             $newval = (int) ($newval / 60);
         }
         $h .= selectInputHTML('', $affils, "{$this->domidbase}newaffilid", "dojoType=\"dijit.form.Select\" maxHeight=\"250\"");
         $h .= "<input dojoType=\"dijit.form.NumberSpinner\" ";
         $h .= "required=\"1\" ";
         $h .= "style=\"width: 70px;\" ";
         $h .= "value=\"{$newval}\" ";
         $h .= "constraints=\"{min:{$this->minval}, max:{$this->maxval}}\" ";
         $h .= "smallDelta=\"1\" ";
         $h .= "largeDelta=\"10\" ";
         $h .= "id=\"{$this->domidbase}newval\">\n";
         $h .= dijitButton("{$this->domidbase}addbtn", i('Add'), "{$this->jsname}.addAffiliationSetting();");
         $cont = addContinuationsEntry('AJaddAffiliationSetting', $this->basecdata);
         $h .= "<input type=\"hidden\" id=\"{$this->domidbase}addcont\" value=\"{$cont}\">\n";
         $h .= "</div>\n";
         $cdata = $this->basecdata;
         $cdata['origvals'] = $origvals;
         $cont = addContinuationsEntry('AJdeleteAffiliationSetting', $cdata);
         $h .= "<input type=\"hidden\" id=\"delete{$this->domidbase}cont\" value=\"{$cont}\">\n";
     }
     $tmp = array_keys($origvals);
     $keys = implode(',', $tmp);
     $h .= "<div id=\"{$this->domidbase}msg\"></div>\n";
     $h .= "<input type=\"hidden\" id=\"{$this->domidbase}savekeys\" value=\"{$keys}\">\n";
     $h .= dijitButton("{$this->domidbase}btn", i('Submit Changes'), "{$this->jsname}.saveSettings();", 1);
     $cdata = $this->basecdata;
     $cdata['origvals'] = $origvals;
     $cont = addContinuationsEntry('AJupdateAllSettings', $cdata);
     $h .= "<input type=\"hidden\" id=\"{$this->domidbase}cont\" value=\"{$cont}\">\n";
     $h .= "</div>\n";
     return $h;
 }