ajout liaison entre entrée temporaire et retour
This commit is contained in:
parent
144a909494
commit
ce87720d41
@ -85,32 +85,6 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
{{* calculer la quantité restant à l'extérieur de chaque matériel *}}
|
|
||||||
{{#foreach from=$config.output_nature key=key}}
|
|
||||||
{{if $type == "temporaire"}}
|
|
||||||
{{:assign var="temp_outputs." value=$key|quote_sql}}
|
|
||||||
{{/if}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{:assign operations=$temp_outputs|implode:","}}
|
|
||||||
{{:assign operations="("|cat:$operations|cat:")"}}
|
|
||||||
|
|
||||||
{{#select
|
|
||||||
mvt.key AS mvt_key,
|
|
||||||
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
|
|
||||||
FROM module_data_equipment AS mvt
|
|
||||||
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.output')
|
|
||||||
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
|
||||||
WHERE
|
|
||||||
json_extract(mvt.document, '$.operation') IN !op
|
|
||||||
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
|
||||||
GROUP by mvt.key
|
|
||||||
;
|
|
||||||
!op = $operations
|
|
||||||
:eqpmt_key = $_GET.key
|
|
||||||
}}
|
|
||||||
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
|
|
||||||
{{/select}}
|
|
||||||
|
|
||||||
{{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}}
|
{{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}}
|
||||||
{{:assign stock=0}}
|
{{:assign stock=0}}
|
||||||
{{:assign exterieur=0}}
|
{{:assign exterieur=0}}
|
||||||
@ -145,6 +119,32 @@
|
|||||||
|
|
||||||
{{* lister tous les mouvements du matériel passé en paramètre *}}
|
{{* lister tous les mouvements du matériel passé en paramètre *}}
|
||||||
{{if $_GET.prop}}
|
{{if $_GET.prop}}
|
||||||
|
{{* calculer la quantité temporairement l'extérieur de chaque matériel *}}
|
||||||
|
{{#foreach from=$config.output_nature key=key}}
|
||||||
|
{{if $type == "temporaire"}}
|
||||||
|
{{:assign var="temp_outputs." value=$key|quote_sql}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign operations=$temp_outputs|implode:","}}
|
||||||
|
{{:assign operations="("|cat:$operations|cat:")"}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
mvt.key AS mvt_key,
|
||||||
|
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
|
||||||
|
FROM module_data_equipment AS mvt
|
||||||
|
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.output')
|
||||||
|
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||||
|
WHERE
|
||||||
|
json_extract(mvt.document, '$.operation') IN !op
|
||||||
|
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
||||||
|
GROUP by mvt.key
|
||||||
|
;
|
||||||
|
!op = $operations
|
||||||
|
:eqpmt_key = $_GET.key
|
||||||
|
}}
|
||||||
|
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
{{#list
|
{{#list
|
||||||
type="movement"
|
type="movement"
|
||||||
select="$$.date AS 'Date';
|
select="$$.date AS 'Date';
|
||||||
@ -154,7 +154,7 @@
|
|||||||
"" as 'Stock';
|
"" as 'Stock';
|
||||||
"" as 'Sorti';
|
"" as 'Sorti';
|
||||||
"" as 'Disponible';
|
"" as 'Disponible';
|
||||||
$$.comment AS 'Remarque'"
|
$$.comment AS 'Commentaire'"
|
||||||
equipment=$equipment_key
|
equipment=$equipment_key
|
||||||
order=1
|
order=1
|
||||||
}}
|
}}
|
||||||
@ -179,8 +179,8 @@
|
|||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{if $current != "archives"}}
|
{{if $current != "archives"}}
|
||||||
{{if $direction == "output" && $type_mvt == "temporaire"}}
|
{{if $direction == "output" && $type_mvt == "temporaire"}}
|
||||||
{{:assign var="ext" from="reste.%s"|args:$key}}
|
{{:assign var="temp_ext" from="reste.%s"|args:$key}}
|
||||||
{{if $ext != null && $ext > 0}}
|
{{if $temp_ext != null && $temp_ext > 0}}
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Retour"
|
label="Retour"
|
||||||
href="mouvements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
href="mouvements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
||||||
@ -210,6 +210,33 @@
|
|||||||
{{/list}}
|
{{/list}}
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
{{* calculer la quantité présente temporairement de chaque matériel *}}
|
||||||
|
{{#foreach from=$config.input_nature key=key}}
|
||||||
|
{{if $type == "temporaire"}}
|
||||||
|
{{:assign var="temp_inputs." value=$key|quote_sql}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign operations=$temp_inputs|implode:","}}
|
||||||
|
{{:assign operations="("|cat:$operations|cat:")"}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
mvt.key AS mvt_key,
|
||||||
|
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
|
||||||
|
FROM module_data_equipment AS mvt
|
||||||
|
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.input')
|
||||||
|
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||||
|
WHERE
|
||||||
|
json_extract(mvt.document, '$.operation') IN !op
|
||||||
|
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
||||||
|
GROUP by mvt.key
|
||||||
|
;
|
||||||
|
!op = $operations
|
||||||
|
:eqpmt_key = $_GET.key
|
||||||
|
}}
|
||||||
|
{{:assign var="present.%s"|args:$mvt_key value=$present}}
|
||||||
|
{{/select}}
|
||||||
|
{{*:debug present=$present*}}
|
||||||
|
{{*:debug direction=$direction type_mvt=$type_mvt in=$in*}}
|
||||||
{{#list
|
{{#list
|
||||||
type="movement"
|
type="movement"
|
||||||
select="$$.date AS 'Date';
|
select="$$.date AS 'Date';
|
||||||
@ -217,11 +244,11 @@
|
|||||||
$$.operation AS 'Opération';
|
$$.operation AS 'Opération';
|
||||||
$$.amount AS 'Quantité';
|
$$.amount AS 'Quantité';
|
||||||
"" as 'Présent';
|
"" as 'Présent';
|
||||||
$$.comment AS 'Remarque'"
|
$$.comment AS 'Commentaire'"
|
||||||
equipment=$equipment_key
|
equipment=$equipment_key
|
||||||
order=1
|
order=1
|
||||||
}}
|
}}
|
||||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$direction:$col3}}
|
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$col3}}
|
||||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
||||||
|
|
||||||
{{if $direction === "input" && $op_label|in:$input_types ||
|
{{if $direction === "input" && $op_label|in:$input_types ||
|
||||||
@ -236,6 +263,16 @@
|
|||||||
<td class="num nosort">{{$stock}}</td>
|
<td class="num nosort">{{$stock}}</td>
|
||||||
<td>{{$comment}}</td>
|
<td>{{$comment}}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
|
{{if $direction == "input" && $type_mvt == "temporaire"}}
|
||||||
|
{{:assign var="temp_in" from="present.%s"|args:$key}}
|
||||||
|
{{if $temp_in != null && $temp_in > 0}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Retour"
|
||||||
|
href="mouvements/input_return.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
||||||
|
shape="history"
|
||||||
|
target="_dialog"}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Dupliquer"
|
label="Dupliquer"
|
||||||
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
href="mouvements/dupliquer_mouvement.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
||||||
|
@ -95,13 +95,6 @@
|
|||||||
<td>{{$cat_name}}</td>
|
<td>{{$cat_name}}</td>
|
||||||
<td class="num">{{$col3}}</td>
|
<td class="num">{{$col3}}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{if $col3 > 0}}
|
|
||||||
{{:linkbutton
|
|
||||||
label="Retour"
|
|
||||||
href="mouvements/sorties/emprunte.html?key=%s"|args:$key
|
|
||||||
shape="history"
|
|
||||||
target="_dialog"}}
|
|
||||||
{{/if}}
|
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Entrée"
|
label="Entrée"
|
||||||
shape="plus"
|
shape="plus"
|
||||||
|
181
mouvements/input_return.html
Normal file
181
mouvements/input_return.html
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Enregistrer un retour d'entrée temporaire
|
||||||
|
paramètres :
|
||||||
|
- key : clé du mouvement
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{* infos du mouvement *}}
|
||||||
|
{{#load key=$_GET.key assign="mvt_new"}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Aucun mouvement avec la clé %s"|args:$_GET.key}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* infos du matériel associé *}}
|
||||||
|
{{#load key=$mvt_new.equipment assign="equipment"}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Aucun matériel avec la clé « %s »"|args:$key}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* récupérer la config des entrées/sorties *}}
|
||||||
|
{{:include file="../_get_config.html" keep="config"}}
|
||||||
|
|
||||||
|
{{* calculer la quantité entrée temporairement *}}
|
||||||
|
{{#foreach from=$config.input_nature key=key}}
|
||||||
|
{{if $type == "temporaire"}}
|
||||||
|
{{:assign var="temp_inputs." value=$key|quote_sql}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign operations=$temp_inputs|implode:","}}
|
||||||
|
{{:assign operations="("|cat:$operations|cat:")"}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
|
||||||
|
FROM module_data_equipment AS mvt
|
||||||
|
LEFT JOIN module_data_equipment AS link ON mvt.key = json_extract(link.document, '$.input')
|
||||||
|
LEFT JOIN module_data_equipment AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||||
|
WHERE
|
||||||
|
json_extract(mvt.document, '$.operation') IN !op
|
||||||
|
AND mvt.key = :mvt_key
|
||||||
|
GROUP by mvt.key
|
||||||
|
;
|
||||||
|
!op = $operations
|
||||||
|
:mvt_key = $_GET.key
|
||||||
|
}}
|
||||||
|
{{:assign present=$present}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
-------------------- Traiter la saisie --------------------
|
||||||
|
*}}
|
||||||
|
{{#form on="save"}}
|
||||||
|
{{* vérifier validité des données *}}
|
||||||
|
{{if $_POST.amount <= 0}}
|
||||||
|
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.amount > $present}}
|
||||||
|
{{:error message="La quantité (%s) doit être inférieure à la quantité présente (%s) !!"|args:$_POST.amount:$present}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.date|parse_date|strtotime > $now}}
|
||||||
|
{{:error message="Impossible de saisir une date dans le futur (%s)"|args:$_POST.date}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* préparer le nouveau mouvement *}}
|
||||||
|
{{:assign var="mvt_new.key" value=""|uuid}}
|
||||||
|
{{: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}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
lister les mouvements
|
||||||
|
- insérer le nouveau mvt à sa place par date croissante
|
||||||
|
*}}
|
||||||
|
{{:assign insere=false}}
|
||||||
|
{{#load
|
||||||
|
where="
|
||||||
|
$$.type = 'movement'
|
||||||
|
AND
|
||||||
|
$$.equipment = :eqpmt_key"
|
||||||
|
:eqpmt_key=$equipment.key
|
||||||
|
order="$$.date"
|
||||||
|
assign="movement"
|
||||||
|
}}
|
||||||
|
{{if! $insere}}
|
||||||
|
{{if
|
||||||
|
$mvt_new.direction == "input" && $date >= $mvt_new.date ||
|
||||||
|
$mvt_new.direction == "output" && $date > $mvt_new.date
|
||||||
|
}}
|
||||||
|
{{:assign var="movements_new." from=mvt_new}}
|
||||||
|
{{:assign insere=true}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign var="movements_new." from=movement}}
|
||||||
|
{{/load}}
|
||||||
|
{{if ! $insere}}
|
||||||
|
{{:assign var="movements_new." from=mvt_new}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* Vérifier la cohérence des mouvements du matériel *}}
|
||||||
|
{{:include
|
||||||
|
file="./valider_modification.html"
|
||||||
|
keep="erreur, pb"
|
||||||
|
movements=$movements_new
|
||||||
|
}}
|
||||||
|
{{if $erreur}}
|
||||||
|
<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}}
|
||||||
|
{{* 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"
|
||||||
|
input=$_GET.key
|
||||||
|
return=$mvt_key
|
||||||
|
}}
|
||||||
|
{{:redirect force="../historique.html?ok=1&key=%s&prop=0&msg=retour"|args:$mvt_new.equipment}}
|
||||||
|
{{/if}}
|
||||||
|
{{/form}}
|
||||||
|
|
||||||
|
{{:admin_header title="Retour de matériel" custom_css="./../../style.css" current="module_equipment"}}
|
||||||
|
{{:form_errors}}
|
||||||
|
|
||||||
|
{{* barre de navigation *}}
|
||||||
|
{{if ! $dialog}}
|
||||||
|
{{:include file="../_nav.html" current="entrees"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
-------------------- Préparer la saisie --------------------
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{#foreach from=$config.output_nature key=key}}
|
||||||
|
{{if $type == "retour"}}
|
||||||
|
{{:assign var="return_label.%s"|args:$key value=$label}}
|
||||||
|
{{:break}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
|
||||||
|
{{* infos de la catégorie *}}
|
||||||
|
{{#load key=$equipment.category assign="category"}}{{/load}}
|
||||||
|
|
||||||
|
<form method="post" action="">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Retour de « {{$equipment.name}} (Catégorie : {{$category.name}}) »</legend>
|
||||||
|
<dl>
|
||||||
|
{{:input type="select" name="operation" label="Type" required=true options=$return_label}}
|
||||||
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||||||
|
{{:input type="number" name="amount" label="Quantité" min=1 max=$present required=true default=$present}}
|
||||||
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false}}
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{:admin_footer}}
|
23
mouvements/link.schema.json
Normal file
23
mouvements/link.schema.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["link"]
|
||||||
|
},
|
||||||
|
"input" : {
|
||||||
|
"description": "clé d'une entrée temporaire",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"output" : {
|
||||||
|
"description": "clé d'une sortie temporaire",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"return": {
|
||||||
|
"description": "clé d'un retour",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["type", "return"]
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
|
Enregistrer un retour de sortie temporaire
|
||||||
paramètres :
|
paramètres :
|
||||||
- key : clé du mouvement
|
- key : clé du mouvement
|
||||||
*}}
|
*}}
|
||||||
@ -130,6 +131,7 @@
|
|||||||
{{* enregistrer la liaison entre le retour et la sortie temporaire *}}
|
{{* enregistrer la liaison entre le retour et la sortie temporaire *}}
|
||||||
{{:save
|
{{:save
|
||||||
key=""|uuid
|
key=""|uuid
|
||||||
|
validate_schema="link.schema.json"
|
||||||
type="link"
|
type="link"
|
||||||
output=$_GET.key
|
output=$_GET.key
|
||||||
return=$mvt_key
|
return=$mvt_key
|
||||||
@ -167,7 +169,7 @@
|
|||||||
{{:input type="select" name="operation" label="Type" required=true options=$return_label}}
|
{{:input type="select" name="operation" label="Type" required=true options=$return_label}}
|
||||||
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||||||
{{:input type="number" name="amount" label="Quantité" min=1 max=$exterieur required=true default=$exterieur}}
|
{{:input type="number" name="amount" label="Quantité" min=1 max=$exterieur required=true default=$exterieur}}
|
||||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_new.comment}}
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false}}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
@ -21,54 +21,63 @@
|
|||||||
{{:include file="../_get_config.html" keep="config"}}
|
{{:include file="../_get_config.html" keep="config"}}
|
||||||
|
|
||||||
{{#form on="delete"}}
|
{{#form on="delete"}}
|
||||||
|
|
||||||
{{#load type="link" where="$$.output = :key OR $$.return = :key" :key=$_GET.key}}
|
|
||||||
{{:assign link_key=$key}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{* vérifier s'il est possible de supprimer le mouvement *}}
|
{{* vérifier s'il est possible de supprimer le mouvement *}}
|
||||||
{{if $mvt_suppr.direction == 'input'}}
|
{{if $mvt_suppr.direction == 'input'}}
|
||||||
{{:assign dispo=0}}
|
{{:assign var="type_operation" from="config.input_nature.%s.type"|args:$mvt_suppr.operation}}
|
||||||
{{:assign nonprop=0}}
|
|
||||||
|
|
||||||
{{#load
|
|
||||||
type="movement"
|
|
||||||
where="$$.equipment = :key" :key=$mvt_suppr.equipment
|
|
||||||
assign="mvt"
|
|
||||||
order="$$.date"}}
|
|
||||||
|
|
||||||
{{* déterminer le type de mouvement *}}
|
|
||||||
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt.direction:$mvt.operation}}
|
|
||||||
|
|
||||||
{{if $key != $_GET.key}}
|
|
||||||
{{* ce n'est pas le mouvement à supprimer : cumuler les entrées/sorties *}}
|
|
||||||
{{if $mvt.direction == 'input'}}
|
|
||||||
{{if $type_mvt == 'temporaire'}}
|
|
||||||
{{:assign nonprop="%d+%d"|math:$nonprop:$mvt.amount}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign dispo="%d+%d"|math:$dispo:$mvt.amount}}
|
|
||||||
{{/if}}
|
|
||||||
{{elseif $mvt.direction == 'output'}}
|
|
||||||
{{if $type_mvt == 'retour'}}
|
|
||||||
{{:assign nonprop="%d-%d"|math:$nonprop:$mvt.amount}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign dispo="%d-%d"|math:$dispo:$mvt.amount}}
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* problème ? *}}
|
|
||||||
{{if $dispo < 0 || $nonprop < 0}}
|
|
||||||
{{:redirect force="../historique.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
|
{{if $type_operation == 'temporaire'}}
|
||||||
|
{{#load type="link" where="$$.input = :key OR $$.return = :key" :key=$_GET.key}}
|
||||||
|
{{:assign link_key=$key}}
|
||||||
|
{{/load}}
|
||||||
|
{{if $link_key != null}}
|
||||||
|
{{:redirect force="../historique.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/load}}
|
{{else}}
|
||||||
|
{{:assign dispo=0}}
|
||||||
|
{{:assign nonprop=0}}
|
||||||
|
|
||||||
|
{{#load
|
||||||
|
type="movement"
|
||||||
|
where="$$.equipment = :key" :key=$mvt_suppr.equipment
|
||||||
|
assign="mvt"
|
||||||
|
order="$$.date"}}
|
||||||
|
|
||||||
|
{{* déterminer le type de mouvement *}}
|
||||||
|
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$mvt.direction:$mvt.operation}}
|
||||||
|
|
||||||
|
{{if $key != $_GET.key}}
|
||||||
|
{{* ce n'est pas le mouvement à supprimer : cumuler les entrées/sorties *}}
|
||||||
|
{{if $mvt.direction == 'input'}}
|
||||||
|
{{if $type_mvt == 'temporaire'}}
|
||||||
|
{{:assign nonprop="%d+%d"|math:$nonprop:$mvt.amount}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign dispo="%d+%d"|math:$dispo:$mvt.amount}}
|
||||||
|
{{/if}}
|
||||||
|
{{elseif $mvt.direction == 'output'}}
|
||||||
|
{{if $type_mvt == 'retour'}}
|
||||||
|
{{:assign nonprop="%d-%d"|math:$nonprop:$mvt.amount}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign dispo="%d-%d"|math:$dispo:$mvt.amount}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* problème ? *}}
|
||||||
|
{{if $dispo < 0 || $nonprop < 0}}
|
||||||
|
{{:redirect force="../historique.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
{{/load}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{* sortie *}}
|
{{* sortie *}}
|
||||||
{{:assign var="type_operation" from="config.output_nature.%s.type"|args:$mvt_suppr.operation}}
|
{{:assign var="type_operation" from="config.output_nature.%s.type"|args:$mvt_suppr.operation}}
|
||||||
|
|
||||||
{{if $type_operation == 'temporaire'}}
|
{{if $type_operation == 'temporaire'}}
|
||||||
|
{{#load type="link" where="$$.output = :key OR $$.return = :key" :key=$_GET.key}}
|
||||||
|
{{:assign link_key=$key}}
|
||||||
|
{{/load}}
|
||||||
{{if $link_key != null}}
|
{{if $link_key != null}}
|
||||||
{{:redirect force="../historique.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
{{:redirect force="../historique.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user