Ajout des options de configuration pour reçus
This commit is contained in:
parent
64dc0d541d
commit
b18cd91aa4
10 changed files with 514 additions and 14 deletions
|
|
@ -11,9 +11,23 @@ if (f('save') && $form->check('facturation_config'))
|
|||
try {
|
||||
$plugin->setConfig('rna_asso', trim(f('rna_asso')));
|
||||
$plugin->setConfig('siret_asso', trim(f('siret_asso')));
|
||||
$plugin->setConfig('validate_cp', f('validate_cp'));
|
||||
$plugin->setConfig('unique_client_name', f('unique_name'));
|
||||
|
||||
$plugin->setConfig('numero_rue_asso', trim(f('numero_rue')));
|
||||
$plugin->setConfig('rue_asso', trim(f('rue')));
|
||||
$plugin->setConfig('cp_asso', trim(f('codepostal')));
|
||||
$plugin->setConfig('ville_asso', trim(f('ville')));
|
||||
|
||||
$plugin->setConfig('droit_art200', (bool)f('droit_art200'));
|
||||
$plugin->setConfig('droit_art238bis', (bool)f('droit_art238bis'));
|
||||
$plugin->setConfig('droit_art885-0VbisA', (bool)f('droit_art885-0VbisA'));
|
||||
$plugin->setConfig('objet_0', trim(f('objet_0')));
|
||||
$plugin->setConfig('objet_1', trim(f('objet_1')));
|
||||
$plugin->setConfig('objet_2', trim(f('objet_2')));;
|
||||
|
||||
$plugin->setConfig('footer', f('footer'));
|
||||
|
||||
$plugin->setConfig('validate_cp', (bool)f('validate_cp'));
|
||||
$plugin->setConfig('unique_client_name', (bool)f('unique_name'));
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
||||
}
|
||||
|
|
@ -23,12 +37,90 @@ if (f('save') && $form->check('facturation_config'))
|
|||
}
|
||||
}
|
||||
|
||||
// Traitement de l'image de signature
|
||||
// Copié du plugin de nfrery
|
||||
if (f('upload') || isset($_POST['uploadHelper_status']))
|
||||
{
|
||||
$form->check('signature_config');
|
||||
|
||||
if (f('uploadHelper_status') > 0)
|
||||
{
|
||||
throw new UserException('Un seul fichier peut être envoyé en même temps.');
|
||||
}
|
||||
elseif (!empty($_POST['fichier']) || isset($_FILES['fichier']))
|
||||
{
|
||||
try {
|
||||
if (isset($_POST['uploadHelper_status']) && !empty($_POST['fichier']))
|
||||
{
|
||||
$fichier = Fichiers::uploadExistingHash(f('fichier'), f('uploadHelper_fileHash'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$fichier = Fichiers::upload($_FILES['fichier']);
|
||||
}
|
||||
|
||||
// ?? je comprends pas tout dans ce bloc
|
||||
if (isset($_POST['uploadHelper_status']))
|
||||
{
|
||||
echo json_encode([
|
||||
'redirect' => WWW_URL,
|
||||
'callback' => 'insertHelper',
|
||||
'file' => [
|
||||
'image' => (int)$fichier->image,
|
||||
'id' => (int)$fichier->id,
|
||||
'nom' => $fichier->nom,
|
||||
'thumb' => $fichier->image ? $fichier->getURL(200) : false
|
||||
],
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$plugin->getConfig('signaturetxt') == "")
|
||||
{
|
||||
$fichier_old = new Fichiers($plugin->getConfig('signaturetxt'));
|
||||
$fichier_old->remove();
|
||||
}
|
||||
|
||||
Static_Cache::storeFromUpload('fichiers.'.$fichier->id, $fichier->nom);
|
||||
$plugin->setConfig('signaturetxt', $fichier->id);
|
||||
Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
throw new UserException($e->getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = 'Aucun fichier envoyé.';
|
||||
}
|
||||
}
|
||||
|
||||
if(!$plugin->getConfig('signaturetxt') == "")
|
||||
{
|
||||
$img1 = new Fichiers($plugin->getConfig('signaturetxt'));
|
||||
$cache_id = 'fichiers.' . $img1->id_contenu;
|
||||
|
||||
if (!Static_Cache::exists($cache_id))
|
||||
{
|
||||
$blob = DB::getInstance()->openBlob('fichiers_contenu', 'contenu', (int)$img1->id_contenu);
|
||||
Static_Cache::storeFromPointer($cache_id, $blob);
|
||||
fclose($blob);
|
||||
}
|
||||
|
||||
$uri = $img1->getURL();
|
||||
$tpl->assign('image', $uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->assign('image', false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$tpl->assign('ok', qg('ok') !== null);
|
||||
|
||||
$tpl->assign('rna_asso', $plugin->getConfig('rna_asso') ?: '');
|
||||
$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->assign('max_size', Utils::getMaxUploadSize());
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|
||||
|
|
|
|||
134
www/admin/generation.php
Normal file
134
www/admin/generation.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
namespace Garradin;
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ADMIN);
|
||||
|
||||
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
throw new UserException("Le numéro du reçu fiscal est manquant.");
|
||||
}
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
|
||||
$gendon = new Plugin\RecuDon\GenDon;
|
||||
|
||||
$recu = $gendon->get($id);
|
||||
|
||||
require_once PLUGIN_ROOT . '/lib/MPDF/vendor/autoload.php';
|
||||
|
||||
// require_once(PLUGIN_ROOT . '/lib/fpdf/fpdf.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/pdf_context.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/pdf_parser.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi_pdf_parser.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi_bridge.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdf_tpl.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi.php');
|
||||
|
||||
$pdf = new \Mpdf\Mpdf([
|
||||
'default_font_size' => 10,
|
||||
'default_font' => 'Helvetica',
|
||||
]);
|
||||
|
||||
$pdf->AddPage();
|
||||
$pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
|
||||
$pdf->useTemplate(
|
||||
$pdf->importPage(1)
|
||||
);
|
||||
|
||||
$pdf->SetTextColor(0);
|
||||
$pdf->WriteText(180, 18, $recu->gen_ordre);
|
||||
$pdf->WriteText(20, 43, $config->get('nom_asso'));
|
||||
$pdf->WriteText(24, 53, utf8_decode($plugin->getConfig('numero_rue')));
|
||||
$pdf->SetXY(42,53);
|
||||
$pdf->Write(0, utf8_decode($plugin->getConfig('rue')));
|
||||
$pdf->SetXY(38,59);
|
||||
$pdf->Write(0, utf8_decode($plugin->getConfig('codepostal')));
|
||||
$pdf->SetXY(72,59);
|
||||
$pdf->Write(0, utf8_decode($plugin->getConfig('ville')));
|
||||
$pdf->SetXY(20,69);
|
||||
$pdf->Write(0, utf8_decode($plugin->getConfig('objet0')));
|
||||
$pdf->SetXY(20,73);
|
||||
$pdf->Write(0, utf8_decode($plugin->getConfig('objet1')));
|
||||
$pdf->SetXY(20,77);
|
||||
$pdf->Write(0, utf8_decode($plugin->getConfig('objet2')));
|
||||
$pdf->SetXY(19,135);
|
||||
$pdf->Write(0, "X");
|
||||
|
||||
$pdf->AddPage();
|
||||
$pdf->useTemplate(
|
||||
$pdf->importPage(2)
|
||||
);
|
||||
|
||||
$pdf->SetXY(18,25);
|
||||
$pdf->Write(0, $recu->nom);
|
||||
$pdf->SetXY(108,25);
|
||||
$pdf->Write(0, $recu->prenom);
|
||||
$pdf->SetXY(18,38);
|
||||
$pdf->Write(0, utf8_decode($recu->adresse));
|
||||
$pdf->SetXY(38,44);
|
||||
$pdf->Write(0, $recu->codepostal);
|
||||
$pdf->SetXY(78,44);
|
||||
$pdf->Write(0, utf8_decode($recu->ville));
|
||||
$pdf->SetXY(85,69); // Somme en chiffre
|
||||
$pdf->Write(0, utf8_decode("***".$recu->montant."***"));
|
||||
$pdf->SetXY(58,79); // Somme en toute lettre
|
||||
$pdf->Write(0, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($recu->montant)) . ' euros');
|
||||
$date = date_parse($recu->date);
|
||||
|
||||
$pdf->SetXY(70,88); // Jour du don
|
||||
$pdf->Write(0, $date['day']);
|
||||
$pdf->SetXY(81,88); // Mois du don
|
||||
$pdf->Write(0, $date['month']);
|
||||
$pdf->SetXY(97,88); // Année du don
|
||||
$pdf->Write(0, $date['year']);
|
||||
if($plugin->getConfig('droit_art200')){
|
||||
$pdf->SetXY(56.5,103); // 200
|
||||
$pdf->Write(0, "X");
|
||||
}
|
||||
if($plugin->getConfig('droit_art238bis')){
|
||||
$pdf->SetXY(106.5,103); // 238 bis
|
||||
$pdf->Write(0, "X");
|
||||
}
|
||||
if($plugin->getConfig('droit_art885-0VbisA')){
|
||||
$pdf->SetXY(156.5,103); // 885-0 V bis A
|
||||
$pdf->Write(0, "X");
|
||||
}
|
||||
$pdf->SetXY(119,120.5); // Déclaration de don manuel
|
||||
$pdf->Write(0, "X");
|
||||
$pdf->SetXY(19,142.5); // Numéraire
|
||||
$pdf->Write(0, "X");
|
||||
switch ($recu->mode_paiement){
|
||||
case 0:
|
||||
$pdf->SetXY(19,165); // Remise d'espèces
|
||||
$pdf->Write(0, "X");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$pdf->SetXY(61.5,165); // Chèque
|
||||
$pdf->Write(0, "X");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$pdf->SetXY(119,165); // Virement, prélèvement, carte bancaire
|
||||
$pdf->Write(0, "X");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$pdf->SetXY(143,245); // Jour de l'édition du document
|
||||
$pdf->Write(0, date('d'));
|
||||
$pdf->SetXY(151,245); // Mois de l'édition du document
|
||||
$pdf->Write(0, date('m'));
|
||||
$pdf->SetXY(158,245); // Année de l'édition du document
|
||||
$pdf->Write(0, date('y'));
|
||||
$img = new Fichiers($plugin->getConfig('signaturetxt'));
|
||||
$cache_id = 'fichiers.' . $img->id_contenu;
|
||||
if (!Static_Cache::exists($cache_id))
|
||||
{
|
||||
$blob = DB::getInstance()->openBlob('fichiers_contenu', 'contenu', (int)$img->id_contenu);
|
||||
Static_Cache::storeFromPointer($cache_id, $blob);
|
||||
fclose($blob);
|
||||
}
|
||||
$uri = Static_Cache::getPath($cache_id);
|
||||
$pdf->Image($uri, 140, 247, 50, 0, 'PNG' ); // Emplacement de la signature avec restriction de largeur pour tenir dans sur la case.
|
||||
$pdf->Output($recu->gen_ordre.".pdf", "I");
|
||||
19
www/admin/recu.php
Normal file
19
www/admin/recu.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
namespace Garradin;
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ADMIN);
|
||||
|
||||
$error = false;
|
||||
|
||||
if (isset($_GET['ok']))
|
||||
{
|
||||
$error = 'OK';
|
||||
}
|
||||
|
||||
$recus = new Plugin\RecuDon\GenDon;
|
||||
|
||||
$trecus = $recus->listSimple();
|
||||
|
||||
$tpl->assign('trecus', $trecus);
|
||||
$tpl->assign('error', $error);
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/recu.tpl');
|
||||
44
www/admin/supprimer.php
Normal file
44
www/admin/supprimer.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace Garradin;
|
||||
|
||||
if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
|
||||
{
|
||||
throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
|
||||
}
|
||||
|
||||
$gendon = new Plugin\RecuDon\GenDon;
|
||||
|
||||
$recu = $gendon->get(Utils::get('id'));
|
||||
|
||||
if (!$recu)
|
||||
{
|
||||
throw new UserException("Le reçu demandé n'existe pas.");
|
||||
}
|
||||
|
||||
$error = false;
|
||||
|
||||
if (!empty($_POST['remove']))
|
||||
{
|
||||
if (!Utils::CSRF_check('recu_supprimer_'.$recu['id']))
|
||||
{
|
||||
$error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$gendon->remove($recu['id']);
|
||||
Utils::redirect(PLUGIN_URL . 'recu.php');
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->assign('error', $error);
|
||||
|
||||
$tpl->assign('recu', $recu);
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/supprimer.tpl');
|
||||
Loading…
Add table
Add a link
Reference in a new issue