FIX Missing transaction around action

This commit is contained in:
Laurent Destailleur 2018-10-08 17:40:17 +02:00
parent 0c7b7ed7f4
commit c930218dd2

View File

@ -609,12 +609,23 @@ if (empty($reshook))
// Classify billed // Classify billed
else if ($action == 'classifybilled' && $usercanclose) else if ($action == 'classifybilled' && $usercanclose)
{ {
$db->begin();
$result=$object->cloture($user, 4, ''); $result=$object->cloture($user, 4, '');
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
} }
// Close proposal // Close proposal
@ -627,12 +638,23 @@ if (empty($reshook))
// prevent browser refresh from closing proposal several times // prevent browser refresh from closing proposal several times
if ($object->statut == Propal::STATUS_VALIDATED) if ($object->statut == Propal::STATUS_VALIDATED)
{ {
$db->begin();
$result=$object->cloture($user, GETPOST('statut','int'), GETPOST('note_private','none')); $result=$object->cloture($user, GETPOST('statut','int'), GETPOST('note_private','none'));
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
} }
} }
} }
@ -643,12 +665,23 @@ if (empty($reshook))
// prevent browser refresh from reopening proposal several times // prevent browser refresh from reopening proposal several times
if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED)
{ {
$db->begin();
$result=$object->reopen($user, 1); $result=$object->reopen($user, 1);
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
} }
} }