From dd25ba702fc9a92513e42a2bf5726374e226f05a Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 16 Oct 2023 12:02:05 +0200 Subject: [PATCH] =?UTF-8?q?Gestion=20ajout=20mat=C3=A9riel=20non=20r=C3=A9?= =?UTF-8?q?pertori=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mouvements/entrees/non_repertorie.html | 64 +++++++++++++++++--------- mouvements/movement.schema.json | 16 +++---- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/mouvements/entrees/non_repertorie.html b/mouvements/entrees/non_repertorie.html index 55c977d..b753da9 100644 --- a/mouvements/entrees/non_repertorie.html +++ b/mouvements/entrees/non_repertorie.html @@ -11,35 +11,57 @@ {{:assign var='types_entrees.' value='Récupération'}} {{:assign var='types_entrees.' value='Location / Prêt'}} -{{:assign maintenant=$now|date_short}} +{{* Traiter l'envoi du formulaire *}} +{{#form on="save"}} + {{* récupérer les infos de la catégorie *}} + {{#load type="category" key=$_POST.category assign="category"}} + {{/load}} + + {{* enregistrer un nouveau matériel *}} + {{:assign equipment_key=""|uuid}} + {{:save + key=$equipment_key + validate_schema="/%s/equipment.schema.json"|args:$module.name + type="equipment" + category=$category.key + designation=$_POST.designation|trim + }} + + {{* 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 to="index.html?ok=1"}} +{{else}} + {{:form_errors}} +{{/form}} {{* lister les catégories disponibles *}} -{{#load type="category" assign="category"}} {{* order="$$.name" debug *}} -{{:assign var="categories." value=$category.name}} +{{#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}} -{{* TODO Traiter l'envoi du formulaire *}} -{{#form on="save"}} - {{:assign key=""|uuid}} - {{:save - key=$key - validate_schema="./category.schema.json" - type="category" - name=$_POST.name|trim - }} - {{:redirect to="./index.html?ok=1"}} -{{/form}} -{{* /TODO *}} - -{{:form_errors}} - {{* formulaire d'ajout de matériel *}} -
+ + {{* action="{{$_GET.caller}}">*}}
Ajouter une entrée d'un matériel non répertorié - {{:input type="select" name="type_materiel" label="Type" required=true options=$types_entrees}} - {{:input type="date" name="date" label="Date" required=true default=$maintenant}} + {{: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}}
diff --git a/mouvements/movement.schema.json b/mouvements/movement.schema.json index 72958bc..16b1dac 100644 --- a/mouvements/movement.schema.json +++ b/mouvements/movement.schema.json @@ -13,31 +13,31 @@ }, "inputNature": { "description": "Nature de l'entrée", - "type": "string", + "type": ["null", "string"], "enum": ["Achat", "Don", "Récupération", "Location / Prêt"] }, "outputNature": { "description": "Nature de la sortie", - "type": "string", + "type": ["null", "string"], "enum": ["Vente", "Don", "Besoin", "Autre (perte, vol, ...)", "Location / Prêt"] }, "amount": { "description": "Quantité ajoutée ou retirée", "type": "integer", "minimum": 1 - } + }, "equipment": { "type": "string" - } + }, "date" : { "description": "Date de l'opération", "type": "string", - "format": "datetime" - } + "format": "date" + }, "comment": { "description": "Commentaire additionnel", - "type": "string" + "type": ["null", "string"] } }, - "required": ["type", "direction", "inputNature", "outputNature", "amount", "equipment", "date", "comment"] + "required": ["type", "direction", "amount", "equipment", "date", "comment"] }