[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16606]
From: |
nelson . guerra |
Subject: |
[Fmsystem-commits] [16606] |
Date: |
Fri, 21 Apr 2017 01:22:21 -0400 (EDT) |
Revision: 16606
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16606
Author: nelson224
Date: 2017-04-21 01:22:20 -0400 (Fri, 21 Apr 2017)
Log Message:
-----------
Modified Paths:
--------------
branches/dev-syncromind-2/property/inc/class.soreport.inc.php
Modified: branches/dev-syncromind-2/property/inc/class.soreport.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.soreport.inc.php
2017-04-20 17:43:54 UTC (rev 16605)
+++ branches/dev-syncromind-2/property/inc/class.soreport.inc.php
2017-04-21 05:22:20 UTC (rev 16606)
@@ -202,6 +202,32 @@
$jsonB = json_decode($definition['report_definition'],
true);
+ $columns_a = array_values($jsonB['group']);
+
+ $first = 0;
+ $last_a = count($columns_a) -1;
+
+ $columns_b = $columns_a;
+ unset($columns_b[$last_a]);
+
+ $last_b = count($columns_b) -1;
+
+ $query_columns = implode(',', $columns_b);
+
+ foreach ($columns_b as $c => $v)
+ {
+ if ($c == $first)
+ {
+ $query_columns .= ", CASE WHEN
".$columns_b[$first]." is null THEN 'Grand Total'";
+ }
+ else {
+ $query_columns .= " WHEN
".$columns_b[$c]." is null THEN concat (".$columns_b[$c-1]."::character
varying, ' total')";
+ }
+ }
+
+ $query_columns .= " WHEN ".$columns_a[$last_a]." is
null THEN concat (".$columns_b[$last_b]."::character varying, ' total')";
+ $query_columns .= " ELSE
".$columns_a[$last_a]."::character varying END AS ".$columns_a[$last_a];
+
$columns = implode(',', $jsonB['group']);
$agregates = array();
foreach ($jsonB['aggregate'] as $c => $v)
@@ -216,7 +242,7 @@
}
//$sql = "SELECT ".$columns.",".$func_agregates." FROM
".$dataset['view_name']." GROUP BY ".$columns.$order;
- $sql = "SELECT ".$columns.",".$func_agregates." FROM
".$dataset['view_name']." GROUP BY ROLLUP (".$columns.')'.$order;
+ $sql = "SELECT ".$query_columns.",".$func_agregates."
FROM ".$dataset['view_name']." GROUP BY ROLLUP (".$columns.')'.$order;
$this->db->query($sql, __LINE__, __FILE__);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16606],
nelson . guerra <=