180 lines
5.2 KiB
HTML
180 lines
5.2 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
|
|
|
{{:admin_header title="Prêts en cours" custom_css="../style.css" current="module_equipment"}}
|
|
{{:include file="./_nav.html" current="prêts" subcurrent="encours"}}
|
|
|
|
{{*
|
|
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}}
|
|
{{if $_GET.ok}}
|
|
{{if $_GET.msg == "modification"}}
|
|
<p class="block confirm">Modification enregistrée</p>
|
|
{{elseif $_GET.msg == "copie"}}
|
|
<p class="block confirm">Mouvement copié</p>
|
|
{{elseif $_GET.msg == "suppression"}}
|
|
<p class="block confirm">Mouvement supprimé</p>
|
|
{{/if}}
|
|
{{elseif $_GET.err}}
|
|
{{if $_GET.msg == "suppression"}}
|
|
<p class="block error">Ce mouvement ne peut être supprimé</p>
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
{{* lecture config (défaut ou enregistrée) *}}
|
|
{{:include file="./_get_config.html" keep="config"}}
|
|
|
|
{{* filtrer selon la catégorie *}}
|
|
{{if $_GET.cat_key == null}}
|
|
{{:assign selected_category=$module.config.loan_hist_cat_key}}
|
|
{{elseif $_GET.cat_key == -1}}
|
|
{{:assign selected_category=null}}
|
|
{{:save key="config" loan_hist_cat_key=null}}
|
|
{{else}}
|
|
{{:assign selected_category=$_GET.cat_key}}
|
|
{{:save key="config" loan_hist_cat_key=$selected_category}}
|
|
{{/if}}
|
|
|
|
{{* condition de filtrage *}}
|
|
{{if $selected_category != null}}
|
|
{{:assign cat_key=$selected_category|quote_sql}}
|
|
{{:assign cat_condition="json_extract(mat.document, '$.category') = %s"|args:$cat_key}}
|
|
{{else}}
|
|
{{:assign cat_condition=1}}
|
|
{{/if}}
|
|
|
|
{{#foreach from=$config.output_nature key="key"}}
|
|
{{if $type == 'temporaire' && $fee != 'payant'}}
|
|
{{:assign var="out_keys." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{/foreach}}
|
|
{{:assign out_keys=$out_keys|implode:","}}
|
|
{{:assign out_keys="("|cat:$out_keys|cat:")"}}
|
|
|
|
{{* sélecteur de catégorie *}}
|
|
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
|
|
{{#load type="category" order="$$.name"}}
|
|
{{:assign
|
|
var="cat_options."
|
|
value=$key
|
|
label=$name
|
|
href="?cat_key=%s"|args:$key
|
|
}}
|
|
{{/load}}
|
|
|
|
<fieldset class="shortFormRight">
|
|
<legend>Filtrer par catégorie</legend>
|
|
{{:dropdown
|
|
title="Filtrer par catégorie"
|
|
options=$cat_options
|
|
value="%s"|args:$selected_category
|
|
}}
|
|
</fieldset>
|
|
|
|
<div class="shortFormLeft">
|
|
<p class="help">Location de matériel en cours</p>
|
|
</div>
|
|
|
|
{{:assign premier=true}}
|
|
{{#select
|
|
users.nom AS nom,
|
|
users.id AS user,
|
|
mvt.key AS mvt_key,
|
|
json_extract(mat.document, '$.name') AS mat_name,
|
|
json_extract(mvt.document, '$.date') AS out_date,
|
|
json_extract(mvt.document, '$.amount') AS out_amount,
|
|
json_extract(mvt.document, '$.return_date') AS return_date,
|
|
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS remain
|
|
FROM !table AS mvt
|
|
LEFT JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
|
LEFT JOIN !table AS links ON mvt.key = json_extract(links.document, '$.temp_key')
|
|
LEFT JOIN !table AS retour ON retour.key = json_extract(links.document, '$.return')
|
|
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
|
WHERE json_extract(mvt.document, '$.type') = 'movement'
|
|
AND json_extract(mvt.document, '$.operation') IN !op
|
|
AND !cat_condition
|
|
GROUP BY mvt.key
|
|
HAVING remain != 0
|
|
ORDER BY out_date, nom
|
|
;
|
|
!table=$module.table
|
|
!op = $out_keys
|
|
!cat_condition=$cat_condition
|
|
}}
|
|
{{if $premier}}
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<td>Matériel</td>
|
|
<td>Date prêt</td>
|
|
<td>Quantité</td>
|
|
<td>Membre</td>
|
|
<td>Date retour</td>
|
|
<td>Reste à rendre</td>
|
|
<td>Remarque</td>
|
|
<td class="actions"></td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{:assign premier=false}}
|
|
{{/if}}
|
|
|
|
{{if $return_date != null}}
|
|
{{:assign ts_retour=$return_date|strtotime}}
|
|
{{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}}
|
|
{{/if}}
|
|
<tr>
|
|
<td>{{$mat_name}}</td>
|
|
<td>{{$out_date|date_short}}</td>
|
|
<td>{{$out_amount}}</td>
|
|
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$nom}}</td>
|
|
<td>{{$return_date|date_short}}</td>
|
|
<td>{{$remain}}</td>
|
|
<td>
|
|
{{if $return_date != null}}
|
|
{{:assign jour="jour}}
|
|
{{if $nb_jours > 0}}
|
|
{{if $nb_jours > 1}}{{:assign jour="jours"}}{{/if}}
|
|
{{:tag color="darkred" label="Retard %s %s"|args:$nb_jours:$jour}}
|
|
{{elseif $nb_jours < 0}}
|
|
{{:assign delai="abs(%d)"|math:$nb_jours}}
|
|
{{if $nb_jours < -1}}{{:assign jour="jours"}}{{/if}}
|
|
{{"Reste %s %s"|args:$delai:$jour}}
|
|
{{else}}
|
|
{{:tag color="darkgreen" label="À rendre aujourd'hui"}}
|
|
{{/if}}
|
|
{{/if}}
|
|
</td>
|
|
<td class="actions">
|
|
{{:linkbutton
|
|
label="Retour"
|
|
href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key
|
|
shape="reset"
|
|
target="_dialog"}}
|
|
{{:linkbutton
|
|
label="Détails"
|
|
href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key
|
|
shape="eye"
|
|
}}
|
|
</td>
|
|
</tr>
|
|
{{else}}
|
|
<p class="block alert">Aucun mouvement.</p>
|
|
{{/select}}
|
|
</tbody>
|
|
</table>
|
|
{{else}}
|
|
<p class="block alert">Aucun mouvement.</p>
|
|
{{/if}}
|
|
|
|
{{:admin_footer}}
|