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