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