diff --git a/_get_config.html b/_get_config.html index 0ebc002..07ef418 100644 --- a/_get_config.html +++ b/_get_config.html @@ -26,3 +26,9 @@ {{/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 ce8cffc..213bcc9 100644 --- a/_inventory.html +++ b/_inventory.html @@ -112,7 +112,7 @@ {{else}} {{:assign prop="&prop=%s"|args:$selected_prop}} {{/if}} - {{:link href="equipment_history.html?key=%s&prop=%s"|args:$key:$selected_prop label=$name}} + {{:link href="equipment_history.html?key=%s&prop=%s"|args:$key:$selected_prop" label=$name}} {{$cat_name}} {{$stock}} {{$col4}} @@ -120,8 +120,22 @@ {{$out}} {{$col7}} +{{* + {{if $col7 > 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="Mouvements" + label="Historique" href="equipment_history.html?key=%s&prop=1"|args:$key shape="table"}} {{:linkbutton diff --git a/_nav.html b/_nav.html index c615e3d..10a41d0 100644 --- a/_nav.html +++ b/_nav.html @@ -3,29 +3,13 @@ diff --git a/archives.html b/archives.html index 5525aab..efb1a22 100644 --- a/archives.html +++ b/archives.html @@ -66,11 +66,11 @@ }} - {{:link href="equipment_history.html?key=%s&prop=1¤t=archives"|args:$key label=$name}} + {{$name}} {{$col2}} {{:linkbutton - label="Mouvements" + label="Historique" href="equipment_history.html?key=%s&prop=1¤t=archives"|args:$key shape="table"}} {{:linkbutton diff --git a/config.schema.json b/config.schema.json index 1f9213c..8395b2f 100644 --- a/config.schema.json +++ b/config.schema.json @@ -36,11 +36,6 @@ "type" : { "type" : "string", "enum" : ["définitif", "temporaire", "retour"] - }, - "fee" : { - "description" : "tarif sortie temporaire", - "type" : ["string", "null"], - "enum" : ["gratuit", "payant"] } } } diff --git a/config/misc.html b/config/misc.html index 7034c04..ba11eec 100644 --- a/config/misc.html +++ b/config/misc.html @@ -3,9 +3,9 @@ {{#restrict block=true section="accounting" level="write"}}{{/restrict}} {{#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}} + {{* vérifier la valisité 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 @@ -30,7 +30,7 @@
Autres paramètres
- {{:input type="number" name="loan_duration" label="Durée de prêt par défaut" min=0 default=$module.config.loan_duration help="Durée en nombre de jours ; mettre 0 pour supprimer la durée par défaut"}} + {{:input type="number" name="loan_duration" label="Durée de prêt par défaut" min=1 required=true default=$loan_duration help="Durée en nombre de jours"}}

diff --git a/default.json b/default.json index ab06a2c..b9906b7 100644 --- a/default.json +++ b/default.json @@ -26,19 +26,13 @@ { "key" : "c9ba00d9-26ee-448b-9f02-73e479ec2980", "label" : "Prêt", - "type" : "temporaire", - "fee" : "gratuit" - }, - { - "key" : "5c6c20bf-53e9-49dc-bcd6-e3cac23a6786", - "label" : "Location", - "type" : "temporaire", - "fee" : "payant" + "type" : "temporaire" }, { "key" : "fefefa51-1a85-46ca-ab78-b594b10390ff", "label" : "Retour de Location/Emprunt", "type" : "retour" } - ] + ], + "loan_duration" : "30" } diff --git a/equipment_history.html b/equipment_history.html index 5db0fb6..83c0860 100644 --- a/equipment_history.html +++ b/equipment_history.html @@ -31,6 +31,25 @@ {{else}} {{:assign current="inventaire"}} {{/if}} +{{:include file="./_nav.html" current=$current subcurrent="historique" eqpmt=$equipment.name category=$category.name}} + +{{if $_GET.ok}} + {{if $_GET.msg == "modification"}} +

Modification enregistrée

+ {{elseif $_GET.msg == "copie"}} +

Mouvement copié

+ {{elseif $_GET.msg == "retour"}} +

Retour enregistré

+ {{elseif $_GET.msg == "suppression"}} +

Mouvement supprimé

+ {{else}} +

Mouvement enregistré

+ {{/if}} +{{elseif $_GET.err}} + {{if $_GET.msg == "suppression"}} +

Ce mouvement ne peut être supprimé

+ {{/if}} +{{/if}} {{* récupérer la config des entrées/sorties *}} {{:include file="./_get_config.html" keep="config"}} @@ -229,29 +248,6 @@ {{:assign var="prop_options." value="1" label="Matériels propriété de l'association" href="?key=%s&prop=1"|args:$_GET.key}} {{:assign var="prop_options." value="0" label="Matériels NON propriété de l'association" href="?key=%s&prop=0"|args:$_GET.key}} -{{if $dispo_final > 0 && $selected_prop == null || $selected_prop}} - {{:assign sortie="sortie"}} -{{/if}} -{{:include file="./_nav.html" current=$current subcurrent="mouvements" eqpmt=$equipment.name category=$category.name sortie=$sortie key=$_GET.key}} - -{{if $_GET.ok}} - {{if $_GET.msg == "modification"}} -

Modification enregistrée

- {{elseif $_GET.msg == "copie"}} -

Mouvement copié

- {{elseif $_GET.msg == "retour"}} -

Retour enregistré

- {{elseif $_GET.msg == "suppression"}} -

Mouvement supprimé

- {{else}} -

Mouvement enregistré

- {{/if}} -{{elseif $_GET.err}} - {{if $_GET.msg == "suppression"}} -

Ce mouvement ne peut être supprimé

- {{/if}} -{{/if}} -
Filtrer par appartenance {{:dropdown @@ -261,6 +257,17 @@ }}
+{{if $current != "archives"}} + +{{/if}} + {{* lister les mouvements du matériel passé en paramètre *}} {{#list type="movement" @@ -268,7 +275,6 @@ where="%s"|args:$prop_condition equipment=$equipment_key order=1 - desc=true }} {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} @@ -316,19 +322,12 @@ {{if $transactions|count > 0}}{{"Oui"}}{{/if}} {{if $current != "archives"}} - {{if $direction == "output" && $type_mvt == "retour"}} - {{:assign prop = 0}} - {{elseif $direction == "input" && $type_mvt == "temporaire"}} - {{:assign prop = 0}} - {{else}} - {{:assign prop = 1}} - {{/if}} {{if $direction == "output" && $type_mvt == "temporaire"}} {{:assign var="temp_ext" from="reste.%s"|args:$key}} {{if $temp_ext != null && $temp_ext > 0}} {{:linkbutton label="Retour" - href="movements/output_return.html?key=%s&prop=%s"|args:$key:$prop + href="movements/output_return.html?key=%s&prop=%s"|args:$key:$selected_prop shape="reset" target="_dialog"}} {{/if}} @@ -338,14 +337,14 @@ {{if $temp_in != null && $temp_in > 0}} {{:linkbutton label="Retour" - href="movements/input_return.html?key=%s&prop=%s"|args:$key:$prop + href="movements/input_return.html?key=%s&prop=%s"|args:$key:$selected_prop shape="reset" target="_dialog"}} {{/if}} {{/if}} {{:linkbutton label="Détails" - href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$prop + href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$selected_prop shape="eye" }} {{/if}} @@ -353,6 +352,10 @@ {{/list}} +{{if $dispo_final == 0 && $stock > 0 && $current != "archives"}} + Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie +{{/if}} + {{:admin_footer}} diff --git a/index.html b/index.html index d05fab9..740bf3b 100644 --- a/index.html +++ b/index.html @@ -14,9 +14,6 @@ {{else}} {{#restrict block=true section="accounting" level="write"}}{{/restrict}} - {{#load type="category" count=true limit=1 assign="result"}}{{/load}} - {{:include file="_nav.html" current="inventaire" cat="%d"|args:$result.count subcurrent="stock"}} - {{if $_GET.ok}} {{if $_GET.msg == "ajout" }}

Ajout effectué

@@ -31,6 +28,9 @@

Modification refusée

{{/if}} + {{#load type="category" count=true limit=1 assign="result"}}{{/load}} + {{:include file="_nav.html" current="inventaire" cat="%d"|args:$result.count subcurrent="stock"}} + {{if $result.count == 0}}

Il n'y a aucune catégorie : vous devez en ajouter.

{{else}} diff --git a/loan_history.html b/loan_history.html index 92c4ee1..a7ff7de 100644 --- a/loan_history.html +++ b/loan_history.html @@ -99,6 +99,10 @@ }} +
+

{{$label|ucfirst}} de matériel en cours

+
+ {{:assign premier=true}} {{#select users.nom AS nom, diff --git a/loan_movements.html b/loan_movements.html index cf9fcda..4a3f859 100644 --- a/loan_movements.html +++ b/loan_movements.html @@ -104,6 +104,10 @@ }} +
+

Historique des {{$label}}s

+
+ {{* lister les mouvements *}} {{:assign premier=true}} {{#select * FROM diff --git a/member_loan.html b/member_loan.html index 28f7278..9f40061 100644 --- a/member_loan.html +++ b/member_loan.html @@ -42,6 +42,10 @@ {{:assign out_keys=$out_keys|implode:","}} {{:assign out_keys="("|cat:$out_keys|cat:")"}} +
+

{{$label|ucfirst}}s aux membres

+
+ {{:assign premier=true}} {{#select nom, user, GROUP_CONCAT(mat_name, ", ") AS materiel, SUM(remain) AS quantite @@ -86,20 +90,12 @@ {{$materiel}} {{else}} - {{if $label == "prêt"}} -

Aucun {{$label}} en cours.

- {{elseif $label == "location"}} -

Aucune {{$label}} en cours.

- {{/if}} +

Aucun mouvement.

{{/select}} {{else}} - {{if $label == "prêt"}} -

Aucun {{$label}} en cours.

- {{elseif $label == "location"}} -

Aucune {{$label}} en cours.

- {{/if}} +

Aucun mouvement.

{{/if}} {{:admin_footer}} diff --git a/movements/add_new_equipment.html b/movements/add_new_equipment.html index 456cfdd..30614d6 100644 --- a/movements/add_new_equipment.html +++ b/movements/add_new_equipment.html @@ -150,7 +150,7 @@
- Autres informations + Informations facultatives
{{if $storage != null}} {{:input type="select" name="storage" label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}} diff --git a/movements/copy_movement.html b/movements/copy_movement.html index 6814d88..e1ebf4e 100644 --- a/movements/copy_movement.html +++ b/movements/copy_movement.html @@ -16,7 +16,7 @@ {{/load}} {{* récupérer la config des entrées/sorties *}} -{{:include file="../_get_config.html" keep="config, directions"}} +{{:include file="../_get_config.html" keep="config, directions, loan_duration"}} {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}} {{* interdire de dupliquer un retour => utiliser le bouton « Retour » *}} @@ -95,12 +95,8 @@ {{:assign var="mvt_new.amount" value=$_POST.amount}} {{:assign var="mvt_new.date" value=$_POST.date|parse_date}} {{:assign var="mvt_new.comment" value=$_POST.comment}} - - {{if $_POST.return_date != null}} - {{:assign return_date=$_POST.return_date|parse_date}} - {{if $return_date < $_POST.date|parse_date}} - {{:error message="La date de retour doit être postérieure à la date de sortie !"}} - {{/if}} + {{if $_POST.set_return_date != null}} + {{:assign return_date=$_POST.return_date}} {{else}} {{:assign return_date=null}} {{/if}} @@ -209,7 +205,7 @@ user=$user.id storage=$_POST.storage transactions=$transactions - return_date=$return_date + return_date=$return_date|parse_date }} {{if $_GET.from|substr:0:1 == "l"}} @@ -244,6 +240,7 @@ -------------------- Préparer la saisie -------------------- *}} +{{* récupérer les infos de la catégorie *}} {{#load key=$equipment.category assign="category"}}{{/load}} {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}} @@ -271,18 +268,17 @@
Informations obligatoires
- {{:input type="date" name="date" label="Date" required=true default=$mvt_new.date}} - {{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_new.amount}} {{if $mvt_new.direction == "input"}} {{:input type="select" name="operation" label="Type" required=true options=$input_labels|sort default=$mvt_new.operation}} {{else}} {{:input type="select" name="operation" label="Type" required=true options=$output_labels|sort default=$mvt_new.operation}} {{/if}} + {{:input type="date" name="date" label="Date" required=true default=$mvt_new.date}} + {{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_new.amount}}
-
- Autres informations + Informations facultatives
{{if $prop == 1 && $mvt_new.direction == "output"}} {{:input @@ -296,25 +292,27 @@ }} {{/if}} {{if $mvt_new.direction == "input" && $storage != null}} - {{:input type="select" name="storage" label="Lieu de stockage" default=$mvt_new.storage default_empty="— Aucun —" options=$storage required=false}} + {{:input type="select" name="storage" default=$mvt_new.storage label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}} {{/if}} {{if $type_mvt != "retour"}} {{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}} {{/if}} - {{:input type="textarea" name="comment" label="Remarques" cols="40" rows="3" required=false default=$mvt_new.comment}} - {{if $mvt_new.direction == "output"}} + {{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_new.comment}} + {{if $mvt_new.direction == "output" && $type_mvt == "temporaire"}} {{if $mvt_new.return_date != null}} + {{:assign checked="checked"}} + {{:assign visibility="visible"}} {{:assign return_date=$mvt_new.return_date}} {{else}} - {{if $module.config.loan_duration != null && $module.config.loan_duration > 0}} - {{:assign ts_sortie=$mvt_new.date|strtotime}} - {{:assign ts_retour="%d+%d*(60*60*24)"|math:$ts_sortie:$module.config.loan_duration}} - {{:assign return_date=$ts_retour|date_short}} - {{/if}} + {{:assign visibility="hidden"}} + {{:assign ts_sortie=$mvt_new.date|strtotime}} + {{:assign ts_retour="%d+%d*(60*60*24)"|math:$ts_sortie:$loan_duration}} + {{:assign return_date=$ts_retour|date_short}} {{/if}} -
+ {{:input id="set_return_date" type="checkbox" value=1 name="set_return_date" label="Fixer une date de retour" help="Cocher pour fixer une date de retour" checked="%s"|args:$checked}} +
{{:input type="date" name="return_date" label="Date de retour" default=$return_date}} - +
{{/if}}
@@ -329,17 +327,9 @@ {{:admin_footer}} - diff --git a/movements/delete_movement.html b/movements/delete_movement.html index ce9e4c3..0ecafb2 100644 --- a/movements/delete_movement.html +++ b/movements/delete_movement.html @@ -173,7 +173,7 @@ {{else}} {{* supprimer le matériel *}} {{:delete key=$curr_eqpmt.key}} - {{:redirect force="../index.html?ok=1&msg=supprmvtmat"|args}} + {{:redirect force="%s?ok=1&msg=supprmvtmat%s"|args:$from:$param}} {{/if}} {{/form}} diff --git a/movements/input_equipment.html b/movements/input_equipment.html index 502580e..31fe136 100644 --- a/movements/input_equipment.html +++ b/movements/input_equipment.html @@ -116,7 +116,7 @@
- Autres informations + Informations facultatives
{{if $storage != null}} {{:input type="select" name="storage" label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}} diff --git a/movements/modify_movement.html b/movements/modify_movement.html index 7dd87d0..5a9f1bd 100644 --- a/movements/modify_movement.html +++ b/movements/modify_movement.html @@ -15,7 +15,22 @@ {{/load}} {{* récupérer la config des entrées/sorties *}} -{{:include file="../_get_config.html" keep="config, directions"}} +{{:include file="../_get_config.html" keep="config, directions, loan_duration"}} +{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}} + +{{if $mvt_new.direction == "input"}} + {{if $type_mvt == "temporaire"}} + {{:assign prop=0}} + {{else}} + {{:assign prop=1}} + {{/if}} +{{else}} + {{if $type_mvt == "retour"}} + {{:assign prop=0}} + {{else}} + {{:assign prop=1}} + {{/if}} +{{/if}} {{* infos pour affichage *}} {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}} @@ -30,15 +45,25 @@ {{:error message="Aucun matériel avec la clé « %s »"|args:$eqpmt_key}} {{/load}} +{{#foreach from=$directions key="direction"}} + {{:assign var="nature" from="config.%s_nature"|args:$direction}} + {{#foreach from=$nature key="key"}} + {{if $type_mvt != "retour" && $type != "retour" || + $type_mvt == "retour" && $type == "retour"}} + {{:assign var="%s_labels.%s"|args:$direction:$key value=$label}} + {{/if}} + {{/foreach}} +{{/foreach}} + {{* -------------------- Traiter la saisie -------------------- *}} {{#form on="save"}} - {{* vérifier la validité de la saisie *}} {{if $_POST.amount <= 0}} {{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}} {{/if}} + {{* vérifier validité des données *}} {{if $_POST.date|parse_date|strtotime > $now}} {{:error message="Impossible de saisir une date dans le futur (%s)"|args:$_POST.date}} {{/if}} @@ -61,13 +86,8 @@ {{:assign var="mvt_new.amount" value=$_POST.amount}} {{:assign var="mvt_new.date" value=$_POST.date|parse_date}} {{:assign var="mvt_new.comment" value=$_POST.comment}} - {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}} - - {{if $_POST.return_date != null}} - {{:assign return_date=$_POST.return_date|parse_date}} - {{if $return_date < $_POST.date|parse_date}} - {{:error message="La date de retour doit être postérieure à la date de sortie !"}} - {{/if}} + {{if $_POST.set_return_date != null}} + {{:assign return_date=$_POST.return_date}} {{else}} {{:assign return_date=null}} {{/if}} @@ -79,7 +99,10 @@ *}} {{:assign insere=false}} {{#load - where="$$.type = 'movement' AND $$.equipment = :eqpmt_key" + where=" + $$.type = 'movement' + AND + $$.equipment = :eqpmt_key" :eqpmt_key=$eqpmt_key order="$$.date" assign="movement" @@ -199,7 +222,7 @@ user=$user_id storage=$_POST.storage transactions=$transactions - return_date=$return_date + return_date=$return_date|parse_date }} {{if $_GET.from|substr:0:1 == "l"}} @@ -213,20 +236,6 @@ {{:assign suffix="movements"}} {{/if}} - {{if $mvt_new.direction == "input"}} - {{if $type_mvt == "temporaire"}} - {{:assign prop=0}} - {{else}} - {{:assign prop=1}} - {{/if}} - {{else}} - {{if $type_mvt == "retour"}} - {{:assign prop=0}} - {{else}} - {{:assign prop=1}} - {{/if}} - {{/if}} - {{if $_GET.from == "eh"}} {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}} {{elseif $suffix == null}} @@ -242,26 +251,14 @@ {{:assign mvt_label="sortie"}} {{/if}} {{:admin_header title="Modifier une %s"|args:$mvt_label custom_css="./../style.css" current="module_equipment"}} -{{:form_errors}} +{{:form_errors}} {{* -------------------- Préparer la saisie -------------------- *}} {{#load key=$equipment.category assign="category"}}{{/load}} -{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}} -{{#foreach from=$directions key="direction"}} - {{:assign var="nature" from="config.%s_nature"|args:$direction}} - {{#foreach from=$nature key="key"}} - {{if $type_mvt != "retour" && $type != "retour" || - $type_mvt == "retour" && $type == "retour"}} - {{:assign var="%s_labels.%s"|args:$direction:$key value=$label}} - {{/if}} - {{/foreach}} -{{/foreach}} - - {{if $mvt_new.user != null}} {{#select id, !name as nom FROM users WHERE id=:id; !name=$config.user_fields.name_sql :id=$mvt_new.user}} {{:assign var="user.%s"|args:$id value=$nom}} @@ -305,9 +302,9 @@
- Autres informations + Informations facultatives
- {{if $mvt_new.direction == "output" && $type_mvt != "retour"}} + {{if $prop == 1 && $mvt_new.direction == "output"}} {{:input type="list" name="user" @@ -318,26 +315,30 @@ max=1 }} {{/if}} - {{if $mvt_new.direction == "input" && $storage != null}} - {{:input type="select" name="storage" label="Lieu de stockage" default=$mvt_new.storage default_empty="— Aucun —" options=$storage required=false}} + {{if $mvt_new.direction == "input"}} + {{if $storage != null}} + {{:input type="select" name="storage" label="Lieu de stockage" default=$mvt_new.storage default_empty="— Aucun —" options=$storage required=false}} + {{/if}} {{/if}} {{if $type_mvt != "retour"}} - {{:input type="list" name="transactions" label="Écritures liées" default=$mvt_new.transactions target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}} + {{:input type="list" name="transactions" default=$mvt_new.transactions label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}} {{/if}} {{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_new.comment}} - {{if $mvt_new.direction == "output"}} + {{if $mvt_new.direction == "output" && $type_mvt == "temporaire"}} {{if $mvt_new.return_date != null}} + {{:assign checked="checked"}} + {{:assign visibility="visible"}} {{:assign return_date=$mvt_new.return_date}} {{else}} - {{if $module.config.loan_duration != null && $module.config.loan_duration > 0}} - {{:assign ts_sortie=$mvt_new.date|strtotime}} - {{:assign ts_retour="%d+%d*(60*60*24)"|math:$ts_sortie:$module.config.loan_duration}} - {{:assign return_date=$ts_retour|date_short}} - {{/if}} + {{:assign visibility="hidden"}} + {{:assign ts_sortie=$mvt_new.date|strtotime}} + {{:assign ts_retour="%d+%d*(60*60*24)"|math:$ts_sortie:$loan_duration}} + {{:assign return_date=$ts_retour|date_short}} {{/if}} -
+ {{:input id="set_return_date" type="checkbox" value=1 name="set_return_date" label="Fixer une date de retour" help="Cocher pour fixer une date de retour" checked="%s"|args:$checked}} +
{{:input type="date" name="return_date" label="Date de retour" default=$return_date}} - +
{{/if}}
@@ -352,17 +353,9 @@ {{:admin_footer}} - diff --git a/movements/output_equipment.html b/movements/output_equipment.html index 7a1958a..7043184 100644 --- a/movements/output_equipment.html +++ b/movements/output_equipment.html @@ -9,7 +9,7 @@ *}} {{* récupérer la config des entrées/sorties *}} -{{:include file="../_get_config.html" keep="config"}} +{{:include file="../_get_config.html" keep="config, loan_duration"}} {{* types de sorties *}} {{#foreach from=$config.output_nature key=key}} @@ -33,27 +33,22 @@ {{* Traiter l'envoi du formulaire *}} {{#form on="save"}} - {{* vérifier la validité de la saisie *}} - {{* interdire date dans le futur *}} {{if $_POST.date|parse_date|strtotime > $now}} {{:error message="Impossible de saisir une date dans le futur (%s)"|args:$_POST.date}} {{/if}} + {{* vérifier les infos saisies *}} {{if $_POST.operation == ""}} {{:error message="Vous devez choisir un type de sortie"}} {{/if}} {{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$_POST.operation}} - {{if $type_mvt != "temporaire" && $_POST.return_date != null}} + {{if $type_mvt != "temporaire" && $_POST.set_return_date != null}} {{:error message="On ne peut associer une date de retour qu'à une sortie temporaire"}} {{/if}} - - {{if $_POST.return_date != null}} - {{:assign return_date=$_POST.return_date|parse_date}} - {{if $return_date < $_POST.date|parse_date}} - {{:error message="La date de retour doit être postérieure à la date de sortie !"}} - {{/if}} + {{if $_POST.set_return_date != null}} + {{:assign return_date=$_POST.return_date}} {{else}} {{:assign return_date=null}} {{/if}} @@ -174,7 +169,7 @@ date=$_POST.date|parse_date comment=$_POST.remarques|trim user=$user.id - return_date=$return_date + return_date=$return_date|parse_date transactions=$transactions }} {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=1&msg=sortie"|args:$_GET.key}} @@ -185,16 +180,13 @@ {{* barre de navigation *}} {{:include file="../_nav.html" current="sorties"}} {{/if}} -{{:form_errors}} {{#load key=$equipment.category assign="category"}}{{/load}} {{:assign dispo="%d-%d"|math:$equipment.stock:$equipment.out}} {{if $dispo > 0}} - {{if $module.config.loan_duration != null && $module.config.loan_duration > 0}} - {{:assign ts_retour="%d+%d*(60*60*24)"|math:$now:$module.config.loan_duration}} - {{:assign date_retour=$ts_retour|date_short}} - {{/if}} + {{:assign ts_retour="%d+%d*(60*60*24)"|math:$now:$loan_duration}} + {{:assign date_retour=$ts_retour|date_short}} {{* formulaire de sortie de matériel *}}
@@ -234,9 +226,10 @@ }} {{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}} {{:input type="textarea" name="remarques" label="Remarques" cols="40" rows="3" required=false}} -
+ {{:input id="set_return_date" type="checkbox" value=1 name="set_return_date" label="Fixer une date de retour" help="Cocher pour fixer une date de retour"}} +
@@ -248,20 +241,16 @@

Il n'y a aucune unité de ce matériel disponible à la date du {{$now|date_short}}

{{/if}} +{{:form_errors}} {{:admin_footer}} diff --git a/movements/output_return.html b/movements/output_return.html index b5c5e9c..ba51ec2 100644 --- a/movements/output_return.html +++ b/movements/output_return.html @@ -220,7 +220,7 @@
- Autres informations + Informations facultatives
{{if $storage != null}} {{:input type="select" name="storage" label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}} diff --git a/scripts.js b/scripts.js index c913078..2de1a45 100644 --- a/scripts.js +++ b/scripts.js @@ -26,6 +26,18 @@ function disableColumSort(liste) { } } +function toggleVisibility(idcheck, fields) { + const elem = document.getElementById(idcheck); + for (let id of fields) { + const field = document.getElementById(id); + if (elem.checked) { + field.style.visibility = "visible"; + } else { + field.style.visibility = "hidden"; + } + } +} + /** * renvoyer la valeur en secondes d'une date au format j/m/a * @param {string} date @@ -47,29 +59,7 @@ function getDate(idelem) { function setReturnDate(id_date, id_return_date, id_loan_duration) { const loan_duration = document.getElementById(id_loan_duration).value; - if (loan_duration !== undefined && loan_duration > 0) { - let nbsec = getDate(id_date) + loan_duration*24*60*60; - const date_retour = new Date(nbsec * 1000); - document.getElementById(id_return_date).value = date_retour.toLocaleDateString(); - } -} - -/** - * changer la visibilité de la date de retour - */ -function toggleVisibility(id_date, id_type, div, id_return_date) -{ - const key = document.getElementById(id_type).value; - let type_sortie; - if (key !== undefined && key != '') { - type_sortie = output_nature[key].type; - } - const div_date = document.getElementById(div); - if (type_sortie == 'temporaire') { - div_date.style.visibility = "visible"; - document.getElementById(id_date).onchange(); - } else { - div_date.style.visibility = "hidden"; - document.getElementById(id_return_date).value = null; - } + let nbsec = getDate(id_date) + loan_duration*24*60*60; + const date_retour = new Date(nbsec * 1000); + document.getElementById(id_return_date).value = date_retour.toLocaleDateString(); } diff --git a/snippets/_details.html b/snippets/_details.html index 10a1fe1..9ab9458 100644 --- a/snippets/_details.html +++ b/snippets/_details.html @@ -135,9 +135,9 @@ {{if $retard < 0}} {{:assign delai="abs(%d)"|math:$retard}} {{"Reste %s jours"|args:$delai}} - {{elseif $retard > 0 }} + {{elseif $retard >0 }} {{:tag color="darkred" label="Retard %s jours"|args:$retard}} - {{elseif $return_date != null}} + {{else}} {{:tag color="darkgreen" label="À rendre aujourdh'ui"}} {{/if}}