Fix: Trigger error not reported

This commit is contained in:
Laurent Destailleur 2014-09-15 11:48:50 +02:00
parent b94d913440
commit 2dbbc76645
5 changed files with 59 additions and 46 deletions

View File

@ -351,7 +351,6 @@ else if ($action == 'add' && $user->rights->propal->creer) {
}
$id = $object->create($user);
if ($id > 0)
{
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
@ -435,11 +434,11 @@ else if ($action == 'add' && $user->rights->propal->creer) {
if ($reshook < 0)
$error ++;
} else {
$mesgs [] = $srcobject->error;
setEventMessages($srcobject->error, $srcobject->errors, 'errors');
$error ++;
}
} else {
$mesgs [] = $object->error;
setEventMessages($object->error, $object->errors, 'errors');
$error ++;
}
} // Standard creation
@ -448,23 +447,29 @@ else if ($action == 'add' && $user->rights->propal->creer) {
$id = $object->create($user);
}
if ($id > 0) {
if ($id > 0)
{
// Insertion contact par defaut si defini
if (GETPOST('contactidp') > 0) {
if (GETPOST('contactidp') > 0)
{
$result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external');
if ($result < 0) {
$error ++;
if ($result < 0)
{
$error++;
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
}
}
if (! $error) {
if (! $error)
{
$db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
// Define output language
$outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) {
if (! empty($conf->global->MAIN_MULTILANGS))
{
$outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
@ -475,13 +480,18 @@ else if ($action == 'add' && $user->rights->propal->creer) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
} else {
$db->rollback();
}
} else {
dol_print_error($db, $object->error);
else
{
$db->rollback();
$action='create';
}
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
exit();
$action='create';
}
}
}

View File

@ -869,15 +869,15 @@ class Propal extends CommonObject
}
}
else
{
$this->error=$this->db->error();
{
$this->error=$this->db->lasterror();
$error++;
}
}
}
else
{
$this->error=$this->db->error();
{
$this->error=$this->db->lasterror();
$error++;
}
@ -895,7 +895,7 @@ class Propal extends CommonObject
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}

View File

@ -1559,7 +1559,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
}
// Other attributes
$parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) {

View File

@ -605,7 +605,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error ++;
// Replacement invoice
// Replacement invoice
if ($_POST['type'] == Facture::TYPE_REPLACEMENT)
{
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
@ -716,10 +716,11 @@ else if ($action == 'add' && $user->rights->facture->creer)
}
if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) {
if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0)
{
$facture_source = new Facture($db); // fetch origin object if not previously defined
if($facture_source->fetch($object->fk_facture_source)>0) {
if ($facture_source->fetch($object->fk_facture_source)>0)
{
$totalpaye = $facture_source->getSommePaiement();
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
$totaldeposits = $facture_source->getSumDepositsUsed();
@ -1061,9 +1062,9 @@ else if ($action == 'add' && $user->rights->facture->creer)
{
$db->rollback();
$action = 'create';
$_GET ["origin"] = $_POST["origin"];
$_GET ["originid"] = $_POST["originid"];
setEventMessage($object->error, 'errors');
$_GET["origin"] = $_POST["origin"];
$_GET["originid"] = $_POST["originid"];
setEventMessages($object->error, $object->errors, 'errors');
}
}

View File

@ -3460,6 +3460,7 @@ abstract class CommonObject
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
if ($result < 0)
{
if (!empty($this->errors))
@ -3471,6 +3472,7 @@ abstract class CommonObject
$this->errors=$interface->errors;
}
}
return $result;
}