diff --git a/_calcul_dispo.html b/_calcul_dispo.html
index 7a0fbcb..a6eae0c 100644
--- a/_calcul_dispo.html
+++ b/_calcul_dispo.html
@@ -73,11 +73,14 @@
{{:assign nonproprio=0}}
{{/if}}
- {{* déterminer le type de mouvement *}}
- {{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
- {{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
-
{{if $mvt.direction === 'input'}}
+ {{* déterminer le type de mouvement *}}
+ {{#foreach from=$config.input_nature}}
+ {{if $key == $mvt.operation}}
+ {{:assign type_mvt=$type}}
+ {{:break}}
+ {{/if}}
+ {{/foreach}}
{{if $type_mvt == 'définitif'}}
{{:assign stock="%d+%d"|math:$stock:$mvt.amount}}
{{:assign
@@ -95,6 +98,13 @@
from=nonproprio}}
{{/if}}
{{elseif $mvt.direction === 'output'}}
+ {{* déterminer le type de mouvement *}}
+ {{#foreach from=config.output_nature}}
+ {{if $key == $mvt.operation}}
+ {{:assign type_mvt=$type}}
+ {{:break}}
+ {{/if}}
+ {{/foreach}}
{{if $type_mvt == 'définitif'}}
{{:assign stock="%d-%d"|math:$stock:$mvt.amount}}
{{:assign
diff --git a/_get_config.html b/_get_config.html
index 5c819b9..f03f643 100644
--- a/_get_config.html
+++ b/_get_config.html
@@ -8,29 +8,41 @@
{{* config par défaut *}}
{{:read file="./defaut.json" assign="config_defaut"}}
{{:assign config_defaut=$config_defaut|json_decode}}
+{{*:debug config_defaut=$config_defaut*}}
{{if $module.config.input_nature != null}}
+{{*:debug module.config.input_nature=$module.config.input_nature*}}
{{#foreach from=$module.config.input_nature item="elem"}}
- {{:assign var="config.input_nature.%s"|args:$elem.label value=$elem.type}}
+ {{#foreach from=$elem key=label item=value}}
+ {{:assign var="in.%s"|args:$label value=$value}}
+ {{/foreach}}
+ {{:assign var="config.input_nature." from="in"}}
{{/foreach}}
{{else}}
{{* pas de config enregistrée : utiliser la config par défaut *}}
{{#foreach from=$config_defaut.inputs item="elem"}}
{{#foreach from=$elem key=label item=value}}
- {{:assign var="config.input_nature.%s"|args:$label value=$value}}
+ {{:assign var="in.%s"|args:$label value=$value}}
{{/foreach}}
+ {{:assign var="config.input_nature." from="in"}}
{{/foreach}}
{{/if}}
+{{*:debug config.input_nature=$config.input_nature*}}
{{if $module.config.output_nature != null}}
+{{*:debug module.config.output_nature=$module.config.output_nature*}}
{{#foreach from=$module.config.output_nature item="elem"}}
- {{:assign var="config.output_nature.%s"|args:$elem.label value=$elem.type}}
+ {{#foreach from=$elem key=label item=value}}
+ {{:assign var="out.%s"|args:$label value=$value}}
+ {{/foreach}}
+ {{:assign var="config.output_nature." from="out"}}
{{/foreach}}
{{else}}
{{* pas de config enregistrée : utiliser la config par défaut *}}
{{#foreach from=$config_defaut.outputs item="elem"}}
{{#foreach from=$elem key=label item=value}}
- {{:assign var="config.output_nature.%s"|args:$label value=$value}}
+ {{:assign var="out.%s"|args:$label value=$value}}
{{/foreach}}
+ {{:assign var="config.output_nature." from="out"}}
{{/foreach}}
{{/if}}
diff --git a/config.html b/config.html
index fd93413..2aaab47 100644
--- a/config.html
+++ b/config.html
@@ -11,22 +11,13 @@
{{* lecture config (défaut ou enregistrée) *}}
{{:include file="./_get_config.html" keep="config"}}
-
-{{* types d'entrées *}}
-{{#foreach from=$config.input_nature key="label" item="type"}}
- {{:assign var='input_types.%s'|args:$type value=$type}}
-{{/foreach}}
+{{*:debug config.in=$config.input_nature config.out=$config.output_nature*}}
{{* types d'entrées qui ne peuvent être supprimées *}}
{{#load type="movement" where="$$.direction='input'" group="$$.input_nature"}}
{{:assign var="locked_inputs." value=$input_nature}}
{{/load}}
-{{* types de sorties *}}
-{{#foreach from=$config.output_nature key="label" item="type"}}
- {{:assign var='output_types.%s'|args:$type value=$type}}
-{{/foreach}}
-
{{* types de sorties qui ne peuvent être supprimées *}}
{{#load type="movement" where="$$.direction='output'" group="$$.output_nature"}}
{{:assign var="locked_outputs." value=$output_nature}}
@@ -42,7 +33,7 @@
- {{#foreach from=$config.input_nature key="label" item="type"}}
+ {{#foreach from=$config.input_nature}}
{{$label}} |
{{$type}} |
@@ -67,7 +58,7 @@
- {{#foreach from=$config.output_nature key="label" item="type"}}
+ {{#foreach from=$config.output_nature}}
{{$label}} |
{{$type}} |
diff --git a/config.schema.json b/config.schema.json
index 19afec5..8395b2f 100644
--- a/config.schema.json
+++ b/config.schema.json
@@ -8,6 +8,9 @@
"items": {
"type": "object",
"properties": {
+ "key" : {
+ "type" : "string"
+ },
"label" : {
"type" : "string"
},
@@ -24,6 +27,9 @@
"items": {
"type": "object",
"properties": {
+ "key" : {
+ "type" : "string"
+ },
"label" : {
"type" : "string"
},
diff --git a/config/ajouter_type_mouvement.html b/config/ajouter_type_mouvement.html
index f4a55b6..cfbf1cf 100644
--- a/config/ajouter_type_mouvement.html
+++ b/config/ajouter_type_mouvement.html
@@ -11,38 +11,41 @@
{{:include file="../_get_config.html" keep="config"}}
{{#form on="save"}}
-
{{* vérifier l'existence d'une entrée de même nom et générer le résultat *}}
- {{#foreach from=$config.input_nature key="label" item="type"}}
+ {{#foreach from=$config.input_nature item=elem}}
{{if $label|trim|tolower == $_POST.input_fields.label|trim|tolower}}
{{:error message="Ce libellé d'entrée est déjà présent"}}
{{/if}}
- {{:assign var="input_nature.label" value=$label}}
- {{:assign var="input_nature.type" value=$type}}
- {{:assign var="input_natures." from=input_nature}}
+ {{#foreach from=$elem key=label item=value}}
+ {{:assign var="in.%s"|args:$label value=$value}}
+ {{/foreach}}
+ {{:assign var="input_natures." from="in"}}
{{/foreach}}
{{* ajouter la nouvelle entrée *}}
{{if $_GET.dir == 'input'}}
{{:assign input_label=$_POST.input_fields.label|trim|tolower|ucfirst}}
+ {{:assign var="input_nature.key" value=""|uuid}}
{{:assign var="input_nature.label" value=$_POST.input_fields.label|trim|tolower|ucfirst}}
{{:assign var="input_nature.type" value=$_POST.input_fields.type}}
{{:assign var="input_natures." from=input_nature}}
{{/if}}
{{* vérifier l'existence d'une sortie de même nom et générer le résultat *}}
- {{#foreach from=$config.output_nature key="label" item="type"}}
+ {{#foreach from=$config.output_nature item=elem}}
{{if $label|trim|tolower == $_POST.output_fields.label|trim|tolower}}
{{:error message="Ce libellé de sortie est déjà présent"}}
{{/if}}
- {{:assign var="output_nature.label" value=$label}}
- {{:assign var="output_nature.type" value=$type}}
- {{:assign var="output_natures." from=output_nature}}
+ {{#foreach from=$elem key=label item=value}}
+ {{:assign var="out.%s"|args:$label value=$value}}
+ {{/foreach}}
+ {{:assign var="output_natures." from="out"}}
{{/foreach}}
{{* ajouter la nouvelle sortie *}}
{{if $_GET.dir == 'output'}}
{{:assign output_label=$_POST.output_fields.label|trim|tolower|ucfirst}}
+ {{:assign var="output_nature.key" value=""|uuid}}
{{:assign var="output_nature.label" value=$_POST.output_fields.label|trim|tolower|ucfirst}}
{{:assign var="output_nature.type" value=$_POST.output_fields.type}}
{{:assign var="output_natures." from=output_nature}}
@@ -54,7 +57,7 @@
input_nature=$input_natures
output_nature=$output_natures
}}
-{{:redirect to="./config.html?ok=1"}}
+ {{:redirect to="./config.html?ok=1"}}
{{/form}}
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
@@ -62,10 +65,9 @@
{{if $_GET.dir == 'input'}}
{{* types d'entrées *}}
- {{#foreach from=$config.input_nature key="label" item="type"}}
+ {{#foreach from=$config.input_nature}}
{{:assign var='input_types.%s'|args:$type value=$type}}
{{/foreach}}
-
{{else}}
{{* types de sorties *}}
- {{#foreach from=$config.output_nature key="label" item="type"}}
+ {{#foreach from=$config.output_nature}}
{{:assign var='output_types.%s'|args:$type value=$type}}
{{/foreach}}
diff --git a/config/supprimer_type_mouvement.html b/config/supprimer_type_mouvement.html
index eba02c7..9132c1f 100644
--- a/config/supprimer_type_mouvement.html
+++ b/config/supprimer_type_mouvement.html
@@ -15,21 +15,25 @@
{{:include file="../_get_config.html" keep="config"}}
{{#form on="delete"}}
- {{#foreach from=$config.input_nature key="label" item="type"}}
+ {{#foreach from=$config.input_nature item=elem}}
{{if $_GET.dir == 'input' && $label|trim|tolower != $_GET.mvt|trim|tolower ||
- $_GET.dir == 'output'}}
- {{:assign var="input_nature.label" value=$label}}
- {{:assign var="input_nature.type" value=$type}}
- {{:assign var="input_natures." from=input_nature}}
+ $_GET.dir == 'output'
+ }}
+ {{#foreach from=$elem key=label item=value}}
+ {{:assign var="in.%s"|args:$label value=$value}}
+ {{/foreach}}
+ {{:assign var="input_natures." from="in"}}
{{/if}}
{{/foreach}}
- {{#foreach from=$config.output_nature key="label" item="type"}}
+ {{#foreach from=$config.output_nature item=elem}}
{{if $_GET.dir == 'output' && $label|trim|tolower != $_GET.mvt|trim|tolower ||
- $_GET.dir == 'input'}}
- {{:assign var="output_nature.label" value=$label}}
- {{:assign var="output_nature.type" value=$type}}
- {{:assign var="output_natures." from=output_nature}}
+ $_GET.dir == 'input'
+ }}
+ {{#foreach from=$elem key=label item=value}}
+ {{:assign var="out.%s"|args:$label value=$value}}
+ {{/foreach}}
+ {{:assign var="output_natures." from="out"}}
{{/if}}
{{/foreach}}
diff --git a/defaut.json b/defaut.json
index 404b161..07a9c10 100644
--- a/defaut.json
+++ b/defaut.json
@@ -1,12 +1,37 @@
+
{
- "inputs" : [
- { "Achat" : "définitif" },
- { "Location" : "temporaire" },
- { "Retour de Location/Prêt" : "retour" }
+ "inputs": [
+ {
+ "key": "c3a955e3-4e6e-414e-90f4-ede7ac3e9e33",
+ "label": "Achat",
+ "type": "définitif"
+ },
+ {
+ "key": "9e909c25-14dc-4e02-b97e-73c34ab2ee9b",
+ "label" : "Location",
+ "type": "temporaire"
+ },
+ {
+ "key": "30eb854c-f89a-4c19-85e4-baa5e34a0317",
+ "label" : "Retour de Location/Prêt",
+ "type" : "retour"
+ }
],
- "outputs" : [
- { "Vente" : "définitif" },
- { "Prêt" : "temporaire" },
- { "Retour de Location/Emprunt" : "retour" }
+ "outputs": [
+ {
+ "key": "f0eb189b-0b72-46c7-8b48-c23eed7e9672",
+ "label" : "Vente",
+ "type" : "définitif"
+ },
+ {
+ "key" : "c9ba00d9-26ee-448b-9f02-73e479ec2980",
+ "label" : "Prêt",
+ "type" : "temporaire"
+ },
+ {
+ "key" : "fefefa51-1a85-46ca-ab78-b594b10390ff",
+ "label" : "Retour de Location/Emprunt",
+ "type" : "retour"
+ }
]
}
diff --git a/historique.html b/historique.html
index 3187fd0..5f7856a 100644
--- a/historique.html
+++ b/historique.html
@@ -52,32 +52,35 @@
{{* récupérer la config des entrées/sorties *}}
{{:include file="./_get_config.html" keep="config"}}
+{{:debug config.input_nature=$config.input_nature}}
{{* déterminer les types de mouvements selon l'affection du matériel *}}
-{{#foreach from=$config.input_nature key=mvt item=type_mvt}}
+{{#foreach from=$config.input_nature}}
+ {{:debug key=$key label=$label type=$type}}
{{if $_GET.prop}}
{{* matériel propriété de l'asso *}}
- {{if $type_mvt != 'temporaire'}}
- {{:assign var="input_types." value=$mvt}}
+ {{if $type != 'temporaire'}}
+ {{:assign var="input_types." value=$label}}
{{/if}}
{{else}}
{{* matériel non propriété de l'asso *}}
- {{if $type_mvt == 'temporaire'}}
- {{:assign var="input_types." value=$mvt}}
+ {{if $type == 'temporaire'}}
+ {{:assign var="input_types." value=$label}}
{{/if}}
{{/if}}
{{/foreach}}
+{{:debug input_types=$input_types}}
-{{#foreach from=$config.output_nature key=mvt item=type_mvt}}
+{{#foreach from=$config.output_nature}}
{{if $_GET.prop}}
{{* matériel propriété de l'asso *}}
- {{if $type_mvt != 'retour'}}
- {{:assign var="output_types." value=$mvt}}
+ {{if $type != 'retour'}}
+ {{:assign var="output_types." value=$label}}
{{/if}}
{{else}}
{{* matériel non propriété de l'asso *}}
- {{if $type_mvt == 'retour'}}
- {{:assign var="output_types." value=$mvt}}
+ {{if $type == 'retour'}}
+ {{:assign var="output_types." value=$label}}
{{/if}}
{{/if}}
{{/foreach}}
diff --git a/mouvements/ajouter_entree.html b/mouvements/ajouter_entree.html
index 60836ae..5fc8116 100644
--- a/mouvements/ajouter_entree.html
+++ b/mouvements/ajouter_entree.html
@@ -9,9 +9,9 @@
{{:include file="../_get_config.html" keep="config"}}
{{* types d'entrées *}}
-{{#foreach from=$config.input_nature key="label" item="type"}}
+{{#foreach from=$config.input_nature}} {{* key="label" item="type"*}}
{{if $type != 'retour'}}
- {{:assign var='input_labels.' value="%s"|args:$label}}
+ {{:assign var="input_labels.%s"|args:$key value="%s"|args:$label}}
{{/if}}
{{/foreach}}
@@ -62,13 +62,12 @@
{{* Enregistrer le mouvement *}}
{{:assign mvt_key=""|uuid}}
{{:assign var="operation" from="input_labels.%d"|args:$_POST.type_operation}}
-
{{:save
key=$mvt_key
validate_schema="./movement.schema.json"
type="movement"
direction="input"
- input_nature=$operation
+ operation=$_POST.operation
amount=$_POST.quantite|intval
equipment=$equipment_key
date=$_POST.date|parse_date
@@ -95,7 +94,7 @@