diff --git a/LICENCE b/LICENCE index ad1b3a4..a94d78e 100644 --- a/LICENCE +++ b/LICENCE @@ -1,4 +1,4 @@ -Plugin Facturation pour Garradin +Plugin Facturation pour Paheko Copyright (C) 2019 zou This program is free software: you can redistribute it and/or modify diff --git a/admin/_facture_common.php b/admin/_facture_common.php index 32b951c..cfed2b3 100644 --- a/admin/_facture_common.php +++ b/admin/_facture_common.php @@ -14,7 +14,7 @@ $session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE); use Paheko\DB; use stdClass; -use const \Garradin\Plugin\Facturation\PATTERNS_LIST; +use const \Paheko\Plugin\Facturation\PATTERNS_LIST; $db = DB::getInstance(); @@ -39,7 +39,7 @@ $tpl->assign('natures_don', array('1' => 'Numéraire', $tpl->assign('textes_don', $facture->listTextesCerfa()); if ( !$target ) { - qv(['id' => 'required|numeric']); + f(['id' => 'required|numeric']); $id = (int) qg('id'); if (!$f = $facture->get($id)) @@ -200,13 +200,13 @@ elseif (isset($data)) if ($target) { $id = $facture->add($data, $plugin->getConfig('pattern')); - Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id); + Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id); } else { if ($facture->edit($id, $data)) { - Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id); + Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id); } throw new UserException('Erreur d\'édition du reçu'); } @@ -324,7 +324,7 @@ $tpl->assign('date', $date->format('d/m/Y')); $tpl->assign(compact('liste', 'radio', 'step', 'designations', 'prix', 'from_user', 'identite', 'csrf_key', 'doc')); -$tpl->assign('membres', $db->getAssoc('SELECT id, '.$identite.' FROM membres WHERE id_category != -2 NOT IN (SELECT id FROM users_categories WHERE hidden = 1);')); +$tpl->assign('users', $db->getAssoc('SELECT id, '.$identite.' FROM users WHERE id_category != -2 NOT IN (SELECT id FROM users_categories WHERE hidden = 1);')); $tpl->assign('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;')); $tpl->assign('require_number', $require_number); $tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]); diff --git a/admin/_inc.php b/admin/_inc.php index 01cbd47..25c365b 100644 --- a/admin/_inc.php +++ b/admin/_inc.php @@ -25,11 +25,11 @@ const PATTERNS_LIST = [ $client = new Client; $facture = new Facture; -$tpl->assign('www_url', \Garradin\WWW_URL); +$tpl->assign('www_url', \Paheko\WWW_URL); $tpl->assign('f_obj', $facture); -$tpl->assign('plugin_url', Utils::plugin_url()); -$identite = (string) Config::getInstance()->get('champ_identite'); + +$identite = implode( '', \Paheko\Users\DynamicFields::getNameFields()); $tpl->register_function('money_fac', function (array $params) { diff --git a/admin/aide.php b/admin/aide.php index 227e783..e10ada5 100644 --- a/admin/aide.php +++ b/admin/aide.php @@ -1,6 +1,6 @@ requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ); -qv(['id' => 'required|numeric']); +f(['id' => 'required|numeric']); $id = (int) qg('id'); diff --git a/admin/client_modifier.php b/admin/client_modifier.php index 067619a..cdfd0aa 100644 --- a/admin/client_modifier.php +++ b/admin/client_modifier.php @@ -1,12 +1,12 @@ requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE); -qv(['id' => 'required|numeric']); +f(['id' => 'required|numeric']); $id = (int) qg('id'); $c = $client->get($id); @@ -40,7 +40,7 @@ if(f('save')) 'email' => f('email') ]); - $r ? Utils::redirect(PLUGIN_URL . 'client.php?id='.(int)$id):''; + $r ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):''; } catch (UserException $e) { diff --git a/admin/client_supprimer.php b/admin/client_supprimer.php index d810142..64a3395 100644 --- a/admin/client_supprimer.php +++ b/admin/client_supprimer.php @@ -1,12 +1,12 @@ requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE); -qv(['id' => 'required|numeric']); +f(['id' => 'required|numeric']); $id = (int) qg('id'); @@ -21,7 +21,7 @@ $csrf_key = 'delete_client_'.$c->id; $form->runIf('delete', function () use ($client, $c) { $client->delete($c->id); -}, $csrf_key, PLUGIN_URL . 'clients.php'); +}, $csrf_key, PLUGIN_ADMIN_URL . 'clients.php'); $tpl->assign('deletable', $client->isDeletable($id)); $tpl->assign('client', $c); diff --git a/admin/clients.php b/admin/clients.php index a470ee7..f5adf78 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -1,6 +1,6 @@ f('email') ]); - $id ? Utils::redirect(PLUGIN_URL . 'client.php?id='.(int)$id):''; + $id ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):''; } catch (UserException $e) { diff --git a/admin/config.php b/admin/config.php index 2b818b8..2e9198a 100644 --- a/admin/config.php +++ b/admin/config.php @@ -1,6 +1,6 @@ check('facturation_config')) $plugin->setConfig('pattern', f('pattern')); - Utils::redirect(PLUGIN_URL . 'config.php?ok'); + Utils::redirect(PLUGIN_ADMIN_URL . 'config.php?ok'); } catch (UserException $e) { @@ -43,6 +43,6 @@ if (f('save') && $form->check('facturation_config')) $tpl->assign('ok', qg('ok') !== null); -$tpl->assign('patterns', \Garradin\Plugin\Facturation\PATTERNS_LIST); +$tpl->assign('patterns', \Paheko\Plugin\Facturation\PATTERNS_LIST); $tpl->display(PLUGIN_ROOT . '/templates/config.tpl'); diff --git a/admin/facture.php b/admin/facture.php index 72f3b71..e0044b5 100644 --- a/admin/facture.php +++ b/admin/facture.php @@ -1,16 +1,16 @@ requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ); -use Garradin\Membres; +use Paheko\Users\Users; -$membres = new Membres; +$users = new Users; -qv(['id' => 'required|numeric']); +f(['id' => 'required|numeric']); $id = (int) qg('id'); $f = $facture->get($id); diff --git a/admin/facture_supprimer.php b/admin/facture_supprimer.php index f12f48e..04e5918 100644 --- a/admin/facture_supprimer.php +++ b/admin/facture_supprimer.php @@ -1,12 +1,12 @@ requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE); -qv(['id' => 'required|numeric']); +f(['id' => 'required|numeric']); $id = (int) qg('id'); @@ -25,7 +25,7 @@ if (f('delete')) { try { $facture->delete($f->id); - Utils::redirect(PLUGIN_URL . 'index.php'); + Utils::redirect(PLUGIN_ADMIN_URL . 'index.php'); } catch (UserException $e) { diff --git a/admin/index.php b/admin/index.php index 8a6f7fe..e402ec5 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,6 +1,6 @@ requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ); -$membres = new Membres; +$users = new Users\Users; -qv(['id' => 'required|numeric']); +f(['id' => 'required|numeric']); $id = (int) qg('id'); +$id_field = Users\DynamicFields::getNameFieldsSQL(); // Vérification que le document existe if (!$f = $facture->get($id)) @@ -22,8 +23,8 @@ try { if ($f->receveur_membre) { - $c = $membres->get($f->receveur_id); - $c->identite = $c->$identite; + $c = $users->get($f->receveur_id); + $c->$id_field = $c->$identite; foreach(['ville','code_postal','adresse'] as $v) { if($c->$v == '') @@ -35,7 +36,7 @@ try else { $c = $client->get($f->receveur_id); - $c->identite = $c->nom; + $c->$id_field = $c->nom; } } catch(UserException $e) @@ -72,7 +73,7 @@ if ($f->type_facture != CERFA) $asso = // 'Émis par :

'. ''.$config->get('nom_asso')."
". - str_replace("\n", '
', $config->get('adresse_asso'))."
". + str_replace("\n", '
', $config->get('org_address'))."
". (($t = $plugin->getConfig('rna_asso'))?"RNA : $t
":''). (($t = $plugin->getConfig('siret_asso'))?"SIRET : $t
":''). (($t = $config->get('email_asso'))?"Email : $t
":''). diff --git a/lib/Client.php b/lib/Client.php index d914047..5fc6044 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -1,12 +1,12 @@ champ_identite; + $id_field = \Paheko\Users\DynamicFields::getNameFieldsSQL('u'); $columns = [ // Sélectionner cette colonne, mais ne pas la mettre dans la liste des colonnes @@ -324,7 +324,7 @@ class Facture ], 'receveur' => [ 'label' => 'Receveur', - 'select' => sprintf('CASE WHEN receveur_membre THEN u.%s ELSE c.nom END', $id_field), + 'select' => sprintf('CASE WHEN receveur_membre THEN %s ELSE c.nom END', $id_field), ], 'receveur_adresse' => [ 'label' => 'Son adresse', @@ -361,7 +361,7 @@ class Facture $tables = 'plugin_facturation_factures AS f INNER JOIN plugin_facturation_paiement AS mp ON mp.code = f.moyen_paiement - LEFT JOIN membres AS u ON f.receveur_membre = 1 AND u.id = f.receveur_id + LEFT JOIN users AS u ON f.receveur_membre = 1 AND u.id = f.receveur_id LEFT JOIN plugin_facturation_clients AS c ON f.receveur_membre = 0 AND c.id = f.receveur_id'; $list = new DynamicList($columns, $tables); @@ -425,7 +425,7 @@ class Facture } else // Si c'est un membre de l'asso { - throw new UserException("Woopsie, g pô encore implémenté l'usage des membres de l'asso comme clients"); + throw new UserException("Woopsie, g pô encore implémenté l'usage des users de l'asso comme clients"); } $r = (array)DB::getInstance()->get('SELECT *, strftime(\'%s\', date_emission) AS date_emission, @@ -457,7 +457,7 @@ class Facture } else // Si c'est un membre de l'asso { - throw new UserException("Woopsie, g pô encore implémenté l'usage des membres de l'asso comme clients"); + throw new UserException("Woopsie, g pô encore implémenté l'usage des users de l'asso comme clients"); } return DB::getInstance()->test('plugin_facturation_factures', 'receveur_membre = ? AND receveur_id = ?', $base, $id); @@ -526,6 +526,6 @@ class Facture public static function menuItem(array $params, array &$list): void { - $list['plugin_facturation'] = sprintf('Facturation', \Garradin\ADMIN_URL); + $list['plugin_facturation'] = sprintf('Facturation', \Paheko\ADMIN_URL); } } diff --git a/templates/_form.tpl b/templates/_form.tpl index be25486..1330a4e 100644 --- a/templates/_form.tpl +++ b/templates/_form.tpl @@ -72,7 +72,7 @@
- {input type="select" name="membre" label="Membre" options=$membres required=1 source=$doc} + {input type="select" name="membre" label="Membre" options=$users required=1 source=$doc}
{if !empty($clients)} @@ -162,7 +162,7 @@
- {input type="select" name="membre_cotis" label="Membre" options=$membres required=1 default=$doc.membre} + {input type="select" name="membre_cotis" label="Membre" options=$users required=1 default=$doc.membre}
diff --git a/templates/_list_actions.tpl b/templates/_list_actions.tpl index c99c888..4e7ae63 100644 --- a/templates/_list_actions.tpl +++ b/templates/_list_actions.tpl @@ -4,7 +4,7 @@ PAS FONCTIONNEL - Pour les client·es coché·es : - {csrf_field key="membres_action"} + {csrf_field key="users_action"}