{{if $module.config.disable_input}} {{:redirect to="stats.html"}} {{/if}} {{if $_GET.type === 'exit'}} {{:assign type="exit"}} {{else}} {{:assign type="entry"}} {{/if}} {{:include file="./_init.tpl"}} {{#load type="category" order="$$.label COLLATE U_NOCASE" target=$type}} {{:assign var="categories."|cat:$key label=$label ecologic=$ecologic}} {{/load}} {{#load type="object" order="$$.label COLLATE U_NOCASE" target=$type}} {{:assign var="objects."|cat:$key label=$label weight=$weight}} {{/load}} {{#form on="save"}} {{:assign var="rows" value=$_POST.new|array_transpose}} {{if !$rows|count}} {{:error message="Aucune ligne fournie"}} {{/if}} {{#foreach from=$rows item="row"}} {{:assign weight=$row.weight|weightval}} {{:assign total="%d*%d"|math:$weight:$row.qty}} {{:assign var="category" from="categories.%s"|args:$row.category}} {{:assign var="object" from="objects.%s"|args:$row.object}} {{if !$category}} {{:error message="La catégorie ne peut rester vide."}} {{elseif !$object}} {{:error message="Le type d'objet ne peut rester vide."}} {{elseif $total <= 0}} {{:error message="Le poids ou la quantité sont invalides."}} {{/if}} {{if $type === "entry"}} {{:save key="uuid" validate_schema="./entry.schema.json" type=$type object=$object.label category=$category.label ecologic=$category.ecologic weight=$weight qty=$row.qty|intval total_weight=$total date=$now|date:'Y-m-d H:i:s' }} {{else}} {{:save key="uuid" validate_schema="./exit.schema.json" type=$type object=$object.label category=$category.label ecologic=$category.ecologic weight=$weight qty=$row.qty|intval total_weight=$total date=$now|date:'Y-m-d H:i:s' }} {{/if}} {{/foreach}} {{:redirect to="./?saved=1"}} {{/form}} {{:admin_header title="Saisie au poids" current="module_saisie_poids"}} {{:include file="_nav.html" current=$type}} {{if $_GET.saved}}
La saisie a été enregistrée.
{{/if}} {{:form_errors}} {{if !$_POST}} {{:assign var="rows." weight=0}} {{/if}} {{if !$objects|count}}Aucun type d'objet n'a été configuré.
{{elseif !$categories|count}}Aucune catégorie n'a été configurée.
{{else}} {{/if}} {{:admin_footer}}