119 lines
4.4 KiB
HTML
119 lines
4.4 KiB
HTML
|
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
|
||
|
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
|
||
|
|
||
|
{{if $_GET.dialog === null}}
|
||
|
{{* barre de navigation *}}
|
||
|
{{:include file="/%s/_nav.html"|args:$module.name current="entrees"}}
|
||
|
{{else}}
|
||
|
<header class="header">
|
||
|
<h1>Entrée de matériel</h1>
|
||
|
</header>
|
||
|
{{/if}}
|
||
|
|
||
|
{{* types d'entrées *}}
|
||
|
{{#foreach from=$module.config.inputNature item="elem"}}
|
||
|
{{if $elem.type == 'retour'}}
|
||
|
{{:assign var='types_entrees.' value="%s"|args:$elem.label}}
|
||
|
{{/if}}
|
||
|
{{/foreach}}
|
||
|
|
||
|
{{* Traiter l'envoi du formulaire *}}
|
||
|
{{#form on="save"}}
|
||
|
{{* récupérer les infos du matériel *}}
|
||
|
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
||
|
{{:assign designation=$equipment.designation}}
|
||
|
{{:assign var="categories." value=$equipment.category}}
|
||
|
{{/load}}
|
||
|
{{:assign date=$_POST.date|parse_date}}
|
||
|
|
||
|
{{* Extraire et compiler les infos de la base *}}
|
||
|
{{:include file="/%s/_calcul_dispo.html"|args:$module.name keep="equipments"}}
|
||
|
|
||
|
{{* déterminer la quantité sortie temporairement de ce matriel à la date donnée *}}
|
||
|
{{:assign var=sorti from="equipments.%s.eqpmt.%s.exterieur"|args:$equipment.category:$_POST.equipment}}
|
||
|
|
||
|
{{if $_POST.quantite|intval > $sorti}}
|
||
|
{{:error message="Erreur : la quantité indiquée (%s) est supérieure à celle sortie (%d) à la date du %s"|args:$_POST.quantite:$sorti:$_POST.date}}
|
||
|
{{/if}}
|
||
|
|
||
|
{{* Enregistrer le mouvement *}}
|
||
|
{{:assign mvt_key=""|uuid}}
|
||
|
{{:assign var="operation" from="types_entrees.%d|args:$_POST.type_operation}}
|
||
|
|
||
|
{{:save
|
||
|
key=$mvt_key
|
||
|
validate_schema="/%s/mouvements/movement.schema.json"|args:$module.name
|
||
|
type="movement"
|
||
|
direction="entrée"
|
||
|
inputNature=$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 de « %s » enregistrée"|args:$equipment.designation}}
|
||
|
{{else}}
|
||
|
{{:form_errors}}
|
||
|
{{/form}}
|
||
|
|
||
|
{{* Extraire et compiler les infos de la base *}}
|
||
|
{{:include file="/%s/_calcul_dispo.html"|args:$module.name keep="equipments"}}
|
||
|
|
||
|
{{* déterminer la quantité des matériels sortis temporairement *}}
|
||
|
{{#foreach from=$equipments key="cat_key" item="category"}}
|
||
|
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||
|
{{:assign quantite=$eqpmt.exterieur}}
|
||
|
{{if $quantite != 0}}
|
||
|
{{:assign
|
||
|
var="temporaire.%s.%s"|args:$category.name:$eqpmt_key
|
||
|
value="%s (quantité : %d)"|args:$eqpmt.designation:$quantite
|
||
|
}}
|
||
|
{{/if}}
|
||
|
{{/foreach}}
|
||
|
{{/foreach}}
|
||
|
{{if $temporaire === null}}
|
||
|
{{:error message="Le matériel choisi (%s) n'est pas sorti à la date du %s"|args:$designation:$_POST.date}}
|
||
|
{{/if}}
|
||
|
|
||
|
{{* lister les catégories et matériels associés *}}
|
||
|
{{*
|
||
|
{{#load type="category" assign="category" order="$$.name"}}
|
||
|
{{: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}}
|
||
|
{{/load}}
|
||
|
*}}
|
||
|
|
||
|
{{* Vérifier s'il y a au moins un matériel enregistré *}}
|
||
|
{{*
|
||
|
{{if $equipments|count == 0}}
|
||
|
{{:error message="Erreur : il n'y a aucun matériel"}}
|
||
|
{{/if}}
|
||
|
*}}
|
||
|
{{* formulaire d'entrée de matériel *}}
|
||
|
|
||
|
<form method="post" action="">
|
||
|
|
||
|
<fieldset class="entree">
|
||
|
<legend>Ajouter une entrée pour un retour de matériel</legend>
|
||
|
{{:input type="select" name="type_operation" label="Type" required=true options=$types_entrees}}
|
||
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||
|
{{:input type="number" name="quantite" label="Quantité" required=true default=1}}
|
||
|
|
||
|
<fieldset>
|
||
|
<legend>Matériel</legend>
|
||
|
{{:input type="select_groups" name="equipment" label="Matériel" required=true options=$temporaire}}
|
||
|
{{:input type="textarea" name="remarques" label="Remarques" cols="40", rows="3" required=false}}
|
||
|
</fieldset>
|
||
|
</fieldset>
|
||
|
|
||
|
<p class="submit">
|
||
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||
|
</p>
|
||
|
|
||
|
</form>
|
||
|
|
||
|
{{:admin_footer}}
|