var STDL={version:"1.0"};STDL.apply=Ext.apply;(function(){STDL.apply(STDL,{config:{},data:{},gui:{},actions:{},get:Ext.get,getCmp:Ext.getCmp,extend:Ext.extend,emptyFn:Ext.emptyFn,each:Ext.each,isArray:Ext.isArray,daysBetween:function(e,d){var f=1000*60*60*24;var c=e.getTime();var b=d.getTime();var a=c-b;return Math.round(a/f)},getQP:function(f){var c=window.location.search.substring(1);var e=c.split("&");for(var b=0,a=e.length;b<a;b++){var d=e[b].split("=");if(d[0]==f){return d[1]}}},getCid:function(){if(STDL.config.Production){var a=window.location.hostname;var b=a.split(".");return b[0]=="www"?b[1]:b[0]}else{return this.getQP("cid")}},serialize:function(c){var b=[];for(var a in c){b.push(a+"="+c[a])}return b.join("&")},now:function(a){switch(a){default:case"datetime":break;case"time":return new Date().format("g:i:s A");break}},getFromConfig:function(b,d){for(var c=0,a=b.length;c<a;c++){if(b[c].id==d){return b[c]}}return null}});(function(){STDL.apply(STDL.data,{conn:Ext.Ajax,getRecordsIds:function(b){var d=[];for(var c=0,a=b.length;c<a;c++){d.push(b[c].id)}return d.join(";")},submit:function(b,a){if(!a.hasOwnProperty("includeAuth")||a.includeAuth){a.params=Ext.applyIf((a.params||{}),Session.authParams())}a.url=STDL.config.serverAddress+a.url;a.failure=a.failure||this.submitFailed;b.submit(a)},submitFailed:function(a,b){STDL.gui.Msg.hide();var c=b.result?b.result.message:"Unknown Error.";STDL.gui.Msg.alert("Error",c)},request:function(b,a){b.url=STDL.config.serverAddress+b.url;if(!a){b.params=b.params?STDL.apply(b.params,Session.authParams()):Session.authParams()}b.failure=b.failure||this.requestFailed;this.conn.request(b)},requestFailed:function(a,b){STDL.gui.hideLoadingMask();STDL.gui.Msg.hide();var c=Ext.util.JSON.decode(a.responseText);var d=c.message||"Unknown Error.";STDL.gui.Msg.alert("Error",d)},getDateFormat:function(b){var a=STDL.getFromConfig(STDL.config.Date.Formats,Session.date_format);return b?String.format(b,a.format):a.format},SimpleStore:STDL.extend(Ext.data.SimpleStore,{constructor:function(a){STDL.data.SimpleStore.superclass.constructor.call(this,STDL.apply({fields:["id","name"]},a))},loadFromConfig:function(b){var a=[];STDL.each(b,function(c){var d=[];STDL.each(this.fields.keys,function(e){d.push(c[e])});a.push(d)},this);this.loadData(a)}})})})();(function(){STDL.apply(STDL.gui,{Window:Ext.Window,Msg:Ext.MessageBox,panels:{},Dialog:STDL.extend(Ext.Window,{}),MsgError:function(b,a){STDL.gui.Msg.show({title:b,msg:a,buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR})},MsgInfo:function(b,a){STDL.gui.Msg.show({title:b,msg:a,buttons:Ext.Msg.OK,icon:Ext.MessageBox.INFO})},StandardCombo:STDL.extend(Ext.form.ComboBox,{initComponent:function(){Ext.apply(this,{triggerAction:"all",editable:false,forceSelection:true,selectOnFocus:true,displayField:"name",valueField:"id",mode:"local"});STDL.gui.StandardCombo.superclass.initComponent.call(this)}}),RightsSelectionModel:STDL.extend(Ext.grid.CheckboxSelectionModel,{initEvents:function(){STDL.gui.RightsSelectionModel.superclass.initEvents.call(this);this.on("beforerowselect",function(d,c,b,a){if(a.get("privileges")=="unrestricted"){return false}})},onMouseDown:function(d,b){if(d.button===0){d.stopEvent();var f=d.getTarget(".x-grid3-row");if(f){var a=f.rowIndex;if(this.isSelected(a)){this.deselectRow(a)}else{var c=this.grid.store.getAt(a);if(c.get("privileges")=="unrestricted"){STDL.gui.MsgInfo("To-Do List Privileges","This user can always see all to-do lists due to the assigned Role.");return}this.selectRow(a,true)}}}},renderer:function(b,d,a){var c=a.get("privileges")=="unrestricted"?" checker-disabled":"";return'<div class="x-grid3-row-checker'+c+'">&#160;</div>'}}),showWindow:function(a,d){if(typeof a=="object"){if(a.id&&STDL.getCmp(a.id)){STDL.getCmp(a.id).close()}a.plain=a.plain||true;var b=new STDL.gui.Window(a);var c=b.getId()}else{var b=STDL.getCmp(a)}if(b&&!d){b.show()}return b},closeWindow:function(a){if(STDL.getCmp(a)){STDL.getCmp(a).close()}},showLoadingMask:function(a){this.loadingMask=new Ext.LoadMask(a,{msg:_PleaseWait});this.loadingMask.show()},hideLoadingMask:function(){if(this.loadingMask){this.loadingMask.hide();this.loadingMask=null}},showProgressBar:function(c,b){Ext.MessageBox.show({title:_PleaseWait,msg:c,progressText:b,width:300,progress:true,closable:false});var a=0;var d=function(){return function(){a++;if(a==6){a=0}else{Ext.MessageBox.updateProgress(a*2/10)}}};setInterval(d(),500)},focus:function(a){(function(){a.focus()}).defer(50)}});Ext.reg("standardcombo",STDL.gui.StandardCombo)})()})();STDL.config.DIR={Images:"resources/images/"};Ext.BLANK_IMAGE_URL=STDL.config.DIR.Images+"default/s.gif";STDL.config.serverAddress="server/index.php?route=";STDL.config.Production=true;STDL.config.NODE_ICONS=80;STDL.config.ADD_ROOT_TYPE=0;STDL.config.ADD_TYPE=1;STDL.config.EDIT_TYPE=2;STDL.config.Window_nodeIcon=0;STDL.config.Link={ForgotPassword:"http://www.swifttodolist.com/forgot_password/%s",CancelSubscr:"https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=novotny%40dextronet%2ecom"};STDL.config.Roles={ADMIN:"admin",SUPERUSER:"superuser",USER:"user"};STDL.config.ADMIN_ID=1;STDL.config.User={DefaultRole:"3"};STDL.config.Date={GridFormat:"D {0}",Formats:[{id:1,format:"n/j/Y",name:"8/20/2008"},{id:2,format:"j/n/Y",name:"20/8/2008"},{id:3,format:"j.n.Y",name:"20.8.2008"},{id:4,format:"Y-m-d",name:"2008-08-20"}],Default:1};STDL.config.TabId={Overview:"tasks-overview",Default:"tab0"};STDL.config.Task={GroupBy:"due_date",DefaultStatus:1,UpdaterInterval:300,Status:{T_CLOSED:[],T_OPEN:[]},Priority:[1,2,3,4,5]};var Session=new function(){this.initConfig=function(a){STDL.apply(this,a);this.setupEnvironment()};this.setupEnvironment=function(){if(this.item_statuses){for(var a=0;a<this.item_statuses.length;a++){this.item_statuses[a].id=parseInt(this.item_statuses[a].id);if(parseInt(this.item_statuses[a].done)){STDL.config.Task.Status.T_CLOSED.push(this.item_statuses[a].id)}else{STDL.config.Task.Status.T_OPEN.push(this.item_statuses[a].id)}}}};this.isPersonal=function(){return this.plan.users==1};this.getSubscrNumber=function(){return this.subscr.subscr_id};this.getSubscrId=function(){return this.subscr.id};this.getAccountName=function(){return this.account_name};this.getId=function(){return this.user.id};this.getUsername=function(){return this.user.username};this.setUsername=function(a){this.user.username=a};this.getPassword=function(){return this.user.password};this.setPassword=function(a){this.user.password=a};this.getRole=function(){return this.user.role.name};this.is=function(c){c=STDL.isArray(c)?c:[c];for(var b=0,a=c.length;b<a;b++){if(c[b]==this.getRole()){return true}}return false};this.getName=function(){return this.user.name};this.setName=function(a){this.user.name=a};this.getEmail=function(){return this.user.email};this.setEmail=function(a){this.user.email=a};this.authParams=function(){return{username:this.user.username,password:this.user.password,cid:this.cid,uuid:this.uuid}};this.getState=function(){return this.state||[]};this.updateTaskNumber=function(a,c){var b=1*(a===false?-1:a);if(!c||(c&&!a)){this.tasks_todo=parseInt(this.tasks_todo)-b}if(!c||(c&&a)){this.tasks_done=parseInt(this.tasks_done)+b}STDL.actions.Task.fillInfoBox()};this.lowerTaskNumber=function(a){if(a>0){this.tasks_todo=parseInt(this.tasks_todo)-a}else{this.tasks_done=parseInt(this.tasks_done)+a}STDL.actions.Task.fillInfoBox()};this.hasTasksToDo=function(){return parseInt(this.tasks_todo)>0};this.getParameter=function(a){return this[a]};this.setParameter=function(a,b){this[a]=b}};var _ToDoList_Title="To-Do List";var _Task_Title="Task";var _Root="Root";var _Add="Add";var _Edit="Edit";var _Delete="Delete";var _NodeOptions="To-Do List Options";var _NodeRestrictions="People";var _NodeIcons="To-Do List Icon";var _NodePermissions="Permissions";var _PleaseWait="Please Wait...";var _RequestFailed="The request failed. Please contact the helpdesk.";var _NoTaskSelected="Please select a task first.";var _DeleteToDoList="Do you really want to delete the selected to-do list <br />and all its content?";var _Confirm_TaskDelete="Do you really want to delete the selected task(s)?";var _DeleteAttachments="Do you really want to delete the selected attachments?";var _DeleteUser="Do you really want to delete the selected user?<br />Tasks assigned to this user will remain in the system.";var _NoDueDate="No Due Date";var _TaskType_None="(none)";var _TaskStatus=[[1,"Created"],[2,"Open"],[3,"Waiting"],[4,"Put On Hold"],[5,"Cancelled"],[6,"OK"]];var _TaskPriority={1:"Highest",2:"High",3:"Medium",4:"Low",5:"Lowest"};var _UserRole=[["admin","Admin"],["superuser","Superuser"],["user","User"]];var _Times=[["1","0 minutes"],["2","5 minutes"],["3","10 minutes"],["4","15 minutes"],["5","20 minutes"],["6","30 minutes"],["7","1 hour"],["8","2 hours"],["9","3 hours"],["10","4 hours"],["11","5 hours"],["12","6 hours"],["13","7 hours"],["14","8 hours"],["15","9 hours"],["16","10 hours"],["17","11 hours"],["18","12 hours"],["19","18 hours"],["20","1 day"],["21","2 days"],["22","3 days"],["23","4 days"],["24","1 week"],["25","2 weeks"]];var _LogoutConfirm="Do you really want to logout from Swift To-Do List Online?";var _TaskTypePrompt="Please insert the task type name:";var _TaskTypeConfirm="Do you really want to delete the selected task type?";var _UserAdded="An e-mail containing the login information has been sent to the user.";var _RoleChange="The change of the role will take effect after restarting the application.";var _SavingTask="Saving the task...";var _SavingNode="Saving the node...";var _SavingUser="Saving the user...";var _SettingUpFilters="Setting up filters...";var _CreatingPrint="Generating output...";var _SendingRequest="Sending the message...";STDL.actions.App={close:function(){var a={};if(STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().hasSelection()){a.item_id=STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().getSelected().id;a.item_note=STDL.getCmp("note-editor").getValue()}STDL.data.request({url:"app/logout",params:a})},showMyTasks:function(){if(STDL.application.currentTabId!=STDL.config.TabId.Overview){STDL.gui.center.setActiveTab(STDL.config.TabId.Overview)}},stopGridUpdater:function(){STDL.application.allowGridUpdate=false},releaseGridUpdater:function(){STDL.application.allowGridUpdate=true},showImport:function(){var a=new STDL.gui.ImportDialog();a.show()},support:function(){STDL.windows.windowSupport()},help:function(){window.open("http://www.swifttodolist.com/support")},logout:function(){Ext.MessageBox.confirm("Swift To-Do List Online",_LogoutConfirm,function(a){if(a=="yes"){STDL.gui.showProgressBar("Logging out...");var b={logout:true};STDL.data.request({url:"app/logout",params:b,success:function(){location.href="http://"+location.hostname}})}})},signup:function(){location.href="http://www.swifttodolist.com/signup"}};STDL.actions.Login={tryLogin:function(){if(!STDL.getCmp("username").isValid()||!STDL.getCmp("password").isValid()){STDL.gui.Msg.alert("Login","Please enter your username and password");return}STDL.gui.showProgressBar("Logging in...","");STDL.data.submit(STDL.gui.panels.login.getForm(),{url:"auth/login",params:{cid:Session.getParameter("cid")},includeAuth:false,success:STDL.application.loginSuccess,scope:STDL.application})},autoLogin:function(a,b){STDL.gui.showProgressBar("Logging in...","");var c={cid:Session.getParameter("cid")};if(b){c.pass=true}else{c.username=a[0];c.password=a[1]}STDL.data.request({url:"auth/login",params:c,success:STDL.application.autoLoginSuccess,scope:STDL.application},true)}};STDL.actions.People={manage:function(){if(Session.getRole()==STDL.config.Roles.ADMIN){var a=STDL.application.tree_SelectedNode();STDL.windows.peopleWindow(((a&&STDL.application.currentTabId!=STDL.config.TabId.Overview)?a.id:""))}}};STDL.actions.Task={noSelection:function(){Ext.MessageBox.alert("Task",_NoTaskSelected)},fillInfoBox:function(){var b={tasks_todo:Session.tasks_todo,tasks_done:Session.tasks_done};var a=new Ext.XTemplate('<p><a href="javascript:STDL.actions.App.showMyTasks()">{tasks_todo} my tasks to do</a><br />',"{tasks_done} my tasks done</p>");a.overwrite(STDL.gui.info.body,b)},row_DblClick:function(){STDL.actions.Task.edit()},add:function(){var a=STDL.application.currentTabId;STDL.windows.taskWindow(STDL.application.tree_SelectedNode().id,0,a,{})},editTask:function(a){STDL.actions.Task.showEditDialog(a)},edit:function(){var a=STDL.application.grid_SelectedRow();STDL.actions.Task.showEditDialog(a.id)},showEditDialog:function(b){var a=STDL.application.currentTabId;var c={id:b};STDL.gui.showLoadingMask(Ext.getBody());STDL.data.request({url:"items/get_item_details",params:c,method:"GET",success:function(d,e){var f=Ext.util.JSON.decode(d.responseText);if(f.item){STDL.windows.taskWindow(f.item.node_id,f.id,a,f.item)}}})},remove:function(){Ext.MessageBox.confirm("Task",_Confirm_TaskDelete,function(b){if(b=="yes"){var a=STDL.application.currentTabId;var d=STDL.gui.grids[STDL.application.currentTabId].getSelectionModel().getSelections();var c=STDL.data.getRecordsIds(d);var e={ids:c};STDL.gui.showProgressBar("Deleting task...","");STDL.data.request({url:"items/delete_item",params:e,success:function(g,h){var m=Ext.util.JSON.decode(g.responseText);if(m.ids){var k=m.ids;for(var j=0,f=k.length;j<f;j++){var n=STDL.data.tasks[a].getById(k[j]);var l=n.get("status_id")<5?1:-1;STDL.data.tasks[a].remove(n);Session.lowerTaskNumber(l)}STDL.gui.Msg.hide();if(STDL.application.currentTabId==STDL.config.TabId.Default){STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().selectFirstRow()}}}})}})},search:function(){STDL.windows.searchWindow()},filter:function(){STDL.windows.filterWindow(Windows.FILTER_GRID)},print:function(){if(STDL.windows.tree_Print){STDL.windows.tree_Print.getLoader().on("load",function(){STDL.windows.tree_Print.expandAll()},this,{single:true});STDL.windows.tree_Print.getRootNode().reload()}STDL.windows.printWindow()},changeTaskState:function(b,f,d,a){var c=STDL.application.tree_SelectedNode();var e="";if(c&&STDL.application.currentTabId!=STDL.config.TabId.Overview){e=c.id}STDL.gui.grids[STDL.application.currentTabId].getStore().reload({params:{node:e,item:d,changeTaskStatus:true,status:b?STDL.config.Task.Status.T_CLOSED[1]:STDL.config.Task.Status.T_OPEN[1]}});if(a==Session.getId()){Session.updateTaskNumber(b)}},saveNote:function(c,a){var b={item:c.id,note:a};STDL.data.request({url:"items/update_note",params:b,success:function(){var d=c.store.indexOf(c);if(STDL.application.blankNotes.indexOf(a)>=0){STDL.gui.grids[STDL.application.currentTabId].flagBlankNotes(d)}else{STDL.gui.grids[STDL.application.currentTabId].flagHasNotes(d)}STDL.actions.App.releaseGridUpdater()}})},addAttachment:function(){if(!STDL.application.grid_SelectedRow()){STDL.actions.Task.noSelection();return}var b=STDL.application.grid_SelectedRow();var a=new STDL.gui.UploadDialog({itemId:b.id});a.on("uploadcomplete",function(c){STDL.gui.attachments.load(b.id);if(STDL.gui.attachmentsTW){STDL.gui.attachmentsTW.load(b.id)}});a.show()},deleteAttachment:function(){Ext.MessageBox.confirm("Attachments",_DeleteAttachments,function(a){if(a=="yes"){var b=STDL.application.grid_SelectedRow();STDL.gui.attachments.removeSelected(b.id);if(STDL.gui.attachmentsTW){STDL.gui.attachmentsTW.removeSelected(b.id)}}})},saveAttachment:function(a){if(a){STDL.gui.attachmentsTW.save(a)}else{var b=STDL.application.grid_SelectedRow();STDL.gui.attachments.save(b.id)}}};STDL.actions.Tree={addRootNode:function(){STDL.windows.nodeWindow(Windows.ADD_ROOT_TYPE,0,0,"",0)},addNode:function(){var a=STDL.application.tree_SelectedNode().id;STDL.windows.nodeWindow(Windows.ADD_TYPE,a,0,"",0)},editNode:function(){var c=STDL.application.tree_SelectedNode();var b=c.parentNode.id=="root"?0:c.parentNode.id;var d=c.ui.iconNode.className;var a=parseInt(d.substr(d.indexOf("icon-node-")).substr(10));STDL.windows.nodeWindow(Windows.EDIT_TYPE,b,c.id,c.text,a)},deleteNode:function(){var a=STDL.gui.tree.getSelectionModel().getSelectedNode();var b={id:a.id};Ext.MessageBox.confirm("Delete To-Do List",_DeleteToDoList,function(c){if(c=="yes"){STDL.gui.showLoadingMask(STDL.gui.tree.getEl());STDL.data.request({url:"nodes/delete_node",params:b,success:function(d,e){var g=Ext.util.JSON.decode(d.responseText);var h=STDL.gui.tree.getNodeById(g.id);var f=h.parentNode;h.remove();if(f.id=="root"){if(f.firstChild){f.firstChild.select()}else{f.select()}}else{f.select()}STDL.gui.hideLoadingMask()}})}})},expandNodes:function(){STDL.gui.tree.expandAll();var a=STDL.application.getStateProvider();a.set("tree-expanded",true)},collapseNodes:function(){STDL.gui.tree.collapseAll();var a=STDL.application.getStateProvider();a.set("tree-expanded",false)},goToTodoList:function(b){var a=STDL.gui.tree.getNodeById(b);STDL.gui.tree.getSelectionModel().select(a);if(STDL.gui.currentTabId!=STDL.config.TabId.Default){STDL.gui.center.setActiveTab(STDL.config.TabId.Default)}}};STDL.data.Records={Task:Ext.data.Record.create([{name:"task_id",type:"int",mapping:"id"},{name:"name"},{name:"flags",defaultValue:""},{name:"priority"},{name:"type"},{name:"due_date",type:"date",dateFormat:"m/d/Y",defaultValue:""},{name:"status_id",type:"int"},{name:"status"},{name:"complete"},{name:"assigned_to"},{name:"assigned_to_id"},{name:"created_by"},{name:"last_update"},{name:"note"},{name:"node_id"},{name:"todo_list"},{name:"attachments"},{name:"flag_note"},{name:"flag_attachment"},{name:"flag_reminder"},{name:"flag_note_ttip"},{name:"flag_attachment_ttip"},{name:"flag_reminder_ttip"}])};STDL.data.TaskStore=STDL.extend(Ext.data.Store,{constructor:function(){STDL.data.TaskStore.superclass.constructor.call(this,{baseParams:Session.authParams(),reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},STDL.data.Records.Task)});this.proxy=new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/get_main_grid_content"});this.on("beforeload",function(a,b){b.params=b.params||{};var c=STDL.application.getFilterOptions(Windows.FILTER_GRID);Ext.apply(b.params,c);if(STDL.application.forceSelectRow&&STDL.application.selectRow){STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().clearSelections()}});this.on("load",function(h,d,i){var g=this.reader.xmlData;var f=g.documentElement||g;var b=Ext.DomQuery;var c=b.selectNumber("tasks_todo",f,0);var e=b.selectNumber("tasks_done",f,0);Session.tasks_todo=c;Session.tasks_done=e;Session.updateTaskNumber(0);if(!STDL.application.grid_SelectedRow()||STDL.application.forceSelectRow){if(STDL.application.selectRow){var a=this.getById(STDL.application.selectRow);STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().selectRecords([a]);STDL.application.selectRow=null;STDL.application.forceSelectRow=false}else{if(h.getCount()>0){STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().selectFirstRow()}else{Ext.getCmp("button-edit-task").disable();Ext.getCmp("button-delete-task").disable();Ext.getCmp("note-editor").setValue(null);STDL.gui.attachments.getStore().removeAll()}}}},this)}});STDL.data.TaskGroupingStore=STDL.extend(Ext.data.GroupingStore,{constructor:function(a){var b=a.params||{};Ext.apply(b,Session.authParams());STDL.data.TaskGroupingStore.superclass.constructor.call(this,{baseParams:b,reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},STDL.data.Records.Task),sortInfo:{field:(a.groupBy?a.groupBy:STDL.config.Task.GroupBy),direction:"ASC"},groupField:a.groupBy});this.proxy=new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/get_main_grid_content"});this.listeners={load:function(){if(!STDL.application.grid_SelectedRow()){Ext.getCmp("button-edit-task").disable();Ext.getCmp("button-delete-task").disable();Ext.getCmp("note-editor").setValue(null)}}}}});STDL.data.ListLoader=STDL.extend(Ext.tree.TreeLoader,{constructor:function(a){a=a||{};var b=Ext.apply((a.params||{}),Session.authParams());STDL.data.ListLoader.superclass.constructor.call(this,{dataUrl:STDL.config.serverAddress+"nodes/get_nodes_at_once",baseParams:b})}});STDL.data.AttachmentStore=STDL.extend(Ext.data.Store,{constructor:function(){STDL.data.AttachmentStore.superclass.constructor.call(this,{baseParams:Session.authParams(),reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},["id","name","type","uploaded_by","time"])});this.proxy=new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/get_attachments"})}});STDL.gui.UploadDialog=Ext.extend(Ext.ux.UploadDialog.Dialog,{initComponent:function(){var a=Session.authParams();a.item=this.itemId;Ext.apply(this,{url:STDL.config.serverAddress+"items/upload_file",base_params:a,reset_on_hide:true,allow_close_on_upload:true,upload_autostart:true,modal:true});this.i18n.progress_waiting_text="Please add a file...";STDL.gui.UploadDialog.superclass.initComponent.call(this)}});STDL.gui.AttachmentGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(a){STDL.gui.AttachmentGrid.superclass.constructor.call(this,a)},initComponent:function(){Ext.apply(this,{store:new STDL.data.AttachmentStore(),sm:new Ext.grid.CheckboxSelectionModel(),height:300,loadMask:true,border:false});this.columns=[this.sm,{id:"name",header:"File Name",width:200,dataIndex:"name"},{id:"type",header:"File Type",width:120,dataIndex:"type"},{id:"uploaded_by",header:"Uploaded By",width:120,dataIndex:"uploaded_by"},{id:"time",header:"Time",width:120,dataIndex:"time"}];this.tbar=[{id:"button-add-attachment",xtype:"tbbutton",iconCls:"icon-small-add",cls:"x-btn-text-icon",text:"Add Attachment",handler:STDL.actions.Task.addAttachment},{id:"button-delete-attachment",xtype:"tbbutton",iconCls:"icon-small-delete",cls:"x-btn-text-icon",text:"Delete Attachment",disabled:true,handler:STDL.actions.Task.deleteAttachment},"-",{id:"button-save-attachment",xtype:"tbbutton",iconCls:"icon-small-save",cls:"x-btn-text-icon",text:"Download Attachment",disabled:true,handler:STDL.actions.Task.saveAttachment.createCallback(this.stdl_RowId),scope:this}];STDL.gui.AttachmentGrid.superclass.initComponent.call(this);this.getSelectionModel().on("rowselect",function(){Ext.getCmp("button-delete-attachment").enable();Ext.getCmp("button-save-attachment").enable()});this.getSelectionModel().on("rowdeselect",function(){Ext.getCmp("button-delete-attachment").disable();Ext.getCmp("button-save-attachment").disable()});this.on("rowdblclick",STDL.actions.Task.saveAttachment.createCallback(this.stdl_RowId))},load:function(b){var a={item:b};this.getStore().load({params:a,callback:function(c){var e=STDL.application.grid_SelectedRow();var d=c.length;if(d>0&&d!=e.get("attachments")){var f=e.store.indexOf(e);e.set("attachments",d);STDL.gui.grids[STDL.application.currentTabId].flagHasAttachments(f,d)}if(!this.getSelectionModel().hasSelection()&&Ext.getCmp("button-delete-attachment")){Ext.getCmp("button-delete-attachment").disable();Ext.getCmp("button-save-attachment").disable()}},scope:this})},removeSelected:function(d){var b=this.getSelectionModel().getSelections();var a=STDL.data.getRecordsIds(b);var c={ids:a,item:d};STDL.data.request({url:"items/delete_attachments",params:c,success:function(){for(var e=b.length;e--;){this.getStore().remove(b[e])}var g=STDL.application.grid_SelectedRow();var h=g.store.indexOf(g);var f=this.getStore().getCount();g.set("attachments",f);if(!f){STDL.gui.grids[STDL.application.currentTabId].flagBlankAttachments(h)}else{STDL.gui.grids[STDL.application.currentTabId].flagHasAttachments(h,f)}STDL.gui.hideLoadingMask();Ext.getCmp("button-delete-attachment").disable();Ext.getCmp("button-save-attachment").disable()},scope:this})},save:function(c){var b=this.getSelectionModel().getSelected();var a={id:b.id,item:c};Ext.apply(a,Session.authParams());window.open(STDL.config.serverAddress+"items/save_attachment&"+STDL.serialize(a))}});STDL.gui.NoteEditor=Ext.extend(Ext.form.HtmlEditor,{initComponent:function(){STDL.gui.NoteEditor.superclass.initComponent.call(this);this.on("initialize",function(){Ext.EventManager.on(this.doc,{dblclick:this.detectLink,scope:this})},this)},detectLink:function(a){if(a.target.nodeName=="A"){window.open(a.target.getAttribute("href"))}}});Ext.reg("noteeditor",STDL.gui.NoteEditor);STDL.gui.CenterPanel=Ext.extend(Ext.TabPanel,{constructor:function(){var a=Session.hasTasksToDo()?0:1;STDL.application.currentTabId=a==0?STDL.config.TabId.Overview:STDL.config.TabId.Default;STDL.gui.CenterPanel.superclass.constructor.call(this,{id:"stdl-main-body",region:"center",margins:"5 5 5 0",resizeTabs:true,minTabWidth:135,tabWidth:135,enableTabScroll:true,activeTab:a,stateful:true})},initComponent:function(){STDL.gui.CenterPanel.superclass.initComponent.call(this);this.add({layout:"fit",id:STDL.config.TabId.Overview,title:"My Tasks Overview",items:[STDL.gui.grids[STDL.config.TabId.Overview]]});this.add({layout:"border",title:"To-Do List",id:STDL.config.TabId.Default,items:[STDL.gui.grids[STDL.config.TabId.Default],{region:"south",height:150,split:true,layout:"fit",cls:"list-enhancements",id:"enhancements-panel",stateful:true,items:[{xtype:"tabpanel",border:false,activeTab:0,tabPosition:"bottom",items:[{title:"Task Notes",layout:"fit",items:[{xtype:"noteeditor",id:"note-editor",enableFont:false,ctCls:"htmleditor-no-border"}]},{title:"Task Attachments",layout:"fit",items:[STDL.gui.attachments]}]}]}]});var a=new Ext.util.DelayedTask();this.noteHtml="";STDL.getCmp("note-editor").on("sync",function(c,b){if(this.noteHtml!=b&&STDL.application.grid_SelectedRow()){STDL.actions.App.stopGridUpdater();var d=STDL.application.grid_SelectedRow();d.data.note=b;a.delay(500,STDL.actions.Task.saveNote,null,[d,b]);this.noteHtml=b}},this);this.getComponent(STDL.config.TabId.Default).on("tabclick",function(){var c=STDL.gui.tree.getSelectionModel().getSelectedNode();if(c){STDL.data.tasks[STDL.config.TabId.Default].reload({params:{node:c.id}})}else{var b=STDL.gui.tree.getRootNode();if(b.firstChild){b.firstChild.select()}}})},render:function(){STDL.gui.CenterPanel.superclass.render.apply(this,arguments);this.on("tabchange",function(a,b){STDL.application.currentTabId=b.getId();if(STDL.application.currentTabId==STDL.config.TabId.Overview){STDL.getCmp("button-add-task").disable();STDL.data.tasks[STDL.config.TabId.Overview].reload({params:{}})}else{if(STDL.gui.tree.getSelectionModel().getSelectedNode()){STDL.getCmp("button-add-task").enable()}}})}});STDL.gui.HeaderPanel=STDL.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{border:false,layout:"anchor",region:"north",height:103,items:[{xtype:"box",el:"header-el",border:false,anchor:"none -58"},{xtype:"toolbar",height:58,cls:"main-toolbar",items:[" ",{xtype:"tbbutton",id:"button-add-task",iconCls:"icon-add-task",cls:"x-btn-text-icon main-toolbar-button",disabled:true,text:"Add Task",handler:STDL.actions.Task.add},{xtype:"tbbutton",id:"button-edit-task",iconCls:"icon-edit-task",cls:"x-btn-text-icon main-toolbar-button",disabled:true,text:"Edit Task",handler:STDL.actions.Task.edit},{xtype:"tbbutton",id:"button-delete-task",iconCls:"icon-delete-task",cls:"x-btn-text-icon main-toolbar-button",disabled:true,text:"Delete Task",handler:STDL.actions.Task.remove},"-",{xtype:"tbbutton",iconCls:"icon-search",cls:"x-btn-text-icon main-toolbar-button",text:"Find Tasks",handler:STDL.actions.Task.search},{xtype:"tbbutton",iconCls:"icon-filter",cls:"x-btn-text-icon main-toolbar-button",text:"Filter",handler:STDL.actions.Task.filter},"-",{xtype:"tbbutton",iconCls:"icon-import",cls:"x-btn-text-icon main-toolbar-button",text:"Import",handler:STDL.actions.App.showImport},{xtype:"tbbutton",iconCls:"icon-print",cls:"x-btn-text-icon main-toolbar-button",tooltip:"Print And Export",text:"Print/Export",handler:STDL.actions.Task.print},"-",{xtype:"tbbutton",id:"button-people",iconCls:"icon-people",cls:"x-btn-text-icon main-toolbar-button",text:"People",hidden:true,handler:STDL.actions.People.manage},{xtype:"tbbutton",id:"button-settings",iconCls:"icon-settings",cls:"x-btn-text-icon main-toolbar-button",text:"Account",hidden:true,handler:STDL.actions.App.support},{xtype:"tbbutton",iconCls:"icon-help",cls:"x-btn-text-icon main-toolbar-button",text:"Help",tooltip:"Help And Support",handler:STDL.application.showWizard},"-",{xtype:"tbbutton",iconCls:"icon-logout",cls:"x-btn-text-icon main-toolbar-button",text:"Logout",handler:STDL.actions.App.logout},"->",{xtype:"tbbutton",hidden:Session.is_demo?false:true,iconCls:"icon-get-account",cls:"x-btn-text-icon-large main-toolbar-button button-get-my-account",text:"Get My Own Account",handler:STDL.actions.App.signup}]}]});STDL.gui.HeaderPanel.superclass.initComponent.call(this)}});STDL.gui.InfoPanel=STDL.extend(Ext.Panel,{constructor:function(){STDL.gui.InfoPanel.superclass.constructor.call(this,{region:"south",border:false,height:60,cls:"info-box",margins:"5 0 0 0",listeners:{render:function(){},scope:this}})}});STDL.gui.LeftPanel=Ext.extend(Ext.Panel,{constructor:function(){STDL.gui.LeftPanel.superclass.constructor.call(this,{id:"stdl-tree-body",split:true,border:false,region:"west",layout:"border",width:250,margins:"5 0 5 5",stateful:true,items:[STDL.gui.tree,STDL.gui.info]})}});STDL.gui.ListTree=Ext.extend(Ext.tree.TreePanel,{initComponent:function(){this.updater=new Ext.ux.tree.TreeUpdater({url:STDL.config.serverAddress+"nodes/update_tree",params:Session.authParams(),customAttributes:["sort"],rootNodeId:"0",removedKey:"time_del",onStart:function(b){Ext.get("tree-updater-icon").show()},onUpdate:function(b){b.body.highlight();STDL.data.tasks[STDL.application.currentTabId].reload()},onComplete:function(b){Ext.get("tree-updater-icon").hide();Ext.getCmp("tree-statusbar").setStatus("Last updated: "+STDL.now("time"));if(STDL.application.selectNode){var c=STDL.gui.tree.getNodeById(STDL.application.selectNode);if(c){c.select()}STDL.application.selectNode=null}}});Ext.apply(this,{autoScroll:true,animate:true,ddGroup:"TreeDD",enableDD:true,containerScroll:true,region:"center",border:true,rootVisible:false,plugins:[this.updater],tbar:[{xtype:"tbbutton",id:"button-add-root-node",iconCls:"icon-add-root-node",hidden:true,tooltip:"Add Root To-Do List...",handler:STDL.actions.Tree.addRootNode},{xtype:"tbbutton",id:"button-add-node",iconCls:"icon-add-node",disabled:true,tooltip:"Add To-Do List...",handler:STDL.actions.Tree.addNode},"-",{xtype:"tbbutton",id:"button-edit-node",iconCls:"icon-edit-node",disabled:true,tooltip:"Edit To-Do List...",handler:STDL.actions.Tree.editNode},{xtype:"tbbutton",id:"button-delete-node",iconCls:"icon-delete-node",disabled:true,tooltip:"Delete To-Do List",handler:STDL.actions.Tree.deleteNode},"-",{xtype:"tbbutton",iconCls:"icon-expand-nodes",tooltip:"Expand To-Do Lists",handler:STDL.actions.Tree.expandNodes},{xtype:"tbbutton",iconCls:"icon-collapse-nodes",tooltip:"Collapse To-Do Lists",handler:STDL.actions.Tree.collapseNodes}],bbar:new Ext.StatusBar({id:"tree-statusbar",defaultText:"Last updated: "+STDL.now("time"),items:['<img src="'+Ext.BLANK_IMAGE_URL+'" alt="" id="tree-updater-icon" style="display: none;" class="tree-updater-icon" />']})});this.loader=new STDL.data.ListLoader();this.getLoader().on("load",function(){if(!Session.hasTasksToDo()){if(STDL.gui.grids[STDL.config.TabId.Default].loadMask){STDL.gui.grids[STDL.config.TabId.Default].loadMask.disable()}var b=STDL.gui.tree.getRootNode();if(b.firstChild){b.firstChild.select()}if(STDL.gui.grids[STDL.config.TabId.Default].loadMask){STDL.gui.grids[STDL.config.TabId.Default].loadMask.enable()}}});STDL.gui.ListTree.superclass.initComponent.call(this);var a=new Ext.tree.AsyncTreeNode({text:"To-Do List",draggable:false,id:"root",iconCls:"icon-node-00"});this.setRootNode(a);if(STDL.application.getTreeExpanded()){this.expandAll()}new Ext.tree.TreeSorter(this,{sortType:function(b){return parseInt(b.attributes.sort)}});this.on("nodedragover",function(b){this.dropZone.appendOnly=b.dropNode?false:true},this);this.on("beforenodedrop",function(h){if(h.dropNode){var j=h.dropNode.parentNode;var c=h.dropNode;var k=h.point;var g=parseInt(h.target.attributes.sort);if(k=="above"||k=="below"){var l=h.target.parentNode}else{var l=h.target;g=l.childNodes.length+1}function f(){j.eachChild(function(e){if(e.attributes.sort>c.attributes.sort){e.attributes.sort=parseInt(e.attributes.sort)-1}});l.eachChild(function(e){if(e.attributes.sort>=g){e.attributes.sort=parseInt(e.attributes.sort)+1}});c.attributes.sort=g}allowDrop=true;if(j.id!=l.id){STDL.data.request({url:"users/test_parent_node_privileges",async:false,params:{nodeId:c.id,parentNodeId:l.id},success:function(i,n){var o=Ext.decode(i.responseText);if(o.success){f()}else{var e="Some users assigned to "+c.text+" don't have privileges to access "+l.text+". ";e+="Move and grant privileges?";STDL.gui.Msg.show({title:"Move To-Do List",msg:e,icon:STDL.gui.Msg.QUESTION,buttons:STDL.gui.Msg.YESNO,fn:function(p){if(p=="yes"){f();this.dropZone.completeDrop(h)}},scope:this});allowDrop=false}},scope:this})}else{f()}return allowDrop}else{if(h.data.selections&&h.data.selections.length>0){var m=h.data.selections;var c=h.target;var b=h.rawEvent.ctrlKey;if(m[0].get("node_id")==c.id&&!b){return false}var d=0;this.changeTasksNode(c,m,d,b)}}},this);this.on("nodedrop",function(f){var d=f.dropNode;var b=d.parentNode;var c=d.attributes.sort;this.updateSort(d.id,c,b.id)},this);this.getSelectionModel().on("selectionchange",function(c,b){if(b&&b.getDepth()>0){STDL.getCmp("button-add-node").enable();STDL.getCmp("button-edit-node").enable();STDL.getCmp("button-delete-node").enable();STDL.getCmp("button-add-task").enable();if(STDL.application.currentTabId!=STDL.config.TabId.Default){STDL.gui.center.setActiveTab(STDL.config.TabId.Default)}STDL.data.tasks[STDL.config.TabId.Default].reload({params:{node:b.id}})}else{if(b&&b.getDepth()==0){STDL.data.tasks[STDL.config.TabId.Default].reload({params:{node:0}})}else{STDL.getCmp("button-add-node").disable();STDL.getCmp("button-edit-node").disable();STDL.getCmp("button-delete-node").disable();STDL.getCmp("button-add-task").disable()}}STDL.getCmp("button-edit-task").disable();STDL.getCmp("button-delete-task").disable();STDL.getCmp("note-editor").setValue(null)});this.on("click",function(d,f){var b=STDL.data.tasks[STDL.config.TabId.Default].lastOptions;var c=b?b.params.node:0;if(STDL.application.currentTabId!=STDL.config.TabId.Default&&d.id==c){STDL.gui.center.setActiveTab(STDL.config.TabId.Default)}});this.on("dblclick",STDL.actions.Tree.editNode)},updateSort:function(c,a,d){var b={id:c,sort:a,parent_id:d};STDL.gui.showLoadingMask(this.getEl());STDL.data.request({url:"nodes/reorder",params:b,success:function(e,f){STDL.gui.hideLoadingMask()}})},changeTasksNode:function(b,c,a,d){if(!c[a]){return}STDL.data.request({url:"users/test_node_privileges",async:false,params:{nodeId:b.id,userId:c[a].get("assigned_to_id")},success:function(f,i){var j=Ext.decode(f.responseText);if(j.success){this.changeTaskNode(b,c,a,d)}else{var h=c[a].get("name");var g=c[a].get("assigned_to");var e="User "+g+' assigned to the task "'+h+"\" doesn't have privileges to access "+b.text+". ";e+="Move and grant privileges?";STDL.gui.Msg.show({title:"Move Task",msg:e,icon:STDL.gui.Msg.QUESTION,buttons:STDL.gui.Msg.YESNO,fn:function(k){if(k=="yes"){this.changeTaskNode(b,c,a,d)}else{a++;this.changeTasksNode(b,c,a,d)}},scope:this})}},scope:this})},changeTaskNode:function(c,d,b,e){var a=e?"nodes/copy_item_node":"nodes/change_item_node";STDL.gui.showLoadingMask(STDL.gui.grids[STDL.config.TabId.Default].body);STDL.data.request({url:a,params:{nodeId:c.id,itemId:d[b].id,userId:d[b].get("assigned_to_id")},success:function(f,g){STDL.gui.hideLoadingMask();if(e){STDL.data.tasks[STDL.config.TabId.Default].reload()}else{STDL.data.tasks[STDL.config.TabId.Default].remove(d[b])}b++;this.changeTasksNode(c,d,b,e)},scope:this})}});STDL.gui.CheckboxTree=Ext.extend(Ext.tree.TreePanel,{initComponent:function(){Ext.apply(this,{autoScroll:true,animate:true,enableDD:false,containerScroll:true,rootVisible:false,bbar:[new Ext.Toolbar.Button({text:"Select All",handler:this.selectAll,scope:this}),new Ext.Toolbar.Button({text:"Deselect All",handler:this.deselectAll,scope:this})]});this.loader=new STDL.data.ListLoader({params:this.params});STDL.gui.CheckboxTree.superclass.initComponent.call(this);var a=new Ext.tree.AsyncTreeNode({text:"To-Do List",draggable:false,id:"root",checked:false});this.setRootNode(a)},onRender:function(b,a){STDL.gui.CheckboxTree.superclass.onRender.call(this,b,a);this.expandAll();this.on("checkchange",function(d,c){if(c){d.bubble(function(e){if(e.id!="root"){e.attributes.checked=true;e.ui.checkbox.checked=true}})}else{d.cascade(function(e){e.attributes.checked=false;e.ui.checkbox.checked=false})}})},selectAll:function(){this.getRootNode().cascade(function(a){a.getUI().toggleCheck(true)})},deselectAll:function(){this.getRootNode().cascade(function(a){a.getUI().toggleCheck(false)})}});STDL.gui.LoginForm=Ext.extend(Ext.form.FormPanel,{initComponent:function(){var a=STDL.config.Link.ForgotPassword.replace("%s",Session.getParameter("cid"));Ext.apply(this,{bodyStyle:"padding: 5px",items:[{xtype:"fieldset",title:"Login Information",autoHeight:true,items:[{xtype:"box",autoEl:{cls:"form-info",html:"Please enter your username and password:"}},{xtype:"textfield",allowBlank:false,fieldLabel:"Username",maxLength:30,minLength:2,name:"username",id:"username",anchor:"99%"},{xtype:"textfield",allowBlank:false,fieldLabel:"Password",maxLength:30,minLength:2,name:"password",inputType:"password",id:"password",anchor:"99%"},{xtype:"checkbox",name:"remember_me",id:"remember_me",labelSeparator:"",boxLabel:"Remember me on this computer"}]},{xtype:"box",autoEl:{cls:"forgot-password",html:'<a href="'+a+'" onclick="window.open(this.href); return false;">I forgot my username or password</a>'}}]});STDL.gui.LoginForm.superclass.initComponent.call(this)},onRender:function(){STDL.gui.LoginForm.superclass.onRender.apply(this,arguments);this.mapEnterKey()},enterKeyFn:function(){STDL.actions.Login.tryLogin()}});STDL.gui.WizardCard=function(){var c='<div class="header"><img src="resources/images/swift_to_do_list_online.png" alt="Swift To-Do List Online" /></div>';var a={step1:c+"<h1>Welcome to Swift To-Do List Online!</h1>",step2:c+"<h2>To-Do List Tree</h2>",step3:c+"<h2>To-Do List Views</h2>",step4:c+"<h2>Users</h2>",step5:c+"<h2>Thank you</h2>"};a.step1+="<p><b>Your new account is ready to use!</b></p>";a.step1+="<p>This wizard will guide you through the application basics and help you understand how <b>to-do lists</b>, <b>tasks</b> and <b>users</b> work. </p>";a.step1+="<p>You can click the <b>Next button</b> to continue or the Close button to exit this wizard.</p>";a.step1+='<p>You can reopen this wizard anytime by clicking the Help button in the main toolbar or you can visit our <a href="http://www.swifttodolist.com/support" onclick="window.open(this.href); return false;">support center at swifttodolist.com</a>.</p>';a.step2+="<p>To-do list tree is located at the left side of the application window.</p>";a.step2+="<p>Every to-do list has its own icon and name. To display a to-do list, just click its icon.</p>";a.step2+='<table class="todolist" border="0" cellpadding="3" cellspacing="0"><tr valign="top"><td><img src="resources/images/wizard-1.jpg" alt="Image 1" /></td>';a.step2+="<td><p>To add to-do list, click the first or second icon in the small tree toolbar.</p>";a.step2+="<p>You can also drag & drop these to-do lists. Move mouse over to-do list, click and hold left mouse button and drop it on another list.</p>";a.step2+="<p>The tree is automatically updated. If anyone else makes a change in it, it will reflect in your tree within the next update.<sup>1</sup></p>";a.step2+="<p class=\"important with-sup m1\"><b>User Rights<sup>1</sup></b><br />In the Add/Edit To-Do List dialog in the People tab you can explicitly define which users have access to the to-do list. You can then assign tasks in the to-do list to these users. If you don't see any users you either didn't define any users in the parent to-do lists or you haven't added any other users into your account.</p>";a.step2+='<p class="subinfo"><sup>1)</sup> This doesn\'t apply to Personal Plan accounts</p>';a.step2+="</td></tr></table>";a.step3+="<p>The to-do list views are the main parts of Swift To-Do List Online window.</p>";a.step3+='<div class="illustration"><img src="resources/images/wizard-2.jpg" alt="Image 2" /></div>';a.step3+="<p>There are several columns describing the task. You can click any column to sort the to-do list. Every column has its own popup menu where you can hide and show columns or filter tasks in the current view.</p>";a.step3+="<p>To add task, click the first icon in the main toolbar. Click the second to edit task.</p>";a.step3+="<p>You can also drag & drop tasks from one list to another. Select the task(s) you want to move using mouse, click and hold left mouse button and drop task(s) over a to-do list in tree.</p>";a.step3+='<table border="0" cellpadding="3" cellspacing="0"><tr valign="top"><td width="50%">';a.step3+='<p class="important with-sup"><b>Assign Task to User<sup>1</sup></b><br />You can assign a task to any user from the list of users with access to the to-do list. An e-mail containing task details is sent to the assigned user.</p>';a.step3+='<p class="subinfo"><sup>1)</sup> This doesn\'t apply to Personal Plan accounts</p>';a.step3+="</td><td>";a.step3+='<p class="important"><b>Reminders</b><br />If you add a reminder to a task, an e-mail is sent to the assigned user on the beginning of the day you selected.</p>';a.step3+="</td></tr></table>";a.step4+="<p>With Swift To-Do List Online you can easily share to-do lists and tasks with friends and colleagues thanks to integrated user management system.</p>";a.step4+="<p>You can add, modify and delete users in the People dialog. If you add a new user, an e-mail containing login information will be sent to the user's email address you entered.</p>";a.step4+='<table border="0" class="todolist" cellpadding="3" cellspacing="0"><tr valign="top"><td><img src="resources/images/wizard-3.jpg" alt="Image 1" /></td>';a.step4+='<td><p style="padding-top: 0">Any user can be granted one of the three basic roles: Administrator, Superuser or User.</p>';a.step4+="<p>Administrators have full privileges. They can see and modify all to-do lists and tasks and also modify users and use the account support center.</p>";a.step4+="<p>Superusers can see and modify all to-do lists and tasks but cannot modify users or use the account support center.</p>";a.step4+="<p>Users can only see to-do lists they have explicitly granted access to but they are free to add and modify any tasks or sub to-do lists.</p>";a.step4+='<p class="important m2">In order to assign a user (including administrators) to a task you have to explicitly select them in the Add/Edit To-Do List dialog.</p>';a.step4+="</td></tr></table>";a.step5+="<br /><p><b>Thank you for evaluating Swift To-Do List Online!</b></p>";if(Session.getRole()==STDL.config.Roles.ADMIN){a.step5+="<p>For more help please feel free to contact us anytime!</p>";a.step5+='<p>You can use the contact form in the Support dialog to get priority support or you can contact us directly at <a href="mailto:support@swifttodolist.com">support@swifttodolist.com</a>.</p>'}else{a.step5+='<p>Should you have any questions please contact your account administrator or contact us directly at <a href="mailto:support@swifttodolist.com">support@swifttodolist.com</a>.</p></p>'}a.step5+="<p>Have a great day!</p>";var b=new Ext.Panel({layout:"card",activeItem:0,defaults:{border:false},items:[{id:"step-1",cls:"wizard-bg",html:a.step1},{id:"step-2",cls:"wizard-bg",html:a.step2},{id:"step-3",cls:"wizard-bg",html:a.step3},{id:"step-4",cls:"wizard-bg",html:a.step4},{id:"step-5",cls:"wizard-bg",html:a.step5}]});return b};STDL.gui.TaskView=Ext.extend(Ext.grid.GridView,{emptyText:"There are no tasks to show in this list.",getRowClass:function(c,b){var a=[];if(STDL.application.task_IsDone(c)){a.push("grid-row-task-done")}if(c.data.assigned_to_id==Session.user.id&&!Session.isPersonal()){a.push("grid-row-my-task")}return a.join(" ")}});STDL.gui.TaskGroupingView=Ext.extend(Ext.grid.GroupingView,{emptyText:"You have no tasks to do.",getRowClass:function(c,b){var a=[];if(STDL.config.Task.Status.T_CLOSED.indexOf(c.data.status_id)>=0){a.push("grid-row-task-done")}return a.join(" ")}});STDL.gui.TaskGrid=Ext.extend(Ext.grid.GridPanel,{initComponent:function(){var b=this.tasksOverview?true:false;var a=this.tasksOverview?STDL.config.Task.Status.T_OPEN:[];this.setFilterOptions();this.gridFilters=new Ext.ux.grid.GridFilters({filters:[{type:"string",dataIndex:"name"},{type:"list",phpMode:true,dataIndex:"priority",options:this.priorityFilterOptions},{type:"list",phpMode:true,dataIndex:"type",options:this.typeFilterOptions},{type:"date",dataIndex:"due_date"},{type:"list",phpMode:true,dataIndex:"status",options:this.statusFilterOptions,active:b,value:a},{type:"list",phpMode:true,dataIndex:"assigned_to",options:this.userFilterOptions},{type:"list",phpMode:true,dataIndex:"created_by",options:this.userFilterOptions}]});this.cellActions=new Ext.ux.grid.CellActions({callbacks:{"flag-note":function(f,c,h,g,e,i,d){}},align:"left"});Ext.apply(this,{plugins:[this.gridFilters,this.cellActions],width:600,ddGroup:"TreeDD",enableDragDrop:!this.tasksOverview,loadMask:true,autoExpandColumn:"task",region:"center",cls:"main-grid",stateful:true});if(this.tasksOverview){this.view=new STDL.gui.TaskGroupingView();this.view.on("refresh",function(c){var d=STDL.application.getStateProvider();d.set("group-field",c.getGroupField())})}else{this.view=new STDL.gui.TaskView();this.updaterInterval=STDL.config.Task.UpdaterInterval*1000;this.updaterTask={run:this.executeUpdater,interval:this.updaterInterval,scope:this}}this.addColumns();this.dateFormat=STDL.data.getDateFormat(STDL.config.Date.GridFormat);STDL.gui.TaskGrid.superclass.initComponent.call(this);this.getSelectionModel().on("rowdeselect",function(){if(!this.hasSelection()){Ext.getCmp("button-edit-task").disable();Ext.getCmp("button-delete-task").disable();if(STDL.application.currentTabId==STDL.config.TabId.Default){Ext.getCmp("note-editor").setValue(null);STDL.gui.attachments.getStore().removeAll()}}});this.getSelectionModel().on("rowselect",function(e,d,c){Ext.getCmp("button-edit-task").enable();Ext.getCmp("button-delete-task").enable();if(STDL.application.currentTabId==STDL.config.TabId.Default){Ext.getCmp("note-editor").setValue(c.get("note"));STDL.gui.center.noteHtml=c.get("note");STDL.gui.attachments.load(c.id)}});this.on("rowdblclick",STDL.actions.Task.row_DblClick);this.on("dblclick",function(c){if(c.target.className=="x-grid3-scroller"&&!Ext.getCmp("button-add-task").disabled){STDL.actions.Task.add()}});this.on("keydown",function(c){if(c.getKey()==c.DELETE){}})},addColumns:function(){function d(e,f){var g=e.replace(/"/g,"&quot;");f.attr='ext:qtip="'+g+'"';return e}function a(f,i,h){var j=Math.floor(parseInt(f)/2)-49;var e=STDL.application.task_IsDone(h)?"complete-box-bg-done":"complete-box-bg";var g='<div class="complete-box '+e+'" style="background-position: '+j+'px 50%;"><div class="complete-box-border">'+f+"%</div></div>";return g}var b=[{iconIndex:"flag_note",qtipIndex:"flag_note_ttip"},{iconIndex:"flag_attachment",qtipIndex:"flag_attachment_ttip"},{iconIndex:"flag_reminder",qtipIndex:"flag_reminder_ttip"}];var c=[{id:"done",header:"&nbsp;",sortable:true,align:"center",hideable:false,fixed:true,width:30,renderer:this.setTaskDone,dataIndex:"status_id"},{id:"task_id",header:"ID",sortable:true,hidden:true,width:35,dataIndex:"task_id"},{id:"task",header:"Task",sortable:true,hideable:false,width:300,renderer:d,dataIndex:"name"},{id:"flags",header:"Flags",sortable:false,width:70,dataIndex:"flags",cellActions:b},{id:"priority",header:"Priority",sortable:true,renderer:this.getTaskPriority,width:60,dataIndex:"priority"},{id:"type",header:"Type",sortable:true,renderer:this.getTaskType,width:80,dataIndex:"type"},{id:"due_date",header:"Due Date",sortable:true,renderer:this.checkDueDate.createDelegate(this),width:90,dataIndex:"due_date"},{id:"status",header:"Status",sortable:true,width:70,dataIndex:"status"},{id:"complete",header:"Complete",sortable:true,width:65,dataIndex:"complete",renderer:a}];if(this.tasksOverview){c.push({id:"todo_list",header:"To-Do List",sortable:true,dataIndex:"todo_list",renderer:this.todoListLink})}else{c.push({id:"assigned_to",header:"Assigned To",sortable:true,dataIndex:"assigned_to",hidden:Session.isPersonal()})}c.push({id:"created_by",header:"Created By",sortable:true,hidden:true,dataIndex:"created_by"});c.push({id:"last_update",header:"Last Update",sortable:true,hidden:true,width:180,dataIndex:"last_update"});this.columns=c},onRender:function(b,a){STDL.gui.TaskGrid.superclass.onRender.apply(this,arguments);if(this.tasksOverview){this.store.load()}else{this.startUpdater()}},startUpdater:function(){if(!this.updater){this.updater=new Ext.util.TaskRunner()}this.updater.start.defer(this.updaterInterval,this,[this.updaterTask])},stopUpdater:function(){if(this.updater){this.updater.stop(this.updaterTask);this.updater=null}},executeUpdater:function(){if(STDL.application.currentTabId!=STDL.config.TabId.Default||STDL.application.tree_SelectedNode()==null||!STDL.application.allowGridUpdate){return}this.store.reload()},setFilterOptions:function(){this.priorityFilterOptions=[];for(var a=0;a<STDL.config.Task.Priority.length;a++){this.priorityFilterOptions.push({id:STDL.config.Task.Priority[a],text:_TaskPriority[STDL.config.Task.Priority[a]]})}this.statusFilterOptions=[];for(var a=0;a<Session.item_statuses.length;a++){this.statusFilterOptions.push({id:Session.item_statuses[a]["id"],text:Session.item_statuses[a]["name"]})}this.typeFilterOptions=[];this.typeFilterOptions.push({id:"none",text:_TaskType_None});for(var a=0;a<Session.item_types.length;a++){this.typeFilterOptions.push({id:Session.item_types[a]["id"],text:Session.item_types[a]["name"]})}this.userFilterOptions=[];for(var a=0;a<Session.users.length;a++){this.userFilterOptions.push({id:Session.users[a]["id"],text:Session.users[a]["name"]})}},reloadFilterOptions:function(){this.setFilterOptions();var a=this.gridFilters.filters.get("assigned_to");a.menu=new Ext.ux.menu.ListMenu({options:this.userFilterOptions});a.menu.on("checkchange",a.onCheckChange,a);var c=this.gridFilters.filters.get("created_by");c.menu=new Ext.ux.menu.ListMenu({options:this.userFilterOptions});c.menu.on("checkchange",c.onCheckChange,c);var b=this.gridFilters.filters.get("type");b.menu=new Ext.ux.menu.ListMenu({options:this.typeFilterOptions});b.menu.on("checkchange",b.onCheckChange,b)},setTaskDone:function(e,a,f,g,b,d){var c='<input type="checkbox" onclick="STDL.actions.Task.changeTaskState(this.checked, '+g+", "+f.id+", "+f.data.assigned_to_id+');" name="task-box-'+f.id+'" id="task-box-'+f.id+'"'+((STDL.config.Task.Status.T_CLOSED.indexOf(e)>=0)?' checked="checked"':"")+" />";return c},getTaskPriority:function(a){return _TaskPriority[a]},getTaskType:function(a){return a?a:_TaskType_None},checkDueDate:function(f,e,a){var d=Ext.util.Format.date(f,this.dateFormat)||_NoDueDate;var c=new Date();var b=c.clearTime();if(f&&c>f&&STDL.config.Task.Status.T_CLOSED.indexOf(a.data.status_id)<0){e.css="duedate-expired"}return d},todoListLink:function(e,c,f,g,b,a){var d='<a href="#" onclick="STDL.actions.Tree.goToTodoList('+f.data.node_id+')">'+e+"</a>";return d},flagBlankNotes:function(a){this.cellActions.iconSwitch("flag-note",a,"flag-note-blank");this.cellActions.qtipSwitch("flag-note-blank",a,"Task doesn't have notes")},flagHasNotes:function(a){this.cellActions.iconSwitch("flag-note-blank",a,"flag-note");this.cellActions.qtipSwitch("flag-note",a,"Task has notes")},flagBlankAttachments:function(a){this.cellActions.iconSwitch("flag-attachment",a,"flag-attachment-blank");this.cellActions.qtipSwitch("flag-attachment-blank",a,"Task doesn't have attachments")},flagHasAttachments:function(b,a){this.cellActions.iconSwitch("flag-attachment-blank",b,"flag-attachment");this.cellActions.qtipSwitch("flag-attachment",b,"Task has "+a+" attachment(s)")}});STDL.gui.AssignCombo=STDL.extend(Ext.form.ComboBox,{initComponent:function(){var b=this.params||{};Ext.apply(b,Session.authParams());var a=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"users/assign_to_users"}),baseParams:b,reader:new Ext.data.JsonReader({totalProperty:"results",root:"rows",id:"id"},["id","name"])});if(this.defaultValue){a.on("load",function(){this.setValue(this.defaultValue)},this,{single:true});a.load()}Ext.apply(this,{triggerAction:"all",editable:false,forceSelection:true,selectOnFocus:true,emptyText:"Loading...",displayField:"name",valueField:"id",mode:"local",store:a});STDL.gui.AssignCombo.superclass.initComponent.call(this)}});Ext.reg("assigncombo",STDL.gui.AssignCombo);STDL.gui.StatusCombo=STDL.extend(Ext.form.ComboBox,{initComponent:function(){Ext.apply(this,{triggerAction:"all",editable:false,forceSelection:true,selectOnFocus:true,value:this.defaultValue||STDL.config.Task.DefaultStatus,displayField:"name",valueField:"id",mode:"local",store:STDL.data.statuses});STDL.gui.StatusCombo.superclass.initComponent.call(this)}});Ext.reg("statuscombo",STDL.gui.StatusCombo);STDL.gui.ImportDialog=STDL.extend(STDL.gui.Dialog,{constructor:function(){var a="You can use this dialog to import to-do lists and tasks from Swift To-Do List for Windows. The data will be placed into ";a+='a new to-do list <i>"IMPORT date time (filename.xml)</i>".';this.uploadField=new Ext.form.FileUploadField({xtype:"fileuploadfield",anchor:"100%",fieldLabel:"XML File",name:"file"});this.importForm=new Ext.form.FormPanel({fileUpload:true,border:false,labelWidth:90,bodyStyle:"padding: 10px",items:[{xtype:"box",autoEl:{cls:"support-info",html:a}},{xtype:"fieldset",autoHeight:true,title:"Import Data",items:[this.uploadField]},{xtype:"fieldset",autoHeight:true,title:"Import Settings",items:[{xtype:"assigncombo",fieldLabel:"Assigned To",hiddenName:"assigned_to",defaultValue:Session.getId(),allowBlank:false},{xtype:"statuscombo",fieldLabel:"Undone Status",hiddenName:"undone_status",defaultValue:1,allowBlank:false},{xtype:"statuscombo",fieldLabel:"Done Status",hiddenName:"done_status",defaultValue:6,allowBlank:false}]}]});STDL.gui.ImportDialog.superclass.constructor.call(this,{layout:"fit",width:400,height:340,items:this.importForm,title:"Import To-Do Lists And Tasks",buttons:[{text:"Import",handler:this.startImport,scope:this},{text:"Close",handler:function(){this.close()},scope:this}]})},startImport:function(){if(!this.uploadField.getValue()){STDL.gui.Msg.alert("Import","Please choose a XML file with exported Swift To-Do List database first.");return}STDL.gui.showProgressBar("Importing... this may take a while.");STDL.data.submit(this.importForm.getForm(),{url:"app/import",params:{uuid:"0"},success:function(a,b){STDL.gui.Msg.hide();STDL.gui.Msg.alert("Import","Your database has been successfully imported.<br /><br />The To-Do List Tree will update itself in just a few moments.");STDL.application.selectNode=b.result.id;STDL.gui.tree.updater.execute();STDL.gui.tree.updater.reset(20000);this.close()},failure:function(a,b){STDL.gui.Msg.hide();if(b.result.message=="xml_parse_error"){STDL.gui.MsgError("Import","The import has failed.<br />We are sorry for this inconvenience, we will contact you<br />as soon as we fix the problem.")}else{STDL.gui.MsgError("Import","We are sorry, you can only import tasks from Swift To-Do List for Windows.")}},scope:this})}});Windows=function(){this.initialize()};Windows.NODE_ICONS=80;Windows.ADD_ROOT_TYPE=0;Windows.ADD_TYPE=1;Windows.EDIT_TYPE=2;Windows.nodeIcon=0;Windows.prototype={window_Node:null,form_Node:null,window_Task:null,form_Task:null,window_People:null,grid_People:null,window_Person:null,form_Person:null,window_Types:null,grid_Types:null,form_Node_Checkbox1:null,form_Node_Checkbox2:null,textfield_Node:null,textfield_Task:null,textfield_FirstName:null,textfield_LastName:null,textfield_Email:null,textfield_Login:null,textfield_Password:null,panel_DueDate:null,typeCombo:null,assignTo:null,assignToFilter:null,rightsGrid:null,attachmentGrid:null,field_TaskComplete:null,field_DueDate:null,field_RemindBeforeType:null,field_RemindBefore:null,field_RemindAt:null,combobox_TaskStatus:null,button_AddUser:null,button_EditUser:null,button_DeleteUser:null,button_AddType:null,button_EditType:null,button_DeleteType:null,reloadGridOnTaskClose:false,initialize:function(){Session.setParameter("windows",this)},showPeopleTab:function(){if(STDL.getCmp("node-people-tab")){STDL.getCmp("node-people-tab").show()}},seeParentLists:function(c){var b=STDL.gui.tree.getNodeById(c);var a="";b.bubble(function(d){if(d.id!="root"){a+="+ <b>"+d.text+"</b><br />"}});STDL.gui.Msg.alert("Parent To-Do Lists",a)},nodeWindow:function(g,j,c,b,h){switch(g){case Windows.ADD_ROOT_TYPE:var i=_Add+" "+_Root+" "+_ToDoList_Title;break;case Windows.ADD_TYPE:var i=_Add+" "+_ToDoList_Title;break;case Windows.EDIT_TYPE:var i=_Edit+" "+_ToDoList_Title;break}if(!h){h=1}var k=this.nodeIconsSelection(h);if(Session.is(["superuser","admin"])){this.setRightsGrid()}var d={everyone:'Everyone can see this to-do list. You can change this in the <a href="#" onclick="Session.windows.showPeopleTab(); return false;">People tab</a>.',somenot:'Some users can\'t see this to-do list. You can chage this in the <a href="#" onclick="Session.windows.showPeopleTab(); return false;">People tab</a>.'};this.form_Node=new Ext.FormPanel({border:false,labelWidth:80,bodyStyle:"padding: 10px 10px 0",items:[this.textfield_Node=new Ext.form.TextField({id:"textfield_Node",allowBlank:false,anchor:"100%",fieldLabel:"Name",maxLength:255,minLength:1,name:"name",value:b}),{xtype:"fieldset",title:_NodeIcons,autoHeight:true,items:[{xtype:"panel",html:k,border:false}]}]});var a=new Ext.TabPanel({activeTab:0,border:false,deferredRender:false,layoutOnTabChange:true,items:[{title:_NodeOptions,layout:"form",autoHeight:true,items:[this.form_Node]}]});if(Session.is(["superuser","admin"])&&!Session.isPersonal()){a.getComponent(0).add({xtype:"box",id:"node-info-box",hidden:true,autoEl:{cls:"small-info",id:"node-info",html:""}});var f={id:"node-people-tab",title:"People",layout:"border",items:[this.rightsGrid]};a.add(f);if(j){a.getComponent(1).add({xtype:"box",region:"south",height:24,autoEl:{cls:"small-info",html:'Users with access to this to-do list will also see <a href="#" onclick="Session.windows.seeParentLists('+j+'); return false;">all parent to-do lists</a>.'}})}this.rightsGrid.getSelectionModel().on("selectionchange",function(l){if(l.getSelections().length==this.rightsGrid.getStore().getCount()-this.rightsGrid.getStore().unrestrictedUsers){Ext.get("node-info").update(d.everyone)}else{Ext.get("node-info").update(d.somenot)}Ext.getCmp("node-info-box").show()},this)}this.window_Node=new Ext.Window({title:i,layout:"fit",width:425,height:355,plain:true,modal:true,resizable:false,items:a,buttons:[{text:"OK",handler:function(){this.form_Node_Submit(j,c)},scope:this},{text:"Cancel",handler:function(){this.window_Node.close()},scope:this}]});this.focusOnShow(this.window_Node,this.textfield_Node);this.window_Node.show();this.submitOnEnter(this.form_Node,this.form_Node_Submit.createDelegate(this,[j,c]));Windows.selectNodeIcon(h);if(Session.is(["superuser","admin"])&&!Session.isPersonal()){var e={parent:j,id:c};Ext.apply(e,Session.authParams());this.rightsGrid.getStore().load({params:e,scope:this,callback:function(){if(!this.rightsGrid.getSelectionModel().hasSelection()&&this.rightsGrid.getStore().getCount()!=this.rightsGrid.getStore().unrestrictedUsers){Ext.get("node-info").update(d.somenot);Ext.getCmp("node-info-box").show()}}})}},form_Node_Submit:function(a,e){if(!this.textfield_Node.isValid()){Ext.MessageBox.alert("To-Do List","Please specify the to-do list name");return}var b=[];if(Session.is(["superuser","admin"])&&!Session.isPersonal()){var d=this.rightsGrid.getSelectionModel();this.rightsGrid.getStore().each(function(f){if(d.isSelected(f)||f.get("privileges")=="unrestricted"){b.push(f.id)}},this)}b=b.join(";");var c={parent:a,id:e,icon:Windows.nodeIcon,people:b};Ext.apply(c,Session.authParams());STDL.gui.showProgressBar(_SavingNode,"");this.form_Node.getForm().submit({url:STDL.config.serverAddress+"nodes/add_edit_node",params:c,success:function(i,j){if(j.result.isNewNode){var f=STDL.gui.tree;var h=a?f.getNodeById(a):f.getRootNode();var g=new Ext.tree.AsyncTreeNode({id:j.result.node.id,text:j.result.node.name,leaf:false,children:[],iconCls:j.result.node.iconCls,sort:j.result.node.sort});h.leaf=false;h.appendChild(g);g.toggle();g.select()}else{var h=STDL.gui.tree.getNodeById(j.result.node.id);h.setText(j.result.node.name);h.ui.getEl().firstChild.firstChild.nextSibling.nextSibling.className="x-tree-node-icon "+j.result.node.iconCls;h.select()}Ext.MessageBox.hide();this.window_Node.close()},failure:function(f,g){Ext.MessageBox.alert("Error",g.result.message)},scope:this})},nodeIconsSelection:function(d){var c='<table border="0" cellpadding="0" cellspacing="0" class="nodeIconsTable"><tr>';var a=0;var f="";if(!d){d=1}var e=this;for(var b=1;b<=Windows.NODE_ICONS;b++){a++;if(a==15){c+="</tr><tr>";a=1}f=b<10?"0"+b:""+b;c+='<td id="icon-cell-'+b+'" onclick="Windows.selectNodeIcon('+b+');"><div class="icon-node-'+f+'">&nbsp;</div></td>'}c+="</tr></table>";return c},button_Types_Click:function(){this.typesWindow()},taskWindow:function(j,i,u,t){var r=Session.user.id;this.setAssignToCombo(j,(t.user_id?t.user_id:r),(t.assigned_to?t.assigned_to:""));if(STDL.application.currentTabId==STDL.config.TabId.Overview){j=""}this.combobox_TaskStatus=new STDL.gui.StatusCombo({fieldLabel:"Status",anchor:"95%",hiddenName:"status",defaultValue:t.item_status_id});var f=0;if(t.complete){var a=parseInt(t.complete);if(a>0&&a<10){f=10}else{if(a>90&&a<100){f=90}else{f=Math.round(a/10)*10}}}var l=new STDL.gui.StandardCombo({fieldLabel:"% Completed",anchor:"99%",hiddenName:"complete",value:f,store:new STDL.data.SimpleStore({data:[[0,"0%"],[10,"10%"],[20,"20%"],[30,"30%"],[40,"40%"],[50,"50%"],[60,"60%"],[70,"70%"],[80,"80%"],[90,"90%"],[100,"100%"]]})});var o=new Ext.form.ComboBox({fieldLabel:"Estimated Time",anchor:"95%",mode:"local",hiddenName:"estimated_time",triggerAction:"all",readOnly:true,value:t.estimated_time?t.estimated_time:1,displayField:"time",valueField:"id",store:this.getTimeStore()});var b=new Ext.form.ComboBox({fieldLabel:"Time Spent",anchor:"99%",mode:"local",hiddenName:"actual_time",triggerAction:"all",readOnly:true,value:t.actual_time?t.actual_time:1,displayField:"time",valueField:"id",store:this.getTimeStore()});var p=new Ext.form.ComboBox({fieldLabel:"Priority",anchor:"95%",mode:"local",hiddenName:"priority",triggerAction:"all",readOnly:true,value:t.priority?t.priority:3,displayField:"name",valueField:"id",store:new Ext.data.SimpleStore({fields:["id","name"],data:STDL.data.TaskPriority})});var g;this.typeCombo=new Ext.form.ComboBox({fieldLabel:"Type",allowBlank:false,emptyText:"Select type...",anchor:"78%",hiddenName:"type",triggerAction:"all",displayField:"name",valueField:"id",readOnly:true,value:_TaskType_None,store:g=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/list_types"}),baseParams:Session.authParams(),reader:new Ext.data.JsonReader({totalProperty:"results",root:"rows",id:"id"},["id","name"])}),append:[new Ext.Button({text:"...",handler:this.button_Types_Click,scope:this,minWidth:40})]});g.on("load",function(w){if(!w.getById(this.typeCombo.getValue())){this.typeCombo.setValue(_TaskType_None)}},this);if(t.item_type_id){g.on("load",function(){this.typeCombo.setValue(t.item_type_id)},this,{single:true});g.load()}var h=new Date();var q=h.format("Y-m-d");var k=STDL.data.getDateFormat();var m=t.reminder?true:false;var c=m?t.reminder:{};STDL.gui.attachmentsTW=new STDL.gui.AttachmentGrid({id:"attachments-tab",title:"Attachments",layout:"fit",stdl_RowId:i});var d=Session.is_demo?"Please note reminders are not available in live demo version.":"Reminder will be sent to the assigned user.";var e=new Ext.TabPanel({border:false,activeTab:0,layoutOnTabChange:true,deferredRender:false,items:[{title:"Task",layout:"form",autoHeight:true,bodyStyle:"padding: 10px",items:[this.textfield_Task=new Ext.form.TextField({id:"textfield_Task",allowBlank:false,anchor:"100%",fieldLabel:"Task",maxLength:255,minLength:1,name:"task",style:"margin-bottom: 5px",value:t.name?t.name:null}),{layout:"column",border:false,items:[{columnWidth:0.5,border:false,layout:"form",items:[this.assignTo]},{columnWidth:0.5,border:false,layout:"form",labelWidth:1,items:[new Ext.form.Checkbox({boxLabel:Session.isPersonal()?"":"Send notify e-mail",id:"notify_email-checkbox",name:"notify_email",checked:(i||r)?false:true,hidden:Session.isPersonal(),labelSeparator:""})]}]},{layout:"column",labelAlign:"top",style:"margin-bottom: 5px",border:false,items:[{columnWidth:0.5,layout:"form",border:false,items:[this.combobox_TaskStatus,o]},{columnWidth:0.5,layout:"form",border:false,items:[l,b]}]},{layout:"column",labelAlign:"top",style:"margin-bottom: 5px",border:false,items:[{columnWidth:0.5,layout:"form",border:false,items:[p,{layout:"column",border:false,items:[{columnWidth:0.55,layout:"form",border:false,items:[this.field_DueDate=new Ext.form.DateField({fieldLabel:'<input type="checkbox"'+(t.due_date?' checked="checked"':"")+' onclick="this.checked ? Session.windows.field_DueDate.enable() : Session.windows.field_DueDate.disable()" /> Use Due Date',anchor:"95%",disabled:t.due_date?false:true,value:t.due_date?Ext.util.Format.date(t.due_date,k):q,name:"due_date",format:k})]},{columnWidth:0.45,layout:"form",border:false,items:[this.panel_DueDate=new Ext.Panel({border:false,html:"",style:"margin-top: 21px; font-size: 12px"})]}]}]},{columnWidth:0.5,layout:"form",border:false,items:[this.typeCombo]}]}]},{title:"Reminder",layout:"form",bodyStyle:"padding: 10px",autoHeight:true,items:[new Ext.form.FieldSet({id:"reminder-fieldset",title:"Use Reminder by E-Mail",checkboxToggle:true,autoHeight:true,collapsed:!m,labelWidth:150,width:420,items:[{xtype:"box",autoEl:{cls:"support-info",html:d}},this.field_RemindAt=new Ext.form.DateField({fieldLabel:'<input type="radio" name="reminder_type" onclick="Session.windows.changeReminderType(1);" value="at"'+((!m||(m&&c.at))?' checked="checked"':"")+" />&nbsp;At",anchor:"65%",name:"remind_at",disabled:(m&&c.before),value:(m&&c.at)?Ext.util.Format.date(c.at,k):q,format:k}),{layout:"column",border:false,width:430,items:[{columnWidth:0.65,layout:"form",border:false,items:[this.field_RemindBefore=new Ext.form.NumberField({fieldLabel:'<input type="radio" name="reminder_type" onclick="Session.windows.changeReminderType(2);" value="before"'+((m&&c.before)?' checked="checked"':"")+" />&nbsp;Before Due Date",anchor:"100%",minValue:0,allowDecimals:false,style:"text-align: right",value:(m&&c.before)?c.before:0,disabled:(!m||(m&&c.at)),name:"remind_before"})]},{columnWidth:0.35,layout:"form",border:false,labelWidth:1,items:[this.field_RemindBeforeType=new Ext.form.ComboBox({labelSeparator:"",anchor:"70%",disabled:(!m||(m&&c.at)),mode:"local",hiddenName:"remind_before_type",triggerAction:"all",readOnly:true,value:(m&&c.before_type)?c.before_type:3,displayField:"name",valueField:"id",store:new Ext.data.SimpleStore({fields:["id","name"],data:[["3","Days"]]})})]}]}]})]},{title:"Notes",layout:"fit",height:285,items:[{xtype:"htmleditor",id:"task-notes",enableFont:false,width:100,height:100,border:false,name:"note",value:t.note?t.note:null}]}]});this.form_Task=new Ext.FormPanel({id:"jentest",border:false,labelWidth:80,items:[e]});this.assignTo.on("select",function(y,w,x){if(w.id==Session.getId()){Ext.getCmp("notify_email-checkbox").setValue(false)}else{Ext.getCmp("notify_email-checkbox").setValue(true)}});var n=this;this.field_DueDate._old_onTriggerClick=this.field_DueDate.onTriggerClick;this.field_DueDate.onTriggerClick=function(){var w=(this.menu==null);this._old_onTriggerClick();if(w&&this.menu!=null){this.menu.on({select:function(x,y){this.setValue(y);n.dueDateInfo(y)},scope:this})}};if(!i){e.add({title:"Attachments",autoEl:{style:"padding: 10px; font-size: 13px",html:"You can add attachments after saving task."}})}else{e.add(STDL.gui.attachmentsTW)}if(i){var v=_Edit+" "+_Task_Title}else{var v=_Add+" "+_Task_Title}this.window_Task=new Ext.Window({id:"task-window",title:v,layout:"fit",width:460,height:380,plain:true,modal:true,resizable:false,items:this.form_Task,buttons:[{text:"OK",handler:function(){this.form_Task_Submit(j,i,u,t.item_status_id)},scope:this},{text:"Cancel",handler:function(){this.window_Task.close()},scope:this}]});this.focusOnShow(this.window_Task,this.textfield_Task);if(i){this.window_Task.on("close",function(){STDL.gui.attachmentsTW=null},this);this.window_Task.on("show",function(){STDL.gui.hideLoadingMask()},this);var s={item:i};Ext.apply(s,Session.authParams());STDL.gui.attachmentsTW.getStore().reload({params:s})}this.window_Task.on("close",function(){if(this.reloadGridOnTaskClose){this.reloadGridOnTaskClose=false;STDL.gui.grids[STDL.application.currentTabId].getStore().reload({params:{node:j}})}},this);this.window_Task.show();this.submitOnEnter(this.form_Task,this.form_Task_Submit.createDelegate(this,[j,i,u,t.item_status_id]));if(t.due_date){this.dueDateInfo(t.due_date)}this.field_DueDate.on("enable",function(w){this.dueDateInfo(w.getValue())},this);this.field_DueDate.on("disable",function(x){var w=new Ext.XTemplate("");w.overwrite(this.panel_DueDate.body,{})},this)},form_Task_Submit:function(c,a,b,f){if(!this.textfield_Task.isValid()){Ext.MessageBox.alert("Task","Please specify the Task field.");Ext.getCmp("form-task-tabs").setActiveTab(0);return}if(!this.assignTo.isValid()){Ext.MessageBox.alert("Task","Please specify the user this task is assigned to.");Ext.getCmp("form-task-tabs").setActiveTab(0);return}var g=this.combobox_TaskStatus.getValue();var h=a?false:true;var e=a?false:((g==5||g==6)?true:false);if(f!=5&&f!=6&&(g==5||g==6)){e=true;h=true}else{if((f==5||f==6)&&g!=5&&g!=6){e=false;h=true}}var i=Ext.getCmp("reminder-fieldset").collapsed?"":1;var d={node:c,id:a,type_none:_TaskType_None,use_reminder:i};Ext.apply(d,Session.authParams());STDL.gui.showProgressBar(_SavingTask,"");this.form_Task.getForm().submit({url:STDL.config.serverAddress+"items/add_edit_item",params:d,success:function(j,k){if(k.result.item&&k.result.item.id){STDL.application.forceSelectRow=true;STDL.application.selectRow=k.result.item.id}STDL.gui.grids[STDL.application.currentTabId].getStore().reload({params:{node:c}});if(this.window_Search){this.findTasks()}if(this.assignTo.getValue()==Session.user.id&&h){Session.updateTaskNumber(e,(a?false:true))}Ext.MessageBox.hide();this.window_Task.close();if(k.result.message){Ext.MessageBox.alert("Info",k.result.message)}},failure:function(j,k){Ext.MessageBox.alert("Error",k.result.message)},scope:this})},dueDateInfo:function(d){var f=typeof(d)=="string"?Date.parseDate(d,"m/d/Y"):d;var c=new Date();var g=c.format("Y-m-d");var a=Date.parseDate(g,"Y-m-d");var h=STDL.daysBetween(f,a);var e={info:""};if(h==0){e.info='<span class="duedate-ok">Today</span>'}else{if(h==1){e.info='<span class="duedate-ok">Tomorrow</span>'}else{if(h>1){e.info='<span class="duedate-ok">'+h+" days left</span>"}else{e.info='<span class="duedate-expired">Expired date</span>'}}}var b=new Ext.XTemplate("<span>{info}</span>");b.overwrite(this.panel_DueDate.body,e)},getTimeStore:function(){var a=new Ext.data.SimpleStore({fields:["id","time"],data:_Times});return a},button_markTaskDone_Click:function(){this.markTaskDone(true)},changeReminderType:function(a){switch(a){case 1:this.field_RemindBeforeType.disable();this.field_RemindBefore.disable();this.field_RemindAt.enable();break;case 2:this.field_RemindBeforeType.enable();this.field_RemindBefore.enable();this.field_RemindAt.disable();break}},button_AddType_Click:function(){Ext.MessageBox.prompt("Add Task Type",_TaskTypePrompt,function(a,c){if(a=="ok"&&c!=""){STDL.gui.showLoadingMask(this.grid_Types.getEl());var b={name:c};Ext.apply(b,Session.authParams());Ext.Ajax.request({url:STDL.config.serverAddress+"items/add_edit_type",params:b,method:"POST",success:function(e,g){var h=Ext.util.JSON.decode(e.responseText);Session.item_types=h.item_types;STDL.application.reloadFilters();var d=Ext.data.Record.create(["id","name"]);var f=new d({id:h.id,name:h.name});f.id=h.id;this.grid_Types.getStore().add(f);STDL.gui.hideLoadingMask()},failure:STDL.data.requestFailed,scope:this})}},this)},grid_Types_DoubleClick:function(){this.button_EditType_Click()},button_EditType_Click:function(){var a=this.grid_Types.getSelectionModel().getSelected();Ext.MessageBox.show({title:"Edit Task Type",msg:_TaskTypePrompt,buttons:Ext.Msg.OKCANCEL,prompt:true,value:a.data.name,fn:function(b,d){if(b=="ok"&&d!=""){STDL.gui.showLoadingMask(this.grid_Types.getEl());var c={id:a.id,name:d};Ext.apply(c,Session.authParams());Ext.Ajax.request({url:STDL.config.serverAddress+"items/add_edit_type",params:c,method:"POST",success:function(e,f){var g=Ext.util.JSON.decode(e.responseText);Session.item_types=g.item_types;STDL.application.reloadFilters();a.set("name",d);this.reloadGridOnTaskClose=true;STDL.gui.hideLoadingMask()},failure:STDL.data.requestFailed,scope:this})}}.createDelegate(this)})},button_DeleteType_Click:function(){Ext.MessageBox.confirm("Delete Task Type",_TaskTypeConfirm,function(a){if(a=="yes"){var c=this.grid_Types.getSelectionModel().getSelected();STDL.gui.showLoadingMask(this.grid_Types.getEl());var b={id:c.id};Ext.apply(b,Session.authParams());Ext.Ajax.request({url:STDL.config.serverAddress+"items/delete_type",method:"POST",params:b,success:function(d,e){var f=Ext.util.JSON.decode(d.responseText);Session.item_types=f.item_types;STDL.application.reloadFilters();this.grid_Types.getStore().remove(c);this.reloadGridOnTaskClose=true;STDL.gui.hideLoadingMask()},failure:STDL.data.requestFailed,scope:this})}},this)},typesWindow:function(){var c={};Ext.apply(c,Session.authParams());var a=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/get_types"}),baseParams:c,reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},["id","name"])});var b=new Ext.grid.ColumnModel([{id:"name",header:"Type",dataIndex:"name"}]);this.grid_Types=new Ext.grid.GridPanel({layout:"fit",store:a,cm:b,width:300,loadMask:true,autoExpandColumn:"name",tbar:[this.button_AddType=new Ext.Toolbar.Button({iconCls:"icon-small-add",cls:"x-btn-text-icon",text:"Add Type",handler:this.button_AddType_Click,scope:this}),this.button_EditType=new Ext.Toolbar.Button({iconCls:"icon-small-edit",cls:"x-btn-text-icon",text:"Edit Type",disabled:true,handler:this.button_EditType_Click,scope:this}),this.button_DeleteType=new Ext.Toolbar.Button({iconCls:"icon-small-delete",cls:"x-btn-text-icon",text:"Delete Type",disabled:true,handler:this.button_DeleteType_Click,scope:this})]});this.grid_Types.on("rowdblclick",function(){this.grid_Types_DoubleClick()},this);this.grid_Types.getSelectionModel().on("rowselect",function(d){this.button_EditType.enable();this.button_DeleteType.enable()},this);this.grid_Types.getSelectionModel().on("rowdeselect",function(d){if(!d.hasSelection()){this.button_EditType.disable();this.button_DeleteType.disable()}},this);this.window_Types=new Ext.Window({title:"Manage Task Types",layout:"fit",width:330,height:300,plain:true,modal:true,resizable:false,items:this.grid_Types,buttons:[{text:"Close",handler:function(){this.window_Types.close()},scope:this}]});this.window_Types.on("close",function(){this.typeCombo.store.reload()},this);this.window_Types.show();this.grid_Types.getStore().load()},button_AddUser_Click:function(){if(Session.isPersonal()){Ext.Msg.show({title:"Account Limit",msg:"You have a personal account. If you wish to add another users, please upgrade to a multi-user plan.",buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING});return}if(Session.plan.users>0&&this.grid_People.getStore().getCount()>Session.plan.users){Ext.Msg.show({title:"Account Limit",msg:"You have reached the user limit for your account.<br />If you wish to add another user, please delete one first or upgrade to a higher plan.",buttons:Ext.Msg.OK,icon:Ext.MessageBox.WARNING});return}this.personWindow(0)},grid_People_DoubleClick:function(){this.button_EditUser_Click()},button_EditUser_Click:function(){var a=this.grid_People.getSelectionModel().getSelected();var b={id:a.id,first_name:a.data.first_name,last_name:a.data.last_name,email:a.data.email,login:a.data.login,role_id:a.data.role_id};this.personWindow(a.id,b)},button_DeleteUser_Click:function(){Ext.MessageBox.confirm("User",_DeleteUser,function(a){if(a=="yes"){var c=this.grid_People.getSelectionModel().getSelected();var b={id:c.id};Ext.apply(b,Session.authParams());STDL.gui.showLoadingMask(this.grid_People.getEl());Ext.Ajax.request({url:STDL.config.serverAddress+"users/delete_user",method:"POST",params:b,success:function(d,e){var f=Ext.util.JSON.decode(d.responseText);Session.users=f.users;STDL.application.reloadFilters();STDL.gui.hideLoadingMask();this.reloadGridOnTaskClose=true;this.grid_People.getStore().reload()},failure:STDL.data.requestFailed,scope:this})}},this)},peopleWindow:function(d){if(Session.getRole()!=STDL.config.Roles.ADMIN){return false}var f={};Ext.apply(f,Session.authParams());var b=new Ext.data.GroupingStore({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"users/get_people"}),baseParams:f,reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},["id","name","first_name","last_name","login","email","role","role_id"]),sortInfo:{field:"last_name",direction:"ASC"},groupField:"role"});var c=new Ext.grid.ColumnModel([{id:"id",header:"Id",width:25,dataIndex:"id"},{id:"name",header:"Name",dataIndex:"name"},{id:"login",header:"Login",width:80,dataIndex:"login"},{id:"email",header:"E-mail",width:100,dataIndex:"email"},{id:"role",header:"Role",width:60,dataIndex:"role"}]);var e=new Ext.grid.GroupingView({forceFit:true});var a=new Ext.grid.RowSelectionModel({singleSelect:true});this.grid_People=new Ext.grid.GridPanel({layout:"fit",store:b,cm:c,view:e,sm:a,width:300,loadMask:true,autoExpandColumn:"name",tbar:[this.button_AddUser=new Ext.Toolbar.Button({iconCls:"icon-small-add",cls:"x-btn-text-icon",text:"Add User",handler:this.button_AddUser_Click,scope:this}),this.button_EditUser=new Ext.Toolbar.Button({iconCls:"icon-small-edit",cls:"x-btn-text-icon",text:"Edit User",disabled:true,handler:this.button_EditUser_Click,scope:this}),this.button_DeleteUser=new Ext.Toolbar.Button({iconCls:"icon-small-delete",cls:"x-btn-text-icon",text:"Delete User",disabled:true,handler:this.button_DeleteUser_Click,scope:this})]});this.grid_People.on("rowdblclick",function(){this.grid_People_DoubleClick()},this);this.grid_People.getSelectionModel().on("rowselect",function(g){this.button_EditUser.enable();if(g.getSelected().id!=STDL.config.ADMIN_ID){this.button_DeleteUser.enable()}},this);this.grid_People.getSelectionModel().on("rowdeselect",function(g){if(!g.hasSelection()){this.button_EditUser.disable();this.button_DeleteUser.disable()}},this);this.window_People=new Ext.Window({title:"People",layout:"fit",width:600,height:450,plain:true,modal:true,resizable:false,items:this.grid_People,buttons:[{text:"Close",handler:function(){if(this.reloadGridOnTaskClose&&(STDL.application.currentTabId==STDL.config.TabId.Overview||d)){this.reloadGridOnTaskClose=false;STDL.gui.grids[STDL.application.currentTabId].getStore().reload({params:{node:d}})}this.window_People.close()},scope:this}]});this.window_People.show();this.grid_People.getStore().load()},showPrivilegesTab:function(){if(STDL.getCmp("list-privileges-tree")){STDL.getCmp("list-privileges-tree").show()}},personWindow:function(f,e){if(Session.getRole()!=STDL.config.Roles.ADMIN){return false}if(!e){e={}}var d={};if(f){d.userId=f}else{d["export"]="1"}var c=new STDL.gui.CheckboxTree({id:"list-privileges-tree",title:"To-Do Lists Privileges",layout:"fit",params:d});var a;this.roleCombo=new Ext.form.ComboBox({fieldLabel:"Role",anchor:"60%",hiddenName:"role",triggerAction:"all",editable:false,value:(f&&f==1)?"Administrator":"Loading...",displayField:"name",valueField:"id",disabled:(f&&f==1),store:a=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"users/list_roles"}),baseParams:Session.authParams(),reader:new Ext.data.JsonReader({totalProperty:"results",root:"rows",id:"id"},["id","name"])})});a.on("load",function(){if(e.role_id){this.roleCombo.setValue(e.role_id)}else{this.roleCombo.setValue(STDL.config.User.DefaultRole)}},this,{single:true});a.load();Ext.apply(Ext.form.VTypes,{password:function(i,h){var g=/.{4,}/;return i.match(g)},passwordText:"The password has to be at least 4 characters long."});this.form_Person=new Ext.FormPanel({border:false,labelWidth:80,layout:"fit",items:tabPanel=new Ext.TabPanel({border:false,activeTab:0,layoutOnTabChange:true,deferredRender:false,items:[{title:"General",layout:"form",autoHeight:true,items:[{layout:"form",height:336,bodyStyle:"padding: 10px 10px 0",border:false,items:[new Ext.form.FieldSet({title:"Personal Information",labelWidth:80,autoHeight:true,items:[this.textfield_FirstName=new Ext.form.TextField({id:"textfield_Person",allowBlank:false,anchor:"100%",fieldLabel:"First Name",maxLength:45,minLength:1,name:"first_name",style:"margin-bottom: 5px",value:e.first_name?e.first_name:null}),this.textfield_LastName=new Ext.form.TextField({allowBlank:false,anchor:"100%",fieldLabel:"Last Name",maxLength:45,minLength:1,name:"last_name",style:"margin-bottom: 5px",value:e.last_name?e.last_name:null}),this.textfield_Email=new Ext.form.TextField({allowBlank:false,vtype:"email",anchor:"100%",fieldLabel:"E-mail",maxLength:45,minLength:1,name:"email",style:"margin-bottom: 5px",value:e.email?e.email:null})]}),new Ext.form.FieldSet({title:"Login Information",labelWidth:80,autoHeight:true,items:[this.textfield_Login=new Ext.form.TextField({allowBlank:false,anchor:"70%",fieldLabel:"Login",maxLength:45,minLength:1,name:"new_login",style:"margin-bottom: 5px",value:e.login?e.login:null}),this.textfield_Password=new Ext.form.TextField({inputType:"password",allowBlank:f?true:false,anchor:"70%",maxLength:45,fieldLabel:"Password",vtype:"password",name:"new_password",style:"margin-bottom: 5px",value:null})]}),new Ext.form.FieldSet({title:"Permissions",labelWidth:80,autoHeight:true,items:[this.roleCombo]})]},{xtype:"box",id:"user-info-box",hidden:true,autoEl:{cls:"small-info",id:"node-info",html:'You can change user privileges in the <a href="#" onclick="Session.windows.showPrivilegesTab(); return false;">To-Do Lists Privileges tab</a>.'}}]},c,{id:"list-privileges-notice",title:"To-Do Lists Privileges",layout:"form",items:[{xtype:"box",autoEl:{style:"padding: 10px",html:"This user can always see all to-do lists due to the assigned role."}}]}]})});this.roleCombo.on("select",function(i,g,h){if(h==2){tabPanel.unhideTabStripItem("list-privileges-tree");tabPanel.hideTabStripItem("list-privileges-notice");Ext.getCmp("user-info-box").show()}else{tabPanel.hideTabStripItem("list-privileges-tree");tabPanel.unhideTabStripItem("list-privileges-notice");Ext.getCmp("user-info-box").hide()}});this.window_Person=new Ext.Window({title:"Person",layout:"fit",width:400,height:455,plain:true,modal:true,resizable:false,items:this.form_Person,buttons:[{text:"OK",handler:function(){this.form_Person_Submit(f)},scope:this},{text:"Cancel",handler:function(){this.window_Person.close()},scope:this}]});this.focusOnShow(this.window_Person,this.textfield_FirstName);this.window_Person.show();var b="list-privileges-tree";if(!f||e.role_id==3){var b="list-privileges-notice";Ext.getCmp("user-info-box").show()}tabPanel.hideTabStripItem(b);this.submitOnEnter(this.form_Person,this.form_Person_Submit.createDelegate(this,[f]))},form_Person_Submit:function(e){if(!this.textfield_FirstName.isValid()||!this.textfield_LastName.isValid()){Ext.MessageBox.alert("User","Please specify the user's name.");return}if(!this.textfield_Email.isValid()){Ext.MessageBox.alert("User","Please specify the user's e-mail.");return}if(!this.textfield_Login.isValid()){Ext.MessageBox.alert("User","Please specify the user's login.");return}if(!this.textfield_Password.isValid()){Ext.MessageBox.alert("User","The password has to be at least 4 characters long.");return}var d={id:e};Ext.apply(d,Session.authParams());if(this.roleCombo.getValue()=="3"){var c=STDL.getCmp("list-privileges-tree").getChecked();for(var b=0,a=c.length;b<a;b++){d["nodes["+b+"]"]=c[b].id}}STDL.gui.showProgressBar(_SavingUser,"");this.form_Person.getForm().submit({url:STDL.config.serverAddress+"users/add_edit_user",params:d,success:function(f,g){this.grid_People.getStore().reload();this.reloadGridOnTaskClose=true;Session.users=g.result.users;STDL.application.reloadFilters();Ext.MessageBox.hide();this.window_Person.close();if(e&&e==Session.getId()){Session.setUsername(g.result.user.login);STDL.gui.grids[STDL.config.TabId.Overview].getStore().baseParams.username=Session.getUsername();STDL.gui.grids[STDL.config.TabId.Default].getStore().baseParams.username=Session.getUsername();Session.setName(g.result.user.name);Ext.get("user-info-name").update(Session.getName());Session.setEmail(g.result.user.email);if(g.result.user.password){Session.setPassword(g.result.user.password);STDL.gui.grids[STDL.config.TabId.Overview].getStore().baseParams.password=Session.getPassword();STDL.gui.grids[STDL.config.TabId.Default].getStore().baseParams.password=Session.getPassword()}if(e!=1&&g.result.user.role!=Session.getRole()){Ext.MessageBox.alert("User",_RoleChange)}}if(!e){Ext.MessageBox.alert("User",_UserAdded)}},failure:function(f,g){Ext.MessageBox.alert("Error",g.result.message)},scope:this})},focusOnShow:function(a,b){a.on("show",function(e){var f=Ext.get(e.el);f.setStyle("overflow","auto");var c=f.select(".ext-mb-textarea",true);if(!c.item(0)){c=f.select(".ext-mb-text",true)}if(c.item(0)){c.item(0).dom.select()}b.focus()},this,{delay:50})},submitOnEnter:function(b,a){var c=new Ext.KeyMap(b.getForm().getEl(),{key:13,fn:a,scope:this})},setAssignToCombo:function(d,h,j){if(!d){var e={};var a="taskfilter[value][assigned_to]";var g="";var b=""}else{var e={node:d};var a="assign_to";var g="Assign To";var b=":"}Ext.apply(e,Session.authParams());var k;var f=new Ext.data.Record.create([{name:"name"},{name:"id"}]);var i=new Ext.form.ComboBox({fieldLabel:g,labelSeparator:b,allowBlank:d?false:true,disabled:(d&&!Session.isPersonal())?false:true,emptyText:"Select user...",anchor:d?"95%":"99%",hiddenName:a,triggerAction:"all",displayField:"name",valueField:"id",readOnly:true,style:d?"margin-bottom: 10px":"",store:k=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"users/assign_to_users"}),baseParams:e,reader:new Ext.data.JsonReader({totalProperty:"results",root:"rows",id:"id"},f)})});if(h){k.on("load",function(c){if(c.getById(h)){i.setValue(h)}else{if(j){i.setValue(j);i.hiddenField.value=h}}},this,{single:true});k.load()}if(d){this.assignTo=i}else{this.assignToFilter=i}},setRightsGrid:function(){var c=new Ext.data.GroupingStore({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"users/node_users"}),reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},["name","last_name","checked","role","privileges"]),sortInfo:{field:"checked",direction:"DESC"},groupField:"privileges"});function d(f){return f=="restricted"?"Users with restricted access":"Users that always see all to-do lists"}var b=new STDL.gui.RightsSelectionModel();var a=new Ext.grid.ColumnModel([b,{id:"name",header:"Name",dataIndex:"name"},{id:"role",header:"Role",dataIndex:"role"},{id:"privileges",header:"Privileges",dataIndex:"privileges",hidden:true,groupRenderer:d}]);var e=new Ext.grid.GroupingView({showGroupName:false,forceFit:true});this.rightsGrid=new Ext.grid.GridPanel({store:c,cm:a,sm:b,view:e,autoExpandColumn:"name",loadMask:true,width:200,height:100,region:"center",layout:"fit",title:"Who can see this to-do list?",border:false});this.rightsGrid.getStore().on("load",function(g,f){g.unrestrictedUsers=0;STDL.each(f,function(h){if(h.get("privileges")=="unrestricted"){g.unrestrictedUsers++}});STDL.each(f,function(h){if(h.get("checked")==1){var i=c.indexOf(h);this.rightsGrid.getSelectionModel().selectRow(i,true)}},this)},this)}};Windows.selectNodeIcon=function(b){for(var a=1;a<=Windows.NODE_ICONS;a++){Ext.get("icon-cell-"+a).removeClass("cell-selected")}Ext.get("icon-cell-"+b).addClass("cell-selected");Windows.nodeIcon=b};Windows.FILTER_GRID="grid";Windows.FILTER_SEARCH="search";Windows.FILTER_PRINT="print";Ext.override(Windows,{window_Search:null,form_Search:null,grid_Search:null,window_Filter:{},form_Filter:{},window_Print:null,form_Print:null,tree_Print:null,window_Support:null,form_Support:null,form_Settings:null,textfield_Search:null,checkbox_IncludeNotes:null,checkbox_IncludeFilter:null,checkbox_IncludePrintFilter:null,fieldset_Filter:{},field_Filter_Comp:{},field_Filter_Value:{},filterValues:{},textfield_Email:null,textarea_Message:null,button_Find_Click:function(){this.findTasks()},grid_Search_DoubleClick:function(){STDL.actions.Task.showEditDialog(this.grid_Search.getSelectionModel().getSelected().id)},configureFilter:function(){this.checkbox_IncludeFilter.setValue(true);this.filterWindow(Windows.FILTER_SEARCH)},searchWindow:function(){var d={};Ext.apply(d,Session.authParams());var b=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/find_items"}),baseParams:d,reader:new Ext.data.XmlReader({record:"row",id:"id",totalRecords:"results"},["id","name","todolist","todolist_id"])});b.on("beforeload",function(e,f){f.params=f.params||{};var g=STDL.application.getFilterOptions(Windows.FILTER_SEARCH);Ext.apply(f.params,g)},this);var c=new Ext.grid.ColumnModel([{id:"name",header:"Task",dataIndex:"name"},{id:"todolist",header:"To-Do List",width:110,dataIndex:"todolist"}]);this.grid_Search=new Ext.grid.GridPanel({title:"Search Results",store:b,cm:c,width:450,height:240,loadMask:true,autoExpandColumn:"name"});this.grid_Search.getSelectionModel().on("rowselect",function(k,j,e){var h=STDL.gui.tree.getNodeById(e.data.todolist_id);var f=e.id;var i=STDL.application.tree_SelectedNode();if(!i||i.id!=h.id){STDL.application.selectRow=f}STDL.gui.tree.getSelectionModel().select(h);if(i&&i.id==h.id){var g=STDL.data.tasks[STDL.config.TabId.Default].getById(f);STDL.gui.grids[STDL.config.TabId.Default].getSelectionModel().selectRecords([g])}},this);this.grid_Search.on("rowdblclick",this.grid_Search_DoubleClick,this);this.form_Search=new Ext.FormPanel({border:false,labelWidth:80,bodyStyle:"padding: 10px",items:[new Ext.form.FieldSet({title:"Search Configuration",labelWidth:80,autoHeight:true,items:[this.textfield_Search=new Ext.form.TextField({id:"textfield_Search",anchor:"99%",fieldLabel:"Find",maxLength:255,name:"find"}),this.checkbox_IncludeNotes=new Ext.form.Checkbox({boxLabel:"Search task notes as well",name:"include_notes",labelSeparator:""}),{layout:"column",border:false,items:[{columnWidth:0.6,layout:"form",border:false,items:[this.checkbox_IncludeFilter=new Ext.form.Checkbox({boxLabel:"Filter search results...",name:"include_filter",labelSeparator:""})]},{columnWidth:0.4,layout:"form",border:false,labelWidth:1,items:[new Ext.Button({text:"Configure Search Filter...",handler:this.configureFilter,scope:this})]}]}]}),new Ext.Button({text:"Find",handler:this.button_Find_Click,scope:this,cls:"find-button"})]});var a=new Ext.Panel({layout:"border",border:false,items:[{border:false,layout:"form",region:"north",height:160,items:this.form_Search},{border:false,region:"center",bodyStyle:"padding: 10px",items:this.grid_Search}]});this.window_Search=new Ext.Window({title:"Find Tasks",layout:"fit",width:490,height:490,plain:true,modal:true,resizable:false,items:a,buttons:[{text:"Close",handler:function(){this.window_Search.close()},scope:this}]});this.focusOnShow(this.window_Search,this.textfield_Search);this.window_Search.show();this.submitOnEnter(this.form_Search,this.findTasks.createDelegate(this))},findTasks:function(){var c=this.textfield_Search.getValue();var b=this.checkbox_IncludeNotes.checked;var a=this.checkbox_IncludeFilter.checked;this.grid_Search.getStore().reload({params:{find:c,include_notes:b?"true":"",include_filter:a?"true":""}})},filterWindow:function(d){if(!this.window_Filter[d]){var e=[["1",">="],["2","="],["3","<="]];var c=[["is","is"],["isnot","is not"]];var b=[["1","today"],["2","expired"],["3","before"],["4","after"],["5","equals to"],["6","before or on"],["7","after or on"],["8","tomorrow"],["9","yeasterday"]];var a=[["1","after"],["2","on"],["3","before"]];this.field_Filter_Comp[d]={};this.field_Filter_Value[d]={};this.setAssignToCombo();this.field_Filter_Value[d]["assigned_to"]=this.assignToFilter;this.form_Filter[d]=new Ext.FormPanel({border:false,bodyStyle:"padding: 10px",items:[this.fieldset_Filter[d]=new Ext.form.FieldSet({title:"Filter Tasks",labelWidth:120,autoHeight:true,checkboxToggle:true,collapsed:true,width:375,layout:"column",items:[{columnWidth:0.6,layout:"form",border:false,items:[this.field_Filter_Comp[d]["status"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-status" onclick="Session.windows.setFilter(\''+d+"', 'status', this.checked);\" class=\"checkboxClass\" /> Status",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][status]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:e})}),this.field_Filter_Comp[d]["assigned_to"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-assigned_to" onclick="Session.windows.setFilter(\''+d+"', 'assigned_to', this.checked);\" class=\"checkboxClass\" /> Assigned To",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][assigned_to]",valueField:"id",displayField:"name",value:"is",store:new Ext.data.SimpleStore({fields:["id","name"],data:c})}),this.field_Filter_Comp[d]["complete"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-complete" onclick="Session.windows.setFilter(\''+d+"', 'complete', this.checked);\" class=\"checkboxClass\" /> Complete (%)",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][complete]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:e})}),this.field_Filter_Comp[d]["due_date"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-due_date" onclick="Session.windows.setFilter(\''+d+"', 'due_date', this.checked);\" class=\"checkboxClass\" /> Due Date",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][due_date]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:b})}),this.field_Filter_Comp[d]["created"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-created" onclick="Session.windows.setFilter(\''+d+"', 'created', this.checked);\" class=\"checkboxClass\" /> Created",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][created]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:a})}),this.field_Filter_Comp[d]["priority"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-priority" onclick="Session.windows.setFilter(\''+d+"', 'priority', this.checked);\" class=\"checkboxClass\" /> Priority",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][priority]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:e})}),this.field_Filter_Comp[d]["type"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-type" onclick="Session.windows.setFilter(\''+d+"', 'type', this.checked);\" class=\"checkboxClass\" /> Type",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][type]",valueField:"id",displayField:"name",value:"is",store:new Ext.data.SimpleStore({fields:["id","name"],data:c})}),this.field_Filter_Comp[d]["estimated_time"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-estimated_time" onclick="Session.windows.setFilter(\''+d+"', 'estimated_time', this.checked);\" class=\"checkboxClass\" /> Estimated Time",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][estimated_time]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:e})}),this.field_Filter_Comp[d]["actual_time"]=new Ext.form.ComboBox({fieldLabel:'<input type="checkbox" id="filter-'+d+'-actual_time" onclick="Session.windows.setFilter(\''+d+"', 'actual_time', this.checked);\" class=\"checkboxClass\" /> Actual Time",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,disabled:true,hiddenName:"taskfilter[comp][actual_time]",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:e})})]},{columnWidth:0.4,layout:"form",border:false,labelWidth:1,items:[this.field_Filter_Value[d]["status"]=new Ext.form.ComboBox({labelSeparator:"",anchor:"99%",mode:"local",hiddenName:"taskfilter[value][status]",triggerAction:"all",readOnly:true,disabled:true,value:1,displayField:"name",valueField:"id",store:STDL.data.statuses}),this.field_Filter_Value[d]["assigned_to"],this.field_Filter_Value[d]["complete"]=new Ext.form.NumberField({labelSeparator:"",anchor:"99%",minValue:0,maxValue:100,allowDecimals:false,disabled:true,style:"text-align: right",value:0,name:"taskfilter[value][complete]"}),this.field_Filter_Value[d]["due_date"]=new Ext.form.DateField({labelSeparator:"",anchor:"99%",disabled:true,value:new Date(),name:"taskfilter[value][due_date]"}),this.field_Filter_Value[d]["created"]=new Ext.form.DateField({labelSeparator:"",anchor:"99%",disabled:true,value:new Date(),name:"taskfilter[value][created]"}),this.field_Filter_Value[d]["priority"]=new Ext.form.ComboBox({labelSeparator:"",anchor:"99%",mode:"local",hiddenName:"taskfilter[value][priority]",triggerAction:"all",readOnly:true,disabled:true,value:3,displayField:"name",valueField:"id",store:new Ext.data.SimpleStore({fields:["id","name"],data:STDL.data.TaskPriority})}),this.field_Filter_Value[d]["type"]=new Ext.form.ComboBox({labelSeparator:"",anchor:"99%",hiddenName:"taskfilter[value][type]",triggerAction:"all",displayField:"name",valueField:"id",readOnly:true,disabled:true,value:_TaskType_None,store:typeComboStore=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:STDL.config.serverAddress+"items/list_types"}),baseParams:Session.authParams(),reader:new Ext.data.JsonReader({totalProperty:"results",root:"rows",id:"id"},["id","name"])})}),this.field_Filter_Value[d]["estimated_time"]=new Ext.form.ComboBox({labelSeparator:"",anchor:"99%",mode:"local",hiddenName:"taskfilter[value][estimated_time]",triggerAction:"all",readOnly:true,disabled:true,value:1,displayField:"name",valueField:"id",store:new Ext.data.SimpleStore({fields:["id","name"],data:_Times})}),this.field_Filter_Value[d]["actual_time"]=new Ext.form.ComboBox({labelSeparator:"",anchor:"99%",mode:"local",hiddenName:"taskfilter[value][actual_time]",triggerAction:"all",readOnly:true,disabled:true,value:1,displayField:"name",valueField:"id",store:new Ext.data.SimpleStore({fields:["id","name"],data:_Times})})]}]})]});this.field_Filter_Value[d]["due_date"].on("enable",function(){var f=this.field_Filter_Comp[d]["due_date"].getValue();switch(f){case"1":case"2":case"8":case"9":this.field_Filter_Value[d]["due_date"].disable();break}},this);this.field_Filter_Comp[d]["due_date"].on("select",function(h,f,g){switch(f.data.id){case"1":case"2":case"8":case"9":this.field_Filter_Value[d]["due_date"].disable();break;default:this.field_Filter_Value[d]["due_date"].enable();break}},this);this.window_Filter[d]=new Ext.Window({title:"Filter",layout:"fit",width:410,height:360,plain:true,modal:true,resizable:false,items:this.form_Filter[d],closeAction:"hide",buttons:[{text:"OK",handler:function(){this.filterTasks(d)},scope:this},{text:"Cancel",handler:function(){this.window_Filter[d].hide()},scope:this}]});this.window_Filter[d].on("hide",this.closingFilter.createDelegate(this,[d]));this.window_Filter[d].on("destroy",function(){this.window_Filter[d]=null;this.form_Filter[d]=null},this)}this.window_Filter[d].show();this.submitOnEnter(this.form_Filter[d],this.filterTasks.createDelegate(this,[d]))},closingFilter:function(b){if(STDL.application.filterValues[b]){this.fieldset_Filter[b].expand();for(var a in STDL.application.filterValues[b]){if(STDL.application.filterValues[b][a].enabled){this.field_Filter_Comp[b][a].enable();this.field_Filter_Value[b][a].enable();this.field_Filter_Comp[b][a].setValue(STDL.application.filterValues[b][a].comp);this.field_Filter_Value[b][a].setValue(STDL.application.filterValues[b][a].value);Ext.get("filter-"+b+"-"+a).dom.checked=true}else{this.field_Filter_Comp[b][a].disable();this.field_Filter_Value[b][a].disable();Ext.get("filter-"+b+"-"+a).dom.checked=false}}}else{this.window_Filter[b].destroy()}},filterTasks:function(b){STDL.application.filterValues[b]={};if(!this.fieldset_Filter[b].collapsed){var e;var d;for(var a in this.field_Filter_Comp[b]){d=this.field_Filter_Value[b][a].getValue();if(typeof(d)=="object"){d=d.format("m/d/Y")}e={enabled:!this.field_Filter_Comp[b][a].disabled,comp:this.field_Filter_Comp[b][a].getValue(),value:d};STDL.application.filterValues[b][a]=e}}else{STDL.application.filterValues[b]=null}Ext.MessageBox.hide();this.window_Filter[b].hide();if(b==Windows.FILTER_GRID){var c=STDL.application.tree_SelectedNode();if(STDL.application.currentTabId==STDL.config.TabId.Default&&c){STDL.gui.grids[STDL.config.TabId.Default].getStore().reload({params:{node:c.id}})}}},setFilter:function(a,c,b){if(b){this.field_Filter_Comp[a][c].enable();this.field_Filter_Value[a][c].enable()}else{this.field_Filter_Comp[a][c].disable();this.field_Filter_Value[a][c].disable()}},button_PrintFilter_Click:function(){this.checkbox_IncludePrintFilter.setValue(true);this.filterWindow(Windows.FILTER_PRINT)},button_PrintPreview_Click:function(){this.form_Print_Submit("preview")},button_PrintPrint_Click:function(){this.form_Print_Submit("print")},button_PrintExport_Click:function(){this.form_Print_Submit("export")},button_SelectAll_Click:function(){this.tree_Print.getRootNode().cascade(function(a){a.getUI().toggleCheck(true)})},button_DeselectAll_Click:function(){this.tree_Print.getRootNode().cascade(function(a){a.getUI().toggleCheck(false)})},printWindow:function(){if(!this.window_Print){var d={"export":"1"};Ext.apply(d,Session.authParams());this.tree_Print=new Ext.tree.TreePanel({autoScroll:true,animate:true,enableDD:false,containerScroll:true,title:"To-Do List",width:100,height:411,border:true,rootVisible:false,loader:new Ext.tree.TreeLoader({dataUrl:STDL.config.serverAddress+"nodes/get_nodes_at_once",baseParams:d}),bbar:[new Ext.Toolbar.Button({text:"Select All",handler:this.button_SelectAll_Click,scope:this}),new Ext.Toolbar.Button({text:"Deselect All",handler:this.button_DeselectAll_Click,scope:this})]});var b=new Ext.tree.AsyncTreeNode({text:"To-Do List",draggable:false,id:"root",checked:false});this.tree_Print.setRootNode(b);this.tree_Print.expandAll();this.tree_Print.getSelectionModel().on("selectionchange",function(f,e){},this);var a=[["1","Task"],["2","Status"],["3","Assigned To"],["4","Complete"],["5","Due Date"],["6","Created"],["7","Priority"],["8","Type"],["9","Estimated Time"],["10","Actual Time"]];var c;this.form_Print=new Ext.FormPanel({border:false,labelWidth:80,items:c=new Ext.TabPanel({border:false,activeTab:0,deferredRender:false,layoutOnTabChange:true,items:[{title:"General",layout:"column",autoHeight:true,bodyStyle:"padding: 10px",items:[{layout:"fit",border:false,columnWidth:0.45,items:[this.tree_Print]},{layout:"form",border:false,columnWidth:0.55,bodyStyle:"padding-left: 10px",items:[{xtype:"fieldset",labelWidth:1,autoHeight:true,title:"Filter",layout:"column",cls:"print-dialog-fieldset",items:[{layout:"form",columnWidth:0.5,border:false,items:[this.checkbox_IncludePrintFilter=new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Filter tasks",name:"include_filter"})]},{layout:"form",columnWidth:0.5,border:false,items:[new Ext.Button({text:"Configure Filter...",cls:"print-dialog-button",handler:this.button_PrintFilter_Click,scope:this})]}]},new Ext.form.FieldSet({labelWidth:1,autoHeight:true,title:"Options",cls:"print-dialog-fieldset print-dialog-checkbox",items:[new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Include task notes",name:"opt[notes]"}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Page-wide tables",name:"opt[page_wide_tables]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Hide inner borders",name:"opt[hide_borders]"}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Include full to-do list path",name:"opt[full_path]"}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Color tasks by priority",name:"opt[color]"}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Merge to one table",name:"opt[merge]"}),{layout:"form",border:false,labelWidth:80,items:[new Ext.form.ComboBox({style:"margin-bottom: 3px",fieldLabel:"Font Size",width:80,mode:"local",triggerAction:"all",readOnly:true,hiddenName:"font_size",valueField:"id",displayField:"name",value:"12",store:new Ext.data.SimpleStore({fields:["id","name"],data:[["16","16"],["12","12"],["10","10"],["9","9"],["8","8"]]})}),new Ext.form.ComboBox({fieldLabel:"Heading Size",width:80,mode:"local",triggerAction:"all",readOnly:true,hiddenName:"heading_size",valueField:"id",displayField:"name",value:"4",store:new Ext.data.SimpleStore({fields:["id","name"],data:[["1","Largest"],["2","Larger"],["3","Large"],["4","Medium"],["5","Small"],["6","Smallest"]]})})]}]}),new Ext.form.FieldSet({labelWidth:1,autoHeight:true,title:"Print",layout:"column",cls:"print-dialog-fieldset",items:[{layout:"form",columnWidth:0.5,border:false,items:[new Ext.Button({text:"Preview...",cls:"print-dialog-button",handler:this.button_PrintPreview_Click,scope:this})]},{layout:"form",columnWidth:0.5,border:false,items:[new Ext.Button({text:"Print...",cls:"print-dialog-button",handler:this.button_PrintPrint_Click,scope:this})]}]}),new Ext.form.FieldSet({labelWidth:40,autoHeight:true,title:"Export",layout:"column",cls:"print-dialog-fieldset",items:[{layout:"form",columnWidth:0.5,border:false,items:[new Ext.form.ComboBox({fieldLabel:"Format",anchor:"95%",mode:"local",triggerAction:"all",readOnly:true,hiddenName:"export_format",valueField:"id",displayField:"name",value:"1",store:new Ext.data.SimpleStore({fields:["id","name"],data:[["1","HTML"],["2","CSV"]]})})]},{layout:"form",columnWidth:0.5,border:false,labelWidth:1,items:[new Ext.Button({text:"Export...",cls:"print-dialog-button",handler:this.button_PrintExport_Click,scope:this})]}]})]}]},{title:"Columns and Sorting",layout:"form",autoHeight:true,bodyStyle:"padding: 10px",items:[new Ext.form.FieldSet({labelWidth:1,autoHeight:true,title:"Columns",items:[new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Done/Undone checkbox",name:"col[done_undone]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Status",name:"col[status]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Assigned To",name:"col[assigned_to]",checked:!Session.isPersonal()}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Complete",name:"col[complete]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Due Date",name:"col[due_date]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Created",name:"col[created]"}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Priority",name:"col[priority]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Type",name:"col[type]",checked:true}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Estimated Time",name:"col[estimated_time]"}),new Ext.form.Checkbox({labelSeparator:"",boxLabel:"Actual Time",name:"col[actual_time]"})]}),new Ext.form.FieldSet({labelWidth:60,autoHeight:true,title:"Sorting",items:[new Ext.form.ComboBox({fieldLabel:"Sort By",width:140,mode:"local",triggerAction:"all",readOnly:true,hiddenName:"sort_by",valueField:"id",displayField:"name",value:"8",store:new Ext.data.SimpleStore({fields:["id","name"],data:a})})]})]}]})});this.window_Print=new Ext.Window({title:"Print and Export",layout:"fit",width:520,height:530,plain:true,modal:true,resizable:false,items:this.form_Print,closeAction:"hide",buttons:[{text:"Close",handler:function(){this.window_Print.hide()},scope:this}]})}this.window_Print.show()},form_Print_Submit:function(d){var e=this.tree_Print.getChecked();var f={type:d};for(var c=0,a=e.length;c<a;c++){f["nodes["+c+"]"]=e[c].id}var b=STDL.application.getFilterOptions(Windows.FILTER_PRINT);Ext.apply(f,b);Ext.apply(f,Session.authParams());STDL.gui.showProgressBar(_CreatingPrint,"");this.form_Print.getForm().submit({url:STDL.config.serverAddress+"items/generate_print_output",params:f,success:function(g,i){var k=i.result.fid;var h=i.result.format;var j={fid:k,type:d,format:h};Ext.apply(j,Session.authParams());window.open(STDL.config.serverAddress+"items/print_and_export&"+STDL.serialize(j));Ext.MessageBox.hide()},failure:function(g,h){Ext.MessageBox.alert("Error",h.result.message)},scope:this})},windowSupport:function(){if(!this.window_Support){this.form_Support=new Ext.FormPanel({title:"Contact Support",id:"contact-support-tab",border:false,labelWidth:80,bodyStyle:"padding: 10px",items:[{xtype:"box",autoEl:{cls:"support-info",html:"Please feel free to use this form to contact us with any issue regarding your account or client application. Our tech support staff is ready to help you."}},new Ext.form.FieldSet({autoHeight:true,labelWidth:120,title:"Contact Form",labelAlign:"top",items:[{layout:"column",border:false,items:[{layout:"form",border:false,columnWidth:0.5,items:[this.textfield_Email=new Ext.form.TextField({fieldLabel:"Your E-Mail",name:"email",vtype:"email",anchor:"95%",value:Session.user.email,allowBlank:false})]},{layout:"form",border:false,columnWidth:0.5,items:[new Ext.form.ComboBox({fieldLabel:"Request Type",anchor:"99%",mode:"local",triggerAction:"all",readOnly:true,hiddenName:"request_type",valueField:"name",displayField:"name",value:"General Support",store:new Ext.data.SimpleStore({fields:["id","name"],data:[["1","General Support"],["2","Something isn't working"],["3","Ideas and Improvements"],["4","Other Client Issue"],["5","Upgrade or Downgrade Request"],["6","Cancellation Request"],["7","Other Account Issue"]]})})]}]},new Ext.form.TextField({fieldLabel:"Subject (optional)",name:"subject",anchor:"99%"}),this.textarea_Message=new Ext.form.TextArea({name:"message",fieldLabel:"Message",height:80,anchor:"100%",allowBlank:false})]})]});var c="You can cancel your subscription at any time. Your account will be automatically closed after cancelling your subscription. If you don't have PayPal account associated with your subscription, please send us cancellation request and we will cancel the subscription for you.";this.form_Settings=new Ext.form.FormPanel({id:"settings-tab",title:"Settings",border:false,labelWidth:140,bodyStyle:"padding: 10px",items:[{xtype:"box",autoEl:{cls:"support-info",html:"Welcome to the Account Center. You can change global settings of your account here. For upgrade/downgrade requests please use the contact form in the Help section."}},{xtype:"fieldset",title:"Date Format",autoHeight:true,items:[{xtype:"standardcombo",fieldLabel:"Which looks right?<sup>*</sup>",labelSeparator:"",value:Session.date_format,hiddenName:"date_format",mode:"local",store:STDL.data.date_formats}]},{xtype:"box",autoEl:{cls:"add-info",html:"<sup>*</sup> This change will take effect at the next logon."}}]});function a(e){var d=new Ext.form.FormPanel({border:false,baseCls:"x-plain",bodyStyle:"padding: 5px",labelWidth:1,items:[{xtype:"box",autoEl:{cls:"cancel-subscription",html:"We are sorry to see you go. We would like to ask you the reason you are canceling your subscription to help us improve our service:"}},{xtype:"textarea",id:"why-unsbuscribe",labelSeparator:"",width:"100%",height:70,name:"reason",style:"padding-left: 0"}]});STDL.gui.showWindow({id:"cancel-subscription-window",title:"Subscription Cancellation",layout:"fit",closable:true,width:360,height:210,items:d,buttons:[{text:"Cancel My Subscription",handler:function(){STDL.gui.showProgressBar((e==1?"Redirecting to subscription service...":"Sending cancellation request..."));STDL.data.submit(d.getForm(),{url:"app/why_cancel",success:function(f,g){if(e==1){location.href=STDL.config.Link.CancelSubscr}else{var h={email:Session.user.email,request_type:"Cancellation Request",subject:"Send Cancellation Request button",message:"SID: "+Session.getSubscrId()};STDL.data.request({url:"users/support_request",params:h,success:function(i,k){STDL.gui.Msg.hide();var j=Ext.util.JSON.decode(i.responseText);if(j.success){Ext.MessageBox.alert("Cancellation Request","The cancellation request has been sent.")}else{Ext.MessageBox.alert("Error",j.message)}STDL.gui.closeWindow("cancel-subscription-window")}})}}})}},{text:"Keep My Account Open",handler:function(){STDL.gui.closeWindow("cancel-subscription-window")}}]});STDL.gui.focus(Ext.getCmp("why-unsbuscribe"))}var b=new Ext.TabPanel({activeTab:0,border:false,deferredRender:false,layoutOnTabChange:true,defaults:{bodyStyle:"padding: 10px"},items:[this.form_Settings,{title:"Subscription",layout:"form",items:[{xtype:"fieldset",title:"Subscription Cancellation",autoHeight:true,items:[{xtype:"box",autoEl:{cls:"in-fieldset-info",html:c}},{xtype:"box",autoEl:{cls:"in-fieldset-info",html:"Your Subscription Number: <b>"+Session.getSubscrNumber()+"</b>"}},{xtype:"button",text:"Cancel My Subscription",minWidth:220,style:"margin-left: 80px",handler:function(){a(1)}},{xtype:"button",text:"Send Cancellation Request",minWidth:220,style:"margin-left: 80px; margin-top: 10px",handler:function(){a(2)}}]}]},this.form_Support]});b.on("tabchange",function(e,d){if(Ext.getCmp("save-settings-button")){Ext.getCmp("save-settings-button").hide()}if(Ext.getCmp("support-close-button")){Ext.getCmp("support-close-button").setText("Close")}if(Ext.getCmp("send-request-button")){Ext.getCmp("send-request-button").hide()}if(d.getId()=="settings-tab"){Ext.getCmp("save-settings-button").show();Ext.getCmp("support-close-button").setText("Cancel")}else{if(d.getId()=="contact-support-tab"){Ext.getCmp("send-request-button").show()}}});this.window_Support=new Ext.Window({title:"Account",layout:"fit",width:450,height:420,plain:true,modal:true,resizable:false,items:b,closeAction:"hide",buttons:[{id:"save-settings-button",hidden:true,text:"OK",handler:function(){this.form_Settings_Submit()},scope:this},{id:"send-request-button",hidden:true,text:"&nbsp;&nbsp;Send Support Request&nbsp;&nbsp;",handler:function(){this.form_Support_Submit()},scope:this},{id:"support-close-button",text:"Close",handler:function(){this.window_Support.hide()},scope:this}]})}this.window_Support.show()},form_Settings_Submit:function(){STDL.gui.showProgressBar("Saving settings...");STDL.data.submit(this.form_Settings.getForm(),{url:"app/settings",success:function(a,b){Ext.MessageBox.hide();this.window_Support.hide();var c=Ext.Msg.buttonText.ok;Ext.Msg.buttonText.ok="&nbsp;&nbsp;Restart Now&nbsp;&nbsp;";STDL.gui.Msg.show({title:"Account",msg:"This change will take effect at the next logon. Would you like to restart Swift To-Do List Online now?",buttons:Ext.Msg.OKCANCEL,fn:function(d){if(d=="ok"){STDL.gui.showProgressBar("Restarting application...");location.reload(true)}},icon:Ext.MessageBox.QUESTION});Ext.Msg.buttonText.ok=c},scope:this})},form_Support_Submit:function(){if(!this.textfield_Email.isValid()){Ext.MessageBox.alert("Support Request","Please specify your e-mail.");return}if(!this.textarea_Message.isValid()){Ext.MessageBox.alert("Support Request","Please specify the message.");return}var a={};Ext.apply(a,Session.authParams());STDL.gui.showProgressBar(_SendingRequest,"");this.form_Support.getForm().submit({url:STDL.config.serverAddress+"users/support_request",params:a,success:function(b,c){Ext.MessageBox.hide();Ext.MessageBox.alert("Support Request","Your message has been sent to our tech support stuff.<br />We will review it as soon as possible.");this.form_Support.getForm().reset();this.window_Support.hide()},failure:function(b,c){Ext.MessageBox.alert("Error",c.result.message)},scope:this})}});Application=STDL.extend(STDL.emptyFn,{filterValues:{},demoReminderPeriod:600000,selectRow:null,forceSelectRow:false,allowGridUpdate:true,selectNode:null,blankNotes:[""," ","&nbsp;","<br>","<P>&nbsp;</P>","<p>&nbsp;</p>","<BR>"],constructor:function(){},lookupAccount:function(){var a=STDL.getCid("cid");if(!a){this.unknownAccount();return}Session.setParameter("cid",a);STDL.data.request({url:"default/index",params:{cid:a},success:this.login,failure:this.unknownAccount,scope:this},true)},unknownAccount:function(){var b='<div class="unknown-account">The account you are looking for doesn\'t exist or has expired.</div>';var a=new Ext.Panel({border:false,html:b,bodyStyle:"padding: 10px"});STDL.gui.showWindow({id:"account-failure-window",title:"Account doesn't exist",closeable:false,layout:"fit",width:260,height:100,items:a});STDL.get("loading-msg-container").remove()},login:function(a,b){var d=Ext.util.JSON.decode(a.responseText);for(var c in d){Session.setParameter(c,d[c])}if(Session.getParameter("autologin")){STDL.actions.Login.autoLogin(Session.getParameter("autologin"))}else{if(Session.getParameter("pass")){STDL.actions.Login.autoLogin(null,true)}else{this.showLoginBox()}}},showLoginBox:function(){if(!this.loginWindow){STDL.gui.panels.login=new STDL.gui.LoginForm();this.loginWindow=STDL.gui.showWindow({id:"login-window",title:Session.getParameter("cid")+" - Swift To-Do List Online",layout:"fit",closable:false,width:380,height:260,items:STDL.gui.panels.login,buttons:[{text:"Login",handler:STDL.actions.Login.tryLogin}]})}else{STDL.gui.showWindow("login-window")}STDL.gui.focus(Ext.getCmp("username"))},loginSuccess:function(a,b){document.getElementById("progress-text").innerHTML="Initializing...";STDL.gui.Msg.hide();STDL.gui.closeWindow("login-window");Session.initConfig(b.result);this.startApplication()},autoLoginSuccess:function(a,b){document.getElementById("progress-text").innerHTML="Initializing...";STDL.gui.Msg.hide();Session.initConfig(Ext.util.JSON.decode(a.responseText));this.startApplication()},autoLoginOff:function(){this.cookies.clear("username");this.cookies.clear("password")},startApplication:function(){var a=new Ext.ux.HttpProvider({url:STDL.config.serverAddress+"app/state",user:Session.getId(),session:"session",id:"1",readBaseParams:Ext.apply({cmd:"readState"},Session.authParams()),saveBaseParams:Ext.apply({cmd:"saveState"},Session.authParams()),autoRead:false});Ext.state.Manager.setProvider(a);Ext.state.Manager.getProvider().initState(Session.getState());if(!Session.date_format){Session.setParameter("date_format",STDL.config.Date.Default)}this.initData();this.initGui()},initData:function(){STDL.data.statuses=new STDL.data.SimpleStore();STDL.data.statuses.loadFromConfig(Session.item_statuses);STDL.data.date_formats=new STDL.data.SimpleStore();STDL.data.date_formats.loadFromConfig(STDL.config.Date.Formats);STDL.data.tasks={};var a={groupBy:this.getGroupField(),params:{"filter[99][field]":"assigned_to","filter[99][data][value]":Session.getId()}};STDL.data.tasks[STDL.config.TabId.Overview]=new STDL.data.TaskGroupingStore(a);STDL.data.tasks[STDL.config.TabId.Default]=new STDL.data.TaskStore()},initGui:function(){STDL.windows=new Windows();this.taskPriority();this.initHeader();this.initTreePanel();this.initGridPanel();this.applyLayout();this.applyRole();STDL.get("user-info-name").update(Session.getName());STDL.get("account-name").update(Session.getAccountName())},taskPriority:function(){STDL.data.TaskPriority=[];for(var a=0;a<STDL.config.Task.Priority.length;a++){STDL.data.TaskPriority.push([STDL.config.Task.Priority[a],_TaskPriority[STDL.config.Task.Priority[a]]])}},initHeader:function(){STDL.gui.header=new STDL.gui.HeaderPanel()},initTreePanel:function(){STDL.gui.tree=new STDL.gui.ListTree();STDL.gui.info=new STDL.gui.InfoPanel();STDL.gui.left=new STDL.gui.LeftPanel()},initGridPanel:function(){STDL.gui.grids={};STDL.gui.grids[STDL.config.TabId.Overview]=new STDL.gui.TaskGrid({store:STDL.data.tasks[STDL.config.TabId.Overview],tasksOverview:true,id:"tasks-overview-grid"});STDL.gui.grids[STDL.config.TabId.Default]=new STDL.gui.TaskGrid({store:STDL.data.tasks[STDL.config.TabId.Default],id:"tasks-grid"});STDL.gui.attachments=new STDL.gui.AttachmentGrid();STDL.gui.center=new STDL.gui.CenterPanel()},applyLayout:function(){this.viewport=new Ext.Viewport({layout:"border",listeners:{afterlayout:function(){this.hideLoadingMask()},scope:this},items:[STDL.gui.header,STDL.gui.left,STDL.gui.center]});Session.updateTaskNumber(0)},applyRole:function(){if(Session.getRole()==STDL.config.Roles.ADMIN||Session.getRole()==STDL.config.Roles.SUPERUSER){STDL.getCmp("button-add-root-node").show()}if(Session.getRole()==STDL.config.Roles.ADMIN){STDL.getCmp("button-settings").show();STDL.getCmp("button-people").show()}},hideLoadingMask:function(){if(STDL.get("loading-mask")){var a=this;setTimeout(function(){STDL.get("loading-mask").fadeOut({remove:true});a.appLoaded()},1000)}},appLoaded:function(){Ext.getBody().on("unload",STDL.actions.App.close);if(Session.is_demo){var a="<b>Welcome to our public Live Demo!</b><br /><br />";a+="Feel free to test our application but keep in mind that this is a <b>public</b> live demo<br />";a+="so anyone else may be using it right now too.<br /><br />";a+="You can add to-do lists and tasks and use all advanced features but some functions<br />";a+="such as reminders or notifications are turned off in this live demo application.<br /><br />";a+='Our <a href="javascript:STDL.application.showWizard()">Quick Overview Wizard</a> will help you understand how to-do lists, tasks and <br />users work.<br /><br />';a+='Should you have any questions, please contact us at <a href="mailto:support@swifttodolist.com">support@swifttodolist.com</a>.';STDL.gui.Msg.alert("Swift To-Do List Online",a,this.startDemoReminder,this)}else{if(Session.subscralert==1){this.showSubscrAlert(false,Session.subscralertdays);return}else{if(Session.subscralert==2){this.showSubscrAlert(true);return}}if(!Session.user.last_login){this.showWizard()}}},showSubscrAlert:function(c,e){var d=Session.subscr.site_id;if(c){var b='We are migrating all Swift To-Do List Online accounts from PayPal to a new e-commerce provider (Dextronet at BMT-Micro).<br><br>What this means for you:<br><br><b>1. We cancelled your PayPal subscription.</b><br><br><b>2. You need to sign-up for a new subscription with BMT Micro using the following link:<br><br><a href="http://www.swifttodolist.com/s/'+d+'">http://www.swifttodolist.com/s/'+d+'</a></b><br><br>Once you sign-up for the new subscription, you can continue using your account.<br><br>Sorry for the hassle!<br>If you have any questions, just email us at <a href="mailto:support@swifttodolist.com">support@swifttodolist.com</a>.'}else{var b="We are migrating all Swift To-Do List Online accounts from PayPal to a new e-commerce provider (Dextronet at BMT-Micro).<br><br>What this means for you:<br><br><b>1. We cancelled your PayPal subscription.</b><br><br><b>2. You need to sign-up for a new subscription with BMT Micro using the following link, in no more than "+e+' day(s) from today:<br><br><a href="http://www.swifttodolist.com/s/'+d+'">http://www.swifttodolist.com/s/'+d+'</a></b><br><br>Sorry for the hassle!<br>If you have any questions, just email us at <a href="mailto:support@swifttodolist.com">support@swifttodolist.com</a>.'}var a={title:"This account needs your attention!",layout:"fit",width:450,closable:false,modal:true,items:{bodyStyle:"font-size: 110%; padding: 10px",html:b}};if(!c){a.closable=true;a.buttons=[{text:"Close",handler:function(){this.sawin.close()},scope:this}]}this.sawin=STDL.gui.showWindow(a)},showWizard:function(){STDL.gui.panels.wizard=STDL.gui.WizardCard();function a(e){var b=this.getLayout();var c=b.activeItem.id.split("step-")[1];var d=parseInt(c)+e-1;if((Session.getRole()!=STDL.config.Roles.ADMIN||Session.isPersonal())&&d==3){d=d+e}b.setActiveItem(d);Ext.getCmp("step-prev").setDisabled(d==0);Ext.getCmp("step-next").setDisabled(d==4)}this.wizardWindow=STDL.gui.showWindow({id:"wizard-window",title:"Welcome to Swift To-Do List Online",layout:"fit",width:660,height:530,items:STDL.gui.panels.wizard,buttons:[{text:"Close",handler:function(){this.wizardWindow.close()},scope:this,minWidth:90},{id:"step-prev",text:"&laquo; Previous",handler:a.createDelegate(STDL.gui.panels.wizard,[-1]),disabled:true,minWidth:90},{id:"step-next",text:"Next &raquo;",handler:a.createDelegate(STDL.gui.panels.wizard,[1]),minWidth:90}],listeners:{render:function(d){var b=d.footer.child(".x-panel-btns tr:first");Ext.DomHelper.insertAfter(b.dom.childNodes[0],{tag:"td",style:"width: 100%;"})}}})},startDemoReminder:function(){this.demoReminder=new Ext.util.TaskRunner();this.demoReminderTask={run:function(){var a="This is just a reminder that you are using a public live demo application.<br /><br />";a+='You can get your own account at <a href="http://www.swifttodolist.com/signup">http://www.swifttodolist.com/signup</a>.';STDL.gui.Msg.alert("Swift To-Do List Online",a,function(){this.startDemoReminder()},this);this.demoReminder.stop(this.demoReminderTask)},interval:this.demoReminderPeriod,scope:this};this.demoReminder.start.defer(this.demoReminderPeriod,this,[this.demoReminderTask])},reloadFilters:function(){STDL.gui.grids[STDL.config.TabId.Overview].reloadFilterOptions();STDL.gui.grids[STDL.config.TabId.Default].reloadFilterOptions()},getFilterOptions:function(c){var a={};if(this.filterValues[c]){for(var b in this.filterValues[c]){if(this.filterValues[c][b].enabled){a["taskfilter[comp]["+b+"]"]=this.filterValues[c][b].comp;a["taskfilter[value]["+b+"]"]=this.filterValues[c][b].value}}}return a},getStateProvider:function(){return Ext.state.Manager.getProvider()},getGroupField:function(){var a=this.getStateProvider();var b=a.get("group-field");return typeof b=="undefined"?STDL.config.Task.GroupBy:b},getTreeExpanded:function(){var a=this.getStateProvider();var b=a.get("tree-expanded");return typeof b=="undefined"?true:b},task_IsDone:function(a){return STDL.config.Task.Status.T_CLOSED.indexOf(a.get("status_id"))>=0},tree_SelectedNode:function(){return STDL.gui.tree.getSelectionModel().getSelectedNode()},grid_SelectedIndex:function(){var a=this.grid_SelectedRow();return a?a.store.indexOf(a):null},grid_SelectedRow:function(){var a=STDL.gui.grids[STDL.application.currentTabId].getSelectionModel();return a.hasSelection()?a.getSelected():null}});Ext.onReady(function(){Ext.QuickTips.init();STDL.application=new Application();STDL.application.lookupAccount()});
