From 572dfc172a8c71079ac214d6eebd63da68f570c3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 29 Oct 2025 14:20:58 +0100 Subject: [PATCH] =?UTF-8?q?Histo=20pr=C3=AAts=20:=20ajout=20bouton=20d?= =?UTF-8?q?=C3=A9tails=20+=20navigation=20+=20mutualisation=20js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- equipment_history.html | 4 +-- loan_history.html | 47 ++++++++++++++++++++++++--------- movements/copy_movement.html | 14 +++++++++- movements/delete_movement.html | 13 ++++++--- movements/modify_movement.html | 17 +++++++----- movements/movement_details.html | 6 ++--- movements/output_equipment.html | 8 +++--- scripts.js | 11 ++++++++ 8 files changed, 86 insertions(+), 34 deletions(-) diff --git a/equipment_history.html b/equipment_history.html index 9bb584d..f96010d 100644 --- a/equipment_history.html +++ b/equipment_history.html @@ -224,7 +224,7 @@ {{/if}} {{:linkbutton label="Détails" - href="movements/movement_details.html?key=%s&prop=%s"|args:$key:$_GET.prop + href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop shape="eye" }} {{/if}} @@ -314,7 +314,7 @@ {{/if}} {{:linkbutton label="Détails" - href="movements/movement_details.html?key=%s&prop=%s"|args:$key:$_GET.prop + href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop shape="eye" }} diff --git a/loan_history.html b/loan_history.html index 28a246c..42006aa 100644 --- a/loan_history.html +++ b/loan_history.html @@ -1,6 +1,21 @@ {{* -*- brindille -*- *}} {{:admin_header title="Matériels hors de l'asso" custom_css="../style.css" current="module_equipment"}} + +{{if $_GET.ok}} + {{if $_GET.msg == "modification"}} +

Modification enregistrée

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

Mouvement copié

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

Mouvement supprimé

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

Ce mouvement ne peut être supprimé

+ {{/if}} +{{/if}} + {{:include file="./_nav.html" current="historique" subcurrent="prêts"}} {{* lecture config (défaut ou enregistrée) *}} @@ -24,11 +39,11 @@ json_extract(mvt.document, '$.amount') AS out_amount, json_extract(mvt.document, '$.return_date') AS return_date, json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS remain - FROM module_data_equipment AS mvt + FROM {!$module.table} AS mvt INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id - LEFT JOIN module_data_equipment AS links ON mvt.key = json_extract(links.document, '$.temp_key') - LEFT JOIN module_data_equipment AS retour ON retour.key = json_extract(links.document, '$.return') - INNER JOIN module_data_equipment AS mat ON mat.key = json_extract(mvt.document, '$.equipment') + LEFT JOIN {!$module.table} AS links ON mvt.key = json_extract(links.document, '$.temp_key') + LEFT JOIN {!$module.table} AS retour ON retour.key = json_extract(links.document, '$.return') + INNER JOIN {!$module.table} AS mat ON mat.key = json_extract(mvt.document, '$.equipment') WHERE json_extract(mvt.document, '$.type') = 'movement' AND @@ -70,14 +85,17 @@ {{$remain}} {{if $return_date != null}} - {{if $nb_jours > 0}} - {{:tag color="darkred" label="Retard %s jours"|args:$nb_jours}} - {{elseif $nb_jours < 0}} - {{:assign delai="abs(%d)"|math:$nb_jours}} - {{"Reste %s jours"|args:$delai}} - {{else}} - {{:tag color="darkgreen" label="À rendre aujourdh'ui"}} - {{/if}} + {{:assign jour="jour}} + {{if $nb_jours > 0}} + {{if $nb_jours > 1}}{{:assign jour="jours"}}{{/if}} + {{:tag color="darkred" label="Retard %s %s"|args:$nb_jours:$jour}} + {{elseif $nb_jours < 0}} + {{:assign delai="abs(%d)"|math:$nb_jours}} + {{if $nb_jours < -1}}{{:assign jour="jours"}}{{/if}} + {{"Reste %s %s"|args:$delai:$jour}} + {{else}} + {{:tag color="darkgreen" label="À rendre aujourdh'ui"}} + {{/if}} {{/if}} @@ -86,6 +104,11 @@ href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key shape="reset" target="_dialog"}} + {{:linkbutton + label="Détails" + href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key + shape="eye" + }} {{else}} diff --git a/movements/copy_movement.html b/movements/copy_movement.html index 29539ea..880b774 100644 --- a/movements/copy_movement.html +++ b/movements/copy_movement.html @@ -205,7 +205,12 @@ transactions=$transactions return_date=$return_date|parse_date }} - {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}} + {{if $_GET.from == "lh"}} + {{:assign from="../loan_history.html"}} + {{else}} + {{:assign from="../equipment_history.html"}} + {{/if}} + {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=copie"|args:$from:$eqpmt_key:$prop}} {{/form}} {{if $mvt_new.direction == "input"}} @@ -292,6 +297,7 @@ {{: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}} @@ -311,7 +317,13 @@ function changeVisibility(evt, idcheck = 'f_set_return_date_1', fields = ['div_r toggleVisibility(idcheck, fields); } +function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration') +{ + setReturnDate(id_date, id_return_date, id_loan_duration); +} + (function () { document.getElementById('f_set_return_date_1').onclick = changeVisibility; + document.getElementById('f_date').onchange = changeReturnDate; })(); diff --git a/movements/delete_movement.html b/movements/delete_movement.html index aea6243..0561692 100644 --- a/movements/delete_movement.html +++ b/movements/delete_movement.html @@ -21,6 +21,11 @@ {{:include file="../_get_config.html" keep="config"}} {{#form on="delete"}} + {{if $_GET.from == "lh"}} + {{:assign from="../loan_history.html"}} + {{else}} + {{:assign from="../equipment_history.html"}} + {{/if}} {{* vérifier s'il est possible de supprimer le mouvement *}} {{if $mvt_suppr.direction == 'input'}} {{:assign var="type_operation" from="config.input_nature.%s.type"|args:$mvt_suppr.operation}} @@ -29,7 +34,7 @@ {{:assign link_key=$key}} {{/load}} {{if $link_key != null}} - {{:redirect force="../equipment_history.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} {{/if}} {{else}} {{:assign dispo=0}} @@ -62,7 +67,7 @@ {{* problème ? *}} {{if $dispo < 0 || $nonprop < 0}} - {{:redirect force="../equipment_history.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} {{/if}} {{/if}} {{/load}} @@ -83,7 +88,7 @@ {{:assign link_key=$key}} {{/load}} {{if $link_key != null}} - {{:redirect force="../equipment_history.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} {{/if}} {{elseif $type_operation == 'retour'}} {{#load type="link" where="$$.return = :key" :key=$_GET.key}} @@ -148,7 +153,7 @@ out=$curr_eqpmt.out notowned=$curr_eqpmt.notowned }} - {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} {{else}} {{* supprimer le matériel *}} {{:delete key=$curr_eqpmt.key}} diff --git a/movements/modify_movement.html b/movements/modify_movement.html index 2139e4d..4f32141 100644 --- a/movements/modify_movement.html +++ b/movements/modify_movement.html @@ -222,7 +222,12 @@ transactions=$transactions return_date=$return_date|parse_date }} - {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}} + {{if $_GET.from == "lh"}} + {{:assign from="../loan_history.html"}} + {{else}} + {{:assign from="../equipment_history.html"}} + {{/if}} + {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=modification"|args:$from:$eqpmt_key:$prop}} {{/form}} {{if $mvt_new.direction == "input"}} @@ -231,8 +236,8 @@ {{: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 -------------------- *}} @@ -338,11 +343,9 @@ function changeVisibility(evt, idcheck = 'f_set_return_date_1', fields = ['div_r toggleVisibility(idcheck, fields); } -function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration') { - const loan_duration = document.getElementById(id_loan_duration).value; - 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(); +function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration') +{ + setReturnDate(id_date, id_return_date, id_loan_duration); } (function () { diff --git a/movements/movement_details.html b/movements/movement_details.html index f25fca7..55eeb5a 100644 --- a/movements/movement_details.html +++ b/movements/movement_details.html @@ -42,18 +42,18 @@