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