Pman.Tab.XtupleReports.bjs
[Pman.Xtuple] / Pman.Tab.XtupleReports.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.XtupleReports = new Roo.XComponent({
6     part     :  ["Xtuple","Reports"],
7     order    : '500-Pman.Tab.XtupleReports',
8     region   : 'center',
9     parent   : 'Pman.Tab.Admin',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             title : "Reports",
21             layout : {
22                 xtype: 'BorderLayout',
23                 xns: Roo,
24                 items : [
25                     {
26                         xtype: 'GridPanel',
27                         xns: Roo,
28                         title : "report",
29                         fitToframe : true,
30                         fitContainer : true,
31                         tableName : 'report',
32                         background : true,
33                         region : 'center',
34                         listeners : {
35                             activate : function() {
36                                 _this.panel = this;
37                                 if (_this.grid) {
38                                     _this.grid.footer.onClick('first');
39                                 }
40                             }
41                         },
42                         grid : {
43                             xtype: 'Grid',
44                             xns: Roo.grid,
45                             listeners : {
46                                 render : function() 
47                                 {
48                                     _this.grid = this; 
49                                     //_this.dialog = Pman.Dialog.FILL_IN
50                                     if (_this.panel.active) {
51                                        this.footer.onClick('first');
52                                     }
53                                 },
54                                 rowdblclick : function (_self, rowIndex, e)
55                                 {
56                                     var rec = this.ds.getAt(rowIndex);
57                                     new Pman.Download({
58                                         url : baseURL + '/Roo/Report/' + rec.data.report_name +'-' + report.data.id + '.rpt',
59                                         method : 'GET',
60                                         params : {
61                                             _id : rec.data.report_id,
62                                             _download : 1
63                                         }
64                                     });
65                                     Roo.MessageBox.alert("Downloading",
66                                     
67                                        "Report template is downloading - use " +
68                                            '<a href="http://sourceforge.net/projects/openrpt/files/openrpt/">' + 
69                                            "report writer to edit this" + 
70                                            '</a>'
71                                        );
72                                            
73                                     
74                                     
75                                 }
76                             },
77                             autoExpandColumn : 'report_descrip',
78                             loadMask : true,
79                             dataSource : {
80                                 xtype: 'Store',
81                                 xns: Roo.data,
82                                 listeners : {
83                                     beforeload : function (_self, options)
84                                     {
85                                         options.params['search[name]'] = _this.searchName.getValue();
86                                         options.params._max_versions = 1;
87                                     }
88                                 },
89                                 remoteSort : true,
90                                 sortInfo : { field : 'report_name', direction: 'ASC' },
91                                 proxy : {
92                                     xtype: 'HttpProxy',
93                                     xns: Roo.data,
94                                     method : 'GET',
95                                     url : baseURL + '/Roo/report.php'
96                                 },
97                                 reader : {
98                                     xtype: 'JsonReader',
99                                     xns: Roo.data,
100                                     totalProperty : 'total',
101                                     root : 'data',
102                                     id : 'id',
103                                     fields : [
104                                         {
105                                             'name': 'report_id',
106                                             'type': 'int'
107                                         },
108                                         {
109                                             'name': 'report_name',
110                                             'type': 'string'
111                                         },
112                                         {
113                                             'name': 'report_sys',
114                                             'type': 'int'
115                                         },
116                                         {
117                                             'name': 'report_source',
118                                             'type': 'string'
119                                         },
120                                         {
121                                             'name': 'report_descrip',
122                                             'type': 'string'
123                                         },
124                                         {
125                                             'name': 'report_grade',
126                                             'type': 'int'
127                                         },
128                                         {
129                                             'name': 'report_loaddate',
130                                             'type': 'date',
131                                             'dateFormat': 'Y-m-d'
132                                         }
133                                     ]
134                                 }
135                             },
136                             sm : {
137                                 xtype: 'RowSelectionModel',
138                                 xns: Roo.grid,
139                                 listeners : {
140                                     afterselectionchange : function (_self)
141                                     {
142                                         _this.vgrid.footer.onClick('first');
143                                     }
144                                 },
145                                 singleSelect : true
146                             },
147                             footer : {
148                                 xtype: 'PagingToolbar',
149                                 xns: Roo,
150                                 pageSize : 25,
151                                 displayInfo : true,
152                                 displayMsg : "Displaying report{0} - {1} of {2}",
153                                 emptyMsg : "No report found"
154                             },
155                             toolbar : {
156                                 xtype: 'Toolbar',
157                                 xns: Roo,
158                                 items : [
159                                     {
160                                         xtype: 'TextField',
161                                         xns: Roo.form,
162                                         listeners : {
163                                             render : function (_self)
164                                             {
165                                                 _this.searchName = _self;
166                                             },
167                                             specialkey : function (_self, e)
168                                             {
169                                                 _this.grid.footer.onClick('first');
170                                             }
171                                         }
172                                     },
173                                     {
174                                         xtype: 'Button',
175                                         xns: Roo.Toolbar,
176                                         listeners : {
177                                             click : function (_self, e)
178                                             {
179                                             _this.grid.footer.onClick('first');
180                                             }
181                                         },
182                                         cls : 'x-btn-icon',
183                                         icon : rootURL + '/Pman/templates/images/search.gif'
184                                     },
185                                     {
186                                         xtype: 'Button',
187                                         xns: Roo.Toolbar,
188                                         listeners : {
189                                             click : function (_self, e)
190                                             {
191                                                 _this.searchBox.setValue('');
192                                                 _this.publication_name_combo.setValue('');
193                                                 _this.publication_lang_combo.setValue('');
194                                                 _this.country_combo.setValue('');
195                                                 _this.category_media_id_combo.setValue('');
196                                                 _this.role_combo.setValue('');      
197                                             
198                                                 
199                                                 _this.grid.footer.onClick('first');
200                                             }
201                                         },
202                                         cls : 'x-btn-icon',
203                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif'
204                                     },
205                                     {
206                                         xtype: 'Fill',
207                                         xns: Roo.Toolbar
208                                     },
209                                     {
210                                         xtype: 'Button',
211                                         xns: Roo.Toolbar,
212                                         text : "Add",
213                                         cls : 'x-btn-text-icon',
214                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
215                                         listeners : {
216                                             click : function()
217                                             {
218                                                 if (!_this.dialog) return;
219                                                 _this.dialog.show( { id : 0 } , function() {
220                                                     _this.grid.footer.onClick('first');
221                                                }); 
222                                             }
223                                         }
224                                     }
225                                 ]
226                             },
227                             colModel : [
228                                 {
229                                     xtype: 'ColumnModel',
230                                     xns: Roo.grid,
231                                     header : 'Report name',
232                                     width : 200,
233                                     dataIndex : 'report_name',
234                                     renderer : function(v) { return String.format('{0}', v); }
235                                 },
236                                 {
237                                     xtype: 'ColumnModel',
238                                     xns: Roo.grid,
239                                     header : 'Report descrip',
240                                     width : 200,
241                                     dataIndex : 'report_descrip',
242                                     renderer : function(v) { return String.format('{0}', v); }
243                                 }
244                             ]
245                         }
246                     },
247                     {
248                         xtype: 'GridPanel',
249                         xns: Roo,
250                         listeners : {
251                             activate : function() {
252                                 _this.vpanel = this;
253                                 if (_this.vgrid) {
254                                     _this.vgrid.footer.onClick('first');
255                                 }
256                             }
257                         },
258                         background : false,
259                         fitContainer : true,
260                         fitToframe : true,
261                         region : 'east',
262                         tableName : 'report',
263                         title : "report",
264                         grid : {
265                             xtype: 'Grid',
266                             xns: Roo.grid,
267                             listeners : {
268                                 render : function() 
269                                 {
270                                     _this.vgrid = this; 
271                                     //_this.dialog = Pman.Dialog.FILL_IN
272                                     if (_this.vpanel.active) {
273                                        this.footer.onClick('first');
274                                     }
275                                 },
276                                 rowdblclick : function (_self, rowIndex, e)
277                                 {
278                                     if (!_this.dialog) return;
279                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
280                                         _this.grid.footer.onClick('first');
281                                     }); 
282                                 }
283                             },
284                             autoExpandColumn : 'report_name',
285                             loadMask : true,
286                             dataSource : {
287                                 xtype: 'Store',
288                                 xns: Roo.data,
289                                 listeners : {
290                                     beforeload : function (_self, options)
291                                     {
292                                         if (!_this.grid) {
293                                             return false;
294                                         } 
295                                         var sel  = _this.grid.selModel.getSelected()
296                                         if (!sel) {
297                                             this.removeAll();
298                                             return false;
299                                         }
300                                         options.params.report_name = sel.data.report_name;
301                                         
302                                         
303                                     }
304                                 },
305                                 remoteSort : true,
306                                 sortInfo : { field : 'report_grade', direction: 'DESC' },
307                                 proxy : {
308                                     xtype: 'HttpProxy',
309                                     xns: Roo.data,
310                                     method : 'GET',
311                                     url : baseURL + '/Roo/report.php'
312                                 },
313                                 reader : {
314                                     xtype: 'JsonReader',
315                                     xns: Roo.data,
316                                     totalProperty : 'total',
317                                     root : 'data',
318                                     id : 'id',
319                                     fields : [
320                                         {
321                                             'name': 'report_id',
322                                             'type': 'int'
323                                         },
324                                         {
325                                             'name': 'report_name',
326                                             'type': 'string'
327                                         },
328                                         {
329                                             'name': 'report_sys',
330                                             'type': 'int'
331                                         },
332                                         {
333                                             'name': 'report_source',
334                                             'type': 'string'
335                                         },
336                                         {
337                                             'name': 'report_descrip',
338                                             'type': 'string'
339                                         },
340                                         {
341                                             'name': 'report_grade',
342                                             'type': 'int'
343                                         },
344                                         {
345                                             'name': 'report_loaddate',
346                                             'type': 'date',
347                                             'dateFormat': 'Y-m-d'
348                                         }
349                                     ]
350                                 }
351                             },
352                             footer : {
353                                 xtype: 'PagingToolbar',
354                                 xns: Roo,
355                                 pageSize : 25,
356                                 displayInfo : true,
357                                 displayMsg : "Displaying report{0} - {1} of {2}",
358                                 emptyMsg : "No report found"
359                             },
360                             colModel : [
361                                 {
362                                     xtype: 'ColumnModel',
363                                     xns: Roo.grid,
364                                     header : 'Report grade',
365                                     width : 75,
366                                     dataIndex : 'report_grade',
367                                     renderer : function(v) { return String.format('{0}', v); }
368                                 },
369                                 {
370                                     xtype: 'ColumnModel',
371                                     xns: Roo.grid,
372                                     header : 'Report loaddate',
373                                     width : 75,
374                                     dataIndex : 'report_loaddate',
375                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
376                                 }
377                             ]
378                         }
379                     }
380                 ],
381                 center : {
382                     xtype: 'LayoutRegion',
383                     xns: Roo
384                 },
385                 east : {
386                     xtype: 'LayoutRegion',
387                     xns: Roo,
388                     split : true,
389                     title : "Versions",
390                     titlebar : true,
391                     width : 200
392                 }
393             }
394         };
395     }
396 });