From 745de00331217d9629e5be833df1d7cae932fb9d Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Thu, 26 Feb 2026 10:09:36 +0100 Subject: [PATCH] Ajout archivage factures --- admin/index.php | 10 +++++++++- lib/Facture.php | 4 ++-- templates/_style.css | 4 ++++ templates/index.tpl | 25 ++++++++++++++----------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/admin/index.php b/admin/index.php index 29d2d99..ee581d6 100644 --- a/admin/index.php +++ b/admin/index.php @@ -13,11 +13,19 @@ $form->runIf(f('archiver') && !$form->hasErrors(), function () use($facture) { foreach(f('selected') as $f) { - $facture->archiver($f); + $facture->archiver($f, 1); } }, 'archiver_factures'); +$form->runIf(f('desarchiver') && !$form->hasErrors(), + function () use($facture) + { + foreach(f('selected') as $f) { + $facture->archiver($f, 0); + } + + }, 'desarchiver_factures'); $archive = isset($_GET['archive']) && $_GET['archive'] == 1; $list = $facture->list(! $archive); diff --git a/lib/Facture.php b/lib/Facture.php index 761683f..e6f766e 100644 --- a/lib/Facture.php +++ b/lib/Facture.php @@ -559,10 +559,10 @@ class Facture return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id); } - public function archiver($id) + public function archiver($id, $archive) { $f = $this->get($id); - $f->archivee = 1; + $f->archivee = $archive; $f->date_emission = $f->date_emission->format('d/m/Y'); $f->date_echeance = $f->date_echeance->format('d/m/Y'); $id = $f->id; diff --git a/templates/_style.css b/templates/_style.css index f860f56..c38b377 100644 --- a/templates/_style.css +++ b/templates/_style.css @@ -18,4 +18,8 @@ div.aide ul { padding: 1em; } +div.flex { + display: flex; + justify-content : space-between; +} {/literal} diff --git a/templates/index.tpl b/templates/index.tpl index 92d727c..af0d181 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -13,7 +13,7 @@ {foreach from=$list->iterate() item="facture"} - {if ! $archive}{input type="checkbox" name="selected[]" value=$facture.id}{/if} + {input type="checkbox" name="selected[]" value=$facture.id} {$facture.type} {$facture.numero} {if $facture.receveur_membre} @@ -40,17 +40,20 @@ {$list->getHTMLPagination()|raw} -

- Export de la liste : - {linkbutton href="?export=csv" label="Export CSV" shape="download"} - {linkbutton href="?export=ods" label="Export tableur" shape="download"} -

-{if !$archive} -

+

+ {if $archive} + {csrf_field key="desarchiver_factures"} + {button type="submit" name="desarchiver" label="Désarchiver les factures sélectionnées" shape="right"} + {else} {csrf_field key="archiver_factures"} - {button type="submit" name="archiver" label="Archiver les factures sélectionnées" shape="right" class="main"} -

-{/if} + {button type="submit" name="archiver" label="Archiver les factures sélectionnées" shape="right"} + {/if} +
+ Export de la liste : + {linkbutton href="?export=csv" label="Export CSV" shape="download"} + {linkbutton href="?export=ods" label="Export tableur" shape="download"} +
+
{else}

Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.

{/if}