facturation/admin/client_modifier.php

55 lines
1.0 KiB
PHP
Raw Normal View History

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 (!$c)
{
throw new UserException("Ce client n'existe pas.");
}
if(f('save'))
{
$form->check('edit_client', [
'nom' => 'required|string',
'adresse' => 'required|string',
'code_postal' => 'required|string',
'ville' => 'required|string',
'telephone' => 'string',
'email' => 'email'
]);
2019-11-03 17:51:31 +01:00
2019-11-02 17:53:27 +01:00
if (!$form->hasErrors())
{
try
{
$r = $client->edit($id,[
'nom' => f('nom'),
'adresse' => f('adresse'),
'code_postal' => f('code_postal'),
'ville' => f('ville'),
'telephone' => f('telephone'),
'email' => f('email')
]);
2019-11-03 17:51:31 +01:00
2019-11-02 17:53:27 +01:00
$r ? Utils::redirect(PLUGIN_URL . 'client.php?id='.(int)$id):'';
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
}
}
$tpl->assign('client', $c);
$tpl->display(PLUGIN_ROOT . '/templates/client_modifier.tpl');