{{#load assign="claim" key=$_GET.claim}} {{else}} {{:error message="Cette note de frais n'existe pas"}} {{/load}} {{#restrict section="accounting" level="write"}} {{:assign is_admin=true}} {{else}} {{:assign is_admin=false}} {{/restrict}} {{#form on="save"}} {{#load select="MAX($$.number) AS number" type="claim" assign="max"}} {{/load}} {{:assign new_number="%d+1"|math:$max.number}} {{:assign new_key=""|uuid}} {{if $is_admin}} {{#foreach from=$_POST.user key="id" item="name"}} {{:assign user_id=$id user_name=$name}} {{else}} {{:error message="Aucun membre sélectionné"}} {{/foreach}} {{else}} {{:assign user_id=$logged_user.id user_name=$logged_user._name}} {{/if}} {{:save validate_schema="./claim.schema.json" key=$new_key number=$new_number type="claim" label=$_POST.label|trim|or:null date=$now|date_format:"%Y-%m-%d" user_id=$user_id user_name=$user_name status="draft" }} {{#load type="line" claim=$claim.key}} {{:save validate_schema="./line.schema.json" key="uuid" type="line" claim=$new_key label=$label category=$category account=$account|strval|or:null description=$description amount=$amount reference=$reference date=$date id_project=$id_project }} {{/load}} {{:redirect to="./details.html?key=%s"|args:$new_key}} {{/form}} {{:admin_header title="Dupliquer une note de frais"}} {{:form_errors}}
{{:admin_footer}}