Ajout historique des mouvements d'un matériel d'un membre
This commit is contained in:
parent
2fc09554f0
commit
ef4870257d
3 changed files with 142 additions and 4 deletions
122
member_history.html
Normal file
122
member_history.html
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Afficher l'historique des mouvements d'un matériel pour un membre
|
||||||
|
paramètres
|
||||||
|
- key : clé du matériel
|
||||||
|
- id : id du membre
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:admin_header title="Historique membre" custom_css="./style.css" current="module_equipment"}}
|
||||||
|
|
||||||
|
{{* lecture config (défaut ou enregistrée) *}}
|
||||||
|
{{:include file="./_get_config.html" keep="config, directions"}}
|
||||||
|
|
||||||
|
{{#foreach from=$directions key="direction"}}
|
||||||
|
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
|
||||||
|
{{#foreach from=$nature key=key}}
|
||||||
|
{{:assign var="types.%s.%s."|args:$direction:$type value=$key|quote_sql}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign var="io_types" from="types.%s"|args:$direction}}
|
||||||
|
{{#foreach from=$io_types key=key}}
|
||||||
|
{{:assign var=elem from="io_types.%s"|args:$key}}
|
||||||
|
{{:assign elem=$elem|implode:","}}
|
||||||
|
{{:assign elem="("|cat:$elem|cat:")"}}
|
||||||
|
{{:assign var="%s_types.%s"|args:$direction:$key value=$elem}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{/foreach}}
|
||||||
|
|
||||||
|
{{#users id=$_GET.id}}
|
||||||
|
{{:assign user_name=$nom}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Il n'existe aucun membre avec l'identifiant %s !"|args:$_GET.id}}
|
||||||
|
{{/users}}
|
||||||
|
|
||||||
|
{{#load key=$_GET.key|trim}}
|
||||||
|
{{:assign eqpmt_name=$name}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Il n'existe aucun matériel avec la clé %s !"|args:$_GET.key|trim}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
<h3>Historique des mouvements de « {{$eqpmt_name}} » du membre « {{$user_name}} »</h3>
|
||||||
|
|
||||||
|
{{:assign otk=null}}
|
||||||
|
{{#select
|
||||||
|
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, '$.amount') as amount,
|
||||||
|
COALESCE((SELECT
|
||||||
|
json_extract(links.document, '$.temp_key')
|
||||||
|
FROM {!$module.table} AS links
|
||||||
|
WHERE json_extract(links.document, '$.temp_key') = mvt.key
|
||||||
|
OR json_extract(links.document, '$.return') = mvt.key), mvt.key)
|
||||||
|
AS out_temp_key
|
||||||
|
FROM {!$module.table} AS mvt
|
||||||
|
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||||
|
INNER JOIN {!$module.table} AS eqpmt
|
||||||
|
ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||||
|
WHERE users.id = :user
|
||||||
|
AND eqpmt.key = :eqpmt_key
|
||||||
|
AND (json_extract(mvt.document, '$.operation') IN !output_types
|
||||||
|
OR json_extract(mvt.document, '$.operation') IN !input_types)
|
||||||
|
ORDER BY out_temp_key, date
|
||||||
|
;
|
||||||
|
:user = $_GET.id
|
||||||
|
:eqpmt_key = $_GET.key|trim
|
||||||
|
!output_types=$output_types.temporaire
|
||||||
|
!input_types=$input_types.retour
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{: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:$out_temp_key}}
|
||||||
|
{{if $total == null}}
|
||||||
|
{{:assign total=0}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $otk != null && $otk != $out_temp_key}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
{{if $otk == null || $otk != $out_temp_key}}
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Opération</td>
|
||||||
|
<td>Quantité</td>
|
||||||
|
<td>Total</td>
|
||||||
|
<td class="actions"></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{:assign otk=$out_temp_key}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $direction == 'input' && $type_mvt == 'retour'}}
|
||||||
|
{{:assign var="reste.%s"|args:$out_temp_key value="%d-%d"|math:$total:$amount}}
|
||||||
|
{{elseif $direction == 'output' && $type_mvt == 'temporaire'}}
|
||||||
|
{{:assign var="reste.%s"|args:$out_temp_key value="%d+%d"|math:$total:$amount}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign var="total" from="reste.%s"|args:$out_temp_key}}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{{$date|date_short}}</td>
|
||||||
|
<td>{{$op_label}}</td>
|
||||||
|
<td>{{$amount}}</td>
|
||||||
|
<td>{{$total}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
{{if $direction == "output" && $type_mvt == "temporaire"}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Retour"
|
||||||
|
href="%smovements/output_return.html?key=%s&prop=0&user=%s"|args:$module.url:$mvt_key:$_GET.id
|
||||||
|
shape="history"
|
||||||
|
target="_dialog"}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/select}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
@ -95,16 +95,21 @@
|
||||||
{{else}}—
|
{{else}}—
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</dd>
|
</dd>
|
||||||
|
{{if $mvt.direction == "output" && $type_mvt != "retour"}}
|
||||||
|
<dt>Date de retour</dt>
|
||||||
|
<dd>
|
||||||
|
{{if $mvt.return_date != null}}
|
||||||
|
{{$mvt.return_date|date_short}}
|
||||||
|
{{else}}—
|
||||||
|
{{/if}}
|
||||||
|
</dd>
|
||||||
|
{{/if}}
|
||||||
<dt>Remarques</dt>
|
<dt>Remarques</dt>
|
||||||
<dd>{{if $mvt.comment != null}}
|
<dd>{{if $mvt.comment != null}}
|
||||||
{{$mvt.comment}}
|
{{$mvt.comment}}
|
||||||
{{else}}—
|
{{else}}—
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</dd>
|
</dd>
|
||||||
{{if $mvt.return_date != null}}
|
|
||||||
<dt>Date de retour</dt>
|
|
||||||
<dd>{{$mvt.return_date|date_short}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@
|
||||||
{{:assign nb_jours=0}}
|
{{:assign nb_jours=0}}
|
||||||
{{:assign old_eqpmt_key=$eqpmt_key}}
|
{{:assign old_eqpmt_key=$eqpmt_key}}
|
||||||
{{:assign var="ligne.date" value=$date}}
|
{{:assign var="ligne.date" value=$date}}
|
||||||
|
{{:assign var="ligne.eqpmt_key" value=$eqpmt_key}}
|
||||||
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
||||||
{{:assign var="ligne.return_date" value=$return_date}}
|
{{:assign var="ligne.return_date" value=$return_date}}
|
||||||
{{:assign var="ligne.retard" value="0"}}
|
{{:assign var="ligne.retard" value="0"}}
|
||||||
|
|
@ -88,6 +89,7 @@
|
||||||
{{:assign nb_jours=0}}
|
{{:assign nb_jours=0}}
|
||||||
{{:assign old_eqpmt_key=$eqpmt_key}}
|
{{:assign old_eqpmt_key=$eqpmt_key}}
|
||||||
{{:assign var="ligne.date" value=$date}}
|
{{:assign var="ligne.date" value=$date}}
|
||||||
|
{{:assign var="ligne.eqpmt_key" value=$eqpmt_key}}
|
||||||
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
||||||
{{:assign var="ligne.return_date" value=$return_date}}
|
{{:assign var="ligne.return_date" value=$return_date}}
|
||||||
{{:assign var="ligne.retard" value="0"}}
|
{{:assign var="ligne.retard" value="0"}}
|
||||||
|
|
@ -120,6 +122,7 @@
|
||||||
<th>Quantité</th>
|
<th>Quantité</th>
|
||||||
<th>Date de retour</th>
|
<th>Date de retour</th>
|
||||||
<th>Remarque</th>
|
<th>Remarque</th>
|
||||||
|
<th class="actions">
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -139,6 +142,14 @@
|
||||||
{{:tag color="darkgreen" label="À rendre aujourdh'ui"}}
|
{{:tag color="darkgreen" label="À rendre aujourdh'ui"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
|
<td class="actions">
|
||||||
|
{{:linkbutton
|
||||||
|
label="Historique"
|
||||||
|
href="%smember_history.html?key=%s&id=%s"|args:$module.url:$eqpmt_key:$user.id
|
||||||
|
shape="table"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue