2024-11-08 19:49:23 +01:00
|
|
|
{{* -*- brindille -*- *}}
|
|
|
|
|
|
|
|
{{*
|
|
|
|
Ajouter une entrée de matériel
|
|
|
|
paramètres :
|
|
|
|
- key : clé du matériel à ajouter
|
|
|
|
*}}
|
|
|
|
|
|
|
|
|
|
|
|
{{: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 key="label" item="type"}}
|
|
|
|
{{if $type != 'retour'}}
|
|
|
|
{{:assign var='input_labels.' value="%s"|args:$label}}
|
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
|
|
|
|
{{* récupérer les informations du matériel et de sa catégorie *}}
|
|
|
|
{{#load key=$_GET.key assign="equipment"}}
|
|
|
|
{{/load}}
|
|
|
|
{{#load where="key = :key" :key=$equipment.category assign="category"}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
|
|
{{#form on="save"}}
|
2024-12-02 09:33:02 +01:00
|
|
|
|
|
|
|
{{* vérifier la quantité saisie *}}
|
|
|
|
{{if $_POST.quantite <= 0}}
|
|
|
|
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.quantite}}
|
|
|
|
{{/if}}
|
|
|
|
|
2024-11-08 19:49:23 +01:00
|
|
|
{{* Enregistrer le mouvement *}}
|
|
|
|
{{:assign mvt_key=""|uuid}}
|
2024-11-19 15:18:51 +01:00
|
|
|
{{:assign var="operation" from="input_labels.%d|args:$_POST.nature_operation}}
|
2024-11-08 19:49:23 +01:00
|
|
|
|
|
|
|
{{: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
|
|
|
|
}}
|
2024-11-19 15:18:51 +01:00
|
|
|
{{:assign var=type_entree from="config.input_nature.%s"|args:$operation}}
|
|
|
|
{{if $type_entree == "temporaire"}}
|
|
|
|
{{:assign prop=0}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign prop=1}}
|
|
|
|
{{/if}}
|
2024-12-02 10:47:38 +01:00
|
|
|
{{:redirect force="../../index.html?ok=1&msg=entrée&prop=%s"|args:$prop}}
|
2024-11-08 19:49:23 +01:00
|
|
|
{{else}}
|
|
|
|
{{:form_errors}}
|
|
|
|
{{/form}}
|
|
|
|
|
|
|
|
|
|
|
|
{{* formulaire de saisie d'une entrée de matériel *}}
|
|
|
|
<form method="post" action="">
|
|
|
|
<fieldset class="entree">
|
2024-11-11 14:23:58 +01:00
|
|
|
<legend>Ajouter une entrée de matériel</legend>
|
2024-11-08 19:49:23 +01:00
|
|
|
<dl>
|
2024-11-19 15:18:51 +01:00
|
|
|
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels}}
|
2024-11-08 19:49:23 +01:00
|
|
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
|
|
|
{{:input type="text" name="equipment" label="Matériel" required=true disabled=true default=$equipment.designation}}
|
2024-11-12 16:54:56 +01:00
|
|
|
{{:input type="text" name="category" label="Catégorie" required=true disabled=true default=$category.name}}
|
2024-11-11 14:23:58 +01:00
|
|
|
{{:input type="number" name="quantite" label="Quantité" required=true min=1 default=1}}
|
2024-11-08 19:49:23 +01:00
|
|
|
{{: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}}
|