Fix indent ++

This commit is contained in:
BuildTools 2019-11-03 17:51:31 +01:00
parent d45f81a515
commit 541c5820bc
16 changed files with 415 additions and 417 deletions

View file

@ -9,4 +9,4 @@ use Garradin\Plugin\Facturation\Client;
$cfg = Config::getInstance();
$client = new Client;
$facture = new Facture;
$facture = new Facture;

View file

@ -19,4 +19,4 @@ if (!$client)
$tpl->assign('docs', $facture->listUserDoc(0, $id));
$tpl->assign('client', $client);
$tpl->display(PLUGIN_ROOT . '/templates/client.tpl');
$tpl->display(PLUGIN_ROOT . '/templates/client.tpl');

View file

@ -26,7 +26,7 @@ if(f('save'))
'telephone' => 'string',
'email' => 'email'
]);
if (!$form->hasErrors())
{
try
@ -39,7 +39,7 @@ if(f('save'))
'telephone' => f('telephone'),
'email' => f('email')
]);
$r ? Utils::redirect(PLUGIN_URL . 'client.php?id='.(int)$id):'';
}
catch (UserException $e)

View file

@ -14,27 +14,27 @@ $c = $client->get($id);
if (!$client)
{
throw new UserException("Ce client n'existe pas.");
throw new UserException("Ce client n'existe pas.");
}
if (f('delete'))
{
$form->check('delete_client_'.$c->id);
$form->check('delete_client_'.$c->id);
if (!$form->hasErrors())
{
try {
var_dump($client->delete($c->id));
Utils::redirect(PLUGIN_URL . 'clients.php');
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
if (!$form->hasErrors())
{
try {
$client->delete($c->id);
Utils::redirect(PLUGIN_URL . 'clients.php');
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
}
}
$tpl->assign('deletable', $client->isDeletable($id));
$tpl->assign('client', $client->get($id));
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');

View file

@ -8,29 +8,29 @@ $session->requireAccess('compta', Membres::DROIT_ACCES);
if(f('add'))
{
$form->check('add_client', [
'nom' => 'required|string',
'adresse' => 'required|string',
'code_postal' => 'required|string',
'ville' => 'required|string',
'telephone' => 'string',
'email' => 'email'
]);
$form->check('add_client', [
'nom' => 'required|string',
'adresse' => 'required|string',
'code_postal' => 'required|string',
'ville' => 'required|string',
'telephone' => 'string',
'email' => 'email'
]);
if (!$form->hasErrors())
{
if (!$form->hasErrors())
{
try
{
$id = $client->add([
'nom' => f('nom'),
'adresse' => f('adresse'),
'code_postal' => f('code_postal'),
'ville' => f('ville'),
'telephone' => f('telephone'),
'email' => f('email')
'nom' => f('nom'),
'adresse' => f('adresse'),
'code_postal' => f('code_postal'),
'ville' => f('ville'),
'telephone' => f('telephone'),
'email' => f('email')
]);
$id ? Utils::redirect(PLUGIN_URL . 'client.php?id='.(int)$id):'';
$id ? Utils::redirect(PLUGIN_URL . 'client.php?id='.(int)$id):'';
}
catch (UserException $e)
{
@ -40,17 +40,16 @@ if(f('add'))
}
// var_dump($client->listAll());
$tpl->assign('clients', $client->listAll());
$tpl->assign('champs',
[
'id' => 'id',
'nom' => 'Nom',
'adresse' => 'Adresse',
'code_postal' => 'Code postal',
'ville' => 'Ville',
'telephone' => 'Numéro de téléphone',
'email' => 'Adresse mail'
[
'id' => 'id',
'nom' => 'Nom',
'adresse' => 'Adresse',
'code_postal' => 'Code postal',
'ville' => 'Ville',
'telephone' => 'Numéro de téléphone',
'email' => 'Adresse mail'
]
);

View file

@ -8,19 +8,19 @@ $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'));
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();
$cfg->save();
Utils::redirect(PLUGIN_URL . 'config.php?ok');
Utils::redirect(PLUGIN_URL . 'config.php?ok');
}
catch (UserException $e)
{
$form->addError($e->getMessage());
$form->addError($e->getMessage());
}
}

View file

@ -26,20 +26,20 @@ $tpl->assign('moyen_paiement', $cats->getMoyenPaiement($f->moyen_paiement));
try
{
if ($f->receveur_membre)
{
$c = $membres->get($f->receveur_id);
foreach(['ville','code_postal','adresse'] as $v)
{
if($c->$v == '')
{
$c->$v = '[A RENSEIGNER DANS LA FICHE MEMBRE]';
}
}
if ($f->receveur_membre)
{
$c = $membres->get($f->receveur_id);
foreach(['ville','code_postal','adresse'] as $v)
{
if($c->$v == '')
{
$c->$v = '[A RENSEIGNER DANS LA FICHE MEMBRE]';
}
}
}
else
{
$c = $client->get($f->receveur_id);
$c = $client->get($f->receveur_id);
}
$tpl->assign('facture', $f);
@ -47,11 +47,11 @@ try
}
catch(UserException $e)
{
$form->addError("Pas de document correspondant à cet id trouvée.");
$form->addError("Pas de document correspondant à cet id trouvée.");
}
$tpl->assign('id', $id);
$tpl->assign('footer', $cfg->get('footer')?:'');
$tpl->assign('siret_asso', $cfg->get('siret_asso')?:'');
$tpl->display(PLUGIN_ROOT . '/templates/facture.tpl');
$tpl->display(PLUGIN_ROOT . '/templates/facture.tpl');

View file

@ -14,78 +14,78 @@ $tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
if (f('add'))
{
$form->check('ajout_facture', [
'type' => 'required|in:facture,devis',
'numero_facture' => 'required|string',
'date_emission' => 'required|date',
'date_echeance' => 'required|date',
// 'reglee' => '',
// 'archivee' => '',
'base_receveur' => 'required|in:membre,client',
// 'client' => '',
// 'membre' => '',
'moyen_paiement' => 'required|in:' . implode(',', array_keys($cats->listMoyensPaiement())),
'designation' => 'array|required',
'prix' => 'array|required'
]);
$form->check('ajout_facture', [
'type' => 'required|in:facture,devis',
'numero_facture' => 'required|string',
'date_emission' => 'required|date',
'date_echeance' => 'required|date',
// 'reglee' => '',
// 'archivee' => '',
'base_receveur' => 'required|in:membre,client',
// 'client' => '',
// 'membre' => '',
'moyen_paiement' => 'required|in:' . implode(',', array_keys($cats->listMoyensPaiement())),
'designation' => 'array|required',
'prix' => 'array|required'
]);
if (!$form->hasErrors())
{
try
{
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
];
if (f('type') == 'facture')
{
$truc['type_facture'] = 1;
}
elseif (f('type') == 'devis')
{
$truc['type_facture'] = 0;
}
if (!$form->hasErrors())
{
try
{
if ( count(f('designation')) !== count(f('prix')) )
{
throw new UserException('Nombre de désignations et de prix reçus différent.');
}
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');
}
$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
];
$id = $facture->add($truc);
if (f('type') == 'facture')
{
$truc['type_facture'] = 1;
}
elseif (f('type') == 'devis')
{
$truc['type_facture'] = 0;
}
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
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']);
}
catch(UserException $e)
{
$form->addError($e->getMessage());
}
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');
}
$id = $facture->add($truc);
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
}
catch(UserException $e)
{
$form->addError($e->getMessage());
}
}
}
@ -119,4 +119,4 @@ $tpl->assign('prix', $prix);
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, nom FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
$tpl->assign('clients', $client->listAll());
$tpl->display(PLUGIN_ROOT . '/templates/facture_ajouter.tpl');
$tpl->display(PLUGIN_ROOT . '/templates/facture_ajouter.tpl');

View file

@ -26,78 +26,78 @@ $tpl->assign('moyen_paiement', f('moyen_paiement') ?: $f->moyen_paiement);
if(f('save'))
{
$form->check('modifier_facture', [
'type' => 'required|in:facture,devis',
'numero_facture' => 'required|string',
'date_emission' => 'required|date',
'date_echeance' => 'required|date',
// 'reglee' => '',
// 'archivee' => '',
'base_receveur' => 'required|in:membre,client',
// 'client' => '',
// 'membre' => '',
'moyen_paiement' => 'required|in:' . implode(',', array_keys($cats->listMoyensPaiement())),
'designation' => 'array|required',
'prix' => 'array|required'
'type' => 'required|in:facture,devis',
'numero_facture' => 'required|string',
'date_emission' => 'required|date',
'date_echeance' => 'required|date',
// 'reglee' => '',
// 'archivee' => '',
'base_receveur' => 'required|in:membre,client',
// 'client' => '',
// 'membre' => '',
'moyen_paiement' => 'required|in:' . implode(',', array_keys($cats->listMoyensPaiement())),
'designation' => 'array|required',
'prix' => 'array|required'
]);
if (!$form->hasErrors())
{
try
{
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
];
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']);
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');
}
try
{
if ( count(f('designation')) !== count(f('prix')) )
{
throw new UserException('Nombre de désignations et de prix reçus différent.');
}
$r = $facture->edit($id, $truc);
$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
];
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
if (f('type') == 'facture')
{
$truc['type_facture'] = 1;
}
elseif (f('type') == 'devis')
{
$truc['type_facture'] = 0;
}
}
catch(UserException $e)
{
$form->addError($e->getMessage());
}
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');
}
$r = $facture->edit($id, $truc);
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
}
catch(UserException $e)
{
$form->addError($e->getMessage());
}
}
}

View file

@ -49,8 +49,8 @@ catch(UserException $e)
$pdf = new \Mpdf\Mpdf([
'default_font_size' => 10,
'default_font' => 'dejavusans',
// 'tempDir' => PLUGINS_ROOT . '/mpdf-tmp/'
'default_font' => 'dejavusans',
// 'tempDir' => PLUGINS_ROOT . '/mpdf-tmp/'
]);
$pdf->SetAuthor($config->get('nom_asso'));
@ -61,20 +61,20 @@ $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 = $cfg->get('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 = $cfg->get('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->nom.'</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->nom.'</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);
@ -88,58 +88,58 @@ echo <<<EOF
<style>
.titre {
text-align: center;
font-size: 8pt;
position: absolute;
top: 6mm;
width: 180mm;
text-align: center;
font-size: 8pt;
position: absolute;
top: 6mm;
width: 180mm;
}
.h2 {
margin: 25 20 0 20;
margin: 25 20 0 20;
}
.h2 span {
font-weight: bold;
font-size: 15pt;
font-weight: bold;
font-size: 15pt;
}
hr {
margin: 5 0 20 0;
margin: 5 0 20 0;
}
.adressage {
font-size: 11pt;
font-size: 11pt;
}
.adressage td {
width: 95mm;
vertical-align: top;
width: 95mm;
vertical-align: top;
}
.contenu td, .contenu th {
vertical-align: top;
padding: 8 10;
margin : 0;
border-collapse: collapse;
vertical-align: top;
padding: 8 10;
margin : 0;
border-collapse: collapse;
}
.contenu tr th, .contenu tr td {
text-align: right;
width: 16%;
text-align: right;
width: 16%;
}
.contenu tr td:nth-child(1), .contenu tr th:nth-child(1) {
text-align: left;
width: 84%;
text-align: left;
width: 84%;
}
.contenu thead tr, .contenu tfoot tr {
background-color: #CCE;
border: 10px solid black;
background-color: #CCE;
border: 10px solid black;
}
.contenu tbody tr:nth-child(even) {
background-color: #DDF;
background-color: #DDF;
}
footer {
position: absolute;
bottom: 0;
margin: 14mm 0;
position: absolute;
bottom: 0;
margin: 14mm 0;
}
</style>
@ -152,8 +152,8 @@ $doc - Émis le $emission
<table class="adressage">
<tr>
<td>$asso</td>
<td>$receveur</td>
<td>$asso</td>
<td>$receveur</td>
</tr>
</table>
@ -166,14 +166,14 @@ $doc - Émis le $emission
<table class="contenu">
<thead>
<tr>
<th>
Désignations
</th>
<th>
Prix
</th>
</tr>
<tr>
<th>
Désignations
</th>
<th>
Prix
</th>
</tr>
</thead>
<tbody>
EOF;
@ -181,21 +181,21 @@ EOF;
$i = 1;
foreach($f->contenu as $k=>$v)
{
echo '<tr><td>';
echo str_replace("\n", '<br>', $v['designation']);
echo '</td><td>';
echo number_format($v['prix'], 2, ',', ' ').'€';
echo '</td></tr>';
echo '<tr><td>';
echo str_replace("\n", '<br>', $v['designation']);
echo '</td><td>';
echo number_format($v['prix'], 2, ',', ' ').'€';
echo '</td></tr>';
$i++;
}
echo <<<EOF
</tbody>
<tfoot>
<tr>
<td><h3>Total</h3>Net à payer</td>
<td><b>$total </b> (HT)</td>
</tr>
<tr>
<td><h3>Total</h3>Net à payer</td>
<td><b>$total </b> (HT)</td>
</tr>
</tfoot>
</table>
@ -209,7 +209,7 @@ echo <<<EOF
Moyen de paiement : $moyen_paiement
<p>
$footer
$footer
</p>
</footer>
@ -221,13 +221,13 @@ $pdf->WriteHTML($html);
if(qg('d') !== null)
{
$t = \Mpdf\Output\Destination::DOWNLOAD;
$t = \Mpdf\Output\Destination::DOWNLOAD;
}
else
{
$t = \Mpdf\Output\Destination::INLINE;
$t = \Mpdf\Output\Destination::INLINE;
}
$pdf->Output(
($f->type_facture?'Facture':'Devis').' '.$f->numero
. ' du '.date('d-m-Y' ,$f->date_emission)
.'.pdf', $t);
($f->type_facture?'Facture':'Devis').' '.$f->numero
. ' du '.date('d-m-Y' ,$f->date_emission)
.'.pdf', $t);

View file

@ -13,8 +13,8 @@ $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
foreach($factures = $facture->listAll() as $k=>$f)
{
$factures[$k]->receveur = $f->receveur_membre? $membres->get($f->receveur_id) : $client->get($f->receveur_id);
$factures[$k]->moyen_paiement = $cats->getMoyenPaiement($f->moyen_paiement);
$factures[$k]->receveur = $f->receveur_membre? $membres->get($f->receveur_id) : $client->get($f->receveur_id);
$factures[$k]->moyen_paiement = $cats->getMoyenPaiement($f->moyen_paiement);
}
$tpl->assign('factures', $factures);