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