Mutualisation suppression mouvement

This commit is contained in:
Jean-Christophe Engel 2023-10-27 10:47:59 +02:00
parent db36bce5fa
commit e3b33231a7
3 changed files with 110 additions and 8 deletions

View File

@ -0,0 +1,43 @@
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
{{:assign var="type_movement" value=$_GET.mvt}}
{{:admin_header title="Supprimer une %s"|args:$type_movement 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}}
{{#load key=$_GET.key assign="movement"}}
{{* trouver le matériel concerné par ce mouvement *}}
{{#load type="equipment" where="key = :key" :key=$movement.equipment assign="equipment"}}
{{else}}
{{:error message="Matériel avec la clé « %s » introuvable"|args:$movement.equipment}}
{{/load}}
{{else}}
{{:error message="%s avec la clé « %s » introuvable"|args:$type_movement:$_GET.key}}
{{/load}}
{{:assign var="date_supp" value="%s"|args:$movement.date|date_short}}
{{#form on="delete"}}
{{* supprimer le mouvement *}}
{{:delete key=$_GET.key}}
{{:assign var="msg" value="%s « %d %s en date du %s » supprimée"|args:$type_movement:$movement.amount:$equipment.designation:$date_supp}}
{{* voir s'il reste des mouvements pour le matériel concerné par le mouvement supprimé *}}
{{#load type="movement" where="$$.equipment = :eqpmt_key" :eqpmt_key=$equipment.key}}
{{else}}
{{* supprimer le matériel *}}
{{:delete key=$equipment.key}}
{{:assign var="msg" value="%s - Matériel « %s » supprimé"|args:$msg:$equipment.designation}}
{{/load}}
{{:redirect force="%s?ok=1&msg=%s"|args:$url:$msg}}
{{/form}}
{{:delete_form legend="Supprimer cette %s ?"|args:$type_movement warning="Supprimer %s « %d %s » en date du %s ?"|args:$type_movement:$movement.amount:$equipment.designation:$date_supp}}
{{:form_errors}}
{{:admin_footer}}

View File

@ -5,18 +5,68 @@
{{:include file="/%s/_nav.html"|args:$module.name current="entrees"}} {{:include file="/%s/_nav.html"|args:$module.name current="entrees"}}
{{if $_GET.ok}} {{if $_GET.ok}}
<p class="block confirm">Entrée enregistrée.</p> <p class="block confirm">{{$_GET.msg}}</p>
{{/if}} {{/if}}
<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 pour du </legend>
{{:linkbutton label="Matériel répertorié" shape="plus" href="repertorie.html"}} {{:linkbutton label="Matériel répertorié" shape="plus" href="repertorie.html" target="_dialog"}}
{{:linkbutton label="Matériel non répertorié" shape="plus" href="non_repertorie.html}} {{:linkbutton label="Matériel non répertorié" shape="plus" href="non_repertorie.html" target="_dialog"}}
</fieldset> </fieldset>
</form> </form>
{{* lister les entrées *}} {{* lister les entrées *}}
<section class="liste_entrees">
<h2>Liste des entrées avec la section #list</h2>
{{* MARCHE PAS (voir message de Bohwaz)
{{#list
select="
$$.date AS 'Date' ;
$$.inputNature AS 'Type' ;
$$.amount AS 'Nombre' ;
(SELECT $$.designation
FROM @TABLE AS b
WHERE b.$$.equipment = @TABLE.$$.equipment)
AS 'Matériel' ;
$$.comment AS 'Remarques'"
type="movement"
direction="entrée"
order=1}}
*}}
{{#list select="$$.date AS 'Date' ; $$.inputNature AS 'Type' ; $$.amount AS 'Nombre' ; '' AS 'Matériel' ; $$.comment AS 'Remarques'" type="movement" direction="entrée" order=1}}
{{:assign var='mvt_key' value=$key}}
{{#load type="equipment" key=$equipment assign="equipment"}}
<tr>
<td>{{$date|date_short}}</td>
<td>{{$inputNature}}</td>
<td>{{$amount}}</td>
<td>{{$designation}}</td>
<td>{{$comment}}</td>
<td class="actions">
{{*
{{:linkbutton label="Supprimer" href="delete_entree.html?key=%s"|args:$mvt_key shape="delete" target="_dialog"}}
*}}
{{:linkbutton
label="Supprimer"
href="../delete_movement.html?key=%s&mvt=entrée&caller=%s"|args:$mvt_key:$request_url
shape="delete"
target="_dialog"}}
</td>
</tr>
{{/load}}
{{/list}}
</section>
{{*
Remarque :
- le tri par matériel ne fonctionne pas, car j'ai dû tricher pour afficher cette colonne
*}}
<section class="liste_entrees">
<h2>Liste des entrées avec la section #load</h2>
<table class="list"> <table class="list">
<thead> <thead>
<tr> <tr>
@ -29,21 +79,22 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#load type="movement" direction="entrée" assign="entrees"}} {{#load type="movement" direction="entrée" order="$$.date" assign="entrees"}}
{{#load type="equipment" key=$entrees.equipment assign="equipment"}} {{#load type="equipment" key=$entrees.equipment assign="equipment"}}
<tr> <tr>
<td>{{$entrees.date}}</td> <td>{{$entrees.date|date_short}}</td>
<td>{{$entrees.inputNature}}</td> <td>{{$entrees.inputNature}}</td>
<td>{{$entrees.amount}}</td> <td>{{$entrees.amount}}</td>
<td>{{$designation}}</td> <td>{{$designation}}</td>
<td>{{$entrees.comment}}</td> <td>{{$entrees.comment}}</td>
<td class="actions"> <td class="actions">
{{:linkbutton label="Supprimer" href="delete.html?id=%s"|args:$key shape="delete" target="_dialog"}} {{:linkbutton label="Supprimer" href="delete_entree.html?key=%s"|args:$key shape="delete" target="_dialog"}}
</td> </td>
</tr> </tr>
{{/load}} {{/load}}
</tbody> </tbody>
{{/load}} {{/load}}
</table> </table>
</section>
{{:admin_footer}} {{:admin_footer}}

View File

@ -17,7 +17,7 @@
</form> </form>
{{* lister les sorties *}} {{* lister les sorties *}}
<section class="liste_entrees"> <section class="liste_sorties">
<h2>Liste des sorties</h2> <h2>Liste des sorties</h2>
{{#list select="$$.date AS 'Date' ; $$.outputNature AS 'Type' ; $$.amount AS 'Nombre' ; "" AS 'Matériel' ; $$.comment AS 'Remarques'" type="movement" direction="sortie" order=1}} {{#list select="$$.date AS 'Date' ; $$.outputNature AS 'Type' ; $$.amount AS 'Nombre' ; "" AS 'Matériel' ; $$.comment AS 'Remarques'" type="movement" direction="sortie" order=1}}
{{:assign var='mvt_key' value=$key}} {{:assign var='mvt_key' value=$key}}
@ -29,7 +29,15 @@
<td>{{$designation}}</td> <td>{{$designation}}</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 label="Supprimer" href="delete_sortie.html?key=%s"|args:$mvt_key shape="delete" target="_dialog"}}
*}}
{{:linkbutton
label="Supprimer"
href="../delete_movement.html?key=%s&mvt=sortie&caller=%s"|args:$mvt_key:$request_url
shape="delete"
target="_dialog"}}
</td> </td>
</tr> </tr>
{{/load}} {{/load}}