facturation/admin/client_supprimer.php
2023-08-01 22:56:38 +02:00

30 lines
648 B
PHP

<?php
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE);
f(['id' => 'required|numeric']);
$id = (int) qg('id');
$c = $client->get($id);
if (!$client)
{
throw new UserException("Ce client n'existe pas.");
}
$csrf_key = 'delete_client_'.$c->id;
$form->runIf('delete', function () use ($client, $c) {
$client->delete($c->id);
}, $csrf_key, PLUGIN_ADMIN_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');