fusion branche retourhisto

This commit is contained in:
Jean-Christophe Engel 2025-03-31 12:21:22 +02:00
commit 68284ee309
8 changed files with 433 additions and 287 deletions

View file

@ -42,6 +42,8 @@
<p class="block confirm">Modification enregistrée</p>
{{elseif $_GET.msg == "copie"}}
<p class="block confirm">Mouvement copié</p>
{{elseif $_GET.msg == "retour"}}
<p class="block confirm">Retour enregistré</p>
{{elseif $_GET.msg == "suppression"}}
<p class="block confirm">Mouvement supprimé</p>
{{else}}
@ -125,15 +127,38 @@
{{/if}}
{{:linkbutton label="Entrée" shape="plus" href="mouvements/entrees/repertorie.html?key=%s"|args:$_GET.key target="_dialog"}}
{{else}}
{{if $equipment.notowned > 0}}
{{:linkbutton label="Retour" href="mouvements/sorties/emprunte.html?key=%s"|args:$_GET.key shape="history" target="_dialog"}}
{{/if}}
{{:linkbutton label="Entrée" shape="plus" href="mouvements/entrees/repertorie.html?key=%s"|args:$_GET.key target="_dialog"}}
{{/if}}
</aside>
</nav>
{{* 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, '$.temp_key')
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';
@ -178,7 +203,17 @@
<td>{{$comment}}</td>
<td class="actions">
{{if $current != "archives"}}
{{:linkbutton
{{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="mouvements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="reset"
target="_dialog"}}
{{/if}}
{{/if}}
{{:linkbutton
label="Dupliquer"
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="plus"
@ -200,6 +235,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, '$.temp_key')
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';
@ -215,7 +277,7 @@
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 ||
@ -231,6 +293,16 @@
<td>{{$col6}}</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="reset"
target="_dialog"}}
{{/if}}
{{/if}}
{{:linkbutton
label="Dupliquer"
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop