Compare commits

..

10 commits

Author SHA1 Message Date
Jean-Christophe Engel
8266ab8aeb Mise-à-jour README 2025-10-23 10:41:22 +02:00
Jean-Christophe Engel
b6743ad3b3 Simplification détails membre 2025-10-23 10:39:01 +02:00
Jean-Christophe Engel
1d5d54e59e Remplacement nom table explicite 2025-10-22 17:40:45 +02:00
Jean-Christophe Engel
18d9ad9699 Amélioration présentation inventaire 2025-10-22 17:31:13 +02:00
Jean-Christophe Engel
2285c44a32 Rajout bouton historique dans inventaire 2025-10-22 17:28:35 +02:00
Jean-Christophe Engel
56d4f729e3 Correction détection libellé entrée/sortie déjà présent dans config 2025-10-22 17:26:18 +02:00
Jean-Christophe Engel
5848d73196 Amélioration cohérence infos formulaires 2025-10-18 09:36:18 +02:00
Jean-Christophe Engel
36f840b3c6 Correction oubli inhiber tri colonne 2025-10-18 09:36:18 +02:00
Jean-Christophe Engel
14cf1a520d Ajout détails mouvement et possibilité joindre fichier 2025-10-18 09:34:31 +02:00
Jean-Christophe Engel
2ba9c20037 Amélioration présentation détails membre 2025-10-16 11:31:58 +02:00
13 changed files with 301 additions and 166 deletions

View file

@ -3,8 +3,12 @@
Ce module permet de gérer les matériels de l'association: stock, Ce module permet de gérer les matériels de l'association: stock,
entrées, sorties, classés par catégorie. entrées, sorties, classés par catégorie.
Un matériel peut entrer temporairement (location, emprunt, ...) ou Un matériel peut entrer dans l'association :
définitivement dans l'association (achat, ...). - temporairement (location, emprunt, ...)
- définitivement (achat, ...)
Dans les deux cas, il est possible de lui associer une écriture de la
compta ou un fichier.
Un matériel appartenant à l'association peut sortir : Un matériel appartenant à l'association peut sortir :
- temporairement (prêt, ...) : il est possible de lui associer un lieu - temporairement (prêt, ...) : il est possible de lui associer un lieu

View file

@ -1,9 +1,8 @@
{{* -*- brindille -*- *}} {{* -*- brindille -*- *}}
{{* {{*
Récupérer soit la config enregistrée, soit la config par défaut Récupérer la config
@param : default = true si config par défaut résultat : config_defaut, directions, config.input_nature et config.output_nature
résultat : config.input_nature et config.output_nature
*}} *}}
{{* config par défaut *}} {{* config par défaut *}}
@ -15,7 +14,7 @@
{{#foreach from=$directions key="direction"}} {{#foreach from=$directions key="direction"}}
{{:assign var="nature" from="module.config.%s_nature"|args:$direction}} {{:assign var="nature" from="module.config.%s_nature"|args:$direction}}
{{if $nature != null && ! $default}} {{if $nature != null}}
{{#foreach from=$nature item="elem"}} {{#foreach from=$nature item="elem"}}
{{:assign var="item" label=$label type=$type}} {{:assign var="item" label=$label type=$type}}
{{:assign var="config.%s_nature.%s"|args:$direction:$key value=$item}} {{:assign var="config.%s_nature.%s"|args:$direction:$key value=$item}}

View file

@ -72,6 +72,10 @@
href="movements/input_equipment.html?key=%s"|args:$key href="movements/input_equipment.html?key=%s"|args:$key
target="_dialog"}} target="_dialog"}}
{{:linkbutton {{:linkbutton
label="Historique"
href="equipment_history.html?key=%s&prop=1"|args:$key
shape="table"}}
{{:linkbutton
label="Modifier" label="Modifier"
href="modify_equipment.html?key=%s&prop=1"|args:$key href="modify_equipment.html?key=%s&prop=1"|args:$key
shape="edit" shape="edit"
@ -84,7 +88,10 @@
<script type="text/javascript" src="scripts.js"></script> <script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
disableColumSort(document.querySelector("table[class=list]")); let table = document.querySelector("table[class=list]");
})(); if (table != null) {
disableColumSort(table);
}
})();
</script> </script>

View file

@ -61,6 +61,10 @@
href="movements/input_equipment.html?key=%s"|args:$key href="movements/input_equipment.html?key=%s"|args:$key
target="_dialog"}} target="_dialog"}}
{{:linkbutton {{:linkbutton
label="Historique"
href="equipment_history.html?key=%s&prop=0"|args:$key
shape="table"}}
{{:linkbutton
label="Modifier" label="Modifier"
href="modify_equipment.html?key=%s&prop=0"|args:$key href="modify_equipment.html?key=%s&prop=0"|args:$key
shape="edit" shape="edit"

View file

@ -12,16 +12,16 @@
{{* Traiter l'envoi du formulaire *}} {{* Traiter l'envoi du formulaire *}}
{{* lecture config par défaut *}} {{* lecture config *}}
{{:include file="../_get_config.html" keep="config, directions" default=true}} {{:include file="../_get_config.html" keep="config, directions, config_defaut"}}
{{#form on="save"}} {{#form on="save"}}
{{* vérifier s'il existe un type de mouvement de même nom *}} {{* vérifier s'il existe un libellé de même nom dans la même direction *}}
{{#foreach from=$directions key="direction"}} {{#foreach from=$directions key="direction"}}
{{:assign var="nature" from="config.%s_nature"|args:$direction}} {{:assign var="nature" from="config.%s_nature"|args:$direction}}
{{#foreach from=$nature key="key"}} {{#foreach from=$nature key="key"}}
{{:assign var="fields" from="_POST.%s_fields"|args:$_GET.dir}} {{:assign var="fields" from="_POST.%s_fields"|args:$_GET.dir}}
{{if $label|trim|tolower == $fields.label|trim|tolower}} {{if $_GET.dir == $direction && $label|trim|tolower == $fields.label|trim|tolower}}
{{:error message="Ce libellé est déjà présent"}} {{:error message="Ce libellé est déjà présent"}}
{{/if}} {{/if}}
{{:assign var="%s_nature.key"|args:$direction value=$key}} {{:assign var="%s_nature.key"|args:$direction value=$key}}
@ -39,7 +39,6 @@
{{:assign var="%s_nature.type"|args:$direction from="_POST.%s_fields.type"|args:$direction}} {{:assign var="%s_nature.type"|args:$direction from="_POST.%s_fields.type"|args:$direction}}
{{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}} {{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
{{/if}} {{/if}}
{{/foreach}} {{/foreach}}
{{:save {{:save
@ -56,7 +55,7 @@
{{if $_GET.dir == 'input'}} {{if $_GET.dir == 'input'}}
{{* types d'entrées *}} {{* types d'entrées *}}
{{#foreach from=$config.input_nature}} {{#foreach from=$config_defaut.inputs}}
{{:assign var='input_types.%s'|args:$type value=$type}} {{:assign var='input_types.%s'|args:$type value=$type}}
{{/foreach}} {{/foreach}}
<form method="post" action=""> <form method="post" action="">
@ -95,7 +94,7 @@
</form> </form>
{{else}} {{else}}
{{* types de sorties *}} {{* types de sorties *}}
{{#foreach from=$config.output_nature}} {{#foreach from=$config_defaut.outputs}}
{{:assign var='output_types.%s'|args:$type value=$type}} {{:assign var='output_types.%s'|args:$type value=$type}}
{{/foreach}} {{/foreach}}

View file

@ -28,6 +28,7 @@
{{else}} {{else}}
{{:error message="Le matériel %s n'appartient à aucune catégorie"|args:$equipment.name}} {{:error message="Le matériel %s n'appartient à aucune catégorie"|args:$equipment.name}}
{{/load}} {{/load}}
{{:admin_header title="Gestion des matériels" custom_css="./style.css" current="module_equipment"}} {{:admin_header title="Gestion des matériels" custom_css="./style.css" current="module_equipment"}}
{{if $_GET.current != null}} {{if $_GET.current != null}}
@ -112,20 +113,20 @@
{{:assign nonproprio="%d-%d"|math:$nonproprio:$amount}} {{:assign nonproprio="%d-%d"|math:$nonproprio:$amount}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{:assign dispo="%d-%d"|math:$stock:$exterieur}} {{:assign dispo_final="%d-%d"|math:$stock:$exterieur}}
{{:assign var="quantites.%s.stock"|args:$id value=$stock}} {{:assign var="quantites.%s.stock"|args:$id value=$stock}}
{{:assign var="quantites.%s.exterieur"|args:$id value=$exterieur}} {{:assign var="quantites.%s.exterieur"|args:$id value=$exterieur}}
{{:assign var="quantites.%s.dispo"|args:$id value=$dispo}} {{:assign var="quantites.%s.dispo"|args:$id value=$dispo_final}}
{{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}} {{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}}
{{/load}} {{/load}}
{{if $current != "archives"}} {{if $current != "archives"}}
<nav class="tabs"> <nav class="tabs">
<aside> <aside>
{{if $_GET.prop && $equipment.stock > 0}} {{if $_GET.prop && $dispo_final > 0}}
{{:linkbutton label="Sortie" title="Enregistrer une sortie de ce matériel" shape="minus" href="movements/output_equipment.html?key=%s"|args:$_GET.key target="_dialog"}} {{:linkbutton label="Sortie" shape="minus" href="movements/output_equipment.html?key=%s"|args:$_GET.key target="_dialog"}}
{{/if}} {{/if}}
{{:linkbutton label="Entrée" title="Enregistrer une entrée de ce matériel" shape="plus" href="movements/input_equipment.html?key=%s"|args:$_GET.key target="_dialog"}} {{:linkbutton label="Entrée" shape="plus" href="movements/input_equipment.html?key=%s"|args:$_GET.key target="_dialog"}}
</aside> </aside>
</nav> </nav>
{{/if}} {{/if}}
@ -144,9 +145,9 @@
{{#select {{#select
mvt.key AS mvt_key, mvt.key AS mvt_key,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
FROM module_data_equipment AS mvt FROM {!$module.table} AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.temp_key') LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE WHERE
json_extract(mvt.document, '$.operation') IN !op json_extract(mvt.document, '$.operation') IN !op
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
@ -176,7 +177,8 @@
THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage) THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
ELSE '' ELSE ''
END AS 'Stockage'; END AS 'Stockage';
$$.comment AS 'Commentaire' '' AS 'Documents';
$$.transactions AS 'Écritures'
"|args:$config.user_fields.name_sql "|args:$config.user_fields.name_sql
equipment=$equipment_key equipment=$equipment_key
order=1 order=1
@ -190,6 +192,12 @@
{{:assign var="stock" from="quantites.%s.stock"|args:$id}} {{:assign var="stock" from="quantites.%s.stock"|args:$id}}
{{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}} {{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}}
{{:assign var="dispo" from="quantites.%s.dispo"|args:$id}} {{:assign var="dispo" from="quantites.%s.dispo"|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}}
<tr> <tr>
<td>{{$date|date_short}}</td> <td>{{$date|date_short}}</td>
<td>{{$col2}}</td> <td>{{$col2}}</td>
@ -200,7 +208,8 @@
<td class="num nosort">{{$dispo}}</td> <td class="num nosort">{{$dispo}}</td>
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col8}}</td> <td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col8}}</td>
<td>{{$col9}}</td> <td>{{$col9}}</td>
<td>{{$comment}}</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"> <td class="actions">
{{if $current != "archives"}} {{if $current != "archives"}}
{{if $direction == "output" && $type_mvt == "temporaire"}} {{if $direction == "output" && $type_mvt == "temporaire"}}
@ -208,37 +217,24 @@
{{if $temp_ext != null && $temp_ext > 0}} {{if $temp_ext != null && $temp_ext > 0}}
{{:linkbutton {{:linkbutton
label="Retour" label="Retour"
title="Enregistrer un retour de sortie temporaire"
href="movements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop href="movements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="reset" shape="reset"
target="_dialog"}} target="_dialog"}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{if $direction == "input" && $type_mvt == "retour"}}
{{* interdire dupliquer *}}
{{else}}
{{:linkbutton {{:linkbutton
label="Dupliquer" label="Détails"
href="movements/copy_movement.html?key=%s&prop=%s"|args:$key:$_GET.prop href="movements/movement_details.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="plus" shape="eye"
target="_dialog"}} }}
{{/if}}
{{:linkbutton
label="Modifier"
href="movements/modify_movement.html?key=%s"|args:$key
shape="edit"
target="_dialog"}}
{{:linkbutton
label="Supprimer"
href="movements/delete_movement.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="delete"
target="_dialog"}}
{{/if}} {{/if}}
</td> </td>
</tr> </tr>
{{/if}} {{/if}}
{{/list}} {{/list}}
{{if $dispo_final === 0}}
<span class="help">Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie</span>
{{/if}}
{{else}} {{else}}
{{* calculer la quantité présente temporairement de chaque matériel *}} {{* calculer la quantité présente temporairement de chaque matériel *}}
{{#foreach from=$config.input_nature key=key}} {{#foreach from=$config.input_nature key=key}}
@ -252,9 +248,9 @@
{{#select {{#select
mvt.key AS mvt_key, mvt.key AS mvt_key,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
FROM module_data_equipment AS mvt FROM {!$module.table} AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.temp_key') LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE WHERE
json_extract(mvt.document, '$.operation') IN !op json_extract(mvt.document, '$.operation') IN !op
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
@ -277,7 +273,9 @@
THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage) THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
ELSE '' ELSE ''
END as 'Stockage'; END as 'Stockage';
$$.comment AS 'Commentaire'" '' AS 'Documents';
$$.transactions AS 'Écritures'
"
equipment=$equipment_key equipment=$equipment_key
order=1 order=1
}} }}
@ -288,6 +286,12 @@
$direction === "output"&& $op_label|in:$output_types $direction === "output"&& $op_label|in:$output_types
}} }}
{{:assign var="stock" from="quantites.%s.nonproprio"|args:$id}} {{:assign var="stock" 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}}
<tr> <tr>
<td>{{$date|date_short}}</td> <td>{{$date|date_short}}</td>
<td>{{$col2}}</td> <td>{{$col2}}</td>
@ -295,38 +299,24 @@
<td class="num">{{$amount}}</td> <td class="num">{{$amount}}</td>
<td class="num nosort">{{$stock}}</td> <td class="num nosort">{{$stock}}</td>
<td>{{$col6}}</td> <td>{{$col6}}</td>
<td>{{$comment}}</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"> <td class="actions">
{{if $direction == "input" && $type_mvt == "temporaire"}} {{if $direction == "input" && $type_mvt == "temporaire"}}
{{:assign var="temp_in" from="present.%s"|args:$key}} {{:assign var="temp_in" from="present.%s"|args:$key}}
{{if $temp_in != null && $temp_in > 0}} {{if $temp_in != null && $temp_in > 0}}
{{:linkbutton {{:linkbutton
label="Retour" label="Retour"
title="Enregistrer un retour d'entrée temporaire"
href="movements/input_return.html?key=%s&prop=%s"|args:$key:$_GET.prop href="movements/input_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="reset" shape="reset"
target="_dialog"}} target="_dialog"}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{if $direction == "output" && $type_mvt == "retour"}}
{{* interdire dupliquer *}}
{{else}}
{{:linkbutton {{:linkbutton
label="Dupliquer" label="Détails"
href="movements/copy_movement.html?key=%s&prop=%s"|args:$key:$_GET.prop href="movements/movement_details.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="plus" shape="eye"
target="_dialog"}} }}
{{/if}}
{{:linkbutton
label="Modifier"
href="movements/modify_movement.html?key=%s"|args:$key
shape="edit"
target="_dialog"}}
{{:linkbutton
label="Supprimer"
href="movements/delete_movement.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="delete"
target="_dialog"}}
</td> </td>
</tr> </tr>
{{/if}} {{/if}}
@ -337,7 +327,10 @@
<script type="text/javascript" src="scripts.js"></script> <script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
disableColumSort(document.querySelector("table[class=list]")); let table = document.querySelector("table[class=list]");
})(); if (table != null) {
disableColumSort(table);
}
})();
</script> </script>

View file

@ -88,7 +88,10 @@
<script type="text/javascript" src="scripts.js"></script> <script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
disableColumSort(document.querySelector("table[class=list]")); let table = document.querySelector("table[class=list]");
})(); if (table != null) {
disableColumSort(table);
}
})();
</script> </script>

View file

@ -202,7 +202,12 @@
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}} {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
{{/form}} {{/form}}
{{:admin_header title="Dupliquer un mouvement" custom_css="./../style.css" current="module_equipment"}} {{if $mvt_new.direction == "input"}}
{{:assign mvt_label="entrée"}}
{{else}}
{{:assign mvt_label="sortie"}}
{{/if}}
{{:admin_header title="Dupliquer une %s"|args:$mvt_label custom_css="./../style.css" current="module_equipment"}}
{{:form_errors}} {{:form_errors}}
{{* {{*
@ -261,9 +266,7 @@
}} }}
{{/if}} {{/if}}
{{if $mvt_new.direction == "input"}} {{if $mvt_new.direction == "input"}}
{{if $storage != null}} {{:input type="select" name="storage" default=$mvt_new.storage label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}}
{{:input type="select" name="storage" label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}}
{{/if}}
{{if $type_mvt != "retour"}} {{if $type_mvt != "retour"}}
{{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}} {{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}}
{{/if}} {{/if}}

View file

@ -32,9 +32,9 @@
{{#select {{#select
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
FROM module_data_equipment AS mvt FROM {!$module.table} AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.temp_key') LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE WHERE
json_extract(mvt.document, '$.operation') IN !op json_extract(mvt.document, '$.operation') IN !op
AND mvt.key = :mvt_key AND mvt.key = :mvt_key

View file

@ -219,7 +219,12 @@
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}} {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}}
{{/form}} {{/form}}
{{:admin_header title="Modifier un mouvement" custom_css="./../style.css" current="module_equipment"}} {{if $mvt_new.direction == "input"}}
{{:assign mvt_label="entrée"}}
{{else}}
{{:assign mvt_label="sortie"}}
{{/if}}
{{:admin_header title="Modifier une %s"|args:$mvt_label custom_css="./../style.css" current="module_equipment"}}
{{:form_errors}} {{:form_errors}}
{{* {{*
@ -232,11 +237,6 @@
{{#select id, !name as nom FROM users WHERE id=:id; !name=$config.user_fields.name_sql :id=$mvt_new.user}} {{#select id, !name as nom FROM users WHERE id=:id; !name=$config.user_fields.name_sql :id=$mvt_new.user}}
{{:assign var="user.%s"|args:$id value=$nom}} {{:assign var="user.%s"|args:$id value=$nom}}
{{/select}} {{/select}}
{{#load type="link" where="$$.direction="output" AND $$.temp_key = :mvt_key" :mvt_key=$mvt_new.key limit=1}}
{{:assign retour=true}}
{{else}}
{{:assign retour=false}}
{{/load}}
{{/if}} {{/if}}
{{#load type="storage" order="$$.name"}} {{#load type="storage" order="$$.name"}}
@ -274,10 +274,11 @@
{{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_new.amount}} {{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_new.amount}}
</dl> </dl>
</fieldset> </fieldset>
<fieldset class="entree"> <fieldset class="entree">
<legend>Informations facultatives</legend> <legend>Informations facultatives</legend>
<dl> <dl>
{{if $prop == 1 && $mvt_new.direction == "output" && ! $retour}} {{if $prop == 1 && $mvt_new.direction == "output"}}
{{:input {{:input
type="list" type="list"
name="user" name="user"

View file

@ -0,0 +1,109 @@
{{* -*- brindille -*- *}}
{{*
Afficher les détails d'un mouvement et donner la possibilité :
- d'associer des fichiers
- de modifier, supprimer ou dupliquer le mouvement
paramètres :
- key : clé du mouvement
- prop = 1 si matériel appartient à l'asso
*}}
{{:admin_header title="Détails du mouvement" custom_css="../style.css" current="module_equipment"}}
{{:form_errors}}
{{* récupérer les infos du mouvement *}}
{{#load key=$_GET.key assign="mvt"}}
{{else}}
{{:error message="Aucun mouvement avec la clé %s"|args:$_GET.key}}
{{/load}}
{{* récupérer la config des entrées/sorties *}}
{{:include file="../_get_config.html" keep="config, directions"}}
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt.direction:$mvt.operation}}
{{* récupérer les infos du matériel associé *}}
{{#load key=$mvt.equipment assign="equipment"}}
{{else}}
{{:error message="Aucun matériel avec la clé « %s »"|args:$mvt.equipment}}
{{/load}}
{{*
-------------------- Afficher les informations du mouvement --------------------
*}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$mvt.direction:$mvt.operation}}
{{#load key=$equipment.category assign="category"}}{{/load}}
{{#load key=$mvt.storage assign="storage"}}{{/load}}
{{#select !name as nom FROM users WHERE id=:id; !name=$config.user_fields.name_sql :id=$mvt.user}}
{{:assign user_name=$nom}}
{{/select}}
<nav class="tabs">
{{:linkbutton
label="Modifier ce mouvement"
href="modify_movement.html?key=%s"|args:$_GET.key
shape="edit"
target="_dialog"}}
{{:linkbutton
label="Supprimer ce mouvement"
href="delete_movement.html?key=%s&prop=%s"|args:$_GET.key:$_GET.prop
shape="delete"
target="_dialog"}}
{{if $type_mvt != "retour"}}
{{:linkbutton
label="Dupliquer ce mouvement"
href="copy_movement.html?key=%s&prop=%s"|args:$_GET.key:$_GET.prop
shape="plus"
target="_dialog"}}
{{/if}}
</nav>
<dl class="describe">
<dt>Opération</dt>
<dd>{{$op_label}}</dd>
<dt>Matériel</dt>
<dd>{{$equipment.name}}</dd>
<dt>Catégorie</dt>
<dd>{{$category.name}}</dd>
<dt>Date</dt>
<dd>{{$mvt.date|date_short}}</dd>
<dt>Quantité</dt>
<dd>{{$mvt.amount}}</dd>
{{if $mvt.direction == "output" && $type_mvt != "retour"}}
<dt>Membre destinataire</dt>
<dd>
{{if $mvt.user != null}}
{{$user_name}}
{{else}}—
{{/if}}
</dd>
{{/if}}
{{if $mvt.direction == "input"}}
<dt>Lieu de stockage</dt>
<dd>
{{if $storage != null}}
{{$storage.name}}
{{else}}—
{{/if}}
</dd>
{{/if}}
<dt>Écritures liées</dt>
<dd>
{{#foreach from=$mvt.transactions item="trans"}}
{{:link class="num" href="!acc/transactions/details.php?id=%d"|args:$trans label=$trans}}
{{else}}—
{{/foreach}}
</dd>
<dt>Remarques</dt>
<dd>{{if $mvt.comment != null}}
{{$mvt.comment}}
{{else}}—
{{/if}}
</dd>
</dl>
<form method="post" action="">
{{:admin_files path=$_GET.key upload=true edit=true use_trash=false}}
</form>
{{:admin_footer}}

View file

@ -32,9 +32,9 @@
{{#select {{#select
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS exterieur json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS exterieur
FROM module_data_equipment AS mvt FROM {!$module.table} AS mvt
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.temp_key') LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key')
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE WHERE
json_extract(mvt.document, '$.operation') IN !op json_extract(mvt.document, '$.operation') IN !op
AND mvt.key = :mvt_key AND mvt.key = :mvt_key

View file

@ -30,97 +30,110 @@
{{/load}} {{/load}}
{{if $table_presente}} {{if $table_presente}}
{{* Matériels attribués temporairement *}}
{{* vérifier la présence des types d'entrées et de sorties requis *}} {{* 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"}} {{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 {{#select
json_extract(mvt.document, '$.direction') AS direction,
json_extract(mvt.document, '$.date') AS date,
eqpmt.key as eqpmt_key, eqpmt.key as eqpmt_key,
json_extract(eqpmt.document, '$.name') as eqpmt_name, json_extract(eqpmt.document, '$.name') AS eqpmt_name,
mvt.key AS mvt_key, json_extract(mvt.document, '$.amount') AS qte,
json_extract(mvt.document, '$.direction') as direction, json_extract(mvt.document, '$.operation') AS operation
json_extract(mvt.document, '$.operation') as operation, FROM {!$module.table} AS mvt
json_extract(mvt.document, '$.date') as date,
json_extract(mvt.document, '$.amount') as amount
FROM module_data_equipment AS mvt
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
INNER JOIN module_data_equipment AS eqpmt INNER JOIN {!$module.table} AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key
ON json_extract(mvt.document, '$.equipment') = eqpmt.key WHERE
WHERE users.id = :user users.id = :user
AND (json_extract(mvt.document, '$.operation') IN !output_types AND
OR json_extract(mvt.document, '$.operation') IN !input_types) json_extract(mvt.document, '$.type') = 'movement'
ORDER BY date 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 :user = $user.id
!output_types=$output_types.temporaire !output_types=$output_types.temporaire
!input_types=$input_types.retour !input_types=$input_types.retour
assign="temp_mat."
}} }}
{{/select}} {{if $premier}}
{{:assign premier=false}}
{{:assign total=0}}
{{:assign old_eqpmt_key=$eqpmt_key}}
{{:assign var="ligne.date" value=$date}}
{{:assign var="ligne.materiel" value=$eqpmt_name}}
{{/if}} {{/if}}
{{if $temp_mat|count != 0}} {{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 old_eqpmt_key=$eqpmt_key}}
{{:assign var="ligne.date" value=$date}}
{{:assign var="ligne.materiel" value=$eqpmt_name}}
{{/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> <h3 class="ruler">Matériels attribués temporairement</h3>
<table class="list"> <table class="list" id="liste_temporaires">
<thead> <thead>
<tr> <tr>
<td>Date</td> <th>Date</th>
<td>Opération</td> <th>Matériel</th>
<td>Matériel</td> <th>Quantité</th>
<td>Quantité</td>
<td>Total</td>
<td class="actions"></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#foreach from=$temp_mat}} {{#foreach from=$lignes}}
{{: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="total" from="reste.%s"|args:$eqpmt_key}}
{{if $total == null}}
{{:assign total=0}}
{{/if}}
{{if $direction == 'input' && $type_mvt == 'retour'}}
{{:assign var="reste.%s"|args:$eqpmt_key value="%d-%d"|math:$total:$amount}}
{{elseif $direction == 'output' && $type_mvt == 'temporaire'}}
{{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}}
{{/if}}
{{:assign var="total" from="reste.%s"|args:$eqpmt_key}}
<tr> <tr>
<td>{{$date|date_short}}</td> <td>{{$date|date_short}}</td>
<td>{{$op_label}}</td> <td>{{$materiel}}</td>
<td>{{$eqpmt_name}}</td> <td>{{$qte}}</td>
<td>{{$amount}}</td>
<td>{{$total}}</td>
<td class="actions">
{{if $direction == "output" && $type_mvt == "temporaire"}}
{{:linkbutton
label="Retour"
href="%smovements/output_return.html?key=%s&prop=0&user=%s"|args:$module.url:$mvt_key:$user.id
shape="history"
target="_dialog"}}
{{/if}}
</td>
</tr> </tr>
{{/foreach}} {{/foreach}}
</tbody> </tbody>
</table> </table>
{{/if}} {{/if}}
{{/if}}
{{* vérifier la présence des types d'entrées et de sorties requis *}} {{* Matériels attribués définitivement *}}
{{ if $output_types|has_key:"définitif"}} {{* vérifier la présence des types de sorties requis *}}
{{if $output_types|has_key:"définitif"}}
{{#select {{#select
eqpmt.key as eqpmt_key, eqpmt.key as eqpmt_key,
json_extract(eqpmt.document, '$.name') as eqpmt_name, json_extract(eqpmt.document, '$.name') as eqpmt_name,
json_extract(mvt.document, '$.direction') as direction, json_extract(mvt.document, '$.direction') as direction,
json_extract(mvt.document, '$.operation') as operation, json_extract(mvt.document, '$.operation') as operation,
json_extract(mvt.document, '$.date') as date, MIN(json_extract(mvt.document, '$.date')) as date,
json_extract(mvt.document, '$.amount') as amount SUM(json_extract(mvt.document, '$.amount')) as amount
FROM module_data_equipment AS mvt FROM {!$module.table} AS mvt
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
INNER JOIN module_data_equipment AS eqpmt INNER JOIN {!$module.table} AS eqpmt
ON json_extract(mvt.document, '$.equipment') = eqpmt.key ON json_extract(mvt.document, '$.equipment') = eqpmt.key
WHERE users.id = :user WHERE users.id = :user
AND json_extract(mvt.document, '$.operation') IN !output_types AND json_extract(mvt.document, '$.operation') IN !output_types
ORDER BY date DESC GROUP BY eqpmt_key, operation
ORDER BY eqpmt_name, date
; ;
:user = $user.id :user = $user.id
!output_types=$output_types.définitif !output_types=$output_types.définitif
@ -134,11 +147,11 @@
<table class="list"> <table class="list">
<thead> <thead>
<tr> <tr>
<td>Date</td> <th>Date</th>
<td>Opération</td> <th>Matériel</th>
<td>Matériel</td> <th>Opération</th>
<td>Quantité</td> <th>Quantité</th>
<td>Total</td> <th>Total</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -155,8 +168,8 @@
{{:assign var="total" from="reste.%s"|args:$eqpmt_key}} {{:assign var="total" from="reste.%s"|args:$eqpmt_key}}
<tr> <tr>
<td>{{$date|date_short}}</td> <td>{{$date|date_short}}</td>
<td>{{$op_label}}</td>
<td>{{$eqpmt_name}}</td> <td>{{$eqpmt_name}}</td>
<td>{{$op_label}}</td>
<td>{{$amount}}</td> <td>{{$amount}}</td>
<td>{{$total}}</td> <td>{{$total}}</td>
</tr> </tr>