get(utils::get('cat')); if (!$cat) { throw new UserException("La catégorie demandée n'existe pas."); } $type = $cat['type']; } else { if (isset($_GET['autres'])) $type = Compta_Categories::AUTRES; elseif (isset($_GET['depenses'])) $type = Compta_Categories::DEPENSES; else $type = Compta_Categories::RECETTES; } $journal = new Compta_Journal; $list = $journal->getListForCategory($type === Compta_Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null); $tpl->assign('categorie', $cat); $tpl->assign('type', $type); if ($type !== Compta_Categories::AUTRES) { $tpl->assign('liste_cats', $cats->getList($type)); } $total = 0.0; foreach ($list as &$row) { $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'); ?>