Compare commits

..

No commits in common. "80a5245bc8f3fbb0a8dbbbe8352c4c821ef22f39" and "93c1daeffdcf262c2a520262a0c270ac7ff13a71" have entirely different histories.

2 changed files with 25 additions and 29 deletions

View File

@ -51,7 +51,7 @@ if ( !$target ) {
// Traitement // Traitement
$data=[]; $data=[];
$form->runIf(f('save') && !$form->hasErrors(), $form->runIf(f('save') && !$form->hasErrors(),
function () use ($client, &$data, $form) function () use ($client, &$data)
{ {
try try
{ {
@ -101,10 +101,6 @@ $form->runIf(f('save') && !$form->hasErrors(),
$data['receveur_membre'] = 1; $data['receveur_membre'] = 1;
$data['receveur_id'] = f('membre'); $data['receveur_id'] = f('membre');
} }
else
{
throw new UserException('Vous devez indiquer si le receveur est un client ou un membre');
}
} }
catch(UserException $e) catch(UserException $e)
@ -156,36 +152,33 @@ $form->runIf(f('add_cotis') && !$form->hasErrors(),
} }
}, 'add_cotis_2'); }, 'add_cotis_2');
if (! $form->hasErrors()) if ($step)
{ {
if ($step) try
{ {
try $liste = $facture->getCotis((int)f('membre_cotis'));
{
$liste = $facture->getCotis((int)f('membre_cotis'));
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
} }
elseif (count($data) > 0) catch (UserException $e)
{ {
if ($target) $form->addError($e->getMessage());
{
$id = $facture->add($data, $plugin->getConfig('pattern'));
Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id);
}
else
{
if ($facture->edit($id, $data))
{
Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id);
}
throw new UserException('Erreur d\'édition du reçu');
}
} }
} }
elseif (count($data) > 0)
{
if ($target)
{
$id = $facture->add($data, $plugin->getConfig('pattern'));
Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id);
}
else
{
if ($facture->edit($id, $data))
{
Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id);
}
throw new UserException('Erreur d\'édition du reçu');
}
}
// Affichage // Affichage

View File

@ -8,6 +8,7 @@ $users = new Users\Users;
f(['id' => 'required|numeric']); f(['id' => 'required|numeric']);
$id = (int) qg('id'); $id = (int) qg('id');
$id_field = Users\DynamicFields::getNameFieldsSQL();
$sign_tag = UserTemplate\Functions::signature(); $sign_tag = UserTemplate\Functions::signature();
// Vérification que le document existe // Vérification que le document existe
@ -24,6 +25,7 @@ try
if ($f->receveur_membre) if ($f->receveur_membre)
{ {
$c = $users->get($f->receveur_id); $c = $users->get($f->receveur_id);
$c->$id_field = $c->$identite;
foreach(['ville','code_postal','adresse'] as $v) foreach(['ville','code_postal','adresse'] as $v)
{ {
if($c->$v == '') if($c->$v == '')
@ -35,6 +37,7 @@ try
else else
{ {
$c = $client->get($f->receveur_id); $c = $client->get($f->receveur_id);
$c->$id_field = $c->nom;
} }
} }
catch(UserException $e) catch(UserException $e)