Immo non amorties : modifier infos
This commit is contained in:
parent
4f1be445ff
commit
11be1386c2
@ -58,8 +58,8 @@
|
||||
<td>{{$project_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Ajouter infos"
|
||||
href="add_duration.html?immo_id=%s&amort=0"|args:$immo_id
|
||||
label="Modifier infos"
|
||||
href="modif_infos.html?immo_id=%s&amort=0"|args:$immo_id
|
||||
shape="help"
|
||||
target="_dialog"
|
||||
}}
|
||||
|
108
modif_infos.html
Normal file
108
modif_infos.html
Normal file
@ -0,0 +1,108 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:admin_header title="Modifier informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="change"}}
|
||||
|
||||
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
||||
{{#select
|
||||
trans.date as date_achat
|
||||
from acc_transactions_lines as line
|
||||
inner join acc_transactions as trans on line.id_transaction = trans.id
|
||||
where line.id = :line_id;
|
||||
:line_id = $immo_id
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{if $_POST.no_amort}}
|
||||
{{* ne pas amortir *}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||
{{:assign noamort=true}}
|
||||
{{else}}
|
||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
||||
{{:assign date_debut=$_POST.date_mes|or:$ligne_immo.date_achat|parse_date}}
|
||||
{{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}}
|
||||
{{:assign dd=$date_debut|date_short}}
|
||||
{{:assign da=$ligne_immo.date_achat|date_short}}
|
||||
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
||||
{{/if}}
|
||||
{{:assign duration=$_POST.duree|intval}}
|
||||
{{:assign noamort=false}}
|
||||
{{/if}}
|
||||
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||
{{:assign key=$key}}
|
||||
{{/load}}
|
||||
{{* enregistrer les infos modifiées de l'immobilisation *}}
|
||||
{{*:assign key=""|uuid*}}
|
||||
{{:save
|
||||
key=$key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$immo_id
|
||||
duration=$duration
|
||||
date=$date_debut
|
||||
noamort=$noamort
|
||||
}}
|
||||
|
||||
{{if $_POST.no_amort}}
|
||||
{{:assign amort=0}}
|
||||
{{else}}
|
||||
{{:assign amort=1}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/form}}
|
||||
|
||||
{{* renseigner la date de mise en service et durée d'amortissement *}}
|
||||
{{if $_GET.amort == 0}}
|
||||
{{:assign checked=1}}
|
||||
{{:assign disabled=1}}
|
||||
{{else}}
|
||||
{{:assign checked=0}}
|
||||
{{:assign disabled=0}}
|
||||
{{/if}}
|
||||
<form method="post" action="">
|
||||
<fieldset id="infos_immo">
|
||||
<legend></legend>
|
||||
<dl>
|
||||
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 disabled=$disabled}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="change" label="Modifier" shape="right" class="main"}}
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
||||
{{* activer/désactiver les champs de saisie *}}
|
||||
<script type="text/javascript">
|
||||
function toggleInputs(idfs, idcb) {
|
||||
const noamort = document.getElementById(idcb);
|
||||
const fs = document.getElementById(idfs);
|
||||
for (let field of fs.querySelectorAll("input")) {
|
||||
if (field == noamort) { continue }
|
||||
if (noamort.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
Loading…
Reference in New Issue
Block a user