Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleDashboard.js
index a6e1790..963d592 100644 (file)
@@ -172,14 +172,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                     render : function (_self)
                                                     {
                                                       _this.viewType = _self;
-                                                       _this.dateRange = function() {
-                                                                    return {
-                                                                       date_from : _this.mfrom.getValue(),
-                                                                        date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
-                                                             
-                                                                    };
-                                                               
-                                                               };
+                                                      
                                                     },
                                                     select : function (combo, record, index)
                                                     {
@@ -199,14 +192,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                _this.mto.hide(); 
                                                                _this.daypick.hide();
                                                                
-                                                               _this.dateRange = function() {
-                                                                    return {
-                                                                       date_from : _this.mfrom.getValue(),
-                                                                        date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
-                                                             
-                                                                    };
-                                                               
-                                                               };
+                                                          
                                                                
                                                                
                                                                 break;
@@ -219,12 +205,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                _this.mfrom.show();
                                                                _this.mto.hide(); 
                                                                _this.daypick.hide();
-                                                               _this.dateRange = function() {
-                                                                    return {
-                                                                        date_from : _this.mfrom.getValue(),
-                                                                        date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
-                                                                    };
-                                                               };
+                                                             
                                                               break;
                                                             case 'Q':                
                                                             
@@ -234,12 +215,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                _this.mfrom.show();
                                                                _this.mto.hide(); 
                                                                _this.daypick.hide();
-                                                               _this.dateRange = function() {
-                                                                    return {
-                                                                        date_from : _this.mfrom.getValue(),
-                                                                        date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
-                                                                    };
-                                                                };   
+                                                                  
                                                                 break;
                                                     
                                                             case 'M':        
@@ -248,12 +224,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                _this.mfrom.show();
                                                                _this.mto.hide(); 
                                                                _this.daypick.hide();
-                                                                _this.dateRange = function() {
-                                                                    return {
-                                                                        date_from : _this.mfrom.getValue(),
-                                                                        date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
-                                                                    };
-                                                                };   
+                                                                 
                                                                 break;        
                                                             
                                                     
@@ -269,12 +240,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                  _this.mfrom.show();
                                                                 _this.mto.show(); 
                                                                 _this.daypick.hide();
-                                                                 _this.dateRange = function() {
-                                                                    return {
-                                                                        date_from : _this.mfrom.getValue(),
-                                                                        date_to : _this.mto.getValue()
-                                                                    };
-                                                                };   
+                                                                 
                                                                 
                                                                 
                                                                 break;
@@ -316,6 +282,70 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                 value : "R",
                                                 valueField : 'ftype',
                                                 width : 150,
+                                                dateRange : function() {
+                                                
+                                                  
+                                                    var ftype =  this.getValue();
+                                                    
+                                                    switch(ftype) {
+                                                        case 'Y':
+                                                       
+                                                            
+                                                            return {
+                                                               date_from : _this.mfrom.getValue(),
+                                                                date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
+                                                     
+                                                            };
+                                                       ;
+                                                           
+                                                           
+                                                            break;
+                                                        case 'H':        
+                                                        // 
+                                                                return {
+                                                                    date_from : _this.mfrom.getValue(),
+                                                                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
+                                                                };
+                                                            
+                                                          break;
+                                                        case 'Q':                
+                                                        
+                                                            
+                                                 
+                                                                return {
+                                                                    date_from : _this.mfrom.getValue(),
+                                                                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
+                                                                };
+                                                           
+                                                            break;
+                                                
+                                                        case 'M':        
+                                                           
+                                                                return {
+                                                                    date_from : _this.mfrom.getValue(),
+                                                                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
+                                                                };
+                                                              
+                                                               
+                                                        
+                                                
+                                                        
+                                                        case 'R':
+                                                           
+                                                                return {
+                                                                    date_from : _this.mfrom.getValue(),
+                                                                    date_to : _this.mto.getValue()
+                                                                };
+                                                           
+                                                            
+                                                            break;
+                                                       
+                                                        default:
+                                                            Roo.MessageBox.alert("select range");
+                                                            return;
+                                                    }
+                                                 
+                                                },
                                                 store : {
                                                     xtype: 'SimpleStore',
                                                     xns: Roo.data,
@@ -426,11 +456,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/SalesByCustomer',
-                                                                        params : {
-                                                                        
-                                                                              date_from : _this.mfrom.getValue(),
-                                                                                    date_to :_this.mto.getValue()
-                                                                        }
+                                                                        params : _this.viewType.dateRange()
                                                                          
                                                                     
                                                                     });
@@ -446,7 +472,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/SalesByCountry',
-                                                                        params :  _this.dateRange()
+                                                                        params :  _this.viewType.dateRange()
                                                                     
                                                                     });
                                                                 }
@@ -461,7 +487,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/SalesByProduct',
-                                                                        params :  _this.dateRange()
+                                                                        params :  _this.viewType.dateRange()
                                                                     
                                                                     });
                                                                 }
@@ -480,7 +506,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
-                                                                        params :  _this.dateRange()
+                                                                        params :  _this.viewType.dateRange()
                                                                     
                                                                     });
                                                                 }
@@ -495,7 +521,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
-                                                                        params :  _this.dateRange()
+                                                                        params :  _this.viewType.dateRange()
                                                                     
                                                                     });
                                                                 }
@@ -514,7 +540,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/StockAtLocation',
-                                                                         params :  _this.dateRange()
+                                                                         params :  _this.viewType.dateRange()
                                                                     
                                                                     });
                                                                     Roo.MessageBox.alert("Downloading", 
@@ -536,7 +562,7 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                                 {
                                                                     new Pman.Download({
                                                                         url :baseURL + '/Xtuple/Reports/SGTax',
-                                                                         params :  _this.dateRange()
+                                                                         params :  _this.viewType.dateRange()
                                                                     
                                                                     });
                                                                     Roo.MessageBox.alert("Downloading",