Pman.Tab.XtupleCurrency.bjs
[Pman.Xtuple] / Pman.Tab.XtupleCurrency.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.XtupleCurrency = new Roo.XComponent({
6     part     :  ["Xtuple","Currency"],
7     order    : '901-Pman.Tab.XtupleCurrency',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleAccountsTab',
10     name     : "Pman.Tab.XtupleCurrency",
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             background : true,
21             region : 'center',
22             title : "Currency / Rates",
23             layout : {
24                 xtype: 'BorderLayout',
25                 xns: Roo,
26                 items : [
27                     {
28                         xtype: 'GridPanel',
29                         xns: Roo,
30                         listeners : {
31                             activate : function() {
32                                 _this.panel = this;
33                                 if (_this.grid) {
34                                     _this.grid.footer.onClick('first');
35                                 }
36                             }
37                         },
38                         background : false,
39                         fitContainer : true,
40                         fitToframe : true,
41                         region : 'west',
42                         tableName : 'curr_symbol',
43                         title : "curr_symbol",
44                         grid : {
45                             xtype: 'Grid',
46                             xns: Roo.grid,
47                             autoExpandColumn : 'curr_name',
48                             loadMask : true,
49                             listeners : {
50                                 render : function() 
51                                 {
52                                     _this.grid = this; 
53                                     //_this.dialog = Pman.Dialog.FILL_IN
54                                     if (_this.panel.active) {
55                                        this.footer.onClick('first');
56                                     }
57                                 },
58                                 rowdblclick : function (_self, rowIndex, e)
59                                 {
60                                     if (!_this.dialog) return;
61                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
62                                         _this.grid.footer.onClick('first');
63                                     }); 
64                                 }
65                             },
66                             sm : {
67                                 xtype: 'RowSelectionModel',
68                                 xns: Roo.grid,
69                                 listeners : {
70                                     afterselectionchange : function (_self)
71                                     {
72                                         _this.rgrid.footer.onClick('first');
73                                     }
74                                 },
75                                 singleSelect : true
76                             },
77                             dataSource : {
78                                 xtype: 'Store',
79                                 xns: Roo.data,
80                                 remoteSort : true,
81                                 sortInfo : { field : 'curr_name', direction: 'ASC' },
82                                 proxy : {
83                                     xtype: 'HttpProxy',
84                                     xns: Roo.data,
85                                     method : 'GET',
86                                     url : baseURL + '/Roo/curr_symbol.php'
87                                 },
88                                 reader : {
89                                     xtype: 'JsonReader',
90                                     xns: Roo.data,
91                                     totalProperty : 'total',
92                                     root : 'data',
93                                     id : 'id',
94                                     fields : [
95                                         {
96                                             'name': 'curr_id',
97                                             'type': 'int'
98                                         },
99                                         {
100                                             'name': 'curr_base',
101                                             'type': 'int'
102                                         },
103                                         {
104                                             'name': 'curr_name',
105                                             'type': 'string'
106                                         },
107                                         {
108                                             'name': 'curr_symbol',
109                                             'type': 'string'
110                                         },
111                                         {
112                                             'name': 'curr_abbr',
113                                             'type': 'string'
114                                         }
115                                     ]
116                                 }
117                             },
118                             footer : {
119                                 xtype: 'PagingToolbar',
120                                 xns: Roo,
121                                 pageSize : 25,
122                                 displayInfo : true,
123                                 displayMsg : "Displaying curr_symbol{0} - {1} of {2}",
124                                 emptyMsg : "No curr_symbol found"
125                             },
126                             toolbar : {
127                                 xtype: 'Toolbar',
128                                 xns: Roo,
129                                 items : [
130                                     {
131                                         xtype: 'Fill',
132                                         xns: Roo.Toolbar
133                                     },
134                                     {
135                                         xtype: 'Button',
136                                         xns: Roo.Toolbar,
137                                         text : "Add",
138                                         cls : 'x-btn-text-icon',
139                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
140                                         listeners : {
141                                             click : function()
142                                             {
143                                                 if (!_this.dialog) return;
144                                                 _this.dialog.show( { id : 0 } , function() {
145                                                     _this.grid.footer.onClick('first');
146                                                }); 
147                                             }
148                                         }
149                                     }
150                                 ]
151                             },
152                             colModel : [
153                                 {
154                                     xtype: 'ColumnModel',
155                                     xns: Roo.grid,
156                                     dataIndex : 'curr_name',
157                                     header : 'Name',
158                                     width : 80,
159                                     renderer : function(v,x,r) { 
160                                     
161                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
162                                         
163                                     }
164                                 },
165                                 {
166                                     xtype: 'ColumnModel',
167                                     xns: Roo.grid,
168                                     dataIndex : 'curr_symbol',
169                                     header : 'Symbol',
170                                     width : 80,
171                                     renderer : function(v,x,r) { 
172                                     
173                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
174                                         
175                                     }
176                                 },
177                                 {
178                                     xtype: 'ColumnModel',
179                                     xns: Roo.grid,
180                                     dataIndex : 'curr_abbr',
181                                     header : 'Abbr.',
182                                     width : 80,
183                                     renderer : function(v,x,r) { 
184                                     
185                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
186                                         
187                                     }
188                                 }
189                             ]
190                         }
191                     },
192                     {
193                         xtype: 'GridPanel',
194                         xns: Roo,
195                         listeners : {
196                             activate : function() {
197                                 _this.rpanel = this;
198                                 if (_this.rgrid) {
199                                     _this.rgrid.footer.onClick('first');
200                                 }
201                             }
202                         },
203                         background : false,
204                         fitContainer : true,
205                         fitToframe : true,
206                         region : 'center',
207                         tableName : 'curr_rate',
208                         title : "curr_rate",
209                         grid : {
210                             xtype: 'Grid',
211                             xns: Roo.grid,
212                             listeners : {
213                                 render : function() 
214                                 {
215                                     _this.rgrid = this; 
216                                     //_this.dialog = Pman.Dialog.FILL_IN
217                                     if (_this.rpanel.active) {
218                                        this.footer.onClick('first');
219                                     }
220                                 },
221                                 rowdblclick : function (_self, rowIndex, e)
222                                 {
223                                     if (!_this.dialog) return;
224                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
225                                         _this.grid.footer.onClick('first');
226                                     }); 
227                                 }
228                             },
229                             autoExpandColumn : 'curr_rate',
230                             loadMask : true,
231                             dataSource : {
232                                 xtype: 'Store',
233                                 xns: Roo.data,
234                                 listeners : {
235                                     beforeload : function (_self, options)
236                                     {
237                                         var s = _this.grid.selModel.getSelected();
238                                         if (!s) { 
239                                             this.removeAll();
240                                             return false;
241                                         }
242                                         options.params.curr_id = s.data.curr_id;
243                                         options.params._with_base_symbol  = 1;
244                                     }
245                                 },
246                                 remoteSort : true,
247                                 sortInfo : { field : 'curr_effective', direction: 'DESC' },
248                                 proxy : {
249                                     xtype: 'HttpProxy',
250                                     xns: Roo.data,
251                                     method : 'GET',
252                                     url : baseURL + '/Roo/curr_rate.php'
253                                 },
254                                 reader : {
255                                     xtype: 'JsonReader',
256                                     xns: Roo.data,
257                                     totalProperty : 'total',
258                                     root : 'data',
259                                     id : 'id',
260                                     fields : [
261                                         {
262                                             'name': 'curr_rate_id',
263                                             'type': 'int'
264                                         },
265                                         {
266                                             'name': 'curr_id',
267                                             'type': 'int'
268                                         },
269                                         {
270                                             'name': 'curr_id',
271                                             'type': 'int'
272                                         },
273                                         {
274                                             'name': 'curr_rate',
275                                             'type': 'float'
276                                         },
277                                         {
278                                             'name': 'curr_effective',
279                                             'type': 'date',
280                                             'dateFormat': 'Y-m-d'
281                                         },
282                                         {
283                                             'name': 'curr_expires',
284                                             'type': 'date',
285                                             'dateFormat': 'Y-m-d'
286                                         }
287                                     ]
288                                 }
289                             },
290                             footer : {
291                                 xtype: 'PagingToolbar',
292                                 xns: Roo,
293                                 pageSize : 25,
294                                 displayInfo : true,
295                                 displayMsg : "Displaying curr_rate{0} - {1} of {2}",
296                                 emptyMsg : "No curr_rate found"
297                             },
298                             toolbar : {
299                                 xtype: 'Toolbar',
300                                 xns: Roo,
301                                 items : [
302                                     {
303                                         xtype: 'Fill',
304                                         xns: Roo.Toolbar
305                                     },
306                                     {
307                                         xtype: 'Button',
308                                         xns: Roo.Toolbar,
309                                         listeners : {
310                                             click : function()
311                                             {
312                                                 if (!_this.dialog) return;
313                                                 _this.dialog.show( { id : 0 } , function() {
314                                                     _this.grid.footer.onClick('first');
315                                                }); 
316                                             }
317                                         },
318                                         cls : 'x-btn-text-icon',
319                                         text : "Get this months rates",
320                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
321                                     }
322                                 ]
323                             },
324                             colModel : [
325                                 {
326                                     xtype: 'ColumnModel',
327                                     xns: Roo.grid,
328                                     dataIndex : 'curr_effective',
329                                     header : 'From',
330                                     width : 150,
331                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
332                                 },
333                                 {
334                                     xtype: 'ColumnModel',
335                                     xns: Roo.grid,
336                                     dataIndex : 'curr_expires',
337                                     header : 'To',
338                                     width : 150,
339                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
340                                 },
341                                 {
342                                     xtype: 'ColumnModel',
343                                     xns: Roo.grid,
344                                     align : 'right',
345                                     dataIndex : 'curr_rate',
346                                     header : 'Rate',
347                                     width : 75,
348                                     renderer : function(v) { return String.format('{0}', v); }
349                                 },
350                                 {
351                                     xtype: 'ColumnModel',
352                                     xns: Roo.grid,
353                                     align : 'right',
354                                     dataIndex : 'curr_rate1',
355                                     header : 'Rate',
356                                     width : 150,
357                                     renderer : function(v,x,r) {
358                                     
359                                          return String.format('{1}1 = {2}{0}', 
360                                             Roo.util.Format.number(r.data.curr_rate,2),
361                                             r.data.base_curr_symbol,
362                                             r.data.curr_id_curr_symbol
363                                         ); 
364                                         
365                                     }
366                                 },
367                                 {
368                                     xtype: 'ColumnModel',
369                                     xns: Roo.grid,
370                                     align : 'right',
371                                     dataIndex : 'curr_rate2',
372                                     header : 'Rate',
373                                     width : 150,
374                                     renderer : function(v,x,r) {    
375                                          return String.format('{2}1 = {1}{0}', 
376                                             Roo.util.Format.number(1.0/r.data.curr_rate,2),
377                                             r.data.base_curr_symbol,
378                                             r.data.curr_id_curr_symbol
379                                         ); 
380                                     }
381                                 }
382                             ]
383                         }
384                     }
385                 ],
386                 west : {
387                     xtype: 'LayoutRegion',
388                     xns: Roo,
389                     split : true,
390                     width : 300
391                 },
392                 center : {
393                     xtype: 'LayoutRegion',
394                     xns: Roo
395                 }
396             }
397         };
398     }
399 });