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;
175 _this.dateRange = function() {
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')
184 select : function (combo, record, index)
187 // Pman.Clipping.DashboardRender.load();
189 var ys = n.format('Y' )+ '-05-01';
190 n = Date.parseDate(ys, 'Y-n-d');
192 var ftype = record ? record.data.ftype : this.getValue();
196 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
197 _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
200 _this.daypick.hide();
202 _this.dateRange = function() {
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')
215 var m = (new Date()).format('n')*1 > 6 ? 6 : 0;
217 Roo.log( n.add(Date.MONTH,m));
218 _this.mfrom.setValue(n.add(Date.MONTH,m));
221 _this.daypick.hide();
222 _this.dateRange = function() {
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')
231 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
233 _this.mfrom.setValue(n.add(Date.MONTH, m));
236 _this.daypick.hide();
237 _this.dateRange = function() {
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')
246 var m = (new Date()).format('n') *1 - 1 ;
247 _this.mfrom.setValue(n.add(Date.MONTH, m ));
250 _this.daypick.hide();
251 _this.dateRange = function() {
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')
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 ));
271 _this.daypick.hide();
272 _this.dateRange = function() {
274 date_from : _this.mfrom.getValue(),
275 date_to : _this.mto.getValue()
283 var d = (new Date()).format('w') * -1;
284 _this.daypick.setValue( (new Date()).add(Date.DAY, d ));
287 _this.daypick.show();
292 _this.daypick.setValue(new Date());
295 _this.daypick.show();
299 alerT("oops invalid ftype?");
308 displayField : 'fname',
310 fieldLabel : 'Status',
311 hiddenName : 'cm_status',
314 name : 'cm_status_name',
315 triggerAction : 'all',
317 valueField : 'ftype',
319 dateRange : function() {
321 date_from : _this.mfrom.getValue(),
322 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
327 xtype: 'SimpleStore',
330 [ 'Y', "Show Year From"],
331 [ 'H' , "6 Months From"],
332 [ 'Q', "3 Months From"] ,
333 [ 'M', "Single Month"],
334 // [ 'W', "Single Week Starting"],
335 [ 'R', "Between these Dates"] //,
336 // [ 'D', "Single Day"]
339 fields : [ 'ftype', 'fname']
346 render : function (_self)
353 value : (function() {
356 var y = n.format('Y');
357 if (n.format('m') < 5) {
361 return Date.parseDate(y + '-05-01', 'Y-m-d');
368 render : function (_self)
376 value : (function() {
377 var n = (new Date()).add(Date.YEAR, 1);
381 var y = n.format('Y');
382 if (n.format('m') >= 5) {
386 return Date.parseDate(y + '-05-01', 'Y-m-d');
396 render : function (_self)
398 _this.daypick = _self;
404 value : (function() {
405 // var n = new Date();
413 click : function (_self, e)
415 Pman.Xtuple.DashboardRender.load();
423 text : "Other Reports",
432 click : function (_self, e)
435 url :baseURL + '/Xtuple/Reports/SalesByCustomer',
436 params : _this.dateRange()
442 text : "Sales By Customer"
448 click : function (_self, e)
451 url :baseURL + '/Xtuple/Reports/SalesByCountry',
452 params : _this.dateRange()
457 text : "Sales By Country"
463 click : function (_self, e)
466 url :baseURL + '/Xtuple/Reports/SalesByProduct',
467 params : _this.dateRange()
472 text : "Sales By Product"
482 click : function (_self, e)
485 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
486 params : _this.dateRange()
491 text : "Purchases By Vendor"
497 click : function (_self, e)
500 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
501 params : _this.dateRange()
506 text : "Purchases By Product"
516 click : function (_self, e)
519 url :baseURL + '/Xtuple/Reports/StockAtLocation',
520 params : _this.dateRange()
523 Roo.MessageBox.alert("Downloading",
524 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
528 text : "Historical Stock Levels (EO HKFY)"
538 click : function (_self, e)
541 url :baseURL + '/Xtuple/Reports/SGTax',
542 params : _this.dateRange()
545 Roo.MessageBox.alert("Downloading",
546 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
550 text : "SG Tax report"
572 select : function (combo, record, index)
574 Pman.Xtuple.DashboardRender.load();
576 render : function (_self)
578 _this.themeCombo = this;
582 displayField : 'name',
584 hiddenName : 'colortheme',
586 name : 'colorTheme_title',
587 qtip : "Select a Color Theme",
588 selectOnFocus : true,
589 triggerAction : 'all',
591 valueField : 'themeData',
592 value : (function() {
593 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
596 xtype: 'SimpleStore',
599 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
602 fields : ['name','themeData']
609 xtype: 'ContentPanel',
612 render : function (_self)
614 _this.reportpanel = _self;
620 showReport : function(node, isxls) {
622 _this.selectedNode = node;
624 var rc = _this.reportCompany.getValue();
626 flhead_name : _this.selectedNode.attributes.text,
628 period : _this.reportDateFrom.getValue(),
629 interval: _this.reportInterval.getValue(),
630 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
631 singleCountry : rc == 'consolidated' ? 0 : 1
637 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
642 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
645 var el = this.region.el;
653 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
657 Roo.MessageBox.show({
658 title: 'Please wait...',
667 ///el.mask("Loading - Should take around 45 seconds <br/> if it takes longer than 2 minutes, then something is broken<br/> If nothing displays try doing shift-reload or ctrl-reload");
669 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
673 callback: function() {
675 Roo.MessageBox.hide();
690 text : "Report Range :"
696 render : function (_self)
698 _this.reportDateFrom = _self;
700 select : function (combo, date)
702 //_this.grid.footer.onClick('first');
708 value : (function() {
709 return Date.parseDate(
710 '' + (new Date()).format('Y-m') + '-01'
717 render : function (_self)
719 _this.reportInterval = _self;
721 select : function (combo, record, index)
723 // Roo.log('select');
724 // _this.grid.footer.onClick('first');
728 displayField : 'fname',
730 fieldLabel : 'Status',
731 hiddenName : 'cm_status',
734 name : 'cm_status_name',
735 triggerAction : 'all',
737 valueField : 'ftype',
740 xtype: 'SimpleStore',
743 [ 'Y', "Since Start of Financial Year"],
744 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
745 [ 'M' , "Single Month"],
746 [ 'MM' , "Single Month with Previous Month"],
747 [ 'MY' , "Single Month with Previous Year"],
748 [ 'MF' , "This Months of Financia Year"],
749 [ 'ML' , "Last 12 Months"]
751 fields : [ 'ftype', 'fname']
758 render : function (_self)
760 _this.reportCompany = _self;
764 displayField : 'fname',
766 fieldLabel : 'Status',
767 hiddenName : 'report_company',
770 name : 'report_company_name',
771 triggerAction : 'all',
773 valueField : 'ftype',
775 hidden : (function() {
777 return baseURL.match(/hk\.php$/) ? false : true;
780 xtype: 'SimpleStore',
783 [ 'hk', "Hong Kong"],
784 [ 'sg' , "Singapore"],
785 [ 'my' , "Malaysia"],
787 [ 'au' , "Australia"],
788 [ 'consolidated' , "Consolidated"]
790 fields : [ 'ftype', 'fname']
797 click : function (_self, e)
799 _this.reportpanel.showReport();
802 text : "Refresh Report"
812 click : function (_self, e)
814 _this.reportpanel.showReport(false,'xls');
817 text : "Download XLS"
824 xtype: 'LayoutRegion',
834 render : function (_self)
850 xtype: 'AsyncTreeNode',
854 xtype: 'DefaultSelectionModel',
857 selectionchange : function (_self, node)
859 var at = node.attributes.id;
861 _this.dashpanel.layout.getRegion('center').showPanel(0);
862 Pman.Xtuple.DashboardRender.load();
866 _this.dashpanel.layout.getRegion('center').showPanel(1);
867 _this.reportpanel.showReport(node);
876 requestMethod : 'GET',
877 baseParams : { _tree : 1, _dragon_only : 1 },
878 dataUrl : baseURL + '/Roo/Flhead'
881 xtype: 'AsyncTreeNode',
888 xtype: 'LayoutRegion',
895 xtype: 'LayoutRegion',