Update api_thirdparties.class.php

The variable $errors does not exist. Did you maybe mean $error?
This commit is contained in:
Frédéric FRANCE 2020-11-24 23:19:19 +01:00 committed by GitHub
parent bac24485c2
commit ba3ba7dd06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -398,8 +398,7 @@ class Thirdparties extends DolibarrApi
} }
// Move links // Move links
if (!$error) if (!$error) {
{
// This list is also into the societe/card.php file // This list is also into the societe/card.php file
// TODO Mutualise the list into object societe.class.php // TODO Mutualise the list into object societe.class.php
$objects = array( $objects = array(
@ -433,57 +432,49 @@ class Thirdparties extends DolibarrApi
{ {
require_once DOL_DOCUMENT_ROOT.$object_file; require_once DOL_DOCUMENT_ROOT.$object_file;
if (!$errors && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) if (!$error && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) {
{ $error++;
$errors++;
//setEventMessages($this->db->lasterror(), null, 'errors'); //setEventMessages($this->db->lasterror(), null, 'errors');
} }
} }
} }
// External modules should update their ones too // External modules should update their ones too
if (!$errors) if (!$error) {
{
$reshook = $hookmanager->executeHooks('replaceThirdparty', array( $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
'soc_origin' => $soc_origin->id, 'soc_origin' => $soc_origin->id,
'soc_dest' => $object->id 'soc_dest' => $object->id
), $soc_dest, $action); ), $soc_dest, $action);
if ($reshook < 0) if ($reshook < 0) {
{
//setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); //setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$errors++; $error++;
} }
} }
if (!$error) if (!$error) {
{
$object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id);
// Call trigger // Call trigger
$result = $object->call_trigger('COMPANY_MODIFY', $user); $result = $object->call_trigger('COMPANY_MODIFY', $user);
if ($result < 0) if ($result < 0) {
{
//setEventMessages($object->error, $object->errors, 'errors'); //setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
// End call triggers // End call triggers
} }
if (!$error) if (!$error) {
{
//We finally remove the old thirdparty //We finally remove the old thirdparty
if ($soc_origin->delete($soc_origin->id, $user) < 1) if ($soc_origin->delete($soc_origin->id, $user) < 1) {
{ $error++;
$errors++;
} }
} }
// End of merge // End of merge
if ($error) if ($error) {
{
$this->db->rollback(); $this->db->rollback();
throw new RestException(500, 'Error failed to merged thirdparty '.$this->companytoremove->id.' into '.$id.'. Enable and read log file for more information.'); throw new RestException(500, 'Error failed to merged thirdparty '.$this->companytoremove->id.' into '.$id.'. Enable and read log file for more information.');