Migration de Facturation\Config à la gestion de conf intégrée à Garradin

This commit is contained in:
Noizette 2020-10-24 01:00:48 +02:00
parent 4b3fa030d8
commit 33b9f05062
11 changed files with 91 additions and 82 deletions

View file

@ -2,11 +2,8 @@
namespace Garradin;
use Garradin\Plugin\Facturation\Config;
use Garradin\Plugin\Facturation\Facture;
use Garradin\Plugin\Facturation\Client;
$cfg = Config::getInstance();
$client = new Client;
$facture = new Facture;

View file

@ -9,12 +9,10 @@ $session->requireAccess('compta', Membres::DROIT_ADMIN);
if (f('save') && $form->check('facturation_config'))
{
try {
$cfg->set('siret_asso', f('siret_asso'));
$cfg->set('validate_cp', f('validate_cp'));
$cfg->set('unique_client_name', f('unique_name'));
$cfg->set('footer', f('footer'));
$cfg->save();
$plugin->setConfig('siret_asso', f('siret_asso'));
$plugin->setConfig('validate_cp', f('validate_cp'));
$plugin->setConfig('unique_client_name', f('unique_name'));
$plugin->setConfig('footer', f('footer'));
Utils::redirect(PLUGIN_URL . 'config.php?ok');
}
@ -23,12 +21,15 @@ if (f('save') && $form->check('facturation_config'))
$form->addError($e->getMessage());
}
}
// var_dump($plugin->getInfos());
$infos = $plugin->getInfos();
var_dump($infos->version);
$tpl->assign('ok', qg('ok') !== null);
$tpl->assign('siret_asso', $cfg->get('siret_asso') ?: '');
$tpl->assign('footer', $cfg->get('footer') ?: '');
$tpl->assign('validate_cp', $cfg->get('validate_cp') ? 'checked':'');
$tpl->assign('unique_name', $cfg->get('unique_client_name') ? 'checked':'');
$tpl->assign('siret_asso', $plugin->getConfig('siret_asso') ?: '');
$tpl->assign('footer', $plugin->getConfig('footer') ?: '');
$tpl->assign('validate_cp', $plugin->getConfig('validate_cp') ? 'checked':'');
$tpl->assign('unique_name', $plugin->getConfig('unique_client_name') ? 'checked':'');
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');

View file

@ -51,7 +51,7 @@ catch(UserException $e)
}
$tpl->assign('id', $id);
$tpl->assign('footer', $cfg->get('footer')?:'');
$tpl->assign('siret_asso', $cfg->get('siret_asso')?:'');
$tpl->assign('footer', $plugin->getConfig('footer')?:'');
$tpl->assign('siret_asso', $plugin->getConfig('siret_asso')?:'');
$tpl->display(PLUGIN_ROOT . '/templates/facture.tpl');

View file

@ -48,56 +48,56 @@ if(f('save'))
if ( count(f('designation')) !== count(f('prix')) )
{
throw new UserException('Nombre de désignations et de prix reçus différent.');
}
}
$truc = [
'numero' => f('numero_facture'),
'date_emission' => f('date_emission'),
'date_echeance' => f('date_echeance'),
'reglee' => f('reglee') == 'on'?1:0,
'archivee' => f('archivee') == 'on'?1:0,
'moyen_paiement' => f('moyen_paiement'),
'toto' => 0
];
$truc = [
'numero' => f('numero_facture'),
'date_emission' => f('date_emission'),
'date_echeance' => f('date_echeance'),
'reglee' => f('reglee') == 'on'?1:0,
'archivee' => f('archivee') == 'on'?1:0,
'moyen_paiement' => f('moyen_paiement'),
'toto' => 0
];
if (f('type') == 'facture')
{
$truc['type_facture'] = 1;
}
elseif (f('type') == 'devis')
{
$truc['type_facture'] = 0;
}
if (f('type') == 'facture')
{
$truc['type_facture'] = 1;
}
elseif (f('type') == 'devis')
{
$truc['type_facture'] = 0;
}
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = f('prix')[$k];
$truc['toto'] += f('prix')[$k];
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = f('prix')[$k];
$truc['toto'] += f('prix')[$k];
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
if (f('base_receveur') == 'client')
{
$truc['receveur_membre'] = 0;
$truc['receveur_id'] = f('client');
}
elseif (f('base_receveur') == 'membre')
{
$truc['receveur_membre'] = 1;
$truc['receveur_id'] = f('membre');
}
if (f('base_receveur') == 'client')
{
$truc['receveur_membre'] = 0;
$truc['receveur_id'] = f('client');
}
elseif (f('base_receveur') == 'membre')
{
$truc['receveur_membre'] = 1;
$truc['receveur_id'] = f('membre');
}
$r = $facture->edit($id, $truc);
$r = $facture->edit($id, $truc);
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
}
catch(UserException $e)
{
$form->addError($e->getMessage());
}
}
catch(UserException $e)
{
$form->addError($e->getMessage());
}
}
}

View file

@ -64,7 +64,7 @@ $asso =
// 'Émis par :<br><br>'.
'<b>'.$config->get('nom_asso')."</b><br>".
str_replace("\n", '<br>', $config->get('adresse_asso'))."<br>".
(($t = $cfg->get('siret_asso'))?"SIRET : $t<br>":'').
(($t = $plugin->getConfig('siret_asso'))?"SIRET : $t<br>":'').
(($t = $config->get('email_asso'))?"Email : $t<br>":'').
(($t = $config->get('site_asso'))?"Site web : $t<br>":'');
@ -80,7 +80,7 @@ $total = number_format($f->total, 2, ',', ' ');
$echeance = date('d/m/Y' ,$f->date_echeance);
$echeance = ($f->type_facture?'Échéance de paiement':'Échéance du devis')." : ".$echeance;
$reglee = !$f->reglee?'Cette facture est en attente de règlement.':'Cette facture a été reglée.';
$footer = str_replace("\n", '<br>', $cfg->get('footer'));
$footer = str_replace("\n", '<br>', $plugin->getConfig('footer'));
echo <<<EOF