var ds; var dsp; var qf; var gfg; var BusyFlagCounter = 0; wRok = '2008'; wRodzaj = ''; Ext.onReady(function(){ $("#content").append('
'); $("#content").append('
'); $("#content").append('
'); Ext.QuickTips.init(); // turn on validation errors beside the field globally Ext.form.Field.prototype.msgTarget = 'side'; var tb = new Ext.Toolbar({ width: 250, height: 25 }); tb.render('toptoolbar'); tb.add('-',{ text: 'Pokaż mapę (liczby)', id: 'btnShowMapNumbers', tooltip: 'Pokaż w formie mapy (liczbowo)', handler: toolbarHandler },'-',{ text: 'Pokaż mapę (kolory)', id: 'btnShowMapColors', tooltip: 'Pokaż w formie mapy (kolory)', disabled: false, handler: toolbarHandler },'-'); var bd = Ext.get('window'); // Define the Grid data and create the Grid ds = new Ext.data.Store({ //proxy: new Ext.data.ScriptTagProxy({ url: WWW_PREFIX+'/data/grid_values.php', //}), timeoute: 1000, baseParams: { win_name: 'mapa_wyswietlanie'}, reader: new Ext.data.JsonReader({ root: 'result.rows', timeoute:1000, totalProperty: 'result.total', id: 'id', fields: [ {name: 'id',type: 'int'}, {name: 'wartosc'}, {name: 'rok'}, {name: 'umru_nazwa'}, {name: 'umru_kod'} ] }), listeners: { load: function(){ Ext.getCmp('grid').getSelectionModel().selectFirstRow(); //clearBusyFlag; } } }); dsp = new Ext.data.Store({ //proxy: new Ext.data.ScriptTagProxy({ url: WWW_PREFIX+'/data/grid_values.php', //}), timeoute: 1000, baseParams: { win_name: 'mapa_wyswietlanie_powiaty', filtr: '' }, reader: new Ext.data.JsonReader({ root: 'result.rows', timeoute:1000, totalProperty: 'result.total', id: 'id', fields: [ {name: 'id',type: 'int'}, {name: 'wartosc'}, {name: 'rok'}, {name: 'umru_nazwa'}, {name: 'smap_nazwa'}, {name: 'ilosc'} ] }), listeners: { load: function(){ Ext.getCmp('gridp').getSelectionModel().selectFirstRow(); //clearBusyFlag; } } }); dsg = new Ext.data.Store({ //proxy: new Ext.data.ScriptTagProxy({ url: WWW_PREFIX+'/data/grid_values.php', //}), timeoute: 1000, baseParams: { win_name: 'mapa_wyswietlanie_gminy', filtr: '' }, reader: new Ext.data.JsonReader({ root: 'result.rows', timeoute:1000, totalProperty: 'result.total', id: 'id', fields: [ {name: 'id',type: 'int'}, {name: 'wartosc'}, {name: 'rok'}, {name: 'umru_nazwa'}, {name: 'smap_nazwa'}, {name: 'smag_nazwa'}, {name: 'ilosc'} ] }), listeners: { load: function(){ Ext.getCmp('gridg').getSelectionModel().selectFirstRow(); //clearBusyFlag; } } }); // listeners: { // load: function(sm, row, rec) { // } //ds.onload(setBusyFlag); //ds.loadData(myData); //ds.loadData(); //ds.load({params:{start:0, limit:25}}); // example of custom renderer function // {header: "name", width: 75, sortable: true, renderer: change, dataIndex: 'name'}, // {header: "label", width: 75, sortable: true, renderer: pctChange, dataIndex: 'label'}, // {header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'} var colModel = new Ext.grid.ColumnModel([ {header: "Rok", width: 40, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'rok'}, {header: "Rodzaj umowy", width: 110, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'umru_nazwa'}, {header: "Wartość", width: 90, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'wartosc',align: 'right'} ]); var colModelp = new Ext.grid.ColumnModel([ {header: "Rok", width: 40, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'rok'}, {header: "Rodzaj umowy", width: 110, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'umru_nazwa'}, {header: "Wartość", width: 90, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'wartosc',align: 'right'}, {header: "Powiat", width: 130, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'smap_nazwa'}, {header: "Ilość", width: 40, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'ilosc'} ]); var colModelg = new Ext.grid.ColumnModel([ {header: "Rok", width: 40, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'rok'}, {header: "Rodzaj umowy", width: 110, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'umru_nazwa'}, {header: "Wartość", width: 90, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'wartosc',align: 'right'}, {header: "Gmina", width: 100, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'smag_nazwa'}, {header: "Powiat", width: 95, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'smap_nazwa'}, {header: "Ilość", width: 40, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'ilosc'} ]); //bd.createChild({tag: 'h2', html: 'Panel administracyjny portalu - edycja powiatu '}); /* * Here is where we create the Form */ var tabs2 = new Ext.TabPanel({ renderTo: bd, activeTab: 0, deferredRender: false, width:510, height:530, plain:true, defaults:{autoScroll: true}, items:[{ title: 'Wartość zawartych umów', html: "
" },{ title: 'Według powiatów', html: "
" },{ title: 'Według gmin', listeners: {activate: handleActivate}, html: "
" } ] }); var wu = Ext.get('wartosc_umow'); var gridForm = new Ext.Panel({ frame: true, id: 'grid_umowy', labelAlign: 'top', bodyStyle:'padding:5px', width: 500, bbar: new Ext.PagingToolbar({ store: ds, id: 'bba', pageSize: 20, displayInfo: true }), layout: 'fit', // Specifies that the items will now be arranged in columns items: [{ xtype: 'grid', ds: ds, id: 'grid', cm: colModel, loadMask: true, sm: new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { //Ext.getCmp("company-form").getForm().loadRecord(rec); umowy_rowActivate(rec.get('rok'),rec.get('umru_kod')); //alert(rec.get('id')); } } }), height: 450, width: 490, border: true, viewConfig: { getRowClass : function (row, index) { var cls = ''; //var store = row.store; //sd=dn; if (row.data.umru_nazwa.indexOf('razem') !=-1){ cls = 'red-row'; } //alert (row.data.umru_nazwa); return cls; } }, listeners: { render: function(g) { //g.getSelectionModel().selectRow(0); Ext.getCmp('grid').getSelectionModel().selectFirstRow(); },rowdblclick: function(grid, row, rec) { //alert('Clicked'); window.open(WWW_PREFIX+'/modules/mapa/index.php?typ=colors&rok='+wRok+'&rodzaj='+wRodzaj,'mapa','menubar=no,toolbar=no ,location=no, scrollbars=yes, resizable=yes'); }, delay: 10 // Allow rows to be rendered. } }], renderTo: wu }); var wp = Ext.get('wart_wg_powiatow'); var gridFormpowiaty = new Ext.Panel({ frame: true, id: 'grid_powiaty', labelAlign: 'top', bodyStyle:'padding:5px', width: 500, layout: 'fit', // Specifies that the items will now be arranged in columns bbar: new Ext.PagingToolbar({ store: dsp, id: 'bba', pageSize: 20, displayInfo: true }), items: [{ xtype: 'grid', ds: dsp, id: 'gridp', cm: colModelp, loadMask: true, sm: new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { //umowy_rowActivate(rec.get('rok'),rec.get('umru_kod')); //Ext.getCmp("company-form").getForm().loadRecord(rec); //rowActivate(rec.get('id')); //alert(rec.get('id')); } } }), height: 450, width: 460, border: true, listeners: { render: function(g) { Ext.getCmp('gridp').getSelectionModel().selectFirstRow(); //g.getSelectionModel().selectRow(0); }, delay: 10 // Allow rows to be rendered. } }], renderTo: wp }); var wg = Ext.get('wart_wg_gmin'); var gridFormpowiaty = new Ext.Panel({ frame: true, id: 'grid_gminy', labelAlign: 'top', bodyStyle:'padding:5px', width: 500, layout: 'fit', // Specifies that the items will now be arranged in columns bbar: new Ext.PagingToolbar({ store: dsg, id: 'bba', pageSize: 20, displayInfo: true }), items: [{ xtype: 'grid', ds: dsg, id: 'gridg', cm: colModelg, loadMask: true, sm: new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { //Ext.getCmp("company-form").getForm().loadRecord(rec); //rowActivate(rec.get('id')); //alert(rec.get('id')); } } }), height: 450, width: 490, border: true, listeners: { render: function(g) { Ext.getCmp('gridp').getSelectionModel().selectFirstRow(); //g.getSelectionModel().selectRow(0); }, delay: 10 // Allow rows to be rendered. } }], renderTo: wg }); //ds.load(); ds.load({params:{start: 0, limit: 20}}); //dsp.load({params:{start: 0, limit: 20}}); //Ext.getCmp('grid').getSelectionModel().selectFirstRow(); //Ext.getCmp('gridp').getSelectionModel().selectFirstRow(); //ds.load(); }); function rowActivate(field){ setBusyFlag(); Ext.Ajax.request({ url: WWW_PREFIX+'/data/form_values.php', success: readFormDataSuccess, failure: readFormDataFailure, headers: { 'my-header': 'foo' }, params: { field: field, nocache: 'true', win_id: 2} }); alert(1); }; function umowy_rowActivate(rok,rodzaj){ wRok=rok; wRodzaj=rodzaj; qf="rok='"+rok+"' and umru_kod='"+rodzaj+"'"; dsp.baseParams.filtr=qf; dsp.load({params:{start: 0, limit: 20}}); qfg = "rok='"+rok+"' and umru_kod='"+rodzaj+"'"; dsg.baseParams.filtr=qfg; dsg.load({params:{start: 0, limit: 20}}); //alert (qf); //q="rok = 'rok', " //setBusyFlag(); }; function umowy_powiaty_rowActivate(rok,rodzaj){ //qfg="rok='"+rok+"' and umru_kod='"+rodzaj+"'"; //dsg.baseParams.filtr=qfg; //dsg.load({params:{start: 0, limit: 20}}); //alert (qf); //q="rok = 'rok', " //setBusyFlag(); }; function handleActivate(){ } function readFormDataSuccess(responseObject){ clearBusyFlag(); var arr=Ext.util.JSON.decode(responseObject.responseText); //test=Ext.util.JSON.decode('{"cvalues":[{"id":"1014...7","y_tekst":"419620.64590","kolor":"75c5f0"}]}'); //alert (arr['cvalues'][0]['kolor']); /* Ext.getCmp('wx').setValue(arr['cvalues']['wx']); Ext.getCmp('wy').setValue(arr['cvalues']['wy']); Ext.getCmp('warstwa').setValue(arr['cvalues']['warstwa']); Ext.getCmp('colorbox').setValue(arr['cvalues']['colorbox_value']); */ }; function readFormDataFailure(){ clearBusyFlag(); // alert('Failure'); }; function save_values(){ var vid = Ext.getCmp('pid').getValue(); Ext.getCmp('company-form').getForm().submit({ url: WWW_PREFIX+'/data/save_values.php', clientValidation: true, params: 'id='+vid , success: sendDataSuccess , failure: sendDataFailure , waitMsg:'Zapisywanie informacji', waitTitle : 'Proszę czekać' }); }; function reload_values(){ alert('Anulu') }; function sendDataSuccess(){ }; function sendDataFailure(form,action){ switch (action.failureType) { case 'client': Ext.Msg.alert('Błąd zapisu','Błędne wartości pól'); case 'server': Ext.Msg.alert('Błąd zapisu',action.result.errors.errorDesc); break; default: Ext.Msg.alert('Błąd zapisu','Błąd zapisu wartości'); } }; function toolbarHandler(o) { // alert(o.id); switch (o.id) { case 'btnShowMapColors': //qfg = "rok='"+rok+"' and umru_kod='"+rodzaj+"'"; //scrollbars=no, resizable=no, window.open(WWW_PREFIX+'/modules/mapa/index.php?typ=colors&rok='+wRok+'&rodzaj='+wRodzaj,'mapa','menubar=no,toolbar=no ,location=no, scrollbars=yes, resizable=yes'); break; case 'btnShowMapNumbers': window.open(WWW_PREFIX+'/modules/mapa/index.php?typ=numbers&rok='+wRok+'&rodzaj='+wRodzaj,'mapa','menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes'); break; case 'btnRefresh': setBusyFlag(); ds.reload(); break; default: alert('Błędny kod przycisku'); } } function setBusyFlag(){ BusyFlagCounter++; //Ext.getCmp('busy_flag').setIconClass('busy'); } function clearBusyFlag(){ BusyFlagCounter--; if (BusyFlagCounter <= 0) { BusyFlagCounter = 0; //Ext.getCmp('busy_flag').setIconClass('nbusy'); } } //a=b;