Suppression de client : utilisation du formulaire générique

This commit is contained in:
bohwaz 2021-12-17 12:38:58 +01:00
parent 2d4052e984
commit 530f0886b3
3 changed files with 13 additions and 39 deletions

View file

@ -17,24 +17,13 @@ if (!$client)
throw new UserException("Ce client n'existe pas.");
}
if (f('delete'))
{
$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());
}
}
}
$csrf_key = 'delete_client_'.$c->id;
$form->runIf('delete', function () use ($client, $c) {
$client->delete($c->id);
}, $csrf_key, PLUGIN_URL . 'clients.php');
$tpl->assign('deletable', $client->isDeletable($id));
$tpl->assign('client', $c);
$tpl->assign(compact('csrf_key'));
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');