2019-11-02 17:53:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Garradin;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/_inc.php';
|
|
|
|
|
2021-04-11 14:25:59 +02:00
|
|
|
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE);
|
2019-11-02 17:53:27 +01:00
|
|
|
|
|
|
|
qv(['id' => 'required|numeric']);
|
|
|
|
|
|
|
|
$id = (int) qg('id');
|
|
|
|
|
|
|
|
$c = $client->get($id);
|
|
|
|
|
|
|
|
if (!$client)
|
|
|
|
{
|
2019-11-03 17:51:31 +01:00
|
|
|
throw new UserException("Ce client n'existe pas.");
|
2019-11-02 17:53:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (f('delete'))
|
|
|
|
{
|
2019-11-03 17:51:31 +01:00
|
|
|
$form->check('delete_client_'.$c->id);
|
|
|
|
|
|
|
|
if (!$form->hasErrors())
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$client->delete($c->id);
|
|
|
|
Utils::redirect(PLUGIN_URL . 'clients.php');
|
|
|
|
}
|
|
|
|
catch (UserException $e)
|
|
|
|
{
|
|
|
|
$form->addError($e->getMessage());
|
|
|
|
}
|
2019-11-02 17:53:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$tpl->assign('deletable', $client->isDeletable($id));
|
2021-11-06 22:02:47 +01:00
|
|
|
$tpl->assign('client', $c);
|
2019-11-03 17:51:31 +01:00
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');
|