requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ); $form->runIf(f('add') && !$form->hasErrors(), function () use ($client) { try { $id = $client->add([ 'nom' => f('nom'), 'adresse' => f('adresse'), 'code_postal' => f('code_postal'), 'ville' => f('ville'), 'telephone' => f('telephone'), 'email' => f('email') ]); $id ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):''; } catch (UserException $e) { $form->addError($e->getMessage()); } }, 'add_client'); $list = $client->list(); $list->loadFromQueryString(); $tpl->assign(compact('list')); $tpl->display(PLUGIN_ROOT . '/templates/clients.tpl');