diff --git a/_get_config.html b/_get_config.html
index 119a20b..0ebc002 100644
--- a/_get_config.html
+++ b/_get_config.html
@@ -16,21 +16,13 @@
{{: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}}
+ {{:assign var="config.%s_nature.%s"|args:$direction:$key value=$elem}}
{{/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}}
+ {{:assign var="config.%s_nature.%s"|args:$direction:$key value=$elem}}
{{/foreach}}
{{/if}}
{{/foreach}}
-
-{{if $module.config.loan_duration != null}}
- {{:assign loan_duration=$module.config.loan_duration}}
-{{else}}
- {{:assign loan_duration=$config_defaut.loan_duration}}
-{{/if}}
diff --git a/_inventory.html b/_inventory.html
index 090a01d..ce8cffc 100644
--- a/_inventory.html
+++ b/_inventory.html
@@ -1,40 +1,65 @@
{{* -*- brindille -*- *}}
{{*
- inventaire des entrées/sorties des matériels permanents
+ Inventaire des matériels en stock dans l'association
*}}
{{* filtrer selon la catégorie *}}
+{{:assign saved_filters=$module.config.filters}}
+{{:assign var="user_filters" from="saved_filters.%s"|args:$logged_user.id}}
+
{{if $_GET.cat_key == null}}
- {{:assign selected_category=$module.config.stock_cat_key}}
- {{if $module.config.stock_cat_key != null}}
- {{:assign cat_key=$selected_category|quote_sql}}
- {{/if}}
-{{elseif $_GET.cat_key == -1}}
- {{:assign selected_category=null}}
- {{:save key="config" stock_cat_key=null}}
+ {{:assign selected_category=$user_filters.stock_cat_key}}
{{else}}
- {{:assign selected_category=$_GET.cat_key}}
- {{:assign cat_key=$selected_category|quote_sql}}
- {{:save key="config" stock_cat_key=$selected_category}}
+ {{if $_GET.cat_key == -1}}
+ {{:assign selected_category=null}}
+ {{else}}
+ {{:assign selected_category=$_GET.cat_key}}
+ {{/if}}
+ {{:assign var="user_filters.stock_cat_key" value=$selected_category}}
+ {{:assign var="saved_filters.%s"|args:$logged_user.id value=$user_filters}}
+ {{:save key="config" filters=$saved_filters}}
{{/if}}
{{* condition de filtrage *}}
{{if $selected_category != null}}
+ {{:assign cat_key=$selected_category|quote_sql}}
{{:assign cat_condition="$$.category = %s"|args:$cat_key}}
{{else}}
{{:assign cat_condition="1"}}
{{/if}}
-{{* Sélecteur catégories *}}
-{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1&prop=1"}}
+{{* filtrer selon appartenance *}}
+{{if $_GET.prop == null}}
+ {{:assign selected_prop=$user_filters.stock_prop}}
+{{else}}
+ {{if $_GET.prop == -1}}
+ {{:assign selected_prop=null}}
+ {{else}}
+ {{:assign selected_prop=$_GET.prop}}
+ {{/if}}
+ {{:assign var="user_filters.stock_prop" value=$selected_prop}}
+ {{:assign var="saved_filters.%s"|args:$logged_user.id value=$user_filters}}
+ {{:save key="config" filters=$saved_filters}}
+{{/if}}
+
+{{if $selected_prop == null}}
+ {{:assign prop_condition="1"}}
+{{elseif $selected_prop == 1}}
+ {{:assign prop_condition="$$.stock NOT NULL"}}
+{{else}}
+ {{:assign prop_condition="$$.notowned != 0"}}
+{{/if}}
+
+{{* sélecteurs de catégorie et d'appartenance *}}
+{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
{{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}}
{{:assign
var="cat_options."
value=$key
label=$name
- href="?cat_key=%s&prop=1"|args:$key
+ href="?cat_key=%s"|args:$key
}}
{{/load}}
@@ -47,8 +72,21 @@
}}
+{{:assign var="prop_options." value="" label="Tous les matériels" href="?prop=-1"}}
+{{:assign var="prop_options." value="1" label="Matériels propriété de l'association" href="?prop=1"}}
+{{:assign var="prop_options." value="0" label="Matériels NON propriété de l'association" href="?prop=0"}}
+
+
+
{{#list
@@ -58,35 +96,32 @@
FROM @TABLE as cat
WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ;
$$.stock AS 'Stock' ;
+ (SELECT COALESCE($$.notowned, 0)) AS 'Temp' ;
+ (SELECT $$.stock + COALESCE($$.notowned, 0)) AS 'Total' ;
$$.out AS 'Sorti' ;
(SELECT $$.stock - $$.out) AS 'Disponible'
"
type="equipment"
- where="$$.status <> 'archived' AND $$.stock NOT NULL AND %s"|args:$cat_condition
+ where="$$.status <> 'archived' AND %s AND %s"|args:$cat_condition:$prop_condition
order=1
}}
{{:assign var=cat_name from=categories.%s|args:$category}}
- | {{:link href="equipment_history.html?key=%s&prop=1"|args:$key" label=$name}} |
+ {{if $selected_prop == null}}
+ {{:assign prop=""}}
+ {{else}}
+ {{:assign prop="&prop=%s"|args:$selected_prop}}
+ {{/if}}
+ {{:link href="equipment_history.html?key=%s&prop=%s"|args:$key:$selected_prop label=$name}} |
{{$cat_name}} |
{{$stock}} |
+ {{$col4}} |
+ {{$col5}}
| {{$out}} |
- {{$col5}} |
+ {{$col7}} |
- {{if $col5 > 0}}
- {{:linkbutton
- label="Sortie"
- shape="minus"
- href="movements/output_equipment.html?key=%s"|args:$key
- target="_dialog"}}
- {{/if}}
- {{:linkbutton
- label="Entrée"
- shape="plus"
- href="movements/input_equipment.html?key=%s"|args:$key
- target="_dialog"}}
{{:linkbutton
- label="Historique"
+ label="Mouvements"
href="equipment_history.html?key=%s&prop=1"|args:$key
shape="table"}}
{{:linkbutton
diff --git a/_nav.html b/_nav.html
index 3a79414..c615e3d 100644
--- a/_nav.html
+++ b/_nav.html
@@ -3,66 +3,72 @@
diff --git a/_temp_inventory.html b/_temp_inventory.html
index d4b29d4..df4f8aa 100644
--- a/_temp_inventory.html
+++ b/_temp_inventory.html
@@ -4,34 +4,12 @@
inventaire des entrées/sorties des matériels temporaires
*}}
-{{* filtrer selon la catégorie *}}
-{{if $_GET.cat_key == null}}
- {{:assign selected_category=$module.config.temp_cat_key}}
- {{if $module.config.temp_cat_key != null}}
- {{:assign cat_key=$selected_category|quote_sql}}
- {{/if}}
-{{elseif $_GET.cat_key == -1}}
- {{:assign selected_category=null}}
- {{:save key="config" temp_cat_key=null}}
-{{else}}
- {{:assign selected_category=$_GET.cat_key}}
- {{:assign cat_key=$selected_category|quote_sql}}
- {{:save key="config" temp_cat_key=$selected_category}}
-{{/if}}
-
-{{* condition de filtrage *}}
-{{if $selected_category != null}}
- {{:assign cat_condition="$$.category = %s"|args:$cat_key}}
-{{else}}
- {{:assign cat_condition="1"}}
-{{/if}}
-
{{* Sélecteur catégories *}}
-{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1&prop=0"}}
+{{:assign var="options." value="" label="Toutes les catégories" href="?prop=0"}}
{{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}}
{{:assign
- var="cat_options."
+ var="options."
value=$key
label=$name
href="?cat_key=%s&prop=0"|args:$key
@@ -42,8 +20,8 @@
{{:dropdown
title="Filtrer par catégorie"
- options=$cat_options
- value="%s"|args:$selected_category
+ options=$options
+ value="%s"|args:$_GET.cat_key
}}
@@ -51,6 +29,14 @@
Inventaire des matériels empruntés ou loués
+{{* filtrer selon la catégorie *}}
+{{if $_GET.cat_key == null}}
+ {{:assign condition="1"}}
+{{else}}
+ {{:assign cat_key=$_GET.cat_key|quote_sql}}
+ {{:assign condition="$$.category = %s"|args:$cat_key}}
+{{/if}}
+
{{#list
select="
$$.name AS 'Matériel' ;
@@ -60,7 +46,7 @@
$$.notowned AS 'Quantité'
"
type="equipment"
- where="$$.status <> 'archived' AND $$.notowned != 0 AND %s"|args:$cat_condition
+ where="$$.status <> 'archived' AND $$.notowned != 0 AND %s"|args:$condition
order=1
}}
{{:assign var=cat_name from=categories.%s|args:$category}}
diff --git a/archives.html b/archives.html
index 261673c..5525aab 100644
--- a/archives.html
+++ b/archives.html
@@ -9,11 +9,30 @@
Matériel remis en service
{{/if}}
+{{* filtrer selon la catégorie *}}
+{{if $_GET.cat_key == null}}
+ {{:assign selected_category=$module.config.archive_cat_key}}
+{{elseif $_GET.cat_key == -1}}
+ {{:assign selected_category=null}}
+ {{:save key="config" archive_cat_key=null}}
+{{else}}
+ {{:assign selected_category=$_GET.cat_key}}
+ {{:save key="config" archive_cat_key=$selected_category}}
+{{/if}}
+
+{{* condition de filtrage *}}
+{{if $selected_category == null}}
+ {{:assign cat_condition="1"}}
+{{else}}
+ {{:assign cat_key=$selected_category|quote_sql}}
+ {{:assign cat_condition="$$.category == %s"|args:$cat_key}}
+{{/if}}
+
{{* Sélecteur catégories *}}
-{{:assign var="options." value="" label="Toutes les catégories" href="?prop=1"}}
+{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
{{#load type="category" order="$$.name"}}
{{:assign
- var="options."
+ var="cat_options."
value=$key
label=$name
href="?cat_key=%s"|args:$key
@@ -24,8 +43,8 @@
{{:dropdown
title="Filtrer par catégorie"
- options=$options
- value="%s"|args:$_GET.cat_key
+ options=$cat_options
+ value="%s"|args:$selected_category
}}
@@ -33,14 +52,6 @@
Matériels qui ne sont plus dans l'association
-{{* filtrer selon la catégorie *}}
-{{if $_GET.cat_key == null}}
- {{:assign condition="1"}}
-{{else}}
- {{:assign cat_key=$_GET.cat_key|quote_sql}}
- {{:assign condition="$$.category == %s"|args:$cat_key}}
-{{/if}}
-
{{* Liste des matériels archivés *}}
{{#list
select="
@@ -50,16 +61,16 @@
WHERE cat.key = @TABLE.$$.category) AS "Catégorie"
"
type="equipment"
- where="$$.status='archived' AND %s"|args:$condition
+ where="$$.status='archived' AND %s"|args:$cat_condition
order=1
}}
|
- | {{$name}} |
+ {{:link href="equipment_history.html?key=%s&prop=1¤t=archives"|args:$key label=$name}} |
{{$col2}} |
{{:linkbutton
- label="Historique"
+ label="Mouvements"
href="equipment_history.html?key=%s&prop=1¤t=archives"|args:$key
shape="table"}}
{{:linkbutton
diff --git a/config.html b/config.html
index 9927c5e..f4bab4a 100644
--- a/config.html
+++ b/config.html
@@ -11,15 +11,22 @@
Configuration enregistrée.
{{/if}}
-{{* lecture config (défaut ou enregistrée) *}}
-{{:include file="./_get_config.html" keep="config, directions"}}
+{{* lecture config *}}
+{{:include file="./_get_config.html" keep="config_defaut, config, directions"}}
+
+{{* interdire la modification et la suppression des types de mouvement prédéfinis *}}
+{{#foreach from=$directions key="direction"}}
+ {{:assign var="nature" from="config_defaut.%ss"|args:$direction}}
+ {{#foreach from=$nature item="elem"}}
+ {{:assign var="default_keys." value=$key}}
+ {{/foreach}}
+{{/foreach}}
{{#foreach from=$directions key="direction" item="item"}}
{{* types de mouvements qui ne peuvent être supprimés *}}
{{#load type="movement" where="$$.direction='%s'"|args:$direction group="$$.operation"}}
- {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
- {{:assign var="locked_%ss."|args:$direction value=$op_label}}
+ {{:assign var="locked." value=$operation}}
{{/load}}
{{$item|ucfirst}}s
@@ -34,15 +41,23 @@
|
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
{{#foreach from=$nature key=key}}
+ {{:assign sortie_temp=false}}
+ {{if $direction == 'output'}}
+ {{:assign var="type" from="nature.%s.type"|args:$key}}
+ {{if $type == 'temporaire'}}
+ {{:assign sortie_temp=true}}
+ {{/if}}
+ {{/if}}
| {{$label}} |
{{$type}} |
- {{:assign var="locked" from="locked_%ss"|args:$direction}}
- {{if ! $locked|has:$label}}
+ {{if ! $default_keys|has:$key && ! $locked|has:$key}}
{{:linkbutton label="Supprimer" shape="delete" href="config/delete_movement_type.html?dir=%s&op_key=%s"|args:$direction:$key target="_dialog"}}
{{/if}}
+ {{if ! $default_keys|has:$key || $sortie_temp}}
{{:linkbutton label="Modifier" shape="edit" href="config/modify_movement_type.html?dir=%s&op_key=%s"|args:$direction:$key target="_dialog"}}
+ {{/if}}
|
{{/foreach}}
diff --git a/config.schema.json b/config.schema.json
index 8395b2f..1f9213c 100644
--- a/config.schema.json
+++ b/config.schema.json
@@ -36,6 +36,11 @@
"type" : {
"type" : "string",
"enum" : ["définitif", "temporaire", "retour"]
+ },
+ "fee" : {
+ "description" : "tarif sortie temporaire",
+ "type" : ["string", "null"],
+ "enum" : ["gratuit", "payant"]
}
}
}
diff --git a/config/add_movement_type.html b/config/add_movement_type.html
index 06881dc..ecf6866 100644
--- a/config/add_movement_type.html
+++ b/config/add_movement_type.html
@@ -12,18 +12,28 @@
{{* lecture config *}}
{{:include file="../_get_config.html" keep="config, directions, config_defaut"}}
+{{if ! $directions|has_key:$_GET.dir}}
+ {{:error message="Direction « %s » inconnue !"|args:$_GET.dir}}
+{{/if}}
+
{{#form on="save"}}
+ {{if $_POST.output_fields.type == "temporaire"}}
+ {{* vérifier si le tarif a été choisi *}}
+ {{if $_POST.tarif == null}}
+ {{:error message="Vous n'avez pas choisi le tarif"}}
+ {{/if}}
+ {{/if}}
+
{{* vérifier s'il existe un libellé de même nom dans la même direction *}}
{{#foreach from=$directions key="direction"}}
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
- {{#foreach from=$nature key="key"}}
+ {{#foreach from=$nature key="key" item="elem"}}
{{:assign var="fields" from="_POST.%s_fields"|args:$_GET.dir}}
- {{if $_GET.dir == $direction && $label|trim|tolower == $fields.label|trim|tolower}}
- {{:error message="Ce libellé est déjà présent"}}
+ {{if $_GET.dir == $direction && $fields.label|trim|tolower == $elem.label|trim|tolower}}
+ {{:error message="Le libellé « %s » est déjà présent"|args:$fields.label}}
{{/if}}
+ {{:assign var="%s_nature"|args:$direction value=$elem}}
{{: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}}
@@ -34,6 +44,13 @@
{{: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}}
+ {{if $_POST.output_fields != null}}
+ {{if $_POST.output_fields.type == "temporaire"}}
+ {{:assign var="output_nature.fee" value=$_POST.tarif}}
+ {{else}}
+ {{:assign var="output_nature.fee" value=null}}
+ {{/if}}
+ {{/if}}
{{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
{{/if}}
{{/foreach}}
@@ -104,34 +121,63 @@
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
{{/if}}
+
+
diff --git a/config/delete_movement_type.html b/config/delete_movement_type.html
index 4f0ddaa..801f821 100644
--- a/config/delete_movement_type.html
+++ b/config/delete_movement_type.html
@@ -10,16 +10,28 @@
{{* lecture config (défaut ou enregistrée) *}}
-{{:include file="../_get_config.html" keep="config, directions"}}
+{{:include file="../_get_config.html" keep="config_defaut, config, directions"}}
+
+{{if ! $directions|has_key:$_GET.dir}}
+ {{:error message="Direction « %s » inconnue !"|args:$_GET.dir}}
+{{/if}}
+
+{{* interdire la suppression des types de mouvement prédéfinis *}}
+{{:assign var="nature" from="config_defaut.%ss"|args:$_GET.dir}}
+{{#foreach from=$nature item="elem"}}
+ {{:assign var="default_keys." value=$key}}
+{{/foreach}}
+{{if $default_keys|has:$_GET.op_key}}
+ {{:error message="Ce type de mouvement ne peut être supprimé"}}
+{{/if}}
{{#form on="delete"}}
{{#foreach from=$directions key="direction"}}
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
- {{#foreach from=$nature key="key"}}
+ {{#foreach from=$nature key="key" item="elem"}}
{{if $_GET.dir == $direction && $key != $_GET.op_key || $_GET.dir != $direction}}
+ {{:assign var="%s_nature"|args:$direction value=$elem}}
{{: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}}
diff --git a/config/misc.html b/config/misc.html
index d49ef65..7034c04 100644
--- a/config/misc.html
+++ b/config/misc.html
@@ -2,31 +2,35 @@
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
-{{:admin_header title="Configuration" current="module_equipment"}}
-
{{#form on="save"}}
+ {{* vérifier la validité de la durée saisie *}}
+ {{if $_POST.loan_duration < 0}}
+ {{:error message="Durée (%s) erronée ; doit être >= 0"|args:$_POST.loan_duration}}
+ {{/if}}
+
{{:save
- key="config"
- loan_duration=$_POST.loan_duration
+ key="config"
+ loan_duration=$_POST.loan_duration
}}
+
{{/form}}
-{{* barre de navigation *}}
+{{:admin_header title="Configuration" current="module_equipment"}}
{{:include file="../_nav.html" current="config" subcurrent="divers"}}
+{{:form_errors}}
{{if $_GET.ok}}
Configuration enregistrée.
{{/if}}
-{{* lecture config (défaut ou enregistrée) *}}
+{{* lecture config *}}
{{:include file="../_get_config.html" keep="loan_duration"}}