Compare commits

..

No commits in common. "main" and "v0.47" have entirely different histories.
main ... v0.47

10 changed files with 283 additions and 356 deletions

View File

@ -15,6 +15,7 @@
<li {{if $current == 'inventaire'}} class="current"{{/if}}><a href="{{$module.url}}index.html?prop=1">Inventaire</a></li>
<li {{if $current == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}global_history.html">Historique</a></li>
<li {{if $current == 'archives'}} class="current"{{/if}}><a href="{{$module.url}}archives.html">Archives</a></li>
<li {{if $current == 'storage'}} class="current"{{/if}}><a href="{{$module.url}}storage/index.html">Stockage</a></li>
<li {{if $current == 'config'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Configuration</a></li>
</ul>
@ -35,24 +36,23 @@
<li class="title"><strong>Historique — {{$eqpmt}} ({{$category}})</strong></li>
</ul>
{{/if}}
{{elseif $current == 'storage'}}
<aside>
{{:linkbutton label="Ajouter un lieu de stockage" shape="plus" href="add_storage.html" target="_dialog"}}
</aside>
{{elseif $current == 'config'}}
{{if $subcurrent == 'categories'}}
<aside>
{{:linkbutton label="Ajouter une catégorie" shape="plus" href="add_category.html" target="_dialog"}}
</aside>
{{elseif $subcurrent == 'storage'}}
<aside>
{{:linkbutton label="Ajouter un lieu de stockage" shape="plus" href="add_storage.html" target="_dialog"}}
</aside>
{{elseif $subcurrent == 'typesES'}}
<aside>
{{:linkbutton label="Ajouter un type d'entrée" shape="plus" href="config/ajouter_type_mouvement.html?dir=input" target="_dialog"}}
{{:linkbutton label="Ajouter un type de sortie" shape="plus" href="config/ajouter_type_mouvement.html?dir=output" target="_dialog"}}
</aside>
{{/if}}
<ul class="sub">
<ul class="sub" >
<li {{if $subcurrent == 'categories'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Catégories</a></li>
<li {{if $subcurrent == 'storage'}} class="current"{{/if}}><a href="{{$module.url}}storage/index.html">Lieux de stockage</a></li>
<li {{if $subcurrent == 'typesES'}} class="current"{{/if}}><a href="{{$module.url}}config.html">Types d'entrées/sorties</a></li>
</ul>
{{/if}}

View File

@ -32,21 +32,10 @@
}}
</fieldset>
{{* condition de filtrage *}}
{{if $_GET.cat_key != null}}
{{:assign condition="(SELECT key
FROM @TABLE AS cat
WHERE cat.key = (SELECT $$.category
FROM @TABLE AS mat
WHERE mat.key = @TABLE.$$.equipment)) = '%s'"|args:$_GET.cat_key}}
{{else}}
{{:assign condition=1}}
{{/if}}
{{* lister tous les mouvements *}}
{{#list
type="movement"
select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
select="$$.date AS 'Date';
CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement';
$$.operation AS 'Opération';
(SELECT $$.name
@ -63,11 +52,17 @@
END as 'Stockage';
$$.comment AS 'Commentaire'
"|args:$config.user_fields.name_sql
where="%s"|args:$condition
order=1
max=50
desc=true
}}
{{* filtrer selon la catégorie *}}
{{#load key=$equipment}}
{{:assign cat_key=$category}}
{{/load}}
{{if $_GET.cat_key != null && $cat_key != $_GET.cat_key}}
{{:continue}}
{{/if}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
<tr>
<td>{{$date|date_short}}</td>

View File

@ -164,23 +164,22 @@
{{#list
type="movement"
select="
($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
select="$$.date AS 'Date';
CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement';
$$.operation AS 'Opération';
$$.amount AS 'Quantité';
'' AS 'Stock';
'' AS 'Sorti';
'' AS 'Disponible';
"" as 'Stock';
"" as 'Sorti';
"" as 'Disponible';
CASE WHEN $$.user NOT NULL
THEN (SELECT %s AS nom FROM users WHERE id = $$.user)
ELSE ''
END AS 'Dépositaire';
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'
END as 'Stockage';
$$.comment AS 'Commentaire'
"|args:$config.user_fields.name_sql
equipment=$equipment_key
order=1
@ -217,15 +216,11 @@
target="_dialog"}}
{{/if}}
{{/if}}
{{if $direction == "input" && $type_mvt == "retour"}}
{{* interdire dupliquer *}}
{{else}}
{{:linkbutton
label="Dupliquer"
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="plus"
target="_dialog"}}
{{/if}}
label="Dupliquer"
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="plus"
target="_dialog"}}
{{:linkbutton
label="Modifier"
href="mouvements/modifier_mouvement.html?key=%s"|args:$key
@ -236,7 +231,7 @@
href="mouvements/supprimer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop
shape="delete"
target="_dialog"}}
{{/if}}
{{/if}}
</td>
</tr>
{{/if}}
@ -271,7 +266,7 @@
{{#list
type="movement"
select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
select="$$.date AS 'Date';
CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement';
$$.operation AS 'Opération';
$$.amount AS 'Quantité';

View File

@ -75,14 +75,12 @@
{{:error message="Impossible de saisir une date dans le futur (%s)"|args:$_POST.date}}
{{/if}}
{{if $mvt_new.direction == "input" && $_POST.user != null}}
{{if $mvt_new.direction != "output" && $_POST.user != null}}
{{:error message="Un membre ne peut être associé qu'à une sortie"}}
{{/if}}
{{if $_POST.user|count > 1}}
{{:error message="Un membre au plus peut être associé à une sortie"}}
{{/if}}
{{#foreach from=$_POST.user key="id" item="name"}}
{{:assign var="user.id" value=$id}}
{{:assign var="user.name" value=$name}}
@ -117,13 +115,8 @@
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
{{elseif $mvt_new.direction == "output" && $type_mvt == "temporaire"}}
{{if $movement.direction == "input"}}
{{:assign var="type_mvt_crt" from="config.input_nature.%s.type"|args::$movement.operation}}
{{if $type_mvt_crt == "retour"}}
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
{{/if}}
{{/if}}
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
{{/if}}
{{/if}}
{{/if}}
@ -141,58 +134,59 @@
}}
{{if $erreur}}
{{:assign var="mvt_label" from="%s_labels.%s"|args:$mvt_new.direction:$mvt_new.operation}}
{{:assign new_date=$mvt_new.date|date_short}}
{{:error message="Impossible d'enregistrer ce mouvement : « %s de %s (qté : %s) à la date du %s »"|args:$mvt_label:$equipment.name:$mvt_new.amount:$new_date}}
{{/if}}
{{* calculer la nouvelle quantité du matériel *}}
{{if $mvt_new.direction == "input"}}
{{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$_POST.operation}}
{{if $type_mvt == 'définitif'}}
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$_POST.amount|intval}}
{{elseif $type_mvt == 'temporaire'}}
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$_POST.amount|intval}}
{{elseif $type_mvt == 'retour'}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$_POST.amount|intval}}
{{/if}}
<p class="block error">
Impossible d'enregistrer ce mouvement : « {{$mvt_label}}
de {{$equipment.name}} (qté : {{$mvt_new.amount}}) à la date du {{$mvt_new.date|date_short}} »
</p>
{{else}}
{{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$_POST.operation}}
{{if $type_mvt == 'définitif'}}
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$_POST.amount|intval}}
{{elseif $type_mvt == 'temporaire'}}
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$_POST.amount|intval}}
{{elseif $type_mvt == 'retour'}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$_POST.amount|intval}}
{{* calculer la nouvelle quantité du matériel *}}
{{if $mvt_new.direction == "input"}}
{{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$_POST.operation}}
{{if $type_mvt == 'définitif'}}
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$_POST.amount|intval}}
{{elseif $type_mvt == 'temporaire'}}
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$_POST.amount|intval}}
{{elseif $type_mvt == 'retour'}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$_POST.amount|intval}}
{{/if}}
{{else}}
{{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$_POST.operation}}
{{if $type_mvt == 'définitif'}}
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$_POST.amount|intval}}
{{elseif $type_mvt == 'temporaire'}}
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$_POST.amount|intval}}
{{elseif $type_mvt == 'retour'}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$_POST.amount|intval}}
{{/if}}
{{/if}}
{{/if}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* vérification réussie : enregistrer le nouveau mouvement *}}
{{:assign mvt_key=""|uuid}}
{{:save
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction=$mvt_new.direction
operation=$_POST.operation
amount=$mvt_new.amount|intval
equipment=$eqpmt_key
date=$mvt_new.date
comment=$mvt_new.comment
user=$user.id
storage=$_POST.storage
}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* vérification réussie : enregistrer le mouvement modifié *}}
{{:assign mvt_key=""|uuid}}
{{:save
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction=$mvt_new.direction
operation=$_POST.operation
amount=$mvt_new.amount|intval
equipment=$eqpmt_key
date=$mvt_new.date
comment=$mvt_new.comment
user=$user.id
}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
{{/if}}
{{/form}}
{{:admin_header title="Dupliquer un mouvement" current="module_equipment"}}

View File

@ -3,7 +3,7 @@
{{*
Enregistrer un retour d'entrée temporaire
paramètres :
- key : clé de l'entrée temporaire
- key : clé du mouvement
*}}
{{* infos du mouvement *}}
@ -65,7 +65,7 @@
{{* préparer le nouveau mouvement *}}
{{:assign var="mvt_new.key" value=""|uuid}}
{{:assign var="mvt_new.direction" value="output"}}
{{:assign var="mvt_new.direction" value="input"}}
{{:assign var="mvt_new.date" value=$_POST.date|parse_date}}
{{:assign var="mvt_new.operation" value=$_POST.operation}}
{{:assign var="mvt_new.amount" value=$_POST.amount}}
@ -111,57 +111,56 @@
keep="erreur, pb"
movements=$movements_new
}}
{{if $erreur}}
{{:assign message="Impossible d'enregistrer ce mouvement."}}
{{if $pb.mvt.key != $mvt_new.key}}
{{:assign var="err_mvt_label" from="config.output_nature.%s.label"|args:$pb.mvt.operation}}
{{:assign date_pb=$pb.mvt.date|date_short}}
{{:assign var=message2 value=" Mouvement incompatible avec « %s » : « %s (qté : %s) en date du %s »."|args:$err_mvt_label:$equipment.name:$pb.mvt.amount:$date_pb}}
{{:assign message=$message|cat:$message2}}
{{/if}}
{{:error message=$message}}
<p class="block error">Impossible d'enregistrer ce mouvement.
{{if $pb.mvt.key != $mvt_new.key}}
{{:assign var="err_mvt_label" from="config.input_nature.%s.label"|args:$pb.mvt.operation}}
<br />Mouvement incompatible avec
« {{$err_mvt_label}} » : « {{$equipment.name}} (qté : {{$pb.mvt.amount}})
en date du {{$pb.mvt.date|date_short}} ».
{{/if}}
</p>
{{else}}
{{* calculer la nouvelle quantité du matériel *}}
{{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$_POST.operation}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$_POST.amount|intval}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* vérification réussie : enregistrer le mouvement modifié *}}
{{:assign mvt_key=""|uuid}}
{{:save
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction="output"
operation=$_POST.operation
amount=$_POST.amount|intval
equipment=$equipment.key
date=$_POST.date|parse_date
comment=$_POST.comment|trim
}}
{{* enregistrer la liaison entre le retour et la sortie temporaire *}}
{{:save
key=""|uuid
validate_schema="link.schema.json"
type="link"
direction="input"
temp_key=$_GET.key
return=$mvt_key
}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=0&msg=retour"|args:$mvt_new.equipment}}
{{/if}}
{{* calculer la nouvelle quantité du matériel *}}
{{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$_POST.operation}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$_POST.amount|intval}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* vérification réussie : enregistrer le mouvement modifié *}}
{{:assign mvt_key=""|uuid}}
{{:save
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction="output"
operation=$_POST.operation
amount=$_POST.amount|intval
equipment=$equipment.key
date=$_POST.date|parse_date
comment=$_POST.comment|trim
}}
{{* enregistrer la liaison entre le retour et la sortie temporaire *}}
{{:save
key=""|uuid
validate_schema="link.schema.json"
type="link"
direction="input"
temp_key=$_GET.key
return=$mvt_key
}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=0&msg=retour"|args:$mvt_new.equipment}}
{{/form}}
{{:admin_header title="Retour de matériel" custom_css="./../../style.css" current="module_equipment"}}

View File

@ -15,7 +15,6 @@
{{* 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_new.direction:$mvt_new.operation}}
{{if $mvt_new.direction == "input"}}
{{if $type_mvt == "temporaire"}}
{{:assign prop=0}}
@ -88,6 +87,7 @@
- insérer le mvt modifié à sa place par date croissante
*}}
{{:assign insere=false}}
{{:assign entree_def=false}}
{{#load
where="
$$.type = 'movement'
@ -107,13 +107,8 @@
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
{{elseif $mvt_new.direction == "output" && $type_mvt == "temporaire"}}
{{if $movement.direction == "input"}}
{{:assign var="type_mvt_crt" from="config.input_nature.%s.type"|args::$movement.operation}}
{{if $type_mvt_crt == "retour"}}
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
{{/if}}
{{/if}}
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
{{/if}}
{{/if}}
{{/if}}
@ -133,100 +128,103 @@
{{if $erreur}}
{{:assign var="new_op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}}
{{:assign new_date=$mvt_new.date|date_short}}
{{:error message="Modification impossible : « %s de %s (qté : %s) en date du %s » vers « %s de %s (qté : %s) à la date du %s »"|args:$op_label:$equipment.name:$amount_init:$date_init:$new_op_label:$equipment.name:$mvt_new.amount:$new_date}}
{{/if}}
{{* calculer la nouvelle quantité du matériel *}}
{{:assign var="type_mvt_init" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$operation_init}}
{{:assign var="type_mvt_final" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}}
{{if $mvt_new.direction == 'input'}}
{{if $type_mvt_init == 'définitif'}}
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$amount_init}}
{{elseif $type_mvt_init == 'temporaire'}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$amount_init}}
{{elseif $type_mvt_init == 'retour'}}
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$amount_init}}
{{/if}}
{{if $type_mvt_final == 'définitif'}}
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'temporaire'}}
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'retour'}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$mvt_new.amount|intval}}
{{/if}}
<p class="block error">
Modification demandée impossible :
« {{$op_label}} de {{$equipment.name}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
« {{$new_op_label}}
de {{$equipment.name}} (qté : {{$mvt_new.amount}}) à la date du {{$mvt_new.date|date_short}} »
</p>
{{else}}
{{if $type_mvt_init == 'définitif'}}
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$amount_init}}
{{elseif $type_mvt_init == 'temporaire'}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$amount_init}}
{{elseif $type_mvt_init == 'retour'}}
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$amount_init}}
{{/if}}
{{* calculer la nouvelle quantité du matériel *}}
{{:assign var="type_mvt_init" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$operation_init}}
{{:assign var="type_mvt_final" from="config.%s_nature.%s.type"|args:$mvt_new.direction:$mvt_new.operation}}
{{if $type_mvt_final == 'définitif'}}
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'temporaire'}}
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'retour'}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$mvt_new.amount|intval}}
{{/if}}
{{/if}}
{{if $equipment.stock == 0}}
{{* vérifier s'il y a au moins une entrée définitive *}}
{{:assign entree_def=false}}
{{#foreach from=$config.input_nature key=key}}
{{if $type == 'définitif'}}
{{:assign var="input_types." value=$key}}
{{if $mvt_new.direction == 'input'}}
{{if $type_mvt_init == 'définitif'}}
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$amount_init}}
{{elseif $type_mvt_init == 'temporaire'}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$amount_init}}
{{elseif $type_mvt_init == 'retour'}}
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$amount_init}}
{{/if}}
{{/foreach}}
{{#foreach from=$movements_new}}
{{if $operation|in:$input_types}}
{{:assign entree_def=true}}
{{:break}}
{{if $type_mvt_final == 'définitif'}}
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'temporaire'}}
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'retour'}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$mvt_new.amount|intval}}
{{/if}}
{{else}}
{{if $type_mvt_init == 'définitif'}}
{{:assign var="equipment.stock" value="%d+%d"|math:$equipment.stock:$amount_init}}
{{elseif $type_mvt_init == 'temporaire'}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$amount_init}}
{{elseif $type_mvt_init == 'retour'}}
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$amount_init}}
{{/if}}
{{if $type_mvt_final == 'définitif'}}
{{:assign var="equipment.stock" value="%d-%d"|math:$equipment.stock:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'temporaire'}}
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$mvt_new.amount|intval}}
{{elseif $type_mvt_final == 'retour'}}
{{:assign var="equipment.notowned" value="%d-%d"|math:$equipment.notowned:$mvt_new.amount|intval}}
{{/if}}
{{/foreach}}
{{if ! $entree_def}}
{{:assign var="equipment.stock" value=null}}
{{/if}}
{{if $equipment.stock == 0}}
{{* vérifier s'il y a au moins une entrée définitive *}}
{{#foreach from=$config.input_nature key=key}}
{{if $type == 'définitif'}}
{{:assign var="input_types." value=$key}}
{{/if}}
{{/foreach}}
{{#foreach from=$movements_new}}
{{if $operation|in:$input_types}}
{{:assign entree_def=true}}
{{:break}}
{{/if}}
{{/foreach}}
{{if ! $entree_def}}
{{:assign var="equipment.stock" value=null}}
{{/if}}
{{/if}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* enregistrer le mouvement modifié *}}
{{if $user == null}}
{{:assign user_id=$mvt_new.user}}
{{else}}
{{:assign user_id=$user.id}}
{{/if}}
{{:save
key=$_GET.key
validate_schema="movement.schema.json"
type="movement"
direction=$mvt_new.direction
operation=$_POST.operation
amount=$mvt_new.amount|intval
equipment=$eqpmt_key
date=$mvt_new.date
comment=$mvt_new.comment
user=$user_id
storage=$_POST.storage
}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}}
{{/if}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* enregistrer le mouvement modifié *}}
{{if $user == null}}
{{:assign user_id=$mvt_new.user}}
{{else}}
{{:assign user_id=$user.id}}
{{/if}}
{{:save
key=$_GET.key
validate_schema="movement.schema.json"
type="movement"
direction=$mvt_new.direction
operation=$_POST.operation
amount=$mvt_new.amount|intval
equipment=$eqpmt_key
date=$mvt_new.date
comment=$mvt_new.comment
user=$user_id
storage=$_POST.storage
}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}}
{{/form}}
{{:admin_header title="Modifier un mouvement" current="module_equipment"}}

View File

@ -21,7 +21,7 @@
{{* récupérer la config des entrées/sorties *}}
{{:include file="../_get_config.html" keep="config"}}
{{* calculer la quantité sortie temporairement *}}
{{* calculer la quantité sortie *}}
{{#foreach from=$config.output_nature key=key}}
{{if $type == "temporaire"}}
{{:assign var="temp_outputs." value=$key|quote_sql}}
@ -112,59 +112,59 @@
movements=$movements_new
}}
{{if $erreur}}
{{:assign message="Impossible d'enregistrer ce mouvement."}}
{{if $pb.mvt.key != $mvt_new.key}}
{{:assign var="err_mvt_label" from="config.input_nature.%s.label"|args:$pb.mvt.operation}}
{{:assign date_pb=$pb.mvt.date|date_short}}
{{:assign var=message2 value=" Mouvement incompatible avec « %s » : « %s (qté : %s) en date du %s »."|args:$err_mvt_label:$equipment.name:$pb.mvt.amount:$date_pb}}
{{:assign message=$message|cat:$message2}}
{{/if}}
{{:error message=$message}}
{{/if}}
{{* calculer la nouvelle quantité du matériel *}}
{{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$_POST.operation}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$_POST.amount|intval}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* enregistrer le mouvement modifié *}}
{{:assign mvt_key=""|uuid}}
{{:save
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction="input"
operation=$_POST.operation
amount=$_POST.amount|intval
equipment=$equipment.key
date=$_POST.date|parse_date
comment=$_POST.comment|trim
user=$mvt_new.user
}}
{{* enregistrer la liaison entre le retour et la sortie temporaire *}}
{{:save
key=""|uuid
validate_schema="link.schema.json"
type="link"
direction="output"
temp_key=$_GET.key
return=$mvt_key
}}
{{if $_GET.user == null}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=1&msg=retour"|args:$mvt_new.equipment}}
<p class="block error">Impossible d'enregistrer ce mouvement.
{{if $pb.mvt.key != $mvt_new.key}}
{{:assign var="err_mvt_label" from="config.input_nature.%s.label"|args:$pb.mvt.operation}}
<br />Mouvement incompatible avec
« {{$err_mvt_label}} » : « {{$equipment.name}} (qté : {{$pb.mvt.amount}})
en date du {{$pb.mvt.date|date_short}} ».
{{/if}}
</p>
{{else}}
{{:redirect force="/admin/users/details.php?id=%s"|args:$_GET.user}}
{{* calculer la nouvelle quantité du matériel *}}
{{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$_POST.operation}}
{{:assign var="equipment.out" value="%d-%d"|math:$equipment.out:$_POST.amount|intval}}
{{:save
key=$equipment.key
validate_schema="../equipment.schema.json"
type="equipment"
category=$equipment.category
name=$equipment.name
status="available"
stock=$equipment.stock
out=$equipment.out
notowned=$equipment.notowned
}}
{{* enregistrer le mouvement modifié *}}
{{:assign mvt_key=""|uuid}}
{{:save
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction="input"
operation=$_POST.operation
amount=$_POST.amount|intval
equipment=$equipment.key
date=$_POST.date|parse_date
comment=$_POST.comment|trim
user=$mvt_new.user
}}
{{* enregistrer la liaison entre le retour et la sortie temporaire *}}
{{:save
key=""|uuid
validate_schema="link.schema.json"
type="link"
direction="output"
temp_key=$_GET.key
return=$mvt_key
}}
{{if $_GET.user == null}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=1&msg=retour"|args:$mvt_new.equipment}}
{{else}}
{{:redirect force="/admin/users/details.php?id=%s"|args:$_GET.user}}
{{/if}}
{{/if}}
{{/form}}

View File

@ -8,7 +8,7 @@
{{if $_POST.name == null}}
{{:error message="Le nom du lieu de stockage est obligatoire"}}
{{/if}}
{{#load type="storage" where="$$.name = :name" :name=$_POST.name|trim limit=1}}
{{#load type="storage" where="$$.name = :name COLLATE U_NOCASE" :name=$_POST.name|trim limit=1}}
{{:error message="Ce nom est déjà utilisé"}}
{{/load}}
@ -16,8 +16,8 @@
key=""|uuid
validate_schema="storage.schema.json"
type="storage"
name=$_POST.name|trim
location=$_POST.location|trim
name=$_POST.name|tolower|ucwords
location=$_POST.location
}}
{{:redirect force="index.html?ok=1&msg=ajout"}}
{{/form}}

View File

@ -4,9 +4,9 @@
Afficher les lieux de stockage
*}}
{{:admin_header title="Configuration" current="module_equipment"}}
{{:admin_header title="Lieux de stockage" custom_css="./style.css" current="module_equipment"}}
{{:include file="../_nav.html" current="config" subcurrent="storage"}}
{{:include file="../_nav.html" current="storage"}}
{{if $_GET.ok}}
{{if $_GET.msg == "ajout"}}
@ -33,7 +33,6 @@
<td>{{$name}}</td>
<td>{{$location}}</td>
<td class="actions">
{{:linkbutton label="Modifier" shape="edit" href="modify_storage.html?key=%s"|args:$key target="_dialog"}}
{{:linkbutton label="Supprimer" shape="delete" href="delete_storage.html?key=%s"|args:$key target="_dialog"}}
</td>
</tr>

View File

@ -1,53 +0,0 @@
{{* -*- brindille -*- *}}
{{* récupérer les infos du lieu de stockage *}}
{{#load key=$_GET.key assign="storage"}}
{{else}}
{{:error message="Lieu de stockage introuvable"}}
{{/load}}
{{* Traiter l'envoi du formulaire *}}
{{#form on="save"}}
{{* voir si le nom a changé *}}
{{if $_POST.name|trim == $storage.name}}
{{* voir si l'emplacement a changé *}}
{{if $_POST.location|trim != $storage.location}}
{{:assign modif=true}}
{{/if}}
{{else}}
{{* voir s'il existe un lieu de stockage de même nom *}}
{{#load type="storage" where="$$.name = :name" :name=$_POST.name|trim limit=1}}
{{:error message="Modification impossible car ce nom (« %s ») est déjà utilisé !"|args:$name|trim}}
{{else}}
{{:assign modif=true}}
{{/load}}
{{/if}}
{{if $modif}}
{{:save
key=$storage.key
validate_schema="storage.schema.json"
type="storage"
name=$_POST.name|trim
location=$_POST.location|trim
}}
{{/if}}
{{:redirect force="./index.html?ok=1&msg=modification"}}
{{/form}}
{{:admin_header title="Modifier un lieu de stockage" current="module_equipment"}}
{{:form_errors}}
{{* formulaire de modification d'un lieu de stockage *}}
<form method="post" action="" data-focus="1">
<fieldset class="modif_storage">
<legend>Modifier le lieu de stockage « {{$storage.name}} »</legend>
<dl>
{{:input type="text" name="name" label="Nom" default=$storage.name required=true maxlength="100"}}
{{:input type="textarea" name="location" label="Emplacement" default=$storage.location cols="40", rows="3" required=false}}
</dl>
<p class="submit">
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
</p>
</fieldset>
</form>