Ajout modification sortie et mutualisation
This commit is contained in:
parent
d20c6221e2
commit
d804795d41
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset class="entree">
|
<fieldset class="entree">
|
||||||
<legend>Ajouter une entrée pour du </legend>
|
<legend>Ajouter une entrée</legend>
|
||||||
{{:linkbutton label="Matériel répertorié" shape="plus" href="repertorie.html?dialog" target="_dialog"}}
|
{{:linkbutton label="Matériel répertorié" shape="plus" href="repertorie.html?dialog" target="_dialog"}}
|
||||||
{{:linkbutton label="Matériel non répertorié" shape="plus" href="non_repertorie.html?dialog" target="_dialog"}}
|
{{:linkbutton label="Matériel non répertorié" shape="plus" href="non_repertorie.html?dialog" target="_dialog"}}
|
||||||
{{:linkbutton label="Retour de sortie temporaire" shape="plus" href="retour.html?dialog" target="_dialog"}}
|
{{:linkbutton label="Retour de sortie temporaire" shape="plus" href="retour.html?dialog" target="_dialog"}}
|
||||||
@ -52,7 +52,7 @@
|
|||||||
target="_dialog"}}
|
target="_dialog"}}
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Modifier"
|
label="Modifier"
|
||||||
href="modifier_entree.html?key=%s"|args:$mvt_key
|
href="../modifier_mouvement.html?key=%s&direction=entrée&caller=%s"|args:$mvt_key:$request_url
|
||||||
shape="edit"
|
shape="edit"
|
||||||
target="_dialog"}}
|
target="_dialog"}}
|
||||||
</td>
|
</td>
|
||||||
|
195
mouvements/modifier_mouvement.html
Normal file
195
mouvements/modifier_mouvement.html
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
|
||||||
|
{{:admin_header title="Modifier une %s"|args:$_GET.direction current="module_equipment"}}
|
||||||
|
|
||||||
|
{{* déterminer l'url de retour *}}
|
||||||
|
{{:assign url=$_GET.caller}}
|
||||||
|
{{:assign pos=$url|strpos:"?"}}
|
||||||
|
{{if $pos|intval > 0}}
|
||||||
|
{{:assign url=$url|truncate:$pos:"":true}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:assign direction=$_GET.direction}}
|
||||||
|
{{:assign key_mvt=$_GET.key}}
|
||||||
|
|
||||||
|
{{* récupérer les infos du mouvement à modifier *}}
|
||||||
|
{{#load key=$key_mvt assign="mvt_modif"}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Aucune %s avec la clé %s"|args:$_GET.direction:$key_mvt}}
|
||||||
|
{{/load}}
|
||||||
|
{{if $direction == "entrée"}}
|
||||||
|
{{:assign input_init=$mvt_modif.inputNature}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign output_init=$mvt_modif.outputNature}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign amount_init=$mvt_modif.amount}}
|
||||||
|
{{:assign date_init=$mvt_modif.date|date_short}}
|
||||||
|
{{:assign key_eqpmt_init=$mvt_modif.equipment}}
|
||||||
|
|
||||||
|
{{if $direction == "entrée"}}
|
||||||
|
{{* types d'entrées *}}
|
||||||
|
{{#foreach from=$module.config.inputNature key="rang" item="elem"}}
|
||||||
|
{{:assign var='types_entrees.' value="%s"|args:$elem.label}}
|
||||||
|
{{if $elem.label == $mvt_modif.inputNature}}
|
||||||
|
{{:assign type_defaut=$rang}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{else}}
|
||||||
|
{{* types de sorties *}}
|
||||||
|
{{#foreach from=$module.config.outputNature key="rang" item="elem"}}
|
||||||
|
{{:assign var='types_sorties.' value="%s"|args:$elem.label}}
|
||||||
|
{{if $elem.label == $mvt_modif.outputNature}}
|
||||||
|
{{:assign type_defaut=$rang}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* récupérer les infos du matériel associé *}}
|
||||||
|
{{#load key=$key_eqpmt_init assign="eqpmt_init"}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Aucun matériel avec la clé « %s »"|args:$key_eqpmt_init}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
-------------------- Traiter la saisie --------------------
|
||||||
|
*}}
|
||||||
|
{{#form on="change"}}
|
||||||
|
{{* préparer le mouvement modifié *}}
|
||||||
|
{{if $direction == "entrée"}}
|
||||||
|
{{:assign var="mvt_modif.inputNature" from="types_entrees.%d"|args:$_POST.type_operation}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign var="mvt_modif.outputNature" from="types_sorties.%d"|args:$_POST.type_operation}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign var="mvt_modif.amount" value=$_POST.amount}}
|
||||||
|
{{:assign var="mvt_modif.equipment" value=$_POST.equipment}}
|
||||||
|
{{:assign var="mvt_modif.date" value=$_POST.date|parse_date}}
|
||||||
|
{{:assign var="mvt_modif.comment" value=$_POST.comment}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
lister les mouvements et remplacer le mouvement sélectionné par sa version modifiée
|
||||||
|
en l'insérant à sa place par date croissante
|
||||||
|
*}}
|
||||||
|
{{:assign insere=false}}
|
||||||
|
{{#select
|
||||||
|
id, key,
|
||||||
|
json_extract(document, '$.type') as 'type',
|
||||||
|
json_extract(document, '$.direction') as 'direction',
|
||||||
|
json_extract(document, '$.inputNature') as 'inputNature',
|
||||||
|
json_extract(document, '$.outputNature') as 'outputNature',
|
||||||
|
json_extract(document, '$.amount') as 'amount',
|
||||||
|
json_extract(document, '$.equipment') as 'equipment',
|
||||||
|
json_extract(document, '$.date') as 'date',
|
||||||
|
json_extract(document, '$.comment') as 'comment'
|
||||||
|
FROM module_data_equipment
|
||||||
|
WHERE
|
||||||
|
json_extract(document, '$.type') = 'movement'
|
||||||
|
AND
|
||||||
|
(json_extract(document, '$.equipment') = :old_eqpmt_key
|
||||||
|
OR
|
||||||
|
json_extract(document, '$.equipment') = :new_eqpmt_key)
|
||||||
|
ORDER BY json_extract(document, '$.date');
|
||||||
|
:old_eqpmt_key=$key_eqpmt_init
|
||||||
|
:new_eqpmt_key=$_POST.equipment
|
||||||
|
assign="movement"
|
||||||
|
}}
|
||||||
|
{{if $key != $key_mvt}}
|
||||||
|
{{if $date > $mvt_modif.date && ! $insere}}
|
||||||
|
{{:assign var=movements_modif." from=mvt_modif}}
|
||||||
|
{{:assign insere=true}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign var=movements_modif." from=movement}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
{{if ! $insere}}
|
||||||
|
{{:assign var=movements_modif." from=mvt_modif}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* Vérifier la cohérence des opérations de l'ancien matériel *}}
|
||||||
|
{{:include
|
||||||
|
file="./valider_modification.html"
|
||||||
|
keep="erreur"
|
||||||
|
movements=$movements_modif
|
||||||
|
eqpmt_key=$key_eqpmt_init
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{* Si le matériel a changé, vérifier la cohérence des opérations du nouveau matériel *}}
|
||||||
|
{{if ! $erreur && $key_eqpmt_init != $_POST.equipment}}
|
||||||
|
{{:include
|
||||||
|
file="./valider_modification.html"
|
||||||
|
keep="erreur"
|
||||||
|
movements=$movements_modif
|
||||||
|
eqpmt_key=$_POST.equipment
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#load key=$mvt_modif.equipment assign="eqpmt"}}{{/load}}
|
||||||
|
{{if $erreur}}
|
||||||
|
<p class="block error">
|
||||||
|
Modification demandée impossible :
|
||||||
|
{{if $direction == "entrée"}}
|
||||||
|
« {{$input_init}} de {{$eqpmt_init.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||||
|
« {{$mvt_modif.inputNature}} de {{$eqpmt.designation}} (qté : {{$mvt_modif.amount}}) à la date du {{$mvt_modif.date|date_short}} »
|
||||||
|
{{else}}
|
||||||
|
« {{$output_init}} de {{$eqpmt_init.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||||
|
« {{$mvt_modif.outputNature}} de {{$eqpmt.designation}} (qté : {{$mvt_modif.amount}}) à la date du {{$mvt_modif.date|date_short}} »
|
||||||
|
{{/if}}
|
||||||
|
</p>
|
||||||
|
{{* :redirect force="./index.html?err=1&msg=Modification demandée impossible" *}}
|
||||||
|
{{else}}
|
||||||
|
{{* vérification réussie : modifier le mouvement *}}
|
||||||
|
{{:save
|
||||||
|
key=$key_mvt
|
||||||
|
validate_schema="/%s/mouvements/movement.schema.json"|args:$module.name
|
||||||
|
type="movement"
|
||||||
|
direction=$direction
|
||||||
|
inputNature=$mvt_modif.inputNature
|
||||||
|
outputNature=$mvt_modif.outputNature
|
||||||
|
amount=$mvt_modif.amount|intval
|
||||||
|
equipment=$mvt_modif.equipment
|
||||||
|
date=$mvt_modif.date
|
||||||
|
comment=$mvt_modif.comment
|
||||||
|
}}
|
||||||
|
{{:redirect force="%s?ok=1&msg=Modification enregistrée"|args:$url}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/form}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
-------------------- Préparer la saisie --------------------
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{* lister les catégories et matériels associés *}}
|
||||||
|
{{#load type="category" assign="category" order="$$.name"}}
|
||||||
|
{{:assign nom_cat=$category.name}}
|
||||||
|
{{#load type="equipment" where="$$.category = :key" :key=$category.key assign="equipment"}}
|
||||||
|
{{:assign var="equipments.%s.%s"|args:$nom_cat:$equipment.key value=$equipment.designation}}
|
||||||
|
{{/load}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* formulaire de modification du mouvement *}}
|
||||||
|
<form method="post" action="">
|
||||||
|
|
||||||
|
<fieldset class="entree">
|
||||||
|
{{if $direction == "entrée"}}
|
||||||
|
<legend>Modifier l'entrée « {{$input_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||||
|
{{:input type="select" name="type_operation" label="Type" required=true options=$types_entrees default=$type_defaut}}
|
||||||
|
{{else}}
|
||||||
|
<legend>Modifier la sortie « {{$output_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||||
|
{{:input type="select" name="type_operation" label="Type" required=true options=$types_sorties 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}}
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Matériel</legend>
|
||||||
|
{{:input type="select_groups" name="equipment" label="Matériel" required=true options=$equipments default=$key_eqpmt_init}}
|
||||||
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_modif.comment}}
|
||||||
|
</fieldset>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
{{:button type="submit" name="change" label="Enregistrer" shape="right" class="main"}}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{:admin_footer}}
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset class="sortie">
|
<fieldset class="sortie">
|
||||||
<legend>Ajouter une sortie pour du </legend>
|
<legend>Ajouter une sortie </legend>
|
||||||
{{:linkbutton label="Matériel en stock disponible" shape="plus" href="stock_disponible.html?dialog" target="_dialog"}}
|
{{:linkbutton label="Matériel en stock disponible" shape="plus" href="stock_disponible.html?dialog" target="_dialog"}}
|
||||||
{{:linkbutton label="Matériel emprunté" shape="plus" href="emprunte.html?dialog" target="_dialog"}}
|
{{:linkbutton label="Matériel emprunté" shape="plus" href="emprunte.html?dialog" target="_dialog"}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@ -44,14 +44,16 @@
|
|||||||
<td>{{$col4}}</td>
|
<td>{{$col4}}</td>
|
||||||
<td>{{$comment}}</td>
|
<td>{{$comment}}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{:linkbutton label="Supprimer" href="delete_sortie.html?key=%s"|args:$mvt_key shape="delete" target="_dialog"}}
|
|
||||||
{{*
|
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Supprimer"
|
label="Supprimer"
|
||||||
href="../delete_movement.html?key=%s&mvt=sortie&caller=%s"|args:$mvt_key:$request_url
|
href="delete_sortie.html?key=%s"|args:$mvt_key
|
||||||
shape="delete"
|
shape="delete"
|
||||||
target="_dialog"}}
|
target="_dialog"}}
|
||||||
*}}
|
{{:linkbutton
|
||||||
|
label="Modifier"
|
||||||
|
href="../modifier_mouvement.html?key=%s&direction=sortie&caller=%s"|args:$mvt_key:$request_url
|
||||||
|
shape="edit"
|
||||||
|
target="_dialog"}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/list}}
|
{{/list}}
|
||||||
|
47
mouvements/valider_modification.html
Normal file
47
mouvements/valider_modification.html
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{{*
|
||||||
|
Vérifier la cohérence des E/S d'un matériel
|
||||||
|
- paramètres :
|
||||||
|
- movements : liste de mouvements
|
||||||
|
- eqpmt_key : clé du matériel à vérifier
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign erreur = false}}
|
||||||
|
{{:assign stock=0}}
|
||||||
|
{{:assign exterieur=0}}
|
||||||
|
{{:assign nonprop=0}}
|
||||||
|
{{#foreach from=$movements item="movement"}}
|
||||||
|
{{if $movement.equipment == $eqpmt_key}}
|
||||||
|
{{if $movement.direction == 'entrée'}}
|
||||||
|
{{* chercher le type d'entrée parmi les types de la config *}}
|
||||||
|
{{#foreach from=$module.config.inputNature item="elem"}}
|
||||||
|
{{if $movement.inputNature == $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}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{elseif $movement.direction == 'sortie'}}
|
||||||
|
{{* chercher le type de sortie parmi les types de la config *}}
|
||||||
|
{{#foreach from=$module.config.outputNature item="elem"}}
|
||||||
|
{{if $movement.outputNature == $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}}
|
||||||
|
{{:assign erreur=true}}
|
||||||
|
{{:break}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{/foreach}}
|
Loading…
Reference in New Issue
Block a user