+ $sql = sprintf("SELECT datum,id,category,descr,%s FROM %s WHERE %s ORDER BY datum,id",
+ $this->valuecolumn,
+ $this->table,
+ implode (" AND ", $where));
+
+ $sum = 0.0;
+ $sum_in = 0.0;
+ $sum_out = 0.0;
+ $color = 0;
+ foreach ($this->db->fetchAssocList($sql) as $row) {
+ $descr = explode ("\n", $row['descr']);
+ $date = Utils::assertGermanDate($row['datum']);
+
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\">%s</td>", $date);
+ $out .= sprintf ("<td width=\"10%%\" align=\"center\">%s</td>", $row['category']);
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/') === false)
+ $out .= sprintf ("<td width=\"70%%\"><a href=\"edit.php?id=%d%s\" target=\"_new\">%s</a></td>",
+ $row['id'], $add, $descr[0]);
+ else
+ $out .= sprintf ("<td width=\"70%%\"><span route=\"%s/EditDescr\" item_id=\"%d\" text=\"%s\">%s</span></td>",
+ get_class($this),
+ $row['id'], $add, $descr[0]);
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
+ $row[$this->valuecolumn]>0?"in":"out", $row[$this->valuecolumn]);
+ $sum += $row[$this->valuecolumn];
+ if ($row[$this->valuecolumn] > 0) {
+ $sum_in += $row[$this->valuecolumn];
+ } else {
+ $sum_out += $row[$this->valuecolumn];
+ }
+ $out .= "</tr>";
+ $color = !$color;
+ }
+ if (strlen($data['statement'])) {
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>";
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
+ $out .= "</tr>";
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>";
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
+ $out .= "</tr>";
+ }
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= "<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>";
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
+ $sum>0?"in":"out", $sum);
+ $out .= "</tr>";
+
+ return $out;
+ }
+
+ public function ajaxFilter(Array $data)
+ {
+ return array('table' => utf8_encode($this->filterTable($data)));
+ }
+
+}