2023-12-04 10:56:36 +01:00
|
|
|
{{#restrict section="accounting" level="write" block=true}}{{/restrict}}
|
2023-12-05 19:17:08 +01:00
|
|
|
{{:admin_header title="Entrée de matériel" current="module_equipment"}}
|
2023-10-17 12:55:19 +02:00
|
|
|
|
2023-12-05 19:17:08 +01:00
|
|
|
{{* barre de navigation *}}
|
|
|
|
{{if ! $dialog}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:include file="../../_nav.html" current="entrees"}}
|
2023-11-01 16:53:20 +01:00
|
|
|
{{/if}}
|
2023-10-17 12:55:19 +02:00
|
|
|
|
2023-11-30 18:14:46 +01:00
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
2023-12-05 10:07:01 +01:00
|
|
|
{{:include file="../../_get_config.html" keep="config"}}
|
2023-11-30 18:14:46 +01:00
|
|
|
|
2023-10-17 12:55:19 +02:00
|
|
|
{{* types d'entrées *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{#foreach from=$config.input_nature key="label" item="type"}}
|
|
|
|
{{if $type != 'retour'}}
|
|
|
|
{{:assign var='input_labels.' value="%s"|args:$label}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2023-10-26 10:04:45 +02:00
|
|
|
{{/foreach}}
|
2023-10-17 12:55:19 +02:00
|
|
|
|
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
|
|
{{#form on="save"}}
|
2023-12-07 17:33:49 +01:00
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* récupérer les infos du matériel *}}
|
|
|
|
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
{{* Enregistrer le mouvement *}}
|
|
|
|
{{:assign mvt_key=""|uuid}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:assign var="operation" from="input_labels.%d|args:$_POST.type_operation}}
|
2023-12-06 09:59:11 +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
|
|
|
|
}}
|
|
|
|
|
|
|
|
{{:redirect force="index.html?ok=1&msg=entrée"}}
|
2023-10-17 12:55:19 +02:00
|
|
|
{{else}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:form_errors}}
|
2023-10-17 12:55:19 +02:00
|
|
|
{{/form}}
|
|
|
|
|
|
|
|
{{* lister les catégories et matériels associés *}}
|
|
|
|
{{#load type="category" assign="category" order="$$.name"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign nom_cat=$category.name}}
|
|
|
|
{{#load type="equipment" where="$$.category = :key" :key=$category.key assign="equipment"}}
|
|
|
|
{{:assign var="equipments.%s.%s"|args:$nom_cat:$equipment.key value=$equipment.designation}}
|
|
|
|
{{/load}}
|
2023-10-17 12:55:19 +02:00
|
|
|
{{/load}}
|
|
|
|
|
2023-10-27 11:20:22 +02:00
|
|
|
{{* Vérifier s'il y a au moins un matériel enregistré *}}
|
2023-11-30 18:14:46 +01:00
|
|
|
{{if $equipments != null}}
|
2023-10-27 11:20:22 +02:00
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* formulaire d'entrée de matériel *}}
|
|
|
|
|
|
|
|
<form method="post" action="">
|
|
|
|
<fieldset class="entree">
|
|
|
|
<legend>Ajouter une entrée d'un matériel répertorié</legend>
|
|
|
|
<dl>
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{: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_groups" name="equipment" label="Matériel" required=true options=$equipments}}
|
|
|
|
{{: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>
|
2023-11-30 18:14:46 +01:00
|
|
|
{{else}}
|
2023-12-06 09:59:11 +01:00
|
|
|
<p class="block error">Il n'y a aucun matériel</p>
|
2023-11-30 18:14:46 +01:00
|
|
|
{{/if}}
|
2023-10-21 10:58:33 +02:00
|
|
|
|
2023-10-17 12:55:19 +02:00
|
|
|
{{:admin_footer}}
|