2023-12-04 10:56:36 +01:00
|
|
|
{{#restrict section="accounting" level="write" block=true}}{{/restrict}}
|
2023-10-13 16:12:22 +02:00
|
|
|
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
|
|
|
|
|
2023-11-01 16:53:20 +01:00
|
|
|
{{if $_GET.dialog === null}}
|
|
|
|
{{* barre de navigation *}}
|
2023-12-05 10:07:01 +01:00
|
|
|
{{:include file="../../_nav.html" current="entrees"}}
|
2023-11-01 16:53:20 +01:00
|
|
|
{{else}}
|
|
|
|
<header class="header">
|
2023-11-29 14:36:44 +01:00
|
|
|
<h1>Entrée de matériel</h1>
|
2023-11-01 16:53:20 +01:00
|
|
|
</header>
|
|
|
|
{{/if}}
|
2023-10-13 16:12:22 +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-13 16:12:22 +02:00
|
|
|
{{* types d'entrées *}}
|
2023-11-30 18:14:46 +01:00
|
|
|
{{#foreach from=$config.inputNature item="elem"}}
|
2023-11-20 16:08:06 +01:00
|
|
|
{{if $elem.type != 'retour'}}
|
2023-10-26 10:04:45 +02:00
|
|
|
{{:assign var='types_entrees.' value="%s"|args:$elem.label}}
|
2023-11-20 16:08:06 +01:00
|
|
|
{{/if}}
|
2023-10-26 10:04:45 +02:00
|
|
|
{{/foreach}}
|
2023-10-13 16:12:22 +02:00
|
|
|
|
2023-10-16 12:02:05 +02:00
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
|
|
{{#form on="save"}}
|
2023-10-30 14:56:46 +01:00
|
|
|
|
2023-10-16 12:02:05 +02:00
|
|
|
{{* récupérer les infos de la catégorie *}}
|
|
|
|
{{#load type="category" key=$_POST.category assign="category"}}
|
|
|
|
{{/load}}
|
2023-10-13 16:12:22 +02:00
|
|
|
|
2023-10-30 14:56:46 +01:00
|
|
|
{{* 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
|
2023-12-05 10:07:01 +01:00
|
|
|
validate_schema="../../equipment.schema.json"
|
2023-10-30 14:56:46 +01:00
|
|
|
type="equipment"
|
|
|
|
category=$category.key
|
|
|
|
designation=$_POST.designation|trim
|
|
|
|
}}
|
|
|
|
{{/load}}
|
2023-10-16 12:02:05 +02:00
|
|
|
|
|
|
|
{{* Enregistrer le mouvement *}}
|
|
|
|
{{:assign mvt_key=""|uuid}}
|
|
|
|
{{:assign var="operation" from="types_entrees.%d|args:$_POST.type_operation}}
|
2023-10-13 16:12:22 +02:00
|
|
|
|
|
|
|
{{:save
|
2023-10-16 12:02:05 +02:00
|
|
|
key=$mvt_key
|
2023-12-05 10:07:01 +01:00
|
|
|
validate_schema="../movement.schema.json"
|
2023-10-16 12:02:05 +02:00
|
|
|
type="movement"
|
|
|
|
direction="entrée"
|
|
|
|
inputNature=$operation
|
|
|
|
amount=$_POST.quantite|intval
|
|
|
|
equipment=$equipment_key
|
|
|
|
date=$_POST.date|parse_date
|
|
|
|
comment=$_POST.remarques|trim
|
2023-10-13 16:12:22 +02:00
|
|
|
}}
|
2023-10-16 12:02:05 +02:00
|
|
|
|
2023-10-26 12:09:23 +02:00
|
|
|
{{:redirect force="index.html?ok=1&msg=Entrée de « %s » enregistrée"|args:$_POST.designation}}
|
2023-10-16 12:02:05 +02:00
|
|
|
{{else}}
|
|
|
|
{{:form_errors}}
|
2023-10-13 16:12:22 +02:00
|
|
|
{{/form}}
|
|
|
|
|
2023-10-16 12:02:05 +02:00
|
|
|
{{* 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}}
|
2023-10-13 16:12:22 +02:00
|
|
|
|
|
|
|
{{* formulaire d'ajout de matériel *}}
|
2023-10-17 12:55:19 +02:00
|
|
|
<form method="post" action="">
|
2023-10-13 16:12:22 +02:00
|
|
|
|
|
|
|
<fieldset class="entree">
|
|
|
|
<legend>Ajouter une entrée d'un matériel non répertorié</legend>
|
2023-10-16 12:02:05 +02:00
|
|
|
{{: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}}
|
2023-10-13 16:12:22 +02:00
|
|
|
{{:input type="number" name="quantite" label="Quantité" required=true default=1}}
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<legend>Matériel</legend>
|
|
|
|
{{: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}}
|
|
|
|
</fieldset>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<p class="submit">
|
|
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
{{:admin_footer}}
|