Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleCurrency.js
index f1c2ebe..8ce2e6c 100644 (file)
@@ -2,9 +2,11 @@
 
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
+Roo.namespace('Pman.Tab');
+
 Pman.Tab.XtupleCurrency = new Roo.XComponent({
-    part     :  ["Xtuple","Currency"],
-    order    : '901-Pman.Tab.XtupleCurrency',
+    part     :  ["Xtuple", "Currency" ],
+    order    : '600-Pman.Tab.XtupleCurrency',
     region   : 'center',
     parent   : 'Pman.Tab.XtupleAccountsTab',
     name     : "Pman.Tab.XtupleCurrency",
@@ -15,82 +17,50 @@ Pman.Tab.XtupleCurrency = new Roo.XComponent({
         var _this = this;
         var MODULE = this;
         return {
-            xtype: 'NestedLayoutPanel',
-            xns: Roo,
-            background : true,
-            region : 'center',
-            title : "Currency / Rates",
             layout : {
-                xtype: 'BorderLayout',
-                xns: Roo,
+                west : {
+                    '|xns' : 'Roo',
+                    xtype : 'LayoutRegion',
+                    width : 300,
+                    xns : Roo,
+                    split : true
+                },
+                center : {
+                    '|xns' : 'Roo',
+                    xtype : 'LayoutRegion',
+                    xns : Roo
+                },
+                '|xns' : 'Roo',
+                xtype : 'BorderLayout',
+                xns : Roo,
                 items : [
-                    {
-                        xtype: 'GridPanel',
-                        xns: Roo,
-                        listeners : {
-                            activate : function() {
-                                _this.panel = this;
-                                if (_this.grid) {
-                                    _this.grid.footer.onClick('first');
-                                }
-                            }
-                        },
-                        background : false,
-                        fitContainer : true,
-                        fitToframe : true,
-                        region : 'west',
-                        tableName : 'curr_symbol',
-                        title : "curr_symbol",
+                       {
                         grid : {
-                            xtype: 'Grid',
-                            xns: Roo.grid,
-                            autoExpandColumn : 'curr_name',
-                            loadMask : true,
-                            listeners : {
-                                render : function() 
-                                {
-                                    _this.grid = this; 
-                                    //_this.dialog = Pman.Dialog.FILL_IN
-                                    if (_this.panel.active) {
-                                       this.footer.onClick('first');
-                                    }
-                                },
-                                rowdblclick : function (_self, rowIndex, e)
-                                {
-                                    if (!_this.dialog) return;
-                                    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
-                                        _this.grid.footer.onClick('first');
-                                    }); 
-                                }
-                            },
                             sm : {
-                                xtype: 'RowSelectionModel',
-                                xns: Roo.grid,
+                                '|xns' : 'Roo.grid',
+                                xtype : 'RowSelectionModel',
+                                singleSelect : true,
+                                xns : Roo.grid,
                                 listeners : {
-                                    afterselectionchange : function (_self)
-                                    {
-                                        _this.rgrid.footer.onClick('first');
-                                    }
-                                },
-                                singleSelect : true
+                                       afterselectionchange : function (_self)
+                                          {
+                                              _this.rgrid.footer.onClick('first');
+                                          }
+                                }
                             },
                             dataSource : {
-                                xtype: 'Store',
-                                xns: Roo.data,
-                                remoteSort : true,
-                                sortInfo : { field : 'curr_name', direction: 'ASC' },
                                 proxy : {
-                                    xtype: 'HttpProxy',
-                                    xns: Roo.data,
+                                    '|xns' : 'Roo.data',
+                                    url : baseURL + '/Roo/curr_symbol.php',
                                     method : 'GET',
-                                    url : baseURL + '/Roo/curr_symbol.php'
+                                    xtype : 'HttpProxy',
+                                    xns : Roo.data
                                 },
                                 reader : {
-                                    xtype: 'JsonReader',
-                                    xns: Roo.data,
-                                    totalProperty : 'total',
-                                    root : 'data',
+                                    '|xns' : 'Roo.data',
                                     id : 'id',
+                                    root : 'data',
+                                    xtype : 'JsonReader',
                                     fields : [
                                         {
                                             'name': 'curr_id',
@@ -112,151 +82,255 @@ Pman.Tab.XtupleCurrency = new Roo.XComponent({
                                             'name': 'curr_abbr',
                                             'type': 'string'
                                         }
-                                    ]
-                                }
+                                    ],
+                                    xns : Roo.data,
+                                    totalProperty : 'total'
+                                },
+                                '|xns' : 'Roo.data',
+                                remoteSort : true,
+                                xtype : 'Store',
+                                sortInfo : { field : 'curr_name', direction: 'ASC' },
+                                xns : Roo.data,
+                                items : [
+
+                                ]
+
                             },
                             footer : {
-                                xtype: 'PagingToolbar',
-                                xns: Roo,
+                                '|xns' : 'Roo',
                                 pageSize : 25,
-                                displayInfo : true,
-                                displayMsg : "Displaying curr_symbol{0} - {1} of {2}",
-                                emptyMsg : "No curr_symbol found"
+                                xtype : 'PagingToolbar',
+                                emptyMsg : "Nothing found",
+                                xns : Roo,
+                                displayMsg : "{0} - {1} of {2}",
+                                displayInfo : true
                             },
                             toolbar : {
-                                xtype: 'Toolbar',
-                                xns: Roo,
+                                '|xns' : 'Roo',
+                                xtype : 'Toolbar',
+                                xns : Roo,
                                 items : [
-                                    {
-                                        xtype: 'Fill',
-                                        xns: Roo.Toolbar
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
                                         text : "Add",
+                                        xtype : 'Button',
+                                        cls : 'x-btn-text-icon',
+                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+                                        xns : Roo.Toolbar,
+                                        listeners : {
+                                               click : function()
+                                                  {
+                                                      Pman.Dialog.XtupleCurrency.show( { curr_id : 0 } , function() {
+                                                          _this.grid.footer.onClick('first');
+                                                     }); 
+                                                  }
+                                        }
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Fill',
+                                        xns : Roo.Toolbar
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        text : "Get this months rates",
+                                        xtype : 'Button',
                                         cls : 'x-btn-text-icon',
                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+                                        xns : Roo.Toolbar,
                                         listeners : {
-                                            click : function()
-                                            {
-                                                if (!_this.dialog) return;
-                                                _this.dialog.show( { id : 0 } , function() {
-                                                    _this.grid.footer.onClick('first');
-                                               }); 
-                                            }
+                                               click : function()
+                                                  {
+                                                      var s = _this.grid.getSelectionModel().getSelected();
+                                                      
+                                                      if(!s){
+                                                          Roo.MessageBox.alert("Error", "Please select a currency!");
+                                                          return;
+                                                      }
+                                                          
+                                                      new Pman.Request({
+                                                          method: 'POST',
+                                                          url: baseURL+ '/Roo/curr_symbol',
+                                                          params : {
+                                                              curr_id : s.data.curr_id,
+                                                              _load_rates : 1
+                                                          },
+                                                          success : function() {
+                                                              _this.rgrid.footer.onClick('first');
+                                                          }
+                                                      });
+                                                  }
                                         }
                                     }
                                 ]
+
                             },
+                            '|xns' : 'Roo.grid',
+                            autoExpandColumn : 'curr_name',
+                            xtype : 'Grid',
+                            loadMask : true,
+                            xns : Roo.grid,
                             colModel : [
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'curr_name',
-                                    header : 'Name',
-                                    width : 80,
-                                    renderer : function(v,x,r) { 
-                                    
-                                        return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
-                                        
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'curr_symbol',
-                                    header : 'Symbol',
-                                    width : 80,
-                                    renderer : function(v,x,r) { 
-                                    
-                                        return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
-                                        
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'curr_abbr',
-                                    header : 'Abbr.',
-                                    width : 80,
-                                    renderer : function(v,x,r) { 
-                                    
-                                        return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
-                                        
-                                    }
-                                }
+                                {
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'Name',
+                                       width : 80,
+                                       renderer : function(v,x,r) { 
+                                       
+                                           return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
+                                           
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_name'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'Symbol',
+                                       width : 80,
+                                       renderer : function(v,x,r) { 
+                                       
+                                           return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
+                                           
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_symbol'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'Abbr.',
+                                       width : 80,
+                                       renderer : function(v,x,r) { 
+                                       
+                                           return String.format(r.data.curr_base*1 ? '<span style="color:red">{0}</span>' : '{0}', v); 
+                                           
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_abbr'
+                                   }
+                            ],
+                            listeners : {
+                               rowdblclick : function (_self, rowIndex, e)
+                                  {
+                                      Pman.Dialog.XtupleCurrency.show( this.getDataSource().getAt(rowIndex).data, function() {
+                                          _this.grid.footer.onClick('first');
+                                      }); 
+                                  },
+                               render : function() 
+                                  {
+                                      _this.grid = this; 
+                                      //_this.dialog = Pman.Dialog.FILL_IN
+                                      if (_this.panel.active) {
+                                         this.footer.onClick('first');
+                                      }
+                                  }
+                            },
+                            items : [
+
                             ]
-                        }
-                    },
-                    {
-                        xtype: 'GridPanel',
-                        xns: Roo,
-                        listeners : {
-                            activate : function() {
-                                _this.rpanel = this;
-                                if (_this.rgrid) {
-                                    _this.rgrid.footer.onClick('first');
-                                }
-                            }
+
                         },
+                        '|xns' : 'Roo',
+                        fitToframe : true,
                         background : false,
+                        region : 'west',
+                        title : "curr_symbol",
+                        xtype : 'GridPanel',
                         fitContainer : true,
-                        fitToframe : true,
-                        region : 'center',
-                        tableName : 'curr_rate',
-                        title : "curr_rate",
+                        xns : Roo,
+                        tableName : 'curr_symbol',
+                        listeners : {
+                               activate : function() {
+                                      _this.panel = this;
+                                      if (_this.grid) {
+                                          _this.grid.footer.onClick('first');
+                                      }
+                                  }
+                        },
+                        items : [
+
+                        ]
+
+                    },
+                       {
                         grid : {
-                            xtype: 'Grid',
-                            xns: Roo.grid,
-                            listeners : {
-                                render : function() 
-                                {
-                                    _this.rgrid = this; 
-                                    //_this.dialog = Pman.Dialog.FILL_IN
-                                    if (_this.rpanel.active) {
-                                       this.footer.onClick('first');
-                                    }
-                                },
-                                rowdblclick : function (_self, rowIndex, e)
-                                {
-                                    if (!_this.dialog) return;
-                                    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
-                                        _this.grid.footer.onClick('first');
-                                    }); 
-                                }
+                            sm : {
+                                '|xns' : 'Roo.grid',
+                                xtype : 'RowSelectionModel',
+                                singleSelect : true,
+                                xns : Roo.grid
                             },
-                            autoExpandColumn : 'curr_rate',
-                            loadMask : true,
-                            dataSource : {
-                                xtype: 'Store',
-                                xns: Roo.data,
-                                listeners : {
-                                    beforeload : function (_self, options)
-                                    {
-                                        var s = _this.grid.selModel.getSelected();
-                                        if (!s) { 
-                                            this.removeAll();
-                                            return false;
+                            toolbar : {
+                                '|xns' : 'Roo',
+                                xtype : 'Toolbar',
+                                xns : Roo,
+                                items : [
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Fill',
+                                        xns : Roo.Toolbar
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        text : "Delete",
+                                        xtype : 'Button',
+                                        cls : 'x-btn-text-icon',
+                                        icon : rootURL + '/Pman/templates/images/trash.gif',
+                                        xns : Roo.Toolbar,
+                                        listeners : {
+                                               click : function ()
+                                                  {
+                                                  
+                                                       var sel  = _this.rgrid.getSelectionModel().getSelected();
+                                                      if (!sel) {
+                                                          Roo.MessageBox.alert("Error", "Select a rate");
+                                                          return;
+                                                      }
+                                                      
+                                                      Roo.MessageBox.confirm("Are you sure", "Are you sure you want to delete this rate?",
+                                                          function(r) {
+                                                              if (r != 'yes') {
+                                                                  return;
+                                                              }
+                                                              new Pman.Request({
+                                                                  mask : 'Deleting',
+                                                                  url : baseURL + '/Roo/curr_rate',
+                                                                  method : 'POST',
+                                                                  params :  {
+                                                                      _delete : sel.data.curr_rate_id
+                                                                  },
+                                                                  success : function() {
+                                                                      _this.rgrid.footer.onClick('first');
+                                                                  }
+                                                              })
+                                                              
+                                                          }
+                                                      );
+                                                              
+                                                              
+                                                     
+                                                  }
                                         }
-                                        options.params.curr_id = s.data.curr_id;
-                                        options.params._with_base_symbol  = 1;
                                     }
-                                },
-                                remoteSort : true,
-                                sortInfo : { field : 'curr_effective', direction: 'DESC' },
+                                ]
+
+                            },
+                            dataSource : {
                                 proxy : {
-                                    xtype: 'HttpProxy',
-                                    xns: Roo.data,
+                                    '|xns' : 'Roo.data',
+                                    url : baseURL + '/Roo/curr_rate.php',
                                     method : 'GET',
-                                    url : baseURL + '/Roo/curr_rate.php'
+                                    xtype : 'HttpProxy',
+                                    xns : Roo.data
                                 },
                                 reader : {
-                                    xtype: 'JsonReader',
-                                    xns: Roo.data,
-                                    totalProperty : 'total',
-                                    root : 'data',
+                                    '|xns' : 'Roo.data',
                                     id : 'id',
+                                    root : 'data',
+                                    xtype : 'JsonReader',
+                                    xns : Roo.data,
                                     fields : [
                                         {
                                             'name': 'curr_rate_id',
@@ -284,116 +358,158 @@ Pman.Tab.XtupleCurrency = new Roo.XComponent({
                                             'type': 'date',
                                             'dateFormat': 'Y-m-d'
                                         }
-                                    ]
-                                }
+                                    ],
+                                    totalProperty : 'total'
+                                },
+                                '|xns' : 'Roo.data',
+                                xtype : 'Store',
+                                remoteSort : true,
+                                sortInfo : { field : 'curr_effective', direction: 'DESC' },
+                                xns : Roo.data,
+                                listeners : {
+                                       beforeload : function (_self, options)
+                                          {
+                                              var s = _this.grid.selModel.getSelected();
+                                              if (!s) { 
+                                                  this.removeAll();
+                                                  return false;
+                                              }
+                                              options.params.curr_id = s.data.curr_id;
+                                              options.params._with_base_symbol  = 1;
+                                          }
+                                },
+                                items : [
+
+                                ]
+
                             },
                             footer : {
-                                xtype: 'PagingToolbar',
-                                xns: Roo,
+                                '|xns' : 'Roo',
                                 pageSize : 25,
-                                displayInfo : true,
-                                displayMsg : "Displaying curr_rate{0} - {1} of {2}",
-                                emptyMsg : "No curr_rate found"
-                            },
-                            toolbar : {
-                                xtype: 'Toolbar',
-                                xns: Roo,
-                                items : [
-                                    {
-                                        xtype: 'Fill',
-                                        xns: Roo.Toolbar
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        text : "Add",
-                                        cls : 'x-btn-text-icon',
-                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
-                                        listeners : {
-                                            click : function()
-                                            {
-                                                if (!_this.dialog) return;
-                                                _this.dialog.show( { id : 0 } , function() {
-                                                    _this.grid.footer.onClick('first');
-                                               }); 
-                                            }
-                                        }
-                                    }
-                                ]
+                                xtype : 'PagingToolbar',
+                                emptyMsg : "No curr_rate found",
+                                xns : Roo,
+                                displayMsg : "Displaying curr_rate {0} - {1} of {2}",
+                                displayInfo : true
                             },
+                            '|xns' : 'Roo.grid',
+                            autoExpandColumn : 'curr_rate',
+                            xtype : 'Grid',
+                            loadMask : true,
+                            xns : Roo.grid,
                             colModel : [
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'curr_effective',
-                                    header : 'From',
-                                    width : 150,
-                                    renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'curr_expires',
-                                    header : 'To',
-                                    width : 150,
-                                    renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'curr_rate',
-                                    header : 'Rate',
-                                    width : 75,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'curr_rate1',
-                                    header : 'Rate',
-                                    width : 150,
-                                    renderer : function(v,x,r) {
-                                    
-                                         return String.format('{1}1 = {2}{0}', 
-                                            Roo.util.Format.number(r.data.curr_rate,2),
-                                            r.data.base_curr_symbol,
-                                            r.data.curr_id_curr_symbol
-                                        ); 
-                                        
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'curr_rate2',
-                                    header : 'Rate',
-                                    width : 150,
-                                    renderer : function(v,x,r) {    
-                                         return String.format('{2}1 = {1}{0}', 
-                                            Roo.util.Format.number(1.0/r.data.curr_rate,2),
-                                            r.data.base_curr_symbol,
-                                            r.data.curr_id_curr_symbol
-                                        ); 
-                                    }
-                                }
+                                {
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'From',
+                                       width : 150,
+                                       renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_effective'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'To',
+                                       width : 150,
+                                       renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_expires'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       header : 'Rate',
+                                       width : 75,
+                                       renderer : function(v) { return String.format('{0}', v); },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_rate'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       header : 'Rate',
+                                       width : 150,
+                                       renderer : function(v,x,r) {
+                                       
+                                            return String.format('{1}1 = {2}{0}', 
+                                               Roo.util.Format.number(r.data.curr_rate,2),
+                                               r.data.base_curr_symbol,
+                                               r.data.curr_id_curr_symbol
+                                           ); 
+                                           
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_rate1'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       header : 'Rate',
+                                       width : 150,
+                                       renderer : function(v,x,r) {    
+                                            return String.format('{2}1 = {1}{0}', 
+                                               Roo.util.Format.number(1.0/r.data.curr_rate,2),
+                                               r.data.base_curr_symbol,
+                                               r.data.curr_id_curr_symbol
+                                           ); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'curr_rate2'
+                                   }
+                            ],
+                            listeners : {
+                               render : function() 
+                                  {
+                                      _this.rgrid = this; 
+                                      //_this.dialog = Pman.Dialog.FILL_IN
+                                      if (_this.rpanel.active) {
+                                         this.footer.onClick('first');
+                                      }
+                                  }
+                            },
+                            items : [
+
                             ]
-                        }
+
+                        },
+                        '|xns' : 'Roo',
+                        fitToframe : true,
+                        background : false,
+                        region : 'center',
+                        title : "curr_rate",
+                        xtype : 'GridPanel',
+                        fitContainer : true,
+                        xns : Roo,
+                        tableName : 'curr_rate',
+                        listeners : {
+                               activate : function() {
+                                      _this.rpanel = this;
+                                      if (_this.rgrid) {
+                                          _this.rgrid.footer.onClick('first');
+                                      }
+                                  }
+                        },
+                        items : [
+
+                        ]
+
                     }
-                ],
-                west : {
-                    xtype: 'LayoutRegion',
-                    xns: Roo,
-                    split : true,
-                    width : 300
-                },
-                center : {
-                    xtype: 'LayoutRegion',
-                    xns: Roo
-                }
-            }
-        };
-    }
+                ]
+
+            },
+            '|xns' : 'Roo',
+            background : true,
+            region : 'center',
+            title : "Currency / Rates",
+            xtype : 'NestedLayoutPanel',
+            xns : Roo,
+            items : [
+
+            ]
+
+        };    }
 });