Gestion sortie matériel en stock

This commit is contained in:
Jean-Christophe Engel 2023-10-19 14:54:03 +02:00
parent f84753ca1e
commit 5974bb158b
3 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,25 @@
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
{{:admin_header title="Supprimer une sortie" current="module_equipment"}}
{{#load key=$_GET.id assign="movement"}}
{{* trouver le matériel concerné par cette sortie *}}
{{#load type="equipment" where="key = :key" :key=$movement.equipment assign="equipment"}}
{{else}}
{{:error message="Matériel avec la clé %s introuvable"|args:$movement.equipment}}
{{/load}}
{{else}}
{{:error message="Sortie avec la clé %s introuvable"|args:$_GET.id}}
{{/load}}
{{#form on="delete"}}
{{* supprimer la sortie *}}
{{:delete where="key = :key" :key=$_GET.id}}
{{:redirect to="./index.html"}}
{{/form}}
{{:delete_form legend="Supprimer cette sortie ?" warning="Supprimer la sortie « %d %s » en date du %s ?"|args:$movement.amount:$equipment.designation:$movement.date }}
{{:form_errors}}
{{:admin_footer}}

View File

@ -1,6 +1,39 @@
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
{{:admin_header title="Gestion des matériels" current="module_equipment"}} {{:admin_header title="Gestion des matériels" current="module_equipment"}}
{{* barre de navigation *}} {{* barre de navigation *}}
{{:include file="/%s/_nav.html"|args:$module.name current="sorties"}} {{:include file="/%s/_nav.html"|args:$module.name current="sorties"}}
{{if $_GET.ok}}
<p class="block confirm">Sortie enregistrée.</p>
{{/if}}
<form method="post" action="">
<fieldset class="sortie">
<legend>Ajouter une sortie pour du </legend>
{{:linkbutton label="Matériel en stock disponible" shape="plus" href="stock_disponible.html"}}
{{:linkbutton label="Matériel emprunté" shape="plus" href="emprunte.html}}
</fieldset>
</form>
{{* lister les sorties *}}
<section class="liste_entrees">
<h2>Liste des sorties</h2>
{{#list select="$$.date AS 'Date' ; $$.outputNature AS 'Type' ; $$.amount AS 'Nombre' ; "" AS 'Matériel' ; $$.comment AS 'Remarques'" type="movement" direction="sortie" order=1}}
{{:assign var='mvt_key' value=$key}}
{{#load type="equipment" key=$equipment assign="equipment"}}
<tr>
<td>{{$date|date_short}}</td>
<td>{{$outputNature}}</td>
<td>{{$amount}}</td>
<td>{{$designation}}</td>
<td>{{$comment}}</td>
<td class="actions">
{{:linkbutton label="Supprimer" href="delete_sortie.html?id=%s"|args:$mvt_key shape="delete" target="_dialog"}}
</td>
</tr>
{{/load}}
{{/list}}
</section>
{{:admin_footer}} {{:admin_footer}}

View File

@ -0,0 +1,72 @@
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
{{* barre de navigation *}}
{{:include file="/%s/_nav.html"|args:$module.name current="entrees"}}
{{* types de sorties *}}
{{* TODO : stocker dans la configuration du module *}}
{{:assign var='types_sorties.' value='Vente'}}
{{:assign var='types_sorties.' value='Don'}}
{{:assign var='types_sorties.' value='Location / Prêt'}}
{{* Traiter l'envoi du formulaire *}}
{{#form on="save"}}
{{* récupérer les infos du matériel *}}
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
{{/load}}
{{* Enregistrer le mouvement *}}
{{:assign mvt_key=""|uuid}}
{{:assign var="operation" from="types_sorties.%d|args:$_POST.type_operation}}
{{:save
key=$mvt_key
validate_schema="/%s/mouvements/movement.schema.json"|args:$module.name
type="movement"
direction="sortie"
outputNature=$operation
amount=$_POST.quantite|intval
equipment=$equipment.key
date=$_POST.date|parse_date
comment=$_POST.remarques|trim
}}
{{:redirect to="index.html?ok=1"}}
{{else}}
{{:form_errors}}
{{/form}}
{{* 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}}
{{* formulaire de sortie de matériel *}}
<form method="post" action="">
<fieldset class="sortie">
<legend>Ajouter une sortie d'un matériel disponible en stock</legend>
{{:input type="select" name="type_operation" label="Type" required=true options=$types_sorties}}
{{:input type="date" name="date" label="Date de sortie" 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=$equipments}}
{{: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"}}
{{* :button type="submit" name="cancel" label="Annuler" shape="delete" class="main" *}}
</p>
</form>
{{:admin_footer}}