Ext.namespace("PMS.FNTabVARIABLES"); PMS.FNTabVARIABLES= function(myTabName, TabText){ function WindowNewVariable(){ var myformpanelwindows12 = new Ext.FormPanel({ frame:true, labelAlign: 'right', bodyStyle:'padding:5px', width: 300, height:180, waitMsgTarget: true, layout: 'form', items: [ {name: 'variablename', xtype:'textfield', fieldLabel: 'CODE'}, {name: 'variabletext', xtype:'textfield', fieldLabel: 'Text'}, {name: 'variablecomment', xtype:'textfield', fieldLabel: 'Comment'}, new Ext.form.Checkbox({ fieldLabel: 'Active', name:'variableactive'})] }); // Create Window Property of variablerary var myfunction = function(){ myformpanelwindows12.form.submit({ url:'modules/main/js/varsadd-newvariable.php', waitMsg:'Saving ...', success: function (form, action) { Ext.getCmp("listvariables").getStore().load(); win2.close();}, failure:function(form, action) { var SucParams = Ext.decode(action.response.responseText); Ext.MessageBox.alert('ERRORS', SucParams['errors']['strmsg']);} }); }; var win2 = new Ext.Window({ width:300, height:200, autoCreate : true, title:"New variable", resizable:false, constrain:true, constrainHeader:true, minimizable : false, maximizable : false, stateful: false, shim:true, buttonAlign:"center", autoScrool:true, modal:true, plain:true, footer:true, closable:true, items: myformpanelwindows12, buttons: [{ text:'Add',handler: myfunction }, { text: 'Cancel', handler: function(){ win2.hide();} }], buttonAlign: 'center' }); win2.show(this); }; function WindowNewValue(idSelectedID, parentID){ var myformpanelwindows12 = new Ext.FormPanel({ frame:true, labelAlign: 'right', bodyStyle:'padding:5px', width: 300, height:160, waitMsgTarget: true, layout: 'form', id: 'mynewvalueform', baseParams: {variableid: idSelectedID, mparent:parentID}, items: [ {name: 'valuetext', xtype:'textfield', fieldLabel: 'Text'}, {name: 'valuecomment', xtype:'textfield', fieldLabel: 'Comment'}] }); // Create Window Property of variablerary var myfunction = function(){ myformpanelwindows12.form.submit({ url:'modules/main/js/varsadd-newvalue.php', waitMsg:'Saving ...', success: function (form, action) { if(parentID==0) Ext.getCmp("myvariablevalues").getStore().load(); if(parentID>0) Ext.getCmp("myvariablechildvalues").getStore().load(); win2.close();}, failure:function(form, action) { var SucParams = Ext.decode(action.response.responseText); Ext.MessageBox.alert('ERRORS', SucParams['errors']['strmsg']);} }); }; var win2 = new Ext.Window({ width:300, height:160, autoCreate : true, title:"New value", resizable:false, constrain:true, constrainHeader:true, minimizable : false, maximizable : false, stateful: false, shim:true, buttonAlign:"center", autoScrool:true, modal:true, plain:true, footer:true, closable:true, items: myformpanelwindows12, buttons: [{ text:'Add',handler: myfunction }, { text: 'Cancel', handler: function(){ win2.hide();} }], buttonAlign: 'center' }); win2.show(); }; function RemoveValues(){ var gridCmp = Ext.getCmp('myvariablevalues'); if(gridCmp.getSelectionModel().hasSelection()){ var selectionsList = gridCmp.getSelectionModel().getSelections(); var selectedUsersId = ""; var selectedUsersText = ""; for(var i = 0;i0) { var rres=RegCheck1.getAt(0).get('suscess'); if (!rres=='ok') { Ext.MessageBox.show({ title: 'TITLE', msg: RegCheck1.getAt(0).get('text'), buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO}); }else{ Ext.getCmp('myvariablevalues').getStore().load(); } } }); RegCheck1.load(); } ); }else{ Ext.MessageBox.show({ title: 'Warning ... ', msg: "No selected item(s) ", buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.WARNING}); } }; function RemoveValues1(){ var gridCmp = Ext.getCmp('myvariablechildvalues'); if(gridCmp.getSelectionModel().hasSelection()){ var selectionsList = gridCmp.getSelectionModel().getSelections(); var selectedUsersId = ""; var selectedUsersText = ""; for(var i = 0;i0) { var rres=RegCheck1.getAt(0).get('suscess'); if (!rres=='ok') { Ext.MessageBox.show({ title: 'TITLE', msg: RegCheck1.getAt(0).get('text'), buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO}); }else{ Ext.getCmp('myvariablechildvalues').getStore().load(); } } }); RegCheck1.load(); } ); }else{ Ext.MessageBox.show({ title: 'Warning ... ', msg: "No selected item(s) ", buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.WARNING}); } }; // Function for double click Groups grid rows function WindowEditVariable(grid, rowIndex, columnIndex, e){ var SelectedRecord = grid.getStore().getAt(rowIndex); var MyID = SelectedRecord.get("id"); var SelectedVarID = grid.getStore().baseParams['variableid']; var MyStore = new Ext.data.JsonStore({ autoLoad: true, baseParams: {variableid: SelectedVarID, parent:MyID}, url: 'modules/main/js/varsget-variablevalues.php', root: 'variablevalues', fields: ['id', 'text', 'comment']}); // Create Form of property of Group for window var myformpanelwindows = new Ext.FormPanel({ frame:true, labelAlign: 'right', bodyStyle:'padding:5px', width: 503, height:340, waitMsgTarget: true, baseParams:{myid:MyID}, items: [{ layout: 'form', border:false, resizable:false, width: 480, height:100, items:[ {name: 'variableid', xtype:'textfield', fieldLabel: 'ID', disabled:true}, {name: 'variabletext', xtype:'textfield', fieldLabel: 'CODE'}, {name: 'variablecomment', xtype:'textfield', fieldLabel:'Comment'} ] }, { title:' Child values ', layout:'fit', defaults: {width: 450}, frame:true, border:false, items: [ new Ext.grid.GridPanel({ xtype:'grid', store: MyStore, border:true, frame:true, id: 'myvariablechildvalues', cm: new Ext.grid.ColumnModel([ new Ext.grid.CheckboxSelectionModel(), {id:'id',header: "ID", width: 50, sortable: true, dataIndex: 'id'}, {header: "Text", width: 100, sortable: true, dataIndex: 'text'}, {header: "Comment", width: 100, sortable: true, dataIndex: 'comment'} ]), sm: new Ext.grid.CheckboxSelectionModel(), viewConfig: { forceFit:true}, width:450, height:170, tbar:[{ text:'Add', tooltip:'Add value to variable', iconCls:'add', handler: function(){ WindowNewValue(SelectedVarID,MyID); } }, '-', { text:'Remove', tooltip:'Remove selected value(s) from variable', iconCls:'remove', handler: RemoveValues1 }], loadMask:true }) ] }] }); var FNCSavevariable = function(){ myformpanelwindows.form.submit({ url:'modules/main/js/varssavechild-variable.php', // PHP waitMsg:'Saving Data...', success: function (form, action) { win.close(); Ext.getCmp('myvariablevalues').getStore().load(); }, failure:function(form, action) { var SucParams = Ext.decode(action.response.responseText); Ext.MessageBox.alert('ERRORS', SucParams['errors']['strmsg']); } }); }; // Create Window Property of Group var win = new Ext.Window({ width:519, height:410, autoCreate : true, title:"variablerary Property ", resizable:false, constrain:true, constrainHeader:true, minimizable : false, maximizable : false, stateful: false, shim:true, buttonAlign:"center", autoScrool:true, modal:true, plain:true, footer:true, closable:true, items: myformpanelwindows, buttons: [ { text:'Save', handler: FNCSavevariable }, { text: 'Close', handler: function(){ win.hide();} }], buttonAlign: 'center' }); win.show(this); myformpanelwindows.getForm().load({url:'modules/main/js/varsgetchild-variable.php', waitMsg:'Loading ... ', success:function(form, action) { }, failure:function(form, action) { Ext.MessageBox.alert('Message', action.response.responseText); win.hide(); } }); }; // Function for double click Groups grid rows function WindowVariable(grid, rowIndex, columnIndex, e){ var SelectedRecord = grid.getStore().getAt(rowIndex); var SelectedID = SelectedRecord.get("id"); var MyStore = new Ext.data.JsonStore({ autoLoad: true, baseParams: {variableid: SelectedID}, url: 'modules/main/js/varsget-variablevalues.php', root: 'variablevalues', fields: ['id', 'text', 'comment']}); // Create Form of property of Group for window var myformpanelwindows = new Ext.FormPanel({ frame:true, labelAlign: 'right', bodyStyle:'padding:5px', width: 503, height:340, waitMsgTarget: true, baseParams:{variableid: SelectedID}, items: [{ layout:'column', border:false, resizable:false, width: 480, height:60, items:[{ layout: 'form', columnWidth:.5, border:false, items: [ {name: 'variableid', xtype:'textfield', fieldLabel: 'ID', disabled:true}, {name: 'variablename', xtype:'textfield', fieldLabel: 'CODE'}] },{ columnWidth:.5, layout: 'form', border:false, items: [ {name: 'variabletext', xtype:'textfield', fieldLabel: 'NAME'}, new Ext.form.Checkbox({ fieldLabel: 'Active', name:'variableactive'})] }] }, { xtype:'tabpanel', plain:true, activeTab: 0, height:250, width: 480, deferredRender:false, items:[{ title:' Info ', layout:'form', defaults: {width: 230}, defaultType: 'textfield', frame:true, border:false, iconCls:'nav', labelWidth:150, items: [ {fieldLabel: 'Registration date', name: 'variablecdate', disabled:true }, {fieldLabel: 'Author', name: 'variablecaut', disabled:true }, {fieldLabel: 'Last Update', name: 'variableudate', disabled:true }, {fieldLabel: 'Update author', name: 'variableuaut', disabled:true }] },{ title:' Values ', layout:'fit', defaults: {width: 450}, frame:true, border:false, iconCls:'nav', items: [ new Ext.grid.GridPanel({ xtype:'grid', store: MyStore, border:true, frame:true, id: 'myvariablevalues', cm: new Ext.grid.ColumnModel([ new Ext.grid.CheckboxSelectionModel(), {id:'id',header: "ID", width: 50, sortable: true, dataIndex: 'id'}, {header: "Text", width: 100, sortable: true, dataIndex: 'text'}, {header: "Comment", width: 100, sortable: true, dataIndex: 'comment'} ]), sm: new Ext.grid.CheckboxSelectionModel(), viewConfig: { forceFit:true}, width:450, height:170, tbar:[{ text:'Add', tooltip:'Add value to variable', iconCls:'add', handler: function(){WindowNewValue(SelectedID, 0);} }, '-',{ text:'Edit', tooltip:'Edit value to variable', iconCls:'edit', handler: function(){ var mygrid = Ext.getCmp('myvariablevalues'); if(mygrid.getSelectionModel().hasSelection()){ var selectionsList = mygrid.getSelectionModel().getSelections(); var selectedURecord = selectionsList[0]; selectedUsersId = selectedURecord.get('id'); myrowIndex = mygrid.getStore().indexOf(selectedURecord); mygrid.getSelectionModel().clearSelections(); mygrid.getSelectionModel().selectRow(myrowIndex); mygrid.fireEvent("celldblclick", mygrid, myrowIndex,0,null); }else{ Ext.MessageBox.show({ title: 'TITLE', msg: "No selected item", buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO}); } } }, '-',{ text:'Remove', tooltip:'Remove selected value(s) from variable', iconCls:'remove', handler: RemoveValues }], listeners: { celldblclick: WindowEditVariable} }) ] },{ title:' Comment ', layout:'fit', frame:true, border:false, iconCls:'nav', items: { xtype:'textarea', name:'variablecomment', fieldLabel:'Comment'} }] }] }); var FNCSavevariable = function(){ myformpanelwindows.form.submit({ url:'modules/main/js/varssave-variable.php', // PHP waitMsg:'Saving Data...', success: function (form, action) { win.close(); Ext.getCmp('listvariables').getStore().load(); }, failure:function(form, action) { var SucParams = Ext.decode(action.response.responseText); Ext.MessageBox.alert('ERRORS', SucParams['errors']['strmsg']); } }); }; // Create Window Property of Group var win = new Ext.Window({ width:519, height:410, autoCreate : true, title:"variablerary Property ", resizable:false, constrain:true, constrainHeader:true, minimizable : false, maximizable : false, stateful: false, shim:true, buttonAlign:"center", autoScrool:true, modal:true, plain:true, footer:true, closable:true, items: myformpanelwindows, buttons: [ { text:'Save', handler: FNCSavevariable }, { text: 'Close', handler: function(){ win.hide();} }], buttonAlign: 'center' }); win.show(this); myformpanelwindows.getForm().load({url:'modules/main/js/varsget-variable.php', waitMsg:'Loading ... ', success:function(form, action) { }, failure:function(form, action) { Ext.MessageBox.alert('Message', action.response.responseText); win.hide(); } }); }; function DelVariable(idVariable){ var RegCheck2 = new Ext.data.JsonStore({ url: 'modules/main/js/varsrem-variables.php', baseParams: { selVariables: idVariable}, root: 'data', totalProperty: 'count', fields: ['suscess', 'text'] }); RegCheck2.on('load',function(){ if (RegCheck2.getTotalCount()>0) { var rres=RegCheck2.getAt(0).get('suscess'); if (rres=='rok') { Ext.MessageBox.show({ title: 'WARNING', msg: RegCheck2.getAt(0).get('text'), buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.WARNING}); } Ext.getCmp('listvariables').getStore().load(); } }); RegCheck2.load(); }; //var MyStore = new Ext.data.JsonStore({ url: 'modules/main/js/varsget-variables.php', root: 'variables', }); var MyNewStore = new Ext.data.Store({ url: 'modules/main/js/varsget-variables.php', remoteSort: true, reader: new Ext.data.JsonReader({ root: 'variables', totalProperty: 'totalCount', fields: ['id', 'name', 'text', 'comment','active']}) }); MyNewStore.setDefaultSort('id', 'asc'); t = new Ext.Panel({ id: myTabName, title: ' ' + TabText, iconCls:'vars', autoScroll:true, listeners: { activate: handleActivate }, closable:true, layout:'fit', items: [{ xtype:'grid', id: 'listvariables', title:'List variableraries ', store: MyNewStore, cm: new Ext.grid.ColumnModel([ new Ext.grid.CheckboxSelectionModel(), {id:'id',header: "ID", width: 25, sortable: true, dataIndex: 'id'}, {header: "Code", width: 100, sortable: true, dataIndex: 'name'}, {header: "Name", width: 100, sortable: true, dataIndex: 'text'}, {header: "Comment", width: 200, sortable: true, dataIndex: 'comment'} ]), sm: new Ext.grid.CheckboxSelectionModel(), viewConfig: { forceFit:true}, width: 'auto', loadMask: {msg: 'Loading Users'}, bbar: new Ext.PagingToolbar({ pageSize: 15, store: MyNewStore, displayInfo: true }), tbar:[ { text:'Add', tooltip:'Add a new variable', iconCls:'add', handler: WindowNewVariable}, '-', { text:'Edit', tooltip:'Edit the selected variable', iconCls:'edit', handler: function(){ var mygrid = Ext.getCmp('listvariables'); if(mygrid.getSelectionModel().hasSelection()){ var selectionsList = mygrid.getSelectionModel().getSelections(); var selectedURecord = selectionsList[0]; selectedUsersId = selectedURecord.get('id'); myrowIndex = mygrid.getStore().indexOf(selectedURecord); mygrid.getSelectionModel().clearSelections(); mygrid.getSelectionModel().selectRow(myrowIndex); mygrid.fireEvent("celldblclick", mygrid, myrowIndex,0,null); }else{ Ext.MessageBox.show({ title: 'TITLE', msg: "No selected item", buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO}); } }},'-', { text:'Delete', tooltip:'Delete the selected variable', iconCls:'remove', handler: function(){ var gridCmpSel = Ext.getCmp('listvariables'); if(gridCmpSel.getSelectionModel().hasSelection()){ var selectionsList = gridCmpSel.getSelectionModel().getSelections(); var selectedGroupdId = ""; var selectedGroupText = ""; for(var i = 0;i