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                             listeners : {
48                                 render : function() 
49                                 {
50                                     _this.grid = this; 
51                                     //_this.dialog = Pman.Dialog.FILL_IN
52                                     if (_this.panel.active) {
53                                        this.footer.onClick('first');
54                                     }
55                                 },
56                                 rowdblclick : function (_self, rowIndex, e)
57                                 {
58                                     if (!_this.dialog) return;
59                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
60                                         _this.grid.footer.onClick('first');
61                                     }); 
62                                 }
63                             },
64                             autoExpandColumn : 'curr_name',
65                             loadMask : true,
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: 'Button',
132                                         xns: Roo.Toolbar,
133                                         text : "Add",
134                                         cls : 'x-btn-text-icon',
135                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
136                                         listeners : {
137                                             click : function()
138                                             {
139                                                 if (!_this.dialog) return;
140                                                 _this.dialog.show( { id : 0 } , function() {
141                                                     _this.grid.footer.onClick('first');
142                                                }); 
143                                             }
144                                         }
145                                     },
146                                     {
147                                         xtype: 'Fill',
148                                         xns: Roo.Toolbar
149                                     },
150                                     {
151                                         xtype: 'Button',
152                                         xns: Roo.Toolbar,
153                                         listeners : {
154                                             click : function()
155                                             {
156                                                 if (!_this.dialog) return;
157                                                 _this.dialog.show( { id : 0 } , function() {
158                                                     _this.grid.footer.onClick('first');
159                                                }); 
160                                             }
161                                         },
162                                         cls : 'x-btn-text-icon',
163                                         text : "Get this months rates",
164                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
165                                     }
166                                 ]
167                             },
168                             colModel : [
169                                 {
170                                     xtype: 'ColumnModel',
171                                     xns: Roo.grid,
172                                     dataIndex : 'curr_name',
173                                     header : 'Name',
174                                     width : 80,
175                                     renderer : function(v,x,r) { 
176                                     
177                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
178                                         
179                                     }
180                                 },
181                                 {
182                                     xtype: 'ColumnModel',
183                                     xns: Roo.grid,
184                                     dataIndex : 'curr_symbol',
185                                     header : 'Symbol',
186                                     width : 80,
187                                     renderer : function(v,x,r) { 
188                                     
189                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
190                                         
191                                     }
192                                 },
193                                 {
194                                     xtype: 'ColumnModel',
195                                     xns: Roo.grid,
196                                     dataIndex : 'curr_abbr',
197                                     header : 'Abbr.',
198                                     width : 80,
199                                     renderer : function(v,x,r) { 
200                                     
201                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
202                                         
203                                     }
204                                 }
205                             ]
206                         }
207                     },
208                     {
209                         xtype: 'GridPanel',
210                         xns: Roo,
211                         listeners : {
212                             activate : function() {
213                                 _this.rpanel = this;
214                                 if (_this.rgrid) {
215                                     _this.rgrid.footer.onClick('first');
216                                 }
217                             }
218                         },
219                         background : false,
220                         fitContainer : true,
221                         fitToframe : true,
222                         region : 'center',
223                         tableName : 'curr_rate',
224                         title : "curr_rate",
225                         grid : {
226                             xtype: 'Grid',
227                             xns: Roo.grid,
228                             listeners : {
229                                 render : function() 
230                                 {
231                                     _this.rgrid = this; 
232                                     //_this.dialog = Pman.Dialog.FILL_IN
233                                     if (_this.rpanel.active) {
234                                        this.footer.onClick('first');
235                                     }
236                                 },
237                                 rowdblclick : function (_self, rowIndex, e)
238                                 {
239                                     if (!_this.dialog) return;
240                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
241                                         _this.grid.footer.onClick('first');
242                                     }); 
243                                 }
244                             },
245                             autoExpandColumn : 'curr_rate',
246                             loadMask : true,
247                             dataSource : {
248                                 xtype: 'Store',
249                                 xns: Roo.data,
250                                 listeners : {
251                                     beforeload : function (_self, options)
252                                     {
253                                         var s = _this.grid.selModel.getSelected();
254                                         if (!s) { 
255                                             this.removeAll();
256                                             return false;
257                                         }
258                                         options.params.curr_id = s.data.curr_id;
259                                         options.params._with_base_symbol  = 1;
260                                     }
261                                 },
262                                 remoteSort : true,
263                                 sortInfo : { field : 'curr_effective', direction: 'DESC' },
264                                 proxy : {
265                                     xtype: 'HttpProxy',
266                                     xns: Roo.data,
267                                     method : 'GET',
268                                     url : baseURL + '/Roo/curr_rate.php'
269                                 },
270                                 reader : {
271                                     xtype: 'JsonReader',
272                                     xns: Roo.data,
273                                     totalProperty : 'total',
274                                     root : 'data',
275                                     id : 'id',
276                                     fields : [
277                                         {
278                                             'name': 'curr_rate_id',
279                                             'type': 'int'
280                                         },
281                                         {
282                                             'name': 'curr_id',
283                                             'type': 'int'
284                                         },
285                                         {
286                                             'name': 'curr_id',
287                                             'type': 'int'
288                                         },
289                                         {
290                                             'name': 'curr_rate',
291                                             'type': 'float'
292                                         },
293                                         {
294                                             'name': 'curr_effective',
295                                             'type': 'date',
296                                             'dateFormat': 'Y-m-d'
297                                         },
298                                         {
299                                             'name': 'curr_expires',
300                                             'type': 'date',
301                                             'dateFormat': 'Y-m-d'
302                                         }
303                                     ]
304                                 }
305                             },
306                             footer : {
307                                 xtype: 'PagingToolbar',
308                                 xns: Roo,
309                                 pageSize : 25,
310                                 displayInfo : true,
311                                 displayMsg : "Displaying curr_rate{0} - {1} of {2}",
312                                 emptyMsg : "No curr_rate found"
313                             },
314                             colModel : [
315                                 {
316                                     xtype: 'ColumnModel',
317                                     xns: Roo.grid,
318                                     dataIndex : 'curr_effective',
319                                     header : 'From',
320                                     width : 150,
321                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
322                                 },
323                                 {
324                                     xtype: 'ColumnModel',
325                                     xns: Roo.grid,
326                                     dataIndex : 'curr_expires',
327                                     header : 'To',
328                                     width : 150,
329                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
330                                 },
331                                 {
332                                     xtype: 'ColumnModel',
333                                     xns: Roo.grid,
334                                     align : 'right',
335                                     dataIndex : 'curr_rate',
336                                     header : 'Rate',
337                                     width : 75,
338                                     renderer : function(v) { return String.format('{0}', v); }
339                                 },
340                                 {
341                                     xtype: 'ColumnModel',
342                                     xns: Roo.grid,
343                                     align : 'right',
344                                     dataIndex : 'curr_rate1',
345                                     header : 'Rate',
346                                     width : 150,
347                                     renderer : function(v,x,r) {
348                                     
349                                          return String.format('{1}1 = {2}{0}', 
350                                             Roo.util.Format.number(r.data.curr_rate,2),
351                                             r.data.base_curr_symbol,
352                                             r.data.curr_id_curr_symbol
353                                         ); 
354                                         
355                                     }
356                                 },
357                                 {
358                                     xtype: 'ColumnModel',
359                                     xns: Roo.grid,
360                                     align : 'right',
361                                     dataIndex : 'curr_rate2',
362                                     header : 'Rate',
363                                     width : 150,
364                                     renderer : function(v,x,r) {    
365                                          return String.format('{2}1 = {1}{0}', 
366                                             Roo.util.Format.number(1.0/r.data.curr_rate,2),
367                                             r.data.base_curr_symbol,
368                                             r.data.curr_id_curr_symbol
369                                         ); 
370                                     }
371                                 }
372                             ]
373                         }
374                     }
375                 ],
376                 west : {
377                     xtype: 'LayoutRegion',
378                     xns: Roo,
379                     split : true,
380                     width : 300
381                 },
382                 center : {
383                     xtype: 'LayoutRegion',
384                     xns: Roo
385                 }
386             }
387         };
388     }
389 });