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