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);
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,20 +864,20 @@ class Propal extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_CREATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ class Propal extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_CLONE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -1331,7 +1331,7 @@ class Propal extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_VALIDATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -1669,7 +1669,7 @@ class Propal extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_REOPEN',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
@ -1677,8 +1677,8 @@ class Propal extends CommonObject
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
@ -1751,7 +1751,7 @@ class Propal extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_CLOSE_SIGNED',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
else
|
||||
@ -1773,7 +1773,7 @@ class Propal extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_CLOSE_REFUSED',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
if ( ! $error )
|
||||
@ -2040,7 +2040,7 @@ class Propal extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PROPAL_DELETE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -2520,7 +2520,7 @@ class Propal extends CommonObject
|
||||
{
|
||||
$file = $conf->global->PROPALE_ADDON.".php";
|
||||
$classname = $conf->global->PROPALE_ADDON;
|
||||
|
||||
|
||||
// Include file with class
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
@ -2926,10 +2926,10 @@ class PropaleLigne extends CommonObject
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEPROPAL_INSERT',$user);
|
||||
if ($result < 0)
|
||||
{
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -2976,10 +2976,10 @@ class PropaleLigne extends CommonObject
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEPROPAL_DELETE',$user);
|
||||
if ($result < 0)
|
||||
{
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
$this->db->commit();
|
||||
@ -3085,11 +3085,11 @@ class PropaleLigne extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEPROPAL_UPDATE',$user);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user