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