Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r7184]: branches / groupoffice-3.7 / www / modules / calendar / all-module-scripts-min Maximize Restore History

Download this file

all-module-scripts-min    1 lines (1 with data), 190.3 kB

GO.calendar.EventTemplate='{[this.collapsibleSectionHeader(GO.calendar.lang.forthcomingAppointments, "events-"+values.panelId, "events")]}<tpl if="values.events"><table class="display-panel" cellpadding="0" cellspacing="0" border="0" id="events-{panelId}"><tr><td class="table_header_links" width="16px;"></td><td class="table_header_links" width="10px;"></td><td class="table_header_links">'+GO.lang.strName+'</a></td><td class="table_header_links" width="110px">'+GO.calendar.lang.startsAt+'</td><td class="table_header_links" width="120px">'+GO.calendar.lang.calendar+'</td></tr><tpl if="!events.length"><tr><td colspan="4">'+GO.lang.strNoItems+'</td></tr></tpl><tpl for="events"><tr class="display-panel-link"><td style="padding-right:0px !important;"><div class="display-panel-link-icon go-link-icon-1"></div></td><td style="padding-right:0px !important;padding-left:0px !important;"><div class="display-panel-has-links <tpl if="link_count&gt;1">has-links</tpl>"></div></td><td><a href="#" onclick="GO.linkHandlers[1].call(this, {id});">{name}</a></td><td>{start_time}</td><td>{calendar_name}</td></tr></tpl></table></tpl>';GO.calendar.EventDialog=function(c){this.calendar=c;this.buildForm();this.beforeInit();this.goDialogId="event";this.resourceGroupsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"resources"},root:"results",id:"id",totalProperty:"total",fields:["id","resources","name","fields"],remoteSort:true});this.resourceGroupsStore.on("load",function(){this.buildAccordion()},this);var a=[this.propertiesPanel,this.recurrencePanel,this.optionsPanel,this.participantsPanel,this.resourcesPanel];if(GO.customfields&&GO.customfields.types["1"]){for(var b=0;b<GO.customfields.types["1"].panels.length;b++){a.push(GO.customfields.types["1"].panels[b])}}this.tabPanel=new Ext.TabPanel({activeTab:0,deferredRender:false,border:false,anchor:"100% 100%",hideLabel:true,enableTabScroll:true,items:a,defaults:{forceLayout:true}});this.formPanel=new Ext.form.FormPanel({waitMsgTarget:true,url:GO.settings.modules.calendar.url+"json.php",border:false,baseParams:{task:"event"},items:this.tabPanel});this.initWindow();this.addEvents({save:true,show:true});this.win.render(Ext.getBody())};Ext.extend(GO.calendar.EventDialog,Ext.util.Observable,{resources_options:"",beforeInit:function(){},initWindow:function(){var b=function(){this.subjectField.focus()};var a=[this.linkBrowseButton=new Ext.Button({iconCls:"btn-link",cls:"x-btn-text-icon",text:GO.lang.cmdBrowseLinks,disabled:true,handler:function(){if(!GO.linkBrowser){GO.linkBrowser=new GO.LinkBrowser()}GO.linkBrowser.show({link_id:this.event_id,link_type:"1",folder_id:"0"})},scope:this})];if(GO.files){a.push(this.fileBrowseButton=new Ext.Button({iconCls:"btn-files",cls:"x-btn-text-icon",text:GO.files.lang.files,handler:function(){GO.files.openFolder(this.files_folder_id)},scope:this,disabled:true}))}this.win=new GO.Window({layout:"fit",modal:false,tbar:a,resizable:true,collapsible:true,maximizable:true,width:620,height:450,id:"calendar_event_dialog",closeAction:"hide",title:GO.calendar.lang.appointment,items:this.formPanel,focus:b.createDelegate(this),buttons:[{text:GO.lang.cmdOk,handler:function(){this.submitForm(true,{check_conflicts:1})},scope:this},{text:GO.lang.cmdClose,handler:function(){this.win.hide()},scope:this}]})},files_folder_id:0,initCustomFields:function(c){var b,a;if(c>1){b=GO.calendar.groupsStore.getById(c);a=b.get("fields")}else{b=true;a=GO.calendar.defaultGroupFields}if(b){if(a==null){a=""}a=a.split(",");if(GO.customfields&&GO.customfields.types["1"]){this.tabPanel.items.each(function(d){if(d.category_id){var e=a.indexOf("cf_category_"+d.category_id)>-1;if(e){this.tabPanel.unhideTabStripItem(d.id)}else{this.tabPanel.hideTabStripItem(d.id)}}},this)}}if(this.resourceGroupsStore.data.items.length==0||c!="1"){this.tabPanel.hideTabStripItem("resources-panel")}else{this.tabPanel.unhideTabStripItem("resources-panel")}},initialized:false,show:function(c){c=c||{};GO.dialogListeners.apply(this);this.win.show();if(!this.initialized){this.win.getEl().mask(GO.lang.waitMsgLoad);Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:"init_event_window"},callback:function(g,i,f){if(!i){alert(GO.lang.strRequestError)}else{var h=Ext.decode(f.responseText);GO.calendar.groupsStore.loadData(h.groups);this.resourceGroupsStore.loadData(h.resources);if(!GO.calendar.categoriesStore.loaded){GO.calendar.categoriesStore.loadData(h.categories)}this.win.getEl().unmask();this.initialized=true;this.show(c)}},scope:this});return false}if(c.oldDomId){this.oldDomId=c.oldDomId}else{this.oldDomId=false}delete this.link_config;this.formPanel.baseParams.tmp_files=c.tmp_files?Ext.encode(c.tmp_files):"";this.formPanel.form.reset();this.tabPanel.setActiveTab(0);if(!c.event_id){c.event_id=0}this.setEventId(c.event_id);if(c.event_id>0){this.formPanel.load({url:GO.settings.modules.calendar.url+"json.php",waitMsg:GO.lang.waitMsgLoad,success:function(f,g){this.formPanel.form.baseParams.group_id=g.result.data.group_id;this.initCustomFields(g.result.data.group_id);this.changeRepeat(g.result.data.repeat_type);this.setValues(c.values);this.setWritePermission(g.result.data.write_permission);this.selectCalendar.setRemoteText(g.result.data.calendar_name);this.files_folder_id=g.result.data.files_folder_id;if(g.result.data.group_id==1){this.toggleFieldSets(g.result.data.resources_checked)}this.selectCategory.container.up("div.x-form-item").setDisplayed(this.formPanel.form.baseParams.group_id==1);this.numParticipants=g.result.data.num_participants},failure:function(f,g){Ext.Msg.alert(GO.lang.strError,g.result.feedback)},scope:this})}else{if(c.exception_event_id){this.formPanel.load({url:GO.settings.modules.calendar.url+"json.php",params:{event_id:c.exception_event_id},waitMsg:GO.lang.waitMsgLoad,success:function(f,g){this.formPanel.form.baseParams.exception_event_id=c.exception_event_id;this.formPanel.form.baseParams.exceptionDate=c.exceptionDate;this.formPanel.form.findField("repeat_type").setValue(0);this.changeRepeat(0);this.setValues(c.values);this.setWritePermission(g.result.data.write_permission)},failure:function(f,g){Ext.Msg.alert(GO.lang.strError,g.result.feedback)},scope:this})}else{delete this.formPanel.form.baseParams.exception_event_id;delete this.formPanel.form.baseParams.exceptionDate;delete this.formPanel.form.baseParams.group_id;this.setWritePermission(true);c.values=c.values||{};var b=new Date();var d=parseInt(b.format("i"));if(d>45){d="45"}else{if(d>30){d="30"}else{if(d>15){d="15"}else{d="00"}}}if(!c.values.start_date){c.values.start_date=new Date()}if(!c.values.start_time){c.values.start_time=b.format(GO.settings.time_format)}if(!c.values.end_date){c.values.end_date=new Date()}if(!c.values.end_time){c.values.end_time=b.add(Date.HOUR,1).format(GO.settings.time_format)}this.setValues(c.values);var e=1;if(GO.util.empty(c.calendar_id)){c.calendar_id=GO.calendar.defaultCalendar.id;c.calendar_name=GO.calendar.defaultCalendar.name}var a=this.selectCalendar.store.getById(c.calendar_id);if(a){e=a.get("group_id")}this.formPanel.form.baseParams.group_id=e;this.initCustomFields(e);this.selectCategory.container.up("div.x-form-item").setDisplayed(e==1);if(e==1){this.toggleFieldSets()}this.selectCalendar.setValue(c.calendar_id);if(c.calendar_name){this.selectCalendar.setRemoteText(c.calendar_name)}}}if(c&&c.link_config){this.link_config=c.link_config;if(c.link_config.type_id){this.selectLinkField.setValue(c.link_config.type_id);this.selectLinkField.setRemoteText(c.link_config.text);if(this.subjectField.getValue()==""){this.subjectField.setValue(c.link_config.text)}}}this.fireEvent("show",this)},updateResourcePanel:function(){var x={};var w=[];if(this.win.isVisible()){if(GO.customfields&&GO.customfields.types["1"]){for(var q=0;q<this.resourceGroupsStore.data.items.length;q++){var r=this.resourceGroupsStore.data.items[q].data;var f=r.resources;for(var o=0;o<f.length;o++){var s=f[o].id;x["status_"+s]=this.formPanel.form.findField("status_"+s).getValue();var d=this.resourcesPanel.getComponent("group_"+r.id);var t=d.getComponent("resource_"+s);if(!t.collapsed){w.push(s)}for(var n=0;n<r.fields.length;n++){var u=r.fields[n];if(u){for(var h=0;h<GO.customfields.types["1"].panels.length;h++){var e="cf_category_"+GO.customfields.types["1"].panels[h].category_id;if(e==u){var b=GO.customfields.types["1"].panels[h].customfields;for(var g=0;g<b.length;g++){var a="resource_options["+s+"]["+b[g].dataname+"]";var v=this.formPanel.form.findField(a).getValue();x[a]=v}}}}}}}}}this.resourceGroupsStore.load({callback:function(){if(this.win.isVisible()){if(w){this.toggleFieldSets(w)}this.setValues(x);if(this.resourceGroupsStore.data.items.length==0){this.tabPanel.hideTabStripItem("resources-panel");this.tabPanel.setActiveTab(0)}else{this.tabPanel.unhideTabStripItem("resources-panel")}}},scope:this})},toggleFieldSets:function(h){for(var g=0;g<this.resourceGroupsStore.data.items.length;g++){var k=this.resourceGroupsStore.data.items[g].data;var d=k.resources;for(var f=0;f<d.length;f++){var b=this.resourcesPanel.getComponent("group_"+k.id);var a="resource_"+d[f].id;var m=b.getComponent(a);if(h&&(h.indexOf(d[f].id)!=-1)){m.expand()}else{var e=m.getComponent("status_"+d[f].id);e.setValue(GO.calendar.lang.no_status);m.collapse()}}}},setWritePermission:function(a){this.win.buttons[0].setDisabled(!a);this.win.buttons[1].setDisabled(!a)},setValues:function(a){if(a){for(var b in a){var c=this.formPanel.form.findField(b);if(c){c.setValue(a[b])}}}},setEventId:function(a){this.formPanel.form.baseParams.event_id=a;this.event_id=a;this.participantsPanel.setEventId(a);this.selectLinkField.container.up("div.x-form-item").setDisplayed(a==0);this.linkBrowseButton.setDisabled(a<1);if(GO.files){this.fileBrowseButton.setDisabled(a<1)}},setCurrentDate:function(){var b={};var a=new Date();b.start_date=a.format(GO.settings.date_format);b.start_time=a.format(GO.settings.time_format);b.end_date=a.format(GO.settings.date_format);b.end_time=a.add(Date.HOUR,1).format(GO.settings.time_format);this.formPanel.form.setValues(b)},numParticipants:0,submitForm:function(d,a){if(!a){a={}}this.hide=d;var e={task:"save_event",check_conflicts:typeof(a.check_conflicts)!="undefined"?a.check_conflicts:null};if(this.participantsPanel.store.loaded){var c=this.participantsPanel.getGridData();e.participants=Ext.encode(c);this.numParticipants=this.participantsPanel.store.getCount()}if(this.numParticipants>1&&!this.participantsPanel.importCheckbox.getValue()){var b=(this.event_id)?GO.calendar.lang.sendInvitationUpdate:GO.calendar.lang.sendInvitationInitial;e.send_invitation=(confirm(b))?1:0}this.formPanel.form.submit({url:GO.settings.modules.calendar.url+"action.php",params:e,waitMsg:GO.lang.waitMsgSave,success:function(g,i){if(i.result.event_id){this.files_folder_id=i.result.files_folder_id;this.setEventId(i.result.event_id)}var f=this.getStartDate();var j=this.getEndDate();var h={calendar_id:this.selectCalendar.getValue(),event_id:this.event_id,name:Ext.util.Format.htmlEncode(this.subjectField.getValue()),start_time:f.format("Y-m-d H:i"),end_time:j.format("Y-m-d H:i"),startDate:f,endDate:j,description:Ext.util.Format.htmlEncode(GO.util.nl2br(this.formPanel.form.findField("description").getValue()).replace(/\n/g,"")),background:this.formPanel.form.findField("background").getValue(),location:this.formPanel.form.findField("location").getValue(),repeats:this.formPanel.form.findField("repeat_type").getValue()>0,"private":false,exception_event_id:this.formPanel.form.baseParams.exception_event_id,num_participants:this.numParticipants};this.fireEvent("save",h,this.oldDomId);if(this.link_config&&this.link_config.callback){this.link_config.callback.call(this)}if(i.result.feedback){Ext.MessageBox.alert(GO.lang.strError,i.result.feedback)}else{if(d){this.win.hide()}}if(a&&a.callback){a.callback.call(this,this,true)}},failure:function(h,j){if(j.failureType=="client"){var f=GO.lang.strErrorsInForm}else{var f=j.result.feedback}if(f=="Ask permission"){Ext.Msg.show({title:GO.calendar.lang.ignoreConflictsTitle,msg:GO.calendar.lang.ignoreConflictsMsg,buttons:Ext.Msg.YESNO,fn:this.handlePrompt,animEl:"elId",icon:Ext.MessageBox.QUESTION})}else{if(f=="Resource conflict"){f=GO.calendar.lang.resourceConflictMsg;if(a&&a.callback){a.callback.call(this,this,false)}f=f+"<ul>";for(var g in j.result.resources){if(!isNaN(g)){f=f+"<li> - "+j.result.resources[g]+"</li>"}}f=f+"</ul>";Ext.MessageBox.alert(GO.calendar.lang.resourceConflictTitle,f)}else{if(a&&a.callback){a.callback.call(this,this,false)}Ext.MessageBox.alert(GO.lang.strError,f)}}},scope:this})},handlePrompt:function(a){if(a=="yes"){GO.calendar.eventDialog.submitForm(GO.calendar.eventDialog.hide,{check_conflicts:"0"})}},getStartDate:function(){var a=this.startDate.getValue();if(!this.formPanel.form.findField("all_day_event").getValue()){a=Date.parseDate(a.format("Y-m-d")+" "+this.formPanel.form.findField("start_time").getValue(),"Y-m-d "+GO.settings.time_format)}return a},getEndDate:function(){var a=this.endDate.getValue();if(!this.formPanel.form.findField("all_day_event").getValue()){a=Date.parseDate(a.format("Y-m-d")+" "+this.formPanel.form.findField("end_time").getValue(),"Y-m-d "+GO.settings.time_format)}return a},checkDateInput:function(){var b=this.endDate.getValue();var f=this.startDate.getValue();if(f>b){this.endDate.setValue(f)}if(f.getElapsed(b)==0){var a=f.format("Y-m-d")+" "+this.startTime.getValue();var d=Date.parseDate(a,"Y-m-d "+GO.settings.time_format);var c=b.format("Y-m-d")+" "+this.endTime.getValue();var e=Date.parseDate(c,"Y-m-d "+GO.settings.time_format);if(d>=e){this.endTime.setValue(d.add(Date.HOUR,1).format(GO.settings.time_format))}}if(this.repeatType.getValue()>0){if(this.repeatEndDate.getValue()==""){this.repeatForever.setValue(true)}else{if(this.repeatEndDate.getValue()<b){this.repeatEndDate.setValue(b.add(Date.DAY,1))}}}this.participantsPanel.reloadAvailability()},buildForm:function(){this.selectLinkField=new GO.form.SelectLink({});this.subjectField=new Ext.form.TextField({name:"subject",allowBlank:false,fieldLabel:GO.lang.strSubject});this.locationField=new Ext.form.TextField({name:"location",allowBlank:true,fieldLabel:GO.lang.strLocation});this.startDate=new Ext.form.DateField({name:"start_date",width:100,format:GO.settings.date_format,allowBlank:false,listeners:{change:{fn:this.checkDateInput,scope:this}}});this.startTime=new Ext.form.TimeField({increment:15,format:GO.settings.time_format,name:"start_time",width:80,hideLabel:true,autoSelect:true,listeners:{change:{fn:this.checkDateInput,scope:this}}});this.endTime=new Ext.form.TimeField({increment:15,format:GO.settings.time_format,name:"end_time",width:80,hideLabel:true,autoSelect:true,listeners:{change:{fn:this.checkDateInput,scope:this}}});this.endDate=new Ext.form.DateField({name:"end_date",width:100,format:GO.settings.date_format,allowBlank:false,listeners:{change:{fn:this.checkDateInput,scope:this}}});this.allDayCB=new Ext.form.Checkbox({boxLabel:GO.calendar.lang.allDay,name:"all_day_event",checked:false,width:"auto",labelSeparator:"",hideLabel:true});this.allDayCB.on("check",function(g,f){this.startTime.setDisabled(f);this.endTime.setDisabled(f)},this);this.eventStatus=new Ext.form.ComboBox({hiddenName:"status",triggerAction:"all",editable:false,selectOnFocus:true,width:148,forceSelection:true,mode:"local",value:"ACCEPTED",valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:[["NEEDS-ACTION",GO.calendar.lang.needsAction],["ACCEPTED",GO.calendar.lang.accepted],["DECLINED",GO.calendar.lang.declined],["TENTATIVE",GO.calendar.lang.tentative],["DELEGATED",GO.calendar.lang.delegated]]}),listeners:{scope:this,change:function(f,g){if(this.formPanel.form.baseParams.group_id>1){if(g=="ACCEPTED"){this.colorField.setValue("CCFFCC")}else{this.colorField.setValue("FF6666")}}}}});this.busy=new Ext.form.Checkbox({boxLabel:GO.calendar.lang.busy,name:"busy",checked:true,width:"auto",labelSeparator:"",hideLabel:true});this.selectCategory=new GO.form.ComboBoxReset({hiddenName:"category_id",fieldLabel:GO.calendar.lang.category,value:"",valueField:"id",displayField:"name",store:GO.calendar.categoriesStore,mode:"local",triggerAction:"all",emptyText:GO.calendar.lang.selectCategory,editable:false,selectOnFocus:true,forceSelection:true,tpl:'<tpl for="."><div class="x-combo-list-item"><div style="float:left;width:20px;margin-right:5px;background-color:#{color}">&nbsp;</div>{name}</div></tpl>'});this.selectCategory.on("select",function(g,f){this.colorField.setValue(f.data.color)},this);this.propertiesPanel=new Ext.Panel({hideMode:"offsets",title:GO.lang.strProperties,defaults:{anchor:"-20"},bodyStyle:"padding:5px",layout:"form",autoScroll:true,items:[this.subjectField,this.locationField,this.selectLinkField,{xtype:"compositefield",fieldLabel:GO.lang.strStart,items:[this.startDate,this.startTime,this.allDayCB]},{fieldLabel:GO.lang.strEnd,xtype:"compositefield",items:[this.endDate,this.endTime]},{xtype:"compositefield",fieldLabel:GO.calendar.lang.status,items:[this.eventStatus,this.busy]},this.selectCalendar=new GO.calendar.SelectCalendar({anchor:"-20",valueField:"id",displayField:"name",typeAhead:true,triggerAction:"all",editable:false,selectOnFocus:true,forceSelection:true,allowBlank:false}),this.selectCategory,new GO.form.PlainField({fieldLabel:GO.lang.strOwner,value:GO.settings.name,name:"user_name"}),{xtype:"textarea",fieldLabel:GO.lang.strDescription,name:"description",anchor:"-20 -240"}]});var e=new Array();for(var d=1;d<31;d++){e.push([d])}this.repeatEvery=new Ext.form.ComboBox({hiddenName:"repeat_every",triggerAction:"all",editable:false,selectOnFocus:true,width:50,forceSelection:true,mode:"local",value:"1",valueField:"value",displayField:"value",store:new Ext.data.SimpleStore({fields:["value"],data:e})});this.repeatType=new Ext.form.ComboBox({hiddenName:"repeat_type",triggerAction:"all",editable:false,selectOnFocus:true,width:200,forceSelection:true,mode:"local",value:"0",valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:[["0",GO.calendar.lang.noRecurrence],["1",GO.calendar.lang.days],["2",GO.calendar.lang.weeks],["3",GO.calendar.lang.monthsByDate],["4",GO.calendar.lang.monthsByDay],["5",GO.calendar.lang.years]]}),hideLabel:true});this.repeatType.on("select",function(g,f){this.checkDateInput();this.changeRepeat(f.data.value)},this);this.monthTime=new Ext.form.ComboBox({hiddenName:"month_time",triggerAction:"all",selectOnFocus:true,disabled:true,width:80,forceSelection:true,mode:"local",value:"1",valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:[["1",GO.lang.strFirst],["2",GO.lang.strSecond],["3",GO.lang.strThird],["4",GO.lang.strFourth]]})});this.cb=[];for(var a=0;a<7;a++){var c=a+parseInt(GO.settings.first_weekday);if(c==7){c=0}this.cb[c]=new Ext.form.Checkbox({boxLabel:GO.lang.shortDays[c],id:"frm_repeat_days_"+c,name:"repeat_days_"+c,disabled:true,checked:false,width:"auto",hideLabel:true,laelSeperator:""})}this.repeatEndDate=new Ext.form.DateField({name:"repeat_end_date",width:100,disabled:true,format:GO.settings.date_format,allowBlank:true,listeners:{change:{fn:this.checkDateInput,scope:this}}});this.repeatForever=new Ext.form.Checkbox({boxLabel:GO.calendar.lang.repeatForever,name:"repeat_forever",checked:true,disabled:true,width:"auto",hideLabel:true,listeners:{check:{fn:function(f,g){this.repeatEndDate.setDisabled(g)},scope:this}}});this.recurrencePanel=new Ext.Panel({title:GO.calendar.lang.recurrence,bodyStyle:"padding: 5px",layout:"form",hideMode:"offsets",defaults:{forceLayout:true,border:false},items:[{fieldLabel:GO.calendar.lang.repeatEvery,xtype:"compositefield",items:[this.repeatEvery,this.repeatType]},{xtype:"compositefield",fieldLabel:GO.calendar.lang.atDays,items:[this.monthTime,this.cb[1],this.cb[2],this.cb[3],this.cb[4],this.cb[5],this.cb[6],this.cb[0]]},{fieldLabel:GO.calendar.lang.repeatUntil,xtype:"compositefield",items:[this.repeatEndDate,this.repeatForever]}]});var b=[["0",GO.calendar.lang.noReminder]];for(var d=1;d<60;d++){b.push([d,d])}this.reminderValue=new Ext.form.ComboBox({hiddenName:"reminder_value",triggerAction:"all",editable:false,selectOnFocus:true,width:148,forceSelection:true,mode:"local",value:GO.calendar.defaultReminderValue,valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:b})});this.reminderMultiplier=new Ext.form.ComboBox({hiddenName:"reminder_multiplier",triggerAction:"all",editable:false,selectOnFocus:true,width:148,forceSelection:true,mode:"local",value:GO.calendar.defaultReminderMultiplier,valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:[["60",GO.lang.strMinutes],["3600",GO.lang.strHours],["86400",GO.lang.strDays]]}),hideLabel:true,labelSeperator:""});this.participantsPanel=new GO.calendar.ParticipantsPanel(this);this.privateCB=new Ext.form.Checkbox({boxLabel:GO.calendar.lang.privateEvent,name:"private",checked:false,width:"auto",labelSeparator:"",hideLabel:true});this.optionsPanel=new Ext.Panel({layout:"form",title:GO.calendar.lang.options,bodyStyle:"padding:5px",hideMode:"offsets",border:false,items:[{xtype:"compositefield",fieldLabel:GO.calendar.lang.reminder,items:[this.reminderValue,this.reminderMultiplier]},this.colorField=new GO.form.ColorField({fieldLabel:GO.lang.color,value:GO.calendar.defaultBackground,name:"background",colors:["EBF1E2","95C5D3","FFFF99","A68340","82BA80","F0AE67","66FF99","CC0099","CC99FF","996600","999900","FF0000","FF6600","FFFF00","FF9966","FF9900","FF6666","CCFFCC","FB0467","D52A6F","CC3370","C43B72","BB4474","B34D75","AA5577","A25E79","FF00CC","D52AB3","CC33AD","C43BA8","BB44A3","B34D9E","AA5599","A25E94","CC00FF","B32AD5","AD33CC","A83BC4","A344BB","9E4DB3","9955AA","945EA2","6704FB","6E26D9","7033CC","723BC4","7444BB","754DB3","7755AA","795EA2","0404FB","2626D9","3333CC","3B3BC4","4444BB","4D4DB3","5555AA","5E5EA2","0066FF","2A6ED5","3370CC","3B72C4","4474BB","4D75B3","5577AA","5E79A2","00CCFF","2AB2D5","33ADCC","3BA8C4","44A3BB","4D9EB3","5599AA","5E94A2","00FFCC","2AD5B2","33CCAD","3BC4A8","44BBA3","4DB39E","55AA99","5EA294","00FF66","2AD56F","33CC70","3BC472","44BB74","4DB375","55AA77","5EA279","00FF00","2AD52A","33CC33","3BC43B","44BB44","4DB34D","55AA55","5EA25E","66FF00","6ED52A","70CC33","72C43B","74BB44","75B34D","77AA55","79A25E","CCFF00","B2D52A","ADCC33","A8C43B","A3BB44","9EB34D","99AA55","94A25E","FFCC00","D5B32A","CCAD33","C4A83B","BBA344","B39E4D","AA9955","A2945E","FF6600","D56F2A","CC7033","C4723B","BB7444","B3754D","AA7755","A2795E","FB0404","D52A2A","CC3333","C43B3B","BB4444","B34D4D","AA5555","A25E5E","FFFFFF","949494","808080","6B6B6B","545454","404040","292929","000000"]}),this.privateCB]});this.resourcesPanel=new Ext.Panel({id:"resources-panel",title:GO.calendar.lang.resources,border:false,layout:"accordion",forceLayout:true,layoutConfig:{titleCollapse:true,animate:false,activeOnTop:false},defaults:{forceLayout:true}});this.resourcesPanel.on("show",function(){this.tabPanel.doLayout()},this)},buildAccordion:function(){this.resourcesPanel.removeAll(true);this.resourcesPanel.forceLayout=true;var t;for(var o=0;o<this.resourceGroupsStore.getCount();o++){var p=this.resourceGroupsStore.data.items[o].data;var r=[];var e=p.resources;for(var n=0;n<e.length;n++){var d=[];var q=new GO.form.PlainField({id:"status_"+e[n].id,name:"status_"+e[n].id,fieldLabel:GO.calendar.lang.status});d.push(q);this.formPanel.form.add(q);for(var h=0;h<p.fields.length;h++){var s=p.fields[h];if(s&&GO.customfields&&GO.customfields.types["1"]){for(var g=0;g<GO.customfields.types["1"].panels.length;g++){var c="cf_category_"+GO.customfields.types["1"].panels[g].category_id;if(c==s){var b=GO.customfields.types["1"].panels[g].customfields;for(var f=0;f<b.length;f++){t=GO.customfields.getFormField(b[f],{name:"resource_options["+e[n].id+"]["+b[f].dataname+"]",id:"resource_options["+e[n].id+"]["+b[f].dataname+"]"});if(!t.events){t=Ext.ComponentMgr.create(t,"textfield")}d.push(t);this.formPanel.form.add(t)}g=GO.customfields.types["1"].panels.length}}}else{d.push(new GO.form.PlainField({name:"no_fields_"+e[n].id,hideLabel:true,value:GO.calendar.lang.no_custom_fields}))}}r.push({xtype:"fieldset",checkboxToggle:true,checkboxName:"resources["+e[n].id+"]",title:e[n].name,id:"resource_"+e[n].id,autoHeight:true,collapsed:true,forceLayout:true,items:d})}var a=new Ext.Panel({cls:"go-form-panel",id:"group_"+p.id,layout:"form",autoScroll:true,forceLayout:true,title:p.name,items:r});this.resourcesPanel.add(a)}this.tabPanel.doLayout()},changeRepeat:function(d){var c=this.repeatForever.getValue();var a=this.formPanel.form;switch(d){case"0":this.disableDays(true);a.findField("month_time").setDisabled(true);a.findField("repeat_forever").setDisabled(true);a.findField("repeat_end_date").setDisabled(true);a.findField("repeat_every").setDisabled(true);break;case"1":this.disableDays(true);a.findField("month_time").setDisabled(true);a.findField("repeat_forever").setDisabled(false);a.findField("repeat_end_date").setDisabled(c);a.findField("repeat_every").setDisabled(false);break;case"2":this.disableDays(false);a.findField("month_time").setDisabled(true);a.findField("repeat_forever").setDisabled(false);a.findField("repeat_end_date").setDisabled(c);a.findField("repeat_every").setDisabled(false);var b=a.findField("start_date").getValue().getDay();this.formPanel.form.findField("repeat_days_"+b).setValue(true);break;case"3":this.disableDays(true);a.findField("month_time").setDisabled(true);a.findField("repeat_forever").setDisabled(false);a.findField("repeat_end_date").setDisabled(c);a.findField("repeat_every").setDisabled(false);break;case"4":this.disableDays(false);a.findField("month_time").setDisabled(false);a.findField("repeat_forever").setDisabled(false);a.findField("repeat_end_date").setDisabled(c);a.findField("repeat_every").setDisabled(false);break;case"5":this.disableDays(true);a.findField("month_time").setDisabled(true);a.findField("repeat_forever").setDisabled(false);a.findField("repeat_end_date").setDisabled(c);a.findField("repeat_every").setDisabled(false);break}},disableDays:function(b){for(var a=0;a<7;a++){this.formPanel.form.findField("repeat_days_"+a).setDisabled(b)}}});GO.calendar.CalendarEvent=Ext.data.Record.create([{name:"id"},{name:"event_id"},{name:"start_time"},{name:"end_time"},{name:"name"},{name:"description"},{name:"repeats"},{name:"private"},{name:"location"},{name:"background"},{name:"read_only"},{name:"contact_id"},{name:"task_id"},{name:"calendar_name"},{name:"calendar_id"}]);GO.grid.CalendarGrid=Ext.extend(Ext.Panel,{dateFormat:"Y-m-d",dateTimeFormat:"Y-m-d H:i",timeFormat:"H:i",firstWeekday:1,configuredDate:false,startDate:false,dragEvent:false,appointments:Array(),appointmentsMap:{},allDayAppointments:Array(),allDayAppointmentsMap:[],allDayEventRows:0,allDayColumns:Array(),remoteEvents:Array(),domIds:Array(),days:1,scale:96,hourHeight:40,loaded:false,minRows:2,writePermission:false,scrollOffset:19,selected:Array(),nextId:0,periodDisplay:"",initComponent:function(){this.cls="x-calGrid-panel";GO.grid.CalendarGrid.superclass.initComponent.call(this);this.addEvents({create:true,move:true,eventResize:true,eventDblClick:true,deleteEvent:true});if(this.store){this.setStore(this.store,true)}if(!this.startDate){var a=new Date();this.startDate=Date.parseDate(a.format(this.dateFormat),this.dateFormat)}this.configuredDate=this.startDate;this.rowsPerHour=this.scale/24;this.rowHeight=this.hourHeight/this.rowsPerHour},doLayout:function(){GO.grid.CalendarGrid.superclass.doLayout.call(this);if(this.rendered){this.setDate(this.startDate,this.days,false);this.body.setStyle("overflow","hidden");this.body.unselectable();if(this.daysGridRendered){this.cacheGridCells()}this.setStore(this.store)}},renderDaysGrid:function(){this.daysGridRendered=true;this.body.update("");var n=this.container.getSize(true);var l=((n.width-40-this.scrollOffset)/this.days);l=Math.floor(l);this.headingsTable=Ext.DomHelper.append(this.body,{tag:"table",id:Ext.id(),cls:"x-calGrid-headings-table",style:"width:"+(n.width)+"px;"},true);var a=Ext.DomHelper.append(this.headingsTable,{tag:"tbody"},true);this.headingsRow=Ext.DomHelper.append(a,{tag:"tr",children:{tag:"td",style:"width:37px",cls:"x-calGrid-heading"}},true);this.allDayTableContainer=Ext.DomHelper.append(this.body,{tag:"div",cls:"x-calGrid-all-day-table-container"},true);this.allDayTable=Ext.DomHelper.append(this.allDayTableContainer,{tag:"table",id:Ext.id(),cls:"x-calGrid-all-day-table",style:"width:"+(n.width-this.scrollOffset)+"px;"},true);var a=Ext.DomHelper.append(this.allDayTable,{tag:"tbody"},true);this.allDayRow=Ext.DomHelper.append(a,{tag:"tr",children:{tag:"td",style:"width:40px",cls:"x-calGrid-all-day-first-col"}},true);var s=new RegExp(GO.settings.date_separator+"?Y"+GO.settings.date_separator+"?");var u="D "+GO.settings.date_format.replace(s,"");var e=new Date();var t=e.format(u);var q,x,j,p,d;this.allDayColumns=Array();for(var w=0;w<this.days;w++){q=this.startDate.add(Date.DAY,w);x=q.format(u);d=x==t?"x-calGrid-heading x-calGrid-heading-today":"x-calGrid-heading";j=Ext.DomHelper.append(this.headingsRow,{tag:"td",children:[{tag:"div",cls:d,style:"width:"+(l-3)+"px",html:q.format(u)}]});p=Ext.DomHelper.append(this.allDayRow,{tag:"td",id:"all_day_"+w,cls:"x-calGrid-all-day-container",style:"width:"+(l-3)+"px;height:0px"},true);this.allDayColumns.push(p)}Ext.DomHelper.append(this.headingsRow,{tag:"td",style:"width:"+(this.scrollOffset)+"px;height:0px",cls:"x-calGrid-heading"});this.gridContainer=Ext.DomHelper.append(this.body,{tag:"div",cls:"x-calGrid-grid-container"},true);var o=this.headingsTable.getHeight();this.gridTable=Ext.DomHelper.append(this.gridContainer,{tag:"table",id:Ext.id(),cls:"x-calGrid-table",style:"width:"+n.width-this.scrollWidth+"px;"},true);this.tbody=Ext.DomHelper.append(this.gridTable,{tag:"tbody"},true);this.gridTable.on("mousedown",this.startSelection,this);this.gridContainer.on("mousemove",this.onEventDragMouseMove,this);this.body.on("mouseup",this.onEventDragMouseUp,this);this.allDayTable.on("mousemove",this.onAllDayEventDragMouseMove,this);this.body.on("mouseup",this.onAllDayEventDragMouseUp,this);var g=Ext.DomHelper.append(this.tbody,{tag:"tr"});var k=Ext.DomHelper.append(g,{tag:"td",style:"width:40px"},true);var h;var c=(((this.rowHeight+1)*this.rowsPerHour)-1);for(var v=0;v<this.scale;v+=this.rowsPerHour){h=GO.settings.time_format.substr(0,1)=="G"?"G:i":"g a";Ext.DomHelper.append(k,{tag:"div",id:"head"+v,cls:"x-calGrid-timeHead",html:Date.parseDate(v/this.rowsPerHour,"G").format(h),style:"width:40px;height:"+c+"px"},true)}this.gridCells=[];var m,f,b;var y=Ext.isIE6?'<p style="line-height:0px;"></p>':"";for(var w=0;w<this.days;w++){this.gridCells[w]=[];m=Ext.DomHelper.append(g,{tag:"td",id:"dayCol"+w,style:"width:"+l+"px"},true);f="x-calGrid-hourRow";var r=0;for(var v=0;v<this.scale;v++){if(r==0){f="x-calGrid-hourRow"}else{if(this.rowsPerHour/r==2){f="x-calGrid-halfhourRow"}else{f="x-calGrid-blankRow"}}b=Ext.DomHelper.append(m,{tag:"div",id:"day"+w+"_row"+v,cls:f,style:"height:"+(this.rowHeight)+"px;",html:y},true);this.gridCells[w].push(b);r++;if(r==this.rowsPerHour){r=0}}}this.gridX=0;this.gridY=0;this.gridContainer.on("scroll",this.storeScrollPosition,this);this.daysRendered=this.days;this.selector=Ext.DomHelper.append(this.body,{tag:"div",id:Ext.id(),cls:"x-calGrid-selector"},true);this.cacheGridCells();this.gridTableHeight=this.gridTable.getHeight()},cacheGridCells:function(){this.gridTable.xy=this.gridTable.getXY();var a=this.gridTable.getY();var b=this.gridCells[0][0].getSize();var k=this.gridCells[0][0].getXY();var j=k[0];var g=k[1]-a;for(var h=0;h<this.days;h++){var d=j+(h*b.width);for(var f=0;f<this.scale;f++){var c=g+(f*b.height);if(this.gridCells[h]){this.gridCells[h][f].xy=[d,c];this.gridCells[h][f].size=b}else{}}}var e=this.gridCells[0][0];this.snapCol={x:e.size["width"],y:e.size["height"]}},autoSizeGrid:function(){var b=this.ownerCt.body.getHeight();var d=this.headingsTable.getHeight();var c=this.allDayTableContainer.getHeight();if(c>(b/2)){c=b/2;this.allDayTableContainer.setHeight(c)}var a=b-d-c-2;this.gridContainer.setHeight(a)},onResize:function(d,b,a,c){if(this.loaded&&this.daysRendered==this.days){if(d!=this.headingsTable.getWidth()){this.load()}else{if(b!=this.getHeight()){this.autoSizeGrid()}}}},getFirstDateOfWeek:function(a){var b=a.getDay();var c=this.firstWeekday-b;if(c>0){c-=7}return a.add(Date.DAY,c)},mask:function(){if(this.rendered){this.body.mask(GO.lang.waitMsgLoad,"x-mask-loading")}},unmask:function(){if(this.rendered){this.body.unmask()}},getSnap:function(){return this.snapCol},getGridXY:function(){var a=Ext.get("day0_row0");return a.getXY()},getRowIdByXY:function(b,e){var a=this.getSnap();var c=(b-this.gridX)/a.x;var d=(e-this.gridY)/a.y;return"day"+c+"_row"+d},getRowNumberByY:function(c){var a=this.getSnap();var b=this.gridTable.getXY();return Math.floor((c-b[1])/a.y)},getDayByX:function(b){var a=this.getSnap();var c=this.gridTable.getXY();return Math.floor((b-c[0]-40)/a.x)},startSelection:function(d){if(this.writePermission&&!this.dragEvent&&(d.button=="0")){var c=d.getXY();this.clickedDay=this.getDayByX(c[0]);this.clickedRow=this.getRowNumberByY(c[1]);this.dragSnap=this.getSnap();if(this.clickedDay>-1){this.selectorStartRow=this.gridCells[this.clickedDay][this.clickedRow];if(this.selectorStartRow){var b=this.gridTable.getY();var a=[this.selectorStartRow.xy[0],this.selectorStartRow.xy[1]+b];if(!this.overlay){this.overlay=this.body.createProxy({tag:"div",cls:"x-resizable-overlay",html:"&#160;"});this.overlay.unselectable();this.overlay.enableDisplayMode("block");this.overlay.on("mousemove",this.onSelectionMouseMove,this);this.overlay.on("mouseup",this.onSelectionMouseUp,this)}this.overlay.setSize(Ext.lib.Dom.getViewWidth(true),Ext.lib.Dom.getViewHeight(true));this.overlay.show();this.selector.setXY(a);this.selector.setSize(this.snapCol.x-3,this.snapCol.y);this.selector.setVisible(true,false)}}}},onSelectionMouseMove:function(c){var d=c.getXY();var b=this.selector.getXY();var a=this.snap(d[1]-b[1],this.dragSnap.y,0);this.selector.setHeight(a)},onSelectionMouseUp:function(a){this.overlay.hide();this.fireEvent("create",this,this.domToTimes(this.selector.id));this.clearSelection()},showContextMenu:function(b,a){if(!this.contextMenu){this.contextMenu=new GO.calendar.ContextMenu();this.contextMenu.on("deleteEvent",function(){this.fireEvent("deleteEvent",this)},this);this.contextMenu.on("updateEvent",function(h,d){var f=h.event;var c=false;var j=Ext.decode(this.store.baseParams.calendars);for(var e=0;e<j.length&&!c;e++){if(j[e]==f.calendar_id){c=true}}if(h.isCopy){if(c){if(f.repeats){this.store.reload()}else{var g=GO.util.clone(f);delete (g.id);g.event_id=d;g.startDate=Date.parseDate(g.start_time,this.dateTimeFormat).add(Date.DAY,h.offset);g.endDate=Date.parseDate(g.end_time,this.dateTimeFormat).add(Date.DAY,h.offset);g.start_time=g.startDate.format(this.dateTimeFormat);g.end_time=g.endDate.format(this.dateTimeFormat);this.addDaysGridEvent(g,true)}}}else{if(h.repeats){this.store.reload()}else{this.removeEvent(f.domId);delete f.domId;if(c){f.startDate=Date.parseDate(f.start_time,this.dateTimeFormat).add(Date.DAY,h.offset);f.endDate=Date.parseDate(f.end_time,this.dateTimeFormat).add(Date.DAY,h.offset);f.start_time=f.startDate.format(this.dateTimeFormat);f.end_time=f.endDate.format(this.dateTimeFormat);this.addDaysGridEvent(f,true)}}}},this)}b.stopEvent();this.contextMenu.setEvent(a);this.contextMenu.showAt(b.getXY())},getDayIndex:function(a){},addDaysGridEvent:function(f,b){if(f.id==undefined){f.id=this.nextId++}var k=Date.parseDate(f.startDate.format("Ymd"),"Ymd");var t=Date.parseDate(f.endDate.format("Ymd"),"Ymd");var d=this.startDate.format("U");var h=k.format("U");var q,e,g;q=Math.round((h-d)/86400);var s=t.format("U");e=Math.round((s-d)/86400);if(q<this.days&&e>-1){var a=f.startDate.getHours()*this.rowsPerHour;var o=f.endDate.getHours()*this.rowsPerHour-1;var r=60/this.rowsPerHour;var l=f.startDate.getMinutes();a+=Math.ceil(l/r);var c=f.endDate.getMinutes();o+=Math.ceil(c/r);var m=a+this.minRows-1;if(o<m&&q==e){o=m}var u=[];for(var p=q;p<=e;p++){if(p>-1&&p<this.days){if((a||o<(this.rowsPerHour*24-1))&&(a&&p==q||o&&p==e)){f.noResize=p!=e;var j=p==e?o:this.rowsPerHour*24;var n=p==q?a:0;if(j>-1){u.push(this.addGridEvent(f,p,n,j,b))}}else{u.push(this.addAllDayEvent(f,p,p))}}}}return u},getSelectedEvent:function(){if(this.selected&&this.selected.length>0){return this.elementToEvent(this.selected[0].id)}},isSelected:function(a){for(var b=0;b<this.selected.length;b++){if(this.selected[b].id==a){return true}}return false},clearEventSelection:function(){for(var a=0;a<this.selected.length;a++){this.selected[a].removeClass("x-calGrid-selected")}this.selected=[]},selectEventElement:function(a){if(!this.isSelected(a)){this.clearEventSelection();var d=this.getRelatedDomElements(a.id);for(var c=0;c<d.length;c++){var b=Ext.get(d[c]);b.addClass("x-calGrid-selected");this.selected.push(b)}}},removeEvent:function(c,g){if(this.remoteEvents[c]){var l=this.remoteEvents[c].event_id;var f=this.store.findBy(function(i){return i.data.event_id==l});var e=this.store.getAt(f);this.store.remove(e);var k=[];var a=this.getRelatedDomElements(c);if(a){for(var d=0;d<a.length;d++){var b=Ext.get(a[d]);if(b){b.removeAllListeners();b.remove()}if(this.appointmentsMap[a[d]]){var j=this.appointmentsMap[a[d]].day;if(k.indexOf(j,k)==-1){k.push(j)}}this.unregisterDomId(a[d])}}if(!g){for(var d=0,h=k.length;d<h;d++){this.calculateAppointments(k[d])}}}},unregisterDomId:function(f){if(this.appointmentsMap[f]&&this.appointments[this.appointmentsMap[f].day]){var a=this.appointmentsMap[f].day;var g=[];for(var b=0;b<this.appointments[a].length;b++){if(this.appointments[a][b].id!=f){g.push(this.appointments[a][b])}}this.appointments[a]=g}else{if(this.allDayAppointmentsMap[f]&&this.appointments[this.allDayAppointmentsMap[f].day]){var a=this.allDayAppointmentsMap[f];var g=[];for(var b=0;b<this.appointments[a].length;b++){if(this.appointments[a][b].id!=f){g.push(this.appointments[a][b])}}this.allDayAppointmentsMap[a]=g}}delete this.remoteEvents[f];delete this.appointmentsMap[f];var c=false;for(var d in this.domIds){for(var b=0;b<this.domIds[d].length;b++){if(this.domIds[d][b]==f){this.domIds[d].splice(b,1);c=true;break}}if(c){break}}},addAllDayEvent:function(g,e,b){g.allDay=true;g.daySpan=b-e+1;if(e<0){e=0}if(b>this.days-1){b=this.days-1}var h="";if(e!=b){var f=GO.settings.date_format+" "+GO.settings.time_format;h=g.startDate.format(f)+"&nbsp;"+g.name}else{h=g.name}for(var d=e;d<=b;d++){var c=this.lastDomId=g.domId=Ext.id();this.registerEvent(c,g);var j="x-calGrid-all-day-event-container";if(g.link_count>0){j+=" cal-has-links"}var a=Ext.DomHelper.append(this.allDayColumns[d],{tag:"div",id:c,cls:j,style:"background-color:#"+g.background,html:h,qtip:GO.calendar.formatQtip(g),qtitle:g.name,tabindex:0},true);if(typeof(this.allDayAppointments[d])=="undefined"){this.allDayAppointments[d]=Array()}this.allDayAppointments[d].push(a);this.allDayAppointmentsMap[c]=d;if(!g.read_only){a.on("mousedown",function(k,i){i=Ext.get(i).findParent("div.x-calGrid-all-day-event-container",2,true);this.selectEventElement(i);this.clickedEventId=i.id;this.eventMouseUp=false;this.startAllDayEventDrag(k,i.id)},this)}a.on("dblclick",function(m,i){i=Ext.get(i).findParent("div.x-calGrid-all-day-event-container",2,true);this.clickedEventId=i.id;var k={};var l=this.elementToEvent(this.clickedEventId);if(this.remoteEvents[this.clickedEventId]["repeats"]&&this.writePermission){this.handleRecurringEvent("eventDblClick",l,k)}else{this.fireEvent("eventDblClick",this,l,k)}},this);if(!g.read_only){a.on("mouseup",function(){this.eventMouseUp=true},this)}}return c},addGridEvent:function(l,j,m,h,b){var o='<span class="x-calGrid-event-time';if(l.link_count>0){o+=" cal-has-links"}o+='">'+l.startDate.format(GO.settings.time_format)+"</span>&nbsp;"+l.name;if(l.location!=""){o+=" @ "+l.location}var e=this.lastDomId=l.domId=Ext.id();this.registerEvent(e,l);var f=this.getSnap();if(h>(this.scale-1)){h=this.scale-1}var a=this.gridContainer.insertFirst({tag:"div",id:e,cls:"x-calGrid-event-container",style:"background-color:#"+l.background,qtip:GO.calendar.formatQtip(l),qtitle:l.name,html:o,tabindex:0});a.repeats=l.repeats;var i=Ext.get("day"+j+"_row"+m);var c=Ext.get("day"+j+"_row"+h);var d=i.getXY();var g=c.getXY();var n=g[1]-d[1]+f.y;a.setXY(d);a.setSize(f.x-2,n);if(!l.read_only){a.on("mousedown",function(q,p){p=Ext.get(p).findParent("div.x-calGrid-event-container",4,true);this.selectEventElement(p);this.clickedEventId=p.id;this.eventMouseUp=false;this.startEventDrag(q,p.id)},this);a.on("mouseup",function(){this.eventMouseUp=true},this)}else{a.on("mousedown",function(q,p){p=Ext.get(p).findParent("div.x-calGrid-event-container",4,true);this.selectEventElement(p);this.clickedEventId=p.id},this)}a.on("dblclick",function(s,p){var q={};var r=this.elementToEvent(this.clickedEventId);if(this.remoteEvents[this.clickedEventId]["repeats"]&&this.writePermission){this.handleRecurringEvent("eventDblClick",r,q)}else{this.fireEvent("eventDblClick",this,r,q)}},this);a.on("contextmenu",function(r,p){var q=this.elementToEvent(this.clickedEventId);this.showContextMenu(r,q)},this);if(typeof(this.appointments[j])=="undefined"){this.appointments[j]=Array()}this.appointments[j].push(a);this.appointmentsMap[e]={day:j};if(!l.read_only&&!l["private"]&&!l.noResize){var k=new Ext.Resizable(a,{handles:"s",minHeight:f.y,maxWidth:a.getWidth(),heightIncrement:f.y,draggable:false,pinned:true});k.on("resize",function(r,t,x,y,u){if(x>0){var q=this.domToTimes(r.el.id,false);var w=q.endDate.format("U");var z={end_time:w,dragDate:this.remoteEvents[r.el.id].startDate};var p=this.elementToEvent(r.el.id);this.remoteEvents[r.el.id].endDate=q.endDate;var v=r.el.getX();this.clickedDay=this.getDayByX(v);if(this.remoteEvents[r.el.id]["repeats"]){p.day=this.clickedDay;this.handleRecurringEvent("eventResize",p,z)}else{this.resizeAppointment(r.el.id,this.clickedDay);this.fireEvent("eventResize",this,p,z)}var s=r.el.select("span.x-calGrid-event-time");if(s){s.update(p.startDate.format(GO.settings.time_format));r.el.set({"ext:qtip":GO.calendar.formatQtip(p)})}}},this)}if(b){this.calculateAppointments(j)}return e},resizeAppointment:function(c,a){var b=this.findAppointment(a,c);this.appointments[a][b].size=this.appointments[a][b].getSize();this.remoteEvents[c].repeats=false;this.calculateAppointments(a)},calculateAppointments:function(p){if(typeof(this.appointments[p])!="undefined"){var l=this.getSnap();var r=this.gridTable.getY();var j=0;var f=Array();this.appointments[p].sort(function(n,i){return n.getY()-i.getY()});var h=0;this.rows=Array();for(var g=0;g<this.scale;g++){var c=this.gridCells[p][g];var u=c.xy[1];if(g==0){h=c.xy[0]}if(typeof(this.rows[g])=="undefined"){this.rows[g]=Array()}for(var q=0;q<this.appointments[p].length;q++){if(!this.appointments[p][q].xy){this.appointments[p][q].xy=this.appointments[p][q].getXY();this.appointments[p][q].xy[1]-=r}if(!this.appointments[p][q].size){this.appointments[p][q].size=this.appointments[p][q].getSize()}var s=this.appointments[p][q].xy;var e=this.appointments[p][q].size;if((c.xy[0]+c.size.width)>=s[0]&&c.xy[0]<=s[0]+e.width&&u+c.size.height<=s[1]+e.height&&u+c.size.height>s[1]){if(typeof(f[this.appointments[p][q].id])=="undefined"){var t=0;while(typeof(this.rows[g][t])!="undefined"){t++}var d=g;for(var m=u;m<s[1]+e.height-3;m+=l.y){if(typeof(this.rows[d])=="undefined"){this.rows[d]=Array()}this.rows[d][t]=this.appointments[p][q].id;d++}this.rows[g][t]=this.appointments[p][q].id;f[this.appointments[p][q].id]=t}}}if(t>j){j=t}}var b=l.x/(j+1);for(var q=0;q<this.appointments[p].length;q++){if(!this.appointments[p][q].xy){this.appointments[p][q].xy=this.appointments[p][q].getXY();this.appointments[p][q].xy[1]-=r}if(!this.appointments[p][q].size){this.appointments[p][q].size=this.appointments[p][q].getSize()}var s=this.appointments[p][q].xy;var e=this.appointments[p][q].size;var g=Math.floor(s[1]/l.y);var o=(e.height-2)/l.y;var k=this.getEventWidth(f[this.appointments[p][q].id],j,g,o,b);this.appointments[p][q].setWidth(k);var a=f[this.appointments[p][q].id]*b;this.appointments[p][q].setX(h+a)}}},getEventWidth:function(e,b,a,g,d){var h=d;var c=e+1;while(c<=b){for(var f=0;f<g;f++){if(typeof(this.rows[a+f][c])!="undefined"){return h-2}}h+=d;c++}return h-2},inAppointmentsArray:function(c,b){for(var a=0;a<b.length;a++){if(b[a].id==c){return true}}return false},clearSelection:function(){this.selector.setVisible(false)},handleRecurringEvent:function(a,c,b){this.currentRecurringEvent=c;this.currentFireEvent=a;this.currentActionData=b;if(!this.recurrenceDialog){this.recurrenceDialog=new GO.calendar.RecurrenceDialog();this.recurrenceDialog.on("single",function(){this.currentActionData.singleInstance=true;if(!this.currentRecurringEvent.allDay){if(this.currentFireEvent=="eventResize"){this.resizeAppointment(this.currentRecurringEvent.domId,this.currentRecurringEvent.day)}else{if(this.currentFireEvent=="move"){var d=this.moveAppointment(this.currentRecurringEvent,this.currentActionData)}}}this.fireEvent(this.currentFireEvent,this,this.currentRecurringEvent,this.currentActionData,d);this.currentRecurringEvent.repeats=false;this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("entire",function(){this.currentActionData.singleInstance=false;this.fireEvent(this.currentFireEvent,this,this.currentRecurringEvent,this.currentActionData);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("cancel",function(){if(this.currentFireEvent=="move"){this.store.reload()}this.recurrenceDialog.hide()},this)}this.recurrenceDialog.show()},snapPos:function(d,e,b){var f=e-d;var c=Math.floor(f/b);var g=f-(c*b);var a=b/2;if(g>a){c++}return d+(c*b)},snap:function(c,e,b){if(!e||!c){return c}var d=c;var a=c%e;if(a>0){if(a>(e/2)){d=c+(e-a)}else{d=c-a}}return Math.max(b,d)},clearGrid:function(){this.allDayAppointmentsMap={};this.appointmentsMap={};this.appointments={};this.allDayAppointments=Array();this.remoteEvents=Array();this.domIds=Array()},next:function(a){if(!a){a=this.days}this.setDate(this.startDate.add(Date.DAY,a))},setDays:function(b,a){this.setDate(this.configuredDate,b,a)},setDate:function(a,c,b){if(c){this.days=c}this.configuredDate=a;if(this.days>4){this.startDate=this.getFirstDateOfWeek(a)}else{this.startDate=a}this.endDate=this.startDate.add(Date.DAY,this.days);this.setStoreBaseParams();if(b){this.store.reload()}this.periodDisplay=GO.lang.strWeek+" "+this.startDate.format("W")},nextDate:function(){return this.startDate.add(Date.DAY,this.days>4?7:1)},previousDate:function(){return this.startDate.add(Date.DAY,this.days>4?-7:-1)},reload:function(){this.load()},load:function(){var a=this.store.getRange();this.writePermission=this.store.reader.jsonData.write_permission;this.clearGrid();this.renderDaysGrid();this.loaded=false;this.onAdd(this.store,a,0);this.autoSizeGrid();this.scrollToLastPosition();for(var b=0;b<this.days;b++){this.calculateAppointments(b)}this.loaded=true},setStore:function(a,b){if(!b&&this.store){this.store.un("beforeload",this.mask,this);this.store.un("datachanged",this.reload)}if(a){a.on("beforeload",this.mask,this);a.on("load",this.unmask,this);a.on("datachanged",this.reload,this);a.on("add",this.onAdd,this);a.on("remove",this.onRemove,this);a.on("update",this.onUpdate,this)}this.store=a},onAdd:function(g,c,d){for(var e=0,b=c.length;e<b;e++){var a=Date.parseDate(c[e].data.start_time,this.dateTimeFormat);var h=Date.parseDate(c[e].data.end_time,this.dateTimeFormat);var f=c[e].data;f.startDate=a;f.endDate=h;this.addDaysGridEvent(f,this.loaded)}this.nextId=c.length},onRemove:function(c,a,b){},onUpdate:function(b,a){},setStoreBaseParams:function(){this.store.baseParams.start_time=this.startDate.format(this.dateTimeFormat);this.store.baseParams.end_time=this.endDate.format(this.dateTimeFormat)},registerEvent:function(b,a){this.remoteEvents[b]=a;if(!this.domIds[a.id]){this.domIds[a.id]=[]}this.domIds[a.id].push(b)},setNewEventId:function(b,c){for(var d=0,a=b.length;d<a;d++){this.remoteEvents[b[d]].event_id=c}},getEventDomElements:function(a){return GO.util.clone(this.domIds[a])},getRelatedDomElements:function(c){var b=this.remoteEvents[c];if(!b){return false}var a=this.getEventDomElements(b.id);if(!a){a=[c]}return a},elementToEvent:function(a,b){this.remoteEvents[a]["domId"]=a;return this.remoteEvents[a]},domToTimes:function(d,k){if(!k){k=false}var b=Ext.get(d);if(!b){return false}var f=b.getXY();if(!k){var l=b.getSize();var j=this.getRowNumberByY(f[1]);if(j<0){j=0}var e=this.getRowNumberByY(f[1]+l.height);if(e<=j){e=j+1}}else{j=0;e=0}var h=this.getDayByX(f[0]);var c=this.startDate.add(Date.DAY,h);var i=60/this.rowsPerHour;var a=c.add(Date.MINUTE,j*i);var g=c.add(Date.MINUTE,e*i);return{startDate:a,endDate:g,day:h}},getDateByPosition:function(b,e){if(!e){var f=this.getRowNumberByY(b[1]);if(f<0){f=0}}else{f=0}var c=this.getDayByX(b[0]);var d=this.startDate.add(Date.DAY,c);var a=60/this.rowsPerHour;d=d.add(Date.MINUTE,f*a);return d},scrollToRow:function(b){var a=this.getSnap();if(!a){return false}this.gridContainer.scrollTo("top",a.y*b)},scrollToLastPosition:function(){if(this.gridContainer){if(this.scrollPosition&&this.scrollPosition.top>0){this.gridContainer.scrollTo("top",this.scrollPosition.top)}else{this.scrollToRow(7*this.rowsPerHour)}}},storeScrollPosition:function(b,a){var c=Ext.get(a).getScroll();if(c.top>0){this.scrollPosition=Ext.get(a).getScroll()}},onShow:function(){GO.grid.CalendarGrid.superclass.onShow.call(this);this.scrollToLastPosition()},startEventDrag:function(b,a){if(this.writePermission&&!this.eventMouseUp&&b.button=="0"){this.dragClickEventPosition=b.getXY();this.originalEvent=this.elementToEvent(a);if(!this.originalEvent["private"]){this.dragEvent=Ext.get(a);this.dragEvent.size=this.dragEvent.getSize();this.dragappointmentstartPos=this.dragEvent.getXY();this.dragXoffset=this.dragClickEventPosition[0]-this.dragappointmentstartPos[0];this.dragYoffset=this.dragClickEventPosition[1]-this.dragappointmentstartPos[1];this.lastDragX=this.dragappointmentstartPos[0];this.lastDragY=this.dragappointmentstartPos[1];this.dragSnap=this.getSnap();this.columnsContainerY=this.gridTable.getY()}}},onEventDragMouseMove:function(h){if(this.dragEvent){var g=h.getXY();var a=this.snapPos(this.dragappointmentstartPos[0],g[0]-this.dragXoffset,this.dragSnap.x,this.days);var i=this.snapPos(this.dragappointmentstartPos[1],g[1]-this.dragYoffset,this.dragSnap.y,this.scale);var f=this.columnsContainerY-4;var b=this.gridCells[0][0].xy[0]-4;var d=this.columnsContainerY+this.gridTableHeight+5;var c=this.gridCells[this.days-1][47].xy[0]+4;if(a!=this.lastDragX&&a<c&&a>b){this.lastDragX=a;this.dragEvent.setX(a)}if(i!=this.lastDragY&&i<d&&i>f){this.lastDragY=i;this.dragEvent.setY(i)}}},onEventDragMouseUp:function(f){if(this.dragEvent){var h=this.dragEvent.getXY();if(h[0]!=this.dragappointmentstartPos[0]||h[1]!=this.dragappointmentstartPos[1]){var b=this.getDateByPosition(this.dragappointmentstartPos);var i=this.getDateByPosition(h);var j={offset:i.format("U")-b.format("U"),dragDate:this.remoteEvents[this.dragEvent.id].startDate};var a=this.elementToEvent(this.dragEvent.id);var d=Ext.get(this.dragEvent.id);var c=d.select("span.x-calGrid-event-time");if(c){c.update(a.startDate.format(GO.settings.time_format));d.set({"ext:qtip":GO.calendar.formatQtip(a)})}if(this.remoteEvents[this.dragEvent.id]["repeats"]){a.oldPos=this.dragappointmentstartPos;a.newPos=h;this.handleRecurringEvent("move",a,j)}else{var g=this.moveAppointment(a,j);this.fireEvent("move",this,a,j,g)}}this.dragEvent=false}},moveAppointment:function(b,a){this.removeEvent(b.domId,true);delete b.domId;b.startDate=b.startDate.add(Date.SECOND,a.offset);b.endDate=b.endDate.add(Date.SECOND,a.offset);return this.addDaysGridEvent(b,true)},findAppointment:function(a,c){for(var b=0;b<this.appointments[a].length;b++){if(this.appointments[a][b].id==c){return b}}},startAllDayEventDrag:function(b,a){if(!this.eventMouseUp&&this.writePermission){this.dragClickEventPosition=b.getXY();this.originalEvent=this.elementToEvent(a,true);this.allDayDragDate=this.originalEvent.startDate;if(!this.originalEvent["private"]){this.allDayDragEvent=Ext.get(a);this.allDayDragEvent.size=this.allDayDragEvent.getSize();this.dragappointmentstartPos=this.allDayDragEvent.getXY();this.currentDragDay=this.getDayByX(this.dragappointmentstartPos[0]+1);this.dragXoffset=this.dragClickEventPosition[0]-this.dragappointmentstartPos[0];this.dragSnap=this.getSnap()}}},currentDragDay:false,onAllDayEventDragMouseMove:function(d){if(this.allDayDragEvent){var c=d.getXY();var a=this.snapPos(this.dragappointmentstartPos[0],c[0]-this.dragXoffset,this.dragSnap.x,this.days);var b=this.getDayByX(c[0]+1);if(this.currentDragDay!=b&&this.allDayColumns[b]){this.currentDragDay=b;this.allDayColumns[b].appendChild(this.allDayDragEvent)}}},onAllDayEventDragMouseUp:function(h){if(this.allDayDragEvent){var d=h.getXY();if(d[0]!=this.dragappointmentstartPos[0]){var b=this.getDayByX(this.dragappointmentstartPos[0]+1);var c=this.getDayByX(d[0]+1);if(b!=c&&this.allDayColumns[c]){var i=c-b;var g=this.elementToEvent(this.allDayDragEvent.id,true);var f={offsetDays:i,dragDate:this.allDayDragDate};if(this.remoteEvents[this.allDayDragEvent.id]["repeats"]){this.handleRecurringEvent("move",g,f)}else{this.removeEvent(this.allDayDragEvent.id);g.startDate=Date.parseDate(g.start_time,this.dateTimeFormat).add(Date.DAY,i);g.endDate=Date.parseDate(g.end_time,this.dateTimeFormat).add(Date.DAY,i);g.start_time=g.startDate.format(this.dateTimeFormat);g.end_time=g.endDate.format(this.dateTimeFormat);var a=this.addDaysGridEvent(g);this.fireEvent("move",this,g,f,a)}}this.autoSizeGrid()}this.allDayDragEvent=false}}});GO.grid.MonthGrid=Ext.extend(Ext.Panel,{dateFormat:"Y-m-d",dateTimeFormat:"Y-m-d H:i",timeFormat:"H:i",firstWeekday:1,configuredDate:false,startDate:false,dragEvent:false,appointments:Array(),remoteEvents:Array(),domIds:Array(),days:1,selected:Array(),writePermission:false,scrollOffset:22,gridEvents:{},weekNumberWidth:16,dayNameHeight:16,nextId:0,periodDisplay:"",initComponent:function(){this.autoScroll=true;this.addEvents({showday:true,create:true,move:true,eventResize:true,eventDblClick:true,deleteEvent:true});if(this.store){this.setStore(this.store,true)}if(!this.startDate){var a=new Date();this.startDate=Date.parseDate(a.format(this.dateFormat),this.dateFormat)}this.configuredDate=this.startDate;GO.grid.MonthGrid.superclass.initComponent.call(this)},afterRender:function(){GO.grid.MonthGrid.superclass.afterRender.call(this);this.setDate(this.startDate,false);this.body.unselectable();this.setStore(this.store);this.initDD()},renderMonthView:function(){this.body.update("");var s=this.configuredDate.format("Ym");var g=new Date();var k=g.format("Ymd");var h=0;var m="";var o;this.cellWrap=Ext.DomHelper.append(this.body,{tag:"div",id:"cal-monthGrid-wrap"},true);this.gridCells={};this.weekNumberCells=[];this.dayNameCells=[];var a=Ext.DomHelper.append(this.cellWrap,{tag:"div",style:"width:"+(this.dayNameHeight-1)+"px",cls:"cal-monthgrid-week-no"},true);Ext.DomHelper.append(a,{tag:"div",cls:"x-monthGrid-cell-day-text",html:"&nbsp;"},true);for(var q=this.firstWeekday;q<7+this.firstWeekday;q++){var r=(q==7)?GO.calendar.lang.daynames[0]:GO.calendar.lang.daynames[q];var a=Ext.DomHelper.append(this.cellWrap,{tag:"div",cls:"cal-monthgrid-week-no"},true);Ext.DomHelper.append(a,{tag:"div",cls:"x-monthGrid-cell-day-text",html:r},true);this.dayNameCells.push(a)}for(var p=0;p<this.days;p++){var l=this.startDate.add(Date.DAY,p);if(p==0||l.format("j")==1){o="j F"}else{o="j"}var c=l.format("w");var d=l.format("Ym");var j=l.format("Ymd");if(c==this.firstWeekday){var f=l.format("W");var a=Ext.DomHelper.append(this.cellWrap,{tag:"div",style:"width:"+(this.weekNumberWidth-1)+"px",cls:"cal-monthgrid-week-no"},true);var e=Ext.DomHelper.append(a,{tag:"a",cls:"x-monthGrid-cell-day-text",href:"#",id:"wl-"+j,html:f},true);e.on("click",this.onWeekClick,this);this.weekNumberCells.push(a)}if(j==k){m="cal-monthGrid-cell x-monthGrid-cell-today"}else{if(d==s&&(c==0||c==6)){m="cal-monthGrid-cell x-monthGrid-cell-weekend"}else{if(d==s){m="cal-monthGrid-cell x-monthGrid-cell-current"}else{m="cal-monthGrid-cell"}}}var n="d"+j;var a=Ext.DomHelper.append(this.cellWrap,{tag:"div",id:n,cls:m},true);var b=Ext.DomHelper.append(a,{tag:"a",cls:"x-monthGrid-cell-day-text",href:"#",html:l.format(o)},true);b.on("click",this.onAddClick,this);this.gridCells[j]=a}this.syncSize()},onMoreClick:function(d,c){var a=Ext.get(c).findParent("div.cal-monthGrid-cell",3);var b=Date.parseDate(a.id.substring(1,a.id.length),"Ymd");this.fireEvent("changeview",this,1,b)},onWeekClick:function(c,b){var a=Date.parseDate(b.id.substring(3,b.id.length),"Ymd");this.fireEvent("changeview",this,7,a)},onAddClick:function(d,c){var a=Ext.get(c).findParent("div.cal-monthGrid-cell",3);var b=Date.parseDate(a.id.substring(1,a.id.length),"Ymd");this.fireEvent("create",this,b)},onResize:function(d,b,a,c){Ext.grid.GridPanel.superclass.onResize.apply(this,arguments);this.syncSize();this.checkOverflow()},calcCellSize:function(b,a){this.cellHeight=((b.height-this.dayNameHeight)/(this.days/7));if(this.cellHeight<100){this.cellHeight=100;if(!a){b.width-=this.scrollOffset}}this.cellWidth=((b.width-this.weekNumberWidth)/7);if(this.cellWidth<100){this.cellWidth=100;b.height-=this.scrollOffset;if(!a){this.calcCellSize(b,true)}}this.cellHeight=Math.floor(this.cellHeight);this.cellWidth=Math.floor(this.cellWidth)},checkOverflow:function(){if(this.overflowIndicators){for(var a=0;a<this.overflowIndicators.length;a++){this.overflowIndicators[a].remove()}}this.overflowIndicators=[];for(var a in this.gridCells){if(this.gridCells[a].dom.scrollHeight>this.gridCells[a].dom.clientHeight){var b=Ext.DomHelper.append(this.gridCells[a],{tag:"a",cls:"cal-overflow-indicator",href:"#",html:GO.lang.more+"..."},true);b.on("click",this.onMoreClick,this);var c=this.gridCells[a].getXY();b.setXY(c);this.overflowIndicators.push(b)}}},syncSize:function(){if(this.cellWrap){var b=this.container.getSize(true);this.calcCellSize(b);this.cellWrap.setSize(this.cellWidth*7+this.weekNumberWidth,this.cellHeight*(this.days/7));for(var a in this.gridCells){this.gridCells[a].setSize(this.cellWidth,this.cellHeight)}for(var a=0;a<this.dayNameCells.length;a++){this.dayNameCells[a].setWidth(this.cellWidth)}for(var a=0;a<this.weekNumberCells.length;a++){this.weekNumberCells[a].setHeight(this.cellHeight)}for(var c in this.gridEvents){for(var a=0;a<this.gridEvents[c].length;a++){this.gridEvents[c][a].setWidth(this.cellWidth-3)}}}},initDD:function(){var a=new GO.calendar.dd.MonthDragZone(this.body,{ddGroup:"month-grid",scroll:false,monthGrid:this});var b=new GO.calendar.dd.MonthDropTarget(this.body,{ddGroup:"month-grid",onNotifyDrop:function(j,f,d){var c=d.dragDate.format("U");var h=d.dropDate.format("U");var k=Math.round((h-c)/86400);var l={offsetDays:k,dragDate:d.dragDate};var i=this.elementToEvent(d.item.id);if(!i.read_only){if(i.repeats){this.handleRecurringEvent("move",i,l)}else{this.removeEvent(i.domId);delete i.domId;i.repeats=false;i.startDate=i.startDate.add(Date.DAY,k);i.endDate=i.endDate.add(Date.DAY,k);i.start_time=i.startDate.format("U");i.end_time=i.endDate.format("U");var g=this.addMonthGridEvent(i);this.fireEvent("move",this,i,l,g);this.clearSelection()}}},scope:this})},setStore:function(a,b){if(!b&&this.store){this.store.un("beforeload",this.reload);this.store.un("datachanged",this.reload);this.store.un("clear",this.reload)}if(a){a.on("beforeload",this.mask,this);a.on("datachanged",this.reload,this);a.on("clear",this.reload,this)}this.store=a},setStoreBaseParams:function(){this.store.baseParams.start_time=this.startDate.format(this.dateTimeFormat);this.store.baseParams.end_time=this.endDate.format(this.dateTimeFormat)},getFirstDateOfWeek:function(a){var b=a.getDay();if(b<this.firstWeekday){b=7}return a.add(Date.DAY,this.firstWeekday-b)},mask:function(){if(this.rendered){this.body.mask(GO.lang.waitMsgLoad,"x-mask-loading")}},unmask:function(){if(this.rendered){this.body.unmask()}},getSelectedEvent:function(){if(this.selected&&this.selected.length>0){return this.elementToEvent(this.selected[0].id)}},isSelected:function(a){for(var b=0;b<this.selected.length;b++){if(this.selected[b].id==a){return true}}return false},clearSelection:function(){for(var a=0;a<this.selected.length;a++){this.selected[a].removeClass("x-calGrid-selected")}this.selected=[]},selectEventElement:function(a){if(!this.isSelected(a)){this.clearSelection();var d=this.getRelatedDomElements(a.id);for(var c=0;c<d.length;c++){var b=Ext.get(d[c]);if(b){b.addClass("x-calGrid-selected");b.focus();this.selected.push(b)}}}},showContextMenu:function(b,a){if(!this.contextMenu){this.contextMenu=new GO.calendar.ContextMenu();this.contextMenu.on("deleteEvent",function(){this.fireEvent("deleteEvent",this)},this);this.contextMenu.on("updateEvent",function(h,d){var f=h.event;var c=false;var j=Ext.decode(this.store.baseParams.calendars);for(var e=0;e<j.length&&!c;e++){if(j[e]==f.calendar_id){c=true}}if(h.isCopy){if(c){if(f.repeats){this.store.reload()}else{var g=GO.util.clone(f);delete (g.id);g.event_id=d;g.startDate=Date.parseDate(g.start_time,this.dateTimeFormat).add(Date.DAY,h.offset);g.endDate=Date.parseDate(g.end_time,this.dateTimeFormat).add(Date.DAY,h.offset);g.start_time=g.startDate.format(this.dateTimeFormat);g.end_time=g.endDate.format(this.dateTimeFormat);this.addMonthGridEvent(g)}}}else{if(h.repeats){this.store.reload()}else{this.removeEvent(f.domId);delete f.domId;if(c){f.startDate=Date.parseDate(f.start_time,this.dateTimeFormat).add(Date.DAY,h.offset);f.endDate=Date.parseDate(f.end_time,this.dateTimeFormat).add(Date.DAY,h.offset);f.start_time=f.startDate.format(this.dateTimeFormat);f.end_time=f.endDate.format(this.dateTimeFormat);this.addMonthGridEvent(f)}}}},this)}b.stopEvent();this.contextMenu.setEvent(a);this.contextMenu.showAt(b.getXY())},addMonthGridEvent:function(m){if(m.id==undefined){m.id=this.nextId++}var g=Date.parseDate(m.startDate.format("Ymd"),"Ymd");var b=Date.parseDate(m.endDate.format("Ymd"),"Ymd");var h=g.format("U");var l=b.format("U");var j=Math.round((l-h)/86400)+1;var k=[];for(var f=0;f<j;f++){var e=g.add(Date.DAY,f);m.domId=Ext.id();k.push(m.domId);if(j>1){if(!this.domIds[m.id]){this.domIds[m.id]=[]}this.domIds[m.id].push(m.domId)}var c=Ext.get("d"+e.format("Ymd"));if(c){var n="";if(m.startDate.format("G")!="0"){n+=m.startDate.format(GO.settings.time_format)+"&nbsp;"}n+=m.name;var o="x-calGrid-month-event-container";if(m.link_count>0){o+=" cal-has-links"}var a=Ext.DomHelper.append(c,{tag:"div",id:m.domId,cls:o,style:"background-color:#"+m.background+";width:"+(this.eventWidth)+"px",html:n,qtip:GO.calendar.formatQtip(m),qtitle:m.name,tabindex:0},true);var d=e.format("Ymd");if(!this.gridEvents[d]){this.gridEvents[d]=[]}this.gridEvents[d].push(a);this.registerEvent(m.domId,m);a.on("mousedown",function(p,i){i=Ext.get(i).findParent("div.x-calGrid-month-event-container",2,true);this.selectEventElement(i);this.clickedEventId=i.id},this);a.on("dblclick",function(q,i){i=Ext.get(i).findParent("div.x-calGrid-month-event-container",2,true);this.clickedEventId=i.id;var p=this.elementToEvent(this.clickedEventId);if(p.repeats&&this.writePermission){this.handleRecurringEvent("eventDblClick",p,{})}else{this.fireEvent("eventDblClick",this,p,{singleInstance:this.writePermission})}},this);a.on("contextmenu",function(q,i){var p=this.elementToEvent(this.clickedEventId);this.showContextMenu(q,p)},this)}}if(!this.loading){this.checkOverflow()}return k},removeEventByRemoteId:function(d){var b=this.getEventDomElements(d);if(b){for(var c=0,a=b.length;c<a;c++){this.removeEvent(b[c])}}},removeEvent:function(d){var c=this.getRelatedDomElements(d);if(c){for(var a=0;a<c.length;a++){var b=Ext.get(c[a]);if(b){b.removeAllListeners();b.remove()}this.unregisterDomId(c[a])}}this.checkOverflow()},unregisterDomId:function(d){delete this.remoteEvents[d];var b=false;for(var c in this.domIds){for(var a=0;a<this.domIds[c].length;a++){if(this.domIds[c][a]==d){this.domIds[c].splice(a,1);b=true;break}}if(b){break}}},setNewEventId:function(b,c){for(var d=0,a=b.length;d<a;d++){this.remoteEvents[b[d]].event_id=c}},handleRecurringEvent:function(a,c,b){this.currentRecurringEvent=c;this.currentFireEvent=a;this.currentActionData=b;if(!this.recurrenceDialog){this.recurrenceDialog=new GO.calendar.RecurrenceDialog();this.recurrenceDialog.on("single",function(){this.currentActionData.singleInstance=true;var e=this.currentRecurringEvent;var f=GO.util.clone(e);var d=[];if(this.currentActionData.offsetDays){this.removeEvent(e.domId);f.repeats=false;f.startDate=f.startDate.add(Date.DAY,this.currentActionData.offsetDays);f.endDate=f.endDate.add(Date.DAY,this.currentActionData.offsetDays);f.start_time=f.startDate.format("U");f.end_time=f.endDate.format("U");d=this.addMonthGridEvent(f)}this.fireEvent(this.currentFireEvent,this,e,this.currentActionData,d);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("entire",function(){this.currentActionData.singleInstance=false;this.fireEvent(this.currentFireEvent,this,this.currentRecurringEvent,this.currentActionData);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("cancel",function(){this.recurrenceDialog.hide()},this)}this.recurrenceDialog.show()},clearGrid:function(){this.gridEvents={};this.appointments=Array();this.remoteEvents=Array();this.domIds=Array()},setDate:function(c,h){var d=this.startDate;var f=this.endDate;this.configuredDate=c;var i=c.getFirstDateOfMonth();var g=c.getLastDateOfMonth();this.startDate=this.getFirstDateOfWeek(i);var b=this.startDate.format("U");var e=g.format("U");var a=((e-b)/86400)+1;var j=Math.ceil(a/7);this.days=j*7;this.endDate=this.startDate.add(Date.DAY,this.days);this.setStoreBaseParams();this.periodDisplay=this.configuredDate.format("F, Y");if(!f||!d||f.getElapsed(this.endDate)!=0||d.getElapsed(this.startDate)!=0){if(h){this.store.reload()}else{this.loadRequired=true}}},nextDate:function(){var a=this.configuredDate.add(Date.MONTH,1);return a},previousDate:function(){var a=this.configuredDate.add(Date.MONTH,-1);return a},reload:function(){this.load()},load:function(){if(this.rendered){this.loading=true;this.clearGrid();this.renderMonthView();this.writePermission=this.store.reader.jsonData.write_permission;var c=this.store.getRange();for(var d=0,b=c.length;d<b;d++){var a=Date.parseDate(c[d].data.start_time,this.dateTimeFormat);var f=Date.parseDate(c[d].data.end_time,this.dateTimeFormat);var e=c[d].data;e.startDate=a;e.endDate=f;this.addMonthGridEvent(e)}this.nextId=c.length;this.checkOverflow();this.unmask();this.loading=false;this.loadRequired=false}},registerEvent:function(b,a){this.remoteEvents[b]=a},getEventDomElements:function(a){return GO.util.clone(this.domIds[a])},getRelatedDomElements:function(c){var b=this.remoteEvents[c];if(!b){return false}var a=this.getEventDomElements(b.id);if(!a){a=[c]}return a},elementToEvent:function(a,b){this.remoteEvents[a]["domId"]=a;return this.remoteEvents[a]}});GO.calendar.dd.MonthDragZone=function(b,a){a=a||{};Ext.apply(a,{ddel:document.createElement("div")});GO.calendar.dd.MonthDragZone.superclass.constructor.call(this,b,a)};Ext.extend(GO.calendar.dd.MonthDragZone,Ext.dd.DragZone,{onInitDrag:function(c){if(!this.monthGrid.writePermission||this.monthGrid.remoteEvents[this.dragData.item.id]["private"]||this.monthGrid.remoteEvents[this.dragData.item.id]["read_only"]){return false}else{this.ddel.innerHTML=this.dragData.item.dom.innerHTML;this.ddel.className=this.dragData.item.dom.className;this.ddel.style.width=this.dragData.item.getWidth()+"px";this.proxy.update(this.ddel);this.eventDomElements=this.monthGrid.getRelatedDomElements(this.dragData.item.id);var d=Ext.get(this.dragData.item).findParent("div.cal-monthGrid-cell",3,true);this.eventProxies=[];this.proxyDragPos=0;for(var a=0;a<this.eventDomElements.length;a++){this.eventProxies.push(Ext.DomHelper.append(document.body,{tag:"div",id:Ext.id(),cls:"x-calGrid-month-event-proxy",style:"width:"+this.ddel.style.width+"px;"},true));if(this.eventDomElements[a]==this.dragData.item.id){this.proxyDragPos=a}else{var b=Ext.get(this.eventDomElements[a]);if(b){b.setStyle({position:"absolute",top:-10000,display:"none"})}}}}},removeEventProxies:function(){var a=Ext.query("div.x-calGrid-month-event-proxy");for(var b=0;b<a.length;b++){Ext.get(a[b]).remove()}delete this.lastTdOverId;for(var b=0;b<this.eventDomElements.length;b++){var c=Ext.get(this.eventDomElements[b]);if(c){c.setStyle({position:"static",top:"",display:"block"})}}},afterRepair:function(){GO.calendar.dd.MonthDragZone.superclass.afterRepair.call(this);this.removeEventProxies()},getRepairXY:function(b,a){a.item.highlight("#e8edff");return a.item.getXY()},getDragData:function(c){if(!this.monthGrid.writePermission){return false}else{var b=Ext.get(c.getTarget());if(b.hasClass("x-calGrid-month-event-container")&&this.monthGrid.remoteEvents[b.id]["read_only"]){return false}var d=b.parent();var a=Date.parseDate(d.id.substr(1),"Ymd");if(b.hasClass("x-calGrid-month-event-container")&&!this.monthGrid.remoteEvents[b.id]["private"]){return{ddel:this.ddel,item:b,dragDate:a}}else{return false}}}});GO.calendar.dd.MonthDropTarget=function(b,a){GO.calendar.dd.MonthDropTarget.superclass.constructor.call(this,b,a)};Ext.extend(GO.calendar.dd.MonthDropTarget,Ext.dd.DropTarget,{notifyDrop:function(a,g,d){var b=this.scope.elementToEvent(d.item.id);if(!this.scope.writePermission||b.read_only){return false}else{var f=Ext.get(g.getTarget()).findParent("div.cal-monthGrid-cell",3,true);d.dropDate=Date.parseDate(f.id.substr(1),"Ymd");a.removeEventProxies();this.el.removeClass(this.overClass);f.appendChild(d.item);if(this.onNotifyDrop){if(!this.scope){this.scope=this}var c=this.onNotifyDrop.createDelegate(this.scope);c.call(this,a,g,d)}return true}},notifyOver:function(b,h,g){var f=Ext.get(h.getTarget()).findParent("div.cal-monthGrid-cell",3,true);if(f){if(b.lastTdOverId!=f.id){var a=f;for(var c=0;c<b.proxyDragPos;c++){if(a){var d=a.prev("div.cal-monthGrid-cell");a=d}if(d){b.eventProxies[c].insertAfter(d.first());b.eventProxies[c].setStyle({position:"static",top:"",display:"block"})}else{b.eventProxies[c].setStyle({position:"absolute",top:-10000,display:"none"})}}b.eventProxies[c].insertAfter(f.first());var a=f;for(var c=b.proxyDragPos+1;c<b.eventProxies.length;c++){if(a){var d=a.next("div.cal-monthGrid-cell");a=d}if(d){b.eventProxies[c].insertAfter(d.first());b.eventProxies[c].setStyle({position:"static",top:"",display:"block"})}else{b.eventProxies[c].setStyle({position:"absolute",top:-10000,display:"none"})}}}b.lastTdOverId=f.id}return this.dropAllowed}});GO.calendar.ListGrid=function(b){if(!b){b={}}b.store=new Ext.data.GroupingStore({reader:new Ext.data.JsonReader({totalProperty:"count",root:"results",id:"id",fields:["id","event_id","name","time","start_time","end_time","description","location","private","repeats","background","day","task_id","contact_id","link_count","calendar_id","calendar_name","num_participants"]}),baseParams:{task:"events"},proxy:new Ext.data.HttpProxy({url:GO.settings.modules.calendar.url+"json.php"}),groupField:"day",sortInfo:{field:"start_time",direction:"ASC"},remoteSort:true});b.paging=false,b.autoExpandColumn="listview-calendar-name-heading";b.autoExpandMax=2500;b.enableColumnHide=false;b.enableColumnMove=false;b.autoScroll=true;b.columns=[{header:GO.lang.strDay,dataIndex:"day",menuDisabled:true},{header:GO.lang.strTime,dataIndex:"time",width:90,renderer:function(d,f,c){var e='<div class="';if(c.data.link_count>0){e+="cal-has-links"}e+='" style="background-position:1px 3px !important;border:1px solid #c0c0c0;padding:2px;margin:2px;background-color:#'+c.data.background+';">'+d+"</div>";return e},menuDisabled:true},{id:"listview-calendar-name-heading",header:GO.lang.strName,dataIndex:"name",renderer:this.renderName,menuDisabled:true}];b.view=new Ext.grid.GroupingView({hideGroupedColumn:true,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'+GO.lang.items+'" : "'+GO.lang.item+'"]})',emptyText:GO.calendar.lang.noAppointmentsToDisplay,showGroupName:false});b.sm=new Ext.grid.RowSelectionModel({singleSelect:true});b.loadMask=true;GO.calendar.ListGrid.superclass.constructor.call(this,b);if(!this.startDate){var a=new Date();this.startDate=Date.parseDate(a.format(this.dateFormat),this.dateFormat)}this.configuredDate=this.startDate};Ext.extend(GO.calendar.ListGrid,Ext.grid.GridPanel,{dateFormat:"Y-m-d",dateTimeFormat:"Y-m-d H:i",timeFormat:"H:i",firstWeekday:1,configuredDate:false,startDate:false,days:91,nextId:0,periodDisplay:"",renderName:function(b,c,a){return'<div style="font-weight:bold;">'+a.data.name+"</div>"+GO.calendar.formatQtip(a.data)},afterRender:function(){GO.calendar.ListGrid.superclass.afterRender.call(this);this.on("rowdblclick",function(b,d,c){var a=b.getStore().getAt(d);if(a.data.event_id){GO.calendar.showEventDialog({event_id:a.data.event_id})}else{if(a.data.task_id){GO.tasks.showTaskDialog({task_id:a.data.task_id})}else{if(a.data.contact_id){GO.linkHandlers[2].call(this,a.data.contact_id)}}}},this);this.on("rowcontextmenu",function(a,f,c){var d=a.getSelectionModel();if(d.isSelected(f)!==true){d.clearSelections();d.selectRow(f)}var b=a.getStore().getAt(f).data;this.showContextMenu(c,b)},this)},getFirstDateOfWeek:function(a){var b=a.getDay();var c=this.firstWeekday-b;if(c>0){c-=7}return a.add(Date.DAY,c)},setDays:function(b,a){this.setDate(this.configuredDate,7,a)},getSelectedEvent:function(){var c=this.getSelectionModel();var a=c.getSelected();var b=a.data;b.startDate=Date.parseDate(b.start_time,this.dateTimeFormat);b.endDate=Date.parseDate(b.end_time,this.dateTimeFormat);return b},removeEvent:function(){var b=this.getSelectionModel();var a=b.getSelected();this.store.remove(a)},setDate:function(b,e,d){this.configuredDate=b;var a="";var c=b.getFullYear();if(b.getMonth()>8){a=b.getFullYear()+"-10-01";this.periodDisplay="4 "}else{if(b.getMonth()>5){a=c+"-07-01";this.periodDisplay="3 "}else{if(b.getMonth()>2){a=c+"-04-01";this.periodDisplay="2 "}else{a=c+"-01-01";this.periodDisplay="1 "}}}this.periodDisplay=GO.calendar.lang.quarterShort+this.periodDisplay+c;this.startDate=Date.parseDate(a,this.dateFormat);this.endDate=this.nextDate();this.setStoreBaseParams();if(d){this.store.reload()}},nextDate:function(){return this.startDate.add(Date.MONTH,3)},previousDate:function(){return this.startDate.add(Date.MONTH,-3)},setStoreBaseParams:function(){this.store.baseParams.start_time=this.startDate.format(this.dateTimeFormat);this.store.baseParams.end_time=this.endDate.format(this.dateTimeFormat)},showContextMenu:function(b,a){if(!this.contextMenu){this.contextMenu=new GO.calendar.ContextMenu();this.contextMenu.on("deleteEvent",function(){this.fireEvent("deleteEvent",this)},this);this.contextMenu.on("updateEvent",function(e){var f=Ext.decode(this.store.baseParams.calendars);if(!e.isCopy){this.store.reload()}else{for(var c=0,d=false;c<f.length&&!d;c++){if(f[c]==e.event.calendar_id){d=true;this.store.reload()}}}},this)}b.stopEvent();this.contextMenu.setEvent(a);this.contextMenu.showAt(b.getXY())}});GO.grid.ViewGrid=Ext.extend(Ext.Panel,{dateFormat:"Y-m-d",dateTimeFormat:"Y-m-d H:i",timeFormat:"H:i",firstWeekday:1,configuredDate:false,startDate:false,dragEvent:false,appointments:Array(),remoteEvents:Array(),domIds:Array(),days:1,selected:Array(),view_id:0,gridCells:Array(),nextId:0,periodDisplay:"",initComponent:function(){GO.grid.ViewGrid.superclass.initComponent.call(this);this.addEvents({create:true,move:true,eventResize:true,eventDblClick:true,zoom:true,storeload:true});if(!this.startDate){var a=new Date();this.startDate=Date.parseDate(a.format(this.dateFormat),this.dateFormat)}this.configuredDate=this.startDate},setViewId:function(a){this.view_id=a},onRender:function(b,a){GO.grid.ViewGrid.superclass.onRender.apply(this,arguments);this.setDate(this.startDate,false);this.body.setStyle("overflow","hidden");this.body.unselectable();this.initDD()},renderView:function(){this.body.update("");var j=this.container.getSize(true);var c=(j.width-150)/this.days;this.headingsTable=Ext.DomHelper.append(this.body,{tag:"table",id:Ext.id(),cls:"x-calGrid-headings-table",style:"width:"+j.width+"px;"},true);var g=Ext.DomHelper.append(this.headingsTable,{tag:"tbody"},true);this.headingsRow=Ext.DomHelper.append(g,{tag:"tr",children:{tag:"td",style:"width:147px",cls:"x-calGrid-heading"}},true);var e=GO.settings.date_format.indexOf("Y");var b="D "+GO.settings.date_format.substring(0,e-1);for(var m=0;m<this.days;m++){var d=this.startDate.add(Date.DAY,m);var q=Ext.DomHelper.append(this.headingsRow,{tag:"td",cls:"x-calGrid-heading",style:"width:"+(c)+"px",html:d.format(b)})}Ext.DomHelper.append(this.headingsRow,{tag:"td",style:"width:"+(this.scrollOffset-3)+"px;height:0px",cls:"x-calGrid-heading"});this.gridContainer=Ext.DomHelper.append(this.body,{tag:"div",cls:"x-calGrid-grid-container"},true);var p=this.headingsTable.getHeight();var a=j.height-p;this.gridContainer.setSize(j.width,a);this.gridTable=Ext.DomHelper.append(this.gridContainer,{tag:"table",id:Ext.id(),cls:"x-viewGrid-table",style:"width:"+j.width-this.scrollWidth+"px;"},true);this.tbody=Ext.DomHelper.append(this.gridTable,{tag:"tbody"},true);this.gridCells={};for(var f=0,l=this.jsonData.results.length;f<l;f++){var h=this.jsonData.results[f].id;var n=Ext.DomHelper.append(this.tbody,{tag:"tr"});var o=Ext.DomHelper.append(n,{tag:"td",cls:"x-viewGrid-calendar-name-cell",style:"width:150px"},true);var k=Ext.DomHelper.append(o,{tag:"a",id:"view_cal_"+h,href:"#",cls:"normal-link",html:this.jsonData.results[f].name},true);k.on("click",function(t,s){t.preventDefault();var i=s.id.substring(9);var r=this.getCalendar(i);this.fireEvent("zoom",{group_id:r.group_id,calendar_id:i,calendar_name:s.innerHTML,title:s.innerHTML})},this);this.gridCells[h]={};for(var m=0;m<this.days;m++){var d=this.startDate.add(Date.DAY,m);this.gridCells[h][d.format("Ymd")]=Ext.DomHelper.append(n,{tag:"td",id:"cal"+h+"_day"+d.format("Ymd"),cls:"x-viewGrid-cell",style:"width:"+c+"px"},true)}}},getCalendar:function(b){for(var a=0;a<this.jsonData.results.length;a++){if(this.jsonData.results[a].id==b){return this.jsonData.results[a]}}return false},removeEventByRemoteId:function(d){var b=this.getEventDomElements(d);if(b){for(var c=0,a=b.length;c<a;c++){this.removeEvent(b[c])}}},removeEvent:function(d){var c=this.getRelatedDomElements(d);if(c){for(var a=0;a<c.length;a++){var b=Ext.get(c[a]);if(b){b.removeAllListeners();b.remove()}this.unregisterDomId(c[a])}}},unregisterDomId:function(d){delete this.remoteEvents[d];var b=false;for(var c in this.domIds){for(var a=0;a<this.domIds[c].length;a++){if(this.domIds[c][a]==d){this.domIds[c].splice(a,1);b=true;break}}if(b){break}}},setNewEventId:function(b,c){for(var d=0,a=b.length;d<a;d++){this.remoteEvents[b[d]].event_id=c}},initDD:function(){var a=new GO.calendar.dd.ViewDragZone(this.body,{ddGroup:"view-grid",scroll:false,viewGrid:this});var b=new GO.calendar.dd.ViewDropTarget(this.body,{ddGroup:"view-grid",onNotifyDrop:function(j,f,d){var c=d.dragDate.format("U");var h=d.dropDate.format("U");var k=Math.round((h-c)/86400);var l={offsetDays:k,dragDate:d.dragDate,calendar_id:d.calendar_id};var i=this.elementToEvent(d.item.id);if(i.repeats){this.handleRecurringEvent("move",i,l)}else{this.removeEvent(i.domId);delete i.domId;i.repeats=false;i.calendar_id=d.calendar_id;i.startDate=i.startDate.add(Date.DAY,k);i.endDate=i.endDate.add(Date.DAY,k);i.start_time=i.startDate.format("U");i.end_time=i.endDate.format("U");var g=this.addViewGridEvent(i);this.fireEvent("move",this,i,l,g)}},scope:this})},onResize:function(d,b,a,c){if(this.gridContainer){this.gridContainer.setSize(d,b);this.headingsTable.setWidth(d);this.gridTable.setWidth(d)}},getFirstDateOfWeek:function(a){var b=a.getDay();var c=this.firstWeekday-b;if(c>0){c-=7}return a.add(Date.DAY,c)},mask:function(){if(this.rendered){this.body.mask(GO.lang.waitMsgLoad,"x-mask-loading")}},unmask:function(){if(this.rendered){this.body.unmask()}},getSelectedEvent:function(){if(this.selected){return this.elementToEvent(this.selected[0].id)}},isSelected:function(a){for(var b=0;b<this.selected.length;b++){if(this.selected[b].id==a){return true}}return false},clearSelection:function(){for(var a=0;a<this.selected.length;a++){this.selected[a].removeClass("x-calGrid-selected")}this.selected=[]},selectEventElement:function(a){if(!this.isSelected(a)){this.clearSelection();var d=this.getRelatedDomElements(a.id);for(var c=0;c<d.length;c++){var b=Ext.get(d[c]);if(b){b.addClass("x-calGrid-selected");b.focus();this.selected.push(b)}}}},showContextMenu:function(b,a){if(!this.contextMenu){this.contextMenu=new GO.calendar.ContextMenu();this.contextMenu.on("deleteEvent",function(){this.fireEvent("deleteEvent",this)},this);this.contextMenu.on("updateEvent",function(g,d,c){var e=g.event;if(g.isCopy){if(c){if(e.repeats){this.reload()}else{var f=GO.util.clone(e);delete (f.id);delete (f.domId);f.event_id=d;f.startDate=Date.parseDate(f.start_time,this.dateTimeFormat).add(Date.DAY,g.offset);f.endDate=Date.parseDate(f.end_time,this.dateTimeFormat).add(Date.DAY,g.offset);f.start_time=f.startDate.format(this.dateTimeFormat);f.end_time=f.endDate.format(this.dateTimeFormat);this.addViewGridEvent(f)}}}else{if(g.repeats){this.reload()}else{this.removeEvent(e.domId);delete e.domId;if(c){e.startDate=Date.parseDate(e.start_time,this.dateTimeFormat).add(Date.DAY,g.offset);e.endDate=Date.parseDate(e.end_time,this.dateTimeFormat).add(Date.DAY,g.offset);e.start_time=e.startDate.format(this.dateTimeFormat);e.end_time=e.endDate.format(this.dateTimeFormat);this.addViewGridEvent(e)}}}},this)}b.stopEvent();this.contextMenu.setEvent(a,this.view_id);this.contextMenu.showAt(b.getXY())},addViewGridEvent:function(m){if(m.id==undefined){m.id=this.nextId++}var g=Date.parseDate(m.startDate.format("Ymd"),"Ymd");var b=Date.parseDate(m.endDate.format("Ymd"),"Ymd");var h=g.format("U");var l=b.format("U");var j=Math.round((l-h)/86400)+1;var k=[];for(var f=0;f<j;f++){var d=g.add(Date.DAY,f);var e=m.domId?m.domId:Ext.id();k.push(e);if(j>1){if(!this.domIds[m.id]){this.domIds[m.id]=[]}this.domIds[m.id].push(e)}var c=this.gridCells[m.calendar_id][d.format("Ymd")];if(c){var n="";if(m.startDate.format("G")!="0"){n+=m.startDate.format(GO.settings.time_format)+"&nbsp;"}n+=m.name;var o="x-viewGrid-event-container";if(m.link_count>0){o+=" cal-has-links"}var a=Ext.DomHelper.append(c,{tag:"div",id:e,cls:o,style:"background-color:#"+m.background,html:n,qtitle:m.name,qtip:GO.calendar.formatQtip(m),tabindex:0},true);this.registerEvent(e,m);a.on("mousedown",function(p,i){i=Ext.get(i).findParent("div.x-viewGrid-event-container",2,true);this.selectEventElement(i);this.clickedEventId=i.id},this);a.on("dblclick",function(q,i){i=Ext.get(i).findParent("div.x-viewGrid-event-container",2,true);var p=this.elementToEvent(this.clickedEventId);if(p.repeats&&p.write_permission){this.handleRecurringEvent("eventDblClick",p,{})}else{this.fireEvent("eventDblClick",this,p,{singleInstance:p.write_permission})}},this);a.on("contextmenu",function(q,i){var p=this.elementToEvent(this.clickedEventId);this.showContextMenu(q,p)},this)}}return k},removeEventFromArray:function(a,c){for(var b=0;b<this.appointments[a].length;b++){if(this.appointments[a][b].id==c){return this.appointments[a].splice(b,1)}}return false},inAppointmentsArray:function(c,b){for(var a=0;a<b.length;a++){if(b[a].id==c){return true}}return false},handleRecurringEvent:function(a,c,b){this.currentRecurringEvent=c;this.currentFireEvent=a;this.currentActionData=b;if(!this.recurrenceDialog){this.recurrenceDialog=new GO.calendar.RecurrenceDialog();this.recurrenceDialog.on("single",function(){this.currentActionData.singleInstance=true;var e=this.currentRecurringEvent;var f=GO.util.clone(e);var d=[];if(this.currentActionData.offsetDays){this.removeEvent(e.domId);f.calendar_id=this.currentActionData.calendar_id;f.repeats=false;f.startDate=f.startDate.add(Date.DAY,this.currentActionData.offsetDays);f.endDate=f.endDate.add(Date.DAY,this.currentActionData.offsetDays);f.start_time=f.startDate.format("U");f.end_time=f.endDate.format("U");this.addViewGridEvent(f)}this.fireEvent(this.currentFireEvent,this,e,this.currentActionData,d);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("entire",function(){this.currentActionData.singleInstance=false;this.fireEvent(this.currentFireEvent,this,this.currentRecurringEvent,this.currentActionData);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("cancel",function(){this.recurrenceDialog.hide()},this)}this.recurrenceDialog.show()},clearGrid:function(){this.appointments=Array();this.remoteEvents=Array();this.domIds=Array()},setDays:function(b,a){this.setDate(this.configuredDate,b,a)},setDate:function(a,c,b){if(c){this.days=c}this.configuredDate=a;if(this.days>4){this.startDate=this.getFirstDateOfWeek(a)}else{this.startDate=a}this.endDate=this.startDate.add(Date.DAY,this.days);this.periodDisplay=GO.lang.strWeek+" "+this.startDate.format("W");if(b){this.reload()}},nextDate:function(){return this.startDate.add(Date.DAY,this.days>4?7:1)},previousDate:function(){return this.startDate.add(Date.DAY,this.days>4?-7:-1)},reload:function(){this.load()},load:function(a){if(!a){a={}}a.task="view_events";a.view_id=this.view_id;a.start_time=this.startDate.format(this.dateTimeFormat);a.end_time=this.endDate.format(this.dateTimeFormat);this.mask();Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:a,callback:function(k,h,c){if(!h){Ext.MessageBox.alert(GO.lang.strError,c.result.feedback)}else{this.jsonData=Ext.decode(c.responseText);this.clearGrid();this.renderView();var e=0;var f=0;for(var b=0;b<this.jsonData.results.length;b++){var j=this.jsonData.results[b].events;e+=j.length;for(var d=0;d<j.length;d++){var g=j[d];g.startDate=Date.parseDate(j[d]["start_time"],this.dateTimeFormat);g.endDate=Date.parseDate(j[d]["end_time"],this.dateTimeFormat);this.addViewGridEvent(g);if(g.mtime>f){f=g.mtime}}}this.nextId=e;this.fireEvent("storeload",this,e,f,a,c)}this.unmask()},scope:this})},registerEvent:function(b,a){this.remoteEvents[b]=a},getEventDomElements:function(a){return GO.util.clone(this.domIds[a])},getRelatedDomElements:function(c){var b=this.remoteEvents[c];if(!b){return false}var a=this.getEventDomElements(b.id);if(!a){a=[c]}return a},elementToEvent:function(a,b){this.remoteEvents[a].domId=a;return this.remoteEvents[a]}});GO.calendar.dd.ViewDragZone=function(b,a){a=a||{};Ext.apply(a,{ddel:document.createElement("div")});GO.calendar.dd.ViewDragZone.superclass.constructor.call(this,b,a)};Ext.extend(GO.calendar.dd.ViewDragZone,Ext.dd.DragZone,{onInitDrag:function(c){this.ddel.innerHTML=this.dragData.item.dom.innerHTML;this.ddel.className=this.dragData.item.dom.className;this.ddel.style.width=this.dragData.item.getWidth()+"px";this.proxy.update(this.ddel);this.eventDomElements=this.viewGrid.getRelatedDomElements(this.dragData.item.id);this.eventProxies=[];this.proxyDragPos=0;for(var a=0;a<this.eventDomElements.length;a++){this.eventProxies.push(Ext.DomHelper.append(document.body,{tag:"div",id:Ext.id(),cls:"x-viewGrid-event-proxy",style:"width:"+this.ddel.style.width+"px;"},true));if(this.eventDomElements[a]==this.dragData.item.id){this.proxyDragPos=a}else{var b=Ext.get(this.eventDomElements[a]);if(b){b.setStyle({position:"absolute",top:-10000,display:"none"})}}}},removeEventProxies:function(){var a=Ext.query("div.x-viewGrid-event-proxy");for(var b=0;b<a.length;b++){Ext.get(a[b]).remove()}delete this.lastTdOverId;for(var b=0;b<this.eventDomElements.length;b++){var c=Ext.get(this.eventDomElements[b]);if(c){c.setStyle({position:"static",top:"",display:"block"})}}},afterRepair:function(){GO.calendar.dd.ViewDragZone.superclass.afterRepair.call(this);this.removeEventProxies()},getRepairXY:function(b,a){a.item.highlight("#e8edff");return a.item.getXY()},getDragData:function(h){var g=Ext.get(h.getTarget());if(g.hasClass("x-viewGrid-event-container")){var i=g.parent();var a=i.id.indexOf("_day")+4;var d=i.id.substr(3,a-7);var f=this.viewGrid.getCalendar(d);if(!this.viewGrid.remoteEvents[g.id]["private"]&&f.write_permission){var b=i.id.substr(a);var c=Date.parseDate(b,"Ymd");return{ddel:this.ddel,item:g,dragDate:c}}return false}}});GO.calendar.dd.ViewDropTarget=function(b,a){GO.calendar.dd.ViewDropTarget.superclass.constructor.call(this,b,a)};Ext.extend(GO.calendar.dd.ViewDropTarget,Ext.dd.DropTarget,{notifyDrop:function(i,h,f){var c=Ext.get(h.getTarget()).findParent("td",10,true);if(!c){return false}var j=c.id.indexOf("_day")+4;var g=c.id.substr(3,j-7);var d=this.scope.getCalendar(g);if(!d||!d.write_permission){return false}var b=c.id.substr(j);f.dropDate=Date.parseDate(b,"Ymd");f.calendar_id=c.id.substr(3,j-7);i.removeEventProxies();this.el.removeClass(this.overClass);c.appendChild(f.item);if(this.onNotifyDrop){if(!this.scope){this.scope=this}var a=this.onNotifyDrop.createDelegate(this.scope);a.call(this,i,h,f)}return true},notifyOver:function(j,g,d){var h=Ext.get(g.getTarget()).findParent("td.x-viewGrid-cell",10,true);if(h){var l=h.id.indexOf("_day");var f=h.id.substr(3,l-3);var c=this.scope.getCalendar(f);if(c&&c.write_permission){if(j.lastTdOverId!=h.id){var k=h;for(var b=0;b<j.proxyDragPos;b++){if(k){var a=k.prev("td.x-viewGrid-cell");k=a}if(a){a.insertFirst(j.eventProxies[b].id);j.eventProxies[b].setStyle({position:"static",top:"",display:"block"})}else{j.eventProxies[b].setStyle({position:"absolute",top:-10000,display:"none"})}}h.insertFirst(j.eventProxies[b]);var k=h;for(var b=j.proxyDragPos+1;b<j.eventProxies.length;b++){if(k){var a=k.next("td.x-viewGrid-cell");k=a}if(a){a.insertFirst(j.eventProxies[b].id);j.eventProxies[b].setStyle({position:"static",top:"",display:"block"})}else{j.eventProxies[b].setStyle({position:"absolute",top:-10000,display:"none"})}}}j.lastTdOverId=h.id;return this.dropAllowed}}return false}});GO.calendar.CalendarDialog=function(b){if(!b){b={}}this.propertiesTab=new Ext.form.FormPanel({url:GO.settings.modules.calendar.url+"action.php",defaultType:"textfield",waitMsgTarget:true,title:GO.lang.strProperties,layout:"form",anchor:"100% 100%",autoHeight:true,cls:"go-form-panel",labelWidth:120,items:[this.selectUser=new GO.form.SelectUser({fieldLabel:GO.lang.strUser,disabled:!GO.settings.has_admin_permission,value:GO.settings.user_id,anchor:"100%"}),this.name=new Ext.form.TextField({fieldLabel:GO.lang.strName,name:"name",allowBlank:false,anchor:"100%"}),this.selectGroup=new GO.form.ComboBox({hiddenName:"group_id",fieldLabel:GO.calendar.lang.group,valueField:"id",displayField:"name",id:"resource_groups",emptyText:GO.lang.strPleaseSelect,store:GO.calendar.groupsStore,mode:"local",triggerAction:"all",editable:false,selectOnFocus:true,allowBlank:true,forceSelection:true,anchor:"100%"}),{xtype:"checkbox",name:"show_bdays",boxLabel:GO.calendar.lang.show_bdays,hideLabel:true},{xtype:"textarea",fieldLabel:GO.lang.strComment,name:"comment",anchor:"100%",height:50}]});if(GO.tasks){this.tasklistsTab=new GO.calendar.TasklistsGrid({title:GO.tasks.lang.visibleTasklists});this.selectTasklist=new GO.form.ComboBoxReset({fieldLabel:"CalDAV "+GO.tasks.lang.tasklist,store:new GO.data.JsonStore({url:GO.settings.modules.tasks.url+"json.php",baseParams:{task:"tasklists",auth_type:"write"},root:"results",totalProperty:"total",id:"id",fields:["id","name","user_name"],remoteSort:true}),displayField:"name",valueField:"id",triggerAction:"all",hiddenName:"tasklist_id",mode:"remote",editable:true,selectOnFocus:true,forceSelection:true,typeAhead:true,emptyText:GO.lang.none,pageSize:parseInt(GO.settings.max_rows_list)});this.propertiesTab.add(this.selectTasklist)}this.propertiesTab.add([{xtype:"plainfield",fieldLabel:"Direct URL",name:"url",anchor:"100%"},{xtype:"checkbox",hideLabel:true,boxLabel:GO.calendar.lang.publishICS,name:"public"},{xtype:"plainfield",fieldLabel:"iCalendar URL",name:"ics_url",anchor:"100%"},this.exportButton=new Ext.Button({text:GO.lang.cmdExport,disabled:true,handler:function(){document.location=GO.settings.modules.calendar.url+"export.php?calendar_id="+this.calendar_id},scope:this})]);this.readPermissionsTab=new GO.grid.PermissionsPanel({});var c=new GO.form.UploadFile({inputName:"ical_file",max:1});c.on("filesChanged",function(e,d){this.importButton.setDisabled(d.getCount()==1)},this);this.importTab=new Ext.form.FormPanel({fileUpload:true,waitMsgTarget:true,disabled:true,title:GO.lang.cmdImport,items:[{xtype:"panel",html:GO.calendar.lang.selectIcalendarFile,border:false},c,this.importButton=new Ext.Button({xtype:"button",disabled:true,text:GO.lang.cmdImport,handler:function(){this.importTab.form.submit({waitMsg:GO.lang.waitMsgUpload,url:GO.settings.modules.calendar.url+"action.php",params:{task:"import",calendar_id:this.calendar_id},success:function(d,e){c.clearQueue();if(e.result.success){Ext.MessageBox.alert(GO.lang.strSuccess,e.result.feedback);this.fireEvent("calendarimport",this)}else{Ext.MessageBox.alert(GO.lang.strError,e.result.feedback)}},failure:function(d,e){Ext.MessageBox.alert(GO.lang.strError,e.result.feedback)},scope:this})},scope:this})],cls:"go-form-panel"});var a=[this.propertiesTab];if(GO.tasks){a.push(this.tasklistsTab)}a.push(this.readPermissionsTab);a.push(this.importTab);this.tabPanel=new Ext.TabPanel({hideLabel:true,deferredRender:false,xtype:"tabpanel",activeTab:0,border:false,anchor:"100% 100%",items:a});GO.calendar.CalendarDialog.superclass.constructor.call(this,{title:GO.calendar.lang.calendar,layout:"fit",modal:false,height:500,width:500,closeAction:"hide",items:this.tabPanel,buttons:[{text:GO.lang.cmdOk,handler:function(){this.save(true)},scope:this},{text:GO.lang.cmdApply,handler:function(){this.save(false)},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}]});this.addEvents({calendarimport:true})};Ext.extend(GO.calendar.CalendarDialog,GO.Window,{resource:0,initComponent:function(){this.addEvents({save:true});GO.calendar.CalendarDialog.superclass.initComponent.call(this)},show:function(a,b){if(!this.rendered){this.render(Ext.getBody())}this.propertiesTab.show();if(b&&!this.selectGroup.store.loaded){this.selectGroup.store.load()}this.resource=(b>0)?b:0;var c=(this.resource)?GO.calendar.lang.resource:GO.calendar.lang.calendar;this.setTitle(c);if(a>0){if(a!=this.calendar_id){this.loadCalendar(a)}else{GO.calendar.CalendarDialog.superclass.show.call(this)}}else{this.calendar_id=0;this.propertiesTab.form.reset();if(b){this.selectGroup.selectFirst()}else{this.selectGroup.setValue(0)}this.exportButton.setDisabled(true);this.importTab.setDisabled(true);this.readPermissionsTab.setDisabled(true);this.showGroups(b);GO.calendar.CalendarDialog.superclass.show.call(this)}},loadCalendar:function(a){if(GO.tasks){this.tasklistsTab.store.loaded=false;this.tasklistsTab.store.baseParams.calendar_id=a}this.propertiesTab.form.load({url:GO.settings.modules.calendar.url+"json.php",params:{calendar_id:a,task:"calendar"},waitMsg:GO.lang.waitMsgLoad,success:function(b,c){this.calendar_id=a;this.selectUser.setRawValue(c.result.data.user_name);this.readPermissionsTab.setAcl(c.result.data.acl_id);this.exportButton.setDisabled(false);this.importTab.setDisabled(false);if(c.result.data.tasklist_name){this.selectTasklist.setRemoteText(c.result.data.tasklist_name)}this.showGroups(c.result.data.group_id>1);GO.calendar.CalendarDialog.superclass.show.call(this)},failure:function(b,c){Ext.Msg.alert(GO.lang.strError,c.result.feedback)},scope:this})},save:function(a){if(this.resource&&this.name.getValue()&&!this.selectGroup.getValue()){Ext.MessageBox.alert(GO.lang.strError,GO.calendar.lang.no_group_selected)}else{var b=(GO.tasks&&!this.resource)?Ext.encode(this.tasklistsTab.getGridData()):"";this.propertiesTab.form.submit({url:GO.settings.modules.calendar.url+"action.php",params:{task:"save_calendar",calendar_id:this.calendar_id,tasklists:b},waitMsg:GO.lang.waitMsgSave,success:function(c,d){if(d.result.calendar_id){this.calendar_id=d.result.calendar_id;this.readPermissionsTab.setAcl(d.result.acl_id);this.exportButton.setDisabled(false);this.importTab.setDisabled(false)}if(GO.tasks){this.tasklistsTab.store.commitChanges()}this.fireEvent("save",this,this.selectGroup.getValue());if(a){this.hide()}},failure:function(d,e){var c="";if(e.failureType=="client"){c=GO.lang.strErrorsInForm}else{c=e.result.feedback}Ext.MessageBox.alert(GO.lang.strError,c)},scope:this})}},showGroups:function(b){var a=this.propertiesTab.form.findField("resource_groups");a.container.up("div.x-form-item").setDisplayed(b);a=this.propertiesTab.form.findField("show_bdays");a.container.up("div.x-form-item").setDisplayed(!b);if(GO.tasks){if(b){this.tabPanel.hideTabStripItem("calendar_visible_tasklists")}else{this.tabPanel.unhideTabStripItem("calendar_visible_tasklists")}}}});GO.calendar.ViewDialog=function(b){if(!b){b={}}var a=new GO.grid.CheckColumn({header:"&nbsp;",dataIndex:"selected",width:55});this.calendarsStore=new Ext.data.GroupingStore({baseParams:{task:"view_calendars",view_id:this.view_id},reader:new Ext.data.JsonReader({root:"results",id:"id",totalProperty:"total",fields:["id","name","user_name","selected","group_name"]}),proxy:new Ext.data.HttpProxy({url:GO.settings.modules.calendar.url+"json.php"}),sortInfo:{field:"name",direction:"ASC"},groupField:"group_name",remoteSort:true});this.calendarsGrid=new GO.grid.GridPanel({region:"center",layout:"fit",paging:false,border:false,split:true,plugins:a,store:this.calendarsStore,columns:[a,{header:GO.lang.strName,dataIndex:"name"},{header:GO.lang.strOwner,dataIndex:"user_name"},{header:GO.calendar.lang.group,dataIndex:"group_name",id:"group_name",hidden:true}],view:new Ext.grid.GroupingView({autoFill:true,forceFit:true,groupTextTpl:"{text}",emptyText:GO.lang.strNoItems}),sm:new Ext.grid.RowSelectionModel(),loadMask:true});this.propertiesTab=new Ext.Panel({title:GO.lang.strProperties,layout:"border",items:[new Ext.Panel({layout:"form",region:"north",height:110,defaultType:"textfield",defaults:{anchor:"100%"},cls:"go-form-panel",waitMsgTarget:true,labelWidth:75,border:false,items:[this.selectUser=new GO.form.SelectUser({fieldLabel:GO.lang.strUser,disabled:!GO.settings.modules.calendar["write_permission"]}),{fieldLabel:GO.lang.strName,name:"name",allowBlank:false},this.merge=new Ext.form.Checkbox({name:"merge",boxLabel:GO.calendar.lang.merge,hideLabel:true}),GO.calendar.ownColor=new Ext.form.Checkbox({name:"owncolor",boxLabel:GO.calendar.lang.ownColor,hideLabel:true,disabled:true,checked:true})]}),this.calendarsGrid]});this.readPermissionsTab=new GO.grid.PermissionsPanel({});this.formPanel=new Ext.form.FormPanel({url:GO.settings.modules.calendar.url+"action.php",defaultType:"textfield",waitMsgTarget:true,border:false,items:[{hideLabel:true,deferredRender:false,xtype:"tabpanel",activeTab:0,border:false,anchor:"100% 100%",items:[this.propertiesTab,this.readPermissionsTab]}]});GO.calendar.ViewDialog.superclass.constructor.call(this,{title:GO.calendar.lang.view,layout:"fit",modal:false,height:500,width:400,closeAction:"hide",items:this.formPanel,buttons:[{text:GO.lang.cmdOk,handler:function(){this.save(true)},scope:this},{text:GO.lang.cmdApply,handler:function(){this.save(false)},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}]});this.merge.on("check",function(d,c){if(c){GO.calendar.ownColor.setDisabled(false)}else{GO.calendar.ownColor.setDisabled(true)}})};Ext.extend(GO.calendar.ViewDialog,GO.Window,{initComponent:function(){this.addEvents({save:true});GO.calendar.ViewDialog.superclass.initComponent.call(this)},show:function(a){if(!this.rendered){this.render(Ext.getBody())}if(a>0){if(a!=this.view_id){this.loadView(a)}else{GO.calendar.ViewDialog.superclass.show.call(this)}}else{this.view_id=0;this.formPanel.form.reset();this.propertiesTab.show();this.readPermissionsTab.setDisabled(true);this.calendarsStore.baseParams.view_id=0;this.calendarsStore.reload();GO.calendar.ViewDialog.superclass.show.call(this)}},loadView:function(a){this.formPanel.form.load({url:GO.settings.modules.calendar.url+"json.php",params:{view_id:a,task:"view"},waitMsg:GO.lang.waitMsgLoad,success:function(b,c){this.view_id=a;this.selectUser.setRawValue(c.result.data.user_name);this.readPermissionsTab.setAcl(c.result.data.acl_id);this.calendarsStore.baseParams.view_id=a;this.calendarsStore.reload();GO.calendar.ViewDialog.superclass.show.call(this)},failure:function(b,c){Ext.Msg.alert(GO.lang.strError,c.result.feedback)},scope:this})},save:function(b){var c=[];for(var a=0;a<this.calendarsStore.data.items.length;a++){if(this.calendarsStore.data.items[a].get("selected")=="1"){c.push(this.calendarsStore.data.items[a].get("id"))}}this.formPanel.form.submit({url:GO.settings.modules.calendar.url+"action.php",params:{task:"save_view",view_id:this.view_id,merge:this.merge,view_calendars:Ext.encode(c)},waitMsg:GO.lang.waitMsgSave,success:function(d,e){if(e.result.view_id){this.view_id=e.result.view_id;this.readPermissionsTab.setAcl(e.result.acl_id)}this.fireEvent("save");if(b){this.hide()}},failure:function(e,f){var d="";if(f.failureType=="client"){d=GO.lang.strErrorsInForm}else{d=f.result.feedback}Ext.MessageBox.alert(GO.lang.strError,d)},scope:this})}});GO.calendar.SummaryGroupPanel=function(a){if(!a){a={}}a.store=new Ext.data.GroupingStore({reader:new Ext.data.JsonReader({totalProperty:"count",root:"results",id:"id",fields:["id","event_id","name","time","start_time","end_time","description","location","private","repeats","day","calendar_name"]}),baseParams:{task:"summary",user_id:GO.settings.user_id,portlet:true},proxy:new Ext.data.HttpProxy({url:GO.settings.modules.calendar.url+"json.php"}),groupField:"day",sortInfo:{field:"id",direction:"ASC"},remoteGroup:true,remoteSort:true});a.store.on("load",function(){this.ownerCt.ownerCt.ownerCt.doLayout()},this);a.paging=false,a.autoExpandColumn="summary-calendar-name-heading";a.columns=[{header:GO.lang.strDay,dataIndex:"day"},{header:GO.lang.strTime,dataIndex:"time",width:100,align:"right",groupable:false},{id:"summary-calendar-name-heading",header:GO.lang.strName,dataIndex:"name",renderer:function(c,d,b){d.attr='ext:qtip="'+Ext.util.Format.htmlEncode(GO.calendar.formatQtip(b.data))+'"';return c},groupable:false},{header:GO.calendar.lang.calendar,dataIndex:"calendar_name",width:140}];a.view=new Ext.grid.GroupingView({scrollOffset:2,hideGroupedColumn:true,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'+GO.lang.items+'" : "'+GO.lang.item+'"]})',emptyText:GO.calendar.lang.noAppointmentsToDisplay,showGroupName:false});a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;a.autoHeight=true;GO.calendar.SummaryGroupPanel.superclass.constructor.call(this,a)};Ext.extend(GO.calendar.SummaryGroupPanel,Ext.grid.GridPanel,{afterRender:function(){GO.calendar.SummaryGroupPanel.superclass.afterRender.call(this);GO.dialogListeners.add("event",{save:function(){this.store.reload()},scope:this});this.on("rowdblclick",function(b,c,d){var a=b.store.getAt(c);if(a.data.contact_id){GO.linkHandlers[2].call(this,a.data.contact_id)}else{GO.calendar.showEventDialog({event_id:a.data.event_id})}},this);Ext.TaskMgr.start({run:function(){this.store.load()},scope:this,interval:900000})}});GO.mainLayout.onReady(function(){if(GO.summary){var a=new GO.calendar.SummaryGroupPanel({});GO.summary.portlets["portlet-calendar"]=new GO.summary.Portlet({id:"portlet-calendar",title:GO.calendar.lang.appointments,layout:"fit",tools:[{id:"gear",handler:function(){if(!this.manageCalsWindow){this.manageCalsWindow=new Ext.Window({layout:"fit",items:this.PortletSettings=new GO.calendar.PortletSettings(),width:700,height:400,title:GO.calendar.lang.visibleCalendars,closeAction:"hide",buttons:[{text:GO.lang.cmdSave,handler:function(){var b={task:"save_portlet"};if(this.PortletSettings.store.loaded){b.calendars=Ext.encode(this.PortletSettings.getGridData())}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"action.php",params:b,callback:function(d,e,c){if(!e){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{this.PortletSettings.store.reload();this.manageCalsWindow.hide();a.store.reload()}},scope:this})},scope:this}],listeners:{show:function(){if(!this.PortletSettings.store.loaded){this.PortletSettings.store.load()}},scope:this}})}this.manageCalsWindow.show()}},{id:"close",handler:function(d,c,b){b.removePortlet()}}],items:a,autoHeight:true})}});GO.calendar.Participant=Ext.data.Record.create([{name:"id",type:"string"},{name:"name",type:"string"},{name:"email",type:"string"},{name:"available",type:"string"},{name:"status",type:"string"},{name:"is_organizer",type:"int"}]);GO.calendar.ParticipantsPanel=function(a,b){this.eventDialog=a;if(!b){b={}}b.hideMode="offsets";b.store=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"participants"},root:"results",id:"id",fields:["id","name","email","available","status","user_id","is_organizer"]});var c=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){this.showAddParticipantsDialog()},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){var e=this.gridPanel.selModel.getSelections();for(var d=0;d<e.length;d++){e[d].commit();this.store.remove(e[d])}},scope:this},{iconCls:"btn-availability",text:GO.calendar.lang.checkAvailability,cls:"x-btn-text-icon",handler:function(){this.checkAvailability()},scope:this}];this.importCheckbox=new Ext.form.Checkbox({name:"import",boxLabel:GO.calendar.lang.importToCalendar,hideLabel:true});this.checkPanel=new Ext.Panel({border:true,region:"north",height:40,layout:"column",defaults:{border:false,bodyStyle:"padding:5px"},items:[{columnWidth:0.5,items:[this.importCheckbox]}]});this.gridPanel=new GO.grid.GridPanel({layout:"fit",split:true,store:b.store,border:true,region:"center",columns:[{header:GO.lang.strName,dataIndex:"name",sortable:true},{header:GO.lang.strEmail,dataIndex:"email",sortable:true},{header:GO.lang.strStatus,dataIndex:"status",sortable:true,renderer:function(d){switch(d){case"3":return GO.calendar.lang.tentative;break;case"2":return GO.calendar.lang.declined;break;case"1":return GO.calendar.lang.accepted;break;case"0":return GO.calendar.lang.notRespondedYet;break}}},{header:GO.lang.strAvailable,dataIndex:"available",sortable:false,renderer:function(d){var e="img-unknown";switch(d){case"1":e="img-available";break;case"0":e="img-unavailable";break}return'<div class="'+e+'"></div>'}},{header:GO.calendar.lang.isOrganizer,dataIndex:"is_organizer",sortable:false,renderer:function(d){var e="img-unknown";switch(d){case"1":e="img-available";break;case"0":e="img-unavailable";break}return'<div class="'+e+'"></div>'}}],view:new Ext.grid.GridView({autoFill:true,forceFit:true}),loadMask:{msg:GO.lang.waitMsgLoad},sm:new Ext.grid.RowSelectionModel()});Ext.apply(b,{title:GO.calendar.lang.participants,border:false,tbar:c,layout:"border",items:[this.checkPanel,this.gridPanel]});b.store.setDefaultSort("name","ASC");GO.calendar.ParticipantsPanel.superclass.constructor.call(this,b)};Ext.extend(GO.calendar.ParticipantsPanel,Ext.Panel,{event_id:0,newId:0,loaded:false,getGridData:function(){return this.gridPanel.getGridData()},setEventId:function(a){this.event_id=this.store.baseParams.event_id=a;this.store.loaded=false;if(this.event_id==0){this.store.removeAll()}this.newId=0;this.importCheckbox.setValue(false);if(this.isVisible()){this.store.reload()}},onShow:function(){if(!this.store.loaded){if(this.store.baseParams.event_id>0){this.store.load()}else{this.addDefaultParticipant()}}GO.calendar.ParticipantsPanel.superclass.onShow.call(this)},showAddParticipantsDialog:function(){if(!this.addParticipantsDialog){this.addParticipantsDialog=new GO.dialog.SelectEmail({handler:function(c,f){if(c.selModel.selections.keys.length>0){var e=c.selModel.getSelections();if(f=="mailings"||f=="usergroups"){var d=new Array();for(var b=0;b<e.length;b++){d.push(e[b].data.id)}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:f+"_participants",ids:Ext.encode(d)},callback:function(h,l,g){if(!l){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var m=[];var k=Ext.decode(g.responseText);for(var j=0;j<k.results.length;j++){m.push(k.results[j].email)}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:"check_availability",emails:m.join(","),start_time:this.eventDialog.getStartDate().format("U"),end_time:this.eventDialog.getEndDate().format("U")},callback:function(p,s,r){if(!s){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var n=Ext.decode(r.responseText);for(var q=0;q<k.results.length;q++){var o=this.store.findBy(function(i,t){if(i.get("email")==k.results[q].email){return true}else{return false}});if(o==-1){this.addParticipant({name:k.results[q].name,email:k.results[q].email,status:"0",user_id:k.results[q].user_id,available:n[k.results[q].email]})}}}},scope:this})}},scope:this})}else{var a=[];for(var b=0;b<e.length;b++){a.push(e[b].get("email"))}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:"check_availability",emails:a.join(","),start_time:this.eventDialog.getStartDate().format("U"),end_time:this.eventDialog.getEndDate().format("U")},callback:function(j,m,h){if(!m){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var l=Ext.decode(h.responseText);for(var k=0;k<e.length;k++){var g=this.store.findBy(function(i,n){if(i.get("email")==e[k].get("email")){return true}else{return false}});if(g==-1){this.addParticipant({name:e[k].get("name"),email:e[k].get("email"),status:"0",user_id:f=="users"?e[k].get("id"):0,available:l[e[k].get("email")]})}}}},scope:this})}}},scope:this})}this.addParticipantsDialog.show()},addDefaultParticipant:function(){this.body.mask(GO.lang.waitMsgLoad);Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:"get_default_participant",calendar_id:this.eventDialog.selectCalendar.getValue(),start_time:this.eventDialog.getStartDate().format("U"),end_time:this.eventDialog.getEndDate().format("U")},callback:function(b,d,a){this.body.unmask();if(!d){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var c=Ext.decode(a.responseText);this.addParticipant({name:c.name,email:c.email,status:c.status,user_id:c.user_id,available:c.available,is_organizer:c.is_organizer})}},scope:this})},addParticipant:function(a){a.id="new_"+this.newId;var b=new GO.calendar.Participant(a);this.store.insert(this.store.getCount(),b);this.newId++;this.store.loaded=true},reloadAvailability:function(){var c=this.store.getRange();if(c.length){var a=[];for(var b=0;b<c.length;b++){a.push(c[b].get("email"))}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:"check_availability",emails:a.join(","),start_time:this.eventDialog.getStartDate().format("U"),end_time:this.eventDialog.getEndDate().format("U")},callback:function(e,h,d){if(!h){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var g=Ext.decode(d.responseText);for(var f=0;f<c.length;f++){c[f].set("available",g[c[f].get("email")])}this.store.commitChanges()}},scope:this})}},checkAvailability:function(){if(!this.availabilityWindow){this.availabilityWindow=new GO.calendar.AvailabilityCheckWindow();this.availabilityWindow.on("select",function(h,i,j){var l=this.eventDialog;l.startDate.setValue(Date.parseDate(h.store.baseParams.date,GO.settings.date_format));l.endDate.setValue(Date.parseDate(h.store.baseParams.date,GO.settings.date_format));var g=Date.parseDate(l.startTime.getValue(),GO.settings.time_format);var f=Date.parseDate(l.endTime.getValue(),GO.settings.time_format);var e=f.getElapsed(g);var k=Date.parseDate(j.id.substr(4),"G:i");l.startTime.setValue(k.format(GO.settings.time_format));l.endTime.setValue(k.add(Date.MILLI,e).format(GO.settings.time_format));l.tabPanel.setActiveTab(0);this.reloadAvailability();this.availabilityWindow.hide()},this)}var a=this.store.getRange();var d=[];var c=[];for(var b=0;b<a.length;b++){d.push(a[b].get("email"));c.push(a[b].get("name"))}this.availabilityWindow.show({date:this.eventDialog.startDate.getRawValue(),event_id:this.event_id,emails:Ext.encode(d),names:Ext.encode(c)})}});GO.calendar.AvailabilityCheckWindow=function(b){b=b||{};var a=new Ext.XTemplate('<div id="availability_date"></div>','<table class="availability">',"<tr><td></td>",'<td colspan="4" class="availability_time">'+Date.parseDate("0","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("1","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("2","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("3","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("4","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("5","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("6","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("7","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("8","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("9","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("10","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("11","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("12","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("13","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("14","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("15","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("16","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("17","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("18","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("19","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("20","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("21","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("22","G").format(GO.settings.time_format)+"</td>",'<td colspan="4" class="availability_time">'+Date.parseDate("23","G").format(GO.settings.time_format)+"</td>",'<tpl for=".">',"<tr>","<td>{name}</td>",'<tpl if="this.hasFreeBusy(freebusy)">','<tpl for="freebusy">','<td id="time{time}"class="time {[values.busy == 1 ? "busy" : "free"]}"></td>',"</tpl>","</tpl>",'<tpl if="!this.hasFreeBusy(freebusy)">','<td colspan="96">'+GO.calendar.lang.noInformationAvailable+"</td>","</tpl>","</tr>","</tpl>","</table>",{hasFreeBusy:function(c){return c.length>0}});this.dataView=new Ext.DataView({store:new Ext.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",root:"participants",fields:["name","email","freebusy"],baseParams:{task:"availability",emails:"",names:"",event_id:0,date:""}}),tpl:a,autoHeight:true,emptyText:GO.calendar.lang.noParticipantsToDisplay,itemSelector:"td.time",overClass:"time-over"});this.dataView.on("click",function(c,d,e){this.fireEvent("select",c,d,e)},this);this.dataView.store.on("load",function(){Ext.get("availability_date").update(this.dataView.store.baseParams.date)},this);Ext.apply(b,{layout:"fit",modal:false,height:400,width:900,closeAction:"hide",title:GO.lang.strAvailability,items:{layout:"fit",cls:"go-form-panel",waitMsgTarget:true,items:this.dataView,autoScroll:true},tbar:[{iconCls:"btn-left-arrow",text:GO.calendar.lang.previousDay,cls:"x-btn-text-icon",handler:function(){var c=Date.parseDate(this.dataView.store.baseParams.date,GO.settings.date_format).add(Date.DAY,-1);this.dataView.store.baseParams.date=c.format(GO.settings.date_format);this.dataView.store.load()},scope:this},{iconCls:"btn-right-arrow",text:GO.calendar.lang.nextDay,cls:"x-btn-text-icon",handler:function(){var c=Date.parseDate(this.dataView.store.baseParams.date,GO.settings.date_format).add(Date.DAY,1);this.dataView.store.baseParams.date=c.format(GO.settings.date_format);this.dataView.store.load()},scope:this}],buttons:[{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}]});GO.calendar.AvailabilityCheckWindow.superclass.constructor.call(this,b);this.addEvents({select:true})};Ext.extend(GO.calendar.AvailabilityCheckWindow,GO.Window,{show:function(a){this.dataView.store.baseParams.date=a.date;this.dataView.store.baseParams.event_id=a.event_id;this.dataView.store.baseParams.emails=a.emails;this.dataView.store.baseParams.names=a.names;this.dataView.store.load();GO.calendar.AvailabilityCheckWindow.superclass.show.call(this)}});GO.calendar.SettingsPanel=function(a){if(!a){a={}}var c=[["0",GO.calendar.lang.noReminder]];for(var b=1;b<60;b++){c.push([b,b])}this.reminderValue=new Ext.form.ComboBox({fieldLabel:GO.calendar.lang.reminder,hiddenName:"reminder_value",triggerAction:"all",editable:false,selectOnFocus:true,width:148,forceSelection:true,mode:"local",value:"0",valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:c})});this.reminderMultiplier=new Ext.form.ComboBox({hiddenName:"reminder_multiplier",triggerAction:"all",editable:false,selectOnFocus:true,width:148,forceSelection:true,mode:"local",value:"60",valueField:"value",displayField:"text",store:new Ext.data.SimpleStore({fields:["value","text"],data:[["60",GO.lang.strMinutes],["3600",GO.lang.strHours],["86400",GO.lang.strDays]]}),hideLabel:true,labelSeperator:""});a.autoScroll=true;a.border=false;a.hideLabel=true;a.title=GO.calendar.lang.calendar;a.hideMode="offsets";a.layout="form";a.labelWidth=140;a.bodyStyle="padding:5px";a.items=[{forceLayout:true,xtype:"fieldset",autoHeight:true,layout:"form",title:GO.calendar.lang.eventDefaults,items:[{border:false,layout:"table",defaults:{border:false,layout:"form",bodyStyle:"padding-right:3px"},items:[{items:this.reminderValue},{items:this.reminderMultiplier}]},this.colorField=new GO.form.ColorField({fieldLabel:GO.lang.color,value:"EBF1E2",name:"background",colors:["EBF1E2","95C5D3","FFFF99","A68340","82BA80","F0AE67","66FF99","CC0099","CC99FF","996600","999900","FF0000","FF6600","FFFF00","FF9966","FF9900","FB0467","D52A6F","CC3370","C43B72","BB4474","B34D75","AA5577","A25E79","FF00CC","D52AB3","CC33AD","C43BA8","BB44A3","B34D9E","AA5599","A25E94","CC00FF","B32AD5","AD33CC","A83BC4","A344BB","9E4DB3","9955AA","945EA2","6704FB","6E26D9","7033CC","723BC4","7444BB","754DB3","7755AA","795EA2","0404FB","2626D9","3333CC","3B3BC4","4444BB","4D4DB3","5555AA","5E5EA2","0066FF","2A6ED5","3370CC","3B72C4","4474BB","4D75B3","5577AA","5E79A2","00CCFF","2AB2D5","33ADCC","3BA8C4","44A3BB","4D9EB3","5599AA","5E94A2","00FFCC","2AD5B2","33CCAD","3BC4A8","44BBA3","4DB39E","55AA99","5EA294","00FF66","2AD56F","33CC70","3BC472","44BB74","4DB375","55AA77","5EA279","00FF00","2AD52A","33CC33","3BC43B","44BB44","4DB34D","55AA55","5EA25E","66FF00","6ED52A","70CC33","72C43B","74BB44","75B34D","77AA55","79A25E","CCFF00","B2D52A","ADCC33","A8C43B","A3BB44","9EB34D","99AA55","94A25E","FFCC00","D5B32A","CCAD33","C4A83B","BBA344","B39E4D","AA9955","A2945E","FF6600","D56F2A","CC7033","C4723B","BB7444","B3754D","AA7755","A2795E","FB0404","D52A2A","CC3333","C43B3B","BB4444","B34D4D","AA5555","A25E5E","FFFFFF","949494","808080","6B6B6B","545454","404040","292929","000000"]}),this.selectCalendar=new GO.form.ComboBox({fieldLabel:GO.calendar.lang.default_calendar,hiddenName:"default_calendar_id",anchor:"-20",emptyText:GO.lang.strPleaseSelect,store:new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"writable_calendars"},root:"results",id:"id",totalProperty:"total",fields:["id","name"],remoteSort:true}),pageSize:parseInt(GO.settings.max_rows_list),valueField:"id",displayField:"name",typeAhead:true,mode:"remote",triggerAction:"all",editable:false,selectOnFocus:true,forceSelection:true,allowBlank:false})]}];GO.calendar.SettingsPanel.superclass.constructor.call(this,a)};Ext.extend(GO.calendar.SettingsPanel,Ext.Panel,{onLoadSettings:function(a){this.selectCalendar.setRemoteText(a.result.data.default_calendar_name)},onSaveSettings:function(){if(GO.calendar.eventDialog){GO.calendar.eventDialog.reminderValue.originalValue=this.reminderValue.getValue();GO.calendar.eventDialog.reminderMultiplier.originalValue=this.reminderMultiplier.getValue();GO.calendar.eventDialog.colorField.originalValue=this.colorField.getValue()}else{GO.calendar.defaultReminderValue=this.reminderValue.getValue();GO.calendar.defaultReminderMultiplier=this.reminderMultiplier.getValue()}}});GO.mainLayout.onReady(function(){GO.moduleManager.addSettingsPanel("calendar",GO.calendar.SettingsPanel)});GO.calendar.SelectCalendar=function(a){a=a||{};if(!a.hiddenName){a.hiddenName="calendar_id"}if(!a.fieldLabel){a.fieldLabel=GO.calendar.lang.calendar}Ext.apply(this,a);this.store=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"writable_calendars",show_all:true},root:"results",totalProperty:"total",id:"id",fields:["id","name","group_name","user_name","group_id","fields"],remoteSort:true});if(!a.emptyText){this.emptyText=GO.lang.strPleaseSelect}GO.calendar.SelectCalendar.superclass.constructor.call(this,{displayField:"name",valueField:"id",triggerAction:"all",editable:true,selectOnFocus:true,forceSelection:true,typeAhead:true,pageSize:parseInt(GO.settings.max_rows_list),mode:"remote",tpl:new Ext.XTemplate("<h1></h1>",'<tpl for=".">','<tpl if="this.group_name != values.group_name">','<tpl exec="this.group_name = values.group_name"></tpl>',"<h1>{group_name}</h1>","</tpl>",'<div class="x-combo-list-item">{name}</div>',"</tpl>")})};Ext.extend(GO.calendar.SelectCalendar,GO.form.ComboBox,{});GO.calendar.GroupsGrid=function(a){if(!a){a={}}a.title=GO.calendar.lang.resource_groups;a.layout="fit";a.autoScroll=true;a.split=true;a.paging=true;var b=new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{header:GO.lang.strName,dataIndex:"name"},{header:GO.lang.strOwner,dataIndex:"user_name",sortable:false}]});a.cm=b;a.view=new Ext.grid.GridView({autoFill:true,forceFit:true,emptyText:GO.lang.strNoItems});a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;a.tbar=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){GO.calendar.groupDialog.show()},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.deleteSelected()},scope:this}];GO.calendar.GroupsGrid.superclass.constructor.call(this,a);this.on("rowdblclick",function(d,e){var c=d.getStore().getAt(e);GO.calendar.groupDialog.show(c.data.id)},this);this.on("show",function(){if(!this.store.loaded){this.store.load()}},this,{single:true})};Ext.extend(GO.calendar.GroupsGrid,GO.grid.GridPanel);GO.calendar.GroupDialog=function(b){if(!b){b={}}this.buildForm();var a=function(){this.propertiesPanel.items.items[0].focus()};b.collapsible=true;b.maximizable=true;b.layout="fit";b.modal=false;b.resizable=false;b.width=500;b.height=450;b.closeAction="hide";b.title=GO.calendar.lang.resource_group;b.items=this.formPanel;b.focus=a.createDelegate(this);b.buttons=[{text:GO.lang.cmdOk,handler:function(){this.submitForm(true)},scope:this},{text:GO.lang.cmdApply,handler:function(){this.submitForm()},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}];GO.calendar.GroupDialog.superclass.constructor.call(this,b);this.addEvents({save:true})};Ext.extend(GO.calendar.GroupDialog,GO.Window,{show:function(b,a){if(!this.rendered){this.render(Ext.getBody())}this.formPanel.form.reset();this.tabPanel.setActiveTab(0);if(!b){b=0}this.setGroupId(b);if(this.group_id>0){this.formPanel.load({url:GO.settings.modules.calendar.url+"json.php",waitMsg:GO.lang.waitMsgLoad,success:function(c,d){this.groupAdminsPanel.setGroupId(d.result.data.id);this.selectUser.setRemoteText(d.result.data.user_name);if(this.group_id==1){this.tabPanel.hideTabStripItem("permissions-panel");this.selectUser.setDisabled(true);this.setTitle(GO.calendar.lang.calendar_group)}else{this.tabPanel.unhideTabStripItem("permissions-panel");this.selectUser.setDisabled(false);this.setTitle(GO.calendar.lang.resource_group)}GO.calendar.GroupDialog.superclass.show.call(this)},failure:function(c,d){Ext.Msg.alert(GO.lang.strError,d.result.feedback)},scope:this})}else{this.groupAdminsPanel.setGroupId(0);GO.calendar.GroupDialog.superclass.show.call(this)}},setGroupId:function(a){this.formPanel.form.baseParams.group_id=a;this.group_id=a},submitForm:function(a){this.formPanel.form.submit({url:GO.settings.modules.calendar.url+"action.php",params:{task:"save_group"},waitMsg:GO.lang.waitMsgSave,success:function(c,d){if(d.result.group_id){this.groupAdminsPanel.setGroupId(d.result.group_id);this.setGroupId(d.result.group_id)}var b=(this.group_id==1)?d.result.fields:false;this.fireEvent("save",this,this.group_id,b);if(a){this.hide()}},failure:function(b,c){if(c.failureType=="client"){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strErrorsInForm)}else{Ext.MessageBox.alert(GO.lang.strError,c.result.feedback)}},scope:this})},buildForm:function(){this.propertiesPanel=new Ext.Panel({title:GO.lang.strProperties,cls:"go-form-panel",layout:"form",autoScroll:true,items:[this.selectUser=new GO.form.SelectUser({fieldLabel:GO.lang.strUser,disabled:!GO.settings.modules.calendar["write_permission"],value:GO.settings.user_id,anchor:"100%"}),{xtype:"textfield",name:"name",anchor:"100%",fieldLabel:GO.lang.strName},{xtype:"checkbox",name:"show_not_as_busy",hideLabel:true,boxLabel:GO.calendar.lang.showNotBusy}]});if(GO.customfields&&GO.customfields.types["1"]){if(GO.customfields.types["1"].panels.length>0){var a=new Ext.form.FieldSet({autoHeight:true,title:GO.customfields.lang.customfields});for(var c=0;c<GO.customfields.types["1"].panels.length;c++){a.add({xtype:"checkbox",name:"fields[cf_category_"+GO.customfields.types["1"].panels[c].category_id+"]",hideLabel:true,boxLabel:GO.customfields.types["1"].panels[c].title})}this.propertiesPanel.add(a)}}var b=[this.propertiesPanel];this.groupAdminsPanel=new GO.calendar.GroupAdminsPanel({id:"permissions-panel"});b.push(this.groupAdminsPanel);this.tabPanel=new Ext.TabPanel({activeTab:0,deferredRender:false,border:false,items:b,anchor:"100% 100%"});this.formPanel=new Ext.form.FormPanel({waitMsgTarget:true,url:GO.settings.modules.calendar.url+"action.php",border:false,baseParams:{task:"group"},items:this.tabPanel})}});GO.calendar.ManagePermissionsPanel=function(a){if(!a){a={}}a.title=GO.calendar.lang.admins;a.layout="fit";a.autoScroll=true;a.split=true;a.store=new GO.data.JsonStore({url:BaseHref+"json.php",baseParams:{task:"users_in_acl",acl_id:0},root:"results",totalProperty:"total",id:"id",fields:["id","name"],remoteSort:true});var b=new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{header:GO.lang.strName,dataIndex:"name"}]});a.cm=b;a.view=new Ext.grid.GridView({autoFill:true,forceFit:true}),a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;a.tbar=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){this.showAddUsersDialog()},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.deleteSelected()},scope:this}];GO.calendar.ManagePermissionsPanel.superclass.constructor.call(this,a)};Ext.extend(GO.calendar.ManagePermissionsPanel,GO.grid.GridPanel,{changed:false,loaded:false,initComponent:function(){GO.calendar.ManagePermissionsPanel.superclass.initComponent.call(this)},setAcl:function(a){this.acl_id=a?a:0;this.loaded=false;this.store.baseParams.acl_id=a;this.setDisabled(a==0);if(this.isVisible()){this.store.load();this.loaded=true}},onShow:function(){GO.calendar.ManagePermissionsPanel.superclass.onShow.call(this);if(!this.loaded){this.store.load();this.loaded=true}},afterRender:function(){GO.calendar.ManagePermissionsPanel.superclass.afterRender.call(this);if(this.isVisible()&&!this.loaded){this.store.load();this.loaded=true}},showAddUsersDialog:function(){if(!this.addUsersDialog){this.addUsersDialog=new GO.dialog.SelectUsers({handler:function(a){if(a.selModel.selections.keys.length>0){this.store.baseParams.add_users=Ext.encode(a.selModel.selections.keys);this.store.load({callback:function(){if(!this.reader.jsonData.addSuccess){alert(this.reader.jsonData.addFeedback)}}});delete this.store.baseParams.add_users}},scope:this})}this.addUsersDialog.show()}});GO.calendar.ResourcesGrid=function(a){if(!a){a={}}a.title=GO.calendar.lang.resources;a.layout="fit";a.autoScroll=true;a.split=true;a.paging=true;var b=new Ext.grid.ColumnModel([{header:GO.lang.strName,dataIndex:"name",id:"name"},{header:GO.calendar.lang.group,dataIndex:"group_name",id:"group_name",hidden:true}]);a.cm=b;a.view=new Ext.grid.GroupingView({autoFill:true,forceFit:true,groupTextTpl:"{text}",emptyText:GO.lang.strNoItems});a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;a.tbar=[{iconCls:"btn-add",text:GO.lang.cmdAdd,disabled:!GO.settings.modules.calendar.write_permission,cls:"x-btn-text-icon",handler:function(){GO.calendar.calendarDialog.show(0,true)},scope:this},{iconCls:"btn-delete",disabled:!GO.settings.modules.calendar.write_permission,text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.deleteSelected()},scope:this},"-",{iconCls:"btn-settings",text:GO.lang.strPermissions,disabled:!GO.settings.modules.calendar.write_permission,cls:"x-btn-text-icon",handler:function(){if(!GO.calendar.permissionsDialog){GO.calendar.permissionsDialog=new GO.calendar.PermissionsDialog()}GO.calendar.permissionsDialog.show(1)},scope:this}];GO.calendar.ResourcesGrid.superclass.constructor.call(this,a);this.on("rowdblclick",function(d,e){var c=d.getStore().getAt(e);GO.calendar.calendarDialog.show(c.data.id,true)},this);this.on("show",function(){this.store.load()},this,{single:true})};Ext.extend(GO.calendar.ResourcesGrid,GO.grid.GridPanel);GO.calendar.PortletSettings=function(c){if(!c){c={}}c.layout="fit";c.autoScroll=true;c.split=true;var b=new GO.grid.CheckColumn({header:GO.calendar.lang.visible,dataIndex:"visible",width:55,disabled_field:""});var a={fields:["name","calendar_id"],columns:[{header:GO.lang.strTitle,dataIndex:"name"},b]};c.store=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"settings"},root:"results",id:"calendar_id",totalProperty:"total",fields:["calendar_id","name","visible"],remoteSort:true});var d=new Ext.grid.ColumnModel(a.columns);c.cm=d;c.view=new Ext.grid.GridView({autoFill:true,forceFit:true,emptyText:GO.lang.strNoItems});c.sm=new Ext.grid.RowSelectionModel();c.loadMask=true;c.plugins=[b];GO.calendar.PortletSettings.superclass.constructor.call(this,c)};Ext.extend(GO.calendar.PortletSettings,Ext.grid.GridPanel,{getGridData:function(){var d={};for(var b=0;b<this.store.data.items.length;b++){var c=this.store.data.items[b].data;d[b]={};for(var a in c){d[b][a]=c[a]}}return d}});GO.calendar.formatQtip=function(b){var d="Y-m-d H:i";if(!b.startDate){b.startDate=Date.parseDate(b.start_time,d)}if(!b.endDate){b.endDate=Date.parseDate(b.end_time,d)}var a=GO.settings.time_format;if(b.startDate.format("Ymd")!=b.endDate.format("Ymd")){a=GO.settings.date_format+" "+GO.settings.time_format}var c=GO.calendar.lang.startsAt+": "+b.startDate.format(a)+"<br />"+GO.calendar.lang.endsAt+": "+b.endDate.format(a);if(!GO.util.empty(b.duration)){c+="<br />"+GO.calendar.lang.duration+": "+b.duration}if(!GO.util.empty(b.calendar_name)){c+="<br />"+GO.calendar.lang.calendar+": "+b.calendar_name}if(!GO.util.empty(b.username)){c+="<br />"+GO.lang.strOwner+": "+b.username}if(b.location!=""){c+="<br />"+GO.calendar.lang.location+": "+b.location}if(b.description!=""){c+="<br /><br />"+b.description}return c};GO.calendar.MainPanel=function(b){if(!b){b={}}this.datePicker=new Ext.DatePicker({cls:"cal-date-picker",showToday:false});this.datePicker.on("select",function(e,f){this.setDisplay({date:f})},this);GO.calendar.calendarsStore=this.calendarsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"calendars",limit:parseInt(GO.settings.max_rows_list)},root:"results",totalProperty:"total",id:"id",fields:["id","name","comment","user_name","group_id","group_name","checked","project_id"],remoteSort:true});if(GO.projects){this.projectCalendarsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"calendars",project_calendars:1,limit:parseInt(GO.settings.max_rows_list)},root:"results",totalProperty:"total",id:"id",fields:["id","name","comment","user_name","group_id","group_name","checked","project_id"],remoteSort:true})}this.viewsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"views",limit:parseInt(GO.settings.max_rows_list)},root:"results",totalProperty:"total",id:"id",fields:["id","name","user_name","merge","owncolor"],remoteSort:true});GO.calendar.resourcesStore=this.resourcesStore=new Ext.data.GroupingStore({baseParams:{task:"calendars",resources:"true",limit:parseInt(GO.settings.max_rows_list)},reader:new Ext.data.JsonReader({root:"results",id:"id",totalProperty:"total",fields:["id","name","comment","user_name","group_id","group_name"]}),proxy:new Ext.data.HttpProxy({url:GO.settings.modules.calendar.url+"json.php"}),sortInfo:{field:"name",direction:"ASC"},groupField:"group_name"});this.calendarsStore.on("load",function(){if(this.state.displayType!="view"&&this.group_id==1){this.state.applyFilter=true;this.setDisplay(this.state)}},this);if(GO.projects){this.projectCalendarsStore.on("load",function(){this.projectCalendarsList.setVisible(this.projectCalendarsStore.data.length);this.calendarListPanel.doLayout()},this)}this.viewsStore.on("load",function(){this.viewsList.setVisible(this.viewsStore.data.length);this.calendarListPanel.doLayout();if(this.state.displayType=="view"&&this.viewsStore.data.length){this.setDisplay(this.state)}},this);this.resourcesStore.on("load",function(){this.resourcesList.setVisible(this.resourcesStore.data.length);this.calendarListPanel.doLayout();if(this.state.displayType!="view"&&this.group_id>1&&this.resourcesStore.data.length){this.setDisplay(this.state)}},this);this.calendarList=new GO.grid.MultiSelectGrid({title:GO.calendar.lang.calendars,store:this.calendarsStore,allowNoSelection:true,bbar:new GO.SmallPagingToolbar({items:[this.searchField=new GO.form.SearchField({store:this.calendarsStore,width:120,emptyText:GO.lang.strSearch})],store:this.calendarsStore,pageSize:parseInt(GO.settings.max_rows_list)})});if(GO.projects){this.projectCalendarsList=new GO.grid.MultiSelectGrid({title:GO.projects.lang.projectCalendars,store:this.projectCalendarsStore,allowNoSelection:true,bbar:new GO.SmallPagingToolbar({store:this.calendarsStore,pageSize:parseInt(GO.settings.max_rows_list)})})}this.viewsList=new GO.grid.GridPanel({border:false,layout:"fit",title:GO.calendar.lang.views,store:this.viewsStore,cls:"go-grid3-hide-headers",autoScroll:true,columns:[{header:GO.lang.strName,dataIndex:"name",id:"name",width:188}],view:new Ext.grid.GridView({forceFit:true,autoFill:true}),sm:new Ext.grid.RowSelectionModel({singleSelect:true})});this.resourcesList=new GO.grid.GridPanel({border:false,title:GO.calendar.lang.resources,layout:"fit",store:this.resourcesStore,cls:"go-grid3-hide-headers",autoScroll:true,columns:[{header:GO.lang.strName,dataIndex:"name",id:"name",width:188},{header:GO.calendar.lang.group,dataIndex:"group_name",id:"group_name",width:188}],view:new Ext.grid.GroupingView({forceFit:true,hideGroupedColumn:true,groupTextTpl:"{text} ({[values.rs.length]})"}),sm:new Ext.grid.RowSelectionModel({singleSelect:true})});var a=function(k,l,f){if(f.length){var h=[];for(var j=0,e=f.length;j<e;j++){h[j]=f[j].data.id}var g={calendars:h,group_id:1,merge:true,owncolor:true,project_id:f[0].data.project_id};this.setDisplay(g)}};this.calendarList.on("change",a,this);if(this.projectCalendarsList){this.projectCalendarsList.on("change",a,this)}this.viewsList.on("rowclick",function(e,f){this.setDisplay({view_id:e.store.data.items[f].id})},this);this.resourcesList.on("rowclick",function(e,f){this.setDisplay({calendars:[e.store.data.items[f].id],group_id:e.store.data.items[f].data.group_id})},this);this.calendarListPanel=new Ext.Panel({border:true,region:"center",layoutConfig:{hideCollapseTool:true},layout:"accordion",tbar:[{iconCls:"cal-btn-home",text:GO.calendar.lang.myCalendar,handler:function(){this.setDisplay({group_id:1,project_id:0,applyFilter:true,calendars:[GO.calendar.defaultCalendar.id]})},scope:this},{iconCls:"btn-one-day",text:GO.lang.today,handler:function(){this.setDisplay({date:new Date().clearTime()})},scope:this}],items:[this.calendarList]});if(this.projectCalendarsList){this.calendarListPanel.add(this.projectCalendarsList)}this.calendarListPanel.add(this.viewsList);this.calendarListPanel.add(this.resourcesList);this.daysGridStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"events"},root:"results",id:"id",fields:["id","event_id","name","start_time","end_time","description","repeats","private","location","background","read_only","task_id","contact_id","calendar_name","calendar_id","all_day_event","username","duration","link_count","num_participants"]});this.monthGridStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"events"},root:"results",id:"id",fields:["id","event_id","name","start_time","end_time","description","repeats","private","location","background","read_only","task_id","contact_id","calendar_name","calendar_id","username","duration","link_count","num_participants"]});GO.calendar.daysGrid=this.daysGrid=new GO.grid.CalendarGrid({id:"days-grid",store:this.daysGridStore,border:false,firstWeekday:parseInt(GO.settings.first_weekday),keys:[{key:Ext.EventObject.DELETE,fn:function(){this.deleteHandler()},scope:this}]});this.monthGrid=new GO.grid.MonthGrid({id:"month-grid",store:this.monthGridStore,border:false,layout:"fit",firstWeekday:parseInt(GO.settings.first_weekday),keys:[{key:Ext.EventObject.DELETE,fn:function(){this.deleteHandler()},scope:this}]});this.viewGrid=new GO.grid.ViewGrid({id:"view-grid",border:false,firstWeekday:parseInt(GO.settings.first_weekday),keys:[{key:Ext.EventObject.DELETE,fn:function(){this.deleteHandler()},scope:this}]});this.viewGrid.on("zoom",function(e){e.applyFilter=true;this.setDisplay(e)},this);this.listGrid=new GO.calendar.ListGrid({id:"list-grid",border:false,firstWeekday:parseInt(GO.settings.first_weekday)});this.daysGrid.store.on("load",function(){GO.checker.params.calendar_calendars=this.daysGrid.store.baseParams.calendars;GO.checker.params.calendar_start_time=this.daysGrid.store.baseParams.start_time;GO.checker.params.calendar_end_time=this.daysGrid.store.baseParams.end_time;GO.calendar.activePanel=this.getActivePanel();this.calendarComments.setText(GO.calendar.activePanel.store.reader.jsonData.comment);this.calendarTitle.setText(GO.calendar.activePanel.store.reader.jsonData.title);this.calendar_name=GO.calendar.activePanel.store.reader.jsonData.calendar_name;this.calendar_id=GO.calendar.activePanel.store.reader.jsonData.calendar_id},this);this.monthGrid.store.on("load",function(){GO.checker.params.calendar_calendars=this.monthGrid.store.baseParams.calendars;GO.checker.params.calendar_start_time=this.monthGrid.store.baseParams.start_time;GO.checker.params.calendar_end_time=this.monthGrid.store.baseParams.end_time;GO.calendar.activePanel=this.getActivePanel();this.calendarComments.setText(GO.calendar.activePanel.store.reader.jsonData.comment);this.calendarTitle.setText(GO.calendar.activePanel.store.reader.jsonData.title);this.calendar_name=GO.calendar.activePanel.store.reader.jsonData.calendar_name;this.calendar_id=GO.calendar.activePanel.store.reader.jsonData.calendar_id},this);this.listGrid.store.on("load",function(){GO.checker.params.calendar_calendars=this.listGrid.store.baseParams.calendars;GO.checker.params.calendar_start_time=this.listGrid.store.baseParams.start_time;GO.checker.params.calendar_end_time=this.listGrid.store.baseParams.end_time;GO.calendar.activePanel=this.getActivePanel();this.calendarComments.setText(GO.calendar.activePanel.store.reader.jsonData.comment);this.calendarTitle.setText(GO.calendar.activePanel.store.reader.jsonData.title);this.calendar_name=GO.calendar.activePanel.store.reader.jsonData.calendar_name;this.calendar_id=GO.calendar.activePanel.store.reader.jsonData.calendar_id},this);this.viewGrid.on("storeload",function(g,h,f,i,e){GO.checker.params.calendar_start_time=i.start_time;GO.checker.params.calendar_end_time=i.end_time;GO.checker.params.calendar_view_id=i.view_id;GO.calendar.activePanel=this.getActivePanel();GO.calendar.activePanel.count=h;GO.calendar.activePanel.mtime=f;this.calendarComments.setText(g.jsonData.comment);this.calendarTitle.setText(g.jsonData.title);this.calendar_name=g.jsonData.calendar_name;this.calendar_id=g.jsonData.calendar_id},this);this.daysGrid.on("deleteEvent",function(){this.deleteHandler()},this);this.monthGrid.on("deleteEvent",function(){this.deleteHandler()},this);this.listGrid.on("deleteEvent",function(){this.deleteHandler()},this);this.viewGrid.on("deleteEvent",function(){this.deleteHandler()},this);this.listStore=this.listGrid.store;this.displayPanel=new Ext.Panel({region:"center",titlebar:false,autoScroll:false,layout:"card",activeItem:0,border:true,split:true,cls:"cal-display-panel",tbar:[this.calendarComments=new Ext.Toolbar.TextItem({text:"",cls:"cal-comment"}),"-",this.calendarTitle=new Ext.Toolbar.TextItem({text:"Calendar"}),"-",{iconCls:"btn-left-arrow",text:GO.lang.cmdPrevious,cls:"x-btn-text-icon",handler:function(){this.setDisplay({date:this.getActivePanel().previousDate()})},scope:this},this.periodInfoPanel=new Ext.Panel({html:"",plain:true,border:true,cls:"cal-period"}),{iconCls:"btn-right-arrow",text:GO.lang.cmdNext,cls:"x-btn-text-icon",handler:function(){this.setDisplay({date:this.getActivePanel().nextDate()})},scope:this}],items:[this.daysGrid,this.monthGrid,this.viewGrid,this.listGrid]});var d=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){GO.calendar.showEventDialog({calendar_id:this.calendar_id,calendar_name:this.calendar_name})},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:this.deleteHandler,scope:this},{iconCls:"btn-refresh",text:GO.lang.cmdRefresh,cls:"x-btn-text-icon",handler:function(){this.init()},scope:this},{iconCls:"btn-settings",text:GO.lang.administration,cls:"x-btn-text-icon",handler:function(){this.showAdminDialog()},scope:this},"-",this.dayButton=new Ext.Button({iconCls:"btn-one-day",text:GO.calendar.lang.oneDay,cls:"x-btn-text-icon",handler:function(){this.setDisplay({days:1,displayType:this.displayType=="view"?"view":"days",calendar_name:this.calendar_name,view_id:this.view_id})},scope:this}),this.workWeekButton=new Ext.Button({iconCls:"btn-five-days",text:GO.calendar.lang.fiveDays,cls:"x-btn-text-icon",handler:function(){this.setDisplay({days:5,displayType:this.displayType=="view"?"view":"days",calendar_name:this.calendar_name,view_id:this.view_id})},scope:this}),this.weekButton=new Ext.Button({iconCls:"btn-seven-days",text:GO.calendar.lang.sevenDays,cls:"x-btn-text-icon",handler:function(){this.setDisplay({days:7,displayType:this.displayType=="view"?"view":"days",calendar_name:this.calendar_name,view_id:this.view_id})},scope:this}),this.monthButton=new Ext.Button({iconCls:"btn-month",text:GO.calendar.lang.month,cls:"x-btn-text-icon",handler:function(){this.setDisplay({displayType:"month",calendar_name:this.calendar_name,view_id:this.view_id})},scope:this}),this.listButton=new Ext.Button({iconCls:"btn-list",text:GO.calendar.lang.list,cls:"x-btn-text-icon",handler:function(e,f){this.setDisplay({displayType:"list",calendar_name:this.calendar_name,view_id:this.view_id})},scope:this}),"-",this.printButton=new Ext.Button({iconCls:"btn-print",text:GO.lang.cmdPrint,cls:"x-btn-text-icon",handler:function(){var g=this.getActivePanel().startDate;var f=this.getActivePanel().endDate;var e=GO.settings.modules.calendar.url+"print.php?start_time="+g.format("Y-m-d")+"&end_time="+f.format("Y-m-d");if(!GO.util.empty(this.view_id)){e+="&view_id="+this.view_id}else{e+="&calendars="+Ext.encode(this.calendars)}document.location=e},scope:this})];for(var c=0;c<GO.calendar.extraToolbarItems.length;c++){d.push(GO.calendar.extraToolbarItems[c])}b.layout="border";b.border=false;b.tbar=new Ext.Toolbar({cls:"go-head-tb",items:d});b.items=[new Ext.Panel({region:"west",titlebar:false,autoScroll:false,width:210,split:true,layout:"border",border:false,items:[new Ext.Panel({region:"north",border:true,height:160,split:true,baseCls:"x-plain",items:this.datePicker}),this.calendarListPanel]}),this.displayPanel];GO.calendar.MainPanel.superclass.constructor.call(this,b)};Ext.extend(GO.calendar.MainPanel,Ext.Panel,{displayType:"days",lastCalendarDisplayType:"days",state:false,calendarId:0,viewId:0,group_id:1,onShow:function(){GO.calendar.MainPanel.superclass.onShow.call(this);this.daysGrid.scrollToLastPosition();if(GO.calendar.activePanel.id!="view-grid"){GO.calendar.activePanel.store.reload()}else{GO.calendar.activePanel.reload()}},afterRender:function(){GO.calendar.MainPanel.superclass.afterRender.call(this);if(GO.tasks){GO.dialogListeners.add("tasks",{scope:this,save:function(){if(this.isVisible()){this.refresh()}}})}GO.dialogListeners.add("event",{scope:this,save:function(f,c){if(this.displayType=="list"){this.setDisplay()}else{var e=this.getActivePanel();if(f.repeats||!c){e.store.reload()}else{e.removeEvent(c);switch(this.displayType){case"month":if(f.calendar_id==this.calendar_id){GO.calendar.eventDialog.oldDomId=this.monthGrid.addMonthGridEvent(f)}break;case"days":for(var b=0,d=false;b<this.calendars.length&&!d;b++){if(this.calendars[b]==f.calendar_id){var a=new GO.calendar.CalendarEvent(f);this.daysGridStore.add(a);GO.calendar.eventDialog.oldDomId=this.daysGrid.lastDomId;d=true}}break;case"view":GO.calendar.eventDialog.oldDomId=this.viewGrid.addViewGridEvent(f);break}}}}});GO.calendar.groupDialog=new GO.calendar.GroupDialog();GO.calendar.groupDialog.on("save",function(c,b,a){if(b==1){GO.calendar.defaultGroupFields=a}GO.calendar.groupsGrid.store.load({callback:function(){if(GO.calendar.eventDialog){GO.calendar.eventDialog.resourceGroupsStore.reload()}},scope:this})},this);if(GO.calendar.openState){this.state=GO.calendar.openState}else{this.state=Ext.state.Manager.get("calendar-state");if(!this.state){this.state={displayType:"days",days:5,calendars:0,view_id:0}}else{this.state=Ext.decode(this.state)}if(this.state.displayType=="view"){this.state.displayType="days"}this.state.calendars=[GO.calendar.defaultCalendar.id];this.state.view_id=0;this.state.group_id=1}this.init();this.createDaysGrid()},init:function(){this.getEl().mask(GO.lang.waitMsgLoad);Ext.Ajax.request({url:GO.settings.modules.calendar.url+"json.php",params:{task:"startup"},callback:function(b,d,a){if(!d){alert(GO.lang.strRequestError)}else{var c=Ext.decode(a.responseText);this.calendarsStore.loadData(c.calendars);this.viewsStore.loadData(c.views);this.resourcesStore.loadData(c.resources);if(this.projectCalendarsList){this.projectCalendarsStore.loadData(c.project_calendars)}GO.calendar.categoriesStore.loadData(c.categories);this.getEl().unmask()}},scope:this})},deleteHandler:function(){switch(this.displayType){case"days":var a=this.daysGrid.getSelectedEvent();var b=function(d,c){if(c){this.daysGrid.store.reload()}else{this.daysGrid.removeEvent(d.domId)}};break;case"month":var a=this.monthGrid.getSelectedEvent();var b=function(d,c){if(c){this.monthGrid.store.reload()}else{this.monthGrid.removeEvent(d.domId)}};break;case"view":var a=this.viewGrid.getSelectedEvent();var b=function(d,c){if(c){this.viewGrid.reload()}else{this.viewGrid.removeEvent(d.domId)}};break;case"list":var a=this.listGrid.getSelectedEvent();var b=function(d,c){if(c){this.listGrid.store.reload()}else{this.listGrid.removeEvent()}};break}if(a&&!a.read_only&&!a.task_id&!a.contact_id){this.deleteEvent(a,b)}},getActivePanel:function(){switch(this.displayType){case"days":return this.daysGrid;break;case"month":return this.monthGrid;break;case"view":return this.viewGrid;break;case"list":return this.listGrid;break}},updatePeriodInfoPanel:function(){this.periodInfoPanel.body.update(this.getActivePanel().periodDisplay)},deleteEvent:function(a,b){if(a.repeats){this.currentDeleteEvent=a;this.currentDeleteCallback=b;if(!this.recurrenceDialog){this.recurrenceDialog=new GO.calendar.RecurrenceDialog();this.recurrenceDialog.on("single",function(){var c={task:"delete_event",create_exception:true,exception_date:this.currentDeleteEvent.startDate.format(this.daysGrid.dateTimeFormat),event_id:this.currentDeleteEvent.event_id};if(a.num_participants){c.send_cancellation=(confirm(GO.calendar.lang.sendCancellation))?1:0}this.sendDeleteRequest(c,this.currentDeleteCallback,this.currentDeleteEvent);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("entire",function(){var c={task:"delete_event",event_id:this.currentDeleteEvent.event_id};if(a.num_participants){c.send_cancellation=(confirm(GO.calendar.lang.sendCancellation))?1:0}this.sendDeleteRequest(c,this.currentDeleteCallback,this.currentDeleteEvent,true);this.recurrenceDialog.hide()},this);this.recurrenceDialog.on("cancel",function(){this.recurrenceDialog.hide()},this)}this.recurrenceDialog.show()}else{Ext.MessageBox.confirm(GO.lang.strConfirm,GO.lang.strDeleteSelectedItem,function(c){if(c=="yes"){var d={task:"delete_event",event_id:a.event_id};if(a.num_participants){d.send_cancellation=(confirm(GO.calendar.lang.sendCancellation))?1:0}this.sendDeleteRequest(d,b,a)}},this)}},sendDeleteRequest:function(c,d,b,a){Ext.Ajax.request({url:GO.settings.modules.calendar.url+"action.php",params:c,callback:function(f,h,e){if(!h){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var g=Ext.decode(e.responseText);if(!g.success){Ext.MessageBox.alert(GO.lang.strError,g.feedback)}else{d.call(this,b,a)}}},scope:this})},setDisplay:function(g){if(!g){g={}}if(g.calendar_id){g.calendars=[g.calendar_id]}if(g.group_id){this.group_id=g.group_id}if(typeof(g.project_id)!="undefined"){this.project_id=g.project_id}g.title="";var e;if(g.calendars){}else{if(g.view_id){e=this.viewsStore.getById(g.view_id);g.merge=e.get("merge");g.owncolor=e.get("owncolor")}}if(g.displayType){this.displayType=g.displayType}else{if(g.calendars){this.displayType=this.lastCalendarDisplayType}else{if(g.view_id){if(g.merge=="0"){this.displayType="view"}else{this.displayType=this.lastCalendarDisplayType}}}}var d=g.days&&g.days!=this.state.days||g.displayType&&g.displayType!=this.state.displayType;this.state.displayType=this.displayType;if(this.displayType!="view"){this.lastCalendarDisplayType=this.displayType}switch(this.displayType){case"month":this.displayPanel.getLayout().setActiveItem(1);break;case"days":this.displayPanel.getLayout().setActiveItem(0);break;case"view":this.displayPanel.getLayout().setActiveItem(2);break;case"list":this.displayPanel.getLayout().setActiveItem(3);break}this.monthButton.setDisabled(this.displayType=="view");this.listButton.setDisabled(this.displayType=="view");if(g.calendars){this.view_id=0;this.calendar_id=g.calendars.indexOf(GO.calendar.defaultCalendar.id)>-1?GO.calendar.defaultCalendar.id:g.calendars[0];this.calendars=g.calendars;this.daysGridStore.baseParams.calendars=Ext.encode(g.calendars);this.monthGridStore.baseParams.calendars=Ext.encode(g.calendars);this.listGrid.store.baseParams.calendars=Ext.encode(g.calendars)}if(typeof(g.merge)!="undefined"){this.merge=g.merge;this.owncolor=g.owncolor}if(g.calendar_name){this.calendar_name=g.calendar_name}if(g.view_id){this.view_id=g.view_id;this.viewGrid.setViewId(g.view_id)}this.daysGridStore.baseParams.owncolor=this.owncolor;this.monthGridStore.baseParams.owncolor=this.owncolor;this.listGrid.store.baseParams.owncolor=this.owncolor;if(this.merge=="1"&&this.view_id){this.daysGridStore.baseParams.view_id=this.view_id;this.monthGridStore.baseParams.view_id=this.view_id;this.listGrid.store.baseParams.view_id=this.view_id}else{this.daysGridStore.baseParams.view_id=null;this.monthGridStore.baseParams.view_id=null;this.listGrid.store.baseParams.view_id=null}if(g.date){this.datePicker.setValue(g.date);if(!g.days){g.days=this.type=="days"?this.daysGrid.days:this.viewGrid.days}this.daysGrid.setDate(g.date,g.days,this.displayType=="days");this.monthGrid.setDate(g.date,this.displayType=="month");this.viewGrid.setDate(g.date,g.days,this.displayType=="view");this.listGrid.setDate(g.date,g.days,this.displayType=="list");this.days=g.days}else{if(g.days&&this.displayType!="month"){this.daysGrid.setDays(g.days,this.displayType=="days");this.viewGrid.setDays(g.days,this.displayType=="view");this.listGrid.setDays(g.days,this.displayType=="list");this.days=g.days}else{if(g.days){this.days=g.days}switch(this.displayType){case"month":this.monthGridStore.reload();break;case"days":this.daysGridStore.reload();break;case"view":this.viewGrid.load();break;case"list":this.listGrid.store.reload();break}}}this.dayButton.toggle(this.displayType=="days"&&this.days==1);this.workWeekButton.toggle(this.displayType=="days"&&this.days==5);this.weekButton.toggle(this.displayType=="days"&&this.days==7);this.monthButton.toggle(this.displayType=="month");this.listButton.toggle(this.displayType=="list");this.updatePeriodInfoPanel();this.state={displayType:this.displayType,days:this.days,calendars:this.calendars,view_id:this.view_id,merge:this.merge,owncolor:this.owncolor};if(d){this.saveState()}var c,b=[];if(this.view_id>0){c=this.viewsList;c.expand();this.resourcesList.getSelectionModel().clearSelections();b.push(this.calendarList);if(this.projectCalendarsList){b.push(this.projectCalendarsList)}}else{this.viewsList.getSelectionModel().clearSelections();if(this.group_id==1){if(this.project_id>0){b.push(this.calendarList);c=this.projectCalendarsList}else{if(this.projectCalendarsList){b.push(this.projectCalendarsList)}c=this.calendarList}this.resourcesList.getSelectionModel().clearSelections();c.expand();if(g.applyFilter){c.applyFilter(this.calendars,true)}}else{b.push(this.calendarList);if(this.projectCalendarsList){b.push(this.projectCalendarsList)}c=this.resourcesList;var f=[];for(var h=0,a=this.calendars.length;h<a;h++){f.push(c.store.getById(this.calendars[h]))}c.getSelectionModel().selectRecords(f);c.expand()}}for(var h=0,a=b.length;h<a;h++){b[h].applyFilter("clear",true)}},saveState:function(){var a={displayType:this.displayType,days:this.days};Ext.state.Manager.set("calendar-state",Ext.encode(a))},refresh:function(){this.setDisplay()},createDaysGrid:function(){this.daysGrid.on("eventResize",function(a,c,b){var d={task:"update_grid_event",update_event_id:c.event_id,end_time:b.end_time};if(c.num_participants){d.send_invitation=confirm(GO.calendar.lang.sendInvitationUpdate)}if(c.repeats&&b.singleInstance){d.createException="true";d.exceptionDate=b.dragDate.format(a.dateTimeFormat);d.repeats="true"}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"action.php",params:d,callback:function(f,h,e){var g=Ext.decode(e.responseText);if(!g.success){Ext.MessageBox.alert(GO.lang.strError,g.feedback)}else{if(c.repeats&&!b.singleInstance){a.store.reload()}}}})},this);this.daysGrid.on("create",function(b,a){var c={};c.start_date=a.startDate;c.start_time=a.startDate.format(GO.settings.time_format);c.end_date=a.endDate;c.end_time=a.endDate.format(GO.settings.time_format);GO.calendar.showEventDialog({values:c,calendar_id:this.calendar_id,calendar_name:this.calendar_name})},this);this.monthGrid.on("create",function(c,b){var a=new Date();var d={start_date:b,end_date:b,start_hour:a.format("H"),end_hour:a.add(Date.HOUR,1).format("H"),start_min:"00",end_min:"00"};GO.calendar.showEventDialog({values:d,calendar_id:this.calendar_id,calendar_name:this.calendar_name})},this);this.monthGrid.on("changeview",function(b,c,a){this.setDisplay({displayType:"days",days:c,date:a})},this);this.daysGrid.on("eventDblClick",this.onDblClick,this);this.monthGrid.on("eventDblClick",this.onDblClick,this);this.viewGrid.on("eventDblClick",this.onDblClick,this);this.monthGrid.on("move",this.onEventMove,this);this.daysGrid.on("move",this.onEventMove,this);this.viewGrid.on("move",function(b,d,c,a){var e={task:"update_grid_event",update_event_id:d.event_id};if(d.num_participants){e.send_invitation=confirm(GO.calendar.lang.sendInvitationUpdate)}if(c.offset){e.offset=c.offset}if(c.offsetDays){e.offsetDays=c.offsetDays}if(d.repeats&&c.singleInstance){e.createException="true";e.exceptionDate=c.dragDate.format(b.dateTimeFormat);e.repeats="true"}if(c.calendar_id){e.update_calendar_id=c.calendar_id}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"action.php",params:e,callback:function(g,i,f){var h=Ext.decode(f.responseText);if(!h.success){Ext.MessageBox.alert(GO.lang.strError,h.feedback)}else{if(d.repeats&&!c.singleInstance){b.reload()}else{if(h.new_event_id){b.setNewEventId(a,h.new_event_id)}}}}})},this)},onDblClick:function(a,c,b){if(c.read_only&&!c.contact_id&&!c.task_id){return false}if(c.repeats&&b.singleInstance){var d={};d.start_date=c.startDate.format(GO.settings.date_format);d.start_hour=c.startDate.format("H");d.start_min=c.startDate.format("i");d.end_date=c.endDate.format(GO.settings.date_format);d.end_hour=c.endDate.format("H");d.end_min=c.endDate.format("i");GO.calendar.showEventDialog({values:d,exceptionDate:c.startDate.format(this.daysGrid.dateTimeFormat),exception_event_id:c.event_id,oldDomId:c.domId})}else{if(c.task_id){GO.tasks.showTaskDialog({task_id:c.task_id})}else{if(c.contact_id){GO.linkHandlers[2].call(this,c.contact_id)}else{if(c.event_id){GO.calendar.showEventDialog({event_id:c.event_id,oldDomId:c.domId})}}}}},onEventMove:function(b,d,c,a){var e={task:"update_grid_event",update_event_id:d.event_id};if(c.offset){e.offset=c.offset}if(c.offsetDays){e.offsetDays=c.offsetDays}if(d.repeats&&c.singleInstance){e.createException="true";e.exceptionDate=c.dragDate.format(b.dateTimeFormat);e.repeats="true"}if(c.calendar_id){e.update_calendar_id=c.calendar_id}if(d.num_participants){e.send_invitation=confirm(GO.calendar.lang.sendInvitationUpdate)}Ext.Ajax.request({url:GO.settings.modules.calendar.url+"action.php",params:e,callback:function(g,i,f){var h=Ext.decode(f.responseText);if(!h.success){Ext.MessageBox.alert(GO.lang.strError,h.feedback)}else{if(d.repeats&&!c.singleInstance){b.store.reload()}else{if(h.new_event_id){b.setNewEventId(a,h.new_event_id)}}}}})},showAdminDialog:function(){if(!this.adminDialog){this.writableCalendarsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"writable_calendars"},root:"results",totalProperty:"total",id:"id",fields:["id","name","user_name"],remoteSort:true,sortInfo:{field:"name",direction:"ASC"}});this.writableViewsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"writable_views"},root:"results",totalProperty:"total",id:"id",fields:["id","name","user_name","merge"],remoteSort:true,sortInfo:{field:"name",direction:"ASC"}});this.writableResourcesStore=new Ext.data.GroupingStore({baseParams:{task:"writable_calendars",resources:"true"},reader:new Ext.data.JsonReader({root:"results",id:"id",totalProperty:"total",fields:["id","name","user_name","group_name"]}),proxy:new Ext.data.HttpProxy({url:GO.settings.modules.calendar.url+"json.php"}),groupField:"group_name",sortInfo:{field:"name",direction:"ASC"}}),this.calendarDialog=GO.calendar.calendarDialog=new GO.calendar.CalendarDialog();this.calendarDialog.on("save",function(d,c){this.adminDialog.madeChanges=true;if(c>1){this.writableResourcesStore.reload()}else{this.writableCalendarsStore.reload()}},this);this.calendarDialog.on("calendarimport",function(){this.adminDialog.madeChanges=true},this);var b=[{iconCls:"btn-add",text:GO.lang.cmdAdd,disabled:!GO.settings.modules.calendar.write_permission,cls:"x-btn-text-icon",handler:function(){this.calendarDialog.show(0,false)},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,disabled:!GO.settings.modules.calendar.write_permission,cls:"x-btn-text-icon",handler:function(){this.calendarsGrid.deleteSelected()},scope:this}];if(GO.customfields){b.push(new Ext.Button({iconCls:"btn-settings",disabled:!GO.settings.modules.calendar.write_permission,text:GO.customfields.lang.customfields,cls:"x-btn-text-icon",handler:function(){GO.calendar.groupDialog.show(1)},scope:this}))}b.push("-");b.push(new Ext.Button({iconCls:"btn-settings",text:GO.lang.strPermissions,disabled:!GO.settings.modules.calendar.write_permission,cls:"x-btn-text-icon",handler:function(){if(!GO.calendar.permissionsDialog){GO.calendar.permissionsDialog=new GO.calendar.PermissionsDialog()}GO.calendar.permissionsDialog.show(0)},scope:this}));b.push(new GO.form.SearchField({store:this.writableCalendarsStore,width:150}));this.calendarsGrid=new GO.grid.GridPanel({title:GO.calendar.lang.calendars,paging:true,border:false,store:this.writableCalendarsStore,deleteConfig:{callback:function(){this.adminDialog.madeChanges=true},scope:this},columns:[{header:GO.lang.strName,dataIndex:"name",sortable:true},{header:GO.lang.strOwner,dataIndex:"user_name"}],view:new Ext.grid.GridView({autoFill:true}),sm:new Ext.grid.RowSelectionModel(),loadMask:true,tbar:b});this.calendarsGrid.on("rowdblclick",function(c,d,f){this.calendarDialog.show(c.selModel.selections.keys[0],false)},this);this.viewDialog=new GO.calendar.ViewDialog();this.viewDialog.on("save",function(){this.writableViewsStore.reload();this.adminDialog.madeChanges=true},this);this.mergeColumn=new GO.grid.CheckColumn({header:GO.calendar.lang.merge,dataIndex:"merge",width:55});this.mergeColumn.on("change",function(e,f){var c=e.store.data.items;for(var d in c){if(!isNaN(d)){Ext.Ajax.request({url:GO.settings.modules.calendar.url+"action.php",params:{task:"change_merge",view_id:c[d].id,merge:c[d].data.merge},callback:function(h,j,g){if(!j){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strRequestError)}else{var i=Ext.decode(g.responseText);if(!i.success){Ext.MessageBox.alert(GO.lang.strError,i.feedback)}else{this.writableViewsStore.reload();this.viewsStore.reload()}}},scope:this})}}},this);this.viewsGrid=new GO.grid.GridPanel({title:GO.calendar.lang.views,paging:true,border:false,store:this.writableViewsStore,deleteConfig:{callback:function(){this.adminDialog.madeChanges=true},scope:this},columns:[{header:GO.lang.strName,dataIndex:"name",sortable:true},{header:GO.lang.strOwner,dataIndex:"user_name"},this.mergeColumn],view:new Ext.grid.GridView({autoFill:true}),sm:new Ext.grid.RowSelectionModel(),loadMask:true,plugins:[this.mergeColumn],tbar:[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",disabled:!GO.settings.modules.calendar.write_permission,handler:function(){this.viewDialog.show()},scope:this},{disabled:!GO.settings.modules.calendar.write_permission,iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.viewsGrid.deleteSelected()},scope:this}]});this.viewsGrid.on("rowdblclick",function(c,d,f){this.viewDialog.show(c.selModel.selections.keys[0])},this);this.viewsGrid.on("show",function(){this.writableViewsStore.load()},this,{single:true});GO.calendar.groupsGrid=this.groupsGrid=new GO.calendar.GroupsGrid({title:GO.calendar.lang.resource_groups,layout:"fit",store:GO.calendar.groupsStore,deleteConfig:{callback:function(){this.adminDialog.madeChanges=true},scope:this}});this.resourcesGrid=new GO.calendar.ResourcesGrid({title:GO.calendar.lang.resources,layout:"fit",store:this.writableResourcesStore,deleteConfig:{callback:function(){this.adminDialog.madeChanges=true},scope:this}});this.categoriesGrid=new GO.calendar.CategoriesGrid({title:GO.calendar.lang.categories,layout:"fit",store:GO.calendar.categoriesStore,deleteConfig:{callback:function(){this.adminDialog.madeChanges=true},scope:this}});GO.calendar.categoryDialog=new GO.calendar.CategoryDialog();GO.calendar.categoryDialog.on("save",function(){GO.calendar.categoriesStore.reload()},this);var a=[this.calendarsGrid,this.viewsGrid,this.categoriesGrid];if(GO.settings.has_admin_permission){a.push(this.groupsGrid)}if(GO.settings.modules.calendar.write_permission){a.push(this.resourcesGrid)}this.adminDialog=new Ext.Window({title:GO.calendar.lang.administration,layout:"fit",modal:true,minWidth:300,minHeight:300,height:400,width:600,closeAction:"hide",madeChanges:false,items:new Ext.TabPanel({border:false,activeTab:0,items:a}),buttons:[{text:GO.lang.cmdClose,handler:function(){this.adminDialog.hide()},scope:this}]});this.adminDialog.on("hide",function(){if(this.adminDialog.madeChanges){this.init();if(GO.calendar.eventDialog){GO.calendar.eventDialog.initialized=false}this.adminDialog.madeChanges=false}},this)}this.writableCalendarsStore.load();this.adminDialog.show()}});GO.calendar.extraToolbarItems=[];GO.moduleManager.addModule("calendar",GO.calendar.MainPanel,{title:GO.calendar.lang.calendar,iconCls:"go-tab-icon-calendar"});GO.mainLayout.onReady(function(){GO.calendar.groupsStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"groups"},root:"results",id:"id",totalProperty:"total",fields:["id","name","user_name","fields","acl_id"],remoteSort:true}),GO.calendar.categoriesStore=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"categories"},root:"results",id:"id",totalProperty:"total",fields:["id","name","user_name","user_id","color"],remoteSort:true}),GO.newMenuItems.push({text:GO.calendar.lang.appointment,iconCls:"go-link-icon-1",handler:function(b,c){var a=b.parentMenu.eventShowConfig||{};a.link_config=b.parentMenu.link_config;GO.calendar.showEventDialog(a)}});if(GO.checker){GO.checker.on("check",function(a,b){var c=GO.mainLayout.getModulePanel("calendar");if(c&&c.isVisible()&&b.calendar){if(GO.calendar.activePanel.id!="view-grid"){if((GO.calendar.activePanel.store.reader.jsonData.count_events_only!=b.calendar.count)||(GO.calendar.activePanel.store.reader.jsonData.mtime!=b.calendar.mtime)){GO.calendar.activePanel.store.reload()}}else{if((GO.calendar.activePanel.count!=b.calendar.count)||(GO.calendar.activePanel.mtime!=b.calendar.mtime)){GO.calendar.activePanel.reload()}}}})}});GO.calendar.showEventDialog=function(a){if(!GO.calendar.eventDialog){GO.calendar.eventDialog=new GO.calendar.EventDialog()}GO.calendar.eventDialog.show(a)};GO.linkHandlers[1]=function(b){if(!GO.calendar.eventLinkWindow){var a=new GO.calendar.EventPanel();GO.calendar.eventLinkWindow=new GO.LinkViewWindow({title:GO.calendar.lang.appointment,closeAction:"hide",items:a,eventPanel:a})}GO.calendar.eventLinkWindow.eventPanel.load(b);GO.calendar.eventLinkWindow.show()};GO.linkPreviewPanels[1]=function(a){var a=a||{};return new GO.calendar.EventPanel(a)};GO.calendar.showEvent=function(a){a=a||{};a.event_id=a.values.event_id;GO.calendar.showEventDialog(a)};GO.calendar.openCalendar=function(b){if(GO.mainLayout.rendered){var a=GO.mainLayout.initModule("calendar");b.applyFilter=true;if(a.rendered){a.setDisplay(b);a.show()}else{GO.calendar.openState=b;a.show()}}else{GO.calendar.openState=b;GO.mainLayout.on("render",function(){GO.mainLayout.openModule("calendar")})}};GO.calendar.GroupAdminsPanel=function(a){if(!a){a={}}a.title=GO.calendar.lang.admins;a.layout="fit";a.autoScroll=true;a.split=true;a.store=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"group_admins",group_id:0},root:"results",totalProperty:"total",id:"id",fields:["id","name","email"],remoteSort:true});var b=new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{header:GO.lang.strName,dataIndex:"name"},{header:GO.lang.strEmail,dataIndex:"email"}]});a.cm=b;a.view=new Ext.grid.GridView({autoFill:true,forceFit:true}),a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;a.tbar=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){this.showAddAdminsDialog()},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.deleteSelected()},scope:this}];GO.calendar.GroupAdminsPanel.superclass.constructor.call(this,a)};Ext.extend(GO.calendar.GroupAdminsPanel,GO.grid.GridPanel,{changed:false,loaded:false,initComponent:function(){GO.calendar.GroupAdminsPanel.superclass.initComponent.call(this)},setGroupId:function(a){this.group_id=a?a:0;this.loaded=false;this.store.baseParams.group_id=a;this.setDisabled(a==0);if(this.isVisible()){this.store.load();this.loaded=true}},onShow:function(){GO.calendar.GroupAdminsPanel.superclass.onShow.call(this);if(!this.loaded){this.store.load();this.loaded=true}},afterRender:function(){GO.calendar.GroupAdminsPanel.superclass.afterRender.call(this);if(this.isVisible()&&!this.loaded){this.store.load();this.loaded=true}},showAddAdminsDialog:function(){if(!this.AddAdminsDialog){this.AddAdminsDialog=new GO.dialog.SelectUsers({handler:function(a){if(a.selModel.selections.keys.length>0){this.store.baseParams.add_users=Ext.encode(a.selModel.selections.keys);this.store.load({callback:function(){if(!this.reader.jsonData.addSuccess){alert(this.reader.jsonData.addFeedback)}}});delete this.store.baseParams.add_users}},scope:this})}this.AddAdminsDialog.show()}});GO.calendar.TasklistsGrid=function(c){if(!c){c={}}c.layout="fit";c.autoScroll=true;c.loadMask=true;c.store=new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"tasklists"},root:"results",id:"tasklist_id",totalProperty:"total",fields:["id","name","visible"],remoteSort:true});var b=new GO.grid.CheckColumn({header:GO.tasks.lang.visible,dataIndex:"visible",width:55,sortable:false});var a={fields:["name","tasklist_id"],columns:[{header:GO.lang.strTitle,dataIndex:"name"},b]};var d=new Ext.grid.ColumnModel({defaults:{sortable:true},columns:a.columns});c.cm=d;c.view=new Ext.grid.GridView({autoFill:true,forceFit:true,emptyText:GO.lang.strNoItems});c.sm=new Ext.grid.RowSelectionModel();c.loadMask=true;c.plugins=[b];GO.calendar.TasklistsGrid.superclass.constructor.call(this,c)};Ext.extend(GO.calendar.TasklistsGrid,GO.grid.GridPanel,{onShow:function(){if(!this.store.loaded){this.store.load()}GO.calendar.TasklistsGrid.superclass.onShow.call(this)},getGridData:function(){var d={};for(var b=0;b<this.store.data.items.length;b++){var c=this.store.data.items[b].data;d[b]={};for(var a in c){d[b][a]=c[a]}}return d}});GO.calendar.EventPanel=Ext.extend(GO.DisplayPanel,{link_type:1,loadParams:{task:"event_with_items"},idParam:"event_id",loadUrl:GO.settings.modules.calendar.url+"json.php",stateId:"cal-event-panel",editGoDialogId:"event",editHandler:function(){GO.calendar.showEventDialog({event_id:this.link_id})},initComponent:function(){this.template='<table class="display-panel" cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2" class="display-panel-heading">{name}</td></tr><tr><td colspan="2"><table><tr><td>'+GO.calendar.lang.calendar+': </td><td>{calendar_name}</td></tr></table</td></tr><tr><td colspan="2">{html_event}</td></tr></table>';if(GO.customfields){this.template+=GO.customfields.displayPanelTemplate}if(GO.tasks){this.template+=GO.tasks.TaskTemplate}if(GO.calendar){this.template+=GO.calendar.EventTemplate}this.template+=GO.linksTemplate;if(GO.files){Ext.apply(this.templateConfig,GO.files.filesTemplateConfig);this.template+=GO.files.filesTemplate}Ext.apply(this.templateConfig,GO.linksTemplateConfig);if(GO.comments){this.template+=GO.comments.displayPanelTemplate}GO.calendar.EventPanel.superclass.initComponent.call(this)}});GO.calendar.PermissionsDialog=function(a){if(!a){a={}}a.layout="border";a.modal=false;a.resizable=true;a.maximizable=true;a.width=500;a.height=450;a.closeAction="hide";a.buttons=[{text:GO.lang.cmdOk,handler:function(){this.submitForm(true)},scope:this},{text:GO.lang.cmdApply,handler:function(){this.submitForm()},scope:this},{text:GO.lang.cmdClose,handler:function(){this.beforeHide()},scope:this}];this.permissionsGrid=new GO.grid.MultiSelectGrid({allowNoSelection:true,donotcommitRecords:true,region:"center",loadMask:true,store:new GO.data.JsonStore({url:GO.settings.modules.calendar.url+"json.php",baseParams:{task:"permissions"},root:"results",totalProperty:"total",id:"id",fields:["id","name","user_name","checked"],remoteSort:true})});this.formPanel=new Ext.form.FormPanel({region:"north",height:75,defaultType:"textfield",defaults:{anchor:"100%"},cls:"go-form-panel",url:GO.settings.modules.calendar.url+"json.php",waitMsgTarget:true,labelWidth:110,border:false,items:[this.selectGroup=new GO.form.ComboBox({hiddenName:"group_id",fieldLabel:GO.lang.userGroup,store:new GO.data.JsonStore({url:GO.settings.modules.groups.url+"non_admin_json.php",baseParams:{task:"groups_all"},root:"results",totalProperty:"total",id:"id",fields:["id","name","email","groupname"],remoteSort:true}),displayField:"name",valueField:"id",triggerAction:"all",selectOnFocus:true,forceSelection:true,pageSize:parseInt(GO.settings.max_rows_list),mode:"local",editable:false,disabled:!GO.settings.modules.calendar["write_permission"]}),this.selectLevel=new GO.form.ComboBox({hiddenName:"acl_id",fieldLabel:GO.lang.strPermissions,store:new Ext.data.SimpleStore({id:0,fields:["value","text"],data:[[1,GO.lang.permissionRead],[2,GO.lang.permissionWrite],[3,GO.lang.permissionDelete],[4,GO.lang.permissionManage]]}),valueField:"value",displayField:"text",mode:"local",triggerAction:"all",editable:false,selectOnFocus:true,forceSelection:true})]});a.items=[this.formPanel,this.permissionsGrid];GO.calendar.PermissionsDialog.superclass.constructor.call(this,a);this.addEvents({save:true});this.permissionsGrid.on("change",function(c,d,b){this.calendars=d},this);this.permissionsGrid.store.on("load",function(){this.calendars=this.checked_calendars=this.permissionsGrid.store.reader.jsonData.checked_calendars},this);this.selectGroup.on("select",function(c,b){this.permissionsGrid.store.baseParams.group_id=b.id;this.permissionsGrid.store.reload()},this);this.selectLevel.on("select",function(c,b){this.permissionsGrid.store.baseParams.level_id=b.id;this.permissionsGrid.store.reload()},this)};Ext.extend(GO.calendar.PermissionsDialog,GO.Window,{group_id:0,afterRender:function(){GO.calendar.PermissionsDialog.superclass.afterRender.call(this)},show:function(b){if(!this.rendered){this.render(Ext.getBody())}if(!this.selectGroup.store.loaded){this.selectGroup.store.load({callback:function(){this.show(b)},scope:this});return false}var a=this.selectGroup.store.data.items[0].id;this.resources=b;this.selectGroup.setValue(a);this.permissionsGrid.store.baseParams.group_id=a;this.selectLevel.setValue(1);this.permissionsGrid.store.baseParams.level_id=1;var c=(b)?GO.calendar.lang.resourcesPermissions:GO.calendar.lang.calendarsPermissions;this.setTitle(c);this.permissionsGrid.store.baseParams.resources=b;this.permissionsGrid.store.reload();GO.calendar.GroupDialog.superclass.show.call(this)},submitForm:function(a){this.formPanel.form.submit({url:GO.settings.modules.calendar.url+"action.php",params:{task:"save_permissions",calendars:Ext.encode(this.calendars),resources:this.resources},waitMsg:GO.lang.waitMsgSave,success:function(b,c){this.fireEvent("save");this.permissionsGrid.store.reload();if(a){this.hide()}},failure:function(b,c){},scope:this})},beforeHide:function(){var a=false;if(this.calendars.length!=this.checked_calendars.length){a=true}else{this.checked_calendars.sort();this.calendars.sort();if(this.calendars.toString()!=this.checked_calendars.toString()){a=true}}if(!a||confirm(GO.lang.changesWillBeLost)){this.hide()}}});GO.calendar.CategoriesGrid=function(a){if(!a){a={}}a.title=GO.calendar.lang.categories;a.layout="fit";a.autoScroll=true;a.split=true;a.paging=true;var b=new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{header:GO.lang.strName,dataIndex:"name"},{header:GO.lang.strOwner,dataIndex:"user_name",sortable:false}]});a.cm=b;a.view=new Ext.grid.GridView({autoFill:true,forceFit:true,emptyText:GO.lang.strNoItems});a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;a.tbar=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){GO.calendar.categoryDialog.show(0)},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.deleteSelected()},scope:this}];GO.calendar.CategoriesGrid.superclass.constructor.call(this,a);this.on("rowdblclick",function(d,e){var c=d.getStore().getAt(e);if(GO.settings.has_admin_permission||(c.data.user_id>0)){GO.calendar.categoryDialog.show(c)}},this);this.on("show",function(){if(!this.store.loaded){this.store.load()}},this,{single:true})};Ext.extend(GO.calendar.CategoriesGrid,GO.grid.GridPanel);GO.calendar.CategoryDialog=function(b){if(!b){b={}}this.buildForm();var a=function(){this.formPanel.items.items[0].focus()};b.layout="fit";b.title=GO.calendar.lang.category;b.modal=false;b.border=false;b.width=400;b.autoHeight=true;b.resizable=false;b.plain=true;b.shadow=false,b.closeAction="hide";b.items=this.formPanel;b.focus=a.createDelegate(this);b.buttons=[{text:GO.lang.cmdOk,handler:function(){this.submitForm(true)},scope:this},{text:GO.lang.cmdApply,handler:function(){this.submitForm(false)},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}];GO.calendar.CategoryDialog.superclass.constructor.call(this,b);this.addEvents({save:true})};Ext.extend(GO.calendar.CategoryDialog,Ext.Window,{show:function(a){if(!this.rendered){this.render(Ext.getBody())}if(a){this.category_id=a.data.id}else{this.category_id=0}if(this.category_id>0){this.formPanel.form.findField("name").setValue(a.data.name);this.formPanel.form.findField("color").setValue(a.data.color);if(GO.settings.has_admin_permission){this.formPanel.form.findField("global").setValue(a.data.user_id==0)}}else{this.formPanel.form.reset()}GO.calendar.CategoryDialog.superclass.show.call(this)},submitForm:function(a){this.formPanel.form.submit({url:GO.settings.modules.calendar.url+"action.php",params:{task:"save_category",id:this.category_id},waitMsg:GO.lang.waitMsgSave,success:function(b,c){if(c.result.id){this.category_id=c.result.id}this.fireEvent("save");if(a){this.hide()}},failure:function(c,d){var b="";if(d.failureType=="client"){b=GO.lang.strErrorsInForm}else{b=d.result.feedback}Ext.MessageBox.alert(GO.lang.strError,b)},scope:this})},buildForm:function(){var a=[];a.push({fieldLabel:GO.lang.strName,name:"name",anchor:"95%",allowBlank:false});a.push(this.colorField=new GO.form.ColorField({fieldLabel:GO.lang.color,value:GO.calendar.defaultBackground,anchor:"50%",name:"color",colors:["EBF1E2","95C5D3","FFFF99","A68340","82BA80","F0AE67","66FF99","CC0099","CC99FF","996600","999900","FF0000","FF6600","FFFF00","FF9966","FF9900","FB0467","D52A6F","CC3370","C43B72","BB4474","B34D75","AA5577","A25E79","FF00CC","D52AB3","CC33AD","C43BA8","BB44A3","B34D9E","AA5599","A25E94","CC00FF","B32AD5","AD33CC","A83BC4","A344BB","9E4DB3","9955AA","945EA2","6704FB","6E26D9","7033CC","723BC4","7444BB","754DB3","7755AA","795EA2","0404FB","2626D9","3333CC","3B3BC4","4444BB","4D4DB3","5555AA","5E5EA2","0066FF","2A6ED5","3370CC","3B72C4","4474BB","4D75B3","5577AA","5E79A2","00CCFF","2AB2D5","33ADCC","3BA8C4","44A3BB","4D9EB3","5599AA","5E94A2","00FFCC","2AD5B2","33CCAD","3BC4A8","44BBA3","4DB39E","55AA99","5EA294","00FF66","2AD56F","33CC70","3BC472","44BB74","4DB375","55AA77","5EA279","00FF00","2AD52A","33CC33","3BC43B","44BB44","4DB34D","55AA55","5EA25E","66FF00","6ED52A","70CC33","72C43B","74BB44","75B34D","77AA55","79A25E","CCFF00","B2D52A","ADCC33","A8C43B","A3BB44","9EB34D","99AA55","94A25E","FFCC00","D5B32A","CCAD33","C4A83B","BBA344","B39E4D","AA9955","A2945E","FF6600","D56F2A","CC7033","C4723B","BB7444","B3754D","AA7755","A2795E","FB0404","D52A2A","CC3333","C43B3B","BB4444","B34D4D","AA5555","A25E5E","FFFFFF","949494","808080","6B6B6B","545454","404040","292929","000000"]}));if(GO.settings.has_admin_permission){a.push(this.globalCategory=new Ext.form.Checkbox({name:"global",boxLabel:GO.calendar.lang.globalCategory,hideLabel:true,checked:false}))}this.formPanel=new Ext.FormPanel({cls:"go-form-panel",anchor:"100% 100%",bodyStyle:"padding:5px",defaultType:"textfield",autoHeight:true,waitMsgTarget:true,labelWidth:75,items:a})}});GO.calendar.SelectDateDialog=function(b){if(!b){b={}}this.buildForm();var a=function(){this.formPanel.items.items[0].focus()};b.layout="fit";b.modal=false;b.border=false;b.width=400;b.autoHeight=true;b.resizable=false;b.plain=true;b.shadow=false,b.title=GO.calendar.lang.copyEvent;b.closeAction="hide";b.items=this.formPanel;b.focus=a.createDelegate(this);b.buttons=[{text:GO.lang.cmdOk,handler:function(){this.beforeSubmit()},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}];GO.calendar.SelectDateDialog.superclass.constructor.call(this,b);this.addEvents({updateEvent:true})};Ext.extend(GO.calendar.SelectDateDialog,Ext.Window,{isCopy:false,event:null,repeats:false,offset:0,view_id:0,show:function(d,b,c,a){if(!this.rendered){this.render(Ext.getBody())}this.event=d;this.isCopy=(b)?true:false;this.repeats=(c)?true:false;this.view_id=(a)?a:0;var e=(this.isCopy)?GO.calendar.lang.copyEvent:GO.calendar.lang.moveEvent;this.setTitle(e);this.datePicker.setValue(this.event.startDate.add(Date.DAY,1));this.selectCalendar.setValue(this.event.calendar_id);this.selectCalendar.setRemoteText(this.event.calendar_name);GO.calendar.SelectDateDialog.superclass.show.call(this)},beforeSubmit:function(){this.offset=Math.ceil((this.datePicker.getValue()-this.event.startDate)/(86400000));var b=this.selectCalendar.getValue();var a=(b!=this.event.calendar_id)?b:0;if(a){this.event.calendar_id=this.formPanel.form.baseParams.update_calendar_id=a}if(this.isCopy){this.formPanel.form.baseParams.task="copy_event";this.formPanel.form.baseParams.event_id=this.event.event_id;this.formPanel.form.baseParams.offset=this.offset}else{this.formPanel.form.baseParams.task="update_grid_event";this.formPanel.form.baseParams.update_event_id=this.event.event_id;this.formPanel.form.baseParams.offsetDays=this.offset;if(this.event.repeats&&!this.repeats){this.formPanel.form.baseParams.repeats=true;this.formPanel.form.baseParams.createException=true;this.formPanel.form.baseParams.exceptionDate=this.event.startDate.format(GO.calendar.daysGrid.dateTimeFormat)}}this.formPanel.form.baseParams.view_id=this.view_id;this.submitForm(a)},submitForm:function(a){this.formPanel.form.submit({waitMsg:GO.lang.waitMsgSave,success:function(d,e){var c=(e.result.event_id)?e.result.event_id:0;var b=(e.result.is_visible)?e.result.is_visible:0;this.fireEvent("updateEvent",this,c,b);if(this.isCopy){delete (this.formPanel.form.baseParams.event_id);delete (this.formPanel.form.baseParams.offset)}else{delete (this.formPanel.form.baseParams.update_event_id);delete (this.formPanel.form.baseParams.offsetDays);if(this.formPanel.form.baseParams.repeats){delete (this.formPanel.form.baseParams.repeats);delete (this.formPanel.form.baseParams.createException);delete (this.formPanel.form.baseParams.exceptionDate)}}if(a){delete (this.formPanel.form.baseParams.update_calendar_id)}this.hide()},failure:function(c,d){var b="";if(d.failureType=="client"){b=GO.lang.strErrorsInForm}else{b=d.result.feedback}if(b){Ext.MessageBox.alert(GO.lang.strError,b)}},scope:this})},buildForm:function(){this.datePicker=new Ext.DatePicker({xtype:"datepicker",format:GO.settings.date_format,fieldLabel:GO.lang.strDate});this.formPanel=new Ext.form.FormPanel({url:GO.settings.modules.calendar.url+"action.php",baseParams:{},cls:"go-form-panel",labelWidth:75,waitMsgTarget:true,autoHeight:true,items:[{items:this.datePicker,width:220,style:"margin:auto;"},new GO.form.HtmlComponent({html:"<br />"}),this.selectCalendar=new GO.calendar.SelectCalendar({fieldLabel:GO.calendar.lang.calendar,anchor:"100%"})]})}});GO.calendar.RecurrenceDialog=function(a){if(!a){a={}}a.width=400;a.autoHeight=true;a.closeable=false;a.closeAction="hide";a.plain=true;a.border=false;a.closable=false;a.title=GO.calendar.lang.recurringEvent;a.modal=false;a.html=GO.calendar.lang.editRecurringEvent;a.focus=function(){this.getFooterToolbar().items.get("single").focus()};a.buttons=[{itemId:"single",text:GO.calendar.lang.singleOccurence,handler:function(){this.fireEvent("single",this)},scope:this},{text:GO.calendar.lang.entireSeries,handler:function(){this.fireEvent("entire",this)},scope:this},{text:GO.lang.cmdCancel,handler:function(){this.fireEvent("cancel",this)},scope:this}];GO.calendar.RecurrenceDialog.superclass.constructor.call(this,a);this.addEvents({single:true,entire:true,cancel:true})};Ext.extend(GO.calendar.RecurrenceDialog,Ext.Window,{show:function(){GO.calendar.RecurrenceDialog.superclass.show.call(this)}});GO.calendar.ContextMenu=function(a){if(!a){a={}}a.items=[{iconCls:"btn-properties",text:GO.calendar.lang.showInfo,cls:"x-btn-text-icon",scope:this,handler:function(){this.showEventInfoDialog()}},new Ext.menu.Separator(),this.actionCopy=new Ext.menu.Item({iconCls:"btn-copy",text:GO.lang.copy,cls:"x-btn-text-icon",scope:this,disabled:true,handler:function(){this.showSelectDateDialog(true,false)}}),this.actionCut=new Ext.menu.Item({iconCls:"btn-cut",text:GO.calendar.lang.move,cls:"x-btn-text-icon",scope:this,disabled:true,handler:function(){if(this.event.repeats){this.menuHandler()}else{this.showSelectDateDialog(false,false)}}}),new Ext.menu.Separator(),this.actionDelete=new Ext.menu.Item({iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",scope:this,disabled:true,handler:function(){this.fireEvent("deleteEvent",this)}})];if(GO.timeregistration){this.actionAddTimeRegistration=new Ext.menu.Item({text:GO.calendar.lang.addTimeRegistration,iconCls:"go-menu-icon-timeregistration",cls:"x-btn-text-icon",scope:this,handler:function(){this.showAddTimeRegistrationDialog()}});a.items.splice(1,0,this.actionAddTimeRegistration)}GO.calendar.ContextMenu.superclass.constructor.call(this,a);this.addEvents({updateEvent:true})};Ext.extend(GO.calendar.ContextMenu,Ext.menu.Menu,{event:null,view_id:0,setEvent:function(b,a){this.event=b;this.view_id=(a)?a:0;this.actionCopy.setDisabled(this.event.read_only);this.actionCut.setDisabled(this.event.read_only);this.actionDelete.setDisabled(this.event.read_only)},showAddTimeRegistrationDialog:function(){if(!this.addTimeRegistrationDialog){this.addTimeRegistrationDialog=new GO.timeregistration.addTimeRegistrationDialog()}this.addTimeRegistrationDialog.show(this.event)},showSelectDateDialog:function(a,b){if(!this.selectDateDialog){this.selectDateDialog=new GO.calendar.SelectDateDialog();this.selectDateDialog.on("updateEvent",function(e,d,c){this.fireEvent("updateEvent",e,d,c)},this)}this.selectDateDialog.show(this.event,a,b,this.view_id)},showEventInfoDialog:function(){GO.linkHandlers[1].call(this,this.event.event_id)},menuHandler:function(){if(!this.menuRecurrenceDialog){this.menuRecurrenceDialog=new GO.calendar.RecurrenceDialog();this.menuRecurrenceDialog.on("single",function(){this.showSelectDateDialog(false,false);this.menuRecurrenceDialog.hide()},this);this.menuRecurrenceDialog.on("entire",function(){this.showSelectDateDialog(false,true);this.menuRecurrenceDialog.hide()},this);this.menuRecurrenceDialog.on("cancel",function(){this.menuRecurrenceDialog.hide()},this)}this.menuRecurrenceDialog.show()}});GO.calendar.SelectCalendarDialog=function(b){if(!b){b={}}this.buildForm();var a=function(){this.formPanel.items.items[0].focus()};b.layout="fit";b.title=GO.calendar.lang.selectCalendar;b.modal=false;b.border=false;b.width=400;b.autoHeight=true;b.resizable=false;b.plain=true;b.shadow=false,b.closeAction="hide";b.items=this.formPanel;b.focus=a.createDelegate(this);b.buttons=[{text:GO.lang.cmdOk,handler:function(){this.submitForm(true)},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}];GO.calendar.SelectCalendarDialog.superclass.constructor.call(this,b);this.addEvents({calendar_selected:true})};Ext.extend(GO.calendar.SelectCalendarDialog,Ext.Window,{submitForm:function(a){this.fireEvent("calendar_selected",this.selectCalendar.getValue());this.hide()},buildForm:function(){this.selectCalendar=new GO.form.ComboBox({hiddenName:"cal_id",fieldLabel:GO.calendar.lang.calendar,valueField:"id",displayField:"name",store:new Ext.data.ArrayStore({fields:["id","name"]}),mode:"local",triggerAction:"all",emptyText:GO.calendar.lang.selectCalendar,editable:false,selectOnFocus:true,forceSelection:true});this.formPanel=new Ext.FormPanel({cls:"go-form-panel",anchor:"100% 100%",bodyStyle:"padding:5px",defaults:{anchor:"95%"},defaultType:"textfield",autoHeight:true,waitMsgTarget:true,labelWidth:75,items:this.selectCalendar})},populateComboBox:function(a){var c=[];for(var b=0;b<a.length;b++){var d=[];d.push(a[b].id);d.push(a[b].name);c.push(d)}this.selectCalendar.store.loadData(c);var e=this.selectCalendar.store.getAt(0);if(e){this.selectCalendar.setValue(e.data.id)}}});GO.moduleManager.on("moduleconstructed",function(d,c,b){if(c=="settings"){var a=new Ext.form.FieldSet({title:GO.calendar.lang.calendar,items:[{xtype:"textfield",name:"calendar_name_template",fieldLabel:GO.calendar.lang.globalsettings_templatelabel,width:300},{xtype:"checkbox",name:"change_all_calendar_names",fieldLabel:GO.calendar.lang.globalsettings_allchangelabel,listeners:{check:function(e,f){if(f&&!confirm(GO.calendar.lang.globalsettings_renameall)){e.setValue(false)}},scope:this}}]});b.add(a)}});