Fix: Trigger error not reported
This commit is contained in:
parent
b94d913440
commit
2dbbc76645
@ -351,7 +351,6 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
|
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
|
||||||
@ -435,11 +434,11 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
|||||||
if ($reshook < 0)
|
if ($reshook < 0)
|
||||||
$error ++;
|
$error ++;
|
||||||
} else {
|
} else {
|
||||||
$mesgs [] = $srcobject->error;
|
setEventMessages($srcobject->error, $srcobject->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$mesgs [] = $object->error;
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
} // Standard creation
|
} // Standard creation
|
||||||
@ -448,23 +447,29 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
|||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id > 0) {
|
if ($id > 0)
|
||||||
|
{
|
||||||
// Insertion contact par defaut si defini
|
// Insertion contact par defaut si defini
|
||||||
if (GETPOST('contactidp') > 0) {
|
if (GETPOST('contactidp') > 0)
|
||||||
|
{
|
||||||
$result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external');
|
$result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external');
|
||||||
if ($result < 0) {
|
if ($result < 0)
|
||||||
$error ++;
|
{
|
||||||
|
$error++;
|
||||||
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
|
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error) {
|
if (! $error)
|
||||||
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
|
{
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
$outputlangs = new Translate("", $conf);
|
$outputlangs = new Translate("", $conf);
|
||||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
@ -475,13 +480,18 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
|||||||
|
|
||||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
|
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
|
||||||
$db->rollback();
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
dol_print_error($db, $object->error);
|
{
|
||||||
|
$db->rollback();
|
||||||
|
$action='create';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
exit();
|
$action='create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -869,15 +869,15 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,7 +895,7 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1559,7 +1559,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// 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
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
|
||||||
// hook
|
// hook
|
||||||
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
|
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
|
||||||
|
|||||||
@ -605,7 +605,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
if ($ret < 0) $error ++;
|
if ($ret < 0) $error ++;
|
||||||
|
|
||||||
// Replacement invoice
|
// Replacement invoice
|
||||||
if ($_POST['type'] == Facture::TYPE_REPLACEMENT)
|
if ($_POST['type'] == Facture::TYPE_REPLACEMENT)
|
||||||
{
|
{
|
||||||
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
$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
|
$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();
|
$totalpaye = $facture_source->getSommePaiement();
|
||||||
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
|
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
|
||||||
$totaldeposits = $facture_source->getSumDepositsUsed();
|
$totaldeposits = $facture_source->getSumDepositsUsed();
|
||||||
@ -1061,9 +1062,9 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
$_GET ["origin"] = $_POST["origin"];
|
$_GET["origin"] = $_POST["origin"];
|
||||||
$_GET ["originid"] = $_POST["originid"];
|
$_GET["originid"] = $_POST["originid"];
|
||||||
setEventMessage($object->error, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3460,6 +3460,7 @@ abstract class CommonObject
|
|||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
|
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
if (!empty($this->errors))
|
if (!empty($this->errors))
|
||||||
@ -3471,6 +3472,7 @@ abstract class CommonObject
|
|||||||
$this->errors=$interface->errors;
|
$this->errors=$interface->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user