363 lines
12 KiB
HTML
363 lines
12 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
|
|
|
{{*
|
|
Afficher l'historique des mouvements d'un matériel
|
|
paramètres
|
|
- key : clé du matériel
|
|
- prop : = 1 si matériel appartient à l'asso
|
|
- ok : vrai si opération terminée avec succès
|
|
- err : vrai si opération terminée en erreur (ça fait doublon avec ok, non ?)
|
|
- msg : message de retour
|
|
*}}
|
|
|
|
{{:assign equipment_key=$_GET.key|trim}}
|
|
{{#load key=$equipment_key assign="equipment"}}
|
|
{{else}}
|
|
{{:error message="Pas de matériel avec la clé %s"|args:$equipment_key}}
|
|
{{/load}}
|
|
|
|
{{#load type="category" where="key = :cle" :cle=$equipment.category assign="category"}}
|
|
{{else}}
|
|
{{:error message="Le matériel %s n'appartient à aucune catégorie"|args:$equipment.name}}
|
|
{{/load}}
|
|
|
|
{{:admin_header title="Gestion des matériels" custom_css="./style.css" current="module_equipment"}}
|
|
|
|
{{* barre de navigation *}}
|
|
{{if $_GET.current != null}}
|
|
{{:assign current=$_GET.current}}
|
|
{{else}}
|
|
{{:assign current="inventaire"}}
|
|
{{/if}}
|
|
{{:include file="./_nav.html" current=$current subcurrent="historique" eqpmt=$equipment.name category=$category.name}}
|
|
|
|
{{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 == "retour"}}
|
|
<p class="block confirm">Retour enregistré</p>
|
|
{{elseif $_GET.msg == "suppression"}}
|
|
<p class="block confirm">Mouvement supprimé</p>
|
|
{{else}}
|
|
<p class="block confirm">Mouvement enregistré</p>
|
|
{{/if}}
|
|
{{elseif $_GET.err}}
|
|
{{if $_GET.msg == "suppression"}}
|
|
<p class="block error">Ce mouvement ne peut être supprimé</p>
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
|
{{:include file="./_get_config.html" keep="config"}}
|
|
|
|
{{* filtrer selon appartenance *}}
|
|
{{if $_GET.prop == null}}
|
|
{{:assign selected_prop=$module.config.eqpmt_hist_prop}}
|
|
{{elseif $_GET.prop == -1}}
|
|
{{:assign selected_prop=null}}
|
|
{{:save key="config" eqpmt_hist_prop=null}}
|
|
{{else}}
|
|
{{:assign selected_prop=$_GET.prop}}
|
|
{{:save key="config" eqpmt_hist_prop=$_GET.prop}}
|
|
{{/if}}
|
|
|
|
{{* déterminer les types de mouvements selon l'appartenance du matériel *}}
|
|
{{#foreach from=$config.input_nature key="key"}}
|
|
{{if $selected_prop == null}}
|
|
{{* les deux sortes de matériel *}}
|
|
{{:assign var="mvt_keys." value=$key|quote_sql}}
|
|
{{if $type == 'temporaire'}}
|
|
{{:assign var="temp_inputs." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{elseif $selected_prop == 1}}
|
|
{{* matériel propriété de l'asso *}}
|
|
{{if $type != 'temporaire'}}
|
|
{{:assign var="mvt_keys." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{else}}
|
|
{{* matériel non propriété de l'asso *}}
|
|
{{if $type == 'temporaire'}}
|
|
{{:assign var="mvt_keys." value=$key|quote_sql}}
|
|
{{:assign var="temp_inputs." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{/foreach}}
|
|
|
|
{{#foreach from=$config.output_nature key="key"}}
|
|
{{if $selected_prop == null}}
|
|
{{* les deux sortes de matériel *}}
|
|
{{:assign var="mvt_keys." value=$key|quote_sql}}
|
|
{{if $type == "temporaire"}}
|
|
{{:assign var="temp_outputs." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{elseif $selected_prop == 1}}
|
|
{{* matériel propriété de l'asso *}}
|
|
{{if $type != 'retour'}}
|
|
{{:assign var="mvt_keys." value=$key|quote_sql}}
|
|
{{if $type == "temporaire"}}
|
|
{{:assign var="temp_outputs." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{else}}
|
|
{{* matériel non propriété de l'asso *}}
|
|
{{if $type == 'retour'}}
|
|
{{:assign var="mvt_keys." value=$key|quote_sql}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{/foreach}}
|
|
{{:assign key_cond=$mvt_keys|implode:","}}
|
|
{{:assign key_cond="("|cat:$key_cond|cat:")"}}
|
|
|
|
{{if $selected_prop == null}}
|
|
{{:assign prop_condition="1"}}
|
|
{{else}}
|
|
{{:assign prop_condition="$$.operation in %s"|args:$key_cond}}
|
|
{{/if}}
|
|
|
|
{{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}}
|
|
{{:assign stock=0}}
|
|
{{:assign exterieur=0}}
|
|
{{:assign nonproprio=0}}
|
|
|
|
{{#load type="movement" where="$$.equipment = :key" :key=$equipment_key order="$$.date"}}
|
|
{{if $direction == 'input'}}
|
|
{{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$operation}}
|
|
{{if $type_mvt == 'définitif'}}
|
|
{{:assign stock="%d+%d"|math:$stock:$amount}}
|
|
{{elseif $type_mvt == 'retour'}}
|
|
{{:assign exterieur="%d-%d"|math:$exterieur:$amount}}
|
|
{{elseif $type_mvt == 'temporaire'}}
|
|
{{:assign nonproprio="%d+%d"|math:$nonproprio:$amount}}
|
|
{{/if}}
|
|
{{else}}
|
|
{{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$operation}}
|
|
{{if $type_mvt == 'définitif'}}
|
|
{{:assign stock="%d-%d"|math:$stock:$amount}}
|
|
{{elseif $type_mvt == 'temporaire'}}
|
|
{{:assign exterieur="%d+%d"|math:$exterieur:$amount}}
|
|
{{elseif $type_mvt == 'retour'}}
|
|
{{:assign nonproprio="%d-%d"|math:$nonproprio:$amount}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{:assign dispo_final="%d-%d"|math:$stock:$exterieur}}
|
|
{{:assign var="quantites.%s.stock"|args:$id value=$stock}}
|
|
{{:assign var="quantites.%s.exterieur"|args:$id value=$exterieur}}
|
|
{{:assign var="quantites.%s.dispo"|args:$id value=$dispo_final}}
|
|
{{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}}
|
|
{{/load}}
|
|
|
|
{{if $selected_prop == null || $selected_prop}}
|
|
{{* calculer la quantité sortie temporairement de chaque matériel *}}
|
|
{{:assign output_ops=$temp_outputs|implode:","}}
|
|
{{:assign output_ops="("|cat:$output_ops|cat:")"}}
|
|
|
|
{{#select
|
|
mvt.key AS mvt_key,
|
|
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
|
|
FROM !table AS mvt
|
|
LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key')
|
|
LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
|
WHERE
|
|
json_extract(mvt.document, '$.operation') IN !op
|
|
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
|
GROUP by mvt.key
|
|
;
|
|
!table=$module.table
|
|
!op = $output_ops
|
|
:eqpmt_key = $_GET.key
|
|
}}
|
|
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
|
|
{{/select}}
|
|
{{/if}}
|
|
|
|
{{if $selected_prop == null || ! $selected_prop}}
|
|
{{* calculer la quantité présente temporairement de chaque matériel *}}
|
|
{{:assign input_ops=$temp_inputs|implode:","}}
|
|
{{:assign input_ops="("|cat:$input_ops|cat:")"}}
|
|
|
|
{{#select
|
|
mvt.key AS mvt_key,
|
|
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
|
|
FROM !table AS mvt
|
|
LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key')
|
|
LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
|
WHERE
|
|
json_extract(mvt.document, '$.operation') IN !op
|
|
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
|
GROUP by mvt.key
|
|
;
|
|
!table=$module.table
|
|
!op = $input_ops
|
|
:eqpmt_key = $_GET.key
|
|
}}
|
|
{{:assign var="present.%s"|args:$mvt_key value=$present}}
|
|
{{/select}}
|
|
{{/if}}
|
|
|
|
{{:assign
|
|
select_debut="
|
|
($$.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';
|
|
$$.amount AS 'Quantité';"
|
|
}}
|
|
{{:assign
|
|
select_prop="'' AS 'Stock';
|
|
'' AS 'Sorti';
|
|
'' AS 'Disponible';"
|
|
}}
|
|
{{:assign
|
|
select_depositaire="CASE WHEN $$.user NOT NULL
|
|
THEN (SELECT %s AS nom FROM users WHERE id = $$.user)
|
|
ELSE ''
|
|
END AS 'Dépositaire';
|
|
"|args:$config.user_fields.name_sql
|
|
}}
|
|
{{:assign
|
|
select_non_prop="'' as 'Temporaire';"
|
|
}}
|
|
{{:assign select_final="
|
|
CASE WHEN $$.storage NOT NULL
|
|
THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
|
|
ELSE ''
|
|
END AS 'Stockage';
|
|
'' AS 'Documents';
|
|
$$.transactions AS 'Écritures'
|
|
"
|
|
}}
|
|
|
|
{{if $selected_prop == null}}
|
|
{{:assign select_clause=$select_debut|cat:$select_prop|cat:$select_non_prop|cat:$select_depositaire|cat:$select_final}}
|
|
{{elseif $selected_prop}}
|
|
{{:assign select_clause=$select_debut|cat:$select_prop|cat:$select_depositaire|cat:$select_final}}
|
|
{{else}}
|
|
{{:assign select_clause=$select_debut|cat:$select_non_prop|cat:$select_final}}
|
|
{{/if}}
|
|
|
|
{{:assign var="prop_options." value="" label="Tous les matériels" href="?key=%s&prop=-1"|args:$_GET.key}}
|
|
{{:assign var="prop_options." value="1" label="Matériels propriété de l'association" href="?key=%s&prop=1"|args:$_GET.key}}
|
|
{{:assign var="prop_options." value="0" label="Matériels NON propriété de l'association" href="?key=%s&prop=0"|args:$_GET.key}}
|
|
|
|
<fieldset class="shortFormRight">
|
|
<legend>Filtrer par appartenance</legend>
|
|
{{:dropdown
|
|
title="Filtrer par appartenance"
|
|
options=$prop_options
|
|
value="%s"|args:$selected_prop
|
|
}}
|
|
</fieldset>
|
|
|
|
{{if $current != "archives"}}
|
|
<nav class="tabs">
|
|
<aside>
|
|
{{if $dispo_final > 0 && $selected_prop == null || $selected_prop}}
|
|
{{:linkbutton label="Sortie" shape="minus" href="movements/output_equipment.html?key=%s"|args:$_GET.key target="_dialog"}}
|
|
{{/if}}
|
|
{{:linkbutton label="Entrée" shape="plus" href="movements/input_equipment.html?key=%s"|args:$_GET.key target="_dialog"}}
|
|
</aside>
|
|
</nav>
|
|
{{/if}}
|
|
|
|
{{* lister les mouvements du matériel passé en paramètre *}}
|
|
{{#list
|
|
type="movement"
|
|
select="%s"|args:$select_clause
|
|
where="%s"|args:$prop_condition
|
|
equipment=$equipment_key
|
|
order=1
|
|
}}
|
|
{{: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="stock" from="quantites.%s.stock"|args:$id}}
|
|
{{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}}
|
|
{{:assign var="dispo" from="quantites.%s.dispo"|args:$id}}
|
|
{{:assign var="tempo" from="quantites.%s.nonproprio"|args:$id}}
|
|
|
|
{{: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 $selected_prop == null}}
|
|
{{:assign user_details=$col9}}
|
|
{{:assign storage=$col10}}
|
|
{{elseif $selected_prop}}
|
|
{{:assign user_details=$col8}}
|
|
{{:assign storage=$col9}}
|
|
{{else}}
|
|
{{:assign user_details=$col6}}
|
|
{{:assign storage=$col6}}
|
|
{{/if}}
|
|
|
|
<tr>
|
|
<td>{{$date|date_short}}</td>
|
|
<td>{{$col2}}</td>
|
|
<td class="nosort">{{$op_label}}</td>
|
|
<td class="num">{{$amount}}</td>
|
|
{{if $selected_prop == null || $selected_prop}}
|
|
<td class="num nosort">{{$stock}}</td>
|
|
<td class="num nosort">{{$exterieur}}</td>
|
|
<td class="num nosort">{{$dispo}}</td>
|
|
{{/if}}
|
|
{{if $selected_prop == null || ! $selected_prop}}
|
|
<td class="num nosort">{{$tempo}}</td>
|
|
{{/if}}
|
|
{{if $selected_prop == null || $selected_prop}}
|
|
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$user_details}}</td>
|
|
{{/if}}
|
|
<td>{{$storage}}</td>
|
|
<td class="num nosort">{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}</td>
|
|
<td class="num">{{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}}</td>
|
|
<td class="actions">
|
|
{{if $current != "archives"}}
|
|
{{if $direction == "output" && $type_mvt == "temporaire"}}
|
|
{{:assign var="temp_ext" from="reste.%s"|args:$key}}
|
|
{{if $temp_ext != null && $temp_ext > 0}}
|
|
{{:linkbutton
|
|
label="Retour"
|
|
href="movements/output_return.html?key=%s&prop=%s"|args:$key:$selected_prop
|
|
shape="reset"
|
|
target="_dialog"}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{if $direction == "input" && $type_mvt == "temporaire"}}
|
|
{{:assign var="temp_in" from="present.%s"|args:$key}}
|
|
{{if $temp_in != null && $temp_in > 0}}
|
|
{{:linkbutton
|
|
label="Retour"
|
|
href="movements/input_return.html?key=%s&prop=%s"|args:$key:$selected_prop
|
|
shape="reset"
|
|
target="_dialog"}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{:linkbutton
|
|
label="Détails"
|
|
href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$selected_prop
|
|
shape="eye"
|
|
}}
|
|
{{/if}}
|
|
</td>
|
|
</tr>
|
|
{{/list}}
|
|
|
|
{{if $dispo_final == 0 && $stock > 0 && $current != "archives"}}
|
|
<span class="help">Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie</span>
|
|
{{/if}}
|
|
|
|
{{:admin_footer}}
|
|
|
|
<script type="text/javascript" src="scripts.js"></script>
|
|
<script type="text/javascript">
|
|
(function () {
|
|
let table = document.querySelector("table[class=list]");
|
|
if (table != null) {
|
|
disableColumSort(table);
|
|
}
|
|
})();
|
|
</script>
|