Pman.Tab.XtupleDashboard.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 8 May 2014 03:47:27 +0000 (11:47 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 8 May 2014 03:47:27 +0000 (11:47 +0800)
Pman.Tab.XtupleDashboard.js

Pman.Tab.XtupleDashboard.bjs
Pman.Tab.XtupleDashboard.js

index 67a7573..26abc7c 100644 (file)
                                                             "valueField": "ftype",
                                                             "width": 150,
                                                             "xtype": "ComboBox",
-                                                            "|dateRange": "function() {\n    return {\n                   date_from : _this.mfrom.getValue(),\n                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')\n         \n                };\n}\n",
+                                                            "|dateRange": "function() {\n\n  \n    var ftype =  this.getValue();\n    \n    switch(ftype) {\n        case 'Y':\n       \n            \n            return {\n               date_from : _this.mfrom.getValue(),\n                date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')\n     \n            };\n       ;\n           \n           \n            break;\n        case 'H':        \n        // \n                return {\n                    date_from : _this.mfrom.getValue(),\n                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')\n                };\n            \n          break;\n        case 'Q':                \n        \n            var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;\n\n           _this.mfrom.setValue(n.add(Date.MONTH, m));           \n           _this.mfrom.show();\n           _this.mto.hide(); \n           _this.daypick.hide();\n           _this.dateRange = function() {\n                return {\n                    date_from : _this.mfrom.getValue(),\n                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')\n                };\n            };   \n            break;\n\n        case 'M':        \n            var m = (new Date()).format('n') *1  - 1 ;\n           _this.mfrom.setValue(n.add(Date.MONTH, m ));\n           _this.mfrom.show();\n           _this.mto.hide(); \n           _this.daypick.hide();\n            _this.dateRange = function() {\n                return {\n                    date_from : _this.mfrom.getValue(),\n                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')\n                };\n            };   \n            break;        \n        \n\n        \n        case 'R':\n            // this month..\n            var m = (new Date()).format('n') * 1;            \n           _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); \n           _this.mto.setValue(n.add(Date.MONTH,m )); \n        \n        \n        \n             _this.mfrom.show();\n            _this.mto.show(); \n            _this.daypick.hide();\n             _this.dateRange = function() {\n                return {\n                    date_from : _this.mfrom.getValue(),\n                    date_to : _this.mto.getValue()\n                };\n            };   \n            \n            \n            break;\n        /*\n         case 'W': // today\n            var d = (new Date()).format('w') * -1;\n            _this.daypick.setValue( (new Date()).add(Date.DAY, d )); \n             _this.mfrom.hide();\n            _this.mto.hide(); \n            _this.daypick.show();\n            break;\n        \n        \n        case 'D': // today\n            _this.daypick.setValue(new Date()); \n             _this.mfrom.hide();\n            _this.mto.hide(); \n            _this.daypick.show();\n            break;\n            */\n        default:\n            alerT(\"oops invalid ftype?\");\n            return;\n    }\n\n    return {\n                   date_from : _this.mfrom.getValue(),\n                    date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')\n         \n                };\n}\n",
                                                             "|xns": "Roo.form",
                                                             "items": [
                                                                 {
index 0b2f954..28a9893 100644 (file)
@@ -310,6 +310,105 @@ Pman.Tab.XtupleDashboard = new Roo.XComponent({
                                                 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':                
+                                                        
+                                                            var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
+                                                
+                                                           _this.mfrom.setValue(n.add(Date.MONTH, m));           
+                                                           _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':        
+                                                            var m = (new Date()).format('n') *1  - 1 ;
+                                                           _this.mfrom.setValue(n.add(Date.MONTH, m ));
+                                                           _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;        
+                                                        
+                                                
+                                                        
+                                                        case 'R':
+                                                            // this month..
+                                                            var m = (new Date()).format('n') * 1;            
+                                                           _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); 
+                                                           _this.mto.setValue(n.add(Date.MONTH,m )); 
+                                                        
+                                                        
+                                                        
+                                                             _this.mfrom.show();
+                                                            _this.mto.show(); 
+                                                            _this.daypick.hide();
+                                                             _this.dateRange = function() {
+                                                                return {
+                                                                    date_from : _this.mfrom.getValue(),
+                                                                    date_to : _this.mto.getValue()
+                                                                };
+                                                            };   
+                                                            
+                                                            
+                                                            break;
+                                                        /*
+                                                         case 'W': // today
+                                                            var d = (new Date()).format('w') * -1;
+                                                            _this.daypick.setValue( (new Date()).add(Date.DAY, d )); 
+                                                             _this.mfrom.hide();
+                                                            _this.mto.hide(); 
+                                                            _this.daypick.show();
+                                                            break;
+                                                        
+                                                        
+                                                        case 'D': // today
+                                                            _this.daypick.setValue(new Date()); 
+                                                             _this.mfrom.hide();
+                                                            _this.mto.hide(); 
+                                                            _this.daypick.show();
+                                                            break;
+                                                            */
+                                                        default:
+                                                            alerT("oops invalid ftype?");
+                                                            return;
+                                                    }
+                                                
                                                     return {
                                                                    date_from : _this.mfrom.getValue(),
                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')