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