</p>
{/if}
+{if $debug}
+ <p class="debug">
+ {$debug|escape}
+ </p>
+{/if}
+
{if $ok}
<p class="confirm">
L'opération numéro <a href="{$www_url}admin/compta/operations/voir.php?id={$ok|escape}">{$ok|escape}</a> a été ajoutée.
<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|escape}</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>
+ <fieldset id="fluxs">
+ <legend>Flux <b title="(Champ obligatoire)">obligatoire</b></legend>
+ <table>
+ <thead>
+ <tr>
+ <th><label for="f_compte">Compte</label></th>
+ <th><label for="f_montant">Montant<br /><b title="">crédit < 0 < débit</b></label></th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$fluxs item="flux" key="flux_n" name="fluxs"}
+ <tr>
+ <td class="compte">{select_compte comptes=$comptes name="compte" form_name="compte_$flux_n" id="f_compte_$flux_n" data=$flux}</td>
+ {if !$tpl.foreach.fluxs.last}
+ <td class="montant"><input type="number" size="5" name="montant_{$flux_n}" id="f_montant_{$flux_n}"
+ value="{form_field name="montant" data=$flux}"
+ min="0.00" step="0.01" required="required"
+ /> {$config.monnaie|escape}</td>
+ {/if}
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </fieldset>
{elseif $type === 'virement'}
<dt><label for="f_compte1">Compte débité</label></dt>
<dd>
</dl>
</fieldset>
-{if $type == Garradin\Compta_Categories::DEPENSES || $type == Garradin\Compta_Categories::RECETTES || $type == 'dette'}
+{if is_null($type)}
+ <script type="text/javascript">
+ {literal}
+ (function () {
+ if (!document.querySelector || !document.querySelectorAll)
+ {
+ return false;
+ }
+ fluxs = document.querySelector('#fluxs');
+ if (fluxs)
+ {
+ var fluxs = fluxs.querySelectorAll('#fluxs > table > tbody > tr');
+ var fluxs_nb = fluxs.length;
+
+ var add = document.createElement('input');
+ add.type = 'button';
+ add.className = 'icn add';
+ add.value = '+';
+ add.title = 'Ajouter un flux';
+ add.onclick = function (e) {
+ var p = this.parentNode.parentNode; // tbody
+ var fluxs = p.querySelectorAll('tr'); // tr
+ var fluxs_nb = fluxs.length;
+
+ // Add new last flux
+ var new_flux = this.parentNode.cloneNode(true); // tr
+ var new_compte = new_flux.querySelector('.compte');
+ new_compte.querySelector('select').id = 'f_compte_'+fluxs_nb;
+ new_compte.querySelector('select').name = 'compte_'+fluxs_nb;
+ p.appendChild(new_flux);
+
+ // Add a montant to old last flux
+ var new_montant = fluxs[0].querySelector('.montant').cloneNode(true);
+ new_montant.querySelector('input').id = 'f_montant_'+(fluxs_nb - 1);
+ new_montant.querySelector('input').name = 'montant_'+(fluxs_nb - 1);
+ new_montant.querySelector('input').value = '0';
+ this.parentNode.appendChild(new_montant);
+ this.parentNode.removeChild(this);
+
+ // Register this callback on new flux
+ var btn = new_flux.querySelector('input.add');
+ btn.onclick = this.onclick;
+ };
+
+ fluxs[fluxs_nb - 1].appendChild(add);
+ }
+ }());
+ {/literal}
+ </script>
+{elseif $type == Garradin\Compta_Categories::DEPENSES || $type == Garradin\Compta_Categories::RECETTES || $type == 'dette'}
<fieldset>
<legend>Catégorie</legend>
<dl class="catList">
</form>
-{include file="admin/_foot.tpl"}
\ No newline at end of file
+{include file="admin/_foot.tpl"}