Ajout du support des écritures ventilées.
[garradin.git] / www / admin / compta / operations / index.php
index e257d68..e225b10 100644 (file)
@@ -32,7 +32,6 @@ $journal = new Compta_Journal;
 $list = $journal->getListForCategory($type === Compta_Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null);
 
 $tpl->assign('categorie', $cat);
 $list = $journal->getListForCategory($type === Compta_Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null);
 
 $tpl->assign('categorie', $cat);
-$tpl->assign('journal', $list);
 $tpl->assign('type', $type);
 
 if ($type !== Compta_Categories::AUTRES)
 $tpl->assign('type', $type);
 
 if ($type !== Compta_Categories::AUTRES)
@@ -41,14 +40,19 @@ if ($type !== Compta_Categories::AUTRES)
 }
 
 $total = 0.0;
 }
 
 $total = 0.0;
-
-foreach ($list as $row)
+foreach ($list as &$row)
 {
 {
-       $total += (float) $row['montant'];
+       $db = DB::getInstance();
+       $row['montant'] =
+               $db->simpleQuerySingle('
+                       SELECT sum(CASE WHEN montant > 0 THEN montant ELSE 0 END)
+                       FROM compta_flux
+                       WHERE compta_flux.id_journal = ?', false, $row['id']);
+       $total += round((float) $row['montant'], 2);
 }
 }
-
+$tpl->assign('journal', $list);
 $tpl->assign('total', $total);
 
 $tpl->display('admin/compta/operations/index.tpl');
 
 $tpl->assign('total', $total);
 
 $tpl->display('admin/compta/operations/index.tpl');
 
-?>
\ No newline at end of file
+?>