Ajout archivage factures

This commit is contained in:
Jean-Christophe Engel 2026-02-26 10:09:36 +01:00
parent 79b3a72cca
commit 745de00331
4 changed files with 29 additions and 14 deletions

View file

@ -13,11 +13,19 @@ $form->runIf(f('archiver') && !$form->hasErrors(),
function () use($facture) function () use($facture)
{ {
foreach(f('selected') as $f) { foreach(f('selected') as $f) {
$facture->archiver($f); $facture->archiver($f, 1);
} }
}, 'archiver_factures'); }, '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; $archive = isset($_GET['archive']) && $_GET['archive'] == 1;
$list = $facture->list(! $archive); $list = $facture->list(! $archive);

View file

@ -559,10 +559,10 @@ class Facture
return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id); return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id);
} }
public function archiver($id) public function archiver($id, $archive)
{ {
$f = $this->get($id); $f = $this->get($id);
$f->archivee = 1; $f->archivee = $archive;
$f->date_emission = $f->date_emission->format('d/m/Y'); $f->date_emission = $f->date_emission->format('d/m/Y');
$f->date_echeance = $f->date_echeance->format('d/m/Y'); $f->date_echeance = $f->date_echeance->format('d/m/Y');
$id = $f->id; $id = $f->id;

View file

@ -18,4 +18,8 @@ div.aide ul {
padding: 1em; padding: 1em;
} }
div.flex {
display: flex;
justify-content : space-between;
}
{/literal} {/literal}

View file

@ -13,7 +13,7 @@
{foreach from=$list->iterate() item="facture"} {foreach from=$list->iterate() item="facture"}
<tr> <tr>
<td>{if ! $archive}{input type="checkbox" name="selected[]" value=$facture.id}{/if}</td> <td>{input type="checkbox" name="selected[]" value=$facture.id}</td>
<td>{$facture.type}</td> <td>{$facture.type}</td>
<th><a href="facture.php?id={$facture.id}&archive={$archive}">{$facture.numero}</a></th> <th><a href="facture.php?id={$facture.id}&archive={$archive}">{$facture.numero}</a></th>
{if $facture.receveur_membre} {if $facture.receveur_membre}
@ -40,17 +40,20 @@
</table> </table>
{$list->getHTMLPagination()|raw} {$list->getHTMLPagination()|raw}
<p class="help"> <div class="submit flex">
Export de la liste&nbsp;: {if $archive}
{linkbutton href="?export=csv" label="Export CSV" shape="download"} {csrf_field key="desarchiver_factures"}
{linkbutton href="?export=ods" label="Export tableur" shape="download"} {button type="submit" name="desarchiver" label="Désarchiver les factures sélectionnées" shape="right"}
</p> {else}
{if !$archive}
<p class="submit">
{csrf_field key="archiver_factures"} {csrf_field key="archiver_factures"}
{button type="submit" name="archiver" label="Archiver les factures sélectionnées" shape="right" class="main"} {button type="submit" name="archiver" label="Archiver les factures sélectionnées" shape="right"}
</p> {/if}
{/if} <div>
<span class="help">Export de la liste&nbsp;:</span>
{linkbutton href="?export=csv" label="Export CSV" shape="download"}
{linkbutton href="?export=ods" label="Export tableur" shape="download"}
</div>
</div>
{else} {else}
<p class="help">Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.</p> <p class="help">Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.</p>
{/if} {/if}