From 9ae5957473d9dc11679cb281fbaf927667b4cf78 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Wed, 25 May 2016 23:10:43 +0100 Subject: [PATCH] Made currency showing configurable from the controller (#342) --- application/controllers/Reports.php | 27 +++++++++----- application/views/reports/graphs/bar.php | 29 ++++++++++++++- application/views/reports/graphs/hbar.php | 15 ++++++-- application/views/reports/graphs/line.php | 45 ++++++++++++++++++----- application/views/reports/graphs/pie.php | 15 ++++++-- 5 files changed, 106 insertions(+), 25 deletions(-) diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index a23ef35b5..d094b5b35 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -417,7 +417,8 @@ class Reports extends Secure_area "series_data_1" => $series, "summary_data_1" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type'=>$sale_type)), "yaxis_title" => $this->lang->line('reports_revenue'), - "xaxis_title" => $this->lang->line('reports_date') + "xaxis_title" => $this->lang->line('reports_date'), + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -447,7 +448,8 @@ class Reports extends Secure_area "series_data_1" => $series, "summary_data_1" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type'=>$sale_type)), "yaxis_title" => $this->lang->line('reports_items'), - "xaxis_title" => $this->lang->line('reports_revenue') + "xaxis_title" => $this->lang->line('reports_revenue'), + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -476,7 +478,8 @@ class Reports extends Secure_area "chart_type" => "reports/graphs/pie", "labels_1" => $labels, "series_data_1" => $series, - "summary_data_1" => $summary + "summary_data_1" => $summary, + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -505,7 +508,8 @@ class Reports extends Secure_area "chart_type" => "reports/graphs/pie", "labels_1" => $labels, "series_data_1" => $series, - "summary_data_1" => $summary + "summary_data_1" => $summary, + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -534,7 +538,8 @@ class Reports extends Secure_area "chart_type" => "reports/graphs/pie", "labels_1" => $labels, "series_data_1" => $series, - "summary_data_1" => $summary + "summary_data_1" => $summary, + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -563,7 +568,8 @@ class Reports extends Secure_area "chart_type" => "reports/graphs/pie", "labels_1" => $labels, "series_data_1" => $series, - "summary_data_1" => $summary + "summary_data_1" => $summary, + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -593,7 +599,8 @@ class Reports extends Secure_area "series_data_1" => $series, "summary_data_1" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type'=>$sale_type)), "yaxis_title" => $this->lang->line('reports_customers'), - "xaxis_title" => $this->lang->line('reports_revenue') + "xaxis_title" => $this->lang->line('reports_revenue'), + "show_currency" => true ); $this->load->view("reports/graphical", $data); @@ -623,7 +630,8 @@ class Reports extends Secure_area "series_data_1" => $series, "summary_data_1" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type'=>$sale_type)), "yaxis_title" => $this->lang->line('reports_count'), - "xaxis_title" => $this->lang->line('reports_discount_percent') + "xaxis_title" => $this->lang->line('reports_discount_percent'), + "show_currency" => false ); $this->load->view("reports/graphical", $data); @@ -652,7 +660,8 @@ class Reports extends Secure_area "chart_type" => "reports/graphs/pie", "labels_1" => $labels, "series_data_1" => $series, - "summary_data_1" => $summary + "summary_data_1" => $summary, + "show_currency" => true ); $this->load->view("reports/graphical", $data); diff --git a/application/views/reports/graphs/bar.php b/application/views/reports/graphs/bar.php index aafe0fe96..0c6194550 100644 --- a/application/views/reports/graphs/bar.php +++ b/application/views/reports/graphs/bar.php @@ -32,7 +32,34 @@ // Y-Axis specific configuration axisY: { // Lets offset the chart a bit from the labels - offset: 60 + offset: 60, + // The label interpolation function enables you to modify the values + // used for the labels on each axis. + labelInterpolationFnc: function(value) { + config->item('currency_side') ) + { + ?> + return value + 'config->item('currency_symbol'); ?>'; + + return 'config->item('currency_symbol'); ?>' + value; + + return value; + + } }, // plugins configuration diff --git a/application/views/reports/graphs/hbar.php b/application/views/reports/graphs/hbar.php index 3414d9aaf..6c85d6c2b 100644 --- a/application/views/reports/graphs/hbar.php +++ b/application/views/reports/graphs/hbar.php @@ -34,16 +34,25 @@ // used for the labels on each axis. labelInterpolationFnc: function(value) { config->item('currency_side') ) + if( $show_currency ) { + if( $this->config->item('currency_side') ) + { ?> - return value + 'config->item('currency_symbol'); ?>'; + return value + 'config->item('currency_symbol'); ?>'; + + return 'config->item('currency_symbol'); ?>' + value; - return 'config->item('currency_symbol'); ?>' + value; + return value; diff --git a/application/views/reports/graphs/line.php b/application/views/reports/graphs/line.php index a88c6523c..d3d609df6 100644 --- a/application/views/reports/graphs/line.php +++ b/application/views/reports/graphs/line.php @@ -43,16 +43,25 @@ // used for the labels on each axis. labelInterpolationFnc: function(value) { config->item('currency_side') ) + if( $show_currency ) { + if( $this->config->item('currency_side') ) + { ?> - return value + 'config->item('currency_symbol'); ?>'; + return value + 'config->item('currency_symbol'); ?>'; + + return 'config->item('currency_symbol'); ?>' + value; - return 'config->item('currency_symbol'); ?>' + value; + return value; @@ -87,16 +96,25 @@ textAnchor: 'middle', labelInterpolationFnc: function(value) { config->item('currency_side') ) + if( $show_currency ) { + if( $this->config->item('currency_side') ) + { ?> - return value + 'config->item('currency_symbol'); ?>'; + return value + 'config->item('currency_symbol'); ?>'; + + return 'config->item('currency_symbol'); ?>' + value; - return 'config->item('currency_symbol'); ?>' + value; + return value; @@ -107,16 +125,25 @@ pointClass: 'ct-tooltip-point', transformTooltipTextFnc: function(value) { config->item('currency_side') ) + if( $show_currency ) { + if( $this->config->item('currency_side') ) + { ?> - return value + 'config->item('currency_symbol'); ?>'; + return value + 'config->item('currency_symbol'); ?>'; + + return 'config->item('currency_symbol'); ?>' + value; - return 'config->item('currency_symbol'); ?>' + value; + return value; diff --git a/application/views/reports/graphs/pie.php b/application/views/reports/graphs/pie.php index 65aba8931..2129fdb71 100644 --- a/application/views/reports/graphs/pie.php +++ b/application/views/reports/graphs/pie.php @@ -26,16 +26,25 @@ Chartist.plugins.tooltip({ transformTooltipTextFnc: function(value) { config->item('currency_side') ) + if( $show_currency ) { + if( $this->config->item('currency_side') ) + { ?> - return value + 'config->item('currency_symbol'); ?>'; + return value + 'config->item('currency_symbol'); ?>'; + + return 'config->item('currency_symbol'); ?>' + value; - return 'config->item('currency_symbol'); ?>' + value; + return value;