diff --git a/_get_config.html b/_get_config.html index 119a20b..095dff9 100644 --- a/_get_config.html +++ b/_get_config.html @@ -28,9 +28,3 @@ {{/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/_nav.html b/_nav.html index 8ea688e..4e69986 100644 --- a/_nav.html +++ b/_nav.html @@ -29,11 +29,6 @@
  • Historique — {{$eqpmt}} ({{$category}})
  • {{/if}} - {{elseif $current == 'historique'}} - {{elseif $current == 'archives'}} {{if $subsubcurrent == 'historique'}} {{/if}} diff --git a/default.json b/default.json index b9906b7..07a9c10 100644 --- a/default.json +++ b/default.json @@ -33,6 +33,5 @@ "label" : "Retour de Location/Emprunt", "type" : "retour" } - ], - "loan_duration" : "30" + ] } diff --git a/global_history.html b/global_history.html index 5eb69c1..8f98f16 100644 --- a/global_history.html +++ b/global_history.html @@ -6,7 +6,7 @@ {{:admin_header title="Historique des mouvements" custom_css="./style.css" current="module_equipment"}} -{{:include file="./_nav.html" current="historique" subcurrent="tous"}} +{{:include file="./_nav.html" current="historique"}} {{* récupérer la config des entrées/sorties *}} {{:include file="./_get_config.html" keep="config"}} diff --git a/loan_history.html b/loan_history.html deleted file mode 100644 index 8d5ab82..0000000 --- a/loan_history.html +++ /dev/null @@ -1,90 +0,0 @@ -{{* -*- brindille -*- *}} - -{{:admin_header title="Matériels hors de l'asso" custom_css="../style.css" current="module_equipment"}} -{{:include file="./_nav.html" current="historique" subcurrent="prêts"}} - -{{* lecture config (défaut ou enregistrée) *}} -{{:include file="./_get_config.html" keep="config"}} - -{{#foreach from=$config.output_nature key="key"}} - {{if $type == 'temporaire'}} - {{:assign var="output_types." value=$key|quote_sql}} - {{/if}} -{{/foreach}} -{{:assign output_ops=$output_types|implode:","}} -{{:assign output_ops="("|cat:$output_ops|cat:")"}} - -{{:assign premier=true}} -{{#select - users.nom AS nom, - users.id AS user, - json_extract(mat.document, '$.name') AS mat_name, - json_extract(mvt.document, '$.date') AS out_date, - 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 - 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') - WHERE - json_extract(mvt.document, '$.type') = 'movement' - AND - json_extract(mvt.document, '$.operation') IN !op - GROUP BY mvt.key - HAVING remain != 0 - ORDER BY out_date, nom - ; - !op = $output_ops -}} - {{if $premier}} - - - - - - - - - - - - - - - {{:assign premier=false}} - {{/if}} - - {{if $return_date != null}} - {{:assign ts_retour=$return_date|strtotime}} - {{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}} - {{/if}} - - - - - - - - - - -{{else}} -

    Aucun mouvement.

    -{{/select}} - -
    MatérielDate sortieQuantitéMembreDate retourReste à rendreRemarque
    {{$mat_name}}{{$out_date|date_short}}{{$out_amount}}{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$nom}}{{$return_date|date_short}}{{$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}} - {{/if}} -
    - -{{:admin_footer}} diff --git a/movements/copy_movement.html b/movements/copy_movement.html index 29539ea..459cde5 100644 --- a/movements/copy_movement.html +++ b/movements/copy_movement.html @@ -14,7 +14,7 @@ {{/load}} {{* récupérer la config des entrées/sorties *}} -{{:include file="../_get_config.html" keep="config, directions, loan_duration"}} +{{:include file="../_get_config.html" keep="config, directions"}} {{: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 » *}} @@ -93,11 +93,6 @@ {{: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.set_return_date != null}} - {{:assign return_date=$_POST.return_date}} - {{else}} - {{:assign return_date=null}} - {{/if}} {{* lister les mouvements @@ -203,7 +198,6 @@ user=$user.id storage=$_POST.storage 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}} {{/form}} @@ -278,22 +272,6 @@ {{/if}} {{/if}} {{: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}} - {{: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}} @@ -304,14 +282,3 @@ {{:admin_footer}} - - - diff --git a/movements/modify_movement.html b/movements/modify_movement.html index 2139e4d..e737d9d 100644 --- a/movements/modify_movement.html +++ b/movements/modify_movement.html @@ -13,7 +13,7 @@ {{/load}} {{* récupérer la config des entrées/sorties *}} -{{:include file="../_get_config.html" keep="config, directions, loan_duration"}} +{{:include file="../_get_config.html" keep="config, directions"}} {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}} {{if $mvt_new.direction == "input"}} @@ -84,11 +84,6 @@ {{: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.set_return_date != null}} - {{:assign return_date=$_POST.return_date}} - {{else}} - {{:assign return_date=null}} - {{/if}} {{* lister les mouvements @@ -220,7 +215,6 @@ user=$user_id storage=$_POST.storage 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}} {{/form}} @@ -304,23 +298,6 @@ {{/if}} {{/if}} {{: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}} - {{: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}} @@ -331,22 +308,3 @@ {{:admin_footer}} - - - diff --git a/movements/movement.schema.json b/movements/movement.schema.json index eaebdb3..bd27c1c 100644 --- a/movements/movement.schema.json +++ b/movements/movement.schema.json @@ -46,11 +46,6 @@ "items": { "type": "integer" } - }, - "return_date" : { - "description": "Date de retour du matériel", - "type" : ["null", "string"], - "format" : "date" } }, "required": ["type", "direction", "operation", "amount", "equipment", "date", "comment"] diff --git a/movements/movement_details.html b/movements/movement_details.html index f25fca7..16a170f 100644 --- a/movements/movement_details.html +++ b/movements/movement_details.html @@ -101,10 +101,6 @@ {{else}}— {{/if}} - {{if $mvt.return_date != null}} -
    Date de retour
    -
    {{$mvt.return_date|date_short}}
    - {{/if}}
    diff --git a/movements/output_equipment.html b/movements/output_equipment.html index d211cb3..9993f78 100644 --- a/movements/output_equipment.html +++ b/movements/output_equipment.html @@ -6,7 +6,7 @@ *}} {{* récupérer la config des entrées/sorties *}} -{{:include file="../_get_config.html" keep="config, loan_duration"}} +{{:include file="../_get_config.html" keep="config"}} {{* types de sorties *}} {{#foreach from=$config.output_nature key=key}} @@ -31,15 +31,6 @@ {{/if}} {{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$_POST.operation}} - {{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.set_return_date != null}} - {{:assign return_date=$_POST.return_date}} - {{else}} - {{:assign return_date=null}} - {{/if}} - {{if $_POST.user|count > 1}} {{:error message="Un membre au plus peut être associé à une sortie"}} {{/if}} @@ -151,7 +142,6 @@ date=$_POST.date|parse_date comment=$_POST.remarques|trim user=$user.id - return_date=$return_date|parse_date }} {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=1&msg=sortie"|args:$_GET.key}} {{/form}} @@ -166,8 +156,6 @@ {{:assign dispo="%d-%d"|math:$equipment.stock:$equipment.out}} {{if $dispo > 0}} - {{: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 *}} @@ -206,11 +194,6 @@ max=1 }} {{: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"}} -

    @@ -223,23 +206,3 @@ {{:form_errors}} {{:admin_footer}} - - - diff --git a/scripts.js b/scripts.js index fe36b24..299b7e4 100644 --- a/scripts.js +++ b/scripts.js @@ -25,30 +25,3 @@ 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 - */ -function str2sec(date) { - const jma = date.split('/'); - const dd = new Date(jma[2], jma[1]-1, jma[0]); - return dd.getTime()/1000; -} - -// renvoyer la valeur en secondes d'un champ date -function getDate(idelem) { - return str2sec(document.getElementById(idelem).value); -} diff --git a/snippets/user_details.html b/snippets/user_details.html index 6762dde..3268dec 100644 --- a/snippets/user_details.html +++ b/snippets/user_details.html @@ -44,7 +44,6 @@ eqpmt.key as eqpmt_key, json_extract(eqpmt.document, '$.name') AS eqpmt_name, json_extract(mvt.document, '$.amount') AS qte, - json_extract(mvt.document, '$.return_date') AS return_date, json_extract(mvt.document, '$.operation') AS operation FROM {!$module.table} AS mvt INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id @@ -66,19 +65,9 @@ {{if $premier}} {{:assign premier=false}} {{:assign total=0}} - {{:assign nb_jours=0}} {{:assign old_eqpmt_key=$eqpmt_key}} {{:assign var="ligne.date" value=$date}} {{:assign var="ligne.materiel" value=$eqpmt_name}} - {{:assign var="ligne.return_date" value=$return_date}} - {{:assign var="ligne.retard" value="0"}} - {{if $return_date != null}} - {{:assign ts_retour=$return_date|strtotime}} - {{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}} - {{*if $nb_jours > 0*}} - {{:assign var="ligne.retard" value=$nb_jours}} - {{*/if*}} - {{/if}} {{/if}} {{if $eqpmt_key != $old_eqpmt_key}} @@ -87,20 +76,9 @@ {{:assign var="lignes." value=$ligne}} {{/if}} {{:assign total=0}} - {{:assign nb_jours=0}} {{:assign old_eqpmt_key=$eqpmt_key}} {{:assign var="ligne.date" value=$date}} {{:assign var="ligne.materiel" value=$eqpmt_name}} - {{:assign var="ligne.return_date" value=$return_date}} - {{:assign var="ligne.retard" value="0"}} - {{if $return_date != null}} - {{:assign ts_retour=$return_date|strtotime}} - {{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}} - {{*if $nb_jours > 0*}} - {{:assign var="ligne.retard" value=$nb_jours}} - {{*/if*}} - {{*elseif $direction == "output"*}} - {{/if}} {{/if}} {{if $direction == "output"}} @@ -123,8 +101,6 @@ Date Matériel Quantité - Date de retour - Remarque @@ -133,17 +109,6 @@ {{$date|date_short}} {{$materiel}} {{$qte}} - {{$return_date|date_short}} - - {{if $retard < 0}} - {{:assign delai="abs(%d)"|math:$retard}} - {{"Reste %s jours"|args:$delai}} - {{elseif $retard >0 }} - {{:tag color="darkred" label="Retard %s jours"|args:$retard}} - {{else}} - {{:tag color="darkgreen" label="À rendre aujourdh'ui"}} - {{/if}} - {{/foreach}} @@ -186,16 +151,27 @@ Matériel Opération Quantité + Total {{#foreach from=$def_mat}} + {{: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}} + {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} + {{if $total == null}} + {{:assign total=0}} + {{/if}} + {{if $direction == 'output' && $type_mvt == 'définitif'}} + {{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}} + {{/if}} + {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} {{$date|date_short}} {{$eqpmt_name}} {{$op_label}} {{$amount}} + {{$total}} {{/foreach}}