Fix #7123 - getting abra ready to test
[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 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.XtupleCurrency = new Roo.XComponent({
8     part     :  ["Xtuple", "Currency" ],
9     order    : '600-Pman.Tab.XtupleCurrency',
10     region   : 'center',
11     parent   : 'Pman.Tab.XtupleAccountsTab',
12     name     : "Pman.Tab.XtupleCurrency",
13     disabled : false, 
14     permname : '', 
15     _tree : function()
16     {
17         var _this = this;
18         var MODULE = this;
19         return {
20             layout : {
21                 west : {
22                     '|xns' : 'Roo',
23                     xtype : 'LayoutRegion',
24                     width : 300,
25                     xns : Roo,
26                     split : true
27                 },
28                 center : {
29                     '|xns' : 'Roo',
30                     xtype : 'LayoutRegion',
31                     xns : Roo
32                 },
33                 '|xns' : 'Roo',
34                 xtype : 'BorderLayout',
35                 xns : Roo,
36                 items : [
37                         {
38                         grid : {
39                             sm : {
40                                 '|xns' : 'Roo.grid',
41                                 xtype : 'RowSelectionModel',
42                                 singleSelect : true,
43                                 xns : Roo.grid,
44                                 listeners : {
45                                         afterselectionchange : function (_self)
46                                            {
47                                                _this.rgrid.footer.onClick('first');
48                                            }
49                                 }
50                             },
51                             dataSource : {
52                                 proxy : {
53                                     '|xns' : 'Roo.data',
54                                     url : baseURL + '/Roo/curr_symbol.php',
55                                     method : 'GET',
56                                     xtype : 'HttpProxy',
57                                     xns : Roo.data
58                                 },
59                                 reader : {
60                                     '|xns' : 'Roo.data',
61                                     id : 'id',
62                                     root : 'data',
63                                     xtype : 'JsonReader',
64                                     fields : [
65                                         {
66                                             'name': 'curr_id',
67                                             'type': 'int'
68                                         },
69                                         {
70                                             'name': 'curr_base',
71                                             'type': 'int'
72                                         },
73                                         {
74                                             'name': 'curr_name',
75                                             'type': 'string'
76                                         },
77                                         {
78                                             'name': 'curr_symbol',
79                                             'type': 'string'
80                                         },
81                                         {
82                                             'name': 'curr_abbr',
83                                             'type': 'string'
84                                         }
85                                     ],
86                                     xns : Roo.data,
87                                     totalProperty : 'total'
88                                 },
89                                 '|xns' : 'Roo.data',
90                                 remoteSort : true,
91                                 xtype : 'Store',
92                                 sortInfo : { field : 'curr_name', direction: 'ASC' },
93                                 xns : Roo.data,
94                                 items : [
95
96                                 ]
97
98                             },
99                             footer : {
100                                 '|xns' : 'Roo',
101                                 pageSize : 25,
102                                 xtype : 'PagingToolbar',
103                                 emptyMsg : "Nothing found",
104                                 xns : Roo,
105                                 displayMsg : "{0} - {1} of {2}",
106                                 displayInfo : true
107                             },
108                             toolbar : {
109                                 '|xns' : 'Roo',
110                                 xtype : 'Toolbar',
111                                 xns : Roo,
112                                 items : [
113                                         {
114                                         '|xns' : 'Roo.Toolbar',
115                                         text : "Add",
116                                         xtype : 'Button',
117                                         cls : 'x-btn-text-icon',
118                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
119                                         xns : Roo.Toolbar,
120                                         listeners : {
121                                                 click : function()
122                                                    {
123                                                        Pman.Dialog.XtupleCurrency.show( { curr_id : 0 } , function() {
124                                                            _this.grid.footer.onClick('first');
125                                                       }); 
126                                                    }
127                                         }
128                                     },
129                                         {
130                                         '|xns' : 'Roo.Toolbar',
131                                         xtype : 'Fill',
132                                         xns : Roo.Toolbar
133                                     },
134                                         {
135                                         '|xns' : 'Roo.Toolbar',
136                                         text : "Get this months rates",
137                                         xtype : 'Button',
138                                         cls : 'x-btn-text-icon',
139                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
140                                         xns : Roo.Toolbar,
141                                         listeners : {
142                                                 click : function()
143                                                    {
144                                                        var s = _this.grid.getSelectionModel().getSelected();
145                                                        
146                                                        if(!s){
147                                                            Roo.MessageBox.alert("Error", "Please select a currency!");
148                                                            return;
149                                                        }
150                                                            
151                                                        new Pman.Request({
152                                                            method: 'POST',
153                                                            url: baseURL+ '/Roo/curr_symbol',
154                                                            params : {
155                                                                curr_id : s.data.curr_id,
156                                                                _load_rates : 1
157                                                            },
158                                                            success : function() {
159                                                                _this.rgrid.footer.onClick('first');
160                                                            }
161                                                        });
162                                                    }
163                                         }
164                                     }
165                                 ]
166
167                             },
168                             '|xns' : 'Roo.grid',
169                             autoExpandColumn : 'curr_name',
170                             xtype : 'Grid',
171                             loadMask : true,
172                             xns : Roo.grid,
173                             colModel : [
174                                  {
175                                         '|xns' : 'Roo.grid',
176                                         xtype : 'ColumnModel',
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                                         xns : Roo.grid,
185                                         dataIndex : 'curr_name'
186                                     },
187 {
188                                         '|xns' : 'Roo.grid',
189                                         xtype : 'ColumnModel',
190                                         header : 'Symbol',
191                                         width : 80,
192                                         renderer : function(v,x,r) { 
193                                         
194                                             return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
195                                             
196                                         },
197                                         xns : Roo.grid,
198                                         dataIndex : 'curr_symbol'
199                                     },
200 {
201                                         '|xns' : 'Roo.grid',
202                                         xtype : 'ColumnModel',
203                                         header : 'Abbr.',
204                                         width : 80,
205                                         renderer : function(v,x,r) { 
206                                         
207                                             return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
208                                             
209                                         },
210                                         xns : Roo.grid,
211                                         dataIndex : 'curr_abbr'
212                                     }
213                             ],
214                             listeners : {
215                                 rowdblclick : function (_self, rowIndex, e)
216                                    {
217                                        Pman.Dialog.XtupleCurrency.show( this.getDataSource().getAt(rowIndex).data, function() {
218                                            _this.grid.footer.onClick('first');
219                                        }); 
220                                    },
221                                 render : function() 
222                                    {
223                                        _this.grid = this; 
224                                        //_this.dialog = Pman.Dialog.FILL_IN
225                                        if (_this.panel.active) {
226                                           this.footer.onClick('first');
227                                        }
228                                    }
229                             },
230                             items : [
231
232                             ]
233
234                         },
235                         '|xns' : 'Roo',
236                         fitToframe : true,
237                         background : false,
238                         region : 'west',
239                         title : "curr_symbol",
240                         xtype : 'GridPanel',
241                         fitContainer : true,
242                         xns : Roo,
243                         tableName : 'curr_symbol',
244                         listeners : {
245                                 activate : function() {
246                                        _this.panel = this;
247                                        if (_this.grid) {
248                                            _this.grid.footer.onClick('first');
249                                        }
250                                    }
251                         },
252                         items : [
253
254                         ]
255
256                     },
257                         {
258                         grid : {
259                             sm : {
260                                 '|xns' : 'Roo.grid',
261                                 xtype : 'RowSelectionModel',
262                                 singleSelect : true,
263                                 xns : Roo.grid
264                             },
265                             toolbar : {
266                                 '|xns' : 'Roo',
267                                 xtype : 'Toolbar',
268                                 xns : Roo,
269                                 items : [
270                                         {
271                                         '|xns' : 'Roo.Toolbar',
272                                         xtype : 'Fill',
273                                         xns : Roo.Toolbar
274                                     },
275                                         {
276                                         '|xns' : 'Roo.Toolbar',
277                                         text : "Delete",
278                                         xtype : 'Button',
279                                         cls : 'x-btn-text-icon',
280                                         icon : rootURL + '/Pman/templates/images/trash.gif',
281                                         xns : Roo.Toolbar,
282                                         listeners : {
283                                                 click : function ()
284                                                    {
285                                                    
286                                                         var sel  = _this.rgrid.getSelectionModel().getSelected();
287                                                        if (!sel) {
288                                                            Roo.MessageBox.alert("Error", "Select a rate");
289                                                            return;
290                                                        }
291                                                        
292                                                        Roo.MessageBox.confirm("Are you sure", "Are you sure you want to delete this rate?",
293                                                            function(r) {
294                                                                if (r != 'yes') {
295                                                                    return;
296                                                                }
297                                                                new Pman.Request({
298                                                                    mask : 'Deleting',
299                                                                    url : baseURL + '/Roo/curr_rate',
300                                                                    method : 'POST',
301                                                                    params :  {
302                                                                        _delete : sel.data.curr_rate_id
303                                                                    },
304                                                                    success : function() {
305                                                                        _this.rgrid.footer.onClick('first');
306                                                                    }
307                                                                })
308                                                                
309                                                            }
310                                                        );
311                                                                
312                                                                
313                                                       
314                                                    }
315                                         }
316                                     }
317                                 ]
318
319                             },
320                             dataSource : {
321                                 proxy : {
322                                     '|xns' : 'Roo.data',
323                                     url : baseURL + '/Roo/curr_rate.php',
324                                     method : 'GET',
325                                     xtype : 'HttpProxy',
326                                     xns : Roo.data
327                                 },
328                                 reader : {
329                                     '|xns' : 'Roo.data',
330                                     id : 'id',
331                                     root : 'data',
332                                     xtype : 'JsonReader',
333                                     xns : Roo.data,
334                                     fields : [
335                                         {
336                                             'name': 'curr_rate_id',
337                                             'type': 'int'
338                                         },
339                                         {
340                                             'name': 'curr_id',
341                                             'type': 'int'
342                                         },
343                                         {
344                                             'name': 'curr_id',
345                                             'type': 'int'
346                                         },
347                                         {
348                                             'name': 'curr_rate',
349                                             'type': 'float'
350                                         },
351                                         {
352                                             'name': 'curr_effective',
353                                             'type': 'date',
354                                             'dateFormat': 'Y-m-d'
355                                         },
356                                         {
357                                             'name': 'curr_expires',
358                                             'type': 'date',
359                                             'dateFormat': 'Y-m-d'
360                                         }
361                                     ],
362                                     totalProperty : 'total'
363                                 },
364                                 '|xns' : 'Roo.data',
365                                 xtype : 'Store',
366                                 remoteSort : true,
367                                 sortInfo : { field : 'curr_effective', direction: 'DESC' },
368                                 xns : Roo.data,
369                                 listeners : {
370                                         beforeload : function (_self, options)
371                                            {
372                                                var s = _this.grid.selModel.getSelected();
373                                                if (!s) { 
374                                                    this.removeAll();
375                                                    return false;
376                                                }
377                                                options.params.curr_id = s.data.curr_id;
378                                                options.params._with_base_symbol  = 1;
379                                            }
380                                 },
381                                 items : [
382
383                                 ]
384
385                             },
386                             footer : {
387                                 '|xns' : 'Roo',
388                                 pageSize : 25,
389                                 xtype : 'PagingToolbar',
390                                 emptyMsg : "No curr_rate found",
391                                 xns : Roo,
392                                 displayMsg : "Displaying curr_rate {0} - {1} of {2}",
393                                 displayInfo : true
394                             },
395                             '|xns' : 'Roo.grid',
396                             autoExpandColumn : 'curr_rate',
397                             xtype : 'Grid',
398                             loadMask : true,
399                             xns : Roo.grid,
400                             colModel : [
401                                  {
402                                         '|xns' : 'Roo.grid',
403                                         xtype : 'ColumnModel',
404                                         header : 'From',
405                                         width : 150,
406                                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
407                                         xns : Roo.grid,
408                                         dataIndex : 'curr_effective'
409                                     },
410 {
411                                         '|xns' : 'Roo.grid',
412                                         xtype : 'ColumnModel',
413                                         header : 'To',
414                                         width : 150,
415                                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
416                                         xns : Roo.grid,
417                                         dataIndex : 'curr_expires'
418                                     },
419 {
420                                         '|xns' : 'Roo.grid',
421                                         align : 'right',
422                                         xtype : 'ColumnModel',
423                                         header : 'Rate',
424                                         width : 75,
425                                         renderer : function(v) { return String.format('{0}', v); },
426                                         xns : Roo.grid,
427                                         dataIndex : 'curr_rate'
428                                     },
429 {
430                                         '|xns' : 'Roo.grid',
431                                         align : 'right',
432                                         xtype : 'ColumnModel',
433                                         header : 'Rate',
434                                         width : 150,
435                                         renderer : function(v,x,r) {
436                                         
437                                              return String.format('{1}1 = {2}{0}', 
438                                                 Roo.util.Format.number(r.data.curr_rate,2),
439                                                 r.data.base_curr_symbol,
440                                                 r.data.curr_id_curr_symbol
441                                             ); 
442                                             
443                                         },
444                                         xns : Roo.grid,
445                                         dataIndex : 'curr_rate1'
446                                     },
447 {
448                                         '|xns' : 'Roo.grid',
449                                         align : 'right',
450                                         xtype : 'ColumnModel',
451                                         header : 'Rate',
452                                         width : 150,
453                                         renderer : function(v,x,r) {    
454                                              return String.format('{2}1 = {1}{0}', 
455                                                 Roo.util.Format.number(1.0/r.data.curr_rate,2),
456                                                 r.data.base_curr_symbol,
457                                                 r.data.curr_id_curr_symbol
458                                             ); 
459                                         },
460                                         xns : Roo.grid,
461                                         dataIndex : 'curr_rate2'
462                                     }
463                             ],
464                             listeners : {
465                                 render : function() 
466                                    {
467                                        _this.rgrid = this; 
468                                        //_this.dialog = Pman.Dialog.FILL_IN
469                                        if (_this.rpanel.active) {
470                                           this.footer.onClick('first');
471                                        }
472                                    }
473                             },
474                             items : [
475
476                             ]
477
478                         },
479                         '|xns' : 'Roo',
480                         fitToframe : true,
481                         background : false,
482                         region : 'center',
483                         title : "curr_rate",
484                         xtype : 'GridPanel',
485                         fitContainer : true,
486                         xns : Roo,
487                         tableName : 'curr_rate',
488                         listeners : {
489                                 activate : function() {
490                                        _this.rpanel = this;
491                                        if (_this.rgrid) {
492                                            _this.rgrid.footer.onClick('first');
493                                        }
494                                    }
495                         },
496                         items : [
497
498                         ]
499
500                     }
501                 ]
502
503             },
504             '|xns' : 'Roo',
505             background : true,
506             region : 'center',
507             title : "Currency / Rates",
508             xtype : 'NestedLayoutPanel',
509             xns : Roo,
510             items : [
511
512             ]
513
514         };    }
515 });