Propagate summary to headline
[infodrom.org/service.infodrom.org] / class / spritlog.class.php
index 451edc4..65df3fd 100644 (file)
@@ -22,11 +22,11 @@ class SpritLog extends DatabaseTable {
     $total_liter = 0;
     $total_price = 0;
     foreach ($this->db->fetchObjectList($sql) as $row) {
-      $out .= sprintf('<tr id="%d"><td>%s</td><td>%s</td><td>%s</td>' .
+      $out .= sprintf('<tr id="%d"><td>%s</td><td>%s</td><td><span route="SpritLog/EditTankstelle" item_id="%d">%s</span></td>' .
                      '<td class="right">%.2f</td><td class="right">%.2f</td><td class="right">%.2f</td>' .
                      '<td class="right">%d</td><td class="right">%d</td></tr>',
                      $row->id, assert_german_date($row->date),
-                     $row->city, $row->tankstelle,
+                     $row->city, $row->id, $row->tankstelle,
                      $row->price_liter, $row->liter,$row->price,
                      $row->km, $row->km_total);
       $total_km += $row->km;
@@ -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)
@@ -107,4 +111,10 @@ class SpritLog extends DatabaseTable {
     return array('suggestions' => $list);
   }
 
+  public function ajaxEditTankstelle(Array $data)
+  {
+    if (!strlen($data['content'])) return false;
+    return $this->modify('tankstelle', $data['content']);
+  }
+
 }