Overview
Comment:Refonte formulaire saisie compta pour pouvoir changer d'un type à l'autre sans recharger la page (et donc vider les champs)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 563749cf65b7f1221a9ba02e104de93b21fe472f
User & Date: bohwaz on 2017-09-01 03:44:30
Other Links: branch diff | manifest | tags
Context
2017-09-01
07:30
Ajout numéro pièce comptable et remarques dans le formulaire d'enregistrement d'une cotisation check-in: f6fc2d8cbd user: bohwaz tags: dev
03:44
Refonte formulaire saisie compta pour pouvoir changer d'un type à l'autre sans recharger la page (et donc vider les champs) check-in: 563749cf65 user: bohwaz tags: dev
2017-08-31
07:52
Utilisation des cascades pour nettoyer les foreign keys dans les tables (merci SQLite!) check-in: 2bcf7bd531 user: bohwaz tags: dev
Changes

Modified src/templates/admin/compta/operations/saisir.tpl from [e4a817f3eb] to [0aa1e2b506].

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
78
79
80
81
82
83
84
85
86
87
88


89












90

91



92



















93












94
95
96



97









98


99
100
101
102
103
104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
119
120
121

122

123




124

125
126






127
128
129
130
131
132
133
134
135
136
137
138
139
{include file="admin/_head.tpl" title="Saisie d'une opération" current="compta/saisie" js=1}

{form_errors}

{if $ok}
    <p class="confirm">
        L'opération numéro <a href="{$www_url}admin/compta/operations/voir.php?id={$ok}">{$ok}</a> a été ajoutée.
        (<a href="{$www_url}admin/compta/operations/voir.php?id={$ok}">Voir l'opération</a>)
    </p>
{/if}


<ul class="actions">
    <li{if $type == Garradin\Compta\Categories::RECETTES} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?recette">Recette</a></li>
    <li{if $type == Garradin\Compta\Categories::DEPENSES} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?depense">Dépense</a></li>

    <li{if $type === 'virement'} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?virement">Virement interne</a></li>
    <li{if $type === 'dette'} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?dette">Dette</a></li>

    <li{if is_null($type)} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?avance">Saisie avancée</a></li>
</ul>

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

    <fieldset>
        <legend>Informations sur l'opération</legend>
        <dl>
            <dt><label for="f_date">Date</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="date" name="date" id="f_date" value="{form_field name=date default=$date}" size="10" required="required" /></dd>
            <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_montant">Montant</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="number" size="5" name="montant" id="f_montant" value="{form_field name=montant default=0.00}" min="0.00" step="0.01" required="required" /> {$config.monnaie}</dd>

{if is_null($type)}
            <dt><label for="f_compte_debit">Compte débité</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                {select_compte comptes=$comptes name="compte_debit"}
            </dd>
            <dt><label for="f_compte_credit">Compte crédité</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                {select_compte comptes=$comptes name="compte_credit"}
            </dd>
{elseif $type === 'virement'}
            <dt><label for="f_compte1">Compte débité</label></dt>
            <dd>
                <select name="compte1" id="f_compte1">
                    <option value="{$id_caisse}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle} - {$compte.banque}</option>
                {/foreach}
                </select>
            </dd>
            <dt><label for="f_compte2">Compte crédité</label></dt>
            <dd>
                <select name="compte2" id="f_compte2">
                    <option value="{$id_caisse}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle} - {$compte.banque}</option>
                {/foreach}
                </select>
            </dd>
{elseif $type === 'dette'}
            <dt><label for="f_compte_usager">Type de dette</label></dt>
            <dd>
                <input type="radio" name="compte" id="f_compte_usager" value="4110" {form_field name=compte checked=4110 default=4110} />
                <label for="f_compte_usager">Dette envers un membre ou usager</label>
            </dd>
            <dd>
                <input type="radio" name="compte" id="f_compte_fournisseur" value="4010" {form_field name=compte checked=4010} />
                <label for="f_compte_fournisseur">Dette envers un fournisseur</label>
            </dd>
{else}
            <dt><label for="f_moyen_paiement">Moyen de paiement</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="moyen_paiement" id="f_moyen_paiement" required="required">
                {foreach from=$moyens_paiement item="moyen"}
                    <option value="{$moyen.code}"{if $moyen.code == $moyen_paiement} selected="selected"{/if}>{$moyen.nom}</option>
                {/foreach}
                </select>
            </dd>
            <dt class="f_cheque"><label for="f_numero_cheque">Numéro de chèque</label></dt>
            <dd class="f_cheque"><input type="text" name="numero_cheque" id="f_numero_cheque" value="{form_field name=numero_cheque}" /></dd>
            <dt class="f_banque"><label for="f_banque">Compte bancaire</label></dt>
            <dd class="f_banque">
                <select name="banque" id="f_banque">
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle} - {$compte.banque}</option>
                {/foreach}
                </select>
            </dd>


{/if}












            <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>

            <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece}" /></dd>



            <dt><label for="f_remarques">Remarques</label></dt>



















            <dd><textarea name="remarques" id="f_remarques" rows="4" cols="30">{form_field name=remarques}</textarea></dd>












        </dl>
    </fieldset>




{if $type == Garradin\Compta\Categories::DEPENSES || $type == Garradin\Compta\Categories::RECETTES || $type == 'dette'}









    <fieldset>


        <legend>Catégorie</legend>
        <dl class="catList">
        {foreach from=$categories item="cat"}
            <dt>
                <input type="radio" name="categorie" value="{$cat.id}" id="f_cat_{$cat.id}" {form_field name="categorie" checked=$cat.id} />
                <label for="f_cat_{$cat.id}">{$cat.intitule}</label>
            </dt>
            {if !empty($cat.description)}
                <dd class="desc">{$cat.description}</dd>
            {/if}
        {/foreach}
        </dl>
    </fieldset>


    <script type="text/javascript">
    {literal}
    (function () {

        window.changeMoyenPaiement = function()
        {
            var elm = $('#f_moyen_paiement');
            g.toggle('.f_cheque', elm.value == 'CH');
            g.toggle('.f_banque', elm.value != 'ES');

        };






        changeMoyenPaiement();


        $('#f_moyen_paiement').onchange = changeMoyenPaiement;






    } ());
    {/literal}
    </script>
{/if}

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

</form>

{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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179
{include file="admin/_head.tpl" title="Saisie d'une opération" current="compta/saisie" js=1}

{form_errors}

{if $ok}
    <p class="confirm">
        L'opération numéro <a href="{$www_url}admin/compta/operations/voir.php?id={$ok}">{$ok}</a> a été ajoutée.
        (<a href="{$www_url}admin/compta/operations/voir.php?id={$ok}">Voir l'opération</a>)
    </p>
{/if}

<form method="post" action="{$self_url}">
    <ul class="actions">

        <li><input type="radio" name="type" value="recette" {form_field name=type checked=recette default=recette} id="f_type_recette" /><label for="f_type_recette">Recette</label></li>
        <li><input type="radio" name="type" value="depense" {form_field name=type checked=depense} id="f_type_depense" /><label for="f_type_depense">Dépense</label></li>
        <li><input type="radio" name="type" value="virement" {form_field name=type checked=virement} id="f_type_virement" /><label for="f_type_virement">Virement interne</label></li>

        <li><input type="radio" name="type" value="dette" {form_field name=type checked=dette} id="f_type_dette" /><label for="f_type_dette">Dette</label></li>
        <li><input type="radio" name="type" value="avance" {form_field name=type checked=avance} id="f_type_avance" /><label for="f_type_avance">Saisie avancée</label></li>
    </ul>



    <fieldset>
        <legend>Informations sur l'opération</legend>
        <dl>
            <dt><label for="f_date">Date</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="date" name="date" id="f_date" value="{form_field name=date default=$date}" size="10" required="required" /></dd>
            <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_montant">Montant</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="number" size="5" name="montant" id="f_montant" value="{form_field name=montant default=0.00}" min="0.00" step="0.01" required="required" /> {$config.monnaie}</dd>
            <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>













            <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece}" /></dd>





            <dt><label for="f_remarques">Remarques</label></dt>











            <dd><textarea name="remarques" id="f_remarques" rows="4" cols="30">{form_field name=remarques}</textarea></dd>

        </dl>
        <dl class="type_recette type_depense">




            <dt><label for="f_moyen_paiement">Moyen de paiement</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="moyen_paiement" id="f_moyen_paiement" required="required">
                {foreach from=$moyens_paiement item="moyen"}
                    <option value="{$moyen.code}"{if $moyen.code == $moyen_paiement} selected="selected"{/if}>{$moyen.nom}</option>
                {/foreach}
                </select>
            </dd>
            <dt class="f_cheque"><label for="f_numero_cheque">Numéro de chèque</label></dt>
            <dd class="f_cheque"><input type="text" name="numero_cheque" id="f_numero_cheque" value="{form_field name=numero_cheque}" /></dd>
            <dt class="f_banque"><label for="f_banque">Compte bancaire</label></dt>
            <dd class="f_banque">
                <select name="banque" id="f_banque">
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle} - {$compte.banque}</option>
                {/foreach}
                </select>
            </dd>
        </dl>
    </fieldset>

    <fieldset class="type_avance">
        <legend>Saisie avancée</legend>
        <dl>
            <dt><label for="f_compte_debit">Compte débité</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                {select_compte comptes=$comptes name="compte_debit"}
            </dd>
            <dt><label for="f_compte_credit">Compte crédité</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                {select_compte comptes=$comptes name="compte_credit"}
            </dd>
        </dl>

    </fieldset>

    <fieldset class="type_virement">
        <legend>Virement</legend>
        <dl>
            <dt><label for="f_compte1">Compte débité</label></dt>
            <dd>
                <select name="compte1" id="f_compte1">
                    <option value="{$id_caisse}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle} - {$compte.banque}</option>
                {/foreach}
                </select>
            </dd>
            <dt><label for="f_compte2">Compte crédité</label></dt>
            <dd>
                <select name="compte2" id="f_compte2">
                    <option value="{$id_caisse}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle} - {$compte.banque}</option>
                {/foreach}
                </select>
            </dd>
        </dl>
    </fieldset>

    <fieldset class="type_dette">
        <legend>Dette</legend>
        <dl>
            <dt><label for="f_compte_usager">Type de dette</label></dt>
            <dd>
                <input type="radio" name="compte" id="f_compte_usager" value="4110" {form_field name=compte checked=4110 default=4110} />
                <label for="f_compte_usager">Dette envers un membre ou usager</label>
            </dd>
            <dd>
                <input type="radio" name="compte" id="f_compte_fournisseur" value="4010" {form_field name=compte checked=4010} />
                <label for="f_compte_fournisseur">Dette envers un fournisseur</label>
            </dd>
        </dl>
    </fieldset>

    <fieldset class="type_recette">
        <legend>Catégorie</legend>
        <dl class="catList">
        {foreach from=$categories_recettes item="cat"}
            <dt>
                <input type="radio" name="categorie_recette" value="{$cat.id}" id="f_cat_{$cat.id}" {form_field name="categorie" checked=$cat.id} />
                <label for="f_cat_{$cat.id}">{$cat.intitule}</label>
            </dt>
            {if !empty($cat.description)}
                <dd class="desc">{$cat.description}</dd>
            {/if}
        {/foreach}
        </dl>
    </fieldset>

    <fieldset class="type_depense type_dette">
        <legend>Catégorie</legend>
        <dl class="catList">
        {foreach from=$categories_depenses item="cat"}
            <dt>
                <input type="radio" name="categorie_depense" value="{$cat.id}" id="f_cat_{$cat.id}" {form_field name="categorie" checked=$cat.id} />
                <label for="f_cat_{$cat.id}">{$cat.intitule}</label>
            </dt>
            {if !empty($cat.description)}
                <dd class="desc">{$cat.description}</dd>
            {/if}
        {/foreach}
        </dl>
    </fieldset>


    <script type="text/javascript">
    {literal}
    (function () {

        function changeMoyenPaiement()
        {
            var elm = $('#f_moyen_paiement');
            g.toggle('.f_cheque', elm.value == 'CH');
            g.toggle('.f_banque', elm.value != 'ES');
        }

        function changeTypeSaisie(type)
        {
            g.toggle(['.type_dette', '.type_recette', '.type_depense', '.type_avance', '.type_virement'], false);
            g.toggle('.type_' + type, true);
        }

        changeMoyenPaiement();
        changeTypeSaisie('recette');

        $('#f_moyen_paiement').onchange = changeMoyenPaiement;

        $('input[name="type"]').forEach(function (elm) {
            elm.onchange = function (e) {
                changeTypeSaisie(this.value);
            };
        });
    } ());
    {/literal}
    </script>


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

</form>

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

Modified src/www/admin/compta/operations/saisir.php from [84a95ced43] to [e0ff2d0685].

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
$journal = new Compta\Journal;

$journal->checkExercice();

$cats = new Compta\Categories;
$banques = new Compta\Comptes_Bancaires;

if (null !== qg('depense'))
    $type = Compta\Categories::DEPENSES;
elseif (null !== qg('virement'))
    $type = 'virement';
elseif (null !== qg('dette'))
    $type = 'dette';
elseif (null !== qg('avance'))
    $type = null;
else
    $type = Compta\Categories::RECETTES;

if (f('save'))
{
    $form->check('compta_saisie', [
        'libelle' => 'required',
        'date'    => 'date_format:Y-m-d|required',
        'montant' => 'money|required',
    ]);

    if (!$form->hasErrors())
    {
        try
        {
            if (is_null($type))
            {
                $id = $journal->add([
                    'libelle'       =>  f('libelle'),
                    'montant'       =>  f('montant'),
                    'date'          =>  f('date'),
                    'compte_credit' =>  f('compte_credit'),
                    'compte_debit'  =>  f('compte_debit'),
                    'numero_piece'  =>  f('numero_piece'),
                    'remarques'     =>  f('remarques'),
                    'id_auteur'     =>  $user->id,
                ]);
            }
            elseif ($type === 'virement')
            {
                $id = $journal->add([
                    'libelle'       =>  f('libelle'),
                    'montant'       =>  f('montant'),
                    'date'          =>  f('date'),
                    'compte_debit'  =>  f('compte1'),
                    'compte_credit' =>  f('compte2'),
                    'numero_piece'  =>  f('numero_piece'),
                    'remarques'     =>  f('remarques'),
                    'id_auteur'     =>  $user->id,
                ]);
            }
            else
            {










                $cat = $cats->get(f('categorie'));

                if (!$cat)
                {
                    throw new UserException('Il faut choisir une catégorie.');
                }

                if ($type == 'dette')







<
<
<
<
<
<
<
|
<
<













|












|














>
>
>
>
>
>
>
>
>
>
|







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
$journal = new Compta\Journal;

$journal->checkExercice();

$cats = new Compta\Categories;
$banques = new Compta\Comptes_Bancaires;








$type = f('type') ?: 'recette';



if (f('save'))
{
    $form->check('compta_saisie', [
        'libelle' => 'required',
        'date'    => 'date_format:Y-m-d|required',
        'montant' => 'money|required',
    ]);

    if (!$form->hasErrors())
    {
        try
        {
            if ($type == 'avance')
            {
                $id = $journal->add([
                    'libelle'       =>  f('libelle'),
                    'montant'       =>  f('montant'),
                    'date'          =>  f('date'),
                    'compte_credit' =>  f('compte_credit'),
                    'compte_debit'  =>  f('compte_debit'),
                    'numero_piece'  =>  f('numero_piece'),
                    'remarques'     =>  f('remarques'),
                    'id_auteur'     =>  $user->id,
                ]);
            }
            elseif ($type == 'virement')
            {
                $id = $journal->add([
                    'libelle'       =>  f('libelle'),
                    'montant'       =>  f('montant'),
                    'date'          =>  f('date'),
                    'compte_debit'  =>  f('compte1'),
                    'compte_credit' =>  f('compte2'),
                    'numero_piece'  =>  f('numero_piece'),
                    'remarques'     =>  f('remarques'),
                    'id_auteur'     =>  $user->id,
                ]);
            }
            else
            {
                if ($type == 'recette')
                {
                    $cat = 'categorie_recette';
                }
                else
                {
                    // Dette ou dépense
                    $cat = 'categorie_depense';
                }

                $cat = $cats->get(f($cat));

                if (!$cat)
                {
                    throw new UserException('Il faut choisir une catégorie.');
                }

                if ($type == 'dette')
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

165
166
167
168
169
170
171
172
173
174
                        }

                        $a = f('banque');
                        $b = $cat->compte;
                    }
                }

                if ($type === Compta\Categories::DEPENSES)
                {
                    $debit = $b;
                    $credit = $a;
                }
                elseif ($type === Compta\Categories::RECETTES)
                {
                    $debit = $a;
                    $credit = $b;
                }
                elseif ($type === 'dette')
                {
                    $debit = $cat->compte;
                    $credit = f('compte');
                }

                $id = $journal->add([
                    'libelle'       =>  f('libelle'),
                    'montant'       =>  f('montant'),
                    'date'          =>  f('date'),
                    'moyen_paiement'=>  ($type === 'dette') ? null : f('moyen_paiement'),
                    'numero_cheque' =>  ($type === 'dette') ? null : f('numero_cheque'),
                    'compte_credit' =>  $credit,
                    'compte_debit'  =>  $debit,
                    'numero_piece'  =>  f('numero_piece'),
                    'remarques'     =>  f('remarques'),
                    'id_categorie'  =>  ($type === 'dette') ? null : (int)$cat->id,
                    'id_auteur'     =>  $user->id,
                ]);
            }

            $session->sessionStore('compta_date', f('date'));

            if ($type == Compta\Categories::DEPENSES)
                $type = 'depense';
            elseif (is_null($type))
                $type = 'avance';
            elseif ($type == Compta\Categories::RECETTES)
                $type = 'recette';

            Utils::redirect('/admin/compta/operations/saisir.php?'.$type.'&ok='.(int)$id);
        }
        catch (UserException $e)
        {
            $form->addError($e->getMessage());
        }
    }
}

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

if ($type === null)
{
    $tpl->assign('comptes', $comptes->listTree());
}
else
{
    $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
    $tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
    $tpl->assign('categories', $cats->getList($type === 'dette' ? Compta\Categories::DEPENSES : $type));

    $tpl->assign('comptes_bancaires', $banques->getList());
    $tpl->assign('banque', f('banque'));
}

if (!$session->sessionGet('compta_date'))
{
    $exercices = new Compta\Exercices;
    $exercice = $exercices->getCurrent();

    if ($exercice->debut > time() || $exercice->fin < time())







|




|




|









|
|











<
<
<
<
<
<
<
|










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







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138







139
140
141
142
143
144
145
146
147
148
149


150



151
152
153
154
155
156

157
158
159
160
161
162
163
                        }

                        $a = f('banque');
                        $b = $cat->compte;
                    }
                }

                if ($type == 'depense')
                {
                    $debit = $b;
                    $credit = $a;
                }
                elseif ($type == 'recette')
                {
                    $debit = $a;
                    $credit = $b;
                }
                elseif ($type == 'dette')
                {
                    $debit = $cat->compte;
                    $credit = f('compte');
                }

                $id = $journal->add([
                    'libelle'       =>  f('libelle'),
                    'montant'       =>  f('montant'),
                    'date'          =>  f('date'),
                    'moyen_paiement'=>  ($type == 'dette') ? null : f('moyen_paiement'),
                    'numero_cheque' =>  ($type == 'dette') ? null : f('numero_cheque'),
                    'compte_credit' =>  $credit,
                    'compte_debit'  =>  $debit,
                    'numero_piece'  =>  f('numero_piece'),
                    'remarques'     =>  f('remarques'),
                    'id_categorie'  =>  ($type === 'dette') ? null : (int)$cat->id,
                    'id_auteur'     =>  $user->id,
                ]);
            }

            $session->sessionStore('compta_date', f('date'));








            Utils::redirect('/admin/compta/operations/saisir.php?ok='.(int)$id);
        }
        catch (UserException $e)
        {
            $form->addError($e->getMessage());
        }
    }
}

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



$tpl->assign('comptes', $comptes->listTree());



$tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
$tpl->assign('categories_depenses', $cats->getList(Compta\Categories::DEPENSES));
$tpl->assign('categories_recettes', $cats->getList(Compta\Categories::RECETTES));
$tpl->assign('comptes_bancaires', $banques->getList());
$tpl->assign('banque', f('banque'));


if (!$session->sessionGet('compta_date'))
{
    $exercices = new Compta\Exercices;
    $exercice = $exercices->getCurrent();

    if ($exercice->debut > time() || $exercice->fin < time())

Modified src/www/admin/static/admin.css from [86c6f363a9] to [e4ad1fd43c].

401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419




420
421
422
423
424
425
426
427
428
429

430
431
432
433
434
435
436
}

ul.actions li {
    display: inline-block;
    margin: 0 0.2em;
}

ul.actions li a {
    display: inline-block;
    background: rgb(217, 134, 40);
    background: rgba(217, 134, 40, .5);
    background: rgba(var(--gSecondColor), .5);
    border-radius: .5em .5em 0 0;
    padding: .1em .5em;
    color: #000;
    text-decoration: none;
}

ul.actions li.current a {




    background: #9c4f15;
    background: rgb(var(--gMainColor));
    color: #fff;
    color: rgb(var(--gBgColor));
}

ul.actions li a:hover {
    color: #fff;
    color: rgb(var(--gBgColor));
    text-decoration: underline;

}

h3.warning {
    margin: 1em;
    color: red;
}








|










|
>
>
>
>






|



>







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
}

ul.actions li {
    display: inline-block;
    margin: 0 0.2em;
}

ul.actions li a, ul.actions li label {
    display: inline-block;
    background: rgb(217, 134, 40);
    background: rgba(217, 134, 40, .5);
    background: rgba(var(--gSecondColor), .5);
    border-radius: .5em .5em 0 0;
    padding: .1em .5em;
    color: #000;
    text-decoration: none;
}

ul.actions li input {
    display: none;
}

ul.actions li.current a, ul.actions li input:checked + label {
    background: #9c4f15;
    background: rgb(var(--gMainColor));
    color: #fff;
    color: rgb(var(--gBgColor));
}

ul.actions li a:hover, ul.actions li label:hover {
    color: #fff;
    color: rgb(var(--gBgColor));
    text-decoration: underline;
    border-bottom: none;
}

h3.warning {
    margin: 1em;
    color: red;
}