Force reçu-cotis à rentrer dans les cases + style pdf
This commit is contained in:
parent
a7b73bf356
commit
5a9c498eee
11 changed files with 691 additions and 62 deletions
119
www/admin/cotis_ajouter.php
Normal file
119
www/admin/cotis_ajouter.php
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
||||
|
||||
use Garradin\DB;
|
||||
|
||||
$db = DB::getInstance();
|
||||
|
||||
|
||||
$step = $radio = false;
|
||||
$liste = [];
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
if (f('select'))
|
||||
{
|
||||
$form->check('add_cotis_1',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
]);
|
||||
|
||||
$step = true;
|
||||
}
|
||||
elseif (f('add'))
|
||||
{
|
||||
$form->check('add_cotis_2',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
'cotisation' => 'required',
|
||||
]);
|
||||
|
||||
$radio = f('cotisation');
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$num = (int) str_replace('cotis_', '', $radio);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$cotis[$field] = f($field.'_'.$num);
|
||||
}
|
||||
|
||||
$r = $db->get('SELECT moyen_paiement, montant FROM membres_operations AS mo INNER JOIN compta_journal AS cj ON cj.id = mo.id_operation
|
||||
WHERE mo.id_cotisation = ?;', (int)$cotis['id']);
|
||||
$r = $r[0];
|
||||
|
||||
$data = [
|
||||
'type_facture' => 3,
|
||||
'numero' => f('numero_facture'),
|
||||
'receveur_membre' => 1,
|
||||
'receveur_id' => f('membre'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'moyen_paiement' => $r->moyen_paiement,
|
||||
'total' => $r->montant,
|
||||
'contenu' => ['id' => $cotis['id'],
|
||||
'intitule' => $cotis['intitule'],
|
||||
'souscription' => $cotis['date'],
|
||||
'expiration' => $cotis['expiration'] ]
|
||||
];
|
||||
|
||||
$id = $facture->add($data);
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$step = true;
|
||||
}
|
||||
|
||||
|
||||
if ($step)
|
||||
{
|
||||
try
|
||||
{
|
||||
$r = $facture->getCotis((int)f('membre'));
|
||||
// Passe les expiration nulles (cotis ponctuelle) à 0 pour avoir moins d'embrouilles
|
||||
foreach ($r as $i=>$cotis)
|
||||
{
|
||||
foreach($cotis as $k=>$v)
|
||||
{
|
||||
if (in_array($k, $fields))
|
||||
{
|
||||
$liste[$i][$k] = $v;
|
||||
}
|
||||
}
|
||||
if($liste[$i]['expiration'] < 0)
|
||||
{
|
||||
$liste[$i]['expiration'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tpl->assign('liste', $liste);
|
||||
$tpl->assign('radio', $radio);
|
||||
|
||||
$tpl->assign('step', $step);
|
||||
$tpl->assign('identite', $identite);
|
||||
$tpl->assign('membre_id', f('membre') ?: -1);
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/cotis_ajouter.tpl');
|
||||
144
www/admin/cotis_modifier.php
Normal file
144
www/admin/cotis_modifier.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
||||
|
||||
use Garradin\DB;
|
||||
|
||||
$db = DB::getInstance();
|
||||
|
||||
|
||||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
||||
if (!$f = $facture->get($id))
|
||||
{
|
||||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
$membre_id = f('membre') ?: $f->receveur_id;
|
||||
|
||||
$values['numero_facture'] = $f->numero;
|
||||
$values['date_emission'] = date('Y-m-d', $f->date_emission);
|
||||
|
||||
$radio = '';
|
||||
$liste = [];
|
||||
|
||||
|
||||
if (f('select'))
|
||||
{
|
||||
$form->check('add_cotis_1',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
]);
|
||||
|
||||
}
|
||||
elseif (f('add'))
|
||||
{
|
||||
$form->check('add_cotis_2',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
'cotisation' => 'required',
|
||||
]);
|
||||
|
||||
$radio = f('cotisation');
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$num = (int) str_replace('cotis_', '', $radio);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$cotis[$field] = f($field.'_'.$num);
|
||||
}
|
||||
|
||||
$cotis['date'] = date('Y-m-d', $cotis['date']);
|
||||
$cotis['expiration'] = date('Y-m-d', $cotis['expiration']);
|
||||
|
||||
var_export($cotis);
|
||||
// die();
|
||||
|
||||
$r = $db->get('SELECT moyen_paiement, montant FROM membres_operations AS mo INNER JOIN compta_journal AS cj ON cj.id = mo.id_operation
|
||||
WHERE mo.id_cotisation = ?;', (int)$cotis['id']);
|
||||
$r = $r[0];
|
||||
|
||||
$data = [
|
||||
'type_facture' => 3,
|
||||
'numero' => f('numero_facture'),
|
||||
'receveur_membre' => 1,
|
||||
'receveur_id' => f('membre'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'moyen_paiement' => $r->moyen_paiement,
|
||||
'total' => $r->montant,
|
||||
'contenu' => ['id' => $cotis['id'],
|
||||
'intitule' => $cotis['intitule'],
|
||||
'souscription' => $cotis['date'],
|
||||
'expiration' => $cotis['expiration'] ]
|
||||
];
|
||||
|
||||
if($facture->edit($id, $data))
|
||||
{
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
throw new UserException('Erreur d\'édition du reçu');
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
$r = $facture->getCotis((int)$membre_id);
|
||||
// Garde seulement les champs requis
|
||||
// Rattrape le bouton radio à pré-sélectionner
|
||||
// Passe les expiration nulles (cotis ponctuelle) à 0 pour avoir moins d'embrouilles
|
||||
foreach ($r as $i=>$cotis)
|
||||
{
|
||||
foreach($cotis as $k=>$v)
|
||||
{
|
||||
if (in_array($k, $fields))
|
||||
{
|
||||
$liste[$i][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if($liste[$i]['id'] == $f->contenu['id'])
|
||||
{
|
||||
$radio = 'cotis_'.$i;
|
||||
}
|
||||
|
||||
if($liste[$i]['expiration'] < 0)
|
||||
{
|
||||
$liste[$i]['expiration'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
$tpl->assign('liste', $liste);
|
||||
$tpl->assign('radio', $radio);
|
||||
$tpl->assign('values', $values);
|
||||
|
||||
// $tpl->assign('step', $step);
|
||||
$tpl->assign('identite', $identite);
|
||||
$tpl->assign('membre_id', $membre_id);
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/cotis_modifier.tpl');
|
||||
|
|
@ -98,6 +98,25 @@ if (f('add'))
|
|||
|
||||
}
|
||||
|
||||
$type = qg('t');
|
||||
$radio = [];
|
||||
if (is_numeric($type))
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
case 0:
|
||||
$radio['type'] = 'devis';
|
||||
break;
|
||||
case 2:
|
||||
$radio['type'] = 'cerfa';
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
$radio['type'] = 'facture';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tpl->assign('radio', $radio);
|
||||
|
||||
$tpl->assign('client_id', f('client') ?: -1);
|
||||
$tpl->assign('membre_id', f('membre') ?: -1);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ use Garradin\DB;
|
|||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
||||
$f = $facture->get($id);
|
||||
|
||||
if (!$f)
|
||||
if (!$f = $facture->get($id))
|
||||
{
|
||||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,54 +322,139 @@ elseif ($f->type_facture == 3)
|
|||
ob_start();
|
||||
|
||||
$doc = 'Reçu n°'.$f->numero;
|
||||
$emission = date('d/m/Y' ,$f->date_emission);
|
||||
$emission = date('d/m/Y',$f->date_emission);
|
||||
$pdf->SetTitle($doc.' - '.$emission);
|
||||
|
||||
|
||||
$asso =
|
||||
// 'Émis par :<br><br>'.
|
||||
'<b>'.$config->get('nom_asso')."</b><br>".
|
||||
str_replace("\n", '<br>', $config->get('adresse_asso'))."<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>":'').
|
||||
(($t = $config->get('site_asso'))?"Site web : $t<br>":'');
|
||||
|
||||
// 'Émis par :<br><br>'.
|
||||
'<b>'.$config->get('nom_asso')."</b><br>".
|
||||
str_replace("\n", '<br>', $config->get('adresse_asso'))."<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>":'').
|
||||
(($t = $config->get('site_asso'))?"Site web : $t<br>":'');
|
||||
|
||||
$receveur =
|
||||
'Adressé à :<br><br>'.
|
||||
'<b>'.$c->identite.'</b><br>'.
|
||||
$c->adresse."<br>".
|
||||
$c->code_postal.' '.$c->ville."<br>".
|
||||
(($t = $c->email)?"Email : $t<br>":'').
|
||||
(($t = $c->telephone)?"Tel : $t<br>":'');
|
||||
|
||||
'Adressé à :<br><br>'.
|
||||
'<b>'.$c->identite.'</b><br>'.
|
||||
$c->adresse."<br>".
|
||||
$c->code_postal.' '.$c->ville."<br>".
|
||||
(($t = $c->email)?"Email : $t<br>":'').
|
||||
(($t = $c->telephone)?"Tel : $t<br>":'');
|
||||
|
||||
$total = number_format($f->total, 2, ',', ' ');
|
||||
$echeance = date('d/m/Y' ,$f->date_echeance);
|
||||
$footer = str_replace("\n", '<br>', $plugin->getConfig('footer'));
|
||||
|
||||
$lieu = $plugin->getConfig('ville_asso');
|
||||
$intitule = $f->contenu['intitule'];
|
||||
|
||||
$souscription = date('d/m/Y', strtotime($f->contenu['souscription']));
|
||||
|
||||
if($f->contenu['expiration'] == '1970-01-01')
|
||||
{
|
||||
$expiration = "jour même, s'agissant d'une cotisation ponctuelle.";
|
||||
}
|
||||
else {
|
||||
$expiration = date('d/m/Y', strtotime($f->contenu['expiration']));
|
||||
}
|
||||
|
||||
|
||||
echo <<<EOF
|
||||
$doc
|
||||
<!-- STYLE -->
|
||||
|
||||
<style>
|
||||
.titre {
|
||||
text-align: center;
|
||||
font-size: 8pt;
|
||||
position: absolute;
|
||||
top: 6mm;
|
||||
width: 180mm;
|
||||
}
|
||||
.h2 {
|
||||
margin: 25 20 0 20;
|
||||
}
|
||||
.h2 span {
|
||||
font-weight: bold;
|
||||
font-size: 15pt;
|
||||
}
|
||||
hr {
|
||||
margin: 5 0 20 0;
|
||||
}
|
||||
.adressage {
|
||||
font-size: 11pt;
|
||||
}
|
||||
.adressage td {
|
||||
width: 95mm;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.contenu td, .contenu th {
|
||||
vertical-align: top;
|
||||
padding: 8 10;
|
||||
margin : 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.contenu tr th, .contenu tr td {
|
||||
text-align: right;
|
||||
width: 16%;
|
||||
}
|
||||
.contenu tr td:nth-child(1), .contenu tr th:nth-child(1) {
|
||||
text-align: left;
|
||||
width: 84%;
|
||||
}
|
||||
|
||||
.contenu thead tr, .contenu tfoot tr {
|
||||
background-color: #CCE;
|
||||
border: 10px solid black;
|
||||
}
|
||||
.contenu tbody tr:nth-child(even) {
|
||||
background-color: #DDF;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
margin: 14mm 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!-- CONTENU -->
|
||||
<br>
|
||||
<p class="titre">
|
||||
$doc - Émis le $emission
|
||||
</p>
|
||||
|
||||
<table class="adressage">
|
||||
<tr>
|
||||
<td>$asso</td>
|
||||
<td>$receveur</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<div class="h2">
|
||||
<span>Reçu de votre cotisation</span> - $doc
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<br><br>
|
||||
$asso
|
||||
Bonjour,
|
||||
<br><br>
|
||||
$receveur
|
||||
<br><br>
|
||||
À $lieu, le $echeance,
|
||||
À $lieu, le $emission,
|
||||
<br><br>
|
||||
|
||||
Nous accusons réception de votre cotisation reçue le $emission et nous vous en remercions.
|
||||
Nous accusons réception de votre cotisation « $intitule » reçue le $emission et nous vous en remercions.
|
||||
<br><br>
|
||||
Nous reconnaissons que vous avez acquitté la somme de $total € par $moyen_paiement .
|
||||
<br>
|
||||
Votre adhésion sera donc effective à compter du DATE?? jusqu’au DATE??.
|
||||
Votre adhésion sera donc effective à compter du $souscription jusqu’au $expiration.
|
||||
<br><br><br>
|
||||
|
||||
Nous vous prions de recevoir, chère adhérente, cher adhérent, nos meilleures salutations,
|
||||
<br><br>
|
||||
Moi JE Chef
|
||||
<br><br><br>
|
||||
Nous vous rappelons que la cotisation n’est pas soumise à la TVA et qu’elle ne donne pas lieu à la délivrance d’une facture. Elle n’ouvre pas droit au bénéfice des dispositions des articles 200, 238 bis et 885-0 V bis A du code général des impôts.
|
||||
-représentant·e de l'asso-
|
||||
<br><br><br>
|
||||
<i>Nous vous rappelons que la cotisation n’est pas soumise à la TVA et qu’elle ne donne pas lieu à la délivrance d’une facture. Elle n’ouvre pas droit au bénéfice des dispositions des articles 200, 238 bis et 885-0 V bis A du code général des impôts.</i>
|
||||
EOF;
|
||||
|
||||
$html = ob_get_clean();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue