facturation/templates/facture_modifier.tpl

192 lines
7.2 KiB
Smarty

{include file="admin/_head.tpl" title="Modifier un document — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=1}
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
{form_errors}
<style>
{literal}
#Line1 > .fact_rm_line {
display: none;
}
{{/literal}}
</style>
{form_errors}
<form method="post" action="{$self_url}">
<ul class="actions">
<li><input type="radio" name="type" value="facture" {form_field name=type checked=facture default=facture} id="f_type_facture"{if $type !== "devis"} checked="checked"{/if}/><label for="f_type_facture">Facture</label></li>
<li><input type="radio" name="type" value="devis" {form_field name=type checked=devis} id="f_type_devis" {if $type == "devis"} checked="checked"{/if}/><label for="f_type_devis">Devis</label></li>
</ul>
<fieldset>
<legend>Créer une facture</legend>
<dl>
<dt><label for="f_numero_facture">Numéro facture</label> <b title="(Champ obligatoire et unique)">obligatoire et unique</b></dt>
<dd><input type="numero" name="numero_facture" maxlength="12" id="f_numero_facture" value="{$numero_facture}"/></dd>
<p>Chaque facture doit comporter un numéro unique délivré chronologiquement et de façon continue.<br>Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro. </p>
<br>
<dt><label for="f_date_emission">Date d'émission</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="date" name="date_emission" id="f_date_emission" size="10" required="required" value="{$date_emission|date_fr:'Y-m-d'}"/></dd>
<dt><label for="f_date_echeance">Date d'échéance</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="date" name="date_echeance" id="f_date_echeance" size="10" required="required" value="{$date_echeance|date_fr:'Y-m-d'}"/></dd>
<dt><label for="f_reglee">Réglée</label></dt>
<dd><input type="checkbox" name="reglee" id="f_reglee"{if $reglee == "on"} checked="checked"{/if}></dd>
<dt><label for="f_archivee">Archivée</label></dt>
<dd><input type="checkbox" name="archivee" id="f_archivee" disabled></dd>
</dl>
</fieldset>
<fieldset>
<legend>Client</legend>
<dl>
<dt><label>Facture adressée à un·e :</label></dt>
<dd>
<input type="radio" name="base_receveur" value="membre" id="f_base_membre"{if $base_receveur == "membre"} checked="checked"{/if}/><label for="f_base_membre"> Membre</label>
<input type="radio" name="base_receveur" value="client" id="f_base_client" {if $base_receveur !== "membre"} checked="checked"{/if}/><label for="f_base_client"> Client·e</label>
</dd>
<dt><label>Client</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd>
<select class="type_membre" name="membre" id="f_membre" required="required">
{foreach from=$membres item="membre"}
<option value="{$membre.id}"{if $membre.id == $membre_id} selected="selected"{/if}>{$membre.nom}</option>
{/foreach}
</select>
<select class="type_client" name="client" id="f_client" required="required">
{foreach from=$clients item="client"}
<option value="{$client.id}"{if $client.id == $client_id} selected="selected"{/if}>{$client.nom}</option>
{/foreach}
</select>
</dd>
</dl>
</fieldset>
<fieldset>
<legend>Contenu</legend>
<dl>
<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><label for="f_contenu">Contenu du document</label><dt>
<dd>
<table class="list" style="max-width: 800px;">
<colgroup>
<col width="65%">
<col width="33%">
<col width="2%">
</colgroup>
<thead>
<tr>
<td>Désignation</td>
<td>Prix</td>
<td></td>
</tr>
</thead>
<tbody id="Lines">
{if count($designations) > 0}
<tr id="Line1" class="hidden">
<td><textarea name="designation[]" style="width:98%;"></textarea></td>
<td><input type="number" step="0.01" value="0" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
</tr>
{foreach from=$designations item=designation key=key}
<tr>
<td><textarea name="designation[]" style="width:98%;">{$designation}</textarea></td>
<td><input type="number" step="0.01" value="{$prix[$key]}" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
</tr>
{/foreach}
{else}
<tr id="Line1">
<td><textarea name="designation[]" style="width:98%;"></textarea></td>
<td><input type="number" step="0.01" value="0" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
</tr>
{/if}
</tbody>
<tfoot>
<tr>
<td style="text-align: right;">Total :</td>
<td><span id="total">0.00</span> €</td>
<td></td>
</tr>
</tfoot>
</table>
<button type="button" id="ajouter_ligne">Ajouter une ligne</button>
</dd>
</dl>
</fieldset>
<script type="text/javascript">
{literal}
function updateSum(){
var total = 0;
e = document.querySelectorAll('input[name="prix[]"]');
e.forEach( function sum(item, index){
total = total + Number(item.value);
});
document.getElementById('total').innerHTML = total.toFixed(2);
}
updateSum();
(function () {
function plus(){
var newdiv = document.createElement('tr');
newdiv.innerHTML = document.getElementById('Line1').innerHTML;
document.getElementById('Lines').appendChild(newdiv);
}
plus();
$('#ajouter_ligne').onclick = plus;
function changeTypeSaisie(type)
{
g.toggle(['.type_client', '.type_membre'], false);
g.toggle('.type_' + type, true);
}
changeTypeSaisie(document.forms[0].base_receveur.value);
var inputs = $('input[name="base_receveur"]');
for (var i = 0; i < inputs.length; i++)
{
inputs[i].onchange = function (e) {
changeTypeSaisie(this.value);
};
}
} ());
{/literal}
</script>
<p class="submit">
{csrf_field key="modifier_facture"}
<input type="submit" name="save" value="Enregistrer &rarr;" />
</p>
</form>
{include file="admin/_foot.tpl"}