Author: jfthomps
Date: Mon Jun 27 22:34:42 2016
New Revision: 1750422

URL: http://svn.apache.org/viewvc?rev=1750422&view=rev
Log:
VCL-807 - indicate timezone on schedules / reservations
VCL-956 - display reservation times in user's own timezone

blockallocations.php:
-modified blockAllocationForm: added hidden input fields containing a timestamp 
of the current time on the server and the short code for the timezone of the 
server; added timezone short code after input fields where dates or times are 
input or displayed
-modified getCurrentBlockHTML: modified nextstart for listed block allocations 
to have the user's local timezone; added a hidden input field containing the 
short code for the timezone of the server
-modified viewBlockStatus: added the server's timezone to the start and end 
time of the block allocation
-modified viewBlockAllocatedMachines: added line containing short code of 
server's timezone and stating all listed times are in that timezone

dashboard.php: modified dashboard: added line containing short code of server's 
timezone and stating all listed dates and times are in that timezone

privileges.php: modified userLookup: added short code of server's timezone to 
login times; added short code of server's timezone to reservation start/end 
times

requests.php:
-modified viewRequests: added a block at the top that gets the timezone offset 
of the user's browser, submits it back as a GET request, and saves it in a 
session variable
-modified newReservationHTML: add tzoffset to time used to generate drop down 
values for selecting start time; removed timezone short code of server 
displayed next to the start time
-modified AJshowRequestSuggestedTimes: added tzoffset to start time of time 
slots; changed reference in foreach loop from $slot['startts'] to 
$slots[$key]['startts']
-modified AJeditRequest: generate date/time values for displaying and for forms 
that are in the user's timezone
-modified AJsubmitEditRequest: convert submitted start/end times from user 
timezone to server timezone
-modified getReserveDayData: add tzoffset to time when generating list of days 
for start select input

schedule.php: modified addEditDialogHTML: added timezone short code next to 
start/end input times; added a hidden input field containing the short code for 
the timezone of the server

states.php: added AJsetTZoffset

statistics.php: modified viewStatistics: added line containing short code of 
server's timezone and stating all listed dates and times are in that timezone

utils.php:
-modified setupSession: added persistdata to $_SESSION
-modified showTimeTable: added tzoffset to date/time labels to show in user's 
timezone
-modified prettyDatetime: added tzoffset to $stamp before formatting date/time
-added AJsetTZoffset
-modified getDojoHTML: added global javascript variable tzoffset that is set to 
$_SESSION['persistdata']['tzoffset'], or if that is not yet set, to 'unset'. 
also added timeout to call init() which uses AJAX to send the user time zone 
offset to the server that can get set in the session variable; this is to 
attempt to get tzoffset set in the session as soon as possible after a user 
visits the site

vm.php:
-modified vmhostdata: add timezone short code to times displayed for when VMs 
will be removed from hosts
-modified AJvmFromHost: add timezone short code to times displayed for 
confirming when VMs will be removed from hosts

blockallocations.js:
-modified blockFormAddListSlot: use now timestamp embedded in hidden field in 
page instead of current time in browser for validating submitted date so that 
it will be in the server's timezone
-modified gridDateTimePrimary, gridTimePrimary, timeFromTextBox, 
blockTimesGridStart, and blockTimesGridEnd: added timezone short code from 
embedded hidden field to returned date/time

code.js:
-added init() which is used to do any page initialization, but currently only 
sends the user's timezone offset via AJAX if it is not already set
-added getDayName function to Date object

requests.js:
-modified getDeployData: add user's timezone offset to value that gets put in 
data.start
-modified useSuggestedEditSlot: modified for loop that finds matching day of 
start day select input to compare by the day string instead of by the value of 
the select input

resources/schedule.js: modified getTime: added timezone short code from 
embedded hidden input field to returned string

Modified:
    vcl/trunk/web/.ht-inc/blockallocations.php
    vcl/trunk/web/.ht-inc/dashboard.php
    vcl/trunk/web/.ht-inc/privileges.php
    vcl/trunk/web/.ht-inc/requests.php
    vcl/trunk/web/.ht-inc/schedule.php
    vcl/trunk/web/.ht-inc/states.php
    vcl/trunk/web/.ht-inc/statistics.php
    vcl/trunk/web/.ht-inc/utils.php
    vcl/trunk/web/.ht-inc/vm.php
    vcl/trunk/web/js/blockallocations.js
    vcl/trunk/web/js/code.js
    vcl/trunk/web/js/requests.js
    vcl/trunk/web/js/resources/schedule.js

Modified: vcl/trunk/web/.ht-inc/blockallocations.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/blockallocations.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/blockallocations.php (original)
+++ vcl/trunk/web/.ht-inc/blockallocations.php Mon Jun 27 22:34:42 2016
@@ -100,6 +100,12 @@ function blockAllocationForm() {
        global $user, $days, $mode;
        $blockid = getContinuationVar('blockid', '');
        $data = getBlockAllocationData($blockid);
+       if(array_key_exists('tzoffset', $_SESSION['persistdata']))
+               $now = time() - ($_SESSION['persistdata']['tzoffset'] * 60);
+       else
+               $now = time();
+       print "<input type=\"hidden\" id=\"nowtimestamp\" value=\"$now\">\n";
+       print "<input type=\"hidden\" id=\"timezone\" value=\"" . date('T') . 
"\">\n";
        if($mode == 'newBlockAllocation') {
                $brname = '';
                $imageid = '';
@@ -222,6 +228,7 @@ function blockAllocationForm() {
        print "    <td>\n";
        print "      <input type=\"text\" dojoType=\"dijit.form.DateTextBox\" ";
        print "required=\"true\" id=\"wkfirstdate\" value=\"{$data['swdate']}\" 
/>\n";
+       print "    <small>(" . date('T') . ")</small>\n";
        print "    <img src=\"images/helpicon.png\" id=\"wkfdhelp\" />\n";
        print "    </td>\n";
        print "  </tr>\n";
@@ -230,6 +237,7 @@ function blockAllocationForm() {
        print "    <td>\n";
        print "      <input type=\"text\" dojoType=\"dijit.form.DateTextBox\" ";
        print "required=\"true\" id=\"wklastdate\" value=\"{$data['ewdate']}\" 
/>\n";
+       print "    <small>(" . date('T') . ")</small>\n";
        print "    <img src=\"images/helpicon.png\" id=\"wkldhelp\" />\n";
        print "    </td>\n";
        print "  </tr>\n";
@@ -250,9 +258,12 @@ function blockAllocationForm() {
 
        print i("Start") . ":<div type=\"text\" id=\"weeklyaddstart\" 
dojoType=\"dijit.form.TimeTextBox\" ";
        print "required=\"true\" onChange=\"blockFormWeeklyAddBtnCheck(1);\" 
style=\"width: 78px\"></div>\n";
+       print "<small>(" . date('T') . ")</small>\n";
+       print "&nbsp;|&nbsp;&nbsp;";
        print i("End") . ":<div type=\"text\" id=\"weeklyaddend\" 
dojoType=\"vcldojo.TimeTextBoxEnd\" ";
        print "required=\"true\" onChange=\"blockFormWeeklyAddBtnCheck(0);\" 
startid=\"weeklyaddstart\" ";
        print "style=\"width: 78px\"></div>\n";
+       print "<small>(" . date('T') . ")</small>\n";
        print "<button dojoType=\"dijit.form.Button\" type=\"button\" 
disabled=\"true\" ";
        print "id=\"requestBlockWeeklyAddBtn\">\n";
        print i("Add") . "\n";
@@ -289,6 +300,7 @@ function blockAllocationForm() {
        print "    <td>\n";
        print "      <input type=\"text\" id=\"mnfirstdate\" 
dojoType=\"dijit.form.DateTextBox\" ";
        print "required=\"true\" value=\"{$data['smdate']}\"/>\n";
+       print "    <small>(" . date('T') . ")</small>\n";
        print "    <img src=\"images/helpicon.png\" id=\"mnfdhelp\" />\n";
        print "    </td>\n";
        print "  </tr>\n";
@@ -297,6 +309,7 @@ function blockAllocationForm() {
        print "    <td>\n";
        print "      <input type=\"text\" id=\"mnlastdate\" 
dojoType=\"dijit.form.DateTextBox\" ";
        print "required=\"true\" value=\"{$data['emdate']}\" />\n";
+       print "    <small>(" . date('T') . ")</small>\n";
        print "    <img src=\"images/helpicon.png\" id=\"mnldhelp\" />\n";
        print "    </td>\n";
        print "  </tr>\n";
@@ -319,9 +332,12 @@ function blockAllocationForm() {
        print " " . i("of every month") . "<br><br>\n";
        print i("Start") . ":<div type=\"text\" id=\"monthlyaddstart\" 
dojoType=\"dijit.form.TimeTextBox\" ";
        print "required=\"true\" onChange=\"blockFormMonthlyAddBtnCheck(1)\" 
style=\"width: 78px\"></div>\n";
+       print "<small>(" . date('T') . ")</small>\n";
+       print "&nbsp;|&nbsp;&nbsp;";
        print i("End") . ":<div type=\"text\" id=\"monthlyaddend\" 
dojoType=\"vcldojo.TimeTextBoxEnd\" ";
        print "required=\"true\" onChange=\"blockFormMonthlyAddBtnCheck(0)\" 
startid=\"monthlyaddstart\" ";
        print "style=\"width: 78px\"></div>\n";
+       print "<small>(" . date('T') . ")</small>\n";
        print "<button dojoType=\"dijit.form.Button\" type=\"button\" 
disabled=\"true\" ";
        print "id=\"requestBlockMonthlyAddBtn\">\n";
        print i("Add") . "\n";
@@ -351,10 +367,15 @@ function blockAllocationForm() {
        print "title=\"" . i("List of Times") . "\" 
{$data['type2']['list']}>\n";
        print i("Date") . ":<div type=\"text\" id=\"listadddate\" 
dojoType=\"dijit.form.DateTextBox\" ";
        print "required=\"true\" onChange=\"blockFormListAddBtnCheck\" 
style=\"width: 95px\"></div>\n";
+       print "<small>(" . date('T') . ")</small>\n";
+       print "&nbsp;|&nbsp;&nbsp;";
        print i("Start") . ":<input type=\"text\" id=\"listaddstart\" 
dojoType=\"dijit.form.TimeTextBox\" ";
        print "required=\"true\" onChange=\"blockFormListAddBtnCheck\" />\n";
+       print "<small>(" . date('T') . ")</small>\n";
+       print "&nbsp;|&nbsp;&nbsp;";
        print i("End") . ":<input type=\"text\" id=\"listaddend\" 
dojoType=\"vcldojo.TimeTextBoxEnd\" ";
        print "required=\"true\" onChange=\"blockFormListAddBtnCheck\" 
startid=\"listaddstart\" />\n";
+       print "<small>(" . date('T') . ")</small>\n";
        print "<button dojoType=\"dijit.form.Button\" type=\"button\" 
disabled=\"true\" ";
        print "id=\"requestBlockListAddBtn\">\n";
        print i("Add") . "\n";
@@ -1180,7 +1201,12 @@ function getCurrentBlockHTML($listonly=0
                        . "LIMIT 1";
                $qh2 = doQuery($query2, 101);
                if($row2 = mysql_fetch_assoc($qh2)) {
-                       $blocks[$row['id']]['nextstart'] = $row2['start1'];
+                       if(array_key_exists('tzoffset', 
$_SESSION['persistdata'])) {
+                               $tmp = date('n/j/y+g:i=A=T', 
$row2['unixstart']);
+                               $blocks[$row['id']]['nextstart'] = 
str_replace(array('+', '='), array('<br>', '&nbsp;'), $tmp);
+                       }
+                       else
+                               $blocks[$row['id']]['nextstart'] = 
$row2['start1'];
                        if(time() > ($row2['unixstart'] - 1800) &&
                           time() < $row2['unixend'])
                                $blocks[$row['id']]['nextstartactive'] = 1;
@@ -1298,6 +1324,7 @@ function getCurrentBlockHTML($listonly=0
                }
        }
        $rt = '';
+       $rt .= "<input type=\"hidden\" id=\"timezone\" value=\"" . date('T') . 
"\">\n";
        $rt .= "<table summary=\"lists current block allocations\">\n";
        $rt .= "  <TR align=center>\n";
        $rt .= "    <TD colspan=3></TD>\n";
@@ -2835,8 +2862,8 @@ function viewBlockStatus() {
        }
        $startunix = datetimeToUnix($data['start']);
        $endunix = datetimeToUnix($data['end']);
-       $start = strftime('%x %l:%M %P', $startunix);
-       $end = strftime('%x %l:%M %P', $endunix);
+       $start = strftime('%x %l:%M %P %Z', $startunix);
+       $end = strftime('%x %l:%M %P %Z', $endunix);
        print "<div id=statusdiv>\n";
        print "<table class=blockStatusData summary=\"lists attributes of block 
allocation\">\n";
        print "  <tr>\n";
@@ -3573,6 +3600,7 @@ function AJpopulateBlockStore() {
 
////////////////////////////////////////////////////////////////////////////////
 function viewBlockAllocatedMachines() {
        print "<h2>" . i("Block Allocated Machines") . "</h2>\n";
+       print "(All times are in " . date('T') . ")<br><br>\n";
        print i("Start time:") . " \n";
        $start = unixToDatetime(unixFloor15(time() - 3600));
        list($sdate, $stime) = explode(' ', $start);

Modified: vcl/trunk/web/.ht-inc/dashboard.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/dashboard.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/dashboard.php (original)
+++ vcl/trunk/web/.ht-inc/dashboard.php Mon Jun 27 22:34:42 2016
@@ -29,6 +29,7 @@
 
////////////////////////////////////////////////////////////////////////////////
 function dashboard() {
        print "<h2>VCL Dashboard</h2>\n";
+       print "(Times and dates on this page are in " . date('T') . 
")<br><br>\n";
        if(checkUserHasPerm('View Dashboard (global)')) {
                print "View data for:";
                $affils = getAffiliations();

Modified: vcl/trunk/web/.ht-inc/privileges.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/privileges.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/privileges.php (original)
+++ vcl/trunk/web/.ht-inc/privileges.php Mon Jun 27 22:34:42 2016
@@ -1481,7 +1481,7 @@ function userLookup() {
                        foreach($logins as $login) {
                                print "  <tr>\n";
                                print "    <td 
class=\"logincell\">{$login['authmech']}</td>\n";
-                               $ts = prettyDatetime($login['timestamp'], 1);
+                               $ts = prettyDatetime($login['timestamp'], 1) . 
'&nbsp;' . date('T');
                                print "    <td class=\"logincell\">$ts</td>\n";
                                if($login['passfail'])
                                        print "    <td 
class=\"logincell\"><font color=\"#008000\">Pass</font></td>\n";
@@ -1555,11 +1555,11 @@ function userLookup() {
                                }
                                print "  <tr>\n";
                                print "    <th align=right>Start:</th>\n";
-                               print "    <td>{$req['start']}</td>\n";
+                               print "    <td>{$req['start']} " . date('T') . 
"</td>\n";
                                print "  </tr>\n";
                                print "  <tr>\n";
                                print "    <th align=right>End:</th>\n";
-                               print "    <td>{$req['end']}</td>\n";
+                               print "    <td>{$req['end']} " . date('T') . 
"</td>\n";
                                print "  </tr>\n";
                                if($req['IPaddress'] != '') {
                                        print "  <tr>\n";
@@ -1673,14 +1673,14 @@ function userLookup() {
                                }
                                print "  <tr>\n";
                                print "    <th align=right>Start:</th>\n";
-                               print "    <td>{$req['start']}</td>\n";
+                               print "    <td>{$req['start']} " . date('T') . 
"</td>\n";
                                print "  </tr>\n";
                                print "  <tr>\n";
                                print "    <th align=right>End:</th>\n";
                                if($req['end'] == 'Friday, Jan 1st, 2038, 12:00 
AM')
                                        print "    <td>(indefinite)</td>\n";
                                else
-                                       print "    <td>{$req['end']}</td>\n";
+                                       print "    <td>{$req['end']} " . 
date('T') . "</td>\n";
                                print "  </tr>\n";
                                if($req['compIP'] != '') {
                                        print "  <tr>\n";
@@ -1801,14 +1801,14 @@ function userLookup() {
                                        }
                                        print "  <tr>\n";
                                        print "    <th 
align=right>Start:</th>\n";
-                                       print "    <td>{$req['start']}</td>\n";
+                                       print "    <td>{$req['start']} " . 
date('T') . "</td>\n";
                                        print "  </tr>\n";
                                        print "  <tr>\n";
                                        print "    <th align=right>End:</th>\n";
                                        if($req['end'] == 'Friday, Jan 1st, 
2038, 12:00 AM')
                                                print "    
<td>(indefinite)</td>\n";
                                        else
-                                               print "    
<td>{$req['end']}</td>\n";
+                                               print "    <td>{$req['end']} " 
. date('T') . "</td>\n";
                                        print "  </tr>\n";
                                        if($req['compIP'] != '') {
                                                print "  <tr>\n";

Modified: vcl/trunk/web/.ht-inc/requests.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/requests.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/requests.php (original)
+++ vcl/trunk/web/.ht-inc/requests.php Mon Jun 27 22:34:42 2016
@@ -43,6 +43,21 @@ define("IMAGEIDERR", 1 << 5);
 
////////////////////////////////////////////////////////////////////////////////
 function viewRequests() {
        global $user, $inContinuation, $mode, $skin;
+       if(! $inContinuation && ! array_key_exists('tzoffset', 
$_SESSION['persistdata'])) {
+               if(array_key_exists('offset', $_GET)) {
+                       AJsetTZoffset();
+               }
+               else {
+                       print "<script type=\"text/javascript\">\n";
+                       print "var now = new Date();\n";
+                       print "var offset = now.getTimezoneOffset();\n";
+                       print "setTimeout(function() {\n";
+                       print "   window.location = '" . BASEURL . SCRIPT . 
"?mode=$mode&offset=' + offset;\n";
+                       print "}, 1);\n";
+                       print "</script>\n";
+                       return;
+               }
+       }
        if($inContinuation)
                $lengthchanged = getContinuationVar('lengthchanged', 0);
        else
@@ -1672,10 +1687,10 @@ function newReservationHTML() {
        for($i = 1; $i < 13; $i++)
                $tmpArr[$i] = $i;
 
-       $timestamp = unixFloor15(time() + 4500);
+       $tmp = time() + ($_SESSION['persistdata']['tzoffset'] * 60);
+       $timestamp = unixFloor15($tmp + 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]);
@@ -1690,8 +1705,7 @@ function newReservationHTML() {
        $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><br><br>\n";
 
        $h .= "<span id=\"endlbl\"";
        if(! $openend)
@@ -1741,8 +1755,7 @@ function newReservationHTML() {
                $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 .= "style=\"width: 88px\" 
onChange=\"setEndAt();\"></div><br>\n";
        }
        $h .= "</span><br>\n";
 
@@ -2153,6 +2166,7 @@ function AJshowRequestSuggestedTimes() {
                $cnt = 0;
                foreach($slots as $key => $slot) {
                        $cnt++;
+                       $slot['startts'] += 
$_SESSION['persistdata']['tzoffset'] * 60;
                        $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
@@ -2164,7 +2178,7 @@ function AJshowRequestSuggestedTimes() {
                        else
                                $html .= "<tr class=\"tablerow1\">";
                        $html .= "<td><input type=\"radio\" name=\"slot\" 
value=\"$key\" id=\"slot$key\" ";
-                       $html .= 
"onChange=\"setSuggestSlot('{$slot['startts']}');\"></td>";
+                       $html .= 
"onChange=\"setSuggestSlot('{$slots[$key]['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>";
@@ -3152,13 +3166,15 @@ function AJeditRequest() {
        }
        // if future, allow start to be modified
        if($unixstart > $now) {
+               $tzunixstart = $unixstart + 
($_SESSION['persistdata']['tzoffset'] * 60);
                $cdata['modifystart'] = 1;
                $txt  = i("Modify reservation for") . " 
<b>{$request['reservations'][0]['prettyimage']}</b> "; 
                $txt .= i("starting") . " " . prettyDatetime($request["start"]) 
. ": <br>";
                $h .= preg_replace("/(.{1,60}([ \n]|$))/", '\1<br>', $txt);
                $days = array();
-               $startday = date('l', $unixstart);
-               for($cur = time(), $end = $cur + DAYSAHEAD * SECINDAY; 
+               $startday = date('l', $tzunixstart);
+               $cur = time() + ($_SESSION['persistdata']['tzoffset'] * 60);
+               for($end = $cur + DAYSAHEAD * SECINDAY; 
                    $cur < $end; 
                    $cur += SECINDAY) {
                        $index = date('Ymd', $cur);
@@ -3175,12 +3191,13 @@ function AJeditRequest() {
                }
                $h .= "</select>";
                $h .= i("&nbsp;At&nbsp;");
-               $tmp = explode(' ' , $request['start']);
+               $tmp = datetimeToUnix($request['start']) + 
($_SESSION['persistdata']['tzoffset'] * 60);
+               $tmp = unixToDatetime($tmp);
+               $tmp = explode(' ' , $tmp);
                $stime = $tmp[1];
                $h .= "<div type=\"text\" dojoType=\"dijit.form.TimeTextBox\" ";
                $h .= "id=\"editstarttime\" style=\"width: 78px\" 
value=\"T$stime\" ";
-               $h .= "onChange=\"resetEditResBtn();\"></div>";
-               $h .= "<small>(" . date('T') . ")</small><br><br>";
+               $h .= "onChange=\"resetEditResBtn();\"></div><br><br>";
                $durationmatch = 0;
                if($request['serverrequest']) {
                        $cdata['allowindefiniteend'] = 1;
@@ -3269,7 +3286,10 @@ function AJeditRequest() {
                                        $h .= "<br><INPUT type=\"radio\" 
name=\"ending\" id=\"dateradio\" ";
                                        $h .= "checked 
onChange=\"resetEditResBtn();\">";
                                }
-                               $tmp = explode(' ', $request['end']);
+
+                               $tmp = datetimeToUnix($request['end']) + 
($_SESSION['persistdata']['tzoffset'] * 60);
+                               $tmp = unixToDatetime($tmp);
+                               $tmp = explode(' ', $tmp);
                                $edate = $tmp[0];
                                $etime = $tmp[1];
                        }
@@ -3282,7 +3302,6 @@ function AJeditRequest() {
                        $h .= "<div type=\"text\" 
dojoType=\"dijit.form.TimeTextBox\" ";
                        $h .= "id=\"openendtime\" style=\"width: 78px\" 
value=\"T$etime\" ";
                        $h .= "onChange=\"selectEnding();\"></div>";
-                       $h .= "<small>(" . date('T') . ")</small>";
                }
                $h .= "<br><br>";
                $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, 
SECINDAY, 1, 0);
@@ -3450,7 +3469,9 @@ function AJeditRequest() {
                if($request['serverrequest']) {
                        $h .= i("End:");
                        if($endchecked) {
-                               $tmp = explode(' ', $request['end']);
+                               $tmp = datetimeToUnix($request['end']) + 
($_SESSION['persistdata']['tzoffset'] * 60);
+                               $tmp = unixToDatetime($tmp);
+                               $tmp = explode(' ', $tmp);
                                $edate = $tmp[0];
                                $etime = $tmp[1];
                        }
@@ -3461,7 +3482,9 @@ function AJeditRequest() {
                }
                else {
                        $h .= i("Change ending to:");
-                       $tmp = explode(' ', $request['end']);
+                       $tmp = datetimeToUnix($request['end']) + 
($_SESSION['persistdata']['tzoffset'] * 60);
+                       $tmp = unixToDatetime($tmp);
+                       $tmp = explode(' ', $tmp);
                        $edate = $tmp[0];
                        $etime = $tmp[1];
                }
@@ -3473,7 +3496,6 @@ function AJeditRequest() {
                $h .= "<div type=\"text\" dojoType=\"dijit.form.TimeTextBox\" ";
                $h .= "id=\"openendtime\" style=\"width: 78px\" 
value=\"T$etime\" ";
                $h .= "onChange=\"selectEnding();\"></div>";
-               $h .= "<small>(" . date('T') . ")</small>";
                $h .= "<INPUT type=\"hidden\" name=\"enddate\" id=\"enddate\">";
                if($request['serverrequest'] && $timeToNext == 0) {
                        $h .= "<br><br><font color=red>";
@@ -3564,7 +3586,7 @@ function AJsubmitEditRequest() {
                }
                preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', $day, $tmp);
                $startdt = "{$tmp[1]}-{$tmp[2]}-{$tmp[3]} 
{$matches[1]}:{$matches[4]}:00";
-               $startts = datetimeToUnix($startdt);
+               $startts = datetimeToUnix($startdt) - 
($_SESSION['persistdata']['tzoffset'] * 60);
        }
        else {
                $startdt = $request['start'];
@@ -3601,7 +3623,7 @@ function AJsubmitEditRequest() {
                        return;
                }
                $enddt = "{$tmp[1]}-{$tmp[2]}-{$tmp[3]} {$tmp[4]}:{$tmp[7]}:00";
-               $endts = datetimeToUnix($enddt);
+               $endts = datetimeToUnix($enddt) - 
($_SESSION['persistdata']['tzoffset'] * 60);;
        }
        elseif($allowindefiniteend && $endmode == 'indefinite') {
                $endts = datetimeToUnix('2038-01-01 00:00:00');
@@ -4566,7 +4588,7 @@ function processRequestInput() {
        if($return['start'] == 0)
                $start = $now;
        else
-               $start = $return['start'];
+               $start = $return['start']; # don't need to tz offset conversion 
due to javascript date object handling it
        if($return['ending'] == 'endat')
                $end = $return['end'];
        if($return['ending'] == 'indefinite')
@@ -4896,9 +4918,12 @@ function addConnectTimeout($resid, $comp
 
////////////////////////////////////////////////////////////////////////////////
 function getReserveDayData() {
        $days = array();
-       for($cur = time(), $end = $cur + DAYSAHEAD * SECINDAY; 
+       $cur = time();
+       if(array_key_exists('tzoffset', $_SESSION['persistdata']))
+               $cur += $_SESSION['persistdata']['tzoffset'] * 60;
+       for($end = $cur + DAYSAHEAD * SECINDAY; 
            $cur < $end; 
-                $cur += SECINDAY) {
+           $cur += SECINDAY) {
                $tmp = getdate($cur);
                $index = $cur;
                $days[$index] = i($tmp["weekday"]);

Modified: vcl/trunk/web/.ht-inc/schedule.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/schedule.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/schedule.php (original)
+++ vcl/trunk/web/.ht-inc/schedule.php Mon Jun 27 22:34:42 2016
@@ -106,10 +106,13 @@ class Schedule extends Resource {
                $h .= selectInputAutoDijitHTML('startday', $days, 'startday');
                $h .= "<input type=\"text\" id=\"starttime\" 
dojoType=\"dijit.form.TimeTextBox\" ";
                $h .= "required=\"true\" value=\"T00:00:00\"/>\n";
+               $h .= "<small>(" . date('T') . ")</small>\n";
+               $h .= "&nbsp;|&nbsp;&nbsp;";
                $h .= "End:";
                $h .= selectInputAutoDijitHTML('endday', $days, 'endday');
                $h .= "<input type=\"text\" id=\"endtime\" 
dojoType=\"dijit.form.TimeTextBox\" ";
                $h .= "required=\"true\" value=\"T00:00:00\" />\n";
+               $h .= "<small>(" . date('T') . ")</small>\n";
                $h .= dijitButton('addTimeBtn', "Add", "addTime();");
                $h .= "</div>\n"; # text-align: center
                $h .= "<div dojoType=\"dojo.data.ItemFileWriteStore\" 
jsId=\"scheduleStore\" ";
@@ -159,6 +162,8 @@ class Schedule extends Resource {
                $h .= "</div>\n"; # btn div
                $h .= "</div>\n"; # groupdlg
 
+               $h .= "<input type=\"hidden\" id=\"timezonevalue\" value=\"" . 
date('T') . "\">\n";
+
                return $h;
        }
 

Modified: vcl/trunk/web/.ht-inc/states.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Mon Jun 27 22:34:42 2016
@@ -61,6 +61,7 @@ $actions["entry"] = array('main',
                           #'testDojoREST',
                           'siteconfig',
                           'newOneClick',
+                          'AJsetTZoffset',
 );
 
 $noHTMLwrappers = array('sendRDPfile',
@@ -216,6 +217,7 @@ $noHTMLwrappers = array('sendRDPfile',
                         'AJsaveMessages',
                         'AJdeleteMessages',
                         'AJvalidateMessagesPoll',
+                        'AJsetTZoffset',
 );
 
 # main
@@ -723,6 +725,7 @@ $actions['mode']['clearCache'] = "clearP
 $actions['mode']['errorrpt'] = "errorrpt";
 $actions['mode']['AJvalidateUserid'] = "AJvalidateUserid";
 $actions['mode']['changeLocale'] = "changeLocale";
+$actions['mode']['AJsetTZoffset'] = "AJsetTZoffset";
 $actions['pages']['continuationsError'] = "misc";
 $actions['pages']['clearCache'] = "misc";
 $actions['pages']['errorrpt'] = "misc";
@@ -730,6 +733,7 @@ $actions['pages']['logout'] = "misc";
 $actions['pages']['shiblogout'] = "misc";
 $actions['pages']['AJvalidateUserid'] = "misc";
 $actions['pages']['changeLocale'] = "misc";
+$actions['pages']['AJsetTZoffset'] = "misc";
 
 # OneClicks (VCL go)
 $actions['mode']['newOneClick'] = "newOneClick";

Modified: vcl/trunk/web/.ht-inc/statistics.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/statistics.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/statistics.php (original)
+++ vcl/trunk/web/.ht-inc/statistics.php Mon Jun 27 22:34:42 2016
@@ -194,6 +194,7 @@ function viewStatistics() {
                print "<H2>" . i("Statistic Information for") . " 
$statsfor</H2>\n";
        elseif($mode2 == 'provisioning')
                print "<H2>" . i("Statistic Information for") . " 
{$provs[$provid]}</H2>\n";
+       print "(Times and dates on this page are in " . date('T') . ")<br>\n";
        print "<H3>";
        $tmp = mktime(0, 0, 0, $month1, $day1, $year1);
        $starttime = strftime('%x', $tmp);

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Mon Jun 27 22:34:42 2016
@@ -798,6 +798,8 @@ function setupSession() {
                $_SESSION['usersessiondata'] = array();
        if(! array_key_exists('variables', $_SESSION))
                $_SESSION['variables'] = array();
+       if(! array_key_exists('persistdata', $_SESSION))
+               $_SESSION['persistdata'] = array();
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -7489,12 +7491,18 @@ function showTimeTable($links) {
                $stampArr = getdate($stamp);
                $label = "";
                if($stampArr["mday"] != $yesterday) {
-                       $label = date('n/d/Y+g:i+a', $stamp);
+                       if(array_key_exists('tzoffset', 
$_SESSION['persistdata']))
+                               $label = date('n/d/Y+g:i+a', $stamp + 
$_SESSION['persistdata']['tzoffset'] * 60);
+                       else
+                               $label = date('n/d/Y+g:i+a', $stamp);
                        $label = str_replace('+', '&nbsp;', $label);
                        $yesterday = $stampArr["mday"];
                }
                elseif($stampArr["minutes"] == 0) {
-                       $label = date('g:i a', $stamp);
+                       if(array_key_exists('tzoffset', 
$_SESSION['persistdata']))
+                               $label = date('g:i a', $stamp + 
$_SESSION['persistdata']['tzoffset'] * 60);
+                       else
+                               $label = date('g:i a', $stamp);
                }
                print "          <TH align=right>$label</TH>\n";
                $free = 0;
@@ -9324,6 +9332,8 @@ function prettyDatetime($stamp, $showyea
        global $locale;
        if(! preg_match('/^[\d]+$/', $stamp))
                $stamp = datetimeToUnix($stamp);
+       if(array_key_exists('tzoffset', $_SESSION['persistdata']))
+               $stamp += $_SESSION['persistdata']['tzoffset'] * 60;
        if($showyear)
                $return = strftime('%A, %b&nbsp;%-d,&nbsp;%Y, %l:%M %P', 
$stamp);
        else
@@ -9408,6 +9418,25 @@ function prettyLength($minutes) {
 
 
////////////////////////////////////////////////////////////////////////////////
 ///
+/// \fn AJsetTZoffset()
+///
+/// \brief sets tzoffset in persistdata array in session
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJsetTZoffset() {
+       $remtzoffset = processInputVar('offset', ARG_NUMERIC, 0) * -1;
+       if($remtzoffset > 1560 || $remtzoffset < -1560)
+               $remtzoffset = 0;
+       $defaulttz = date_default_timezone_get();
+       $tzobj = timezone_open($defaulttz);
+       $now = date_create('now', timezone_open('UTC'));
+       $mytzoffset = timezone_offset_get($tzobj, $now) / 60; # offset in 
minutes
+       $diff = $remtzoffset - $mytzoffset;
+       $_SESSION['persistdata']['tzoffset'] = $remtzoffset - $mytzoffset;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \fn addLoadTime($imageid, $start, $loadtime)
 ///
 /// \param $imageid - id of loaded image
@@ -13028,6 +13057,13 @@ function getDojoHTML($refresh) {
                $customfile = sprintf("<script type=\"text/javascript\" 
src=\"dojo/dojo/%s?v=$v\"></script>\n", $filename);
        $rt = '';
        $jslocale = strtolower(str_replace('_', '-', $locale));
+       $rt .= "<script type=\"text/javascript\">\n";
+       if(array_key_exists('tzoffset', $_SESSION['persistdata']))
+               $rt .= "   var tzoffset = 
{$_SESSION['persistdata']['tzoffset']};\n";
+       else
+               $rt .= "   var tzoffset = 'unset';\n";
+       $rt .= "   setTimeout(init, 100);\n";
+       $rt .= "</script>\n";
        switch($mode) {
 
                case "viewRequests":

Modified: vcl/trunk/web/.ht-inc/vm.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/vm.php?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/vm.php (original)
+++ vcl/trunk/web/.ht-inc/vm.php Mon Jun 27 22:34:42 2016
@@ -460,7 +460,7 @@ function vmhostdata() {
                $qh = doQuery($query, 101);
                while($row = mysql_fetch_assoc($qh)) {
                        $movevms[] = array('id' => $row['id'],
-                                        'time' => strtolower($row['start']),
+                                        'time' => strtolower($row['start']) . 
' ' . date('T'),
                                         'hostname' => 
$currvms[$row['computerid']]['name']);
                        unset($currvms[$row['computerid']]);
                }
@@ -654,7 +654,7 @@ function AJvmFromHost() {
                if($row = mysql_fetch_assoc($qh)) {
                        $checks[] = array('id' => $compid,
                                          'hostname' => 
$compdata[$compid]['hostname'],
-                                         'end' => strtolower($row['end']),
+                                         'end' => strtolower($row['end']) . ' 
' . date('T'),
                                          'end2' => $row['end2']);
                }
                else {

Modified: vcl/trunk/web/js/blockallocations.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/blockallocations.js?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/js/blockallocations.js (original)
+++ vcl/trunk/web/js/blockallocations.js Mon Jun 27 22:34:42 2016
@@ -276,7 +276,7 @@ function blockFormAddListSlot() {
        var endobj = dijit.byId('listaddend');
        if(! dateobj.isValid() || ! startobj.isValid() || ! endobj.isValid())
                return;
-       var today = new Date();
+       var today = new Date(dojo.byId('nowtimestamp').value * 1000);
        today.setHours(0);
        today.setMinutes(0);
        today.setSeconds(0);
@@ -1155,19 +1155,19 @@ function sortTimeArray(a, b) {
 }
 
 function gridDateTimePrimary(val) {
-       return val.substr(4, 2) + '/' + val.substr(6, 2) + '/' + val.substr(0, 
4);
+       return val.substr(4, 2) + '/' + val.substr(6, 2) + '/' + val.substr(0, 
4) + ' ' + dojo.byId('timezone').value;
 }
 
 function gridTimePrimary(val) {
        var hour = parseInt(val.substr(0, 2), 10);
        var min = parseInt(val.substr(2, 2), 10);
-       return formatHourMin(hour, min);
+       return formatHourMin(hour, min) + ' ' + dojo.byId('timezone').value;
 }
 
 function timeFromTextBox(time) {
        var hour = time.getHours();
        var min = time.getMinutes();
-       return formatHourMin(hour, min);
+       return formatHourMin(hour, min) + ' ' + dojo.byId('timezone').value;
 }
 
 function formatHourMin(hour, min) {
@@ -1262,13 +1262,13 @@ function blockTimesGridDate(val) {
 function blockTimesGridStart(val) {
        var hour = parseInt(val.substr(11, 2), 10);
        var min = parseInt(val.substr(14, 2), 10);
-       return formatHourMin(hour, min);
+       return formatHourMin(hour, min) + ' ' + dojo.byId('timezone').value;
 }
 
 function blockTimesGridEnd(val) {
        var hour = parseInt(val.substr(11, 2), 10);
        var min = parseInt(val.substr(14, 2), 10);
-       return formatHourMin(hour, min);
+       return formatHourMin(hour, min) + ' ' + dojo.byId('timezone').value;
 }
 
 function ownerFocus() {

Modified: vcl/trunk/web/js/code.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/code.js?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/js/code.js (original)
+++ vcl/trunk/web/js/code.js Mon Jun 27 22:34:42 2016
@@ -35,6 +35,19 @@ function setBrowser() {
 }
 setBrowser();
 
+function init() {
+       if(typeof(dojo) == 'undefined') {
+               setTimeout(init, 250);
+               return;
+       }
+       if(typeof(tzoffset) != undefined && tzoffset == 'unset') {
+               var now = new Date();
+               var data = {mode: 'AJsetTZoffset',
+                           offset: now.getTimezoneOffset()};
+               RPCwrapper(data, null, 0);
+       }
+}
+
 function _(str) {
        if(typeof usenls == 'undefined' ||
           typeof nlsmessages == 'undefined' ||
@@ -44,6 +57,10 @@ function _(str) {
        return nlsmessages[str];
 }
 
+Date.prototype.getDayName = function() {
+       return [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), 
_('Thursday'), _('Friday'), _('Saturday')][this.getDay()];
+}
+
 function testJS() {
        if(document.getElementById('testjavascript'))
                document.getElementById('testjavascript').value = '1';

Modified: vcl/trunk/web/js/requests.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/requests.js?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/js/requests.js (original)
+++ vcl/trunk/web/js/requests.js Mon Jun 27 22:34:42 2016
@@ -433,7 +433,9 @@ function getDeployData(waitonly) {
                }
                else {
                        var tmp = dojo.byId('deploystartday').value;
-                       var date = new Date(tmp * 1000);
+                       tmp = new Date(tmp * 1000);
+                       var offset = tmp.getTimezoneOffset() * 60000;
+                       var date = new Date(tmp.getTime() + offset);
                        var hour = parseInt(dojo.byId('deployhour').value);
                        var m = dojo.byId('deploymeridian').value;
                        if(m == 'pm' && hour < 12)
@@ -616,8 +618,7 @@ function useSuggestedEditSlot() {
        if(dojo.byId('deploystartday')) {
                var sel = dojo.byId('deploystartday');
                for(var i = 0; i < sel.options.length; i++) {
-                       var testdate = new Date(parseInt(sel.options[i].value + 
'000'));
-                       if(s.getDay() == testdate.getDay()) {
+                       if(s.getDayName() == sel.options[i].innerHTML) {
                                sel.value = sel.options[i].value;
                                break;
                        }

Modified: vcl/trunk/web/js/resources/schedule.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/schedule.js?rev=1750422&r1=1750421&r2=1750422&view=diff
==============================================================================
--- vcl/trunk/web/js/resources/schedule.js (original)
+++ vcl/trunk/web/js/resources/schedule.js Mon Jun 27 22:34:42 2016
@@ -287,13 +287,14 @@ function getDay(day) {
 function getTime(obj) {
        var hour = obj.getHours();
        var min = obj.getMinutes();
+       var tz = dojo.byId('timezonevalue').value;
        if(hour == 12)
-               return dojox.string.sprintf('12:%02d PM', min);
+               return dojox.string.sprintf('12:%02d PM %s', min, tz);
        if(hour == 0)
-               return dojox.string.sprintf('12:%02d AM', min);
+               return dojox.string.sprintf('12:%02d AM %s', min, tz);
        if(parseInt(hour / 12))
-               return dojox.string.sprintf('%d:%02d PM', hour % 12, min);
-       return dojox.string.sprintf('%d:%02d AM', hour, min);
+               return dojox.string.sprintf('%d:%02d PM %s', hour % 12, min, 
tz);
+       return dojox.string.sprintf('%d:%02d AM %s', hour, min, tz);
 }
 
 function minuteInWeek(val) {



Reply via email to