Simplification calcul dispo et config par défaut
This commit is contained in:
parent
d7f7ec9423
commit
af9dbf2b22
|
@ -1,134 +1,112 @@
|
|||
{{*
|
||||
Calcul des entrées/sorties de matériels à une date donnée
|
||||
paramètres :
|
||||
- liste de catégories
|
||||
- liste de clés de catégories
|
||||
- date
|
||||
résultat : cumul_mvt
|
||||
*}}
|
||||
|
||||
{{* liste des catégories *}}
|
||||
{{if $categories === null}}
|
||||
{{if $category_keys === null}}
|
||||
{{#load type="category"}}
|
||||
{{:assign var="categories." value=$key}}
|
||||
{{:assign var="cumul_mvt.%s.name"|args:$key value=$name}}
|
||||
{{/load}}
|
||||
{{else}}
|
||||
{{#load type="category" where="key"|sql_where:'IN':$category_keys}}
|
||||
{{:assign var="cumul_mvt.%s.name"|args:$key value=$name}}
|
||||
{{/load}}
|
||||
{{/if}}
|
||||
|
||||
{{* date *}}
|
||||
{{if $date === null}}
|
||||
{{* :assign date=$now|date:"Y-m-d" *}}
|
||||
{{:assign date="31/12/9999"|parse_date}}
|
||||
{{* si on veut aussi lister les mouvements du futur :-) *}}
|
||||
{{/if}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="elem"}}
|
||||
{{:assign var="in_categories." value="'%s'"|args:$cat_key}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{#select
|
||||
json_extract(mvt.document, '$.date') as 'date',
|
||||
eqpmt.key as 'eqpmt_key',
|
||||
json_extract(eqpmt.document, '$.designation') as 'designation',
|
||||
cat.key as 'cat_key',
|
||||
json_extract(cat.document, '$.name') as 'category',
|
||||
mvt.key as 'mvt_key',
|
||||
json_extract(mvt.document, '$.direction') as 'direction',
|
||||
CASE json_extract(mvt.document, '$.direction')
|
||||
WHEN 'input' THEN json_extract(mvt.document, '$.input_nature')
|
||||
WHEN 'output' THEN json_extract(mvt.document, '$.output_nature')
|
||||
END
|
||||
AS 'operation',
|
||||
json_extract(mvt.document, '$.amount') AS 'nombre'
|
||||
FROM module_data_equipment as eqpmt
|
||||
INNER JOIN module_data_equipment as cat
|
||||
ON json_extract(eqpmt.document, '$.category') = cat.key
|
||||
INNER JOIN module_data_equipment as mvt
|
||||
ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||
WHERE json_extract(eqpmt.document, '$.type') = "equipment"
|
||||
AND !categories
|
||||
AND json_extract(mvt.document, '$.date') <= :date
|
||||
ORDER BY
|
||||
json_extract(cat.document, '$.name'),
|
||||
json_extract(eqpmt.document, '$.designation'),
|
||||
json_extract(mvt.document, '$.date');
|
||||
!categories='cat_key'|sql_where:'IN':$categories
|
||||
:date=$date
|
||||
}}
|
||||
{{:assign in_categories=$in_categories|implode:","}}
|
||||
{{:assign in_categories="("|cat:$in_categories|cat:")"}}
|
||||
|
||||
{{:assign
|
||||
var="equipments.%s.name"|args:$cat_key
|
||||
value=$category}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.designation"|args:$cat_key:$eqpmt_key
|
||||
value=$designation}}
|
||||
{{* liste des matériels dans les catégories passées en paramètre *}}
|
||||
{{#load type="equipment" where="$$.category IN %s"|args:$in_categories}}
|
||||
{{:assign var="equipments.%s.category"|args:$key value=$category}}
|
||||
{{:assign var="equipments.%s.designation"|args:$key value=$designation}}
|
||||
{{:assign var="in_equipments." value="'%s'"|args:$key}}
|
||||
{{/load}}
|
||||
{{:assign in_equipments=$in_equipments|implode:","}}
|
||||
{{:assign in_equipments="("|cat:$in_equipments|cat:")"}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
{{* parcourir les mouvements et cumuler les entrées/sorties *}}
|
||||
{{#load type="movement" where="$$.equipment IN %s"|args:$in_equipments assign="mvt"}}
|
||||
{{* matériel propriété de l'asso en stock *}}
|
||||
{{:assign
|
||||
var="stock"
|
||||
from="equipments.%s.eqpmt.%s.stock"|args:$cat_key:$eqpmt_key}}
|
||||
{{if $stock === null}}
|
||||
from="equipments.%s.stock"|args:$mvt.equipment}}
|
||||
{{if $stock == null}}
|
||||
{{:assign stock=0}}
|
||||
{{/if}}
|
||||
|
||||
{{* matériel propriété de l'asso à l'extérieur *}}
|
||||
{{:assign
|
||||
var="exterieur"
|
||||
from="equipments.%s.eqpmt.%s.exterieur"|args:$cat_key:$eqpmt_key}}
|
||||
{{if $exterieur === null}}
|
||||
from="equipments.%s.exterieur"|args:$mvt.equipment}}
|
||||
{{if $exterieur == null}}
|
||||
{{:assign exterieur=0}}
|
||||
{{/if}}
|
||||
|
||||
{{* matériel non propriété de l'asso *}}
|
||||
{{:assign
|
||||
var="nonproprio"
|
||||
from="equipments.%s.eqpmt.%s.nonproprio"|args:$cat_key:$eqpmt_key}}
|
||||
{{if $nonproprio === null}}
|
||||
from="equipments.%s.nonproprio"|args:$mvt.equipment}}
|
||||
{{if $nonproprio == null}}
|
||||
{{:assign nonproprio=0}}
|
||||
{{/if}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
{{* déterminer le type de mouvement *}}
|
||||
{{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
|
||||
|
||||
{{if $direction === 'input'}}
|
||||
{{* chercher le type d'entrée parmi les types de la config *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $operation == $elem.label}}
|
||||
{{if $elem.type == 'définitif'}}
|
||||
{{:assign stock="%d+%d"|math:$stock:$nombre}}
|
||||
{{if $mvt.direction === 'input'}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d+%d"|math:$stock:$mvt.amount}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.stock"|args:$cat_key:$eqpmt_key
|
||||
var="equipments.%s.stock"|args:$mvt.equipment
|
||||
from=stock}}
|
||||
{{elseif $elem.type == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$nombre}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$mvt.amount}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.exterieur"|args:$cat_key:$eqpmt_key
|
||||
var="equipments.%s.exterieur"|args:$mvt.equipment
|
||||
from=exterieur}}
|
||||
{{elseif $elem.type == 'temporaire'}}
|
||||
{{:assign nonproprio="%d+%d"|math:$nonproprio:$nombre}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign nonproprio="%d+%d"|math:$nonproprio:$mvt.amount}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.nonproprio"|args:$cat_key:$eqpmt_key
|
||||
var="equipments.%s.nonproprio"|args:$mvt.equipment
|
||||
from=nonproprio}}
|
||||
{{/if}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{elseif $direction === 'output'}}
|
||||
{{* chercher le type de sortie parmi les types de la config *}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $operation == $elem.label}}
|
||||
{{if $elem.type == 'définitif'}}
|
||||
{{:assign stock="%d-%d"|math:$stock:$nombre}}
|
||||
{{elseif $mvt.direction === 'output'}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d-%d"|math:$stock:$mvt.amount}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.stock"|args:$cat_key:$eqpmt_key
|
||||
var="equipments.%s.stock"|args:$mvt.equipment
|
||||
from=stock}}
|
||||
{{elseif $elem.type == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$nombre}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$mvt.amount}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.exterieur"|args:$cat_key:$eqpmt_key
|
||||
var="equipments.%s.exterieur"|args:$mvt.equipment
|
||||
from=exterieur}}
|
||||
{{elseif $elem.type == 'retour'}}
|
||||
{{:assign nonproprio="%d-%d"|math:$nonproprio:$nombre}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign nonproprio="%d-%d"|math:$nonproprio:$mvt.amount}}
|
||||
{{:assign
|
||||
var="equipments.%s.eqpmt.%s.nonproprio"|args:$cat_key:$eqpmt_key
|
||||
var="equipments.%s.nonproprio"|args:$mvt.equipment
|
||||
from=nonproprio}}
|
||||
{{/if}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{/load}}
|
||||
|
||||
{{* grouper les résultats par catégorie *}}
|
||||
{{#foreach from=$equipments key="eqpmt_key" item="eqpmt"}}
|
||||
{{:assign
|
||||
var="cumul_mvt.%s.eqpmt.%s"|args:$eqpmt.category:$eqpmt_key
|
||||
value=$eqpmt}}
|
||||
{{/foreach}}
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
{{* pas de config enregistrée : utiliser la config par défaut *}}
|
||||
{{#foreach from=$config_defaut.inputs item="elem"}}
|
||||
{{#foreach from=$elem key=label item=value}}
|
||||
{{:assign var="item.label" value=$label}}
|
||||
{{:assign var="item.type" value=$value}}
|
||||
{{:assign var="config.input_nature." value=$item}}
|
||||
{{:assign var="config.input_nature.%s"|args:$label value=$value}}
|
||||
{{/foreach}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
@ -26,9 +24,7 @@
|
|||
{{* pas de config enregistrée : utiliser la config par défaut *}}
|
||||
{{#foreach from=$config_defaut.outputs item="elem"}}
|
||||
{{#foreach from=$elem key=label item=value}}
|
||||
{{:assign var="item.label" value=$label}}
|
||||
{{:assign var="item.type" value=$value}}
|
||||
{{:assign var="config.output_nature." value=$item}}
|
||||
{{:assign var="config.output_nature.%s"|args:$label value=$value}}
|
||||
{{/foreach}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
|
|
@ -6,16 +6,12 @@
|
|||
|
||||
{{:admin_header title="Matériels de la catégorie « %s »"|args:$cat_name current="module_equipment"}}
|
||||
|
||||
{{if $_GET.dialog === null}}
|
||||
{{* barre de navigation *}}
|
||||
{{:include file="../_nav.html" current="categories"}}
|
||||
{{else}}
|
||||
<header class="header">
|
||||
<h1>Matériels de la catégorie « {{$cat_name}} »</h1>
|
||||
</header>
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="../_nav.html" current="entrees"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign var="categories." value=$_GET.key}}
|
||||
{{:assign var="category_keys." value=$_GET.key}}
|
||||
{{:include file="../inventaire.html"}}
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
{{/if}}
|
||||
|
||||
{{#load type="category"}}
|
||||
{{:assign var="categories." value=$key}}
|
||||
{{:assign var="category_keys." value=$key}}
|
||||
{{/load}}
|
||||
|
||||
{{if $categories|count == 0}}
|
||||
{{if $category_keys|count == 0}}
|
||||
<p class="block alert">Il n'y a aucune catégorie : vous devez en ajouter.</p>
|
||||
{{else}}
|
||||
{{:include file="./inventaire.html" print_cat_name=true}}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
{{* inventaire des entrées/sorties des matériels des catégories de la variable $categories *}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include file="./_calcul_dispo.html" keep="equipments"}}
|
||||
{{:include file="./_calcul_dispo.html" keep="cumul_mvt,categories"}}
|
||||
|
||||
{{* Afficher les résultats *}}
|
||||
{{if $equipments === null}}
|
||||
{{if $cumul_mvt === null}}
|
||||
{{if $categories|count == 1}}
|
||||
<p class="block alert">Il n'y a aucun matériel dans cette catégorie.</p>
|
||||
{{else}}
|
||||
|
@ -16,21 +16,21 @@
|
|||
<h2 class="ruler">Matériels dont l'association est propriétaire</h2>
|
||||
|
||||
{{* itérer sur les catégories *}}
|
||||
{{#foreach from=$equipments key="cat_key" item="category"}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
||||
|
||||
{{if $print_cat_name}}
|
||||
<h3>{{$cat_elem.name}}</h3>
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier s'il y a des matériels dans cette catégorie *}}
|
||||
{{:assign present=false}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{if $eqpmt.stock !== null && $eqpmt.stock !== 0}}
|
||||
{{:assign present=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $print_cat_name}}
|
||||
<h3>{{$category.name}}</h3>
|
||||
{{/if}}
|
||||
|
||||
{{if $present}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<tbody>
|
||||
|
||||
{{* itérer sur les matériels de la catégorie *}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
|
||||
{{:assign keys=$eqpmt|keys}}
|
||||
{{if "stock"|in:$keys && $eqpmt.stock !== 0}}
|
||||
|
@ -82,21 +82,21 @@
|
|||
<h2 class="ruler">Matériels dont l'association n'est pas propriétaire</h2>
|
||||
|
||||
{{* itérer sur les catégories *}}
|
||||
{{#foreach from=$equipments key="cat_key" item="category"}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
||||
|
||||
{{if $print_cat_name}}
|
||||
<h3>{{$cat_elem.name}}</h3>
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier s'il y a des matériels dans cette catégorie *}}
|
||||
{{:assign present=false}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{if $eqpmt.nonproprio !== null && $eqpmt.nonproprio !== 0}}
|
||||
{{:assign present=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $print_cat_name}}
|
||||
<h3>{{$category.name}}</h3>
|
||||
{{/if}}
|
||||
|
||||
{{if $present}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
@ -109,7 +109,7 @@
|
|||
<tbody>
|
||||
|
||||
{{* itérer sur les matériels de la catégorie *}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
|
||||
{{:assign keys=$eqpmt|keys}}
|
||||
{{if "nonproprio"|in:$keys && $eqpmt.nonproprio !== 0}}
|
||||
|
|
|
@ -29,34 +29,28 @@
|
|||
{{#load
|
||||
type="movement"
|
||||
where="$$.equipment = :key" :key=$key_eqpmt_suppr
|
||||
assign="movement"
|
||||
assign="mvt"
|
||||
order="$$.date"}}
|
||||
|
||||
{{* déterminer le type de mouvement *}}
|
||||
{{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
|
||||
|
||||
{{if $key != $_GET.key}}
|
||||
{{* ce n'est pas le mouvement à supprimer : cumuler les entrées/sorties *}}
|
||||
{{if $movement.direction == 'input'}}
|
||||
{{* chercher le type d'entrée parmi les types de la config *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $movement.input_nature == $elem.label}}
|
||||
{{if $elem.type == 'temporaire'}}
|
||||
{{:assign nonprop="%d+%d"|math:$nonprop:$movement.amount}}
|
||||
{{if $mvt.direction == 'input'}}
|
||||
{{if $type_mvt == 'temporaire'}}
|
||||
{{:assign nonprop="%d+%d"|math:$nonprop:$mvt.amount}}
|
||||
{{else}}
|
||||
{{:assign dispo="%d+%d"|math:$dispo:$movement.amount}}
|
||||
{{:assign dispo="%d+%d"|math:$dispo:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{elseif $movement.direction == 'output'}}
|
||||
{{* chercher le type de sortie parmi les types de la config *}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $movement.output_nature == $elem.label}}
|
||||
{{if $elem.type == 'retour'}}
|
||||
{{:assign nonprop="%d-%d"|math:$nonprop:$movement.amount}}
|
||||
{{elseif $mvt.direction == 'output'}}
|
||||
{{if $type_mvt == 'retour'}}
|
||||
{{:assign nonprop="%d-%d"|math:$nonprop:$mvt.amount}}
|
||||
{{else}}
|
||||
{{:assign dispo="%d-%d"|math:$dispo:$movement.amount}}
|
||||
{{:assign dispo="%d-%d"|math:$dispo:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
{{* problème ? *}}
|
||||
{{if $dispo < 0 || $nonprop < 0}}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
{{:include file="../../_get_config.html" keep="config"}}
|
||||
|
||||
{{* types d'entrées *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $elem.type != 'retour'}}
|
||||
{{:assign var='input_types.' value="%s"|args:$elem.label}}
|
||||
{{#foreach from=$config.input_nature key="label" item="type"}}
|
||||
{{if $type != 'retour'}}
|
||||
{{:assign var='input_labels.' value="%s"|args:$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
|
||||
{{* Enregistrer le mouvement *}}
|
||||
{{:assign mvt_key=""|uuid}}
|
||||
{{:assign var="operation" from="input_types.%d"|args:$_POST.type_operation}}
|
||||
{{:assign var="operation" from="input_labels.%d"|args:$_POST.type_operation}}
|
||||
|
||||
{{:save
|
||||
key=$mvt_key
|
||||
|
@ -64,7 +64,6 @@
|
|||
|
||||
{{* lister les catégories disponibles *}}
|
||||
{{#load type="category" assign="category" order="$$.name"}}
|
||||
{{* :assign var="categories.%d"|args:$category.id value=$category.name *}}
|
||||
{{:assign var="categories.%s"|args:$category.key value=$category.name}}
|
||||
{{/load}}
|
||||
|
||||
|
@ -74,7 +73,7 @@
|
|||
<fieldset class="entree">
|
||||
<legend>Ajouter une entrée d'un matériel non répertorié</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_types}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1}}
|
||||
</dl>
|
||||
|
|
|
@ -10,21 +10,22 @@
|
|||
{{:include file="../../_get_config.html" keep="config"}}
|
||||
|
||||
{{* types d'entrées *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $elem.type != 'retour'}}
|
||||
{{:assign var='input_types.' value="%s"|args:$elem.label}}
|
||||
{{#foreach from=$config.input_nature key="label" item="type"}}
|
||||
{{if $type != 'retour'}}
|
||||
{{:assign var='input_labels.' value="%s"|args:$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
|
||||
{{* récupérer les infos du matériel *}}
|
||||
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
||||
{{/load}}
|
||||
|
||||
{{* Enregistrer le mouvement *}}
|
||||
{{:assign mvt_key=""|uuid}}
|
||||
{{:assign var="operation" from="input_types.%d|args:$_POST.type_operation}}
|
||||
{{:assign var="operation" from="input_labels.%d|args:$_POST.type_operation}}
|
||||
|
||||
{{:save
|
||||
key=$mvt_key
|
||||
|
@ -60,7 +61,7 @@
|
|||
<fieldset class="entree">
|
||||
<legend>Ajouter une entrée d'un matériel répertorié</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_types}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1}}
|
||||
</dl>
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
{{:include file="../../_get_config.html" keep="config"}}
|
||||
|
||||
{{* types d'entrées *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $elem.type == 'retour'}}
|
||||
{{:assign var='input_types.' value="%s"|args:$elem.label}}
|
||||
{{#foreach from=$config.input_nature key="label" item="type"}}
|
||||
{{if $type == 'retour'}}
|
||||
{{:assign var='input_labels.' value="%s"|args:$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
|
@ -27,12 +27,12 @@
|
|||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include
|
||||
file="../../_calcul_dispo.html"
|
||||
keep="equipments"
|
||||
keep="cumul_mvt"
|
||||
date=$_POST.date|parse_date
|
||||
}}
|
||||
|
||||
{{* déterminer la quantité sortie temporairement de ce matriel à la date donnée *}}
|
||||
{{:assign var=sorti from="equipments.%s.eqpmt.%s.exterieur"|args:$equipment.category:$_POST.equipment}}
|
||||
{{:assign var=sorti from="cumul_mvt.%s.eqpmt.%s.exterieur"|args:$equipment.category:$_POST.equipment}}
|
||||
|
||||
{{if $_POST.quantite|intval > $sorti}}
|
||||
{{:error message="Erreur : la quantité indiquée (%s) est supérieure à celle sortie (%d) à la date du %s"|args:$_POST.quantite:$sorti:$_POST.date}}
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
{{* Enregistrer le mouvement *}}
|
||||
{{:assign mvt_key=""|uuid}}
|
||||
{{:assign var="operation" from="input_types.%d|args:$_POST.type_operation}}
|
||||
{{:assign var="operation" from="input_labels.%d|args:$_POST.type_operation}}
|
||||
|
||||
{{:save
|
||||
key=$mvt_key
|
||||
|
@ -60,17 +60,17 @@
|
|||
{{/form}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="equipments"}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="cumul_mvt"}}
|
||||
|
||||
{{if $equipments !== null}}
|
||||
{{if $cumul_mvt !== null}}
|
||||
|
||||
{{* déterminer la quantité des matériels sortis temporairement *}}
|
||||
{{#foreach from=$equipments key="cat_key" item="category"}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{:assign quantite=$eqpmt.exterieur}}
|
||||
{{if $quantite != 0}}
|
||||
{{:assign
|
||||
var="temporaire.%s.%s"|args:$category.name:$eqpmt_key
|
||||
var="temporaire.%s.%s"|args:$cat_elem.name:$eqpmt_key
|
||||
value="%s (quantité : %d)"|args:$eqpmt.designation:$quantite
|
||||
}}
|
||||
{{/if}}
|
||||
|
@ -84,7 +84,7 @@
|
|||
<fieldset class="entree">
|
||||
<legend>Ajouter une entrée pour un retour de matériel</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_types}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1}}
|
||||
</dl>
|
||||
|
|
|
@ -27,18 +27,18 @@
|
|||
|
||||
{{if $direction == "input"}}
|
||||
{{* types d'entrées *}}
|
||||
{{#foreach from=$config.input_nature key="rang" item="elem"}}
|
||||
{{:assign var='input_types.' value="%s"|args:$elem.label}}
|
||||
{{if $elem.label == $mvt_modif.input_nature}}
|
||||
{{:assign type_defaut=$rang}}
|
||||
{{#foreach from=$config.input_nature key="label" item="type"}}
|
||||
{{:assign var="input_labels.%s"|args:$label value="%s"|args:$label}}
|
||||
{{if $label == $mvt_modif.input_nature}}
|
||||
{{:assign type_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{else}}
|
||||
{{* types de sorties *}}
|
||||
{{#foreach from=$config.output_nature key="rang" item="elem"}}
|
||||
{{:assign var='types_sorties.' value="%s"|args:$elem.label}}
|
||||
{{if $elem.label == $mvt_modif.output_nature}}
|
||||
{{:assign type_defaut=$rang}}
|
||||
{{#foreach from=$config.output_nature key="label" item="type"}}
|
||||
{{:assign var="output_labels.%s"|args:$label value="%s"|args:$label}}
|
||||
{{if $label == $mvt_modif.output_nature}}
|
||||
{{:assign type_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
@ -55,9 +55,9 @@
|
|||
{{#form on="change"}}
|
||||
{{* préparer le mouvement modifié *}}
|
||||
{{if $direction == "input"}}
|
||||
{{:assign var="mvt_modif.input_nature" from="input_types.%d"|args:$_POST.type_operation}}
|
||||
{{:assign var="mvt_modif.input_nature" from="input_labels.%s"|args:$_POST.type_operation}}
|
||||
{{else}}
|
||||
{{:assign var="mvt_modif.output_nature" from="types_sorties.%d"|args:$_POST.type_operation}}
|
||||
{{:assign var="mvt_modif.output_nature" from="output_labels.%s"|args:$_POST.type_operation}}
|
||||
{{/if}}
|
||||
{{:assign var="mvt_modif.amount" value=$_POST.amount}}
|
||||
{{:assign var="mvt_modif.equipment" value=$_POST.equipment}}
|
||||
|
@ -160,11 +160,11 @@
|
|||
{{if $direction == "input"}}
|
||||
<legend>Modifier l'entrée « {{$input_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_types default=$type_defaut}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels default=$type_defaut}}
|
||||
{{else}}
|
||||
<legend>Modifier la sortie « {{$output_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$types_sorties default=$type_defaut}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels default=$type_defaut}}
|
||||
{{/if}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$mvt_modif.date}}
|
||||
{{:input type="number" name="amount" label="Quantité" required=true default=$mvt_modif.amount}}
|
||||
|
|
|
@ -23,12 +23,11 @@
|
|||
|
||||
{{* déterminer s'il s'agit d'une sortie temporaire *}}
|
||||
{{:assign temporaire=false}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $mvt_suppr.output_nature == $elem.label && $elem.type == 'temporaire'}}
|
||||
{{:assign var="output_nature" from="config.output_nature.%s"|args:$mvt_suppr.output_nature}}
|
||||
|
||||
{{if $output_nature == 'temporaire'}}
|
||||
{{:assign temporaire=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* dans le cas d'une sortie temporaire, vérifier s'il est possible de la supprimer *}}
|
||||
{{if $temporaire}}
|
||||
|
@ -36,32 +35,29 @@
|
|||
{{#load
|
||||
type="movement"
|
||||
where="$$.equipment = :key" :key=$key_eqpmt_suppr
|
||||
assign="movement"
|
||||
assign="mvt"
|
||||
order="$$.date"}}
|
||||
|
||||
{{* déterminer le type de mouvement *}}
|
||||
{{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
|
||||
|
||||
{{if $key != $_GET.key}}
|
||||
{{* ce n'est pas le mouvement à supprimer : cumuler les entrées/sorties *}}
|
||||
{{if $movement.direction == 'input'}}
|
||||
{{* chercher le type d'entrée parmi les types de la config *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $movement.input_nature == $elem.label && $elem.type == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$movement.amount}}
|
||||
{{if $mvt.direction == 'input'}}
|
||||
{{if $type_mvt == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{elseif $movement.direction == 'output'}}
|
||||
{{* chercher le type de sortie parmi les types de la config *}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $movement.output_nature == $elem.label && $elem.type == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$movement.amount}}
|
||||
{{elseif $mvt.direction == 'output'}}
|
||||
{{if $type_mvt == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
{{* problème ? *}}
|
||||
{{if $exterieur < 0}}
|
||||
{{:redirect force="./index.html?err=1&msg=suppression"}}
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{/if}}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
{{:include file="../../_get_config.html" keep="config"}}
|
||||
|
||||
{{* types de sorties *}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $elem.type == 'retour'}}
|
||||
{{:assign var='output_types.' value="%s"|args:$elem.label}}
|
||||
{{#foreach from=$config.output_nature key="label" item="type"}}
|
||||
{{if $type == 'retour'}}
|
||||
{{:assign var='output_labels.' value="%s"|args:$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
|
@ -21,18 +21,18 @@
|
|||
{{* récupérer les infos du matériel *}}
|
||||
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
||||
{{:assign designation=$equipment.designation}}
|
||||
{{:assign var="categories." value=$equipment.category}}
|
||||
{{:assign var="category_keys." value=$equipment.category}}
|
||||
{{/load}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include
|
||||
file="../../_calcul_dispo.html"
|
||||
keep="equipments"
|
||||
keep="cumul_mvt"
|
||||
date=$_POST.date|parse_date
|
||||
}}
|
||||
|
||||
{{* déterminer la quantité présente de ce matériel à la date donnée *}}
|
||||
{{:assign var=present from="equipments.%s.eqpmt.%s.nonproprio"|args:$equipment.category:$_POST.equipment}}
|
||||
{{:assign var=present from="cumul_mvt.%s.eqpmt.%s.nonproprio"|args:$equipment.category:$_POST.equipment}}
|
||||
|
||||
{{if $_POST.quantite|intval > $present}}
|
||||
{{:error message="Erreur : la quantité indiquée (%s) est supérieure à celle présente (%d) à la date du %s"|args:$_POST.quantite:$present:$_POST.date}}
|
||||
|
@ -41,7 +41,7 @@
|
|||
{{* Enregistrer le mouvement *}}
|
||||
|
||||
{{:assign mvt_key=""|uuid}}
|
||||
{{:assign var="operation" from="output_types.%d|args:$_POST.type_operation}}
|
||||
{{:assign var="operation" from="output_labels.%d|args:$_POST.type_operation}}
|
||||
{{:save
|
||||
key=$mvt_key
|
||||
validate_schema="../movement.schema.json"
|
||||
|
@ -59,16 +59,16 @@
|
|||
{{/form}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="equipments"}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="cumul_mvt"}}
|
||||
|
||||
{{if $equipments !== null}}
|
||||
{{if $cumul_mvt !== null}}
|
||||
{{* calculer les quantité de matériels dont l'asso n'est pas propriétaire *}}
|
||||
{{#foreach from=$equipments key="cat_key" item="category"}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{:assign quantite="%d-%d"|math:$eqpmt.nonproprio:$eqpmt.retour}}
|
||||
{{if $quantite != 0}}
|
||||
{{:assign
|
||||
var="temporaire.%s.%s"|args:$category.name:$eqpmt_key
|
||||
var="temporaire.%s.%s"|args:$cat_elem.name:$eqpmt_key
|
||||
value="%s (quantité : %d)"|args:$eqpmt.designation:$quantite
|
||||
}}
|
||||
{{/if}}
|
||||
|
@ -81,7 +81,7 @@
|
|||
<fieldset class="sortie">
|
||||
<legend>Ajouter une sortie d'un matériel disponible en stock</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_types}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels}}
|
||||
{{:input type="date" name="date" label="Date de sortie" required=true default=$now|date_short}}
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
||||
</dl>
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
{{:include file="../../_get_config.html" keep="config"}}
|
||||
|
||||
{{* types de sorties *}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $elem.type != 'retour'}}
|
||||
{{:assign var='output_types.' value="%s"|args:$elem.label}}
|
||||
{{#foreach from=$config.output_nature key="label" item="type"}}
|
||||
{{if $type != 'retour'}}
|
||||
{{:assign var='output_labels.' value="%s"|args:$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
|
@ -21,19 +21,19 @@
|
|||
{{* récupérer les infos du matériel *}}
|
||||
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
||||
{{:assign designation=$equipment.designation}}
|
||||
{{:assign var="categories." value=$equipment.category}}
|
||||
{{:assign var="category_keys." value=$equipment.category}}
|
||||
{{/load}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include
|
||||
file="../../_calcul_dispo.html"
|
||||
keep="equipments"
|
||||
keep="cumul_mvt"
|
||||
date=$_POST.date|parse_date
|
||||
}}
|
||||
|
||||
{{* déterminer la quantité disponible de ce matériel à la date donnée *}}
|
||||
{{:assign var=stock from="equipments.%s.eqpmt.%s.stock"|args:$equipment.category:$_POST.equipment}}
|
||||
{{:assign var=exterieur from="equipments.%s.eqpmt.%s.exterieur"|args:$equipment.category:$_POST.equipment}}
|
||||
{{:assign var=stock from="cumul_mvt.%s.eqpmt.%s.stock"|args:$equipment.category:$_POST.equipment}}
|
||||
{{:assign var=exterieur from="cumul_mvt.%s.eqpmt.%s.exterieur"|args:$equipment.category:$_POST.equipment}}
|
||||
{{:assign dispo="%d-%d"|math:$stock:$exterieur}}
|
||||
|
||||
{{if $_POST.quantite|intval > $dispo}}
|
||||
|
@ -43,7 +43,7 @@
|
|||
{{* Enregistrer le mouvement *}}
|
||||
|
||||
{{:assign mvt_key=""|uuid}}
|
||||
{{:assign var="operation" from="output_types.%d|args:$_POST.type_operation}}
|
||||
{{:assign var="operation" from="output_labels.%d|args:$_POST.type_operation}}
|
||||
{{:save
|
||||
key=$mvt_key
|
||||
validate_schema="../movement.schema.json"
|
||||
|
@ -61,17 +61,19 @@
|
|||
{{/form}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="equipments"}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="cumul_mvt"}}
|
||||
|
||||
{{if $equipments !== null}}
|
||||
{{if $cumul_mvt !== null}}
|
||||
{{* calculer les disponibilités *}}
|
||||
{{#foreach from=$equipments key="cat_key" item="category"}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{:assign dispo="%d-%d"|math:$eqpmt.stock:$eqpmt.exterieur}}
|
||||
{{if $dispo != 0}}
|
||||
{{:assign
|
||||
var="disponibilites.%s.%s"|args:$category.name:$eqpmt_key
|
||||
var="disponibilites.%s.%s"|args:$cat_elem.name:$eqpmt_key
|
||||
value="%s (dispo : %d)"|args:$eqpmt.designation:$dispo
|
||||
}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/foreach}}
|
||||
{{if $disponibilites === null}}
|
||||
|
@ -83,7 +85,7 @@
|
|||
<fieldset class="sortie">
|
||||
<legend>Ajouter une sortie d'un matériel disponible en stock</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_types}}
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels}}
|
||||
{{:input type="date" name="date" label="Date de sortie" required=true default=$now|date_short}}
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
||||
</dl>
|
||||
|
|
|
@ -12,34 +12,28 @@
|
|||
{{:assign stock=0}}
|
||||
{{:assign exterieur=0}}
|
||||
{{:assign nonprop=0}}
|
||||
{{#foreach from=$movements item="movement"}}
|
||||
{{if $movement.equipment == $eqpmt_key}}
|
||||
{{if $movement.direction == 'input'}}
|
||||
{{* chercher le type d'entrée parmi les types de la config *}}
|
||||
{{#foreach from=$config.input_nature item="elem"}}
|
||||
{{if $movement.input_nature == $elem.label}}
|
||||
{{if $elem.type == 'définitif'}}
|
||||
{{:assign stock="%d+%d"|math:$stock:$movement.amount}}
|
||||
{{elseif $elem.type == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$movement.amount}}
|
||||
{{elseif $elem.type == 'temporaire'}}
|
||||
{{:assign nonprop="%d+%d"|math:$nonprop:$movement.amount}}
|
||||
{{#foreach from=$movements item="mvt"}}
|
||||
{{* déterminer le type de mouvement *}}
|
||||
{{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
|
||||
|
||||
{{if $mvt.equipment == $eqpmt_key}}
|
||||
{{if $mvt.direction == 'input'}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d+%d"|math:$stock:$mvt.amount}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$mvt.amount}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign nonprop="%d+%d"|math:$nonprop:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{elseif $mvt.direction == 'output'}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d-%d"|math:$stock:$mvt.amount}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$mvt.amount}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign nonprop="%d-%d"|math:$nonprop:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{elseif $movement.direction == 'output'}}
|
||||
{{* chercher le type de sortie parmi les types de la config *}}
|
||||
{{#foreach from=$config.output_nature item="elem"}}
|
||||
{{if $movement.output_nature == $elem.label}}
|
||||
{{if $elem.type == 'définitif'}}
|
||||
{{:assign stock="%d-%d"|math:$stock:$movement.amount}}
|
||||
{{elseif $elem.type == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$movement.amount}}
|
||||
{{elseif $elem.type == 'retour'}}
|
||||
{{:assign nonprop="%d-%d"|math:$nonprop:$movement.amount}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
{{:assign dispo="%d-%d"|math:$stock:$exterieur}}
|
||||
{{if $dispo < 0 || $stock < 0 || $exterieur < 0 || $nonprop < 0}}
|
||||
|
|
Loading…
Reference in New Issue