diff options
Diffstat (limited to 'plugins/CoreVisualizations')
4 files changed, 49 insertions, 2 deletions
diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable.php b/plugins/CoreVisualizations/Visualizations/HtmlTable.php index 65866c8edf..adcf8e2bda 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable.php @@ -10,9 +10,9 @@ namespace Piwik\Plugins\CoreVisualizations\Visualizations; use Piwik\API\Request as ApiRequest; use Piwik\Common; +use Piwik\Metrics; use Piwik\Period; use Piwik\Plugin\Visualization; -use Piwik\View; /** * DataTable visualization that shows DataTable data in an HTML table. @@ -44,6 +44,19 @@ class HtmlTable extends Visualization $this->config->show_visualization_only = true; } + if ($this->requestConfig->idSubtable) { + $this->config->show_totals_row = false; + } + + foreach (Metrics::getMetricIdsToProcessReportTotal() as $metricId) { + $this->config->report_ratio_columns[] = Metrics::getReadableColumnName($metricId); + } + if (!empty($this->report)) { + foreach ($this->report->getMetricNamesToProcessReportTotals() as $metricName) { + $this->config->report_ratio_columns[] = $metricName; + } + } + // we do not want to get a datatable\map $period = Common::getRequestVar('period', 'day', 'string'); if (Period\Range::parseDateRange($period)) { diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php b/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php index 9fa8163a6f..266a71e1b4 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php @@ -87,6 +87,19 @@ class Config extends VisualizationConfig */ public $highlight_summary_row = false; + /** + * If true, the totals row will be hidden + * + * Default value: false + */ + public $show_totals_row = true; + + /** + * A list of columns that support showing the ratio percentage on hover + * @var array + */ + public $report_ratio_columns = array(); + public function __construct() { parent::__construct(); diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php b/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php index 2f674a5872..696569c618 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php @@ -29,6 +29,13 @@ class RequestConfig extends VisualizationRequestConfig */ public $keep_summary_row = false; + /** + * Controls whether the totals row is displayed on every page of the datatable view or not. + * + * Default value: false + */ + public $keep_totals_row = false; + public function __construct() { $this->filter_limit = PiwikConfig::getInstance()->General['datatable_default_limit']; @@ -49,11 +56,13 @@ class RequestConfig extends VisualizationRequestConfig 'filter_offset', 'filter_sort_column', 'filter_sort_order', - 'keep_summary_row' + 'keep_summary_row', + 'keep_totals_row' )); $this->addPropertiesThatCanBeOverwrittenByQueryParams(array( 'keep_summary_row', + 'keep_totals_row', )); } diff --git a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig index a85ee66852..2d4a25e950 100644 --- a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig +++ b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig @@ -50,6 +50,18 @@ {% include "@CoreVisualizations/_dataTableViz_htmlTable.twig" with {'dataTable': row.getSubtable(), 'idSubtable': rowSubtableId} %} {% endif %} {%- endfor -%} + {% if dataTable.getTotalsRow and properties.show_totals_row %} + {% set row = dataTable.getTotalsRow %} + {% set rowId = 'totalsRow' %} + <tr class="{{ row.getMetadata('css_class') }} totalsRow" + title="Total values for this table"> + {% for column in properties.columns_to_display %} + <td> + {% include "@CoreHome/_dataTableCell.twig" with properties %} + </td> + {% endfor %} + </tr> + {% endif %} {% endif %} {%- if not showingEmbeddedSubtable -%} </tbody> |