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_READ);
|
2019-11-02 17:53:27 +01:00
|
|
|
|
|
|
|
if(f('add'))
|
|
|
|
{
|
2019-11-03 17:51:31 +01:00
|
|
|
$form->check('add_client', [
|
|
|
|
'nom' => 'required|string',
|
|
|
|
'adresse' => 'required|string',
|
|
|
|
'code_postal' => 'required|string',
|
|
|
|
'ville' => 'required|string',
|
|
|
|
'telephone' => 'string',
|
|
|
|
'email' => 'email'
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (!$form->hasErrors())
|
|
|
|
{
|
2019-11-02 17:53:27 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
$id = $client->add([
|
2019-11-03 17:51:31 +01:00
|
|
|
'nom' => f('nom'),
|
|
|
|
'adresse' => f('adresse'),
|
|
|
|
'code_postal' => f('code_postal'),
|
|
|
|
'ville' => f('ville'),
|
|
|
|
'telephone' => f('telephone'),
|
|
|
|
'email' => f('email')
|
2019-11-02 17:53:27 +01:00
|
|
|
]);
|
|
|
|
|
2023-08-01 22:56:38 +02:00
|
|
|
$id ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):'';
|
2019-11-02 17:53:27 +01:00
|
|
|
}
|
|
|
|
catch (UserException $e)
|
|
|
|
{
|
|
|
|
$form->addError($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-17 13:01:05 +01:00
|
|
|
$list = $client->list();
|
|
|
|
$list->loadFromQueryString();
|
|
|
|
|
|
|
|
$tpl->assign(compact('list'));
|
2019-11-02 17:53:27 +01:00
|
|
|
|
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/clients.tpl');
|