diff --git a/loan_movements.html b/loan_movements.html new file mode 100644 index 0000000..e23e8d1 --- /dev/null +++ b/loan_movements.html @@ -0,0 +1,130 @@ +{{* -*- brindille -*- *}} + +{{#restrict block=true section="accounting" level="write"}}{{/restrict}} + +{{* + Afficher l'historique des prêts +*}} + +{{:admin_header title="Historique des prêts" custom_css="./style.css" current="module_equipment"}} + +{{:include file="./_nav.html" current="prêts" subcurrent="historique"}} + +{{* récupérer la config des entrées/sorties *}} +{{:include file="./_get_config.html" keep="config"}} + +{{* filtrer selon la catégorie *}} +{{if $_GET.cat_key == null}} + {{:assign selected_category=$module.config.loan_cat_key}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" loan_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:save key="config" loan_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category != null}} + {{:assign cat_condition="(SELECT key + FROM @TABLE AS cat + WHERE cat.key = (SELECT $$.category + FROM @TABLE AS mat + WHERE mat.key = @TABLE.$$.equipment)) = '%s'"|args:$selected_category}} +{{else}} + {{:assign cat_condition=1}} +{{/if}} + +{{* déterminer les types de mouvements *}} +{{#foreach from=$config.input_nature key="key"}} + {{if $type == 'retour'}} + {{:assign var="mvt_keys." value=$key|quote_sql}} + {{/if}} +{{/foreach}} + +{{#foreach from=$config.output_nature key="key"}} + {{if $type == 'temporaire'}} + {{:assign var="mvt_keys." value=$key|quote_sql}} + {{/if}} +{{/foreach}} +{{:assign key_cond=$mvt_keys|implode:","}} +{{:assign key_cond="("|cat:$key_cond|cat:")"}} +{{:assign key_cond="$$.operation IN %s"|args:$key_cond}} + +{{* 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="categories.%s"|args:$key value=$name*}} + {{:assign + var="cat_options." + value=$key + label=$name + href="?cat_key=%s"|args:$key + }} +{{/load}} + +
+ Filtrer par catégorie + {{:dropdown + title="Filtrer par catégorie" + options=$cat_options + value="%s"|args:$selected_category + }} +
+ +
+

Historique des prêts

+
+ +{{* lister les mouvements *}} +{{#list + type="movement" + select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date'; + CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement'; + $$.operation AS 'Opération'; + (SELECT $$.name + FROM @TABLE AS mat + WHERE mat.key = @TABLE.$$.equipment) AS 'Matériel' ; + $$.amount AS 'Quantité'; + CASE WHEN $$.user NOT NULL + THEN (SELECT %s AS nom FROM users WHERE id = $$.user) + ELSE '' + END as 'Dépositaire'; + CASE WHEN $$.storage NOT NULL + THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage) + ELSE '' + END as 'Stockage'; + $$.comment AS 'Commentaire' + "|args:$config.user_fields.name_sql + where="%s AND %s"|args:$key_cond:$cat_condition + order=1 + max=50 + desc=true +}} + {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} + + {{$date|date_short}} + {{$col2}} + {{$op_label}} + {{$col4}} + {{$amount}} + {{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col6}} + {{$col7}} + {{$comment}} + + +{{else}} +

Aucun mouvement.

+{{/list}} +{{* *}} +{{:admin_footer}} + + +