Suppression de client : utilisation du formulaire générique
This commit is contained in:
parent
2d4052e984
commit
530f0886b3
3 changed files with 13 additions and 39 deletions
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue