src/it/ht/rcs/console/accounting/view/users/ClockProfile.mxml
<?xml version="1.0" encoding="utf-8"?>
<utils:TitleWindowSaveCancel xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:utils="it.ht.rcs.console.utils.*"
creationComplete="init()" close="closeMe(event)"
title="{R.get('CLOCK_SETTINGS')}" save="onSave()">
<fx:Script>
<![CDATA[
import it.ht.rcs.console.accounting.controller.UserManager;
import it.ht.rcs.console.utils.Clock;
import locale.R;
import mx.collections.ArrayCollection;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
[Bindable]
public static var timezones:ArrayCollection = new ArrayCollection(['GMT -12', 'GMT -11', 'GMT -10', 'GMT -9', 'GMT -8', 'GMT -7', 'GMT -6', 'GMT -5', 'GMT -4', 'GMT -3', 'GMT -2', 'GMT -1',
'GMT',
'GMT +1', 'GMT +2', 'GMT +3', 'GMT +4', 'GMT +5', 'GMT +6', 'GMT +7', 'GMT +8', 'GMT +9', 'GMT +10', 'GMT +11', 'GMT +12']);
private var lastOffset:int
private function init():void
{
timeList.setFocus();
lastOffset=int(Clock.instance.consoleOffset);
}
private function changeTimeZone():void
{
Clock.instance.setConsoleTimezone(timeList.selectedIndex - 12);
}
private function closeMe(event:CloseEvent):void
{
Clock.instance.setConsoleTimezone(lastOffset);
PopUpManager.removePopUp(this);
}
private function onSave():void
{
Clock.instance.setConsoleTimezone(timeList.selectedIndex - 12);
/* save the timezone in the user profile */
Console.currentSession.user.timezone = timeList.selectedIndex - 12;
UserManager.instance.update(Console.currentSession.user, {timezone: Console.currentSession.user.timezone});
PopUpManager.removePopUp(this);
}
override protected function close(event:Event=null):void
{
Clock.instance.setConsoleTimezone(lastOffset);
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<s:Form>
<s:FormItem label="{R.get('UTC_TIME')}">
<s:Label text="{Clock.instance.currentUTCTime}"/>
</s:FormItem>
<s:FormItem label="{R.get('LOCAL_TIME')}">
<s:Label text="{Clock.instance.currentLocalTime}"/>
</s:FormItem>
<s:FormItem label="{R.get('CONSOLE_TIME')}">
<s:Label text="{Clock.instance.currentConsoleTime}"/>
</s:FormItem>
<s:FormItem label="{R.get('CONSOLE_TIMEZONE')}">
<s:DropDownList id="timeList" change="changeTimeZone()" dataProvider="{timezones}"
selectedIndex="{Clock.instance.consoleOffset + 12}"/>
</s:FormItem>
</s:Form>
</utils:TitleWindowSaveCancel>