Migrate to Paheko 1.3

This commit is contained in:
Noizette 2023-08-01 22:56:38 +02:00
parent 161659acfb
commit 235f8ceeed
31 changed files with 95 additions and 94 deletions

View file

@ -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')]);

View file

@ -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)
{

View file

@ -1,6 +1,6 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';

View file

@ -1,12 +1,12 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);
qv(['id' => 'required|numeric']);
f(['id' => 'required|numeric']);
$id = (int) qg('id');

View file

@ -1,12 +1,12 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->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)
{

View file

@ -1,12 +1,12 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->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);

View file

@ -1,6 +1,6 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
@ -30,7 +30,7 @@ if(f('add'))
'email' => 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)
{

View file

@ -1,6 +1,6 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
@ -32,7 +32,7 @@ if (f('save') && $form->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');

View file

@ -1,16 +1,16 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->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);

View file

@ -1,12 +1,12 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->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)
{

View file

@ -1,6 +1,6 @@
<?php
namespace Garradin;
namespace Paheko;
require_once __DIR__ . '/_inc.php';

View file

@ -4,10 +4,11 @@ namespace Paheko;
require_once __DIR__ . '/_inc.php';
$session->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 :<br><br>'.
'<b>'.$config->get('nom_asso')."</b><br>".
str_replace("\n", '<br>', $config->get('adresse_asso'))."<br>".
str_replace("\n", '<br>', $config->get('org_address'))."<br>".
(($t = $plugin->getConfig('rna_asso'))?"RNA : $t<br>":'').
(($t = $plugin->getConfig('siret_asso'))?"SIRET : $t<br>":'').
(($t = $config->get('email_asso'))?"Email : $t<br>":'').