ajout liaison entre entrée temporaire et retour

This commit is contained in:
Jean-Christophe Engel 2025-03-21 14:58:52 +01:00
parent 144a909494
commit ce87720d41
6 changed files with 322 additions and 77 deletions

View file

@ -85,32 +85,6 @@
{{/if}}
{{/foreach}}
{{* calculer la quantité restant à l'extérieur de chaque matériel *}}
{{#foreach from=$config.output_nature key=key}}
{{if $type == "temporaire"}}
{{:assign var="temp_outputs." value=$key|quote_sql}}
{{/if}}
{{/foreach}}
{{:assign operations=$temp_outputs|implode:","}}
{{:assign operations="("|cat:$operations|cat:")"}}
{{#select
mvt.key AS mvt_key,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
FROM module_data_equipment AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.output')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE
json_extract(mvt.document, '$.operation') IN !op
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
GROUP by mvt.key
;
!op = $operations
:eqpmt_key = $_GET.key
}}
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
{{/select}}
{{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}}
{{:assign stock=0}}
{{:assign exterieur=0}}
@ -145,6 +119,32 @@
{{* lister tous les mouvements du matériel passé en paramètre *}}
{{if $_GET.prop}}
{{* calculer la quantité temporairement l'extérieur de chaque matériel *}}
{{#foreach from=$config.output_nature key=key}}
{{if $type == "temporaire"}}
{{:assign var="temp_outputs." value=$key|quote_sql}}
{{/if}}
{{/foreach}}
{{:assign operations=$temp_outputs|implode:","}}
{{:assign operations="("|cat:$operations|cat:")"}}
{{#select
mvt.key AS mvt_key,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
FROM module_data_equipment AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.output')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE
json_extract(mvt.document, '$.operation') IN !op
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
GROUP by mvt.key
;
!op = $operations
:eqpmt_key = $_GET.key
}}
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
{{/select}}
{{#list
type="movement"
select="$$.date AS 'Date';
@ -154,7 +154,7 @@
"" as 'Stock';
"" as 'Sorti';
"" as 'Disponible';
$$.comment AS 'Remarque'"
$$.comment AS 'Commentaire'"
equipment=$equipment_key
order=1
}}
@ -179,8 +179,8 @@
<td class="actions">
{{if $current != "archives"}}
{{if $direction == "output" && $type_mvt == "temporaire"}}
{{:assign var="ext" from="reste.%s"|args:$key}}
{{if $ext != null && $ext > 0}}
{{:assign var="temp_ext" from="reste.%s"|args:$key}}
{{if $temp_ext != null && $temp_ext > 0}}
{{:linkbutton
label="Retour"
href="mouvements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
@ -210,6 +210,33 @@
{{/list}}
{{else}}
{{* calculer la quantité présente temporairement de chaque matériel *}}
{{#foreach from=$config.input_nature key=key}}
{{if $type == "temporaire"}}
{{:assign var="temp_inputs." value=$key|quote_sql}}
{{/if}}
{{/foreach}}
{{:assign operations=$temp_inputs|implode:","}}
{{:assign operations="("|cat:$operations|cat:")"}}
{{#select
mvt.key AS mvt_key,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
FROM module_data_equipment AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.input')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE
json_extract(mvt.document, '$.operation') IN !op
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
GROUP by mvt.key
;
!op = $operations
:eqpmt_key = $_GET.key
}}
{{:assign var="present.%s"|args:$mvt_key value=$present}}
{{/select}}
{{*:debug present=$present*}}
{{*:debug direction=$direction type_mvt=$type_mvt in=$in*}}
{{#list
type="movement"
select="$$.date AS 'Date';
@ -217,11 +244,11 @@
$$.operation AS 'Opération';
$$.amount AS 'Quantité';
"" as 'Présent';
$$.comment AS 'Remarque'"
$$.comment AS 'Commentaire'"
equipment=$equipment_key
order=1
}}
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$direction:$col3}}
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$col3}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
{{if $direction === "input" && $op_label|in:$input_types ||
@ -236,6 +263,16 @@
<td class="num nosort">{{$stock}}</td>
<td>{{$comment}}</td>
<td class="actions">
{{if $direction == "input" && $type_mvt == "temporaire"}}
{{:assign var="temp_in" from="present.%s"|args:$key}}
{{if $temp_in != null && $temp_in > 0}}
{{:linkbutton
label="Retour"
href="mouvements/input_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="history"
target="_dialog"}}
{{/if}}
{{/if}}
{{:linkbutton
label="Dupliquer"
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop