Fix #7123 - getting abra ready to test
[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 +'-' + rec.data.report_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 target="_new" 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                                         listeners : {
213                                             click : function (_self, e)
214                                             {
215                                                 
216                                                 var sel = _this.grid.selModel.getSelected();
217                                                 if (!sel) {
218                                                     Roo.MessageBox.alert("Error", "Select a report");
219                                                     return;
220                                                 }
221                                                 
222                                                 Pman.Dialog.Image.show(
223                                                    {
224                                                         _url : baseURL+'/Xtuple/Import/Report',
225                                                          onid : sel.data.report_id
226                                                          
227                                                         
228                                                    },
229                                                    function (data) {
230                                                         Roo.MessageBox.alert("Notice", "Updated");
231                                                         _this.grid.footer.onClick('refresh');
232                                                    }
233                                                );
234                                             }
235                                         },
236                                         text : "Upload New version"
237                                     }
238                                 ]
239                             },
240                             colModel : [
241                                 {
242                                     xtype: 'ColumnModel',
243                                     xns: Roo.grid,
244                                     header : 'Report name',
245                                     width : 200,
246                                     dataIndex : 'report_name',
247                                     renderer : function(v) { return String.format('{0}', v); }
248                                 },
249                                 {
250                                     xtype: 'ColumnModel',
251                                     xns: Roo.grid,
252                                     header : 'Report descrip',
253                                     width : 200,
254                                     dataIndex : 'report_descrip',
255                                     renderer : function(v) { return String.format('{0}', v); }
256                                 }
257                             ]
258                         }
259                     },
260                     {
261                         xtype: 'GridPanel',
262                         xns: Roo,
263                         listeners : {
264                             activate : function() {
265                                 _this.vpanel = this;
266                                 if (_this.vgrid) {
267                                     _this.vgrid.footer.onClick('first');
268                                 }
269                             }
270                         },
271                         background : false,
272                         fitContainer : true,
273                         fitToframe : true,
274                         region : 'east',
275                         tableName : 'report',
276                         title : "report",
277                         grid : {
278                             xtype: 'Grid',
279                             xns: Roo.grid,
280                             listeners : {
281                                 render : function() 
282                                 {
283                                     _this.vgrid = this; 
284                                     //_this.dialog = Pman.Dialog.FILL_IN
285                                     if (_this.vpanel.active) {
286                                        this.footer.onClick('first');
287                                     }
288                                 },
289                                 rowdblclick : function (_self, rowIndex, e)
290                                 {
291                                     var rec = this.ds.getAt(rowIndex);
292                                     new Pman.Download({
293                                         url : baseURL + '/Roo/Report/' + rec.data.report_name +'-' + rec.data.report_id + '.rpt',
294                                         method : 'GET',
295                                         params : {
296                                             _id : rec.data.report_id,
297                                             _download : 1
298                                         }
299                                     });
300                                     Roo.MessageBox.alert("Downloading",
301                                     
302                                        "Report template is downloading - use " +
303                                            '<a target="_new" href="http://sourceforge.net/projects/openrpt/files/openrpt/">' + 
304                                            "report writer to edit this" + 
305                                            '</a>'
306                                        );
307                                            
308                                     
309                                     
310                                 }
311                             },
312                             autoExpandColumn : 'Report loaddate',
313                             loadMask : true,
314                             dataSource : {
315                                 xtype: 'Store',
316                                 xns: Roo.data,
317                                 listeners : {
318                                     beforeload : function (_self, options)
319                                     {
320                                         if (!_this.grid) {
321                                             return false;
322                                         } 
323                                         var sel  = _this.grid.selModel.getSelected();
324                                         if (!sel) {
325                                             this.removeAll();
326                                             return false;
327                                         }
328                                         options.params.report_name = sel.data.report_name;
329                                         
330                                         
331                                     }
332                                 },
333                                 remoteSort : true,
334                                 sortInfo : { field : 'report_grade', direction: 'DESC' },
335                                 proxy : {
336                                     xtype: 'HttpProxy',
337                                     xns: Roo.data,
338                                     method : 'GET',
339                                     url : baseURL + '/Roo/report.php'
340                                 },
341                                 reader : {
342                                     xtype: 'JsonReader',
343                                     xns: Roo.data,
344                                     totalProperty : 'total',
345                                     root : 'data',
346                                     id : 'id',
347                                     fields : [
348                                         {
349                                             'name': 'report_id',
350                                             'type': 'int'
351                                         },
352                                         {
353                                             'name': 'report_name',
354                                             'type': 'string'
355                                         },
356                                         {
357                                             'name': 'report_sys',
358                                             'type': 'int'
359                                         },
360                                         {
361                                             'name': 'report_source',
362                                             'type': 'string'
363                                         },
364                                         {
365                                             'name': 'report_descrip',
366                                             'type': 'string'
367                                         },
368                                         {
369                                             'name': 'report_grade',
370                                             'type': 'int'
371                                         },
372                                         {
373                                             'name': 'report_loaddate',
374                                             'type': 'date',
375                                             'dateFormat': 'Y-m-d'
376                                         }
377                                     ]
378                                 }
379                             },
380                             footer : {
381                                 xtype: 'PagingToolbar',
382                                 xns: Roo,
383                                 pageSize : 25,
384                                 displayInfo : true,
385                                 displayMsg : "Displaying report{0} - {1} of {2}",
386                                 emptyMsg : "No report found"
387                             },
388                             colModel : [
389                                 {
390                                     xtype: 'ColumnModel',
391                                     xns: Roo.grid,
392                                     dataIndex : 'report_grade',
393                                     header : 'Version',
394                                     width : 20,
395                                     renderer : function(v) { return String.format('{0}', v); }
396                                 },
397                                 {
398                                     xtype: 'ColumnModel',
399                                     xns: Roo.grid,
400                                     dataIndex : 'report_loaddate',
401                                     header : 'Created',
402                                     width : 200,
403                                     renderer : function(v,x,r) { 
404                                         var vv =   Date.parseDate(r.json.report_loaddate.split('.')[0], 'Y-m-d H:i:s').format('d/M/Y h:ia');
405                                         return String.format('{0}', vv); 
406                                     
407                                         }
408                                 }
409                             ]
410                         }
411                     }
412                 ],
413                 center : {
414                     xtype: 'LayoutRegion',
415                     xns: Roo
416                 },
417                 east : {
418                     xtype: 'LayoutRegion',
419                     xns: Roo,
420                     split : true,
421                     title : "Versions",
422                     titlebar : true,
423                     width : 200
424                 }
425             }
426         };
427     }
428 });