diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 188adbdc687..17c95dffac8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -21,7 +21,7 @@ * \file htdocs/core/class/commonobject.class.php * \ingroup core * \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...) - * \version $Id: commonobject.class.php,v 1.157 2011/08/20 15:11:31 eldy Exp $ + * \version $Id: commonobject.class.php,v 1.158 2011/08/20 15:30:38 eldy Exp $ */ @@ -1931,31 +1931,30 @@ class CommonObject /** * Add/Update extra fields - * TODO Use also type of field to do manage date fields */ - function insertExtraFields($object) + function insertExtraFields() { - if (sizeof($object->array_options) > 0) + if (sizeof($this->array_options) > 0) { $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$object->id; - dol_syslog(get_class($object)."::insertExtraFields delete sql=".$sql_del); + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + dol_syslog(get_class($this)."::insertExtraFields delete sql=".$sql_del); $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$object->table_element."_extrafields (fk_object"; - foreach($object->array_options as $key => $value) + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; + foreach($this->array_options as $key => $value) { // Add field of attribut $sql.=",".substr($key,8); // Remove 'options_' prefix } - $sql .= ") VALUES (".$object->id; - foreach($object->array_options as $key => $value) + $sql .= ") VALUES (".$this->id; + foreach($this->array_options as $key => $value) { // Add field o fattribut - if ($object->array_options[$key] != '') + if ($this->array_options[$key] != '') { - $sql.=",'".$object->array_options[$key]."'"; + $sql.=",'".$this->array_options[$key]."'"; } else { @@ -1964,12 +1963,12 @@ class CommonObject } $sql.=")"; - dol_syslog(get_class($object)."::insertExtraFields insert sql=".$sql); + dol_syslog(get_class($this)."::insertExtraFields insert sql=".$sql); $resql = $this->db->query($sql); if (! $resql) { $this->error=$this->db->lasterror(); - dol_syslog(get_class($object)."::update ".$this->error,LOG_ERR); + dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); $this->db->rollback(); return -1; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1f514b79f59..b479f086740 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -26,7 +26,7 @@ * \file htdocs/societe/class/societe.class.php * \ingroup societe * \brief File for third party class - * \version $Id: societe.class.php,v 1.100 2011/08/18 22:25:46 eldy Exp $ + * \version $Id: societe.class.php,v 1.101 2011/08/20 15:30:39 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); @@ -544,7 +544,7 @@ class Societe extends CommonObject $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - $result=$this->insertExtraFields($this); + $result=$this->insertExtraFields(); if ($result < 0) { $error++;