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();
201 var m = (new Date()).format('n')*1 > 6 ? 6 : 0;
203 Roo.log( n.add(Date.MONTH,m));
204 _this.mfrom.setValue(n.add(Date.MONTH,m));
207 _this.daypick.hide();
212 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
214 _this.mfrom.setValue(n.add(Date.MONTH, m));
217 _this.daypick.hide();
222 var m = (new Date()).format('n') *1 - 1 ;
223 _this.mfrom.setValue(n.add(Date.MONTH, m ));
226 _this.daypick.hide();
234 var m = (new Date()).format('n') * 1;
235 _this.mfrom.setValue(n.add(Date.MONTH, m-1 ));
236 _this.mto.setValue(n.add(Date.MONTH,m ));
242 _this.daypick.hide();
249 var d = (new Date()).format('w') * -1;
250 _this.daypick.setValue( (new Date()).add(Date.DAY, d ));
253 _this.daypick.show();
258 _this.daypick.setValue(new Date());
261 _this.daypick.show();
265 alerT("oops invalid ftype?");
274 displayField : 'fname',
276 fieldLabel : 'Status',
277 hiddenName : 'cm_status',
280 name : 'cm_status_name',
281 triggerAction : 'all',
283 valueField : 'ftype',
285 dateRange : function() {
288 var ftype = this.getValue();
295 date_from : _this.mfrom.getValue(),
296 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
306 date_from : _this.mfrom.getValue(),
307 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
316 date_from : _this.mfrom.getValue(),
317 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
325 date_from : _this.mfrom.getValue(),
326 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
336 date_from : _this.mfrom.getValue(),
337 date_to : _this.mto.getValue()
344 Roo.MessageBox.alert("select range");
350 xtype: 'SimpleStore',
353 [ 'Y', "Show Year From"],
354 [ 'H' , "6 Months From"],
355 [ 'Q', "3 Months From"] ,
356 [ 'M', "Single Month"],
357 // [ 'W', "Single Week Starting"],
358 [ 'R', "Between these Dates"] //,
359 // [ 'D', "Single Day"]
362 fields : [ 'ftype', 'fname']
369 render : function (_self)
376 value : (function() {
379 var y = n.format('Y');
380 if (n.format('m') < 5) {
384 return Date.parseDate(y + '-05-01', 'Y-m-d');
391 render : function (_self)
399 value : (function() {
400 var n = (new Date()).add(Date.YEAR, 1);
404 var y = n.format('Y');
405 if (n.format('m') >= 5) {
409 return Date.parseDate(y + '-05-01', 'Y-m-d');
419 render : function (_self)
421 _this.daypick = _self;
427 value : (function() {
428 // var n = new Date();
436 click : function (_self, e)
438 Pman.Xtuple.DashboardRender.load();
446 text : "Other Reports",
455 click : function (_self, e)
458 url :baseURL + '/Xtuple/Reports/SalesByCustomer',
459 params : _this.viewType.dateRange()
465 text : "Sales By Customer"
471 click : function (_self, e)
474 url :baseURL + '/Xtuple/Reports/SalesByCountry',
475 params : _this.viewType.dateRange()
480 text : "Sales By Country"
486 click : function (_self, e)
489 url :baseURL + '/Xtuple/Reports/SalesByProduct',
490 params : _this.viewType.dateRange()
495 text : "Sales By Product"
505 click : function (_self, e)
508 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
509 params : _this.viewType.dateRange()
514 text : "Purchases By Vendor"
520 click : function (_self, e)
523 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
524 params : _this.viewType.dateRange()
529 text : "Purchases By Product"
539 click : function (_self, e)
542 url :baseURL + '/Xtuple/Reports/StockAtLocation',
543 params : _this.viewType.dateRange()
546 Roo.MessageBox.alert("Downloading",
547 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
551 text : "Historical Stock Levels (EO HKFY)"
561 click : function (_self, e)
564 url :baseURL + '/Xtuple/Reports/SGTax',
565 params : _this.viewType.dateRange()
568 Roo.MessageBox.alert("Downloading",
569 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
573 text : "SG Tax report"
595 select : function (combo, record, index)
597 Pman.Xtuple.DashboardRender.load();
599 render : function (_self)
601 _this.themeCombo = this;
605 displayField : 'name',
607 hiddenName : 'colortheme',
609 name : 'colorTheme_title',
610 qtip : "Select a Color Theme",
611 selectOnFocus : true,
612 triggerAction : 'all',
614 valueField : 'themeData',
615 value : (function() {
616 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
619 xtype: 'SimpleStore',
622 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
625 fields : ['name','themeData']
632 xtype: 'ContentPanel',
635 render : function (_self)
637 _this.reportpanel = _self;
643 showReport : function(node, isxls) {
645 _this.selectedNode = node;
647 var rc = _this.reportCompany.getValue();
649 flhead_name : _this.selectedNode.attributes.text,
651 period : _this.reportDateFrom.getValue(),
652 interval: _this.reportInterval.getValue(),
653 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
654 singleCountry : rc == 'consolidated' ? 0 : 1
660 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
665 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
668 var el = this.region.el;
676 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
680 Roo.MessageBox.show({
681 title: 'Please wait...',
690 ///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");
692 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
696 callback: function() {
698 Roo.MessageBox.hide();
713 text : "Report Range :"
719 render : function (_self)
721 _this.reportDateFrom = _self;
723 select : function (combo, date)
725 //_this.grid.footer.onClick('first');
731 value : (function() {
732 return Date.parseDate(
733 '' + (new Date()).format('Y-m') + '-01'
740 render : function (_self)
742 _this.reportInterval = _self;
744 select : function (combo, record, index)
746 // Roo.log('select');
747 // _this.grid.footer.onClick('first');
751 displayField : 'fname',
753 fieldLabel : 'Status',
754 hiddenName : 'cm_status',
757 name : 'cm_status_name',
758 triggerAction : 'all',
760 valueField : 'ftype',
763 xtype: 'SimpleStore',
766 [ 'Y', "Since Start of Financial Year"],
767 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
768 [ 'M' , "Single Month"],
769 [ 'MM' , "Single Month with Previous Month"],
770 [ 'MY' , "Single Month with Previous Year"],
771 [ 'MF' , "This Months of Financia Year"],
772 [ 'ML' , "Last 12 Months"]
774 fields : [ 'ftype', 'fname']
781 render : function (_self)
783 _this.reportCompany = _self;
787 displayField : 'fname',
789 fieldLabel : 'Status',
790 hiddenName : 'report_company',
793 name : 'report_company_name',
794 triggerAction : 'all',
796 valueField : 'ftype',
798 hidden : (function() {
800 return baseURL.match(/hk\.php$/) ? false : true;
803 xtype: 'SimpleStore',
806 [ 'hk', "Hong Kong"],
807 [ 'sg' , "Singapore"],
808 [ 'my' , "Malaysia"],
810 [ 'au' , "Australia"],
811 [ 'consolidated' , "Consolidated"]
813 fields : [ 'ftype', 'fname']
820 click : function (_self, e)
822 _this.reportpanel.showReport();
825 text : "Refresh Report"
835 click : function (_self, e)
837 _this.reportpanel.showReport(false,'xls');
840 text : "Download XLS"
847 xtype: 'LayoutRegion',
857 render : function (_self)
873 xtype: 'AsyncTreeNode',
877 xtype: 'DefaultSelectionModel',
880 selectionchange : function (_self, node)
882 var at = node.attributes.id;
884 _this.dashpanel.layout.getRegion('center').showPanel(0);
885 Pman.Xtuple.DashboardRender.load();
889 _this.dashpanel.layout.getRegion('center').showPanel(1);
890 _this.reportpanel.showReport(node);
899 requestMethod : 'GET',
900 baseParams : { _tree : 1, _dragon_only : 1 },
901 dataUrl : baseURL + '/Roo/Flhead'
904 xtype: 'AsyncTreeNode',
911 xtype: 'LayoutRegion',
918 xtype: 'LayoutRegion',