Ext.define("MyApp.Application",{name:"MyApp",extend:Ext.app.Application,views:[],controllers:[],stores:[]});Ext.define("MyApp.controller.Main",{extend:Ext.app.Controller});Ext.define("MyApp.controller.NotificationSettings",{extend:Ext.app.Controller,refs:[{ref:"myForm",selector:"#myForm"},{ref:"defaultLanguageCombo",selector:"#defaultLanguageCombo"},{ref:"saveButton",selector:"#saveButton"},{ref:"notificationOverdueFrequencyCombo",selector:"#notificationOverdueFrequencyCombo"}],init:function(a){this.control({"#saveButton":{click:this.save},"#myForm":{dirtychange:function(b,c){if(c){this.getSaveButton().enable()}else{this.getSaveButton().disable()}},actioncomplete:function(b,d,c){this.load()}}})},load:function(){Ext.Ajax.request({url:"../../service/settings.php",method:"GET",params:Ext.Object.fromQueryString(document.location.search),success:function(b,c){var a=Ext.JSON.decode(b.responseText).result;this.getMyForm().getForm().setValues(a)},failure:function(a,b){var c=a.responseText;Ext.Error.raise({msg:"Failed to get current settings",option:c,object:b})},scope:this})},save:function(b){b.disable();var a=this.getMyForm().getForm().getValues();a.user=Ext.Object.fromQueryString(document.location.search).user;a.system=Ext.Object.fromQueryString(document.location.search).system;a.client=Ext.Object.fromQueryString(document.location.search).client;Ext.Ajax.request({url:"../../service/settings.php",method:"POST",params:Ext.Object.fromQueryString(document.location.search),jsonData:a,success:function(c,d){this.load()},failure:function(c,d){var e=c.responseText;Ext.MessageBox.alert("Failed to get current settings",e)},scope:this})},onLaunch:function(){this.load()}});Ext.define("MyApp.model.Frequency",{extend:Ext.data.Model,fields:[{name:"text"},{name:"interval"}]});Ext.define("MyApp.model.Language",{extend:Ext.data.Model,fields:[{name:"code"},{name:"title"},{name:"icon"}]});Ext.define("MyApp.store.FrequencyStore",{extend:Ext.data.Store,constructor:function(a){var b=this;a=a||{};b.callParent([Ext.apply({autoLoad:true,model:"MyApp.model.Frequency",storeId:"FrequencyStore",proxy:{type:"ajax",url:"../../../common/service/get_frequencies.php",reader:{type:"json",root:"result"}},listeners:{beforeload:{fn:b.onJsonstoreBeforeLoad,scope:b}}},a)])},onJsonstoreBeforeLoad:function(b,a,c){b.getProxy().extraParams=Ext.Object.fromQueryString(document.location.search);b.getProxy().extraParams.excluded=Ext.JSON.encode([0])}});Ext.define("MyApp.store.LanguageStore",{extend:Ext.data.Store,constructor:function(a){var b=this;a=a||{};b.callParent([Ext.apply({autoLoad:true,model:"MyApp.model.Language",storeId:"LanguageStore",proxy:{type:"ajax",url:"../../../common/service/languages_get_available.php",reader:{type:"json"}}},a)])}});Ext.define("MyApp.view.Main",{extend:Ext.panel.Panel,border:false,layout:"fit",header:false,title:"My Panel",initComponent:function(){var a=this;Ext.applyIf(a,{items:[{xtype:"fieldset",margin:"0 5 10 5",title:"Notification settings",layout:{type:"vbox",align:"stretch"},items:[{xtype:"form",flex:1,border:false,itemId:"myForm",layout:"auto",pollForChanges:true,pollInterval:25,jsonSubmit:true,trackResetOnLoad:true,items:[{xtype:"container",margin:"0 0 5 0",layout:{type:"hbox",align:"stretch"},items:[{xtype:"textfield",width:200,fieldLabel:"Sender email address",labelAlign:"top",labelSeparator:" ",name:"notification_sender_mail"}]},{xtype:"combobox",itemId:"defaultLanguageCombo",width:200,fieldLabel:"Notification language",labelAlign:"top",labelSeparator:" ",name:"notification_language",displayField:"title",store:"LanguageStore",valueField:"code"},{xtype:"combobox",itemId:"notificationOverdueFrequencyCombo",width:200,fieldLabel:"Send reminder for overdue controls",labelAlign:"top",labelSeparator:" ",name:"notification_overdue_frequency",store:"FrequencyStore",valueField:"interval"},{xtype:"checkboxfield",labelSeparator:" ",name:"mail_on_response",boxLabel:"Mail on response",inputValue:"1",uncheckedValue:"0"},{xtype:"checkboxfield",labelSeparator:" ",name:"mail_to_executer",boxLabel:"Mail to executer",inputValue:"1",uncheckedValue:"0"}]},{xtype:"container",margins:"20 0 8 20",layout:{type:"hbox",align:"bottom",pack:"end"},items:[{xtype:"button",disabled:true,itemId:"saveButton",padding:"5 10 5 10",icon:"../../gfx/save.png",scale:"medium",text:"Save changes"}]}]}]});a.callParent(arguments)}});Ext.define("MyApp.view.Viewport",{extend:Ext.container.Viewport,layout:{type:"fit"},items:[{xtype:"app-main"}]});