facturation/admin/facture_supprimer.php

35 lines
819 B
PHP
Raw Permalink Normal View History

<?php
2023-08-01 22:56:38 +02:00
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE);
2023-08-01 22:56:38 +02:00
f(['id' => 'required|numeric']);
$id = (int) qg('id');
$f = $facture->get($id);
if (!$client)
{
throw new UserException("Ce document n'existe pas.");
}
$form->runIf(f('delete') && !$form->hasErrors(),
2024-01-12 11:50:04 +01:00
function () use ($facture, $f, $form)
{
try {
$facture->delete($f->id);
Utils::redirect(PLUGIN_ADMIN_URL . 'index.php');
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
});
$tpl->assign('doc', $f);
$tpl->display(PLUGIN_ROOT . '/templates/facture_supprimer.tpl');