Pman.Tab.XtupleDashboard.bjs
[Pman.Xtuple] / Pman.Tab.XtupleDashboard.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.XtupleDashboard = new Roo.XComponent({
6     part     :  ["Xtuple","Dashboard"],
7     order    : '001-Pman.Tab.XtupleDashboard',
8     region   : 'center',
9     parent   : 'Pman',
10     name     : "Pman.Tab.XtupleDashboard",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function (_self)
22                 {
23                     
24                     try {
25                        // Pman.Xtuple.DashboardRender.load();    
26                     } catch (e) {
27                         Roo.log(e);
28                     }
29                     
30                 }
31             },
32             region : 'center',
33             title : "Management Dashboard",
34             layout : {
35                 xtype: 'BorderLayout',
36                 xns: Roo,
37                 items : [
38                     {
39                         xtype: 'NestedLayoutPanel',
40                         xns: Roo,
41                         listeners : {
42                             render : function (_self)
43                             {
44                                 _this.dashpanel = _self;
45                                 
46                                 
47                                 (function() { 
48                                         this.layout.getRegion('center').showPanel(0);
49                                 }).defer(100,this);
50                             }
51                         },
52                         region : 'center',
53                         layout : {
54                             xtype: 'BorderLayout',
55                             xns: Roo,
56                             items : [
57                                 {
58                                     xtype: 'ContentPanel',
59                                     xns: Roo,
60                                     listeners : {
61                                         render : function (_self)
62                                         {
63                                             _this.viewPanel = _self;
64                                             
65                                           
66                                             //_this.paper = Raphael(_self.el.dom);
67                                             
68                                         
69                                          
70                                             
71                                             
72                                             
73                                         },
74                                         resize : function (_self, width, height)
75                                         {
76                                             
77                                            Roo.log("RESIZE");
78                                            /* _this.svg.attr("width", width)
79                                                 .attr("height", height);
80                                                 */
81                                            //      _this.paper.setSize(width, 400);
82                                             try {
83                                         Pman.Clipping.DashboardRender.resize(width,height);
84                                             } catch (e) {
85                                                 Roo.log(e);
86                                             }
87                                         
88                                            
89                                             
90                                         },
91                                         activate : function (_self)
92                                         {
93                                             if (!_this.loadonce) {
94                                                 _this.loadonce = true;
95                                             
96                                                 (function () { Pman.Xtuple.DashboardRender.load(); }).defer(1000); 
97                                             }
98                                         }
99                                     },
100                                     autoScroll : true,
101                                     fitContainer : true,
102                                     fitToFrame : true,
103                                     region : 'center',
104                                     toolbar : {
105                                         xtype: 'Toolbar',
106                                         xns: Roo,
107                                         items : [
108                                             {
109                                                 xtype: 'TextItem',
110                                                 xns: Roo.Toolbar,
111                                                 text : "Show : "
112                                             },
113                                             {
114                                                 xtype: 'ComboBox',
115                                                 xns: Roo.form,
116                                                 listeners : {
117                                                     render : function (_self)
118                                                     {
119                                                         _this.countryCombo= _self;
120                                                     }
121                                                 },
122                                                 allowBlank : true,
123                                                 displayField : 'addr_country',
124                                                 editable : false,
125                                                 emptyText : " Country",
126                                                 forceSelection : true,
127                                                 listWidth : 400,
128                                                 loadingText : "Searching...",
129                                                 minChars : 2,
130                                                 name : 'addr_country',
131                                                 pageSize : 20,
132                                                 qtip : "Select addr",
133                                                 selectOnFocus : true,
134                                                 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
135                                                 triggerAction : 'all',
136                                                 typeAhead : true,
137                                                 width : 100,
138                                                 store : {
139                                                     xtype: 'Store',
140                                                     xns: Roo.data,
141                                                     listeners : {
142                                                         beforeload : function (_self, o){
143                                                             o.params = o.params || {};
144                                                             // set more here
145                                                             o.params._distinct = 'addr_country';
146                                                             o.params._columns = 'addr_country';    
147                                                             o.params['!addr_country'] = '';
148                                                         }
149                                                     },
150                                                     remoteSort : true,
151                                                     sortInfo : { direction : 'ASC', field: 'addr_country' },
152                                                     proxy : {
153                                                         xtype: 'HttpProxy',
154                                                         xns: Roo.data,
155                                                         method : 'GET',
156                                                         url : baseURL + '/Roo/addr.php'
157                                                     },
158                                                     reader : {
159                                                         xtype: 'JsonReader',
160                                                         xns: Roo.data,
161                                                         id : 'id',
162                                                         root : 'data',
163                                                         totalProperty : 'total',
164                                                         fields : [{"name":"id","type":"int"},{"name":"addr_line1","type":"string"}]
165                                                     }
166                                                 }
167                                             },
168                                             {
169                                                 xtype: 'ComboBox',
170                                                 xns: Roo.form,
171                                                 listeners : {
172                                                     render : function (_self)
173                                                     {
174                                                       _this.viewType = _self;
175                                                       
176                                                     },
177                                                     select : function (combo, record, index)
178                                                     {
179                                                         Roo.log('select');
180                                                        // Pman.Clipping.DashboardRender.load();
181                                                         var n = new Date();
182                                                         var ys = n.format('Y' )+ '-05-01';
183                                                         n = Date.parseDate(ys, 'Y-n-d');
184                                                         
185                                                         var ftype = record ? record.data.ftype : this.getValue();
186                                                         
187                                                         switch(ftype) {
188                                                             case 'Y':
189                                                                 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
190                                                                _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
191                                                                _this.mfrom.show();
192                                                                _this.mto.hide(); 
193                                                                _this.daypick.hide();
194                                                                
195                                                                _this.dateRange = function() {
196                                                                     return {
197                                                                        date_from : _this.mfrom.getValue(),
198                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
199                                                              
200                                                                     };
201                                                                
202                                                                };
203                                                                
204                                                                
205                                                                 break;
206                                                             case 'H':        
207                                                             // ?? latest half
208                                                                 var m = (new Date()).format('n')*1  > 6 ? 6 : 0;
209                                                                 Roo.log(m);
210                                                                 Roo.log( n.add(Date.MONTH,m));
211                                                                _this.mfrom.setValue(n.add(Date.MONTH,m));           
212                                                                _this.mfrom.show();
213                                                                _this.mto.hide(); 
214                                                                _this.daypick.hide();
215                                                                _this.dateRange = function() {
216                                                                     return {
217                                                                         date_from : _this.mfrom.getValue(),
218                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
219                                                                     };
220                                                                };
221                                                               break;
222                                                             case 'Q':                
223                                                             
224                                                                 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
225                                                     
226                                                                _this.mfrom.setValue(n.add(Date.MONTH, m));           
227                                                                _this.mfrom.show();
228                                                                _this.mto.hide(); 
229                                                                _this.daypick.hide();
230                                                                _this.dateRange = function() {
231                                                                     return {
232                                                                         date_from : _this.mfrom.getValue(),
233                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
234                                                                     };
235                                                                 };   
236                                                                 break;
237                                                     
238                                                             case 'M':        
239                                                                 var m = (new Date()).format('n') *1  - 1 ;
240                                                                _this.mfrom.setValue(n.add(Date.MONTH, m ));
241                                                                _this.mfrom.show();
242                                                                _this.mto.hide(); 
243                                                                _this.daypick.hide();
244                                                                 _this.dateRange = function() {
245                                                                     return {
246                                                                         date_from : _this.mfrom.getValue(),
247                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
248                                                                     };
249                                                                 };   
250                                                                 break;        
251                                                             
252                                                     
253                                                             
254                                                             case 'R':
255                                                                 // this month..
256                                                                 var m = (new Date()).format('n') * 1;            
257                                                                _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); 
258                                                                _this.mto.setValue(n.add(Date.MONTH,m )); 
259                                                             
260                                                             
261                                                             
262                                                                  _this.mfrom.show();
263                                                                 _this.mto.show(); 
264                                                                 _this.daypick.hide();
265                                                                  _this.dateRange = function() {
266                                                                     return {
267                                                                         date_from : _this.mfrom.getValue(),
268                                                                         date_to : _this.mto.getValue()
269                                                                     };
270                                                                 };   
271                                                                 
272                                                                 
273                                                                 break;
274                                                             /*
275                                                              case 'W': // today
276                                                                 var d = (new Date()).format('w') * -1;
277                                                                 _this.daypick.setValue( (new Date()).add(Date.DAY, d )); 
278                                                                  _this.mfrom.hide();
279                                                                 _this.mto.hide(); 
280                                                                 _this.daypick.show();
281                                                                 break;
282                                                             
283                                                             
284                                                             case 'D': // today
285                                                                 _this.daypick.setValue(new Date()); 
286                                                                  _this.mfrom.hide();
287                                                                 _this.mto.hide(); 
288                                                                 _this.daypick.show();
289                                                                 break;
290                                                                 */
291                                                             default:
292                                                                 alerT("oops invalid ftype?");
293                                                                 return;
294                                                         }
295                                                         
296                                                         
297                                                         
298                                                     }
299                                                 },
300                                                 allowBlank : false,
301                                                 displayField : 'fname',
302                                                 editable : false,
303                                                 fieldLabel : 'Status',
304                                                 hiddenName : 'cm_status',
305                                                 listWidth : 200,
306                                                 mode : 'local',
307                                                 name : 'cm_status_name',
308                                                 triggerAction : 'all',
309                                                 value : "R",
310                                                 valueField : 'ftype',
311                                                 width : 150,
312                                                 dateRange : function() {
313                                                 
314                                                   
315                                                     var ftype =  this.getValue();
316                                                     
317                                                     switch(ftype) {
318                                                         case 'Y':
319                                                        
320                                                             
321                                                             return {
322                                                                date_from : _this.mfrom.getValue(),
323                                                                 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
324                                                      
325                                                             };
326                                                        ;
327                                                            
328                                                            
329                                                             break;
330                                                         case 'H':        
331                                                         // 
332                                                                 return {
333                                                                     date_from : _this.mfrom.getValue(),
334                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
335                                                                 };
336                                                             
337                                                           break;
338                                                         case 'Q':                
339                                                         
340                                                             
341                                                  
342                                                                 return {
343                                                                     date_from : _this.mfrom.getValue(),
344                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
345                                                                 };
346                                                            
347                                                             break;
348                                                 
349                                                         case 'M':        
350                                                            
351                                                                 return {
352                                                                     date_from : _this.mfrom.getValue(),
353                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
354                                                                 };
355                                                               
356                                                                
357                                                         
358                                                 
359                                                         
360                                                         case 'R':
361                                                            
362                                                                 return {
363                                                                     date_from : _this.mfrom.getValue(),
364                                                                     date_to : _this.mto.getValue()
365                                                                 };
366                                                            
367                                                             
368                                                             break;
369                                                        
370                                                         default:
371                                                             Roo.MessageBox.alert("select range");
372                                                             return;
373                                                     }
374                                                  
375                                                 },
376                                                 store : {
377                                                     xtype: 'SimpleStore',
378                                                     xns: Roo.data,
379                                                     data : [ 
380                                                         [ 'Y', "Show Year From"],
381                                                         [ 'H' , "6 Months From"],
382                                                         [ 'Q', "3 Months From"] ,
383                                                         [ 'M', "Single Month"],
384                                                        // [ 'W', "Single Week Starting"],
385                                                         [ 'R', "Between these Dates"] //,
386                                                       //  [ 'D', "Single Day"]
387                                                         
388                                                     ],
389                                                     fields : [  'ftype', 'fname']
390                                                 }
391                                             },
392                                             {
393                                                 xtype: 'DateField',
394                                                 xns: Roo.form,
395                                                 listeners : {
396                                                     render : function (_self)
397                                                     {
398                                                         _this.mfrom=  _self;
399                                                     }
400                                                 },
401                                                 format : 'd/M/Y',
402                                                 useIso : true,
403                                                 value : (function() {
404                                                     var n = new Date();
405                                                     // previous apr.
406                                                     var y = n.format('Y');
407                                                     if (n.format('m') < 5) { 
408                                                         y--;
409                                                     }
410                                                     
411                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
412                                                 })()
413                                             },
414                                             {
415                                                 xtype: 'DateField',
416                                                 xns: Roo.form,
417                                                 listeners : {
418                                                     render : function (_self)
419                                                     {
420                                                         _this.mto=  _self;
421                                                         //this.hide();
422                                                     }
423                                                 },
424                                                 format : 'd/M/Y',
425                                                 useIso : true,
426                                                 value : (function() {
427                                                     var n = (new Date()).add(Date.YEAR, 1);
428                                                     
429                                                     var n = new Date();
430                                                     // previous apr.
431                                                     var y = n.format('Y');
432                                                     if (n.format('m') >= 5) { 
433                                                         y++;
434                                                     }
435                                                     
436                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
437                                                     
438                                                     
439                                                 
440                                                 })()
441                                             },
442                                             {
443                                                 xtype: 'DateField',
444                                                 xns: Roo.form,
445                                                 listeners : {
446                                                     render : function (_self)
447                                                     {
448                                                         _this.daypick = _self;
449                                                         this.hide();
450                                                     }
451                                                 },
452                                                 format : 'd/M/Y',
453                                                 useIso : true,
454                                                 value : (function() {
455                                                 //    var n = new Date();
456                                                     return new Date();
457                                                 })()
458                                             },
459                                             {
460                                                 xtype: 'Button',
461                                                 xns: Roo.Toolbar,
462                                                 listeners : {
463                                                     click : function (_self, e)
464                                                     {
465                                                         Pman.Xtuple.DashboardRender.load();
466                                                     }
467                                                 },
468                                                 text : "Run Report"
469                                             },
470                                             {
471                                                 xtype: 'Button',
472                                                 xns: Roo.Toolbar,
473                                                 text : "Other Reports",
474                                                 menu : {
475                                                     xtype: 'Menu',
476                                                     xns: Roo.menu,
477                                                     items : [
478                                                         {
479                                                             xtype: 'Item',
480                                                             xns: Roo.menu,
481                                                             listeners : {
482                                                                 click : function (_self, e)
483                                                                 {
484                                                                     new Pman.Download({
485                                                                         url :baseURL + '/Xtuple/Reports/SalesByCustomer',
486                                                                         params : _this.viewType.dateRange()
487                                                                          
488                                                                     
489                                                                     });
490                                                                 }
491                                                             },
492                                                             text : "Sales By Customer"
493                                                         },
494                                                         {
495                                                             xtype: 'Item',
496                                                             xns: Roo.menu,
497                                                             listeners : {
498                                                                 click : function (_self, e)
499                                                                 {
500                                                                     new Pman.Download({
501                                                                         url :baseURL + '/Xtuple/Reports/SalesByCountry',
502                                                                         params :  _this.viewType.dateRange()
503                                                                     
504                                                                     });
505                                                                 }
506                                                             },
507                                                             text : "Sales By Country"
508                                                         },
509                                                         {
510                                                             xtype: 'Item',
511                                                             xns: Roo.menu,
512                                                             listeners : {
513                                                                 click : function (_self, e)
514                                                                 {
515                                                                     new Pman.Download({
516                                                                         url :baseURL + '/Xtuple/Reports/SalesByProduct',
517                                                                         params :  _this.viewType.dateRange()
518                                                                     
519                                                                     });
520                                                                 }
521                                                             },
522                                                             text : "Sales By Product"
523                                                         },
524                                                         {
525                                                             xtype: 'Separator',
526                                                             xns: Roo.menu
527                                                         },
528                                                         {
529                                                             xtype: 'Item',
530                                                             xns: Roo.menu,
531                                                             listeners : {
532                                                                 click : function (_self, e)
533                                                                 {
534                                                                     new Pman.Download({
535                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
536                                                                         params :  _this.viewType.dateRange()
537                                                                     
538                                                                     });
539                                                                 }
540                                                             },
541                                                             text : "Purchases By Vendor"
542                                                         },
543                                                         {
544                                                             xtype: 'Item',
545                                                             xns: Roo.menu,
546                                                             listeners : {
547                                                                 click : function (_self, e)
548                                                                 {
549                                                                     new Pman.Download({
550                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
551                                                                         params :  _this.viewType.dateRange()
552                                                                     
553                                                                     });
554                                                                 }
555                                                             },
556                                                             text : "Purchases By Product"
557                                                         },
558                                                         {
559                                                             xtype: 'Separator',
560                                                             xns: Roo.menu
561                                                         },
562                                                         {
563                                                             xtype: 'Item',
564                                                             xns: Roo.menu,
565                                                             listeners : {
566                                                                 click : function (_self, e)
567                                                                 {
568                                                                     new Pman.Download({
569                                                                         url :baseURL + '/Xtuple/Reports/StockAtLocation',
570                                                                          params :  _this.viewType.dateRange()
571                                                                     
572                                                                     });
573                                                                     Roo.MessageBox.alert("Downloading", 
574                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
575                                                                     
576                                                                 }
577                                                             },
578                                                             text : "Historical Stock Levels (EO HKFY)"
579                                                         },
580                                                         {
581                                                             xtype: 'Separator',
582                                                             xns: Roo.menu
583                                                         },
584                                                         {
585                                                             xtype: 'Item',
586                                                             xns: Roo.menu,
587                                                             listeners : {
588                                                                 click : function (_self, e)
589                                                                 {
590                                                                     new Pman.Download({
591                                                                         url :baseURL + '/Xtuple/Reports/SGTax',
592                                                                          params :  _this.viewType.dateRange()
593                                                                     
594                                                                     });
595                                                                     Roo.MessageBox.alert("Downloading", 
596                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
597                                                                     
598                                                                 }
599                                                             },
600                                                             text : "SG Tax report"
601                                                         }
602                                                     ]
603                                                 }
604                                             },
605                                             {
606                                                 xtype: 'Spacer',
607                                                 xns: Roo.Toolbar
608                                             },
609                                             {
610                                                 xtype: 'Fill',
611                                                 xns: Roo.Toolbar
612                                             },
613                                             {
614                                                 xtype: 'TextItem',
615                                                 xns: Roo.Toolbar,
616                                                 text : "Theme : "
617                                             },
618                                             {
619                                                 xtype: 'ComboBox',
620                                                 xns: Roo.form,
621                                                 listeners : {
622                                                     select : function (combo, record, index)
623                                                     {
624                                                         Pman.Xtuple.DashboardRender.load();
625                                                     },
626                                                     render : function (_self)
627                                                     {
628                                                         _this.themeCombo = this;
629                                                     }
630                                                 },
631                                                 allowBlank : false,
632                                                 displayField : 'name',
633                                                 editable : false,
634                                                 hiddenName : 'colortheme',
635                                                 listWidth : 300,
636                                                 name : 'colorTheme_title',
637                                                 qtip : "Select a Color Theme",
638                                                 selectOnFocus : true,
639                                                 triggerAction : 'all',
640                                                 typeAhead : false,
641                                                 valueField : 'themeData',
642                                                 value : (function() {
643                                                      return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : ''; 
644                                                 })(),
645                                                 store : {
646                                                     xtype: 'SimpleStore',
647                                                     xns: Roo.data,
648                                                     data : (function() {
649                                                         return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
650                                                         
651                                                     })(),
652                                                     fields : ['name','themeData']
653                                                 }
654                                             }
655                                         ]
656                                     }
657                                 },
658                                 {
659                                     xtype: 'ContentPanel',
660                                     xns: Roo,
661                                     listeners : {
662                                         render : function (_self)
663                                         {
664                                             _this.reportpanel = _self;
665                                         }
666                                     },
667                                     autoScroll : true,
668                                     fitToFrame : true,
669                                     region : 'center',
670                                     showReport : function(node, isxls) {
671                                         if (node) {
672                                             _this.selectedNode = node;
673                                         }
674                                         var rc = _this.reportCompany.getValue();
675                                         var params =  {
676                                             flhead_name : _this.selectedNode.attributes.text,
677                                             ts : Math.random(),
678                                             period : _this.reportDateFrom.getValue(),
679                                             interval:   _this.reportInterval.getValue(),
680                                             company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
681                                             singleCountry :  rc == 'consolidated' ? 0 : 1
682                                         };
683                                         
684                                         if (isxls) {
685                                             params._xls = 1;
686                                             new Pman.Download({
687                                                 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
688                                                 method: 'GET',
689                                                 timeout: 120000,
690                                                 params :  params
691                                             });
692                                             Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
693                                             return;
694                                         }
695                                         var el = this.region.el;
696                                     
697                                         var done = false;
698                                         var v= 0;
699                                         var f = function(){
700                                                 if (done) {
701                                                     return;
702                                                 }
703                                                 Roo.MessageBox.updateProgress(v/50, 'Loading..  Around ' + (50-v) + ' seconds to go');
704                                                 v++;
705                                                 f.defer(1000)
706                                            };
707                                          Roo.MessageBox.show({
708                                                title: 'Please wait...',
709                                                msg: 'Loading...',
710                                                width:240,
711                                                progress:true,
712                                                closable:true
713                                            });
714                                         
715                                     
716                                         
717                                         ///el.mask("Loading - Should take around 45 seconds <br/> if it takes longer than 2 minutes, then something is broken<br/> If nothing displays try doing shift-reload or ctrl-reload");
718                                         this.load({
719                                             url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
720                                             method: 'GET',
721                                             params :  params,
722                                             timeout: 120,
723                                             callback: function() {
724                                                 done = true;
725                                                 Roo.MessageBox.hide();
726                                             }
727                                             
728                                         });
729                                         
730                                         f();
731                                         
732                                     },
733                                     toolbar : {
734                                         xtype: 'Toolbar',
735                                         xns: Roo,
736                                         items : [
737                                             {
738                                                 xtype: 'TextItem',
739                                                 xns: Roo.Toolbar,
740                                                 text : "Report Range :"
741                                             },
742                                             {
743                                                 xtype: 'DateField',
744                                                 xns: Roo.form,
745                                                 listeners : {
746                                                     render : function (_self)
747                                                     {
748                                                         _this.reportDateFrom = _self;
749                                                     },
750                                                     select : function (combo, date)
751                                                     {
752                                                       //_this.grid.footer.onClick('first');
753                                                     }
754                                                 },
755                                                 format : 'd/M/Y',
756                                                 useIso : 1,
757                                                 width : 120,
758                                                 value : (function() { 
759                                                     return Date.parseDate( 
760                                                         '' + (new Date()).format('Y-m') + '-01'
761                                                         , 'Y-m-d'   ); })()
762                                             },
763                                             {
764                                                 xtype: 'ComboBox',
765                                                 xns: Roo.form,
766                                                 listeners : {
767                                                     render : function (_self)
768                                                     {
769                                                       _this.reportInterval = _self;
770                                                     },
771                                                     select : function (combo, record, index)
772                                                     {
773                                                        // Roo.log('select');
774                                                        // _this.grid.footer.onClick('first');
775                                                     }
776                                                 },
777                                                 allowBlank : false,
778                                                 displayField : 'fname',
779                                                 editable : false,
780                                                 fieldLabel : 'Status',
781                                                 hiddenName : 'cm_status',
782                                                 listWidth : 400,
783                                                 mode : 'local',
784                                                 name : 'cm_status_name',
785                                                 triggerAction : 'all',
786                                                 value : "Y",
787                                                 valueField : 'ftype',
788                                                 width : 200,
789                                                 store : {
790                                                     xtype: 'SimpleStore',
791                                                     xns: Roo.data,
792                                                     data : [ 
793                                                         [ 'Y', "Since Start of Financial Year"],
794                                                         [ 'YY' , "Since Start of Financial Year with same range Previous Year"],            
795                                                         [ 'M' , "Single Month"],
796                                                         [ 'MM' , "Single Month with Previous Month"],    
797                                                         [ 'MY' , "Single Month with Previous Year"],
798                                                         [ 'MF' , "This Months of Financia Year"],
799                                                         [ 'ML' , "Last 12 Months"]
800                                                     ],
801                                                     fields : [  'ftype', 'fname']
802                                                 }
803                                             },
804                                             {
805                                                 xtype: 'ComboBox',
806                                                 xns: Roo.form,
807                                                 listeners : {
808                                                     render : function (_self)
809                                                     {
810                                                       _this.reportCompany = _self;
811                                                     }
812                                                 },
813                                                 allowBlank : false,
814                                                 displayField : 'fname',
815                                                 editable : false,
816                                                 fieldLabel : 'Status',
817                                                 hiddenName : 'report_company',
818                                                 listWidth : 300,
819                                                 mode : 'local',
820                                                 name : 'report_company_name',
821                                                 triggerAction : 'all',
822                                                 value : "hk",
823                                                 valueField : 'ftype',
824                                                 width : 100,
825                                                 hidden : (function() {
826                                                 
827                                                     return baseURL.match(/hk\.php$/) ? false : true;
828                                                 })(),
829                                                 store : {
830                                                     xtype: 'SimpleStore',
831                                                     xns: Roo.data,
832                                                     data : [ 
833                                                         [ 'hk', "Hong Kong"],
834                                                         [ 'sg' , "Singapore"],            
835                                                         [ 'my' , "Malaysia"],
836                                                         [ 'cn' , "China"],    
837                                                         [ 'au' , "Australia"],
838                                                         [ 'consolidated' , "Consolidated"]
839                                                     ],
840                                                     fields : [  'ftype', 'fname']
841                                                 }
842                                             },
843                                             {
844                                                 xtype: 'Button',
845                                                 xns: Roo.Toolbar,
846                                                 listeners : {
847                                                     click : function (_self, e)
848                                                     {
849                                                           _this.reportpanel.showReport(); 
850                                                     }
851                                                 },
852                                                 text : "Refresh Report"
853                                             },
854                                             {
855                                                 xtype: 'Fill',
856                                                 xns: Roo.Toolbar
857                                             },
858                                             {
859                                                 xtype: 'Button',
860                                                 xns: Roo.Toolbar,
861                                                 listeners : {
862                                                     click : function (_self, e)
863                                                     {
864                                                           _this.reportpanel.showReport(false,'xls'); 
865                                                     }
866                                                 },
867                                                 text : "Download XLS"
868                                             }
869                                         ]
870                                     }
871                                 }
872                             ],
873                             center : {
874                                 xtype: 'LayoutRegion',
875                                 xns: Roo,
876                                 hideTabs : true
877                             }
878                         }
879                     },
880                     {
881                         xtype: 'TreePanel',
882                         xns: Roo,
883                         listeners : {
884                             render : function (_self)
885                             {
886                                 _this.tree = _self;
887                             }
888                         },
889                         fitToFrame : true,
890                         region : 'west',
891                         toolbar : {
892                             xtype: 'Toolbar',
893                             xns: Roo
894                         },
895                         tree : {
896                             xtype: 'TreePanel',
897                             xns: Roo.tree,
898                             rootVisible : false,
899                             root : {
900                                 xtype: 'AsyncTreeNode',
901                                 xns: Roo.tree
902                             },
903                             selModel : {
904                                 xtype: 'DefaultSelectionModel',
905                                 xns: Roo.tree,
906                                 listeners : {
907                                     selectionchange : function (_self, node)
908                                     {
909                                         var at = node.attributes.id;
910                                         if (at > 999) {
911                                              _this.dashpanel.layout.getRegion('center').showPanel(0);
912                                               Pman.Xtuple.DashboardRender.load();
913                                               return;
914                                              
915                                         }
916                                         _this.dashpanel.layout.getRegion('center').showPanel(1);
917                                         _this.reportpanel.showReport(node); 
918                                        
919                                         
920                                     }
921                                 }
922                             },
923                             loader : {
924                                 xtype: 'TreeLoader',
925                                 xns: Roo.tree,
926                                 requestMethod : 'GET',
927                                 baseParams : { _tree : 1, _dragon_only : 1 },
928                                 dataUrl : baseURL + '/Roo/Flhead'
929                             },
930                             root : {
931                                 xtype: 'AsyncTreeNode',
932                                 xns: Roo.tree
933                             }
934                         }
935                     }
936                 ],
937                 west : {
938                     xtype: 'LayoutRegion',
939                     xns: Roo,
940                     hidden : false,
941                     split : true,
942                     width : 200
943                 },
944                 center : {
945                     xtype: 'LayoutRegion',
946                     xns: Roo
947                 }
948             }
949         };
950     }
951 });