Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleGeneralLedger.js
index c762f39..afebcc7 100644 (file)
@@ -2,8 +2,10 @@
 
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
+Roo.namespace('Pman.Tab');
+
 Pman.Tab.XtupleGeneralLedger = new Roo.XComponent({
-    part     :  ["Xtuple","GeneralLedger"],
+    part     :  ["Xtuple", "GeneralLedger" ],
     order    : '100-Pman.Tab.XtupleGeneralLedger',
     region   : 'center',
     parent   : 'Pman.Tab.XtupleAccountsTab',
@@ -15,819 +17,813 @@ Pman.Tab.XtupleGeneralLedger = new Roo.XComponent({
         var _this = this;
         var MODULE = this;
         return {
-            xtype: 'NestedLayoutPanel',
-            xns: Roo,
-            background : true,
-            fitContainer : true,
-            fitToFrame : true,
-            region : 'center',
-            title : "General Ledger",
             layout : {
-                xtype: 'BorderLayout',
-                xns: Roo,
+                center : {
+                    '|xns' : 'Roo',
+                    xtype : 'LayoutRegion',
+                    tabPosition : 'top',
+                    xns : Roo
+                },
+                west : {
+                    '|xns' : 'Roo',
+                    xtype : 'LayoutRegion',
+                    tabPosition : 'top',
+                    width : 600,
+                    xns : Roo,
+                    split : true
+                },
+                '|xns' : 'Roo',
+                xtype : 'BorderLayout',
+                xns : Roo,
                 items : [
-                    {
-                        xtype: 'GridPanel',
-                        xns: Roo,
-                        listeners : {
-                            activate : function() {
-                                _this.wpanel = this;
-                                if (_this.wgrid) {
-                                    _this.wgrid.ds.load({});
-                                }
-                            }
-                        },
-                        background : false,
-                        fitContainer : true,
-                        fitToframe : true,
-                        region : 'west',
-                        tableName : 'accnt',
-                        title : "Account",
+                       {
                         grid : {
-                            xtype: 'Grid',
-                            xns: Roo.grid,
-                            listeners : {
-                                render : function() 
-                                {
-                                    _this.wgrid = this; 
-                                    _this.active = 1;
-                                    //_this.dialog = Pman.Dialog.FILL_IN
-                                    if (_this.wpanel.active) {
-                                       this.ds.load({});
-                                    }
-                                },
-                                rowclick : function (_self, rowIndex, e)
-                                {
-                                    var s = _this.wgrid.ds.getAt(rowIndex);
-                                    
-                                    if(s.data.accnt_id * 1 < 1){
-                                        return;
-                                    }
-                                    
-                                    _this.grid.footer.onClick('first');
-                                    
-                                    
-                                },
-                                rowdblclick : function (_self, rowIndex, e)
-                                {
-                                    var ret = _this.wgrid.ds.getAt(rowIndex).data;
-                                    if(ret.accnt_id * 1 < 1){
-                                        Roo.MessageBox.alert("Error", "Error occur on getting the account id!");
-                                        return;
-                                    }
-                                    Pman.Dialog.XtupleGLAccountNameEdit.show( {accnt_id : ret.accnt_id}, function() {
-                                        _this.wgrid.ds.load({});
-                                    }); 
-                                }
-                            },
-                            autoExpandColumn : 'accnt_descrip',
-                            loadMask : true,
                             toolbar : {
-                                xtype: 'Toolbar',
-                                xns: Roo,
+                                '|xns' : 'Roo',
+                                xtype : 'Toolbar',
+                                xns : Roo,
                                 items : [
-                                    {
-                                        xtype: 'TextField',
-                                        xns: Roo.form,
+                                       {
+                                        '|xns' : 'Roo.form',
+                                        xtype : 'TextField',
+                                        xns : Roo.form,
+                                        width : 100,
                                         listeners : {
-                                            specialkey : function (_self, e)
-                                            {
-                                              _this.wgrid.ds.load({});
-                                            },
-                                            render : function (_self)
-                                            {
-                                                _this.searchBox = _self;
-                                            }
-                                        },
-                                        width : 100
+                                               specialkey : function (_self, e)
+                                                  {
+                                                    _this.wgrid.ds.load({});
+                                                  },
+                                               render : function (_self)
+                                                  {
+                                                      _this.searchBox = _self;
+                                                  }
+                                        }
                                     },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function (_self, e)
-                                            {
-                                                _this.wgrid.ds.load({});
-                                            }
-                                        },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Button',
                                         cls : 'x-btn-icon',
-                                        icon : rootURL + '/Pman/templates/images/search.gif'
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
+                                        icon : rootURL + '/Pman/templates/images/search.gif',
+                                        xns : Roo.Toolbar,
                                         listeners : {
-                                            click : function (_self, e)
-                                            {
-                                                _this.searchBox.setValue('');\r
-                                                _this.wgrid.ds.load({});\r
-                                            }
-                                        },
-                                        cls : 'x-btn-icon',
-                                        icon : rootURL + '/Pman/templates/images/edit-clear.gif'
+                                               click : function (_self, e)
+                                                  {
+                                                      _this.wgrid.ds.load({});
+                                                  }
+                                        }
                                     },
-                                    {
-                                        xtype: 'DateField',
-                                        xns: Roo.form,
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Button',
+                                        cls : 'x-btn-icon',
+                                        icon : rootURL + '/Pman/templates/images/edit-clear.gif',
+                                        xns : Roo.Toolbar,
                                         listeners : {
-                                            render : function (_self)\r
-                                            {\r
-                                                _this.dateSel = _self;\r
-                                               _self.setValue(  new Date() );\r
-                                            },
-                                            select : function (combo, date)
-                                            {
-                                                _this.wgrid.ds.load({});
-                                            }
-                                        },
-                                        allowBlank : false,
+                                               click : function (_self, e)
+                                                  {
+                                                      _this.searchBox.setValue('');\r
+                                                      _this.wgrid.ds.load({});\r
+                                                  }
+                                        }
+                                    },
+                                       {
+                                        '|xns' : 'Roo.form',
                                         format : 'd/M/Y',
-                                        width : 100
+                                        xtype : 'DateField',
+                                        allowBlank : false,
+                                        width : 100,
+                                        xns : Roo.form,
+                                        listeners : {
+                                               render : function (_self)\r
+                                                  {\r
+                                                      _this.dateSel = _self;\r
+                                                     _self.setValue(  new Date() );\r
+                                                  },
+                                               select : function (combo, date)
+                                                  {
+                                                      _this.wgrid.ds.load({});
+                                                  }
+                                        }
                                     },
-                                    {
-                                        xtype: 'Fill',
-                                        xns: Roo.Toolbar
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Fill',
+                                        xns : Roo.Toolbar
                                     },
-                                    {
-                                        xtype: 'TextField',
-                                        xns: Roo.form,
+                                       {
+                                        '|xns' : 'Roo.form',
+                                        xtype : 'TextField',
+                                        xns : Roo.form,
+                                        width : 80,
                                         listeners : {
-                                            render : function (_self)
-                                            {
-                                                _this.orderBox = _self;
-                                            }
-                                        },
-                                        width : 80
+                                               render : function (_self)
+                                                  {
+                                                      _this.orderBox = _self;
+                                                  }
+                                        }
                                     },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        text : "Download / Upload",
+                                       {
                                         menu : {
-                                            xtype: 'Menu',
-                                            xns: Roo.menu,
+                                            '|xns' : 'Roo.menu',
+                                            xtype : 'Menu',
+                                            xns : Roo.menu,
                                             items : [
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Show Inactive",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            _this.active = (_this.active) ? 0 : 1;
-                                                            this.setText(_this.active ? "Show Inactive" : "Hide Inactive");
-                                                            _this.wgrid.ds.load({});
-                                                        }
-                                                    },
-                                                    text : "Show Inactive"
+                                                       click : function (_self, e)
+                                                          {
+                                                              _this.active = (_this.active) ? 0 : 1;
+                                                              this.setText(_this.active ? "Show Inactive" : "Hide Inactive");
+                                                              _this.wgrid.ds.load({});
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Export Account Details",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                          new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                timeout: 60000,
-                                                                newWindow : true,
-                                                                params : {
-                                                                    _group : 'accnt',
-                                                                    _name : 'export',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });;
-                                                            Roo.MessageBox.alert("Notice", "Downloading");
-                                                        }
-                                                    },
-                                                    text : "Export Account Details"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                            new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  timeout: 60000,
+                                                                  newWindow : true,
+                                                                  params : {
+                                                                      _group : 'accnt',
+                                                                      _name : 'export',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });;
+                                                              Roo.MessageBox.alert("Notice", "Downloading");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download Balances",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                            new Pman.download({
-                                                                url : baseURL + '/Roo/accnt.php',
-                                                                method : 'GET',
-                                                                params : {
-                                                                    'start' : 0,
-                                                                    'limit' : 9999,
-                                                                    _with_xt_balances : 1,
-                                                                    'csvTitles[0]' : 'Name', 'csvCols[0]' : 'accnt_name',
-                                                                    'csvTitles[1]' : 'Description', 'csvCols[1]' : 'accnt_descrip',
-                                                                    'csvTitles[2]' : 'Alternative Code', 'csvCols[2]' : 'accnt_code_alt',
-                                                                    'csvTitles[3]' : 'Alternative Description', 'csvCols[3]' : 'accnt_code_descrip',
-                                                                    'csvTitles[4]' : 'ADJUST', 'csvCols[4]' : 'balance_base'
-                                                                }
-                                                                
-                                                            });
-                                                        }
-                                                    },
-                                                    text : "Download Balances"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                              new Pman.download({
+                                                                  url : baseURL + '/Roo/accnt.php',
+                                                                  method : 'GET',
+                                                                  params : {
+                                                                      'start' : 0,
+                                                                      'limit' : 9999,
+                                                                      _with_xt_balances : 1,
+                                                                      'csvTitles[0]' : 'Name', 'csvCols[0]' : 'accnt_name',
+                                                                      'csvTitles[1]' : 'Description', 'csvCols[1]' : 'accnt_descrip',
+                                                                      'csvTitles[2]' : 'Alternative Code', 'csvCols[2]' : 'accnt_code_alt',
+                                                                      'csvTitles[3]' : 'Alternative Description', 'csvCols[3]' : 'accnt_code_descrip',
+                                                                      'csvTitles[4]' : 'ADJUST', 'csvCols[4]' : 'balance_base'
+                                                                  }
+                                                                  
+                                                              });
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Upload JE adjustment",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                           Pman.Dialog.XtupleUploadBalances.show( {} , function(res) {
-                                                                Pman.Dialog.Image.show({
-                                                                    _url : baseURL + '/Xtuple/Import/JournalEntry?' + Roo.urlEncode(res)
-                                                                }, function(data) {
-                                                                     _this.wgrid.ds.load({});
-                                                                });
-                                                           }); 
-                                                        }
-                                                    },
-                                                    text : "Upload JE adjustment"
+                                                       click : function (_self, e)
+                                                          {
+                                                             Pman.Dialog.XtupleUploadBalances.show( {} , function(res) {
+                                                                  Pman.Dialog.Image.show({
+                                                                      _url : baseURL + '/Xtuple/Import/JournalEntry?' + Roo.urlEncode(res)
+                                                                  }, function(data) {
+                                                                       _this.wgrid.ds.load({});
+                                                                  });
+                                                             }); 
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Upload Account Details",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                           Pman.Dialog.Image.show(
-                                                               {
-                                                                    _url : baseURL+'/Xtuple/Import/Accounts',
-                                                                    timeout : 90000
-                                                                
-                                                               },
-                                                               function (data) {
-                                                                    Roo.MessageBox.alert("Notice", data); 
-                                                                    _this.grid.footer.onClick('first');
-                                                        
-                                                               }
-                                                           );
-                                                        }
-                                                    },
-                                                    text : "Upload Account Details"
+                                                       click : function (_self, e)
+                                                          {
+                                                             Pman.Dialog.Image.show(
+                                                                 {
+                                                                      _url : baseURL+'/Xtuple/Import/Accounts',
+                                                                      timeout : 90000
+                                                                  
+                                                                 },
+                                                                 function (data) {
+                                                                      Roo.MessageBox.alert("Notice", data); 
+                                                                      _this.grid.footer.onClick('first');
+                                                          
+                                                                 }
+                                                             );
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AP - Day by Day Comparison",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                          new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                timeout: 60000,
-                                                                newWindow : true,
-                                                                params : {
-                                                                    _group : 'apopen',
-                                                                    _name : 'bydate',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });;
-                                                            Roo.MessageBox.alert("Notice", "This may take some time to calculate");
-                                                        }
-                                                    },
-                                                    text : "Download AP - Day by Day Comparison"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                            new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  timeout: 60000,
+                                                                  newWindow : true,
+                                                                  params : {
+                                                                      _group : 'apopen',
+                                                                      _name : 'bydate',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });;
+                                                              Roo.MessageBox.alert("Notice", "This may take some time to calculate");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AP open vs GL - summary of bad days",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                          new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                timeout: 90000,
-                                                                params : {
-                                                                    _group : 'apopen',
-                                                                    _name : 'bydatesummary',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });;
-                                                            Roo.MessageBox.alert("Notice", "This may take some time to calculate");
-                                                        }
-                                                    },
-                                                    text : "Download AP open vs GL - summary of bad days"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                            new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  timeout: 90000,
+                                                                  params : {
+                                                                      _group : 'apopen',
+                                                                      _name : 'bydatesummary',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });;
+                                                              Roo.MessageBox.alert("Notice", "This may take some time to calculate");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AP - Transactions on a single day",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                          new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                timeout: 90000,
-                                                                params : {
-                                                                     'startDate:text' : _this.dateSel.getValue().format('Y-m-d'),
-                                                                    'endDate:text' :  _this.dateSel.getValue().add(Date.DAY,1).format('Y-m-d'),
-                                                                
-                                                                    _group : 'apopen',
-                                                                    _name : 'all',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });;
-                                                            Roo.MessageBox.alert("Notice", "This may take some time to calculate");
-                                                        }
-                                                    },
-                                                    text : "Download AP - Transactions on a single day"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                            new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  timeout: 90000,
+                                                                  params : {
+                                                                       'startDate:text' : _this.dateSel.getValue().format('Y-m-d'),
+                                                                      'endDate:text' :  _this.dateSel.getValue().add(Date.DAY,1).format('Y-m-d'),
+                                                                  
+                                                                      _group : 'apopen',
+                                                                      _name : 'all',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });;
+                                                              Roo.MessageBox.alert("Notice", "This may take some time to calculate");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AP Aging at this date",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                          new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                timeout: 90000,
-                                                                newWindow : 1,
-                                                                params : {
-                                                                     'relDate:text' : _this.dateSel.getValue().format('Y-m-d'),
-                                                                    'useDocDate:text' :  'FALSE',
-                                                                    
-                                                                    _group : 'apAging',
-                                                                    _name : 'bydate',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });;
-                                                            Roo.MessageBox.alert("Notice", "This may take some time to calculate");
-                                                        }
-                                                    },
-                                                    text : "Download AP Aging at this date"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                            new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  timeout: 90000,
+                                                                  newWindow : 1,
+                                                                  params : {
+                                                                       'relDate:text' : _this.dateSel.getValue().format('Y-m-d'),
+                                                                      'useDocDate:text' :  'FALSE',
+                                                                      
+                                                                      _group : 'apAging',
+                                                                      _name : 'bydate',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });;
+                                                              Roo.MessageBox.alert("Notice", "This may take some time to calculate");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AP Aging Comparison back from this date",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                          new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                timeout: 90000,
-                                                                params : {
-                                                                      'relDate:text' : _this.dateSel.getValue().format('Y-m-d'),
-                                                                    
-                                                                    _group : 'apopen',
-                                                                    _name : 'history',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });
-                                                            Roo.MessageBox.alert("Notice", "This may take some time to calculate");
-                                                        }
-                                                    },
-                                                    text : "Download AP Aging Comparison back from this date"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                            new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  timeout: 90000,
+                                                                  params : {
+                                                                        'relDate:text' : _this.dateSel.getValue().format('Y-m-d'),
+                                                                      
+                                                                      _group : 'apopen',
+                                                                      _name : 'history',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });
+                                                              Roo.MessageBox.alert("Notice", "This may take some time to calculate");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AR - Transactions on a day",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                             new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                params : {
-                                                                    _group : 'aropen',
-                                                                    _name : 'all',
-                                                                    'startDate:text' : _this.dateSel.getValue().format('Y-m-d'),
-                                                                    'endDate:text' :  _this.dateSel.getValue().add(Date.DAY,1).format('Y-m-d'),
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999        
-                                                                    
-                                                                }
-                                                            });;
-                                                        }
-                                                    },
-                                                    text : "Download AR - Transactions on a day"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                               new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  params : {
+                                                                      _group : 'aropen',
+                                                                      _name : 'all',
+                                                                      'startDate:text' : _this.dateSel.getValue().format('Y-m-d'),
+                                                                      'endDate:text' :  _this.dateSel.getValue().add(Date.DAY,1).format('Y-m-d'),
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999        
+                                                                      
+                                                                  }
+                                                              });;
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Download AR - Day by Day Comparison",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            
-                                                             new Pman.Download({
-                                                                url : baseURL + '/Roo/Metasql',
-                                                                method : 'GET',
-                                                                params : {
-                                                                    _group : 'aropen',
-                                                                    _name : 'bydate',
-                                                                    csvCols : '*',
-                                                                    csvTitles : '*', 
-                                                                    limit : 9999         
-                                                                    
-                                                                }
-                                                            });;
-                                                        }
-                                                    },
-                                                    text : "Download AR - Day by Day Comparison"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                               new Pman.Download({
+                                                                  url : baseURL + '/Roo/Metasql',
+                                                                  method : 'GET',
+                                                                  params : {
+                                                                      _group : 'aropen',
+                                                                      _name : 'bydate',
+                                                                      csvCols : '*',
+                                                                      csvTitles : '*', 
+                                                                      limit : 9999         
+                                                                      
+                                                                  }
+                                                              });;
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    text : "Gltrans vs Stock (COHEAD)",
+                                               {
                                                     menu : {
-                                                        xtype: 'Menu',
-                                                        xns: Roo.menu,
+                                                        '|xns' : 'Roo.menu',
+                                                        xtype : 'Menu',
+                                                        xns : Roo.menu,
                                                         items : [
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Gltrans vs Stock By Date",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            timeout: 600000,
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'bydate',
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999       
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Gltrans vs Stock By Date"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000,
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'bydate',
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999       
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Gltrans vs Sales Order",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            timeout: 600000,
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'bycohead',
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999       
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Gltrans vs Sales Order"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000,
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'bycohead',
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999       
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Gltrans",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var dt = _this.dateSel.getValue();
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'gltrans',
-                                                                                '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999       
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Gltrans"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              var dt = _this.dateSel.getValue();
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'gltrans',
+                                                                                      '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999       
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Stock",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var dt = _this.dateSel.getValue();
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'stock',
-                                                                                '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999       
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Stock"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              var dt = _this.dateSel.getValue();
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'stock',
+                                                                                      '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999       
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             }
                                                         ]
-                                                    }
+
+                                                    },
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Gltrans vs Stock (COHEAD)",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
+                                                    items : [
+
+                                                    ]
+
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    text : "Gltrans vs Stock (PO)",
+                                               {
                                                     menu : {
-                                                        xtype: 'Menu',
-                                                        xns: Roo.menu,
+                                                        '|xns' : 'Roo.menu',
+                                                        xtype : 'Menu',
+                                                        xns : Roo.menu,
                                                         items : [
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Gltrans vs Stock By PO",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            timeout: 600000,
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'byorder',
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999       
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Gltrans vs Stock By PO"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000,
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'byorder',
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999       
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Gltrans",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var ord = _this.orderBox.getValue();
-                                                                        
-                                                                        if(!ord.length){
-                                                                            Roo.MessageBox.alert('Error','Please enter a PO number');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'byordergltrans',
-                                                                                'docnumber:text' : ord,
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999       
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Gltrans"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              var ord = _this.orderBox.getValue();
+                                                                              
+                                                                              if(!ord.length){
+                                                                                  Roo.MessageBox.alert('Error','Please enter a PO number');
+                                                                                  return;
+                                                                              }
+                                                                              
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'byordergltrans',
+                                                                                      'docnumber:text' : ord,
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999       
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Download Stock",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var ord = _this.orderBox.getValue();
-                                                                        
-                                                                        if(!ord.length){
-                                                                            Roo.MessageBox.alert('Error','Please enter a PO number');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL + '/Roo/Metasql',
-                                                                            method : 'GET',
-                                                                            params : {
-                                                                                _group : 'gltrans_stock',
-                                                                                _name : 'byorderstock',
-                                                                                'docnumber:text' : ord,
-                                                                                csvCols : '*',
-                                                                                csvTitles : '*', 
-                                                                                limit : 9999      
-                                                                            }
-                                                                        });
-                                                                    }
-                                                                },
-                                                                text : "Download Stock"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              var ord = _this.orderBox.getValue();
+                                                                              
+                                                                              if(!ord.length){
+                                                                                  Roo.MessageBox.alert('Error','Please enter a PO number');
+                                                                                  return;
+                                                                              }
+                                                                              
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL + '/Roo/Metasql',
+                                                                                  method : 'GET',
+                                                                                  params : {
+                                                                                      _group : 'gltrans_stock',
+                                                                                      _name : 'byorderstock',
+                                                                                      'docnumber:text' : ord,
+                                                                                      csvCols : '*',
+                                                                                      csvTitles : '*', 
+                                                                                      limit : 9999      
+                                                                                  }
+                                                                              });
+                                                                          }
+                                                                }
                                                             }
                                                         ]
-                                                    }
+
+                                                    },
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Gltrans vs Stock (PO)",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
+                                                    items : [
+
+                                                    ]
+
                                                 },
-                                                {
-                                                    xtype: 'Separator',
-                                                    xns: Roo.menu
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    text : "Kingdee",
+                                               {
                                                     menu : {
-                                                        xtype: 'Menu',
-                                                        xns: Roo.menu,
+                                                        '|xns' : 'Roo.menu',
+                                                        xtype : 'Menu',
+                                                        xns : Roo.menu,
                                                         items : [
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Currency",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL+'/Xtuple/Kingdee/Currency',
-                                                                            method : 'GET',
-                                                                            timeout: 600000
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "Currency"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL+'/Xtuple/Kingdee/Currency',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000
+                                                                              });
+                                                                              Roo.MessageBox.alert("Notice", "Report will download shortly");
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Exchange Rate",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL+'/Xtuple/Kingdee/Rate',
-                                                                            method : 'GET',
-                                                                            timeout: 600000
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "Exchange Rate"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL+'/Xtuple/Kingdee/Rate',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000
+                                                                              });
+                                                                              Roo.MessageBox.alert("Notice", "Report will download shortly");
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Accounts",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        
-                                                                         new Pman.Download({
-                                                                            url : baseURL+'/Xtuple/Kingdee/Account',
-                                                                            method : 'GET',
-                                                                            timeout: 600000
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "Accounts"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              
+                                                                               new Pman.Download({
+                                                                                  url : baseURL+'/Xtuple/Kingdee/Account',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000
+                                                                              });
+                                                                              Roo.MessageBox.alert("Notice", "Report will download shortly");
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Voucher Category",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        new Pman.Download({
-                                                                            url : baseURL+'/Xtuple/Kingdee/VoucherGroup',
-                                                                            method : 'GET',
-                                                                            timeout: 600000
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "Voucher Category"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              new Pman.Download({
+                                                                                  url : baseURL+'/Xtuple/Kingdee/VoucherGroup',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000
+                                                                              });
+                                                                              Roo.MessageBox.alert("Notice", "Report will download shortly");
+                                                                          }
+                                                                }
                                                             },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
+                                                               {
+                                                                '|xns' : 'Roo.menu',
+                                                                text : "Transactions",
+                                                                xtype : 'Item',
+                                                                xns : Roo.menu,
                                                                 listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var dt = _this.dateSel.getValue();
-                                                                        new Pman.Download({
-                                                                            url : baseURL+'/Xtuple/Kingdee/Voucher',
-                                                                            method : 'GET',
-                                                                            timeout: 600000,
-                                                                            params : {
-                                                                                _as_of : (typeof(dt) == 'string') ? dt : dt.format('Y-m-d')
-                                                                            }
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly - If you wanna import again, please delete all the exist!");
-                                                                    }
-                                                                },
-                                                                text : "Transactions"
+                                                                       click : function (_self, e)
+                                                                          {
+                                                                              var dt = _this.dateSel.getValue();
+                                                                              new Pman.Download({
+                                                                                  url : baseURL+'/Xtuple/Kingdee/Voucher',
+                                                                                  method : 'GET',
+                                                                                  timeout: 600000,
+                                                                                  params : {
+                                                                                      _as_of : (typeof(dt) == 'string') ? dt : dt.format('Y-m-d')
+                                                                                  }
+                                                                              });
+                                                                              Roo.MessageBox.alert("Notice", "Report will download shortly - If you wanna import again, please delete all the exist!");
+                                                                          }
+                                                                }
                                                             }
                                                         ]
-                                                    }
+
+                                                    },
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Kingdee",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
+                                                    items : [
+
+                                                    ]
+
                                                 }
                                             ]
-                                        }
+
+                                        },
+                                        '|xns' : 'Roo.Toolbar',
+                                        text : "Download / Upload",
+                                        xtype : 'Button',
+                                        xns : Roo.Toolbar,
+                                        items : [
+
+                                        ]
+
                                     }
                                 ]
+
                             },
                             dataSource : {
-                                xtype: 'Store',
-                                xns: Roo.data,
-                                listeners : {
-                                    beforeload : function (_self, options)
-                                    {
-                                        options.params = options.params || {};
-                                        
-                                        options.params.limit = 9999;
-                                        
-                                        options.params._general_ledger = 1;
-                                        
-                                        options.params['search[name]'] = _this.searchBox.getValue();
-                                        
-                                        if (_this.active) {\r
-                                            options.params.accnt_active = 1;
-                                            options.params._with_balances = 1;\r
-                                        }
-                                        
-                                       
-                                        \r    var dt = _this.dateSel.getValue();\r
-                                        options.params._as_of = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
-                                        
-                                    
-                                    }
-                                },
-                                remoteSort : true,
-                                sortInfo : { field : 'accnt_name', direction: 'ASC' },
                                 proxy : {
-                                    xtype: 'HttpProxy',
-                                    xns: Roo.data,
-                                    listeners : {
-                                        loadexception : function (This, o, arg, e)
-                                        {
-                                        
-                                        }
-                                    },
+                                    '|xns' : 'Roo.data',
+                                    url : baseURL + '/Roo/accnt.php',
+                                    xtype : 'HttpProxy',
                                     method : 'GET',
-                                    url : baseURL + '/Roo/accnt.php'
+                                    xns : Roo.data,
+                                    listeners : {
+                                       loadexception : function (This, o, arg, e)
+                                          {
+                                          
+                                          }
+                                    }
                                 },
                                 reader : {
-                                    xtype: 'JsonReader',
-                                    xns: Roo.data,
+                                    '|xns' : 'Roo.data',
                                     id : 'accnt_id',
                                     root : 'data',
-                                    totalProperty : 'total',
+                                    xtype : 'JsonReader',
                                     fields : [
                                         {
                                             'name': 'accnt_id',
@@ -857,456 +853,481 @@ Pman.Tab.XtupleGeneralLedger = new Roo.XComponent({
                                             'name': 'accnt_curr_id_curr_id',
                                             'type': 'int'
                                         }
-                                    ]
-                                }
-                            },
-                            colModel : [
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'accnt_name',
-                                    header : 'Name',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'accnt_code_alt',
-                                    header : 'Alternative Code',
-                                    hidden : true,
-                                    sortable : true,
-                                    width : 50,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'accnt_descrip_alt',
-                                    header : 'Alternative Description',
-                                    hidden : true,
-                                    sortable : true,
-                                    width : 50,
-                                    renderer : function(v) { return String.format('{0}', v); }
+                                    ],
+                                    xns : Roo.data,
+                                    totalProperty : 'total'
                                 },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'accnt_type',
-                                    header : 'Type',
-                                    sortable : true,
-                                    width : 50,
-                                    renderer : function(v,x,r) {
-                                         return String.format('{0}-{1}', v,r.data.accnt_subaccnttype_code); 
-                                     }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'accnt_descrip',
-                                    header : 'Description',
-                                    sortable : true,
-                                    width : 200,
-                                    renderer : function(v,x,r) 
-                                    { 
-                                        if(r.data.accnt_descrip_alt){
-                                            return String.format('{0} ({1})', v, r.data.accnt_descrip_alt);     
-                                        }
-                                        
-                                        return String.format('{0}', v); 
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'accnt_curr_id_curr_name',
-                                    header : 'Currency',
-                                    sortable : true,
-                                    width : 50,
-                                    renderer : function(v) { 
-                                        var base = baseURL.match(/sg\.php$/) ? 'SGD' : 'HKD';
-                                        if (v != base) {
-                                            return String.format('<span style="color:green">{0}</span>', v);     
-                                        }
-                                    
-                                        return String.format('{0}', v); 
-                                    }
+                                '|xns' : 'Roo.data',
+                                xtype : 'Store',
+                                remoteSort : true,
+                                sortInfo : { field : 'accnt_name', direction: 'ASC' },
+                                xns : Roo.data,
+                                listeners : {
+                                       beforeload : function (_self, options)
+                                          {
+                                              options.params = options.params || {};
+                                              
+                                              options.params.limit = 9999;
+                                              
+                                              options.params._general_ledger = 1;
+                                              
+                                              options.params['search[name]'] = _this.searchBox.getValue();
+                                              
+                                              if (_this.active) {\r
+                                                  options.params.accnt_active = 1;
+                                                  options.params._with_balances = 1;\r
+                                              }
+                                              
+                                             
+                                              \r    var dt = _this.dateSel.getValue();\r
+                                              options.params._as_of = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
+                                              
+                                          
+                                          }
                                 },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'balance',
-                                    header : 'Balance',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v) { \r
-                                       return String.format('<span style="color:blue;text-decoration:underline;">{0}</span>',\r
-                                                Roo.util.Format.usMoney(v) ); 
-                                    }
-                                }
+                                items : [
+
+                                ]
+
+                            },
+                            '|xns' : 'Roo.grid',
+                            autoExpandColumn : 'accnt_descrip',
+                            xtype : 'Grid',
+                            loadMask : true,
+                            xns : Roo.grid,
+                            colModel : [
+                                {
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Name',
+                                       width : 100,
+                                       renderer : function(v) { return String.format('{0}', v); },
+                                       xns : Roo.grid,
+                                       dataIndex : 'accnt_name'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       hidden : true,
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Alternative Code',
+                                       width : 50,
+                                       renderer : function(v) { return String.format('{0}', v); },
+                                       xns : Roo.grid,
+                                       dataIndex : 'accnt_code_alt'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       hidden : true,
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Alternative Description',
+                                       width : 50,
+                                       renderer : function(v) { return String.format('{0}', v); },
+                                       xns : Roo.grid,
+                                       dataIndex : 'accnt_descrip_alt'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Type',
+                                       width : 50,
+                                       renderer : function(v,x,r) {
+                                            return String.format('{0}-{1}', v,r.data.accnt_subaccnttype_code); 
+                                        },
+                                       xns : Roo.grid,
+                                       dataIndex : 'accnt_type'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Description',
+                                       width : 200,
+                                       renderer : function(v,x,r) 
+                                       { 
+                                           if(r.data.accnt_descrip_alt){
+                                               return String.format('{0} ({1})', v, r.data.accnt_descrip_alt);     
+                                           }
+                                           
+                                           return String.format('{0}', v); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'accnt_descrip'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Currency',
+                                       width : 50,
+                                       renderer : function(v) { 
+                                           var base = baseURL.match(/sg\.php$/) ? 'SGD' : 'HKD';
+                                           if (v != base) {
+                                               return String.format('<span style="color:green">{0}</span>', v);     
+                                           }
+                                       
+                                           return String.format('{0}', v); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'accnt_curr_id_curr_name'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Balance',
+                                       width : 100,
+                                       renderer : function(v) { \r
+                                          return String.format('<span style="color:blue;text-decoration:underline;">{0}</span>',\r
+                                                   Roo.util.Format.usMoney(v) ); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'balance'
+                                   }
+                            ],
+                            listeners : {
+                               rowdblclick : function (_self, rowIndex, e)
+                                  {
+                                      var ret = _this.wgrid.ds.getAt(rowIndex).data;
+                                      if(ret.accnt_id * 1 < 1){
+                                          Roo.MessageBox.alert("Error", "Error occur on getting the account id!");
+                                          return;
+                                      }
+                                      Pman.Dialog.XtupleGLAccountNameEdit.show( {accnt_id : ret.accnt_id}, function() {
+                                          _this.wgrid.ds.load({});
+                                      }); 
+                                  },
+                               render : function() 
+                                  {
+                                      _this.wgrid = this; 
+                                      _this.active = 1;
+                                      //_this.dialog = Pman.Dialog.FILL_IN
+                                      if (_this.wpanel.active) {
+                                         this.ds.load({});
+                                      }
+                                  },
+                               rowclick : function (_self, rowIndex, e)
+                                  {
+                                      var s = _this.wgrid.ds.getAt(rowIndex);
+                                      
+                                      if(s.data.accnt_id * 1 < 1){
+                                          return;
+                                      }
+                                      
+                                      _this.grid.footer.onClick('first');
+                                      
+                                      
+                                  }
+                            },
+                            items : [
+
                             ]
-                        }
-                    },
-                    {
-                        xtype: 'GridPanel',
-                        xns: Roo,
-                        listeners : {
-                            activate : function() {
-                                _this.panel = this;
-                             /*   if (_this.grid) {
-                                    _this.grid.ds.load({});
-                                } */
-                            }
+
                         },
+                        '|xns' : 'Roo',
+                        fitToframe : true,
                         background : false,
+                        region : 'west',
+                        title : "Account",
+                        xtype : 'GridPanel',
                         fitContainer : true,
-                        fitToframe : true,
-                        region : 'center',
-                        tableName : 'gltrans',
-                        title : "Transactions",
+                        xns : Roo,
+                        tableName : 'accnt',
+                        listeners : {
+                               activate : function() {
+                                      _this.wpanel = this;
+                                      if (_this.wgrid) {
+                                          _this.wgrid.ds.load({});
+                                      }
+                                  }
+                        },
+                        items : [
+
+                        ]
+
+                    },
+                       {
                         grid : {
-                            xtype: 'EditorGrid',
-                            xns: Roo.grid,
-                            listeners : {
-                                render : function() 
-                                {
-                                    _this.grid = this; 
-                                    //_this.dialog = Pman.Dialog.FILL_IN
-                                   /* if (_this.panel.active) {
-                                       this.ds.load({});
-                                    } */
-                                },
-                                afteredit : function (e)
-                                {   
-                                    var r = _this.grid.ds.getAt(e.row);
-                                    
-                                    if(e.value == e.originalValue || !r){
-                                        return;
-                                    }
-                                
-                                    new Pman.Request({
-                                        url : baseURL + '/Roo/Gltrans.php',
-                                        method :'POST',
-                                        params : {
-                                            gltrans_id : r.data.gltrans_id,
-                                            gltrans_notes : e.value,
-                                            _update_notes : 1
-                                            
-                                        },
-                                        success : function() {
-                                           
-                                            _this.grid.footer.onClick('refresh');
-                                            
-                                        }
-                                    });
-                                    
-                                },
-                                rowclass : function (gridview, rowcfg)
-                                {
-                                  rowcfg.rowClass = 'dragon-gl-fixedheight';
-                                },
-                                celldblclick : function (_self, rowIndex, columnIndex, e)
-                                {
-                                    var cm = this.colModel.config[columnIndex].dataIndex;
-                                    var r = this.ds.getAt(rowIndex);
-                                    if (cm != 'gltrans_date') {
-                                        return;
-                                    }
-                                    new Pman.Download({
-                                        url : baseURL+ '/Roo/Metasql',
-                                        method : 'GET',
-                                        params : {
-                                            _group : 'gltrans',
-                                            _name : 'sequence',
-                                            'gltrans_sequence:number' : r.data.gltrans_sequence,
-                                            limit : 9999
-                                        }
-                                    });
-                                    
-                                },
-                                cellclick : function (_self, rowIndex, columnIndex, e)
-                                {
-                                    if (!Roo.get(e.getTarget()).hasClass('dragon-ref-accounts')) {
-                                        return;
-                                    }
-                                    var r = this.ds.getAt(rowIndex);
-                                    Pman.Dialog.XtupleJournalEntry.show({
-                                        gltrans_id : r.data.gltrans_id
-                                    }, function()
-                                    {
-                                        // no need to refresh as it's viewed only?
-                                    });
-                                    
-                                    
-                                }
-                            },
-                            autoExpandColumn : 'gltrans_notes',
-                            clicksToEdit : 2,
-                            loadMask : true,
                             toolbar : {
-                                xtype: 'Toolbar',
-                                xns: Roo,
+                                '|xns' : 'Roo',
+                                xtype : 'Toolbar',
+                                xns : Roo,
                                 items : [
-                                    {
-                                        xtype: 'TextField',
-                                        xns: Roo.form,
+                                       {
+                                        '|xns' : 'Roo.form',
+                                        xtype : 'TextField',
+                                        xns : Roo.form,
                                         listeners : {
-                                            specialkey : function (_self, e)
-                                            {
-                                              _this.grid.footer.onClick('first');
-                                            },
-                                            render : function (_self)
-                                            {
-                                                _this.gltransBox = _self;
-                                            }
+                                               specialkey : function (_self, e)
+                                                  {
+                                                    _this.grid.footer.onClick('first');
+                                                  },
+                                               render : function (_self)
+                                                  {
+                                                      _this.gltransBox = _self;
+                                                  }
                                         }
                                     },
-                                    {
-                                        xtype: 'ComboBox',
-                                        xns: Roo.form,
-                                        listeners : {
-                                            render : function (_self)
-                                            {
-                                              _this.sourceCombo = _self;
-                                            },
-                                            select : function (combo, record, index)
-                                            {
-                                                Roo.log('select');
-                                                _this.grid.footer.onClick('first');
-                                            }
+                                       {
+                                        store : {
+                                            '|xns' : 'Roo.data',
+                                            xtype : 'SimpleStore',
+                                            data : [ 
+                                                [ 'ALL', "All Transactions"],
+                                                [ 'S/R' , "Sales Return"],
+                                                [ 'S/O', "Sales Orders"] ,
+                                                [ 'A/P', "Accounts Payable"] ,
+                                                [ 'A/R', "Accounts Recievable"] ,
+                                                [ 'I/M', "Inventory "] ,
+                                                [ 'G/L', "General Ledger "] 
+                                                
+                                                
+                                            ],
+                                            fields : [  'gltrans_source', 'gltrans_source_name'],
+                                            xns : Roo.data
                                         },
-                                        allowBlank : false,
+                                        '|xns' : 'Roo.form',
+                                        listWidth : 200,
+                                        triggerAction : 'all',
                                         displayField : 'gltrans_source_name',
-                                        editable : false,
-                                        fieldLabel : 'Status',
                                         hiddenName : 'gltrans_source',
-                                        listWidth : 200,
+                                        value : "ALL",
+                                        valueField : 'gltrans_source',
+                                        xtype : 'ComboBox',
+                                        allowBlank : false,
+                                        editable : false,
+                                        width : 150,
+                                        xns : Roo.form,
                                         mode : 'local',
                                         name : 'gltrans_source_name',
-                                        triggerAction : 'all',
-                                        value : "NOTCLOSED",
-                                        valueField : 'ftype',
-                                        width : 150,
-                                        store : {
-                                            xtype: 'SimpleStore',
-                                            xns: Roo.data,
-                                            data : [ 
-                                                [ 'NOTCLOSED', "Not Closed"],
-                                                [ 'CLOSED' , "Closed"],
-                                                [ 'UNPOSTED', "Unposted only"] ,
-                                                [ 'UNUSED', "Posted and not used"] 
-                                            ],
-                                            fields : [  'ftype', 'fname']
-                                        }
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
+                                        tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{gltrans_source_name}</b> </div>',
                                         listeners : {
-                                            click : function (_self, e)
-                                            {
-                                                _this.grid.footer.onClick('first');
-                                            }
+                                               render : function (_self)
+                                                  {
+                                                    _this.sourceCombo = _self;
+                                                  },
+                                               select : function (combo, record, index)
+                                                  {
+                                                      Roo.log('select');
+                                                      _this.grid.footer.onClick('first');
+                                                  }
                                         },
-                                        cls : 'x-btn-icon',
-                                        icon : rootURL + '/Pman/templates/images/search.gif'
+                                        items : [
+
+                                        ]
+
                                     },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Button',
+                                        cls : 'x-btn-icon',
+                                        icon : rootURL + '/Pman/templates/images/search.gif',
+                                        xns : Roo.Toolbar,
                                         listeners : {
-                                            click : function (_self, e)
-                                            {
-                                                _this.gltransBox.setValue('');\r
-                                                _this.grid.footer.onClick('first');\r
-                                            }
-                                        },
+                                               click : function (_self, e)
+                                                  {
+                                                      _this.grid.footer.onClick('first');
+                                                  }
+                                        }
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Button',
                                         cls : 'x-btn-icon',
-                                        icon : rootURL + '/Pman/templates/images/edit-clear.gif'
+                                        icon : rootURL + '/Pman/templates/images/edit-clear.gif',
+                                        xns : Roo.Toolbar,
+                                        listeners : {
+                                               click : function (_self, e)
+                                                  {
+                                                      _this.gltransBox.setValue('');\r
+                                                      _this.grid.footer.onClick('first');\r
+                                                  }
+                                        }
                                     },
-                                    {
-                                        xtype: 'Fill',
-                                        xns: Roo.Toolbar
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Fill',
+                                        xns : Roo.Toolbar
                                     },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        cls : 'x-btn-text-icon',
-                                        text : "Download",
-                                        icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
+                                       {
                                         menu : {
-                                            xtype: 'Menu',
-                                            xns: Roo.menu,
+                                            '|xns' : 'Roo.menu',
+                                            xtype : 'Menu',
+                                            xns : Roo.menu,
                                             items : [
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "Transactions from search result",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            var s = _this.wgrid.getSelectionModel().getSelected();
-                                                            
-                                                            if(!s){
-                                                                Roo.MessageBox.alert("Error", "Please select a account"); 
-                                                                return false;
-                                                            }
-                                                            
-                                                            var dt = _this.dateSel.getValue();
-                                                            
-                                                            if(!dt){
-                                                                Roo.MessageBox.alert("Error", "Please select a date on the right"); 
-                                                                return false;
-                                                            }  
-                                                            
-                                                            var g = _this.gltransBox.getValue();
-                                                            
-                                                            var params = {
-                                                                '_group' : 'account',
-                                                                '_name' : 'summary',
-                                                                'limit' : 99999,
-                                                                'accnt_id:number' : s.data.accnt_id,
-                                                                'endDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
-                                                                'csvTitles' : '*',
-                                                                'csvCols' : '*'
-                                                            };
-                                                            
-                                                            if(g.length){
-                                                                params['search:text'] = g;
-                                                            }
-                                                            
-                                                            new Pman.Download({
-                                                              url : baseURL + '/Roo/Metasql',
-                                                              params :   params,
-                                                              method : 'GET'
-                                                            });
-                                                            
-                                                            Roo.MessageBox.alert("Notice", "All Transactions Report for " + s.data.accnt_descrip + " will download shortly");
-                                                        }
-                                                    },
-                                                    text : "Download All Transactions"
+                                                       click : function (_self, e)
+                                                          {
+                                                              
+                                                              new Pman.Download({
+                                                                  grid : _this.grid,
+                                                                  csvCols : '*',
+                                                                  csvTitles : '*',
+                                                                  method : 'GET'
+                                                              });
+                                                              
+                                                              Roo.MessageBox.alert("Notice", "Search Transactions Report for " + s.data.accnt_descrip + " will download shortly");
+                                                          }
+                                                    }
+                                                },
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    xtype : 'Separator',
+                                                    xns : Roo.menu
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "All Transactions",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            var s = _this.wgrid.getSelectionModel().getSelected();
-                                                            
-                                                            if(!s){
-                                                                Roo.MessageBox.alert("Error", "Please select a account"); 
-                                                                return false;
-                                                            }
-                                                            
-                                                            var dt = _this.dateSel.getValue();
-                                                            
-                                                            if(!dt){
-                                                                Roo.MessageBox.alert("Error", "Please select a date on the right"); 
-                                                                return false;
-                                                            }  
-                                                            
-                                                            new Pman.Download({
-                                                                url : baseURL + '/Roo/Gltrans.php',
-                                                                method :'GET',
-                                                                params : {
-                                                                    gltrans_accnt_id : s.data.accnt_id,
-                                                                    _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
-                                                                    _download : 1
-                                                                }
-                                                            });
-                                                            
-                                                            Roo.MessageBox.alert("Notice", "Financial Year Report for " + s.data.accnt_descrip + " will download shortly");
-                                                        }
-                                                    },
-                                                    text : "Download All Transactions (Selected Financial Year)"
+                                                       click : function (_self, e)
+                                                          {
+                                                              var s = _this.wgrid.getSelectionModel().getSelected();
+                                                              
+                                                              if(!s){
+                                                                  Roo.MessageBox.alert("Error", "Please select a account"); 
+                                                                  return false;
+                                                              }
+                                                              
+                                                              var dt = _this.dateSel.getValue();
+                                                              
+                                                              if(!dt){
+                                                                  Roo.MessageBox.alert("Error", "Please select a date on the right"); 
+                                                                  return false;
+                                                              }  
+                                                              
+                                                              var g = _this.gltransBox.getValue();
+                                                              
+                                                              var params = {
+                                                                  '_group' : 'account',
+                                                                  '_name' : 'summary',
+                                                                  'limit' : 99999,
+                                                                  'accnt_id:number' : s.data.accnt_id,
+                                                                  'endDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
+                                                                  'csvTitles' : '*',
+                                                                  'csvCols' : '*'
+                                                              };
+                                                              
+                                                              if(g.length){
+                                                                  params['search:text'] = g;
+                                                              }
+                                                              
+                                                              new Pman.Download({
+                                                                url : baseURL + '/Roo/Metasql',
+                                                                params :   params,
+                                                                method : 'GET'
+                                                              });
+                                                              
+                                                              Roo.MessageBox.alert("Notice", "All Transactions Report for " + s.data.accnt_descrip + " will download shortly");
+                                                          }
+                                                    }
                                                 },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "All Transactions (Selected Financial Year)",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
                                                     listeners : {
-                                                        click : function (_self, e)
-                                                        {   
-                                                            var dt = _this.dateSel.getValue();
-                                                            
-                                                            if(!dt){
-                                                                Roo.MessageBox.alert("Error", "Please select a date on the right"); 
-                                                                return false;
-                                                            }   
-                                                               
-                                                            new Pman.Download({
-                                                                url : baseURL + '/Roo/Gltrans.php',
-                                                                method :'GET',
-                                                                timeout : 900000,
-                                                                params : {
-                                                                    _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
-                                                                    _download : 1
-                                                                }
-                                                            });
-                                                            
-                                                            Roo.MessageBox.alert("Notice", "Financial Year Report for all accounts will download shortly! it might take several minutes");
-                                                        }
-                                                    },
-                                                    text : "Download All Transactions  / All Accounts (Selected Financial Year)"
+                                                       click : function (_self, e)
+                                                          {
+                                                              var s = _this.wgrid.getSelectionModel().getSelected();
+                                                              
+                                                              if(!s){
+                                                                  Roo.MessageBox.alert("Error", "Please select a account"); 
+                                                                  return false;
+                                                              }
+                                                              
+                                                              var dt = _this.dateSel.getValue();
+                                                              
+                                                              if(!dt){
+                                                                  Roo.MessageBox.alert("Error", "Please select a date on the right"); 
+                                                                  return false;
+                                                              }  
+                                                              
+                                                              new Pman.Download({
+                                                                  url : baseURL + '/Roo/Gltrans.php',
+                                                                  method :'GET',
+                                                                  params : {
+                                                                      gltrans_accnt_id : s.data.accnt_id,
+                                                                      _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
+                                                                      _download : 1
+                                                                  }
+                                                              });
+                                                              
+                                                              Roo.MessageBox.alert("Notice", "Financial Year Report for " + s.data.accnt_descrip + " will download shortly");
+                                                          }
+                                                    }
+                                                },
+                                               {
+                                                    '|xns' : 'Roo.menu',
+                                                    text : "All Transactions  / All Accounts (Selected Financial Year)",
+                                                    xtype : 'Item',
+                                                    xns : Roo.menu,
+                                                    listeners : {
+                                                       click : function (_self, e)
+                                                          {   
+                                                              var dt = _this.dateSel.getValue();
+                                                              
+                                                              if(!dt){
+                                                                  Roo.MessageBox.alert("Error", "Please select a date on the right"); 
+                                                                  return false;
+                                                              }   
+                                                                 
+                                                              new Pman.Download({
+                                                                  url : baseURL + '/Roo/Gltrans.php',
+                                                                  method :'GET',
+                                                                  timeout : 900000,
+                                                                  params : {
+                                                                      _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
+                                                                      _download : 1
+                                                                  }
+                                                              });
+                                                              
+                                                              Roo.MessageBox.alert("Notice", "Financial Year Report for all accounts will download shortly! it might take several minutes");
+                                                          }
+                                                    }
                                                 }
                                             ]
-                                        }
+
+                                        },
+                                        '|xns' : 'Roo.Toolbar',
+                                        text : "Download",
+                                        xtype : 'Button',
+                                        cls : 'x-btn-text-icon',
+                                        icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
+                                        xns : Roo.Toolbar,
+                                        items : [
+
+                                        ]
+
                                     }
                                 ]
+
                             },
                             dataSource : {
-                                xtype: 'Store',
-                                xns: Roo.data,
-                                listeners : {
-                                    beforeload : function (_self, options)
-                                    {
-                                        options.params = options.params || {};
-                                        
-                                        var s = _this.wgrid.getSelectionModel().getSelected();
-                                        
-                                        if(!s){
-                                            return;
-                                        }
-                                        
-                                        var dt = _this.dateSel.getValue();
-                                        var g = _this.gltransBox.getValue();
-                                        
-                                        var params = {
-                                            _group : 'account',
-                                            _name : 'summary',
-                                            'accnt_id:number' : s.data.accnt_id,
-                                            'endDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d')
-                                        };
-                                        
-                                        if(g.length){
-                                            params['search:text'] = g;
-                                        }
-                                        
-                                        Roo.apply(options.params,params);
-                                        
-                                        var cm = _this.grid.getColumnModel();
-                                        var hide = (g.length) ? true : false;
-                                        
-                                        cm.setHidden(cm.getIndexByDataIndex('gltrans_balance'), hide);
-                                        
-                                        
-                                    }
-                                },
-                                remoteSort : true,
                                 proxy : {
-                                    xtype: 'HttpProxy',
-                                    xns: Roo.data,
+                                    '|xns' : 'Roo.data',
+                                    url : baseURL + '/Roo/Metasql.php',
                                     method : 'GET',
+                                    xtype : 'HttpProxy',
                                     timeout : 600000,
-                                    url : baseURL + '/Roo/Metasql.php'
+                                    xns : Roo.data
                                 },
                                 reader : {
-                                    xtype: 'JsonReader',
-                                    xns: Roo.data,
+                                    '|xns' : 'Roo.data',
                                     id : 'gltrans_id',
                                     root : 'data',
-                                    totalProperty : 'total',
+                                    xtype : 'JsonReader',
                                     fields : [
                                         {
                                             'name': 'gltrans_id',
@@ -1328,150 +1349,343 @@ Pman.Tab.XtupleGeneralLedger = new Roo.XComponent({
                                             'name': 'gltrans_notes',
                                             'type': 'string'
                                         }
-                                    ]
-                                }
+                                    ],
+                                    xns : Roo.data,
+                                    totalProperty : 'total'
+                                },
+                                '|xns' : 'Roo.data',
+                                xtype : 'Store',
+                                remoteSort : true,
+                                xns : Roo.data,
+                                listeners : {
+                                       beforeload : function (_self, options)
+                                          {
+                                              options.params = options.params || {};
+                                              
+                                              var s = _this.wgrid.getSelectionModel().getSelected();
+                                              
+                                              if(!s){
+                                                  return;
+                                              }
+                                              
+                                              var dt = _this.dateSel.getValue();
+                                              var g = _this.gltransBox.getValue();
+                                              
+                                              var params = {
+                                                  _group : 'account',
+                                                  _name : 'summary',
+                                                  'accnt_id:number' : s.data.accnt_id,
+                                                  'endDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d')
+                                              };
+                                              
+                                              // can not do source + search..
+                                              var source = _this.sourceCombo.getValue();
+                                              if (source != 'ALL') {
+                                                  params['search:text']  = source;
+                                              }
+                                              
+                                              if(g.length){
+                                                  params['search:text'] = g;
+                                              }
+                                              
+                                              Roo.apply(options.params,params);
+                                              
+                                              var cm = _this.grid.getColumnModel();
+                                              var hide = (g.length) ? true : false;
+                                              
+                                              cm.setHidden(cm.getIndexByDataIndex('gltrans_balance'), hide);
+                                              
+                                              
+                                          }
+                                },
+                                items : [
+
+                                ]
+
                             },
                             footer : {
-                                xtype: 'PagingToolbar',
-                                xns: Roo,
+                                '|xns' : 'Roo',
                                 pageSize : 100,
+                                xtype : 'PagingToolbar',
+                                xns : Roo,
                                 items : [
-                                    {
-                                        xtype: 'TextItem',
-                                        xns: Roo.Toolbar,
-                                        text : "Double Click To Edit"
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        text : "Double Click To Edit",
+                                        xtype : 'TextItem',
+                                        xns : Roo.Toolbar
                                     }
                                 ]
+
                             },
+                            '|xns' : 'Roo.grid',
+                            autoExpandColumn : 'gltrans_notes',
+                            xtype : 'EditorGrid',
+                            loadMask : true,
+                            clicksToEdit : 2,
+                            xns : Roo.grid,
                             colModel : [
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'gltrans_date',
-                                    header : 'Date',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v,x,r) { 
-                                        return String.format('{0}<br/><i style="color:#ccc;">{1}</i>',
-                                             v ? v : '', r.data.gltrans_sequence
-                                         ); 
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'gltrans_source',
-                                    header : 'Source / Who',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v,x,r) { 
-                                        return String.format('{0} - {1}<br/>{2}', v,r.data.gltrans_doctype, r.data.gltrans_username);
-                                     }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'gltrans_docnumber',
-                                    header : 'Doc Number',
-                                    hidden : true,
-                                    sortable : true,
-                                    width : 100
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'gltrans_notes',
-                                    header : 'Account / Notes',
-                                    width : 200,
-                                    renderer : function(v,x,r) 
-                                    { 
-                                        return String.format(
-                                                '<u class="dragon-ref-accounts">{3}</u> - <span qtip="{2}"><b>{0}</b>' + "\n" + '{1}', 
-                                                r.data.gltrans_docnumber,
-                                                 v, 
-                                                v.split('\n').join('<br/>'),
-                                                r.data.related_accounts
-                                                
-                                            ).split('\n').join('<br/>');
-                                        
-                                    },
-                                    editor : {
-                                        xtype: 'GridEditor',
-                                        xns: Roo.grid,
-                                        field : {
-                                            xtype: 'TextArea',
-                                            xns: Roo.form
-                                        }
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'gltrans_base_curr',
-                                    header : 'Currency',
-                                    sortable : true,
-                                    width : 75,
-                                    renderer : function(v) { 
-                                        return String.format('{0}', v); 
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'gltrans_credit_amount',
-                                    header : 'Credit',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v,x,r) { 
-                                        return String.format('{0}', v ? Roo.util.Format.number(v*1,2)  : ''  );
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'gltrans_debit_amount',
-                                    header : 'Debit',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v,x,r) { 
-                                        return String.format('{0}', v ? Roo.util.Format.number(v*1,2)  : ''  );
-                                    }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'gltrans_balance',
-                                    header : 'Amount',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v) { 
-                                        var c =v >= 0.0 ? 'black' :  'red';
-                                    \r
-                                       return String.format('<span style="color:' + c + ';">{0}</span>',\r
-                                                Roo.util.Format.number(v,2) ); 
-                                    }
-                                }
+                                {
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Date',
+                                       width : 100,
+                                       renderer : function(v,x,r) { 
+                                           return String.format('{0}<br/><i style="color:#ccc;">{1}</i>',
+                                                v ? v : '', r.data.gltrans_sequence
+                                            ); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_date'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       hidden : true,
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Date',
+                                       width : 100,
+                                       renderer : function(v,x,r) { 
+                                           return String.format('{0}', v); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_created'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Source / Who',
+                                       width : 100,
+                                       renderer : function(v,x,r) { 
+                                           return String.format('{0} - {1}<br/>{2} <i style="color:#ccc;">{3}</i>',
+                                           
+                                                    v,r.data.gltrans_doctype, 
+                                                    r.data.gltrans_username,
+                                                    r.data.gltrans_created);
+                                        },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_source'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       hidden : true,
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Doc Number',
+                                       width : 100,
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_docnumber'
+                                   },
+{
+                                       editor : {
+                                           field : {
+                                               '|xns' : 'Roo.form',
+                                               xtype : 'TextArea',
+                                               xns : Roo.form
+                                           },
+                                           '|xns' : 'Roo.grid',
+                                           xtype : 'GridEditor',
+                                           xns : Roo.grid,
+                                           items : [
+
+                                           ]
+
+                                       },
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'Account / Notes',
+                                       width : 200,
+                                       renderer : function(v,x,r) 
+                                       { 
+                                           return String.format(
+                                                   '<u class="dragon-ref-accounts">{3}</u> - <span qtip="{2}"><b>{0}</b>' + "\n" + '{1}', 
+                                                   r.data.gltrans_docnumber,
+                                                    v, 
+                                                   v.split('\n').join('<br/>'),
+                                                   r.data.related_accounts
+                                                   
+                                               ).split('\n').join('<br/>');
+                                           
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_notes',
+                                       items : [
+
+                                       ]
+
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Currency',
+                                       width : 75,
+                                       renderer : function(v) { 
+                                           return String.format('{0}', v); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_base_curr'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Credit',
+                                       width : 100,
+                                       renderer : function(v,x,r) { 
+                                           return String.format('{0}', v ? Roo.util.Format.number(v*1,2)  : ''  );
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_credit_amount'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Debit',
+                                       width : 100,
+                                       renderer : function(v,x,r) { 
+                                           return String.format('{0}', v ? Roo.util.Format.number(v*1,2)  : ''  );
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_debit_amount'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       align : 'right',
+                                       xtype : 'ColumnModel',
+                                       sortable : true,
+                                       header : 'Amount',
+                                       width : 100,
+                                       renderer : function(v) { 
+                                           var c =v >= 0.0 ? 'black' :  'red';
+                                       \r
+                                          return String.format('<span style="color:' + c + ';">{0}</span>',\r
+                                                   Roo.util.Format.number(v,2) ); 
+                                       },
+                                       xns : Roo.grid,
+                                       dataIndex : 'gltrans_balance'
+                                   }
+                            ],
+                            listeners : {
+                               render : function() 
+                                  {
+                                      _this.grid = this; 
+                                      //_this.dialog = Pman.Dialog.FILL_IN
+                                     /* if (_this.panel.active) {
+                                         this.ds.load({});
+                                      } */
+                                  },
+                               celldblclick : function (_self, rowIndex, columnIndex, e)
+                                  {
+                                      var cm = this.colModel.config[columnIndex].dataIndex;
+                                      var r = this.ds.getAt(rowIndex);
+                                      if (cm != 'gltrans_date') {
+                                          return;
+                                      }
+                                      new Pman.Download({
+                                          url : baseURL+ '/Roo/Metasql',
+                                          method : 'GET',
+                                          params : {
+                                              _group : 'gltrans',
+                                              _name : 'sequence',
+                                              'gltrans_sequence:number' : r.data.gltrans_sequence,
+                                              limit : 9999
+                                          }
+                                      });
+                                      
+                                  },
+                               cellclick : function (_self, rowIndex, columnIndex, e)
+                                  {
+                                      if (!Roo.get(e.getTarget()).hasClass('dragon-ref-accounts')) {
+                                          return;
+                                      }
+                                      var r = this.ds.getAt(rowIndex);
+                                      Pman.Dialog.XtupleJournalEntry.show({
+                                          gltrans_id : r.data.gltrans_id
+                                      }, function()
+                                      {
+                                          // no need to refresh as it's viewed only?
+                                      });
+                                      
+                                      
+                                  },
+                               rowclass : function (gridview, rowcfg)
+                                  {
+                                    rowcfg.rowClass = 'dragon-gl-fixedheight';
+                                  },
+                               afteredit : function (e)
+                                  {   
+                                      var r = _this.grid.ds.getAt(e.row);
+                                      
+                                      if(e.value == e.originalValue || !r){
+                                          return;
+                                      }
+                                  
+                                      new Pman.Request({
+                                          url : baseURL + '/Roo/Gltrans.php',
+                                          method :'POST',
+                                          params : {
+                                              gltrans_id : r.data.gltrans_id,
+                                              gltrans_notes : e.value,
+                                              _update_notes : 1
+                                              
+                                          },
+                                          success : function() {
+                                             
+                                              _this.grid.footer.onClick('refresh');
+                                              
+                                          }
+                                      });
+                                      
+                                  }
+                            },
+                            items : [
+
                             ]
-                        }
+
+                        },
+                        '|xns' : 'Roo',
+                        fitToframe : true,
+                        background : false,
+                        region : 'center',
+                        title : "Transactions",
+                        xtype : 'GridPanel',
+                        fitContainer : true,
+                        xns : Roo,
+                        tableName : 'gltrans',
+                        listeners : {
+                               activate : function() {
+                                      _this.panel = this;
+                                   /*   if (_this.grid) {
+                                          _this.grid.ds.load({});
+                                      } */
+                                  }
+                        },
+                        items : [
+
+                        ]
+
                     }
-                ],
-                center : {
-                    xtype: 'LayoutRegion',
-                    xns: Roo,
-                    tabPosition : 'top'
-                },
-                west : {
-                    xtype: 'LayoutRegion',
-                    xns: Roo,
-                    split : true,
-                    tabPosition : 'top',
-                    width : 600
-                }
-            }
-        };
-    }
+                ]
+
+            },
+            '|xns' : 'Roo',
+            fitToFrame : true,
+            background : true,
+            region : 'center',
+            title : "General Ledger",
+            xtype : 'NestedLayoutPanel',
+            fitContainer : true,
+            xns : Roo,
+            items : [
+
+            ]
+
+        };    }
 });