Ajout consultation mes mouvements ou ceux des autres membres
This commit is contained in:
parent
63775189da
commit
83e5661389
5 changed files with 216 additions and 211 deletions
|
|
@ -7,7 +7,7 @@
|
|||
- id : id du membre
|
||||
*}}
|
||||
|
||||
{{#restrict block=true section="users" level="read"}}{{/restrict}}
|
||||
{{#restrict}}{{/restrict}}
|
||||
|
||||
{{:admin_header title="Historique membre" custom_css="./style.css" current="module_equipment"}}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,5 @@ author="Jean-Christophe Engel"
|
|||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
home_button=true
|
||||
menu=true
|
||||
restrict_section="users"
|
||||
restrict_level="read"
|
||||
restrict_details="... mais uniquement pour consulter l'historique des prêts des membres ; seuls les membres ayant accès en écriture à la comptabilité pourront utiliser l'ensemble des fonctionalités du module."
|
||||
restrict_details="Les membres connectés peuvent consulter l'historique de leurs prêts ; les membres ayant accès en lecture aux membres peuvent consulter l'historique des prêts des autres membres ; seuls les membres ayant accès en écriture à la comptabilité peuvent utiliser l'ensemble des fonctionnalités du module."
|
||||
allow_user_restrict=false
|
||||
|
|
|
|||
210
snippets/_details.html
Normal file
210
snippets/_details.html
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{#restrict section="users" level="read"}}{{/restrict}}
|
||||
|
||||
{{* 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}}
|
||||
|
||||
{{*
|
||||
vérifier l'existence de la table du module
|
||||
eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans
|
||||
*}}
|
||||
{{#load limit="1"}}
|
||||
{{:assign table_presente=true}}
|
||||
{{else}}
|
||||
{{:assign table_presente=false}}
|
||||
{{/load}}
|
||||
|
||||
{{if $table_presente}}
|
||||
{{* Matériels attribués temporairement *}}
|
||||
{{* vérifier la présence des types d'entrées et de sorties requis *}}
|
||||
{{if $output_types|has_key:"temporaire" && $input_types|has_key:"retour"}}
|
||||
|
||||
{{*
|
||||
Calculer les quantités de matériel en prêt
|
||||
*}}
|
||||
{{:assign premier=true}}
|
||||
{{#select
|
||||
json_extract(mvt.document, '$.direction') AS direction,
|
||||
json_extract(mvt.document, '$.date') AS date,
|
||||
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
|
||||
INNER JOIN {!$module.table} AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||
WHERE
|
||||
users.id = :user
|
||||
AND
|
||||
json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND
|
||||
(json_extract(mvt.document, '$.operation') IN !output_types
|
||||
OR
|
||||
json_extract(mvt.document, '$.operation') IN !input_types)
|
||||
ORDER BY eqpmt_name, date
|
||||
;
|
||||
:user = $user.id
|
||||
!output_types=$output_types.temporaire
|
||||
!input_types=$input_types.retour
|
||||
}}
|
||||
{{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.eqpmt_key" value=$eqpmt_key}}
|
||||
{{: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}}
|
||||
{{:assign var="ligne.retard" value=$nb_jours}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $eqpmt_key != $old_eqpmt_key}}
|
||||
{{if $total > 0}}
|
||||
{{:assign var="ligne.qte" value=$total}}
|
||||
{{: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.eqpmt_key" value=$eqpmt_key}}
|
||||
{{: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}}
|
||||
{{:assign var="ligne.retard" value=$nb_jours}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $direction == "output"}}
|
||||
{{:assign total="%d+%d"|math:$total:$qte}}
|
||||
{{else}}
|
||||
{{:assign total="%d-%d"|math:$total:$qte}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{if $total > 0}}
|
||||
{{:assign var="ligne.qte" value=$total}}
|
||||
{{:assign var="lignes." value=$ligne}}
|
||||
{{/if}}
|
||||
|
||||
{{if $lignes|count > 0}}
|
||||
<h3 class="ruler">Matériels attribués temporairement</h3>
|
||||
<table class="list" id="liste_temporaires">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Matériel</th>
|
||||
<th>Quantité</th>
|
||||
<th>Date de retour</th>
|
||||
<th>Remarque</th>
|
||||
<th class="actions">
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$lignes}}
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$materiel}}</td>
|
||||
<td>{{$qte}}</td>
|
||||
<td>{{$return_date|date_short}}</td>
|
||||
<td>
|
||||
{{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}}
|
||||
</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>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* Matériels attribués définitivement *}}
|
||||
{{* vérifier la présence des types de sorties requis *}}
|
||||
{{if $output_types|has_key:"définitif"}}
|
||||
{{#select
|
||||
eqpmt.key as eqpmt_key,
|
||||
json_extract(eqpmt.document, '$.name') as eqpmt_name,
|
||||
json_extract(mvt.document, '$.direction') as direction,
|
||||
json_extract(mvt.document, '$.operation') as operation,
|
||||
MIN(json_extract(mvt.document, '$.date')) as date,
|
||||
SUM(json_extract(mvt.document, '$.amount')) as amount
|
||||
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 json_extract(mvt.document, '$.operation') IN !output_types
|
||||
GROUP BY eqpmt_key, operation
|
||||
ORDER BY eqpmt_name, date
|
||||
;
|
||||
:user = $user.id
|
||||
!output_types=$output_types.définitif
|
||||
assign="def_mat."
|
||||
}}
|
||||
{{/select}}
|
||||
{{/if}}
|
||||
|
||||
{{if $def_mat|count != 0}}
|
||||
<h3 class="ruler">Matériels attribués définitivement</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Matériel</th>
|
||||
<th>Opération</th>
|
||||
<th>Quantité</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$def_mat}}
|
||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$eqpmt_name}}</td>
|
||||
<td>{{$op_label}}</td>
|
||||
<td>{{$amount}}</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
3
snippets/my_details.html
Normal file
3
snippets/my_details.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:include file="./_details.html"}}
|
||||
|
|
@ -1,210 +1,4 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{#restrict section="users" level="read"}}{{/restrict}}
|
||||
|
||||
{{* 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}}
|
||||
|
||||
{{*
|
||||
vérifier l'existence de la table du module
|
||||
eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans
|
||||
*}}
|
||||
{{#load limit="1"}}
|
||||
{{:assign table_presente=true}}
|
||||
{{else}}
|
||||
{{:assign table_presente=false}}
|
||||
{{/load}}
|
||||
|
||||
{{if $table_presente}}
|
||||
{{* Matériels attribués temporairement *}}
|
||||
{{* vérifier la présence des types d'entrées et de sorties requis *}}
|
||||
{{if $output_types|has_key:"temporaire" && $input_types|has_key:"retour"}}
|
||||
|
||||
{{*
|
||||
Calculer les quantités de matériel en prêt
|
||||
*}}
|
||||
{{:assign premier=true}}
|
||||
{{#select
|
||||
json_extract(mvt.document, '$.direction') AS direction,
|
||||
json_extract(mvt.document, '$.date') AS date,
|
||||
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
|
||||
INNER JOIN {!$module.table} AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||
WHERE
|
||||
users.id = :user
|
||||
AND
|
||||
json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND
|
||||
(json_extract(mvt.document, '$.operation') IN !output_types
|
||||
OR
|
||||
json_extract(mvt.document, '$.operation') IN !input_types)
|
||||
ORDER BY eqpmt_name, date
|
||||
;
|
||||
:user = $user.id
|
||||
!output_types=$output_types.temporaire
|
||||
!input_types=$input_types.retour
|
||||
}}
|
||||
{{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.eqpmt_key" value=$eqpmt_key}}
|
||||
{{: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}}
|
||||
{{:assign var="ligne.retard" value=$nb_jours}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $eqpmt_key != $old_eqpmt_key}}
|
||||
{{if $total > 0}}
|
||||
{{:assign var="ligne.qte" value=$total}}
|
||||
{{: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.eqpmt_key" value=$eqpmt_key}}
|
||||
{{: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}}
|
||||
{{:assign var="ligne.retard" value=$nb_jours}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $direction == "output"}}
|
||||
{{:assign total="%d+%d"|math:$total:$qte}}
|
||||
{{else}}
|
||||
{{:assign total="%d-%d"|math:$total:$qte}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{if $total > 0}}
|
||||
{{:assign var="ligne.qte" value=$total}}
|
||||
{{:assign var="lignes." value=$ligne}}
|
||||
{{/if}}
|
||||
|
||||
{{if $lignes|count > 0}}
|
||||
<h3 class="ruler">Matériels attribués temporairement</h3>
|
||||
<table class="list" id="liste_temporaires">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Matériel</th>
|
||||
<th>Quantité</th>
|
||||
<th>Date de retour</th>
|
||||
<th>Remarque</th>
|
||||
<th class="actions">
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$lignes}}
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$materiel}}</td>
|
||||
<td>{{$qte}}</td>
|
||||
<td>{{$return_date|date_short}}</td>
|
||||
<td>
|
||||
{{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}}
|
||||
</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>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* Matériels attribués définitivement *}}
|
||||
{{* vérifier la présence des types de sorties requis *}}
|
||||
{{if $output_types|has_key:"définitif"}}
|
||||
{{#select
|
||||
eqpmt.key as eqpmt_key,
|
||||
json_extract(eqpmt.document, '$.name') as eqpmt_name,
|
||||
json_extract(mvt.document, '$.direction') as direction,
|
||||
json_extract(mvt.document, '$.operation') as operation,
|
||||
MIN(json_extract(mvt.document, '$.date')) as date,
|
||||
SUM(json_extract(mvt.document, '$.amount')) as amount
|
||||
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 json_extract(mvt.document, '$.operation') IN !output_types
|
||||
GROUP BY eqpmt_key, operation
|
||||
ORDER BY eqpmt_name, date
|
||||
;
|
||||
:user = $user.id
|
||||
!output_types=$output_types.définitif
|
||||
assign="def_mat."
|
||||
}}
|
||||
{{/select}}
|
||||
{{/if}}
|
||||
|
||||
{{if $def_mat|count != 0}}
|
||||
<h3 class="ruler">Matériels attribués définitivement</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Matériel</th>
|
||||
<th>Opération</th>
|
||||
<th>Quantité</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$def_mat}}
|
||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$eqpmt_name}}</td>
|
||||
<td>{{$op_label}}</td>
|
||||
<td>{{$amount}}</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{:include file="./_details.html"}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue