1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleDashboard = new Roo.XComponent({
6 part : ["Xtuple","Dashboard"],
7 order : '001-Pman.Tab.XtupleDashboard',
10 name : "Pman.Tab.XtupleDashboard",
18 xtype: 'NestedLayoutPanel',
21 activate : function (_self)
25 // Pman.Xtuple.DashboardRender.load();
33 title : "Management Dashboard",
35 xtype: 'BorderLayout',
39 xtype: 'NestedLayoutPanel',
42 render : function (_self)
44 _this.dashpanel = _self;
48 this.layout.getRegion('center').showPanel(0);
54 xtype: 'BorderLayout',
58 xtype: 'ContentPanel',
61 render : function (_self)
63 _this.viewPanel = _self;
66 //_this.paper = Raphael(_self.el.dom);
74 resize : function (_self, width, height)
78 /* _this.svg.attr("width", width)
79 .attr("height", height);
81 // _this.paper.setSize(width, 400);
83 Pman.Clipping.DashboardRender.resize(width,height);
91 activate : function (_self)
93 if (!_this.loadonce) {
94 _this.loadonce = true;
96 (function () { Pman.Xtuple.DashboardRender.load(); }).defer(1000);
117 render : function (_self)
119 _this.countryCombo= _self;
123 displayField : 'addr_country',
125 emptyText : " Country",
126 forceSelection : true,
128 loadingText : "Searching...",
130 name : 'addr_country',
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',
142 beforeload : function (_self, o){
143 o.params = o.params || {};
145 o.params._distinct = 'addr_country';
146 o.params._columns = 'addr_country';
147 o.params['!addr_country'] = '';
151 sortInfo : { direction : 'ASC', field: 'addr_country' },
156 url : baseURL + '/Roo/addr.php'
163 totalProperty : 'total',
164 fields : [{"name":"id","type":"int"},{"name":"addr_line1","type":"string"}]
172 render : function (_self)
174 _this.viewType = _self;
177 select : function (combo, record, index)
180 // Pman.Clipping.DashboardRender.load();
182 var ys = n.format('Y' )+ '-05-01';
183 n = Date.parseDate(ys, 'Y-n-d');
185 var ftype = record ? record.data.ftype : this.getValue();
189 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
190 _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
193 _this.daypick.hide();
195 _this.dateRange = function() {
197 date_from : _this.mfrom.getValue(),
198 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
208 var m = (new Date()).format('n')*1 > 6 ? 6 : 0;
210 Roo.log( n.add(Date.MONTH,m));
211 _this.mfrom.setValue(n.add(Date.MONTH,m));
214 _this.daypick.hide();
215 _this.dateRange = function() {
217 date_from : _this.mfrom.getValue(),
218 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
224 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
226 _this.mfrom.setValue(n.add(Date.MONTH, m));
229 _this.daypick.hide();
230 _this.dateRange = function() {
232 date_from : _this.mfrom.getValue(),
233 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
239 var m = (new Date()).format('n') *1 - 1 ;
240 _this.mfrom.setValue(n.add(Date.MONTH, m ));
243 _this.daypick.hide();
244 _this.dateRange = function() {
246 date_from : _this.mfrom.getValue(),
247 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
256 var m = (new Date()).format('n') * 1;
257 _this.mfrom.setValue(n.add(Date.MONTH, m-1 ));
258 _this.mto.setValue(n.add(Date.MONTH,m ));
264 _this.daypick.hide();
265 _this.dateRange = function() {
267 date_from : _this.mfrom.getValue(),
268 date_to : _this.mto.getValue()
276 var d = (new Date()).format('w') * -1;
277 _this.daypick.setValue( (new Date()).add(Date.DAY, d ));
280 _this.daypick.show();
285 _this.daypick.setValue(new Date());
288 _this.daypick.show();
292 alerT("oops invalid ftype?");
301 displayField : 'fname',
303 fieldLabel : 'Status',
304 hiddenName : 'cm_status',
307 name : 'cm_status_name',
308 triggerAction : 'all',
310 valueField : 'ftype',
312 dateRange : function() {
315 var ftype = this.getValue();
322 date_from : _this.mfrom.getValue(),
323 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
333 date_from : _this.mfrom.getValue(),
334 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
340 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
342 _this.mfrom.setValue(n.add(Date.MONTH, m));
345 _this.daypick.hide();
346 _this.dateRange = function() {
348 date_from : _this.mfrom.getValue(),
349 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
355 var m = (new Date()).format('n') *1 - 1 ;
356 _this.mfrom.setValue(n.add(Date.MONTH, m ));
359 _this.daypick.hide();
360 _this.dateRange = function() {
362 date_from : _this.mfrom.getValue(),
363 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
372 var m = (new Date()).format('n') * 1;
373 _this.mfrom.setValue(n.add(Date.MONTH, m-1 ));
374 _this.mto.setValue(n.add(Date.MONTH,m ));
380 _this.daypick.hide();
381 _this.dateRange = function() {
383 date_from : _this.mfrom.getValue(),
384 date_to : _this.mto.getValue()
392 var d = (new Date()).format('w') * -1;
393 _this.daypick.setValue( (new Date()).add(Date.DAY, d ));
396 _this.daypick.show();
401 _this.daypick.setValue(new Date());
404 _this.daypick.show();
408 alerT("oops invalid ftype?");
413 date_from : _this.mfrom.getValue(),
414 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
419 xtype: 'SimpleStore',
422 [ 'Y', "Show Year From"],
423 [ 'H' , "6 Months From"],
424 [ 'Q', "3 Months From"] ,
425 [ 'M', "Single Month"],
426 // [ 'W', "Single Week Starting"],
427 [ 'R', "Between these Dates"] //,
428 // [ 'D', "Single Day"]
431 fields : [ 'ftype', 'fname']
438 render : function (_self)
445 value : (function() {
448 var y = n.format('Y');
449 if (n.format('m') < 5) {
453 return Date.parseDate(y + '-05-01', 'Y-m-d');
460 render : function (_self)
468 value : (function() {
469 var n = (new Date()).add(Date.YEAR, 1);
473 var y = n.format('Y');
474 if (n.format('m') >= 5) {
478 return Date.parseDate(y + '-05-01', 'Y-m-d');
488 render : function (_self)
490 _this.daypick = _self;
496 value : (function() {
497 // var n = new Date();
505 click : function (_self, e)
507 Pman.Xtuple.DashboardRender.load();
515 text : "Other Reports",
524 click : function (_self, e)
527 url :baseURL + '/Xtuple/Reports/SalesByCustomer',
528 params : _this.viewType.dateRange()
534 text : "Sales By Customer"
540 click : function (_self, e)
543 url :baseURL + '/Xtuple/Reports/SalesByCountry',
544 params : _this.viewType.dateRange()
549 text : "Sales By Country"
555 click : function (_self, e)
558 url :baseURL + '/Xtuple/Reports/SalesByProduct',
559 params : _this.viewType.dateRange()
564 text : "Sales By Product"
574 click : function (_self, e)
577 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
578 params : _this.viewType.dateRange()
583 text : "Purchases By Vendor"
589 click : function (_self, e)
592 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
593 params : _this.viewType.dateRange()
598 text : "Purchases By Product"
608 click : function (_self, e)
611 url :baseURL + '/Xtuple/Reports/StockAtLocation',
612 params : _this.viewType.dateRange()
615 Roo.MessageBox.alert("Downloading",
616 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
620 text : "Historical Stock Levels (EO HKFY)"
630 click : function (_self, e)
633 url :baseURL + '/Xtuple/Reports/SGTax',
634 params : _this.viewType.dateRange()
637 Roo.MessageBox.alert("Downloading",
638 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
642 text : "SG Tax report"
664 select : function (combo, record, index)
666 Pman.Xtuple.DashboardRender.load();
668 render : function (_self)
670 _this.themeCombo = this;
674 displayField : 'name',
676 hiddenName : 'colortheme',
678 name : 'colorTheme_title',
679 qtip : "Select a Color Theme",
680 selectOnFocus : true,
681 triggerAction : 'all',
683 valueField : 'themeData',
684 value : (function() {
685 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
688 xtype: 'SimpleStore',
691 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
694 fields : ['name','themeData']
701 xtype: 'ContentPanel',
704 render : function (_self)
706 _this.reportpanel = _self;
712 showReport : function(node, isxls) {
714 _this.selectedNode = node;
716 var rc = _this.reportCompany.getValue();
718 flhead_name : _this.selectedNode.attributes.text,
720 period : _this.reportDateFrom.getValue(),
721 interval: _this.reportInterval.getValue(),
722 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
723 singleCountry : rc == 'consolidated' ? 0 : 1
729 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
734 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
737 var el = this.region.el;
745 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
749 Roo.MessageBox.show({
750 title: 'Please wait...',
759 ///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");
761 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
765 callback: function() {
767 Roo.MessageBox.hide();
782 text : "Report Range :"
788 render : function (_self)
790 _this.reportDateFrom = _self;
792 select : function (combo, date)
794 //_this.grid.footer.onClick('first');
800 value : (function() {
801 return Date.parseDate(
802 '' + (new Date()).format('Y-m') + '-01'
809 render : function (_self)
811 _this.reportInterval = _self;
813 select : function (combo, record, index)
815 // Roo.log('select');
816 // _this.grid.footer.onClick('first');
820 displayField : 'fname',
822 fieldLabel : 'Status',
823 hiddenName : 'cm_status',
826 name : 'cm_status_name',
827 triggerAction : 'all',
829 valueField : 'ftype',
832 xtype: 'SimpleStore',
835 [ 'Y', "Since Start of Financial Year"],
836 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
837 [ 'M' , "Single Month"],
838 [ 'MM' , "Single Month with Previous Month"],
839 [ 'MY' , "Single Month with Previous Year"],
840 [ 'MF' , "This Months of Financia Year"],
841 [ 'ML' , "Last 12 Months"]
843 fields : [ 'ftype', 'fname']
850 render : function (_self)
852 _this.reportCompany = _self;
856 displayField : 'fname',
858 fieldLabel : 'Status',
859 hiddenName : 'report_company',
862 name : 'report_company_name',
863 triggerAction : 'all',
865 valueField : 'ftype',
867 hidden : (function() {
869 return baseURL.match(/hk\.php$/) ? false : true;
872 xtype: 'SimpleStore',
875 [ 'hk', "Hong Kong"],
876 [ 'sg' , "Singapore"],
877 [ 'my' , "Malaysia"],
879 [ 'au' , "Australia"],
880 [ 'consolidated' , "Consolidated"]
882 fields : [ 'ftype', 'fname']
889 click : function (_self, e)
891 _this.reportpanel.showReport();
894 text : "Refresh Report"
904 click : function (_self, e)
906 _this.reportpanel.showReport(false,'xls');
909 text : "Download XLS"
916 xtype: 'LayoutRegion',
926 render : function (_self)
942 xtype: 'AsyncTreeNode',
946 xtype: 'DefaultSelectionModel',
949 selectionchange : function (_self, node)
951 var at = node.attributes.id;
953 _this.dashpanel.layout.getRegion('center').showPanel(0);
954 Pman.Xtuple.DashboardRender.load();
958 _this.dashpanel.layout.getRegion('center').showPanel(1);
959 _this.reportpanel.showReport(node);
968 requestMethod : 'GET',
969 baseParams : { _tree : 1, _dragon_only : 1 },
970 dataUrl : baseURL + '/Roo/Flhead'
973 xtype: 'AsyncTreeNode',
980 xtype: 'LayoutRegion',
987 xtype: 'LayoutRegion',