fiche membre : ajout bouton retour et séparation mouvements temporaires et définitifs

This commit is contained in:
Jean-Christophe Engel 2025-03-31 12:26:06 +02:00
parent 8f759dcf77
commit 7340f44aa8

View File

@ -3,52 +3,73 @@
{{#restrict section="users" level="read"}}{{/restrict}} {{#restrict section="users" level="read"}}{{/restrict}}
{{* lecture config (défaut ou enregistrée) *}} {{* lecture config (défaut ou enregistrée) *}}
{{:include file="../_get_config.html" keep="config"}} {{:include file="../_get_config.html" keep="config, directions"}}
{{#foreach from=$config.output_nature key=key}} {{#foreach from=$directions key="direction"}}
{{:assign var="types.output.%s."|args:$type value=$key}} {{:assign var="nature" from="config.%s_nature"|args:$direction}}
{{/foreach}} {{#foreach from=$nature key=key}}
{{:assign var="types.%s.%s."|args:$direction:$type value=$key|quote_sql}}
{{#foreach from=$types.output key=key}} {{/foreach}}
{{:assign var=elem from="types.output.%s"|args:$key}} {{:assign var="io_types" from="types.%s"|args:$direction}}
{{:assign elem=$elem|quote_sql|implode:","}} {{#foreach from=$io_types key=key}}
{{:assign elem="("|cat:$elem|cat:")"}} {{:assign var=elem from="io_types.%s"|args:$key}}
{{:assign var="output_types.%s"|args:$key value=$elem}} {{:assign elem=$elem|implode:","}}
{{:assign elem="("|cat:$elem|cat:")"}}
{{:assign var="%s_types.%s"|args:$direction:$key value=$elem}}
{{/foreach}}
{{/foreach}} {{/foreach}}
{{#select {{#select
json_extract(eqpmt.document, '$.name') as mat, json_extract(eqpmt.document, '$.name') as eqpmt_name,
mvt.key AS mvt_key,
json_extract(mvt.document, '$.direction') as direction,
json_extract(mvt.document, '$.operation') as operation,
json_extract(mvt.document, '$.date') as date, json_extract(mvt.document, '$.date') as date,
json_extract(mvt.document, '$.amount') as qte json_extract(mvt.document, '$.amount') as amount
FROM module_data_equipment AS mvt FROM module_data_equipment AS mvt
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
INNER JOIN module_data_equipment AS eqpmt INNER JOIN module_data_equipment AS eqpmt
ON json_extract(mvt.document, '$.equipment') = eqpmt.key ON json_extract(mvt.document, '$.equipment') = eqpmt.key
WHERE users.id = :user AND json_extract(mvt.document, '$.operation') IN !output_types WHERE users.id = :user AND json_extract(mvt.document, '$.operation') IN !output_types OR json_extract(mvt.document, '$.operation') IN !input_types
ORDER BY date DESC ORDER BY date
; ;
:user = $user.id :user = $user.id
!output_types=$output_types.temporaire !output_types=$output_types.temporaire
!input_types=$input_types.retour
assign="temp_mat." assign="temp_mat."
}} }}
{{/select}} {{/select}}
{{if $temp_mat|count != 0}} {{if $temp_mat|count != 0}}
<h3 class="ruler">Matériels en prêt</h3> <h3 class="ruler">Matériels attribués temporairement</h3>
<table class="list"> <table class="list">
<thead> <thead>
<tr> <tr>
<td>Matériel</td> <td>Matériel</td>
<td>Date</td> <td>Date</td>
<td>Quantité</td> <td>Quantité</td>
<td>Opération</td>
<td class="actions"></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#foreach from=$temp_mat}} {{#foreach from=$temp_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}}
<tr> <tr>
<td>{{$mat}}</td> <td>{{$eqpmt_name}}</td>
<td>{{$date|date_short}}</td> <td>{{$date|date_short}}</td>
<td>{{$qte}}</td> <td>{{$amount}}</td>
<td>{{$op_label}}</td>
<td class="actions">
{{if $direction == "output" && $type_mvt == "temporaire"}}
{{:linkbutton
label="Retour"
href="%smouvements/output_return.html?key=%s&prop=0"|args:$module.url:$mvt_key
shape="history"
target="_dialog"}}
{{/if}}
</td>
</tr> </tr>
{{/foreach}} {{/foreach}}
</tbody> </tbody>
@ -56,9 +77,11 @@
{{/if}} {{/if}}
{{#select {{#select
json_extract(eqpmt.document, '$.name') as mat, json_extract(eqpmt.document, '$.name') as eqpmt_name,
json_extract(mvt.document, '$.direction') as direction,
json_extract(mvt.document, '$.operation') as operation,
json_extract(mvt.document, '$.date') as date, json_extract(mvt.document, '$.date') as date,
json_extract(mvt.document, '$.amount') as qte json_extract(mvt.document, '$.amount') as amount
FROM module_data_equipment AS mvt FROM module_data_equipment AS mvt
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
INNER JOIN module_data_equipment AS eqpmt INNER JOIN module_data_equipment AS eqpmt
@ -80,14 +103,17 @@
<td>Matériel</td> <td>Matériel</td>
<td>Date</td> <td>Date</td>
<td>Quantité</td> <td>Quantité</td>
<td>Opération</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#foreach from=$def_mat}} {{#foreach from=$def_mat}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
<tr> <tr>
<td>{{$mat}}</td> <td>{{$eqpmt_name}}</td>
<td>{{$date|date_short}}</td> <td>{{$date|date_short}}</td>
<td>{{$qte}}</td> <td>{{$amount}}</td>
<td>{{$op_label}}</td>
</tr> </tr>
{{/foreach}} {{/foreach}}
</tbody> </tbody>