diff --git a/_get_config.html b/_get_config.html
index d143240..c95aaf7 100644
--- a/_get_config.html
+++ b/_get_config.html
@@ -9,28 +9,22 @@
{{:read file="./defaut.json" assign="config_defaut"}}
{{:assign config_defaut=$config_defaut|json_decode}}
-{{if $module.config.input_nature != null}}
- {{#foreach from=$module.config.input_nature item="elem"}}
- {{:assign var="item" label=$label type=$type}}
- {{:assign var="config.input_nature.%s"|args:$key value=$item}}
- {{/foreach}}
-{{else}}
- {{* pas de config enregistrée : utiliser la config par défaut *}}
- {{#foreach from=$config_defaut.inputs item="elem"}}
- {{:assign var="item" label=$label type=$type}}
- {{:assign var="config.input_nature.%s"|args:$key value=$item}}
- {{/foreach}}
-{{/if}}
+{{:assign var="directions.input" value="entrée"}}
+{{:assign var="directions.output" value="sortie"}}
-{{if $module.config.output_nature != null}}
- {{#foreach from=$module.config.output_nature item="elem"}}
- {{:assign var="item" label=$label type=$type}}
- {{:assign var="config.output_nature.%s"|args:$key value=$item}}
- {{/foreach}}
-{{else}}
- {{* pas de config enregistrée : utiliser la config par défaut *}}
- {{#foreach from=$config_defaut.outputs item="elem"}}
- {{:assign var="item" label=$label type=$type}}
- {{:assign var="config.output_nature.%s"|args:$key value=$item}}
- {{/foreach}}
-{{/if}}
+{{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="module.config.%s_nature"|args:$direction}}
+ {{if $nature != null}}
+ {{#foreach from=$nature item="elem"}}
+ {{:assign var="item" label=$label type=$type}}
+ {{:assign var="config.%s_nature.%s"|args:$direction:$key value=$item}}
+ {{/foreach}}
+ {{else}}
+ {{* pas de config enregistrée : utiliser la config par défaut *}}
+ {{:assign var="nature" from="config_defaut.%ss"|args:$direction}}
+ {{#foreach from=$nature item="elem"}}
+ {{:assign var="item" label=$label type=$type}}
+ {{:assign var="config.%s_nature.%s"|args:$direction:$key value=$item}}
+ {{/foreach}}
+ {{/if}}
+{{/foreach}}
diff --git a/config.html b/config.html
index db40574..62e9b02 100644
--- a/config.html
+++ b/config.html
@@ -10,9 +10,7 @@
{{/if}}
{{* lecture config (défaut ou enregistrée) *}}
-{{:include file="./_get_config.html" keep="config"}}
-{{:assign var="directions.input" value="d'entrées"}}
-{{:assign var="directions.output" value="de sorties"}}
+{{:include file="./_get_config.html" keep="config, directions"}}
{{#foreach from=$directions key="direction" item="item"}}
@@ -22,7 +20,7 @@
{{:assign var="locked_%ss."|args:$direction value=$op_label}}
{{/load}}
-
Types {{$item}}
+ {{$item|ucfirst}}s
diff --git a/config/ajouter_type_mouvement.html b/config/ajouter_type_mouvement.html
index 2a5331e..f225bda 100644
--- a/config/ajouter_type_mouvement.html
+++ b/config/ajouter_type_mouvement.html
@@ -1,5 +1,10 @@
{{* -*- brindille -*- *}}
+{{*
+ paramètres :
+ - dir : input ou output
+*}}
+
{{* barre de navigation *}}
{{if ! $dialog}}
{{:include file="../_nav.html" current="config" subcurrent="typesES"}}
@@ -8,49 +13,35 @@
{{* Traiter l'envoi du formulaire *}}
{{* lecture config (défaut ou enregistrée) *}}
-{{:include file="../_get_config.html" keep="config"}}
+{{:include file="../_get_config.html" keep="config, directions"}}
{{#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=key}}
- {{if $label|trim|tolower == $_POST.input_fields.label|trim|tolower}}
- {{:error message="Ce libellé d'entrée est déjà présent"}}
+ {{* vérifier s'il existe un type de mouvement de même nom *}}
+ {{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config.%s_nature"|args:$direction}}
+ {{#foreach from=$nature key="key"}}
+ {{:assign var="fields" from="_POST.%s_fields"|args:$_GET.dir}}
+ {{if $label|trim|tolower == $fields.label|trim|tolower}}
+ {{:error message="Ce libellé est déjà présent"}}
+ {{/if}}
+ {{:assign var="%s_nature.key"|args:$direction value=$key}}
+ {{:assign var="%s_nature.label"|args:$direction value=$label}}
+ {{:assign var="%s_nature.type"|args:$direction value=$type}}
+ {{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
+ {{/foreach}}
+
+ {{* ajouter le nouveau type de mouvement *}}
+ {{if $_GET.dir == $direction}}
+ {{:assign var="newlabel" from="_POST.%s_fields.label|args:$direction}}
+ {{:assign newlabel=$newlabel|trim|tolower|ucfirst}}
+ {{:assign var="%s_nature.key"|args:$direction value=""|uuid}}
+ {{:assign var="%s_nature.label"|args:$direction value=$newlabel}}
+ {{:assign var="%s_nature.type"|args:$direction from="_POST.%s_fields.type"|args:$direction}}
+ {{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
{{/if}}
- {{:assign var="input_nature.key" value=$key}}
- {{:assign var="input_nature.label" value=$label}}
- {{:assign var="input_nature.type" value=$type}}
- {{:assign var="input_natures." from=input_nature}}
+
{{/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=key}}
- {{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.key" value=$key}}
- {{:assign var="output_nature.label" value=$label}}
- {{:assign var="output_nature.type" value=$type}}
- {{:assign var="output_natures." from=output_nature}}
- {{/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}}
- {{/if}}
-
{{:save
key="config"
validate_schema="../config.schema.json"
diff --git a/config/modifier_type_mouvement.html b/config/modifier_type_mouvement.html
index b83032d..fe5527d 100644
--- a/config/modifier_type_mouvement.html
+++ b/config/modifier_type_mouvement.html
@@ -12,38 +12,25 @@
{{/if}}
{{* lecture config (défaut ou enregistrée) *}}
-{{:include file="../_get_config.html" keep="config"}}
+{{:include file="../_get_config.html" keep="config, directions"}}
{{#form on="save"}}
- {{:assign input_nature=null}}
- {{#foreach from=$config.input_nature key=key}}
- {{:assign var="input_nature.key" value=$key}}
- {{if $_GET.dir == 'input'}}
- {{if $key == $_GET.op_key}}
- {{:assign var="input_nature.label" value=$_POST.name|trim|tolower|ucfirst}}
+ {{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config.%s_nature"|args:$direction}}
+ {{#foreach from=$nature key="key"}}
+ {{:assign var="%s_nature.key"|args:$direction value=$key}}
+ {{if $_GET.dir == $direction}}
+ {{if $key == $_GET.op_key}}
+ {{:assign var="%s_nature.label"|args:$direction value=$_POST.name|trim|tolower|ucfirst}}
+ {{else}}
+ {{:assign var="%s_nature.label"|args:$direction value=$label}}
+ {{/if}}
{{else}}
- {{:assign var="input_nature.label" value=$label}}
+ {{:assign var="%s_nature.label"|args:$direction value=$label}}
{{/if}}
- {{else}}
- {{:assign var="input_nature.label" value=$label}}
- {{/if}}
- {{:assign var="input_nature.type" value=$type}}
- {{:assign var="input_natures." from=input_nature}}
- {{/foreach}}
-
- {{#foreach from=$config.output_nature key=key}}
- {{:assign var="output_nature.key" value=$key}}
- {{if $_GET.dir == 'output'}}
- {{if $key == $_GET.op_key}}
- {{:assign var="output_nature.label" value=$_POST.name|trim|tolower|ucfirst}}
- {{else}}
- {{:assign var="output_nature.label" value=$label}}
- {{/if}}
- {{else}}
- {{:assign var="output_nature.label" value=$label}}
- {{/if}}
- {{:assign var="output_nature.type" value=$type}}
- {{:assign var="output_natures." from=output_nature}}
+ {{:assign var="%s_nature.type"|args:$direction value=$type}}
+ {{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
+ {{/foreach}}
{{/foreach}}
{{:save
diff --git a/config/supprimer_type_mouvement.html b/config/supprimer_type_mouvement.html
index ce46f28..9e889ab 100644
--- a/config/supprimer_type_mouvement.html
+++ b/config/supprimer_type_mouvement.html
@@ -12,25 +12,19 @@
{{/if}}
{{* lecture config (défaut ou enregistrée) *}}
-{{:include file="../_get_config.html" keep="config"}}
+{{:include file="../_get_config.html" keep="config, directions"}}
{{#form on="delete"}}
- {{#foreach from=$config.input_nature key=key}}
- {{if $_GET.dir == 'input' && $key != $_GET.op_key || $_GET.dir == 'output'}}
- {{:assign var="input_nature.key" value=$key}}
- {{:assign var="input_nature.label" value=$label}}
- {{:assign var="input_nature.type" value=$type}}
- {{:assign var="input_natures." from=input_nature}}
- {{/if}}
- {{/foreach}}
-
- {{#foreach from=$config.output_nature key=key}}
- {{if $_GET.dir == 'output' && $key != $_GET.op_key || $_GET.dir == 'input'}}
- {{:assign var="output_nature.key" value=$key}}
- {{:assign var="output_nature.label" value=$label}}
- {{:assign var="output_nature.type" value=$type}}
- {{:assign var="output_natures." from=output_nature}}
- {{/if}}
+ {{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config.%s_nature"|args:$direction}}
+ {{#foreach from=$nature key="key"}}
+ {{if $_GET.dir == $direction && $key != $_GET.op_key || $_GET.dir != $direction}}
+ {{:assign var="%s_nature.key"|args:$direction value=$key}}
+ {{:assign var="%s_nature.label"|args:$direction value=$label}}
+ {{:assign var="%s_nature.type"|args:$direction value=$type}}
+ {{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
+ {{/if}}
+ {{/foreach}}
{{/foreach}}
{{:save
@@ -45,16 +39,11 @@
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
{{:form_errors}}
-{{if $_GET.dir == 'input'}}
- {{:delete_form
- legend="Supprimer cette entrée ?"
- warning="Supprimer l'entrée « %s » ?"|args:$_GET.mvt
- }}
-{{else}}
- {{:delete_form
- legend="Supprimer cette sortie ?"
- warning="Supprimer la sortie « %s » ?"|args:$_GET.mvt
- }}
-{{/if}}
+{{:assign var="mvt_label" from="config.%s_nature.%s.label"|args:$_GET.dir:$_GET.op_key}}
+{{:assign var="dir_label" from="directions.%s"|args:$_GET.dir}}
+{{:delete_form
+ legend="Supprimer cette %s ?"|args:$dir_label
+ warning="Supprimer « %s » ?"|args:$mvt_label
+}}
{{:admin_footer}}
diff --git a/inventaire.html b/inventaire.html
index b461122..7cc58bf 100644
--- a/inventaire.html
+++ b/inventaire.html
@@ -30,28 +30,21 @@
{{* types d'entrées et sorties *}}
-{{:include file="./_get_config.html" keep="config"}}
+{{:include file="./_get_config.html" keep="config, directions"}}
-{{#foreach from=$config.input_nature key=key}}
- {{:assign var="types.input.%s."|args:$type value=$key}}
-{{/foreach}}
+{{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config.%s_nature"|args:$direction}}
+ {{#foreach from=$nature key="key"}}
+ {{:assign var="types.%s.%s."|args:$direction:$type value=$key}}
+ {{/foreach}}
-{{#foreach from=$types.input key=key}}
- {{:assign var=elem from="types.input.%s"|args:$key}}
- {{:assign elem=$elem|quote_sql|implode:","}}
- {{:assign elem="("|cat:$elem|cat:")"}}
- {{:assign var="input_types.%s"|args:$key value=$elem}}
-{{/foreach}}
-
-{{#foreach from=$config.output_nature key=key}}
- {{:assign var="types.output.%s."|args:$type value=$key}}
-{{/foreach}}
-
-{{#foreach from=$types.output key=key}}
- {{:assign var=elem from="types.output.%s"|args:$key}}
- {{:assign elem=$elem|quote_sql|implode:","}}
- {{:assign elem="("|cat:$elem|cat:")"}}
- {{:assign var="output_types.%s"|args:$key value=$elem}}
+ {{:assign var="iotypes" from="types.%s"|args:$direction}}
+ {{#foreach from=$iotypes key="key"}}
+ {{:assign var=elem from="iotypes.%s"|args:$key}}
+ {{:assign elem=$elem|quote_sql|implode:","}}
+ {{:assign elem="("|cat:$elem|cat:")"}}
+ {{:assign var="%s_types.%s"|args:$direction:$key value=$elem}}
+ {{/foreach}}
{{/foreach}}
{{* filtrer selon la catégorie *}}
diff --git a/inventaire_nonprop.html b/inventaire_nonprop.html
index 68c4419..fe7d4a8 100644
--- a/inventaire_nonprop.html
+++ b/inventaire_nonprop.html
@@ -30,28 +30,21 @@
{{* types d'entrées et sorties *}}
-{{:include file="./_get_config.html" keep="config"}}
+{{:include file="./_get_config.html" keep="config, directions"}}
-{{#foreach from=$config.input_nature key=key}}
- {{:assign var="types.input.%s."|args:$type value=$key}}
-{{/foreach}}
+{{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config.%s_nature"|args:$direction}}
+ {{#foreach from=$nature key="key"}}
+ {{:assign var="types.%s.%s."|args:$direction:$type value=$key}}
+ {{/foreach}}
-{{#foreach from=$types.input key=key}}
- {{:assign var=elem from="types.input.%s"|args:$key}}
- {{:assign elem=$elem|quote_sql|implode:","}}
- {{:assign elem="("|cat:$elem|cat:")"}}
- {{:assign var="input_types.%s"|args:$key value=$elem}}
-{{/foreach}}
-
-{{#foreach from=$config.output_nature key=key}}
- {{:assign var="types.output.%s."|args:$type value=$key}}
-{{/foreach}}
-
-{{#foreach from=$types.output key=key}}
- {{:assign var=elem from="types.output.%s"|args:$key}}
- {{:assign elem=$elem|quote_sql|implode:","}}
- {{:assign elem="("|cat:$elem|cat:")"}}
- {{:assign var="output_types.%s"|args:$key value=$elem}}
+ {{:assign var="iotypes" from="types.%s"|args:$direction}}
+ {{#foreach from=$iotypes key="key"}}
+ {{:assign var=elem from="iotypes.%s"|args:$key}}
+ {{:assign elem=$elem|quote_sql|implode:","}}
+ {{:assign elem="("|cat:$elem|cat:")"}}
+ {{:assign var="%s_types.%s"|args:$direction:$key value=$elem}}
+ {{/foreach}}
{{/foreach}}
{{* filtrer selon la catégorie *}}
@@ -70,23 +63,23 @@
WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ;
(SELECT
SUM($$.amount)
- FROM module_data_equipment AS mvt
+ FROM @TABLE AS mvt
WHERE
$$.type = 'movement'
AND
$$.operation IN %s
AND
- $$.equipment = module_data_equipment.key
+ $$.equipment = @TABLE.key
) -
(SELECT
COALESCE(SUM($$.amount), 0)
- FROM module_data_equipment AS mvt
+ FROM @TABLE AS mvt
WHERE
$$.type = 'movement'
AND
$$.operation IN %s
AND
- $$.equipment = module_data_equipment.key
+ $$.equipment = @TABLE.key
) AS 'Quantité'
"|args:$input_types.temporaire:$output_types.retour
type="equipment"
diff --git a/mouvements/dupliquer_mouvement.html b/mouvements/dupliquer_mouvement.html
index eea614a..66f4695 100644
--- a/mouvements/dupliquer_mouvement.html
+++ b/mouvements/dupliquer_mouvement.html
@@ -61,17 +61,16 @@
{{/if}}
{{* préparer le mouvement copié *}}
+ {{:assign var="mvt_new.operation" value=$_POST.operation}}
+ {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}}
+
{{if $mvt_new.direction == "input"}}
- {{:assign var="mvt_new.operation" value=$_POST.operation}}
- {{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$mvt_new.operation}}
{{if $type_mvt == "temporaire"}}
{{:assign prop=0}}
{{else}}
{{:assign prop=1}}
{{/if}}
{{else}}
- {{:assign var="mvt_new.operation" value=$_POST.operation}}
- {{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$mvt_new.operation}}
{{if $type_mvt == "retour"}}
{{:assign prop=0}}
{{else}}
diff --git a/mouvements/modifier_mouvement.html b/mouvements/modifier_mouvement.html
index a41c57d..6c02bf8 100644
--- a/mouvements/modifier_mouvement.html
+++ b/mouvements/modifier_mouvement.html
@@ -13,7 +13,7 @@
{{/load}}
{{* récupérer la config des entrées/sorties *}}
-{{:include file="../_get_config.html" keep="config"}}
+{{:include file="../_get_config.html" keep="config, directions"}}
{{* infos pour affichage *}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}}
@@ -27,17 +27,12 @@
{{:error message="Aucun matériel avec la clé « %s »"|args:$eqpmt_key}}
{{/load}}
-{{if $mvt_new.direction == "input"}}
- {{* types d'entrées *}}
- {{#foreach from=$config.input_nature key=key}}
- {{:assign var="input_labels.%s"|args:$key value=$label}}
+{{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config.%s_nature"|args:$direction}}
+ {{#foreach from=$nature key="key"}}
+ {{:assign var="%s_labels.%s"|args:$direction:$key value=$label}}
{{/foreach}}
-{{else}}
- {{* types de sorties *}}
- {{#foreach from=$config.output_nature key=key}}
- {{:assign var="output_labels.%s"|args:$key value=$label}}
- {{/foreach}}
-{{/if}}
+{{/foreach}}
{{*
-------------------- Traiter la saisie --------------------
@@ -53,17 +48,16 @@
{{/if}}
{{* préparer le mouvement modifié *}}
+ {{:assign var="mvt_new.operation" value=$_POST.operation}}
+ {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}}
+
{{if $mvt_new.direction == "input"}}
- {{:assign var="mvt_new.operation" value=$_POST.operation}}
- {{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$mvt_new.operation}}
{{if $type_mvt == "temporaire"}}
{{:assign prop=0}}
{{else}}
{{:assign prop=1}}
{{/if}}
{{else}}
- {{:assign var="mvt_new.operation" value=$_POST.operation}}
- {{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$mvt_new.operation}}
{{if $type_mvt == "retour"}}
{{:assign prop=0}}
{{else}}
diff --git a/mouvements/supprimer_mouvement.html b/mouvements/supprimer_mouvement.html
index f3a22e9..25f6404 100644
--- a/mouvements/supprimer_mouvement.html
+++ b/mouvements/supprimer_mouvement.html
@@ -6,18 +6,11 @@
- prop : = 1 si matériel propriété de l'asso
*}}
-{{:assign var="libelles.input" value="entrée"}}
-{{:assign var="libelles.output" value="sortie"}}
-
{{#load key=$_GET.key assign="mvt_suppr"}}
{{else}}
{{:error message="Aucun mouvement avec la clé « %s »"|args:$_GET.key}}
{{/load}}
-{{:assign var="libelle" from="libelles.%s"|args:$mvt_suppr.direction}}
-{{:assign key_eqpmt_suppr=$mvt_suppr.equipment}}
-{{:assign var="date_suppr" value="%s"|args:$mvt_suppr.date|date_short}}
-
{{* trouver le matériel concerné par ce mouvement *}}
{{#load type="equipment" where="key = :key" :key=$mvt_suppr.equipment assign="equipment"}}
{{else}}
@@ -28,7 +21,7 @@
{{* récupérer la config des entrées/sorties *}}
{{:include file="../_get_config.html" keep="config"}}
- {{* TODO vérifier s'il est possible de supprimer le mouvement *}}
+ {{* vérifier s'il est possible de supprimer le mouvement *}}
{{if $mvt_suppr.direction == 'input'}}
{{:assign dispo=0}}
{{:assign nonprop=0}}
@@ -121,6 +114,8 @@
{{:admin_header title="Supprimer un mouvement" current="module_equipment"}}
{{:form_errors}}
+{{:assign var="date_suppr" value="%s"|args:$mvt_suppr.date|date_short}}
+
{{:delete_form
legend="Supprimer ?"
warning="Supprimer « %s (%d) en date du %s » ?"|args:$equipment.name:$mvt_suppr.amount:$date_suppr