init
[garradin.git] / www / admin / compta / banques / index.php
1 <?php
2 namespace Garradin;
3
4 require_once __DIR__ . '/../_inc.php';
5
6 $banques = new Compta_Comptes_Bancaires;
7 $journal = new Compta_Journal;
8
9 $liste = $banques->getList();
10
11 foreach ($liste as &$banque)
12 {
13 $banque['solde'] = $journal->getSolde($banque['id']);
14 }
15
16 $tpl->assign('liste', $liste);
17
18 function tpl_format_iban($iban)
19 {
20 return implode(' ', str_split($iban, 4));
21 }
22
23 function tpl_format_rib($iban)
24 {
25 if (substr($iban, 0, 2) != 'FR')
26 return '';
27
28 $rib = utils::IBAN_RIB($iban);
29 $rib = explode(' ', $rib);
30
31 $out = '<table class="rib"><thead><tr><th>Banque</th><th>Guichet</th><th>Compte</th><th>Clé</th></tr></thead>';
32 $out.= '<tbody><tr><td>'.$rib[0].'</td><td>'.$rib[1].'</td><td>'.$rib[2].'</td><td>'.$rib[3].'</td></tr></tbody></table>';
33 return $out;
34 }
35
36 $tpl->register_modifier('format_iban', 'Garradin\tpl_format_iban');
37 $tpl->register_modifier('format_rib', 'Garradin\tpl_format_rib');
38
39 $tpl->display('admin/compta/banques/index.tpl');
40
41 ?>