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                                                        _this.dateRange = function() {
176                                                                     return {
177                                                                        date_from : _this.mfrom.getValue(),
178                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
179                                                              
180                                                                     };
181                                                                
182                                                                };
183                                                     },
184                                                     select : function (combo, record, index)
185                                                     {
186                                                         Roo.log('select');
187                                                        // Pman.Clipping.DashboardRender.load();
188                                                         var n = new Date();
189                                                         var ys = n.format('Y' )+ '-05-01';
190                                                         n = Date.parseDate(ys, 'Y-n-d');
191                                                         
192                                                         var ftype = record ? record.data.ftype : this.getValue();
193                                                         
194                                                         switch(ftype) {
195                                                             case 'Y':
196                                                                 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
197                                                                _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
198                                                                _this.mfrom.show();
199                                                                _this.mto.hide(); 
200                                                                _this.daypick.hide();
201                                                                
202                                                                _this.dateRange = function() {
203                                                                     return {
204                                                                        date_from : _this.mfrom.getValue(),
205                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
206                                                              
207                                                                     };
208                                                                
209                                                                };
210                                                                
211                                                                
212                                                                 break;
213                                                             case 'H':        
214                                                             // ?? latest half
215                                                                 var m = (new Date()).format('n')*1  > 6 ? 6 : 0;
216                                                                 Roo.log(m);
217                                                                 Roo.log( n.add(Date.MONTH,m));
218                                                                _this.mfrom.setValue(n.add(Date.MONTH,m));           
219                                                                _this.mfrom.show();
220                                                                _this.mto.hide(); 
221                                                                _this.daypick.hide();
222                                                                _this.dateRange = function() {
223                                                                     return {
224                                                                         date_from : _this.mfrom.getValue(),
225                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
226                                                                     };
227                                                                };
228                                                               break;
229                                                             case 'Q':                
230                                                             
231                                                                 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
232                                                     
233                                                                _this.mfrom.setValue(n.add(Date.MONTH, m));           
234                                                                _this.mfrom.show();
235                                                                _this.mto.hide(); 
236                                                                _this.daypick.hide();
237                                                                _this.dateRange = function() {
238                                                                     return {
239                                                                         date_from : _this.mfrom.getValue(),
240                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
241                                                                     };
242                                                                 };   
243                                                                 break;
244                                                     
245                                                             case 'M':        
246                                                                 var m = (new Date()).format('n') *1  - 1 ;
247                                                                _this.mfrom.setValue(n.add(Date.MONTH, m ));
248                                                                _this.mfrom.show();
249                                                                _this.mto.hide(); 
250                                                                _this.daypick.hide();
251                                                                 _this.dateRange = function() {
252                                                                     return {
253                                                                         date_from : _this.mfrom.getValue(),
254                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
255                                                                     };
256                                                                 };   
257                                                                 break;        
258                                                             
259                                                     
260                                                             
261                                                             case 'R':
262                                                                 // this month..
263                                                                 var m = (new Date()).format('n') * 1;            
264                                                                _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); 
265                                                                _this.mto.setValue(n.add(Date.MONTH,m )); 
266                                                             
267                                                             
268                                                             
269                                                                  _this.mfrom.show();
270                                                                 _this.mto.show(); 
271                                                                 _this.daypick.hide();
272                                                                  _this.dateRange = function() {
273                                                                     return {
274                                                                         date_from : _this.mfrom.getValue(),
275                                                                         date_to : _this.mto.getValue()
276                                                                     };
277                                                                 };   
278                                                                 
279                                                                 
280                                                                 break;
281                                                             /*
282                                                              case 'W': // today
283                                                                 var d = (new Date()).format('w') * -1;
284                                                                 _this.daypick.setValue( (new Date()).add(Date.DAY, d )); 
285                                                                  _this.mfrom.hide();
286                                                                 _this.mto.hide(); 
287                                                                 _this.daypick.show();
288                                                                 break;
289                                                             
290                                                             
291                                                             case 'D': // today
292                                                                 _this.daypick.setValue(new Date()); 
293                                                                  _this.mfrom.hide();
294                                                                 _this.mto.hide(); 
295                                                                 _this.daypick.show();
296                                                                 break;
297                                                                 */
298                                                             default:
299                                                                 alerT("oops invalid ftype?");
300                                                                 return;
301                                                         }
302                                                         
303                                                         
304                                                         
305                                                     }
306                                                 },
307                                                 allowBlank : false,
308                                                 displayField : 'fname',
309                                                 editable : false,
310                                                 fieldLabel : 'Status',
311                                                 hiddenName : 'cm_status',
312                                                 listWidth : 200,
313                                                 mode : 'local',
314                                                 name : 'cm_status_name',
315                                                 triggerAction : 'all',
316                                                 value : "R",
317                                                 valueField : 'ftype',
318                                                 width : 150,
319                                                 dateRange : function() {
320                                                     return {
321                                                                    date_from : _this.mfrom.getValue(),
322                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
323                                                          
324                                                                 };
325                                                 },
326                                                 store : {
327                                                     xtype: 'SimpleStore',
328                                                     xns: Roo.data,
329                                                     data : [ 
330                                                         [ 'Y', "Show Year From"],
331                                                         [ 'H' , "6 Months From"],
332                                                         [ 'Q', "3 Months From"] ,
333                                                         [ 'M', "Single Month"],
334                                                        // [ 'W', "Single Week Starting"],
335                                                         [ 'R', "Between these Dates"] //,
336                                                       //  [ 'D', "Single Day"]
337                                                         
338                                                     ],
339                                                     fields : [  'ftype', 'fname']
340                                                 }
341                                             },
342                                             {
343                                                 xtype: 'DateField',
344                                                 xns: Roo.form,
345                                                 listeners : {
346                                                     render : function (_self)
347                                                     {
348                                                         _this.mfrom=  _self;
349                                                     }
350                                                 },
351                                                 format : 'd/M/Y',
352                                                 useIso : true,
353                                                 value : (function() {
354                                                     var n = new Date();
355                                                     // previous apr.
356                                                     var y = n.format('Y');
357                                                     if (n.format('m') < 5) { 
358                                                         y--;
359                                                     }
360                                                     
361                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
362                                                 })()
363                                             },
364                                             {
365                                                 xtype: 'DateField',
366                                                 xns: Roo.form,
367                                                 listeners : {
368                                                     render : function (_self)
369                                                     {
370                                                         _this.mto=  _self;
371                                                         //this.hide();
372                                                     }
373                                                 },
374                                                 format : 'd/M/Y',
375                                                 useIso : true,
376                                                 value : (function() {
377                                                     var n = (new Date()).add(Date.YEAR, 1);
378                                                     
379                                                     var n = new Date();
380                                                     // previous apr.
381                                                     var y = n.format('Y');
382                                                     if (n.format('m') >= 5) { 
383                                                         y++;
384                                                     }
385                                                     
386                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
387                                                     
388                                                     
389                                                 
390                                                 })()
391                                             },
392                                             {
393                                                 xtype: 'DateField',
394                                                 xns: Roo.form,
395                                                 listeners : {
396                                                     render : function (_self)
397                                                     {
398                                                         _this.daypick = _self;
399                                                         this.hide();
400                                                     }
401                                                 },
402                                                 format : 'd/M/Y',
403                                                 useIso : true,
404                                                 value : (function() {
405                                                 //    var n = new Date();
406                                                     return new Date();
407                                                 })()
408                                             },
409                                             {
410                                                 xtype: 'Button',
411                                                 xns: Roo.Toolbar,
412                                                 listeners : {
413                                                     click : function (_self, e)
414                                                     {
415                                                         Pman.Xtuple.DashboardRender.load();
416                                                     }
417                                                 },
418                                                 text : "Run Report"
419                                             },
420                                             {
421                                                 xtype: 'Button',
422                                                 xns: Roo.Toolbar,
423                                                 text : "Other Reports",
424                                                 menu : {
425                                                     xtype: 'Menu',
426                                                     xns: Roo.menu,
427                                                     items : [
428                                                         {
429                                                             xtype: 'Item',
430                                                             xns: Roo.menu,
431                                                             listeners : {
432                                                                 click : function (_self, e)
433                                                                 {
434                                                                     new Pman.Download({
435                                                                         url :baseURL + '/Xtuple/Reports/SalesByCustomer',
436                                                                         params : _this.dateRange()
437                                                                          
438                                                                     
439                                                                     });
440                                                                 }
441                                                             },
442                                                             text : "Sales By Customer"
443                                                         },
444                                                         {
445                                                             xtype: 'Item',
446                                                             xns: Roo.menu,
447                                                             listeners : {
448                                                                 click : function (_self, e)
449                                                                 {
450                                                                     new Pman.Download({
451                                                                         url :baseURL + '/Xtuple/Reports/SalesByCountry',
452                                                                         params :  _this.dateRange()
453                                                                     
454                                                                     });
455                                                                 }
456                                                             },
457                                                             text : "Sales By Country"
458                                                         },
459                                                         {
460                                                             xtype: 'Item',
461                                                             xns: Roo.menu,
462                                                             listeners : {
463                                                                 click : function (_self, e)
464                                                                 {
465                                                                     new Pman.Download({
466                                                                         url :baseURL + '/Xtuple/Reports/SalesByProduct',
467                                                                         params :  _this.dateRange()
468                                                                     
469                                                                     });
470                                                                 }
471                                                             },
472                                                             text : "Sales By Product"
473                                                         },
474                                                         {
475                                                             xtype: 'Separator',
476                                                             xns: Roo.menu
477                                                         },
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/PurchasesByVendor',
486                                                                         params :  _this.dateRange()
487                                                                     
488                                                                     });
489                                                                 }
490                                                             },
491                                                             text : "Purchases By Vendor"
492                                                         },
493                                                         {
494                                                             xtype: 'Item',
495                                                             xns: Roo.menu,
496                                                             listeners : {
497                                                                 click : function (_self, e)
498                                                                 {
499                                                                     new Pman.Download({
500                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
501                                                                         params :  _this.dateRange()
502                                                                     
503                                                                     });
504                                                                 }
505                                                             },
506                                                             text : "Purchases By Product"
507                                                         },
508                                                         {
509                                                             xtype: 'Separator',
510                                                             xns: Roo.menu
511                                                         },
512                                                         {
513                                                             xtype: 'Item',
514                                                             xns: Roo.menu,
515                                                             listeners : {
516                                                                 click : function (_self, e)
517                                                                 {
518                                                                     new Pman.Download({
519                                                                         url :baseURL + '/Xtuple/Reports/StockAtLocation',
520                                                                          params :  _this.dateRange()
521                                                                     
522                                                                     });
523                                                                     Roo.MessageBox.alert("Downloading", 
524                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
525                                                                     
526                                                                 }
527                                                             },
528                                                             text : "Historical Stock Levels (EO HKFY)"
529                                                         },
530                                                         {
531                                                             xtype: 'Separator',
532                                                             xns: Roo.menu
533                                                         },
534                                                         {
535                                                             xtype: 'Item',
536                                                             xns: Roo.menu,
537                                                             listeners : {
538                                                                 click : function (_self, e)
539                                                                 {
540                                                                     new Pman.Download({
541                                                                         url :baseURL + '/Xtuple/Reports/SGTax',
542                                                                          params :  _this.dateRange()
543                                                                     
544                                                                     });
545                                                                     Roo.MessageBox.alert("Downloading", 
546                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
547                                                                     
548                                                                 }
549                                                             },
550                                                             text : "SG Tax report"
551                                                         }
552                                                     ]
553                                                 }
554                                             },
555                                             {
556                                                 xtype: 'Spacer',
557                                                 xns: Roo.Toolbar
558                                             },
559                                             {
560                                                 xtype: 'Fill',
561                                                 xns: Roo.Toolbar
562                                             },
563                                             {
564                                                 xtype: 'TextItem',
565                                                 xns: Roo.Toolbar,
566                                                 text : "Theme : "
567                                             },
568                                             {
569                                                 xtype: 'ComboBox',
570                                                 xns: Roo.form,
571                                                 listeners : {
572                                                     select : function (combo, record, index)
573                                                     {
574                                                         Pman.Xtuple.DashboardRender.load();
575                                                     },
576                                                     render : function (_self)
577                                                     {
578                                                         _this.themeCombo = this;
579                                                     }
580                                                 },
581                                                 allowBlank : false,
582                                                 displayField : 'name',
583                                                 editable : false,
584                                                 hiddenName : 'colortheme',
585                                                 listWidth : 300,
586                                                 name : 'colorTheme_title',
587                                                 qtip : "Select a Color Theme",
588                                                 selectOnFocus : true,
589                                                 triggerAction : 'all',
590                                                 typeAhead : false,
591                                                 valueField : 'themeData',
592                                                 value : (function() {
593                                                      return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : ''; 
594                                                 })(),
595                                                 store : {
596                                                     xtype: 'SimpleStore',
597                                                     xns: Roo.data,
598                                                     data : (function() {
599                                                         return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
600                                                         
601                                                     })(),
602                                                     fields : ['name','themeData']
603                                                 }
604                                             }
605                                         ]
606                                     }
607                                 },
608                                 {
609                                     xtype: 'ContentPanel',
610                                     xns: Roo,
611                                     listeners : {
612                                         render : function (_self)
613                                         {
614                                             _this.reportpanel = _self;
615                                         }
616                                     },
617                                     autoScroll : true,
618                                     fitToFrame : true,
619                                     region : 'center',
620                                     showReport : function(node, isxls) {
621                                         if (node) {
622                                             _this.selectedNode = node;
623                                         }
624                                         var rc = _this.reportCompany.getValue();
625                                         var params =  {
626                                             flhead_name : _this.selectedNode.attributes.text,
627                                             ts : Math.random(),
628                                             period : _this.reportDateFrom.getValue(),
629                                             interval:   _this.reportInterval.getValue(),
630                                             company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
631                                             singleCountry :  rc == 'consolidated' ? 0 : 1
632                                         };
633                                         
634                                         if (isxls) {
635                                             params._xls = 1;
636                                             new Pman.Download({
637                                                 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
638                                                 method: 'GET',
639                                                 timeout: 120000,
640                                                 params :  params
641                                             });
642                                             Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
643                                             return;
644                                         }
645                                         var el = this.region.el;
646                                     
647                                         var done = false;
648                                         var v= 0;
649                                         var f = function(){
650                                                 if (done) {
651                                                     return;
652                                                 }
653                                                 Roo.MessageBox.updateProgress(v/50, 'Loading..  Around ' + (50-v) + ' seconds to go');
654                                                 v++;
655                                                 f.defer(1000)
656                                            };
657                                          Roo.MessageBox.show({
658                                                title: 'Please wait...',
659                                                msg: 'Loading...',
660                                                width:240,
661                                                progress:true,
662                                                closable:true
663                                            });
664                                         
665                                     
666                                         
667                                         ///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");
668                                         this.load({
669                                             url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
670                                             method: 'GET',
671                                             params :  params,
672                                             timeout: 120,
673                                             callback: function() {
674                                                 done = true;
675                                                 Roo.MessageBox.hide();
676                                             }
677                                             
678                                         });
679                                         
680                                         f();
681                                         
682                                     },
683                                     toolbar : {
684                                         xtype: 'Toolbar',
685                                         xns: Roo,
686                                         items : [
687                                             {
688                                                 xtype: 'TextItem',
689                                                 xns: Roo.Toolbar,
690                                                 text : "Report Range :"
691                                             },
692                                             {
693                                                 xtype: 'DateField',
694                                                 xns: Roo.form,
695                                                 listeners : {
696                                                     render : function (_self)
697                                                     {
698                                                         _this.reportDateFrom = _self;
699                                                     },
700                                                     select : function (combo, date)
701                                                     {
702                                                       //_this.grid.footer.onClick('first');
703                                                     }
704                                                 },
705                                                 format : 'd/M/Y',
706                                                 useIso : 1,
707                                                 width : 120,
708                                                 value : (function() { 
709                                                     return Date.parseDate( 
710                                                         '' + (new Date()).format('Y-m') + '-01'
711                                                         , 'Y-m-d'   ); })()
712                                             },
713                                             {
714                                                 xtype: 'ComboBox',
715                                                 xns: Roo.form,
716                                                 listeners : {
717                                                     render : function (_self)
718                                                     {
719                                                       _this.reportInterval = _self;
720                                                     },
721                                                     select : function (combo, record, index)
722                                                     {
723                                                        // Roo.log('select');
724                                                        // _this.grid.footer.onClick('first');
725                                                     }
726                                                 },
727                                                 allowBlank : false,
728                                                 displayField : 'fname',
729                                                 editable : false,
730                                                 fieldLabel : 'Status',
731                                                 hiddenName : 'cm_status',
732                                                 listWidth : 400,
733                                                 mode : 'local',
734                                                 name : 'cm_status_name',
735                                                 triggerAction : 'all',
736                                                 value : "Y",
737                                                 valueField : 'ftype',
738                                                 width : 200,
739                                                 store : {
740                                                     xtype: 'SimpleStore',
741                                                     xns: Roo.data,
742                                                     data : [ 
743                                                         [ 'Y', "Since Start of Financial Year"],
744                                                         [ 'YY' , "Since Start of Financial Year with same range Previous Year"],            
745                                                         [ 'M' , "Single Month"],
746                                                         [ 'MM' , "Single Month with Previous Month"],    
747                                                         [ 'MY' , "Single Month with Previous Year"],
748                                                         [ 'MF' , "This Months of Financia Year"],
749                                                         [ 'ML' , "Last 12 Months"]
750                                                     ],
751                                                     fields : [  'ftype', 'fname']
752                                                 }
753                                             },
754                                             {
755                                                 xtype: 'ComboBox',
756                                                 xns: Roo.form,
757                                                 listeners : {
758                                                     render : function (_self)
759                                                     {
760                                                       _this.reportCompany = _self;
761                                                     }
762                                                 },
763                                                 allowBlank : false,
764                                                 displayField : 'fname',
765                                                 editable : false,
766                                                 fieldLabel : 'Status',
767                                                 hiddenName : 'report_company',
768                                                 listWidth : 300,
769                                                 mode : 'local',
770                                                 name : 'report_company_name',
771                                                 triggerAction : 'all',
772                                                 value : "hk",
773                                                 valueField : 'ftype',
774                                                 width : 100,
775                                                 hidden : (function() {
776                                                 
777                                                     return baseURL.match(/hk\.php$/) ? false : true;
778                                                 })(),
779                                                 store : {
780                                                     xtype: 'SimpleStore',
781                                                     xns: Roo.data,
782                                                     data : [ 
783                                                         [ 'hk', "Hong Kong"],
784                                                         [ 'sg' , "Singapore"],            
785                                                         [ 'my' , "Malaysia"],
786                                                         [ 'cn' , "China"],    
787                                                         [ 'au' , "Australia"],
788                                                         [ 'consolidated' , "Consolidated"]
789                                                     ],
790                                                     fields : [  'ftype', 'fname']
791                                                 }
792                                             },
793                                             {
794                                                 xtype: 'Button',
795                                                 xns: Roo.Toolbar,
796                                                 listeners : {
797                                                     click : function (_self, e)
798                                                     {
799                                                           _this.reportpanel.showReport(); 
800                                                     }
801                                                 },
802                                                 text : "Refresh Report"
803                                             },
804                                             {
805                                                 xtype: 'Fill',
806                                                 xns: Roo.Toolbar
807                                             },
808                                             {
809                                                 xtype: 'Button',
810                                                 xns: Roo.Toolbar,
811                                                 listeners : {
812                                                     click : function (_self, e)
813                                                     {
814                                                           _this.reportpanel.showReport(false,'xls'); 
815                                                     }
816                                                 },
817                                                 text : "Download XLS"
818                                             }
819                                         ]
820                                     }
821                                 }
822                             ],
823                             center : {
824                                 xtype: 'LayoutRegion',
825                                 xns: Roo,
826                                 hideTabs : true
827                             }
828                         }
829                     },
830                     {
831                         xtype: 'TreePanel',
832                         xns: Roo,
833                         listeners : {
834                             render : function (_self)
835                             {
836                                 _this.tree = _self;
837                             }
838                         },
839                         fitToFrame : true,
840                         region : 'west',
841                         toolbar : {
842                             xtype: 'Toolbar',
843                             xns: Roo
844                         },
845                         tree : {
846                             xtype: 'TreePanel',
847                             xns: Roo.tree,
848                             rootVisible : false,
849                             root : {
850                                 xtype: 'AsyncTreeNode',
851                                 xns: Roo.tree
852                             },
853                             selModel : {
854                                 xtype: 'DefaultSelectionModel',
855                                 xns: Roo.tree,
856                                 listeners : {
857                                     selectionchange : function (_self, node)
858                                     {
859                                         var at = node.attributes.id;
860                                         if (at > 999) {
861                                              _this.dashpanel.layout.getRegion('center').showPanel(0);
862                                               Pman.Xtuple.DashboardRender.load();
863                                               return;
864                                              
865                                         }
866                                         _this.dashpanel.layout.getRegion('center').showPanel(1);
867                                         _this.reportpanel.showReport(node); 
868                                        
869                                         
870                                     }
871                                 }
872                             },
873                             loader : {
874                                 xtype: 'TreeLoader',
875                                 xns: Roo.tree,
876                                 requestMethod : 'GET',
877                                 baseParams : { _tree : 1, _dragon_only : 1 },
878                                 dataUrl : baseURL + '/Roo/Flhead'
879                             },
880                             root : {
881                                 xtype: 'AsyncTreeNode',
882                                 xns: Roo.tree
883                             }
884                         }
885                     }
886                 ],
887                 west : {
888                     xtype: 'LayoutRegion',
889                     xns: Roo,
890                     hidden : false,
891                     split : true,
892                     width : 200
893                 },
894                 center : {
895                     xtype: 'LayoutRegion',
896                     xns: Roo
897                 }
898             }
899         };
900     }
901 });