Ajout fonction : numérotation automatique des documents
This commit is contained in:
parent
8e2ddf19c6
commit
2e7710f29c
8 changed files with 110 additions and 22 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Garradin;
|
||||
|
||||
use const \Garradin\Plugin\Facturation\PATTERNS_LIST;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE);
|
||||
|
|
@ -22,18 +24,22 @@ $fields = $facture->recu_fields;
|
|||
$moyens_paiement = $facture->listMoyensPaiement(true);
|
||||
|
||||
$doc = null;
|
||||
$require_number = $plugin->getConfig('pattern') ? false : true;
|
||||
|
||||
if (qg('copy') !== null && $f = $facture->get((int)qg('copy'))) {
|
||||
$doc = (array) $f;
|
||||
|
||||
// Copié depuis facture_modifier.php
|
||||
$doc['type'] = $f->type_facture;
|
||||
$doc['numero_facture'] = $f->numero;
|
||||
$doc['numero_facture'] = '';
|
||||
$doc['base_receveur'] = $f->receveur_membre ? 'membre' : 'client';
|
||||
$doc['client'] = $f->receveur_id;
|
||||
$doc['membre'] = $f->receveur_id;
|
||||
}
|
||||
|
||||
$tpl->assign('require_number', $require_number);
|
||||
$tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]);
|
||||
|
||||
$tpl->assign('moyens_paiement', $moyens_paiement);
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
|
||||
|
||||
|
|
@ -41,7 +47,7 @@ if (f('save'))
|
|||
{
|
||||
$form->check($csrf_key, [
|
||||
'type' => 'required|in:'.implode(',', [DEVIS, FACT, CERFA]),
|
||||
'numero_facture' => 'required|string',
|
||||
'numero_facture' => $require_number ? 'required|string' : 'string',
|
||||
'date_emission' => 'required|date_format:d/m/Y',
|
||||
'date_echeance' => 'required|date_format:d/m/Y',
|
||||
// 'reglee' => '',
|
||||
|
|
@ -61,10 +67,10 @@ 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'),
|
||||
'numero' => f('numero_facture'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'date_echeance' => f('date_echeance'),
|
||||
'reglee' => f('reglee') == 1?1:0,
|
||||
|
|
@ -98,7 +104,7 @@ if (f('save'))
|
|||
$truc['receveur_id'] = f('membre');
|
||||
}
|
||||
|
||||
$id = $facture->add($truc);
|
||||
$id = $facture->add($truc, $plugin->getConfig('pattern'));
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
|
||||
|
|
@ -158,7 +164,7 @@ elseif (f('add_cotis'))
|
|||
'expiration' => $cotis['expiry'] ]
|
||||
];
|
||||
|
||||
$id = $facture->add($data);
|
||||
$id = $facture->add($data, $plugin->getConfig('pattern'));
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue