98 lines
3.0 KiB
HTML
98 lines
3.0 KiB
HTML
{{#restrict section="accounting" level="write" block=true}}{{/restrict}}
|
|
{{:admin_header title="Entrée de matériel" current="module_equipment"}}
|
|
|
|
{{* barre de navigation *}}
|
|
{{if ! $dialog}}
|
|
{{:include file="../../_nav.html" current="entrees"}}
|
|
{{/if}}
|
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
|
{{:include file="../../_get_config.html" keep="config"}}
|
|
|
|
{{* types d'entrées *}}
|
|
{{#foreach from=$config.input_nature item="elem"}}
|
|
{{if $elem.type != 'retour'}}
|
|
{{:assign var='input_types.' value="%s"|args:$elem.label}}
|
|
{{/if}}
|
|
{{/foreach}}
|
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
{{#form on="save"}}
|
|
|
|
{{* récupérer les infos de la catégorie *}}
|
|
{{#load type="category" key=$_POST.category assign="category"}}
|
|
{{/load}}
|
|
|
|
{{* vérifier l'existence d'un matériel du même nom *}}
|
|
{{#load type="equipment" where="lower($$.designation) = :name" :name=$_POST.designation|trim|tolower}}
|
|
{{* utiliser la clé du matériel trouvé *}}
|
|
{{:assign equipment_key=$key}}
|
|
{{else}}
|
|
{{* nouveau matériel => nouvelle clé *}}
|
|
{{:assign equipment_key=""|uuid}}
|
|
|
|
{{* enregistrer un nouveau matériel *}}
|
|
{{:save
|
|
key=$equipment_key
|
|
validate_schema="../../equipment.schema.json"
|
|
type="equipment"
|
|
category=$category.key
|
|
designation=$_POST.designation|trim
|
|
}}
|
|
{{/load}}
|
|
|
|
{{* Enregistrer le mouvement *}}
|
|
{{:assign mvt_key=""|uuid}}
|
|
{{:assign var="operation" from="input_types.%d"|args:$_POST.type_operation}}
|
|
|
|
{{:save
|
|
key=$mvt_key
|
|
validate_schema="../movement.schema.json"
|
|
type="movement"
|
|
direction="input"
|
|
input_nature=$operation
|
|
amount=$_POST.quantite|intval
|
|
equipment=$equipment_key
|
|
date=$_POST.date|parse_date
|
|
comment=$_POST.remarques|trim
|
|
}}
|
|
|
|
{{:redirect force="index.html?ok=1&msg=entrée"}}
|
|
{{else}}
|
|
{{:form_errors}}
|
|
{{/form}}
|
|
|
|
{{* lister les catégories disponibles *}}
|
|
{{#load type="category" assign="category" order="$$.name"}}
|
|
{{* :assign var="categories.%d"|args:$category.id value=$category.name *}}
|
|
{{:assign var="categories.%s"|args:$category.key value=$category.name}}
|
|
{{/load}}
|
|
|
|
{{* formulaire d'ajout de matériel *}}
|
|
<form method="post" action="">
|
|
|
|
<fieldset class="entree">
|
|
<legend>Ajouter une entrée d'un matériel non répertorié</legend>
|
|
<dl>
|
|
{{:input type="select" name="type_operation" label="Type" required=true options=$input_types}}
|
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
|
{{:input type="number" name="quantite" label="Quantité" required=true default=1}}
|
|
</dl>
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
<legend>Matériel</legend>
|
|
<dl>
|
|
{{:input type="select" name="category" label="Catégorie" required=true options=$categories}}
|
|
{{:input type="text" name="designation" label="Désignation" required=true}}
|
|
{{:input type="textarea" name="remarques" label="Remarques" cols="40", rows="3" required=false}}
|
|
</dl>
|
|
</fieldset>
|
|
|
|
<p class="submit">
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
|
</p>
|
|
|
|
</form>
|
|
{{:admin_footer}}
|