{{* -*- brindille -*- *}} {{#restrict block=true section="accounting" level="write"}}{{/restrict}} {{* Afficher l'historique des prêts ou locations *}} {{if $_GET.output_type == "loan"}} {{:assign label="prêt"}} {{elseif $_GET.output_type == "rent"}} {{:assign label="location"}} {{else}} {{:error message="Cette page n'existe pas !"}} {{/if}} {{:admin_header title="Historique des %ss"|args:$label custom_css="./style.css" current="module_equipment"}} {{:include file="./_nav.html" current="%s"|args:$label subcurrent="historique"}} {{* 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"}}

Modification enregistrée

{{elseif $_GET.msg == "copie"}}

Mouvement copié

{{elseif $_GET.msg == "suppression"}}

Mouvement supprimé

{{/if}} {{elseif $_GET.err}} {{if $_GET.msg == "suppression"}}

Ce mouvement ne peut être supprimé

{{/if}} {{/if}} {{* 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 var="selected_category" from="module.config.%s_cat_key"|args:$_GET.output_type}} {{elseif $_GET.cat_key == -1}} {{:assign selected_category=null}} {{if $_GET.output_type == "loan"}} {{:save key="config" loan_cat_key=null}} {{elseif $_GET.output_type == "rent"}} {{:save key="config" rent_cat_key=null}} {{/if}} {{else}} {{:assign selected_category=$_GET.cat_key}} {{if $_GET.output_type == "loan"}} {{:save key="config" loan_cat_key=$selected_category}} {{elseif $_GET.output_type == "rent"}} {{:save key="config" rent_cat_key=$selected_category}} {{/if}} {{/if}} {{* condition de filtrage *}} {{if $selected_category != null}} {{:assign cat_key=$selected_category|quote_sql}} {{:assign cat_condition="category = %s"|args:$cat_key}} {{else}} {{:assign cat_condition=1}} {{/if}} {{* déterminer les types de mouvements *}} {{#foreach from=$config.output_nature key="key"}} {{if $type != 'temporaire'}} {{:continue}} {{/if}} {{if $_GET.output_type == "loan" && $fee != 'payant'}} {{:assign var="out_keys." value=$key|quote_sql}} {{elseif $_GET.output_type == "rent" && $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="?output_type=%s&cat_key=-1"|args:$_GET.output_type}} {{#load type="category" order="$$.name"}} {{:assign var="cat_options." value=$key label=$name href="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key }} {{/load}}
Filtrer par catégorie {{:dropdown title="Filtrer par catégorie" options=$cat_options value="%s"|args:$selected_category }}

Historique des {{$label}}s

{{* lister les mouvements *}} {{:assign premier=true}} {{#select * FROM (WITH sorties AS (SELECT mvt.key, json_extract(mvt.document, '$.date') AS date, json_extract(mvt.document, '$.direction') AS direction, json_extract(mvt.document, '$.operation') AS operation, json_extract(mat.document, '$.name') AS materiel, json_extract(mat.document, '$.category') AS category, json_extract(mvt.document, '$.amount') AS amount, users.id AS user_id, users.nom AS user, json_extract(storage.document, '$.name') AS stockage, json_extract(mvt.document, '$.transactions') AS transactions, json_extract(mvt.document, '$.comment') AS comment, json_extract(mvt.document, '$.return_date') AS return_date FROM !table AS mvt INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment') LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user') LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage') WHERE json_extract(mvt.document, '$.type') = 'movement' AND json_extract(mvt.document, '$.operation') IN !op AND !cat_condition ), entrees AS (SELECT mvt.key, json_extract(mvt.document, '$.date') AS date, json_extract(mvt.document, '$.direction') AS direction, json_extract(mvt.document, '$.operation') AS operation, json_extract(mat.document, '$.name') AS materiel, json_extract(mat.document, '$.category') AS category, json_extract(mvt.document, '$.amount') AS amount, users.id AS user_id, users.nom AS user, json_extract(storage.document, '$.name') AS stockage, json_extract(mvt.document, '$.transactions') AS transactions, json_extract(mvt.document, '$.comment') AS comment, json_extract(mvt.document, '$.return_date') AS return_date FROM !table AS mvt INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment') LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user') LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage') INNER JOIN ( SELECT json_extract(links.document, '$.return') AS return_key FROM !table AS links INNER JOIN sorties ON json_extract(links.document, '$.temp_key') = sorties.key ) AS filtered_links ON filtered_links.return_key = mvt.key WHERE !cat_condition ) SELECT * FROM sorties UNION SELECT * FROM entrees ) ORDER BY date DESC, user ; !table=$module.table !op = $out_keys !cat_condition=$cat_condition }} {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} {{:assign file_path="%s/%s/"|args:$module.storage_root:$key}} {{:assign file_path=$file_path|cat:"%"}} {{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}} {{:assign nb_files=$nb}} {{/select}} {{if $premier}} {{:assign premier=false}} {{/if}} {{else}}

Aucun mouvement.

{{/select}}
Date Mouvement Opération Matériel Quantité Dépositaire Stockage Documents Écritures Remarque
{{$date|date_short}} {{if $direction == "input"}}Entrée{{else}}Sortie{{/if}} {{$op_label}} {{$materiel}} {{$amount}} {{:link href="/admin/users/details.php?id=%s"|args:$user_id label="%s"|args:$user}} {{$stockage}} {{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}} {{if $transactions != null}}{{:icon shape="money"}}{{/if}} {{$comment}} {{if $_GET.output_type == "loan"}} {{:assign from="lm"}} {{elseif $_GET.output_type == "rent"}} {{:assign from="rm"}} {{/if}} {{:linkbutton label="Détails" href="movements/movement_details.html?key=%s&prop=1&from=%s"|args:$key:$from shape="eye" }}
{{else}}

Aucun mouvement.

{{/if}} {{:admin_footer}}