Overview
Comment:Les RIB ne servent plus de nos jours + simplification page des comptes bancaires
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ac27edf028ad804829caba73c5563407b0a1e0b9
User & Date: bohwaz on 2015-02-18 17:58:37
Other Links: manifest | tags
Context
2015-02-18
17:59
Légende plus visible check-in: 2dbae2bec0 user: bohwaz tags: trunk
17:58
Les RIB ne servent plus de nos jours + simplification page des comptes bancaires check-in: ac27edf028 user: bohwaz tags: trunk
16:53
Fix vérification check-in: 48c4153254 user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/Utils.php from [bf051c0ec8] to [9eefb1f3b8].

503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530

    static public function checkIBAN($iban)
    {
        $iban = substr($iban, 4) . substr($iban, 0, 4);
        $iban = str_replace(range('A', 'Z'), range(10, 35), $iban);
        return (bcmod($iban, 97) == 1);
    }

    static public function IBAN_RIB($iban)
    {
        if (substr($iban, 0, 2) != 'FR')
        {
            return '';
        }

        return substr($iban, 4, 5) // Code banque
            . ' ' . substr($iban, 4+5, 5) // Code guichet
            . ' ' . substr($iban, 4+5+5, -2) // Numéro de compte
            . ' ' . substr($iban, -2); // Clé RIB
    }

    static public function checkBIC($bic)
    {
        return preg_match('!^[A-Z]{4}[A-Z]{2}[1-9A-Z]{2}(?:[A-Z\d]{3})?$!', $bic);
    }

    static public function normalizePhoneNumber($n)
    {







|
<
<
<
<
<
<
<
<
<
<
<
<
<







503
504
505
506
507
508
509
510













511
512
513
514
515
516
517

    static public function checkIBAN($iban)
    {
        $iban = substr($iban, 4) . substr($iban, 0, 4);
        $iban = str_replace(range('A', 'Z'), range(10, 35), $iban);
        return (bcmod($iban, 97) == 1);
    }
    













    static public function checkBIC($bic)
    {
        return preg_match('!^[A-Z]{4}[A-Z]{2}[1-9A-Z]{2}(?:[A-Z\d]{3})?$!', $bic);
    }

    static public function normalizePhoneNumber($n)
    {

Deleted src/templates/admin/compta/banques/ajouter.tpl version [3c2df56f9d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{include file="admin/_head.tpl" title="Ajouter un compte" current="compta/banques"}

{if $error}
    <p class="error">
        {$error|escape}
    </p>
{/if}

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Ajouter un compte bancaire</legend>
        <dl>
            <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="libelle" id="f_libelle" value="{form_field name=libelle}" required="required" /></dd>
            <dt><label for="f_banque">Nom de la banque</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="banque" id="f_banque" value="{form_field name=banque}" required="required" /></dd>
            <dt><label for="f_iban">Numéro IBAN</label></dt>
            <dd><input type="text" size="30" name="iban" id="f_iban" value="{form_field name=iban}" /></dd>
            <dt><label for="f_bic">Code BIC/SWIFT de la banque</label></dt>
            <dd><input type="text" size="10" name="bic" id="f_bic" value="{form_field name=bic}" /></dd>
        </dl>
    </fieldset>

    <p class="submit">
        {csrf_field key="compta_ajout_banque"}
        <input type="submit" name="add" value="Enregistrer &rarr;" />
    </p>

</form>

{include file="admin/_foot.tpl"}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































Modified src/templates/admin/compta/banques/index.tpl from [20cc85f3ce] to [f4e86ef9da].

1
2
3
4
5
6
7
8
9
10











11

12
13

14
15
16
17
18
19
20
21

22
23
24
25

26


27

28


29
30

31
32
33

























34
{include file="admin/_head.tpl" title="Comptes bancaires" current="compta/banques"}

<ul class="actions">
    <li class="current"><a href="{$www_url}admin/compta/banques/">Comptes bancaires</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin\Compta\Comptes::CAISSE}&amp;suivi">Journal de caisse</a></li>
    {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}<li><strong><a href="{$www_url}admin/compta/banques/ajouter.php">Ajouter un compte bancaire</a></strong></li>{/if}
</ul>

    {if !empty($liste)}
        <dl class="catList">











        {foreach from=$liste item="compte"}

            <dt>{$compte.libelle|escape} {if !empty($compte.banque)}({$compte.banque|escape}){/if}</dt>
            <dd class="desc">

                IBAN : {$compte.iban|escape|format_iban}<br />
                BIC : {$compte.bic|escape}<br />
                {$compte.iban|escape|format_rib}
            </dd>
            <dd class="desc">Solde : {$compte.solde|html_money} {$config.monnaie|escape}</dd>
            <dd class="actions">
                <a href="{$www_url}admin/compta/comptes/journal.php?id={$compte.id|escape}&amp;suivi">Journal</a>
            {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}

                | <a href="{$www_url}admin/compta/banques/modifier.php?id={$compte.id|escape}">Modifier</a>
                | <a href="{$www_url}admin/compta/banques/supprimer.php?id={$compte.id|escape}">Supprimer</a>
            {/if}
            </dd>

        {/foreach}


        </dl>

    {else}


        <p class="alert">
            Aucun compte bancaire trouvé.

        </p>
    {/if}


























{include file="admin/_foot.tpl"}





<


|
|
>
>
>
>
>
>
>
>
>
>
>

>
|
|
>
|
|
<
<
<
|
|
|
>
|
|
|
|
>

>
>
|
>
|
>
>
|
<
>



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{include file="admin/_head.tpl" title="Comptes bancaires" current="compta/banques"}

<ul class="actions">
    <li class="current"><a href="{$www_url}admin/compta/banques/">Comptes bancaires</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin\Compta\Comptes::CAISSE}&amp;suivi">Journal de caisse</a></li>

</ul>

{if !empty($liste)}
    <table class="list">
        <thead>
            <tr>
                <td>Banque</td>
                <th>Libellé</th>
                <td>Solde</td>
                <td>IBAN</td>
                <td>BIC</td>
                <td></td>
            </tr>
        </thead>
        <tbody>
        {foreach from=$liste item="compte"}
            <tr>
                <td>{$compte.banque|escape}</td>
                <th>{$compte.libelle|escape}</th>
                <td><strong>{$compte.solde|html_money} {$config.monnaie|escape}</strong></td>
                <td>{$compte.iban|escape|format_iban}</td>
                <td>{$compte.bic|escape}</td>



                <td class="actions">
                    <a class="icn" href="{$www_url}admin/compta/comptes/journal.php?id={$compte.id|escape}&amp;suivi" title="Journal">𝍢</a>
                    {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
                        <a class="icn" href="{$www_url}admin/compta/banques/rapprocher.php?id={$compte.id|escape}" title="Rapprocher">☑</a>
                        <a class="icn" href="{$www_url}admin/compta/banques/modifier.php?id={$compte.id|escape}" title="Modifier">✎</a>
                        <a class="icn" href="{$www_url}admin/compta/banques/supprimer.php?id={$compte.id|escape}" title="Supprimer">✘</a>
                    {/if}
                </td>
            </tr>
        {/foreach}
        </tbody>
    </table>
    </dl>
{/if}

{if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
    {if $error}
        <p class="error">

            {$error|escape}
        </p>
    {/if}

    <form method="post" action="{$self_url|escape}">

        <fieldset>
            <legend>Ajouter un compte bancaire</legend>
            <dl>
                <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
                <dd><input type="text" name="libelle" id="f_libelle" value="{form_field name=libelle}" required="required" /></dd>
                <dt><label for="f_banque">Nom de la banque</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
                <dd><input type="text" name="banque" id="f_banque" value="{form_field name=banque}" required="required" /></dd>
                <dt><label for="f_solde">Solde initial</label></dt>
                <dd><input type="number" size="5" name="solde" id="f_solde" value="{form_field name=solde default=0.00}" step="0.01" /> {$config.monnaie|escape}</dd>
                <dt><label for="f_iban">Numéro IBAN</label></dt>
                <dd><input type="text" size="30" name="iban" id="f_iban" value="{form_field name=iban}" /></dd>
                <dt><label for="f_bic">Code BIC/SWIFT de la banque</label></dt>
                <dd><input type="text" size="10" name="bic" id="f_bic" value="{form_field name=bic}" /></dd>
            </dl>
        </fieldset>

        <p class="submit">
            {csrf_field key="compta_ajout_banque"}
            <input type="submit" name="add" value="Enregistrer &rarr;" />
        </p>

    </form>
{/if}
{include file="admin/_foot.tpl"}

Added src/templates/admin/compta/banques/rapprocher.tpl version [c2cc21d617].





















>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
{include file="admin/_head.tpl" title="Rapprochement — `$compte.id`" current="compta/banques" js=1}

<ul class="actions">
    <li><a href="{$www_url}admin/compta/banques/">Comptes bancaires</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin\Compta\Comptes::CAISSE}&amp;suivi">Journal de caisse</a></li>
    <li class="current"><a href="{$admin_url}compta/banques/rapprochement.php?id={$compte.id|escape}">Rapprochement</a></li>
</ul>


{include file="admin/_foot.tpl"}

Deleted src/www/admin/compta/banques/ajouter.php version [5795e36182].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$banque = new Compta\Comptes_Bancaires;

$error = false;

if (!empty($_POST['add']))
{
    if (!Utils::CSRF_check('compta_ajout_banque'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $id = $banque->add([
                'libelle'       =>  Utils::post('libelle'),
                'banque'        =>  Utils::post('banque'),
                'iban'          =>  Utils::post('iban'),
                'bic'           =>  Utils::post('bic'),
            ]);

            Utils::redirect('/admin/compta/banques/');
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

$tpl->assign('error', $error);

$tpl->display('admin/compta/banques/ajouter.tpl');

?>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































Modified src/www/admin/compta/banques/index.php from [135ab2cb49] to [14fbe20721].

1
2
3
4
5
6
7



















































8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

$banques = new Compta\Comptes_Bancaires;
$journal = new Compta\Journal;




















































$liste = $banques->getList();

foreach ($liste as &$banque)
{
    $banque['solde'] = $journal->getSolde($banque['id']);
}

$tpl->assign('liste', $liste);

function tpl_format_iban($iban)
{
    return implode(' ', str_split($iban, 4));
}

function tpl_format_rib($iban)
{
    if (substr($iban, 0, 2) != 'FR')
        return '';

    $rib = Utils::IBAN_RIB($iban);
    $rib = explode(' ', $rib);

    $out = '<table class="rib"><thead><tr><th>Banque</th><th>Guichet</th><th>Compte</th><th>Clé</th></tr></thead>';
    $out.= '<tbody><tr><td>'.$rib[0].'</td><td>'.$rib[1].'</td><td>'.$rib[2].'</td><td>'.$rib[3].'</td></tr></tbody></table>';
    return $out;
}

$tpl->register_modifier('format_iban', 'Garradin\tpl_format_iban');
$tpl->register_modifier('format_rib', 'Garradin\tpl_format_rib');

$tpl->display('admin/compta/banques/index.tpl');







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>















<
<
<
<
<
<
<
<
<
<
<
<
<

|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73













74
75
76
77
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

$banques = new Compta\Comptes_Bancaires;
$journal = new Compta\Journal;

$error = false;

if (Utils::post('add'))
{
	if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
	{
	    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
	}

    if (!Utils::CSRF_check('compta_ajout_banque'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $id = $banques->add([
                'libelle'       =>  Utils::post('libelle'),
                'banque'        =>  Utils::post('banque'),
                'iban'          =>  Utils::post('iban'),
                'bic'           =>  Utils::post('bic'),
            ]);

            if (Utils::post('solde'))
            {
            	$exercices = new Compta\Exercices;
            	$exercice = $exercices->getCurrent();
            	$solde = Utils::post('solde');

            	$journal->add([
                    'libelle'       =>  'Solde initial',
                    'montant'       =>  abs($solde),
                    'date'          =>  gmdate('Y-m-d', $exercice['debut']),
                    'compte_credit' =>  $solde > 0 ? null : $id,
                    'compte_debit'  =>  $solde < 0 ? null : $id,
                    'numero_piece'  =>  null,
                    'remarques'     =>  'Opération automatique à l\'ajout du compte dans la liste des comptes bancaires',
                    'id_auteur'     =>  $user['id'],
                ]);
            }

            Utils::redirect('/admin/compta/banques/');
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
	}
}

$liste = $banques->getList();

foreach ($liste as &$banque)
{
    $banque['solde'] = $journal->getSolde($banque['id']);
}

$tpl->assign('liste', $liste);

function tpl_format_iban($iban)
{
    return implode(' ', str_split($iban, 4));
}














$tpl->register_modifier('format_iban', 'Garradin\tpl_format_iban');
$tpl->assign('error', $error);

$tpl->display('admin/compta/banques/index.tpl');