Index: src/include/lib/Garradin/Accounting/Years.php ================================================================== --- src/include/lib/Garradin/Accounting/Years.php +++ src/include/lib/Garradin/Accounting/Years.php @@ -48,12 +48,13 @@ } static public function list(bool $reverse = false) { $desc = $reverse ? 'DESC' : ''; - $em = EntityManager::getInstance(Year::class); - return $em->all(sprintf('SELECT * FROM @TABLE ORDER BY end_date %s;', $desc)); + return DB::getInstance()->get(sprintf('SELECT *, + (SELECT COUNT(*) FROM acc_transactions WHERE id_year = acc_years.id) AS nb_transactions + FROM acc_years ORDER BY end_date %s;', $desc)); } static public function getNewYearDates(): array { $last_year = EntityManager::findOne(Year::class, 'SELECT * FROM @TABLE ORDER BY end_date DESC LIMIT 1;'); Index: src/templates/acc/years/index.tpl ================================================================== --- src/templates/acc/years/index.tpl +++ src/templates/acc/years/index.tpl @@ -34,43 +34,49 @@ {/if} -
+ {foreach from=$list item="year"} -
{$year.label}
-
- {if $year.closed}Clôturé{else}En cours{/if} - | Du {$year.start_date|date_short} au {$year.end_date|date_short} - | Plan comptable -
-
- Graphiques - | Balance générale - | Journal général - | Grand livre - | Compte de résultat - | Bilan -
- {if $session->canAccess('compta', Membres::DROIT_ADMIN)} -
- {linkbutton label="Export CSV" shape="export" href="import.php?id=%d&export=csv"|args:$year.id} - {linkbutton label="Export tableur" shape="export" href="import.php?id=%d&export=ods"|args:$year.id} - {if !$year.closed} - {linkbutton label="Import" shape="upload" href="import.php?id=%d"|args:$year.id} - {linkbutton label="Balance d'ouverture" shape="reset" href="balance.php?id=%d"|args:$year.id} - {linkbutton label="Modifier" shape="edit" href="edit.php?id=%d"|args:$year.id} - {linkbutton label="Clôturer" shape="lock" href="close.php?id=%d"|args:$year.id} - {linkbutton label="Supprimer" shape="delete" href="delete.php?id=%d"|args:$year.id} - {/if} -
- {/if} + + + + + + + + + + + + + + {/foreach} - +

{$year.label}

{$year.nb_transactions} écritures | Plan comptable
{$year.start_date|date_short} au {$year.end_date|date_short} + Graphiques + | Balance générale + | Journal général + | Grand livre + | Compte de résultat + | Bilan +
{if $year.closed}Clôturé{else}En cours{/if} + {if $session->canAccess('compta', Membres::DROIT_ADMIN)} + {linkbutton label="Export CSV" shape="export" href="import.php?id=%d&export=csv"|args:$year.id} + {linkbutton label="Export tableur" shape="export" href="import.php?id=%d&export=ods"|args:$year.id} + {if !$year.closed} + {linkbutton label="Import" shape="upload" href="import.php?id=%d"|args:$year.id} + {linkbutton label="Balance d'ouverture" shape="reset" href="balance.php?id=%d"|args:$year.id} + {linkbutton label="Modifier" shape="edit" href="edit.php?id=%d"|args:$year.id} + {linkbutton label="Clôturer" shape="lock" href="close.php?id=%d"|args:$year.id} + {linkbutton label="Supprimer" shape="delete" href="delete.php?id=%d"|args:$year.id} + {/if} + {/if} +
{else}

Il n'y a pas d'exercice en cours.

{/if} {include file="admin/_foot.tpl"} Index: src/www/admin/acc/years/index.php ================================================================== --- src/www/admin/acc/years/index.php +++ src/www/admin/acc/years/index.php @@ -5,10 +5,8 @@ require_once __DIR__ . '/../../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ACCES); -$years = new Years; - -$tpl->assign('list', $years->list(true)); +$tpl->assign('list', Years::list(true)); $tpl->display('acc/years/index.tpl');