materiels/src/www/admin/localisations/supprimer_localisation.php

37 lines
736 B
PHP
Raw Normal View History

<?php
namespace Garradin;
use Garradin\Plugin\Materiels\Location;
use Garradin\Utils;
require_once __DIR__ . '/../_inc.php';
$loc = new Location;
$l = $loc->get((int) qg('id'));
if (!$l) {
throw new UserException("Cette localisation n'existe pas.");
}
$csrf_key = 'delete_location_' . $l->id;
if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
{
try
{
$loc->delete($l->id);
Utils::redirect(PLUGIN_URL . 'localisations/index.php');
}
catch (\RuntimeException $e)
{
$form->addError($e->getMessage());
}
}
$cancel_link = PLUGIN_URL . 'localisations/index.php';
$tpl->assign(compact('l', 'csrf_key', 'cancel_link'));
$tpl->display(PLUGIN_ROOT . '/templates/localisations/supprimer_localisation.tpl');