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