2021-11-06 22:02:47 +01:00
|
|
|
<?php
|
|
|
|
|
2023-08-01 22:56:38 +02:00
|
|
|
namespace Paheko;
|
2021-11-06 22:02:47 +01:00
|
|
|
|
|
|
|
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']);
|
2021-11-06 22:02:47 +01:00
|
|
|
|
|
|
|
$id = (int) qg('id');
|
|
|
|
|
|
|
|
$f = $facture->get($id);
|
|
|
|
|
|
|
|
if (!$client)
|
|
|
|
{
|
|
|
|
throw new UserException("Ce document n'existe pas.");
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:24:49 +02:00
|
|
|
$form->runIf(f('delete') && !$form->hasErrors(),
|
|
|
|
function () use ($facture, $f)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$facture->delete($f->id);
|
|
|
|
Utils::redirect(PLUGIN_ADMIN_URL . 'index.php');
|
|
|
|
}
|
|
|
|
catch (UserException $e)
|
|
|
|
{
|
|
|
|
$form->addError($e->getMessage());
|
|
|
|
}
|
|
|
|
});
|
2021-11-06 22:02:47 +01:00
|
|
|
|
|
|
|
$tpl->assign('doc', $f);
|
2023-10-19 10:24:49 +02:00
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/facture_supprimer.tpl');
|