|
@@ -164,24 +164,27 @@ class AuditDataService
|
|
|
|
|
|
$from = $this->buildFrom($entity);
|
|
|
$where = $this->buildWhere($entity, $users, $types, $idx, $dateFrom, $dateTo, $searchValue);
|
|
|
+
|
|
|
+ $groupBy = $this->buildGroupBy($entity);
|
|
|
+
|
|
|
+ $sql_cnt = $this->buildSelect($entity, true) . $from . $where . $groupBy;
|
|
|
+ $fetchAll = $this->connection->query($sql_cnt)->fetchAll();
|
|
|
+
|
|
|
+ $count = 0;
|
|
|
+ foreach ($fetchAll as $row) {
|
|
|
+ $count += isset($row['total']) ? $row['total'] : 0;
|
|
|
+ }
|
|
|
|
|
|
- $sql_cnt = $this->buildSelect($entity, true) . $from . $where;
|
|
|
- $count = $this->connection->query($sql_cnt)->fetchAll()[0]['total'];
|
|
|
-
|
|
|
- $sql = $this->buildSelect($entity) . $from . $where;
|
|
|
- $sql .= "ORDER BY R.timestamp DESC ";
|
|
|
-
|
|
|
- // print_r("<pre>");
|
|
|
- // print_r($sql);
|
|
|
- // print_r("</pre>");
|
|
|
+ $sql = $this->buildSelect($entity) . $from . $where . $groupBy;
|
|
|
+ $sql .= " ORDER BY R.timestamp DESC ";
|
|
|
|
|
|
if(is_null($resxpage)) $resxpage = 10;
|
|
|
-
|
|
|
+
|
|
|
if ($resxpage != "inf") {
|
|
|
$pages = ceil(($count / floatval($resxpage)));
|
|
|
$from = ($page - 1) * $resxpage;
|
|
|
//$to = ($page) * $resxpage;
|
|
|
- $sql .= "LIMIT {$from},{$resxpage}";
|
|
|
+ $sql .= " LIMIT {$from},{$resxpage} ";
|
|
|
}
|
|
|
|
|
|
return array(
|
|
@@ -290,8 +293,24 @@ class AuditDataService
|
|
|
$where .= ') ';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return $where;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ private function buildGroupBy($entity)
|
|
|
+ {
|
|
|
+ $columns = $this->getColumns();
|
|
|
+ $groupBy[] = 'C.rev';
|
|
|
+ foreach ($columns[$entity] as $column) {
|
|
|
+ $groupBy[] = "C.{$column}";
|
|
|
+ }
|
|
|
+ $groupBy = implode(', ', $groupBy);
|
|
|
+ $groupBy = " GROUP BY {$groupBy} ";
|
|
|
+
|
|
|
+ return $groupBy;
|
|
|
+ }
|
|
|
+
|
|
|
}
|