From 74cba062b4d2593792a07b2de1df355d3141909f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Sep 2014 19:37:59 +0200 Subject: [PATCH] Add a TODO to explain why we keep some extends into class. Should be removed once php min will be 5.4. --- htdocs/comm/propal.php | 36 +- htdocs/compta/facture/class/facture.class.php | 13 +- htdocs/core/class/commoninvoice.class.php | 6 +- htdocs/core/class/commonobject.class.php | 715 +++++++++--------- htdocs/core/class/commonobjectline.class.php | 34 +- htdocs/core/tpl/objectline_view.tpl.php | 3 +- 6 files changed, 404 insertions(+), 403 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 75d9b560658..3eac57a64b4 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -664,10 +664,12 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G } // Go back to draft -if ($action == 'modif' && $user->rights->propal->creer) { +if ($action == 'modif' && $user->rights->propal->creer) +{ $object->set_draft($user); - 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)) { @@ -2010,26 +2012,34 @@ if ($action == 'create') $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)) { - foreach ($extrafields->attribute_label as $key => $label) { - if ($action == 'edit_extras') { + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + foreach ($extrafields->attribute_label as $key => $label) + { + if ($action == 'edit_extras') + { $value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]); - } else { + } + else + { $value = $object->array_options ["options_" . $key]; } - if ($extrafields->attribute_type [$key] == 'separate') { + if ($extrafields->attribute_type [$key] == 'separate') + { print $extrafields->showSeparator($key); - } else { + } + else + { print 'attribute_required [$key])) - print ' class="fieldrequired"'; + if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"'; print '>' . $label . ''; // Convert date into timestamp format if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); } - if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key) { + if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key) + { print '
'; print ''; print ''; @@ -2041,7 +2051,9 @@ if ($action == 'create') print ''; print '
'; - } else { + } + else + { print $extrafields->showOutputField($key, $value); if ($object->statut == 0 && $user->rights->propal->creer) print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f5d20936052..193443dd64d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -34,9 +34,9 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; -require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT .'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; /** @@ -3263,11 +3263,10 @@ class Facture extends CommonInvoice /** - * \class FactureLigne - * \brief Classe permettant la gestion des lignes de factures - * Gere des lignes de la table llx_facturedet + * Class to manage invoice lines. + * Saved into database table llx_facturedet */ -class FactureLigne extends CommonInvoiceLine +class FactureLigne extends CommonInvoiceLine { var $db; var $error; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index f44efafbffa..90ad3e196e3 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -358,10 +358,14 @@ abstract class CommonInvoice extends CommonObject } } + + +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; + /** * Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...) */ -abstract class CommonInvoiceLine extends CommonObject +abstract class CommonInvoiceLine extends CommonObjectLine { } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60e59222c9e..e8dcce57ac4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2153,327 +2153,6 @@ abstract class CommonObject } } - - /** - * Function to get extra fields of a member into $this->array_options - * This method is in most cases called by method fetch of objects but you can call it separately. - * - * @param int $rowid Id of line - * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() - * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded - */ - function fetch_optionals($rowid='',$optionsArray='') - { - if (empty($rowid)) $rowid=$this->id; - - if (! is_array($optionsArray)) - { - // optionsArray not already loaded, so we load it - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); - } - - // Request to get complementary values - if (count($optionsArray) > 0) - { - $sql = "SELECT rowid"; - foreach ($optionsArray as $name => $label) - { - $sql.= ", ".$name; - } - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; - $sql.= " WHERE fk_object = ".$rowid; - - dol_syslog(get_class($this)."::fetch_optionals", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $numrows=$this->db->num_rows($resql); - if ($numrows) - { - $tab = $this->db->fetch_array($resql); - - foreach ($tab as $key => $value) - { - // Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine) - if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) - { - // we can add this attribute to adherent object - $this->array_options["options_".$key]=$value; - } - } - } - - $this->db->free($resql); - - if ($numrows) return $numrows; - else return 0; - } - else - { - dol_print_error($this->db); - return -1; - } - } - return 0; - } - - /** - * Delete all extra fields values for the current object. - * - * @return int <0 if KO, >0 if OK - */ - function deleteExtraFields() - { - global $langs; - - $error=0; - - $this->db->begin(); - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; - dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); - $resql=$this->db->query($sql_del); - if (! $resql) - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; - } - else - { - $this->db->commit(); - return 1; - } - } - - /** - * Add/Update all extra fields values for the current object. - * All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd') - * - * @return int -1=error, O=did nothing, 1=OK - */ - function insertExtraFields() - { - global $conf,$langs; - - $error=0; - - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used - - if (! empty($this->array_options)) - { - // Check parameters - $langs->load('admin'); - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); - - foreach($this->array_options as $key => $value) - { - $attributeKey = substr($key,8); // Remove 'options_' prefix - $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeSize = $extrafields->attribute_size[$attributeKey]; - $attributeLabel = $extrafields->attribute_label[$attributeKey]; - switch ($attributeType) - { - case 'int': - if (!is_numeric($value) && $value!='') - { - $error++; $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel); - return -1; - } - elseif ($value=='') - { - $this->array_options[$key] = null; - } - break; - case 'price': - $this->array_options[$key] = price2num($this->array_options[$key]); - break; - case 'date': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); - break; - case 'datetime': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); - break; - } - } - $this->db->begin(); - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; - dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); - $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; - foreach($this->array_options as $key => $value) - { - $attributeKey = substr($key,8); // Remove 'options_' prefix - // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate - $sql.=",".$attributeKey; - } - $sql .= ") VALUES (".$this->id; - foreach($this->array_options as $key => $value) - { - $attributeKey = substr($key,8); // Remove 'options_' prefix - // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) - { - if ($this->array_options[$key] != '') - { - $sql.=",'".$this->db->escape($this->array_options[$key])."'"; - } - else - { - $sql.=",null"; - } - } - } - $sql.=")"; - - dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; - } - else - { - $this->db->commit(); - return 1; - } - } - else return 0; - } - - /** - * Function to show lines of extrafields with output datas - * - * @param object $extrafields Extrafield Object - * @param string $mode Show output (view) or input (edit) for extrafield - * @param array $params Optionnal parameters - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * - * @return string - */ - function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='') - { - global $_POST, $conf; - - $out = ''; - - if (count($extrafields->attribute_label) > 0) - { - $out .= "\n"; - $out .= ' '; - $out .= "\n"; - - $e = 0; - foreach($extrafields->attribute_label as $key=>$label) - { - if (is_array($params) && count($params)>0) { - if (array_key_exists('colspan',$params)) { - $colspan=$params['colspan']; - } - }else { - $colspan='3'; - } - switch($mode) { - case "view": - $value=$this->array_options["options_".$key]; - break; - case "edit": - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); - break; - } - if ($extrafields->attribute_type[$key] == 'separate') - { - $out .= $extrafields->showSeparator($key); - } - else - { - $csstyle=''; - if (is_array($params) && count($params)>0) { - if (array_key_exists('style',$params)) { - $csstyle=$params['style']; - } - } - if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) - { - $out .= ''; - $colspan='0'; - } - else - { - $out .= ''; - } - // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) - { - $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]); - } - - if($extrafields->attribute_required[$key]) - $label = ''.$label.''; - - $out .= ''.$label.''; - $out .=''; - - switch($mode) { - case "view": - $out .= $extrafields->showOutputField($key,$value); - break; - case "edit": - $out .= $extrafields->showInputField($key,$value,'',$keyprefix); - break; - } - - $out .= ''."\n"; - - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; - else $out .= ''; - $e++; - } - } - $out .= "\n"; - $out .= ' '; - $out .= ' - '; - } - return $out; - } - - /** * Function to check if an object is used by others. * Check is done into this->childtables. There is no check into llx_element_element. @@ -3473,38 +3152,6 @@ abstract class CommonObject } } - /** - * Call trigger based on this instance - * NB: Error from trigger are stacked in interface->errors - * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. - * - * @param string $trigger_name trigger's name to execute - * @param User $user Object user - * @return int Result of run_triggers - */ - function call_trigger($trigger_name, $user) - { - global $langs,$conf; - - 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)) - { - $this->errors=array_merge($this->errors,$interface->errors); - } - else - { - $this->errors=$interface->errors; - } - } - - return $result; - } - /** * Common function for all objects extending CommonObject for generating documents * @@ -3597,4 +3244,366 @@ abstract class CommonObject } } + + /* Functions common to commonobject and commonobjectline */ + + + /* For triggers */ + + + /** + * Call trigger based on this instance + * NB: Error from trigger are stacked in interface->errors + * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. + * + * @param string $trigger_name trigger's name to execute + * @param User $user Object user + * @return int Result of run_triggers + */ + function call_trigger($trigger_name, $user) + { + global $langs,$conf; + + 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)) + { + $this->errors=array_merge($this->errors,$interface->errors); + } + else + { + $this->errors=$interface->errors; + } + } + + return $result; + } + + + /* Functions for extrafields */ + + + /** + * Function to get extra fields of a member into $this->array_options + * This method is in most cases called by method fetch of objects but you can call it separately. + * + * @param int $rowid Id of line + * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() + * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded + */ + function fetch_optionals($rowid='',$optionsArray='') + { + if (empty($rowid)) $rowid=$this->id; + + if (! is_array($optionsArray)) + { + // optionsArray not already loaded, so we load it + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); + } + + // Request to get complementary values + if (count($optionsArray) > 0) + { + $sql = "SELECT rowid"; + foreach ($optionsArray as $name => $label) + { + $sql.= ", ".$name; + } + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; + $sql.= " WHERE fk_object = ".$rowid; + + dol_syslog(get_class($this)."::fetch_optionals", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $numrows=$this->db->num_rows($resql); + if ($numrows) + { + $tab = $this->db->fetch_array($resql); + + foreach ($tab as $key => $value) + { + // Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine) + if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) + { + // we can add this attribute to adherent object + $this->array_options["options_".$key]=$value; + } + } + } + + $this->db->free($resql); + + if ($numrows) return $numrows; + else return 0; + } + else + { + dol_print_error($this->db); + return -1; + } + } + return 0; + } + + /** + * Delete all extra fields values for the current object. + * + * @return int <0 if KO, >0 if OK + */ + function deleteExtraFields() + { + global $langs; + + $error=0; + + $this->db->begin(); + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); + $resql=$this->db->query($sql_del); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + + /** + * Add/Update all extra fields values for the current object. + * All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd') + * + * @return int -1=error, O=did nothing, 1=OK + */ + function insertExtraFields() + { + global $conf,$langs; + + $error=0; + + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used + + if (! empty($this->array_options)) + { + // Check parameters + $langs->load('admin'); + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); + + foreach($this->array_options as $key => $value) + { + $attributeKey = substr($key,8); // Remove 'options_' prefix + $attributeType = $extrafields->attribute_type[$attributeKey]; + $attributeSize = $extrafields->attribute_size[$attributeKey]; + $attributeLabel = $extrafields->attribute_label[$attributeKey]; + switch ($attributeType) + { + case 'int': + if (!is_numeric($value) && $value!='') + { + $error++; $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel); + return -1; + } + elseif ($value=='') + { + $this->array_options[$key] = null; + } + break; + case 'price': + $this->array_options[$key] = price2num($this->array_options[$key]); + break; + case 'date': + $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + break; + case 'datetime': + $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + break; + } + } + $this->db->begin(); + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); + $this->db->query($sql_del); + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; + foreach($this->array_options as $key => $value) + { + $attributeKey = substr($key,8); // Remove 'options_' prefix + // Add field of attribut + if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + $sql.=",".$attributeKey; + } + $sql .= ") VALUES (".$this->id; + foreach($this->array_options as $key => $value) + { + $attributeKey = substr($key,8); // Remove 'options_' prefix + // Add field o fattribut + if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + { + if ($this->array_options[$key] != '') + { + $sql.=",'".$this->db->escape($this->array_options[$key])."'"; + } + else + { + $sql.=",null"; + } + } + } + $sql.=")"; + + dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + else return 0; + } + + /** + * Function to show lines of extrafields with output datas + * + * @param object $extrafields Extrafield Object + * @param string $mode Show output (view) or input (edit) for extrafield + * @param array $params Optionnal parameters + * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * + * @return string + */ + function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='') + { + global $_POST, $conf; + + $out = ''; + + if (count($extrafields->attribute_label) > 0) + { + $out .= "\n"; + $out .= ' '; + $out .= "\n"; + + $e = 0; + foreach($extrafields->attribute_label as $key=>$label) + { + if (is_array($params) && count($params)>0) { + if (array_key_exists('colspan',$params)) { + $colspan=$params['colspan']; + } + }else { + $colspan='3'; + } + switch($mode) { + case "view": + $value=$this->array_options["options_".$key]; + break; + case "edit": + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); + break; + } + if ($extrafields->attribute_type[$key] == 'separate') + { + $out .= $extrafields->showSeparator($key); + } + else + { + $csstyle=''; + if (is_array($params) && count($params)>0) { + if (array_key_exists('style',$params)) { + $csstyle=$params['style']; + } + } + if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) + { + $out .= ''; + $colspan='0'; + } + else + { + $out .= ''; + } + // Convert date into timestamp format + if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + { + $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]); + } + + if($extrafields->attribute_required[$key]) + $label = ''.$label.''; + + $out .= ''.$label.''; + $out .=''; + + switch($mode) { + case "view": + $out .= $extrafields->showOutputField($key,$value); + break; + case "edit": + $out .= $extrafields->showInputField($key,$value,'',$keyprefix); + break; + } + + $out .= ''."\n"; + + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; + else $out .= ''; + $e++; + } + } + $out .= "\n"; + $out .= ' '; + $out .= ' + '; + } + return $out; + } + } diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 675e1cf0794..c3c8d823a34 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -26,36 +26,12 @@ * Parent class for class inheritance lines of business objects * This class is useless for the moment so no inherit are done on it */ -abstract class CommonObjectLine +abstract class CommonObjectLine extends CommonObject { - /** - * Call trigger based on this instance - * NB: Error from trigger are stacked in interface->errors - * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. - * - * @param string $trigger_name trigger's name to execute - * @param User $user Object user - * @return int Result of run_triggers - */ - function call_trigger($trigger_name, $user) - { - global $langs,$conf; + // TODO - 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)) - { - $this->errors=array_merge($this->errors,$interface->errors); - } - else - { - $this->errors=$interface->errors; - } - } - return $result; - } + // Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code. + + // For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits. } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index c56ffc30aea..777732aa192 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -194,7 +194,8 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); } ?>