Propagate summary to headline
authorJoey Schulze <joey@infodrom.org>
Sat, 9 Jun 2018 12:01:36 +0000 (14:01 +0200)
committerJoey Schulze <joey@infodrom.org>
Sat, 6 Oct 2018 17:30:27 +0000 (19:30 +0200)
class/spritlog.class.php
src/InfoCon/sprit/list.wml

index 275a427..65df3fd 100644 (file)
@@ -48,12 +48,16 @@ class SpritLog extends DatabaseTable {
        '</tr></tfoot>' .
        '</table>';
     }
-    return $out;
+    return array($out, $total_liter, $total_price, $total_km);
   }
 
   public function ajaxList(Array $data)
   {
-    return array('html' => array('list_'.$data['year'] => $this->formatYear($data['year'])));
+    list($table, $liter, $price, $km) = $this->formatYear($data['year']);
+
+    return array('html' => array('list_'.$data['year'] => $table,
+                                'sum_'.$data['year'] => sprintf('&euro; %.2f&nbsp;&nbsp;%d km', $price, $km),
+                                ));
   }
 
   public function ajaxAdd(Array $data)
index 6a4988c..dd03ff0 100644 (file)
@@ -71,7 +71,7 @@ table.spritlog tbody tr:hover {
   foreach ($list as $row) {
     echo '<div class="bar">';
     printf('<div year="%d" class="year">%d</div>', $row->year, $row->year);
-    printf('<div style="float:right;">&euro; %.2f&nbsp;&nbsp;%d km</div>', $row->sum, $row->km);
+    printf('<div id="sum_%d" style="float:right;">&euro; %.2f&nbsp;&nbsp;%d km</div>', $row->year, $row->sum, $row->km);
     echo '<div style="clear:both;"></div></div>';
     printf('<div id="list_%d" style="display:none;"></div>', $row->year);
   }