init
[garradin.git] / www / admin / compta / operations / voir.php
1 <?php
2 namespace Garradin;
3
4 require_once __DIR__ . '/../_inc.php';
5
6 $journal = new Compta_Journal;
7
8 $operation = $journal->get(utils::get('id'));
9
10 if (!$operation)
11 {
12 throw new UserException("L'opération demandée n'existe pas.");
13 }
14 $exercices = new Compta_Exercices;
15
16 $tpl->assign('operation', $operation);
17
18 $credit = $comptes->get($operation['compte_credit']);
19 $tpl->assign('nom_compte_credit', $credit['libelle']);
20
21 $debit = $comptes->get($operation['compte_debit']);
22 $tpl->assign('nom_compte_debit', $debit['libelle']);
23
24 $tpl->assign('exercice', $exercices->get($operation['id_exercice']));
25
26 if ($operation['id_categorie'])
27 {
28 $cats = new Compta_Categories;
29
30 $categorie = $cats->get($operation['id_categorie']);
31 $tpl->assign('categorie', $categorie);
32
33 if ($categorie['type'] == Compta_Categories::RECETTES)
34 {
35 $tpl->assign('compte', $debit['libelle']);
36 }
37 else
38 {
39 $tpl->assign('compte', $credit['libelle']);
40 }
41
42 $tpl->assign('moyen_paiement', $cats->getMoyenPaiement($operation['moyen_paiement']));
43 }
44
45 if ($operation['id_auteur'])
46 {
47 $auteur = $membres->get($operation['id_auteur']);
48 $tpl->assign('nom_auteur', $auteur['identite']);
49 }
50
51 $tpl->display('admin/compta/operations/voir.tpl');
52
53 ?>