Gestion ajout matériel non répertorié

This commit is contained in:
Jean-Christophe Engel 2023-10-16 12:02:05 +02:00
parent 41dad67b1b
commit dd25ba702f
2 changed files with 51 additions and 29 deletions

View File

@ -11,35 +11,57 @@
{{:assign var='types_entrees.' value='Récupération'}} {{:assign var='types_entrees.' value='Récupération'}}
{{:assign var='types_entrees.' value='Location / Prêt'}} {{: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 *}} {{* lister les catégories disponibles *}}
{{#load type="category" assign="category"}} {{* order="$$.name" debug *}} {{#load type="category" assign="category" order="$$.name"}}
{{:assign var="categories." value=$category.name}} {{* :assign var="categories.%d"|args:$category.id value=$category.name *}}
{{:assign var="categories.%s"|args:$category.key value=$category.name}}
{{/load}} {{/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 *}} {{* formulaire d'ajout de matériel *}}
<form method="post" action="{{$_GET.caller}}">
<form method="post" action=""> {{* action="{{$_GET.caller}}">*}}
<fieldset class="entree"> <fieldset class="entree">
<legend>Ajouter une entrée d'un matériel non répertorié</legend> <legend>Ajouter une entrée d'un matériel non répertorié</legend>
{{:input type="select" name="type_materiel" label="Type" required=true options=$types_entrees}} {{:input type="select" name="type_operation" label="Type" required=true options=$types_entrees}}
{{:input type="date" name="date" label="Date" required=true default=$maintenant}} {{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
{{:input type="number" name="quantite" label="Quantité" required=true default=1}} {{:input type="number" name="quantite" label="Quantité" required=true default=1}}
<fieldset> <fieldset>

View File

@ -13,31 +13,31 @@
}, },
"inputNature": { "inputNature": {
"description": "Nature de l'entrée", "description": "Nature de l'entrée",
"type": "string", "type": ["null", "string"],
"enum": ["Achat", "Don", "Récupération", "Location / Prêt"] "enum": ["Achat", "Don", "Récupération", "Location / Prêt"]
}, },
"outputNature": { "outputNature": {
"description": "Nature de la sortie", "description": "Nature de la sortie",
"type": "string", "type": ["null", "string"],
"enum": ["Vente", "Don", "Besoin", "Autre (perte, vol, ...)", "Location / Prêt"] "enum": ["Vente", "Don", "Besoin", "Autre (perte, vol, ...)", "Location / Prêt"]
}, },
"amount": { "amount": {
"description": "Quantité ajoutée ou retirée", "description": "Quantité ajoutée ou retirée",
"type": "integer", "type": "integer",
"minimum": 1 "minimum": 1
} },
"equipment": { "equipment": {
"type": "string" "type": "string"
} },
"date" : { "date" : {
"description": "Date de l'opération", "description": "Date de l'opération",
"type": "string", "type": "string",
"format": "datetime" "format": "date"
} },
"comment": { "comment": {
"description": "Commentaire additionnel", "description": "Commentaire additionnel",
"type": "string" "type": ["null", "string"]
} }
}, },
"required": ["type", "direction", "inputNature", "outputNature", "amount", "equipment", "date", "comment"] "required": ["type", "direction", "amount", "equipment", "date", "comment"]
} }