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_symbol',
164                                                     params : {
165                                                         curr_id : s.data.curr_id,
166                                                         _load_rates : 1
167                                                     },
168                                                     success : function() {
169                                                         _this.rgrid.footer.onClick('first');
170                                                     }
171                                                 });
172                                             }
173                                         },
174                                         cls : 'x-btn-text-icon',
175                                         text : "Get this months rates",
176                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
177                                     }
178                                 ]
179                             },
180                             colModel : [
181                                 {
182                                     xtype: 'ColumnModel',
183                                     xns: Roo.grid,
184                                     dataIndex : 'curr_name',
185                                     header : 'Name',
186                                     width : 80,
187                                     renderer : function(v,x,r) { 
188                                     
189                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
190                                         
191                                     }
192                                 },
193                                 {
194                                     xtype: 'ColumnModel',
195                                     xns: Roo.grid,
196                                     dataIndex : 'curr_symbol',
197                                     header : 'Symbol',
198                                     width : 80,
199                                     renderer : function(v,x,r) { 
200                                     
201                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
202                                         
203                                     }
204                                 },
205                                 {
206                                     xtype: 'ColumnModel',
207                                     xns: Roo.grid,
208                                     dataIndex : 'curr_abbr',
209                                     header : 'Abbr.',
210                                     width : 80,
211                                     renderer : function(v,x,r) { 
212                                     
213                                         return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
214                                         
215                                     }
216                                 }
217                             ]
218                         }
219                     },
220                     {
221                         xtype: 'GridPanel',
222                         xns: Roo,
223                         listeners : {
224                             activate : function() {
225                                 _this.rpanel = this;
226                                 if (_this.rgrid) {
227                                     _this.rgrid.footer.onClick('first');
228                                 }
229                             }
230                         },
231                         background : false,
232                         fitContainer : true,
233                         fitToframe : true,
234                         region : 'center',
235                         tableName : 'curr_rate',
236                         title : "curr_rate",
237                         grid : {
238                             xtype: 'Grid',
239                             xns: Roo.grid,
240                             listeners : {
241                                 render : function() 
242                                 {
243                                     _this.rgrid = this; 
244                                     //_this.dialog = Pman.Dialog.FILL_IN
245                                     if (_this.rpanel.active) {
246                                        this.footer.onClick('first');
247                                     }
248                                 }
249                             },
250                             autoExpandColumn : 'curr_rate',
251                             loadMask : true,
252                             toolbar : {
253                                 xtype: 'Toolbar',
254                                 xns: Roo,
255                                 items : [
256                                     {
257                                         xtype: 'Fill',
258                                         xns: Roo.Toolbar
259                                     },
260                                     {
261                                         xtype: 'Button',
262                                         xns: Roo.Toolbar,
263                                         listeners : {
264                                             click : function ()
265                                             {
266                                             
267                                                  var sel  = _this.invgrid.getSelectionModel().getSelected();
268                                                 if (!sel) {
269                                                     Roo.MessageBox.alert("Error", "Select a invoice");
270                                                     return;
271                                                 }
272                                                 // check current status of shipment..
273                                                 
274                                                 var params =  {
275                                             //        cobmisc_id : sel.data.cobmisc_id,
276                                                     _void : 1
277                                                 };
278                                                 if (sel.data.cobmisc_id * 1) {
279                                                     params.cobmisc_id = sel.data.cobmisc_id * 1 ;
280                                                 }
281                                                 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {    
282                                                     params.invchead_id  =  sel.data.cobmisc_invchead_id_invchead_id * 1;
283                                                 }
284                                                 
285                                                 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
286                                                     function(r) {
287                                                         if (r != 'yes') {
288                                                             return;
289                                                         }
290                                                         new Pman.Request({
291                                                             mask : 'Sending',
292                                                             url : baseURL + '/Roo/cobmisc',
293                                                             method : 'POST',
294                                                             params :  params,
295                                                             success : function() {
296                                                                 _this.invgrid.ds.load({});
297                                                             }
298                                                         })
299                                                         
300                                                     }
301                                                 );
302                                                         
303                                                         
304                                                
305                                             }
306                                         },
307                                         cls : 'x-btn-text-icon',
308                                         text : "Void / Unpost",
309                                         icon : rootURL + '/Pman/templates/images/trash.gif'
310                                     }
311                                 ]
312                             },
313                             dataSource : {
314                                 xtype: 'Store',
315                                 xns: Roo.data,
316                                 listeners : {
317                                     beforeload : function (_self, options)
318                                     {
319                                         var s = _this.grid.selModel.getSelected();
320                                         if (!s) { 
321                                             this.removeAll();
322                                             return false;
323                                         }
324                                         options.params.curr_id = s.data.curr_id;
325                                         options.params._with_base_symbol  = 1;
326                                     }
327                                 },
328                                 remoteSort : true,
329                                 sortInfo : { field : 'curr_effective', direction: 'DESC' },
330                                 proxy : {
331                                     xtype: 'HttpProxy',
332                                     xns: Roo.data,
333                                     method : 'GET',
334                                     url : baseURL + '/Roo/curr_rate.php'
335                                 },
336                                 reader : {
337                                     xtype: 'JsonReader',
338                                     xns: Roo.data,
339                                     totalProperty : 'total',
340                                     root : 'data',
341                                     id : 'id',
342                                     fields : [
343                                         {
344                                             'name': 'curr_rate_id',
345                                             'type': 'int'
346                                         },
347                                         {
348                                             'name': 'curr_id',
349                                             'type': 'int'
350                                         },
351                                         {
352                                             'name': 'curr_id',
353                                             'type': 'int'
354                                         },
355                                         {
356                                             'name': 'curr_rate',
357                                             'type': 'float'
358                                         },
359                                         {
360                                             'name': 'curr_effective',
361                                             'type': 'date',
362                                             'dateFormat': 'Y-m-d'
363                                         },
364                                         {
365                                             'name': 'curr_expires',
366                                             'type': 'date',
367                                             'dateFormat': 'Y-m-d'
368                                         }
369                                     ]
370                                 }
371                             },
372                             footer : {
373                                 xtype: 'PagingToolbar',
374                                 xns: Roo,
375                                 displayInfo : true,
376                                 displayMsg : "Displaying curr_rate {0} - {1} of {2}",
377                                 emptyMsg : "No curr_rate found",
378                                 pageSize : 25
379                             },
380                             colModel : [
381                                 {
382                                     xtype: 'ColumnModel',
383                                     xns: Roo.grid,
384                                     dataIndex : 'curr_effective',
385                                     header : 'From',
386                                     width : 150,
387                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
388                                 },
389                                 {
390                                     xtype: 'ColumnModel',
391                                     xns: Roo.grid,
392                                     dataIndex : 'curr_expires',
393                                     header : 'To',
394                                     width : 150,
395                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
396                                 },
397                                 {
398                                     xtype: 'ColumnModel',
399                                     xns: Roo.grid,
400                                     align : 'right',
401                                     dataIndex : 'curr_rate',
402                                     header : 'Rate',
403                                     width : 75,
404                                     renderer : function(v) { return String.format('{0}', v); }
405                                 },
406                                 {
407                                     xtype: 'ColumnModel',
408                                     xns: Roo.grid,
409                                     align : 'right',
410                                     dataIndex : 'curr_rate1',
411                                     header : 'Rate',
412                                     width : 150,
413                                     renderer : function(v,x,r) {
414                                     
415                                          return String.format('{1}1 = {2}{0}', 
416                                             Roo.util.Format.number(r.data.curr_rate,2),
417                                             r.data.base_curr_symbol,
418                                             r.data.curr_id_curr_symbol
419                                         ); 
420                                         
421                                     }
422                                 },
423                                 {
424                                     xtype: 'ColumnModel',
425                                     xns: Roo.grid,
426                                     align : 'right',
427                                     dataIndex : 'curr_rate2',
428                                     header : 'Rate',
429                                     width : 150,
430                                     renderer : function(v,x,r) {    
431                                          return String.format('{2}1 = {1}{0}', 
432                                             Roo.util.Format.number(1.0/r.data.curr_rate,2),
433                                             r.data.base_curr_symbol,
434                                             r.data.curr_id_curr_symbol
435                                         ); 
436                                     }
437                                 }
438                             ]
439                         }
440                     }
441                 ],
442                 west : {
443                     xtype: 'LayoutRegion',
444                     xns: Roo,
445                     split : true,
446                     width : 300
447                 },
448                 center : {
449                     xtype: 'LayoutRegion',
450                     xns: Roo
451                 }
452             }
453         };
454     }
455 });