2019-11-02 17:53:27 +01:00
|
|
|
<?php
|
|
|
|
|
2023-08-01 22:56:38 +02:00
|
|
|
namespace Paheko;
|
2019-11-02 17:53:27 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-08-01 22:56:38 +02:00
|
|
|
f(['id' => 'required|numeric']);
|
2019-11-02 17:53:27 +01:00
|
|
|
$id = (int) qg('id');
|
|
|
|
|
|
|
|
$c = $client->get($id);
|
|
|
|
|
|
|
|
if (!$c)
|
|
|
|
{
|
|
|
|
throw new UserException("Ce client n'existe pas.");
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:24:49 +02:00
|
|
|
$form->runIf(f('save') && !$form->hasErrors(),
|
|
|
|
function () use ($client, $id)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$r = $client->edit($id,[
|
|
|
|
'nom' => f('nom'),
|
|
|
|
'adresse' => f('adresse'),
|
|
|
|
'code_postal' => f('code_postal'),
|
|
|
|
'ville' => f('ville'),
|
2024-01-11 20:41:19 +01:00
|
|
|
'siret' => f('siret'),
|
2023-10-19 10:24:49 +02:00
|
|
|
'telephone' => f('telephone'),
|
|
|
|
'email' => f('email')
|
|
|
|
]);
|
|
|
|
|
|
|
|
$r ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):'';
|
|
|
|
}
|
|
|
|
catch (UserException $e)
|
|
|
|
{
|
|
|
|
$form->addError($e->getMessage());
|
|
|
|
}
|
|
|
|
}, 'edit_client');
|
2019-11-02 17:53:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
$tpl->assign('client', $c);
|
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/client_modifier.tpl');
|