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() {
323 xtype: 'SimpleStore',
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"]
335 fields : [ 'ftype', 'fname']
342 render : function (_self)
349 value : (function() {
352 var y = n.format('Y');
353 if (n.format('m') < 5) {
357 return Date.parseDate(y + '-05-01', 'Y-m-d');
364 render : function (_self)
372 value : (function() {
373 var n = (new Date()).add(Date.YEAR, 1);
377 var y = n.format('Y');
378 if (n.format('m') >= 5) {
382 return Date.parseDate(y + '-05-01', 'Y-m-d');
392 render : function (_self)
394 _this.daypick = _self;
400 value : (function() {
401 // var n = new Date();
409 click : function (_self, e)
411 Pman.Xtuple.DashboardRender.load();
419 text : "Other Reports",
428 click : function (_self, e)
431 url :baseURL + '/Xtuple/Reports/SalesByCustomer',
432 params : _this.dateRange()
438 text : "Sales By Customer"
444 click : function (_self, e)
447 url :baseURL + '/Xtuple/Reports/SalesByCountry',
448 params : _this.dateRange()
453 text : "Sales By Country"
459 click : function (_self, e)
462 url :baseURL + '/Xtuple/Reports/SalesByProduct',
463 params : _this.dateRange()
468 text : "Sales By Product"
478 click : function (_self, e)
481 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
482 params : _this.dateRange()
487 text : "Purchases By Vendor"
493 click : function (_self, e)
496 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
497 params : _this.dateRange()
502 text : "Purchases By Product"
512 click : function (_self, e)
515 url :baseURL + '/Xtuple/Reports/StockAtLocation',
516 params : _this.dateRange()
519 Roo.MessageBox.alert("Downloading",
520 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
524 text : "Historical Stock Levels (EO HKFY)"
534 click : function (_self, e)
537 url :baseURL + '/Xtuple/Reports/SGTax',
538 params : _this.dateRange()
541 Roo.MessageBox.alert("Downloading",
542 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
546 text : "SG Tax report"
568 select : function (combo, record, index)
570 Pman.Xtuple.DashboardRender.load();
572 render : function (_self)
574 _this.themeCombo = this;
578 displayField : 'name',
580 hiddenName : 'colortheme',
582 name : 'colorTheme_title',
583 qtip : "Select a Color Theme",
584 selectOnFocus : true,
585 triggerAction : 'all',
587 valueField : 'themeData',
588 value : (function() {
589 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
592 xtype: 'SimpleStore',
595 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
598 fields : ['name','themeData']
605 xtype: 'ContentPanel',
608 render : function (_self)
610 _this.reportpanel = _self;
616 showReport : function(node, isxls) {
618 _this.selectedNode = node;
620 var rc = _this.reportCompany.getValue();
622 flhead_name : _this.selectedNode.attributes.text,
624 period : _this.reportDateFrom.getValue(),
625 interval: _this.reportInterval.getValue(),
626 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
627 singleCountry : rc == 'consolidated' ? 0 : 1
633 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
638 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
641 var el = this.region.el;
649 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
653 Roo.MessageBox.show({
654 title: 'Please wait...',
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");
665 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
669 callback: function() {
671 Roo.MessageBox.hide();
686 text : "Report Range :"
692 render : function (_self)
694 _this.reportDateFrom = _self;
696 select : function (combo, date)
698 //_this.grid.footer.onClick('first');
704 value : (function() {
705 return Date.parseDate(
706 '' + (new Date()).format('Y-m') + '-01'
713 render : function (_self)
715 _this.reportInterval = _self;
717 select : function (combo, record, index)
719 // Roo.log('select');
720 // _this.grid.footer.onClick('first');
724 displayField : 'fname',
726 fieldLabel : 'Status',
727 hiddenName : 'cm_status',
730 name : 'cm_status_name',
731 triggerAction : 'all',
733 valueField : 'ftype',
736 xtype: 'SimpleStore',
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"]
747 fields : [ 'ftype', 'fname']
754 render : function (_self)
756 _this.reportCompany = _self;
760 displayField : 'fname',
762 fieldLabel : 'Status',
763 hiddenName : 'report_company',
766 name : 'report_company_name',
767 triggerAction : 'all',
769 valueField : 'ftype',
771 hidden : (function() {
773 return baseURL.match(/hk\.php$/) ? false : true;
776 xtype: 'SimpleStore',
779 [ 'hk', "Hong Kong"],
780 [ 'sg' , "Singapore"],
781 [ 'my' , "Malaysia"],
783 [ 'au' , "Australia"],
784 [ 'consolidated' , "Consolidated"]
786 fields : [ 'ftype', 'fname']
793 click : function (_self, e)
795 _this.reportpanel.showReport();
798 text : "Refresh Report"
808 click : function (_self, e)
810 _this.reportpanel.showReport(false,'xls');
813 text : "Download XLS"
820 xtype: 'LayoutRegion',
830 render : function (_self)
846 xtype: 'AsyncTreeNode',
850 xtype: 'DefaultSelectionModel',
853 selectionchange : function (_self, node)
855 var at = node.attributes.id;
857 _this.dashpanel.layout.getRegion('center').showPanel(0);
858 Pman.Xtuple.DashboardRender.load();
862 _this.dashpanel.layout.getRegion('center').showPanel(1);
863 _this.reportpanel.showReport(node);
872 requestMethod : 'GET',
873 baseParams : { _tree : 1, _dragon_only : 1 },
874 dataUrl : baseURL + '/Roo/Flhead'
877 xtype: 'AsyncTreeNode',
884 xtype: 'LayoutRegion',
891 xtype: 'LayoutRegion',