Ajout : ./garradin
[garradin.git] / templates / admin / compta / operations / modifier.tpl
1 {include file="admin/_head.tpl" title="Modification de l'opération n°`$operation.id`" current="compta/saisie" js=1}
2
3 {if $error}
4 <p class="error">
5 {$error|escape}
6 </p>
7 {/if}
8
9 {if $debug}
10 <p class="debug">
11 {$debug|escape}
12 </p>
13 {/if}
14
15 <form method="post" action="{$self_url|escape}">
16
17 <fieldset>
18 <legend>Informations sur l'opération</legend>
19 <dl>
20 <dt><label for="f_date">Date</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
21 <dd><input type="date" name="date" id="f_date" value="{form_field name=date default=$operation.date|date_fr:'Y-m-d'}" size="10" required="required" /></dd>
22 <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
23 <dd><input type="text" name="libelle" id="f_libelle" value="{form_field name=libelle data=$operation}" required="required" /></dd>
24
25 {if is_null($type)}
26 <fieldset id="fluxs">
27 <legend>Flux <b title="(Champ obligatoire)">obligatoire</b></legend>
28 <table>
29 <thead>
30 <tr>
31 <th><label for="f_compte">Compte</label></th>
32 <th><label for="f_montant">Montant<br /><b title="">crédit &lt; 0 &lt; débit</b></label></th>
33 </tr>
34 </thead>
35 <tbody>
36 {foreach from=$fluxs item="flux" key="flux_n" name="fluxs"}
37 <tr>
38 <td class="compte">{select_compte comptes=$comptes name="compte" form_name="compte_$flux_n" id="f_compte_$flux_n" data=$flux}</td>
39 {if !$tpl.foreach.fluxs.last}
40 <td class="montant"><input type="number" size="5" name="montant_{$flux_n}" id="f_montant_{$flux_n}"
41 value="{form_field name="montant" data=$flux}"
42 min="0.00" step="0.01" required="required"
43 /> {$config.monnaie|escape}</td>
44 {/if}
45 </tr>
46 {/foreach}
47 </tbody>
48 </table>
49 </fieldset>
50 {else}
51 <dt><label for="f_moyen_paiement">Moyen de paiement</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
52 <dd>
53 <select name="moyen_paiement" id="f_moyen_paiement">
54 {foreach from=$moyens_paiement item="moyen"}
55 <option value="{$moyen.code|escape}"{if $moyen.code == $operation.moyen_paiement} selected="selected"{/if}>{$moyen.nom|escape}</option>
56 {/foreach}
57 </select>
58 </dd>
59 <dt class="f_cheque"><label for="f_numero_cheque">Numéro de chèque</label></dt>
60 <dd class="f_cheque"><input type="text" name="numero_cheque" id="f_numero_cheque" value="{form_field name=numero_cheque data=$operation}" /></dd>
61 <dt class="f_banque"><label for="f_banque">Compte bancaire</label></dt>
62 <dd class="f_banque">
63 <select name="banque" id="f_banque">
64 {foreach from=$comptes_bancaires item="compte"}
65 <option value="{$compte.id|escape}"{if ($type == Garradin\Compta_Categories::DEPENSES && $compte.id == $operation.compte_credit) || $compte.id == $operation.compte_debit} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
66 {/foreach}
67 </select>
68 </dd>
69 {/if}
70
71 <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>
72 <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece data=$operation}" /></dd>
73 <dt><label for="f_remarques">Remarques</label></dt>
74 <dd><textarea name="remarques" id="f_remarques" rows="4" cols="30">{form_field name=remarques data=$operation}</textarea></dd>
75 </dl>
76 </fieldset>
77
78 {if is_null($type)}
79 <script type="text/javascript">
80 {literal}
81 (function () {
82 if (!document.querySelector || !document.querySelectorAll)
83 {
84 return false;
85 }
86 fluxs = document.querySelector('#fluxs');
87 if (fluxs)
88 {
89 var fluxs = fluxs.querySelectorAll('#fluxs > table > tbody > tr');
90 var fluxs_nb = fluxs.length;
91
92 var add = document.createElement('input');
93 add.type = 'button';
94 add.className = 'icn add';
95 add.value = '+';
96 add.title = 'Ajouter un flux';
97 add.onclick = function (e) {
98 var p = this.parentNode.parentNode; // tbody
99 var fluxs = p.querySelectorAll('tr'); // tr
100 var fluxs_nb = fluxs.length;
101
102 // Add new last flux
103 var new_flux = this.parentNode.cloneNode(true); // tr
104 var new_compte = new_flux.querySelector('.compte');
105 new_compte.querySelector('select').id = 'f_compte_'+fluxs_nb;
106 new_compte.querySelector('select').name = 'compte_'+fluxs_nb;
107 p.appendChild(new_flux);
108
109 // Add a montant to old last flux
110 var new_montant = fluxs[0].querySelector('.montant').cloneNode(true);
111 new_montant.querySelector('input').id = 'f_montant_'+(fluxs_nb - 1);
112 new_montant.querySelector('input').name = 'montant_'+(fluxs_nb - 1);
113 new_montant.querySelector('input').value = '0';
114 this.parentNode.appendChild(new_montant);
115 this.parentNode.removeChild(this);
116
117 // Register this callback on new flux
118 var btn = new_flux.querySelector('input.add');
119 btn.onclick = this.onclick;
120 };
121
122 fluxs[fluxs_nb - 1].appendChild(add);
123 }
124 }());
125 {/literal}
126 </script>
127 {else}
128 <fieldset>
129 <legend>Catégorie</legend>
130 <dl class="catList">
131 {foreach from=$categories item="cat"}
132 <dt>
133 <input type="radio" name="id_categorie" value="{$cat.id|escape}" id="f_cat_{$cat.id|escape}" {form_field name="id_categorie" checked=$cat.id data=$operation} />
134 <label for="f_cat_{$cat.id|escape}">{$cat.intitule|escape}</label>
135 </dt>
136 {if !empty($cat.description)}
137 <dd class="desc">{$cat.description|escape}</dd>
138 {/if}
139 {/foreach}
140 </dl>
141 </fieldset>
142
143 <script type="text/javascript">
144 {literal}
145 (function () {
146
147 window.changeMoyenPaiement = function()
148 {
149 var elm = $('#f_moyen_paiement');
150 toggleElementVisibility('.f_cheque', elm.value == 'CH');
151 toggleElementVisibility('.f_banque', elm.value != 'ES');
152 };
153
154 changeMoyenPaiement();
155
156 $('#f_moyen_paiement').onchange = changeMoyenPaiement;
157 } ());
158 {/literal}
159 </script>
160 {/if}
161
162 <p class="submit">
163 {csrf_field key="compta_modifier_`$operation.id`"}
164 <input type="submit" name="save" value="Enregistrer &rarr;" />
165 </p>
166
167 </form>
168
169 {include file="admin/_foot.tpl"}