2
0
forked from Wavyzz/dolibarr
This commit is contained in:
Frédéric FRANCE
2019-02-25 22:27:04 +01:00
parent 1c07006015
commit c89e4d79b8
19 changed files with 376 additions and 373 deletions

View File

@@ -423,7 +423,7 @@ abstract class CommonObject
* @param string $ref_ext Ref ext of object to check
* @return int <0 if KO, 0 if OK but not found, >0 if OK and exists
*/
static function isExistingObject($element, $id, $ref = '', $ref_ext = '')
public static function isExistingObject($element, $id, $ref = '', $ref_ext = '')
{
global $db,$conf;
@@ -457,7 +457,7 @@ abstract class CommonObject
*
* @return string String with errors
*/
function errorsToString()
public function errorsToString()
{
return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ', $this->errors)):'');
}
@@ -468,7 +468,7 @@ abstract class CommonObject
* @param string $objref Customer ref
* @return string Customer ref formated
*/
function getFormatedCustomerRef($objref)
public function getFormatedCustomerRef($objref)
{
global $hookmanager;
@@ -488,7 +488,7 @@ abstract class CommonObject
* @param string $objref Supplier ref
* @return string Supplier ref formated
*/
function getFormatedSupplierRef($objref)
public function getFormatedSupplierRef($objref)
{
global $hookmanager;
@@ -511,7 +511,7 @@ abstract class CommonObject
* @param int $maxlen Maximum length
* @return string String with full name
*/
function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
{
//print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
$lastname=$this->lastname;
@@ -538,7 +538,7 @@ abstract class CommonObject
* @param int $withregion 1=Add region into address string
* @return string Full address string
*/
function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0)
public function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0)
{
if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
@@ -569,7 +569,7 @@ abstract class CommonObject
* @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member)
* @return string Full address string
*/
function getBannerAddress($htmlkey, $object)
public function getBannerAddress($htmlkey, $object)
{
global $conf, $langs;
@@ -688,7 +688,7 @@ abstract class CommonObject
* @param int $relativelink 0=Return full external link, 1=Return link relative to root of file
* @return string Link or empty string if there is no download link
*/
function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0)
public function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0)
{
global $user, $dolibarr_main_url_root;
@@ -775,7 +775,7 @@ abstract class CommonObject
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Add a link between element $this->element and a contact
*
@@ -785,7 +785,7 @@ abstract class CommonObject
* @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0)
public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0)
{
// phpcs:enable
global $user,$langs;
@@ -899,7 +899,7 @@ abstract class CommonObject
} else return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Copy contact from one element to current
*
@@ -907,7 +907,7 @@ abstract class CommonObject
* @param string $source Nature of contact ('internal' or 'external')
* @return int >0 if OK, <0 if KO
*/
function copy_linked_contact($objFrom, $source = 'internal')
public function copy_linked_contact($objFrom, $source = 'internal')
{
// phpcs:enable
$contacts = $objFrom->liste_contact(-1, $source);
@@ -922,7 +922,7 @@ abstract class CommonObject
return 1;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update a link to contact line
*
@@ -932,7 +932,7 @@ abstract class CommonObject
* @param int $fk_socpeople Id of soc_people to update (not modified if 0)
* @return int <0 if KO, >= 0 if OK
*/
function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0)
public function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0)
{
// phpcs:enable
// Insert into database
@@ -953,7 +953,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Delete a link to contact line
*
@@ -961,7 +961,7 @@ abstract class CommonObject
* @param int $notrigger Disable all triggers
* @return int >0 if OK, <0 if KO
*/
function delete_contact($rowid, $notrigger = 0)
public function delete_contact($rowid, $notrigger = 0)
{
// phpcs:enable
global $user;
@@ -992,7 +992,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Delete all links between an object $this and all its contacts
*
@@ -1000,7 +1000,7 @@ abstract class CommonObject
* @param string $code Type of contact (code or id)
* @return int >0 if OK, <0 if KO
*/
function delete_linked_contact($source = '', $code = '')
public function delete_linked_contact($source = '', $code = '')
{
// phpcs:enable
$temp = array();
@@ -1029,7 +1029,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get array of all contacts for an object
*
@@ -1039,7 +1039,7 @@ abstract class CommonObject
* @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...)
* @return array|int Array of contacts, -1 if error
*/
function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '')
public function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '')
{
// phpcs:enable
global $langs;
@@ -1109,7 +1109,7 @@ abstract class CommonObject
* @param int $rowid Id of link between object and contact
* @return int <0 if KO, >=0 if OK
*/
function swapContactStatus($rowid)
public function swapContactStatus($rowid)
{
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle";
@@ -1138,7 +1138,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return array with list of possible values for type of contacts
*
@@ -1149,7 +1149,7 @@ abstract class CommonObject
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
*/
function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '')
public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '')
{
// phpcs:enable
global $langs;
@@ -1203,7 +1203,7 @@ abstract class CommonObject
* @param int $status limited to a certain status
* @return array List of id for such contacts
*/
function getIdContact($source, $code, $status = 0)
public function getIdContact($source, $code, $status = 0)
{
global $conf;
@@ -1256,14 +1256,14 @@ abstract class CommonObject
return $result;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load object contact with id=$this->contactid into $this->contact
*
* @param int $contactid Id du contact. Use this->contactid if empty.
* @return int <0 if KO, >0 if OK
*/
function fetch_contact($contactid = null)
public function fetch_contact($contactid = null)
{
// phpcs:enable
if (empty($contactid)) $contactid=$this->contactid;
@@ -1277,14 +1277,14 @@ abstract class CommonObject
return $result;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty
*
* @param int $force_thirdparty_id Force thirdparty id
* @return int <0 if KO, >0 if OK
*/
function fetch_thirdparty($force_thirdparty_id = 0)
public function fetch_thirdparty($force_thirdparty_id = 0)
{
// phpcs:enable
global $conf;
@@ -1340,7 +1340,7 @@ abstract class CommonObject
return $this->fetch($result->rowid);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load data for barcode into properties ->barcode_type*
* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but
@@ -1348,7 +1348,7 @@ abstract class CommonObject
*
* @return int <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded)
*/
function fetch_barcode()
public function fetch_barcode()
{
// phpcs:enable
global $conf;
@@ -1391,13 +1391,13 @@ abstract class CommonObject
return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the project with id $this->fk_project into this->project
*
* @return int <0 if KO, >=0 if OK
*/
function fetch_projet()
public function fetch_projet()
{
// phpcs:enable
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@@ -1413,13 +1413,13 @@ abstract class CommonObject
return $result;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the product with id $this->fk_product into this->product
*
* @return int <0 if KO, >=0 if OK
*/
function fetch_product()
public function fetch_product()
{
// phpcs:enable
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@@ -1433,14 +1433,14 @@ abstract class CommonObject
return $result;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the user with id $userid into this->user
*
* @param int $userid Id du contact
* @return int <0 if KO, >0 if OK
*/
function fetch_user($userid)
public function fetch_user($userid)
{
// phpcs:enable
$user = new User($this->db);
@@ -1449,13 +1449,13 @@ abstract class CommonObject
return $result;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Read linked origin object
*
* @return void
*/
function fetch_origin()
public function fetch_origin()
{
// phpcs:enable
if ($this->origin == 'shipping') $this->origin = 'expedition';
@@ -1478,7 +1478,7 @@ abstract class CommonObject
* @param string $element Element name
* @return int <0 if KO, >0 if OK
*/
function fetchObjectFrom($table, $field, $key, $element = null)
public function fetchObjectFrom($table, $field, $key, $element = null)
{
global $conf;
@@ -1514,7 +1514,7 @@ abstract class CommonObject
* @param string $field Field selected
* @return int <0 if KO, >0 if OK
*/
function getValueFrom($table, $id, $field)
public function getValueFrom($table, $id, $field)
{
$result=false;
if (!empty($id) && !empty($field) && !empty($table)) {
@@ -1548,7 +1548,7 @@ abstract class CommonObject
* @return int <0 if KO, >0 if OK
* @see updateExtraField()
*/
function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif')
public function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif')
{
global $user,$langs,$conf;
@@ -1618,7 +1618,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load properties id_previous and id_next by comparing $fieldid with $this->ref
*
@@ -1627,7 +1627,7 @@ abstract class CommonObject
* @param int $nodbprefix Do not include DB prefix to forge table name
* @return int <0 if KO, >0 if OK
*/
function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0)
public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0)
{
// phpcs:enable
global $conf, $user;
@@ -1751,7 +1751,7 @@ abstract class CommonObject
* @return array Array of id of contacts (if source=external or internal)
* Array of id of third parties with at least one contact on object (if source=thirdparty)
*/
function getListContactId($source = 'external')
public function getListContactId($source = 'external')
{
$contactAlreadySelected = array();
$tab = $this->liste_contact(-1, $source);
@@ -1773,7 +1773,7 @@ abstract class CommonObject
* @param int $projectid Project id to link element to
* @return int <0 if KO, >0 if OK
*/
function setProject($projectid)
public function setProject($projectid)
{
if (! $this->table_element)
{
@@ -1814,7 +1814,7 @@ abstract class CommonObject
* @param int $id Id of new payment method
* @return int >0 if OK, <0 if KO
*/
function setPaymentMethods($id)
public function setPaymentMethods($id)
{
dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
@@ -1856,7 +1856,7 @@ abstract class CommonObject
* @param string $code multicurrency code
* @return int >0 if OK, <0 if KO
*/
function setMulticurrencyCode($code)
public function setMulticurrencyCode($code)
{
dol_syslog(get_class($this).'::setMulticurrencyCode('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
@@ -1898,7 +1898,7 @@ abstract class CommonObject
* @param int $mode mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency
* @return int >0 if OK, <0 if KO
*/
function setMulticurrencyRate($rate, $mode = 1)
public function setMulticurrencyRate($rate, $mode = 1)
{
dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
@@ -1999,7 +1999,7 @@ abstract class CommonObject
* @param int $id Id of new payment terms
* @return int >0 if OK, <0 if KO
*/
function setPaymentTerms($id)
public function setPaymentTerms($id)
{
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
@@ -2043,7 +2043,7 @@ abstract class CommonObject
* @param int $id Address id
* @return int <0 si ko, >0 si ok
*/
function setDeliveryAddress($id)
public function setDeliveryAddress($id)
{
$fieldname = 'fk_delivery_address';
if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
@@ -2074,7 +2074,7 @@ abstract class CommonObject
*
* @return int 1 if OK, 0 if KO
*/
function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null)
public function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null)
{
global $user;
@@ -2128,7 +2128,7 @@ abstract class CommonObject
* @param int $warehouse_id Id of warehouse
* @return int 1 if OK, 0 if KO
*/
function setWarehouse($warehouse_id)
public function setWarehouse($warehouse_id)
{
if (! $this->table_element) {
dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR);
@@ -2159,7 +2159,7 @@ abstract class CommonObject
* @param string $modelpdf Modele name
* @return int <0 if KO, >0 if OK
*/
function setDocModel($user, $modelpdf)
public function setDocModel($user, $modelpdf)
{
if (! $this->table_element)
{
@@ -2198,7 +2198,7 @@ abstract class CommonObject
* @param User $userused Object user
* @return int 1 if OK, 0 if KO
*/
function setBankAccount($fk_account, $notrigger = false, $userused = null)
public function setBankAccount($fk_account, $notrigger = false, $userused = null)
{
global $user;
@@ -2253,7 +2253,7 @@ abstract class CommonObject
// TODO: Move line related operations to CommonObjectLine?
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Save a new position (field rang) for details lines.
* You can choose to set position for lines with already a position or lines without any position defined.
@@ -2263,7 +2263,7 @@ abstract class CommonObject
* @param boolean $fk_parent_line Table with fk_parent_line field or not
* @return int <0 if KO, >0 if OK
*/
function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true)
public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true)
{
// phpcs:enable
if (! $this->table_element_line)
@@ -2348,7 +2348,7 @@ abstract class CommonObject
* @param int $id Id of parent line
* @return array Array with list of children lines id
*/
function getChildrenOfLine($id)
public function getChildrenOfLine($id)
{
$rows=array();
@@ -2374,7 +2374,7 @@ abstract class CommonObject
return $rows;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update a line to have a lower rank
*
@@ -2382,7 +2382,7 @@ abstract class CommonObject
* @param boolean $fk_parent_line Table with fk_parent_line field or not
* @return void
*/
function line_up($rowid, $fk_parent_line = true)
public function line_up($rowid, $fk_parent_line = true)
{
// phpcs:enable
$this->line_order(false, 'ASC', $fk_parent_line);
@@ -2394,7 +2394,7 @@ abstract class CommonObject
$this->updateLineUp($rowid, $rang);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update a line to have a higher rank
*
@@ -2402,7 +2402,7 @@ abstract class CommonObject
* @param boolean $fk_parent_line Table with fk_parent_line field or not
* @return void
*/
function line_down($rowid, $fk_parent_line = true)
public function line_down($rowid, $fk_parent_line = true)
{
// phpcs:enable
$this->line_order(false, 'ASC', $fk_parent_line);
@@ -2424,7 +2424,7 @@ abstract class CommonObject
* @param int $rang Position
* @return void
*/
function updateRangOfLine($rowid, $rang)
public function updateRangOfLine($rowid, $rang)
{
$fieldposition = 'rang';
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
@@ -2439,14 +2439,14 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update position of line with ajax (rang)
*
* @param array $rows Array of rows
* @return void
*/
function line_ajaxorder($rows)
public function line_ajaxorder($rows)
{
// phpcs:enable
$num = count($rows);
@@ -2463,7 +2463,7 @@ abstract class CommonObject
* @param int $rang Position
* @return void
*/
function updateLineUp($rowid, $rang)
public function updateLineUp($rowid, $rang)
{
if ($rang > 1)
{
@@ -2497,7 +2497,7 @@ abstract class CommonObject
* @param int $max Max
* @return void
*/
function updateLineDown($rowid, $rang, $max)
public function updateLineDown($rowid, $rang, $max)
{
if ($rang < $max)
{
@@ -2529,7 +2529,7 @@ abstract class CommonObject
* @param int $rowid Id of line
* @return int Value of rang in table of lines
*/
function getRangOfLine($rowid)
public function getRangOfLine($rowid)
{
$sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE rowid ='.$rowid;
@@ -2549,7 +2549,7 @@ abstract class CommonObject
* @param int $rang Rang value
* @return int Rowid of the line
*/
function getIdOfLine($rang)
public function getIdOfLine($rang)
{
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
@@ -2562,14 +2562,14 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get max value used for position of line (rang)
*
* @param int $fk_parent_line Parent line id
* @return int Max value of rang in table of lines
*/
function line_max($fk_parent_line = 0)
public function line_max($fk_parent_line = 0)
{
// phpcs:enable
// Search the last rang with fk_parent_line
@@ -2610,14 +2610,14 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update external ref of element
*
* @param string $ref_ext Update field ref_ext
* @return int <0 if KO, >0 if OK
*/
function update_ref_ext($ref_ext)
public function update_ref_ext($ref_ext)
{
// phpcs:enable
if (! $this->table_element)
@@ -2643,7 +2643,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update note of element
*
@@ -2651,7 +2651,7 @@ abstract class CommonObject
* @param string $suffix '', '_public' or '_private'
* @return int <0 if KO, >0 if OK
*/
function update_note($note, $suffix = '')
public function update_note($note, $suffix = '')
{
// phpcs:enable
global $user;
@@ -2696,7 +2696,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update public note (kept for backward compatibility)
*
@@ -2705,13 +2705,13 @@ abstract class CommonObject
* @deprecated
* @see update_note()
*/
function update_note_public($note)
public function update_note_public($note)
{
// phpcs:enable
return $this->update_note($note, '_public');
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
* Must be called at end of methods addline or updateline.
@@ -2722,7 +2722,7 @@ abstract class CommonObject
* @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
* @return int <0 if KO, >0 if OK
*/
function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null)
public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null)
{
// phpcs:enable
global $conf, $hookmanager, $action;
@@ -2950,7 +2950,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Add objects linked in llx_element_element.
*
@@ -2959,7 +2959,7 @@ abstract class CommonObject
* @return int <=0 if KO, >0 if OK
* @see fetchObjectLinked(), updateObjectLinked(), deleteObjectLinked()
*/
function add_object_linked($origin = null, $origin_id = null)
public function add_object_linked($origin = null, $origin_id = null)
{
// phpcs:enable
$origin = (! empty($origin) ? $origin : $this->origin);
@@ -3020,7 +3020,7 @@ abstract class CommonObject
* @return int <0 if KO, >0 if OK
* @see add_object_linked(), updateObjectLinked(), deleteObjectLinked()
*/
function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)
public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)
{
global $conf;
@@ -3224,7 +3224,7 @@ abstract class CommonObject
* @return int >0 if OK, <0 if KO
* @see add_object_linked(), fetObjectLinked(), deleteObjectLinked()
*/
function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '')
public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '')
{
$updatesource=false;
$updatetarget=false;
@@ -3271,7 +3271,7 @@ abstract class CommonObject
* @return int >0 if OK, <0 if KO
* @see add_object_linked, updateObjectLinked, fetchObjectLinked
*/
function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '')
public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '')
{
$deletesource=false;
$deletetarget=false;
@@ -3332,7 +3332,7 @@ abstract class CommonObject
* @param string $trigkey Trigger key to use for trigger
* @return int <0 if KO, >0 if OK
*/
function setStatut($status, $elementId = null, $elementType = '', $trigkey = '')
public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '')
{
global $user,$langs,$conf;
@@ -3420,7 +3420,7 @@ abstract class CommonObject
* @param string $ref Record ref
* @return int <0 if KO, 0 if nothing done, >0 if OK
*/
function getCanvas($id = 0, $ref = '')
public function getCanvas($id = 0, $ref = '')
{
global $conf;
@@ -3461,7 +3461,7 @@ abstract class CommonObject
* @param int $lineid Id of line
* @return int Special code
*/
function getSpecialCode($lineid)
public function getSpecialCode($lineid)
{
$sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE rowid = '.$lineid;
@@ -3480,7 +3480,7 @@ abstract class CommonObject
* @param int $id Force id of object
* @return int <0 if KO, 0 if not used, >0 if already used
*/
function isObjectUsed($id = 0)
public function isObjectUsed($id = 0)
{
global $langs;
@@ -3549,7 +3549,7 @@ abstract class CommonObject
* @param int $predefined -1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service
* @return int <0 if KO, 0 if no predefined products, nb of lines with predefined products if found
*/
function hasProductsOrServices($predefined = -1)
public function hasProductsOrServices($predefined = -1)
{
$nb=0;
@@ -3572,7 +3572,7 @@ abstract class CommonObject
*
* @return float
*/
function getTotalDiscount()
public function getTotalDiscount()
{
$total_discount=0.00;
@@ -3612,7 +3612,7 @@ abstract class CommonObject
*
* @return array array('weight'=>...,'volume'=>...)
*/
function getTotalWeightVolume()
public function getTotalWeightVolume()
{
$totalWeight = 0;
$totalVolume = 0;
@@ -3706,7 +3706,7 @@ abstract class CommonObject
*
* @return int <0 if KO, >0 if OK
*/
function setExtraParameters()
public function setExtraParameters()
{
$this->db->begin();
@@ -3739,7 +3739,7 @@ abstract class CommonObject
*
* @return string incoterms info
*/
function display_incoterms()
public function display_incoterms()
{
// phpcs:enable
$out = '';
@@ -3765,7 +3765,7 @@ abstract class CommonObject
*
* @return string incoterms info
*/
function getIncotermsForPDF()
public function getIncotermsForPDF()
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$resql = $this->db->query($sql);
@@ -3796,7 +3796,7 @@ abstract class CommonObject
* @param string $location location of incoterm
* @return int <0 if KO, >0 if OK
*/
function setIncoterms($id_incoterm, $location)
public function setIncoterms($id_incoterm, $location)
{
if ($this->id && $this->table_element)
{
@@ -3844,7 +3844,7 @@ abstract class CommonObject
* @param Societe $buyer Object thirdparty who buy
* @return void
*/
function formAddObjectLine($dateSelector, $seller, $buyer)
public function formAddObjectLine($dateSelector, $seller, $buyer)
{
global $conf,$user,$langs,$object,$hookmanager;
global $form,$bcnd,$var;
@@ -3887,7 +3887,7 @@ abstract class CommonObject
* @param int $dateSelector 1=Show also date range input fields
* @return void
*/
function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0)
public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0)
{
global $conf, $hookmanager, $langs, $user;
// TODO We should not use global var for this !
@@ -4029,8 +4029,8 @@ abstract class CommonObject
* Return HTML content of a detail line
* TODO Move this into an output class file (htmlline.class.php)
*
* @param string $action GET/POST action
* @param CommonObjectLine $line Selected object line to output
* @param string $action GET/POST action
* @param CommonObjectLine $line Selected object line to output
* @param string $var Is it a an odd line (true)
* @param int $num Number of line (0)
* @param int $i I
@@ -4041,7 +4041,7 @@ abstract class CommonObject
* @param int $extrafieldsline Object of extrafield line attribute
* @return void
*/
function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0)
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0)
{
global $conf,$langs,$user,$object,$hookmanager;
global $form,$bc,$bcdd;
@@ -4159,7 +4159,7 @@ abstract class CommonObject
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only
* @return void
*/
function printOriginLinesList($restrictlist = '')
public function printOriginLinesList($restrictlist = '')
{
global $langs, $hookmanager, $conf;
@@ -4213,7 +4213,7 @@ abstract class CommonObject
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not)
* @return void
*/
function printOriginLine($line, $var, $restrictlist = '')
public function printOriginLine($line, $var, $restrictlist = '')
{
global $langs, $conf;
@@ -4348,7 +4348,7 @@ abstract class CommonObject
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Add resources to the current object : add entry into llx_element_resources
* Need $this->element & $this->id
@@ -4359,7 +4359,7 @@ abstract class CommonObject
* @param int $mandatory Mandatory or not
* @return int <=0 if KO, >0 if OK
*/
function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0)
public function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0)
{
// phpcs:enable
$this->db->begin();
@@ -4394,7 +4394,7 @@ abstract class CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Delete a link to resource line
*
@@ -4403,7 +4403,7 @@ abstract class CommonObject
* @param int $notrigger Disable all triggers
* @return int >0 if OK, <0 if KO
*/
function delete_resource($rowid, $element, $notrigger = 0)
public function delete_resource($rowid, $element, $notrigger = 0)
{
// phpcs:enable
global $user;
@@ -4440,7 +4440,7 @@ abstract class CommonObject
*
* @return void
*/
function __clone()
public function __clone()
{
// Force a copy of this->lines, otherwise it will point to same object.
if (isset($this->lines) && is_array($this->lines))
@@ -4617,9 +4617,15 @@ abstract class CommonObject
if ($useonlinesignature) $setsharekey=true;
if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
}
if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey=true;
}
if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey=true;
}
if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey=true;
}
if ($setsharekey)
{
@@ -4717,7 +4723,7 @@ abstract class CommonObject
* @param string $file Path file in UTF8 to original file to create thumbs from.
* @return void
*/
function addThumbs($file)
public function addThumbs($file)
{
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
@@ -4753,7 +4759,7 @@ abstract class CommonObject
* @param string $alternatevalue Alternate value to use
* @return string|string[] Default value (can be an array if the GETPOST return an array)
**/
function getDefaultCreateValueFor($fieldname, $alternatevalue = null)
public function getDefaultCreateValueFor($fieldname, $alternatevalue = null)
{
global $conf, $_POST;
@@ -4782,7 +4788,7 @@ abstract class CommonObject
/* For triggers */
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Call trigger based on this instance.
* Some context information may also be provided into array property this->context.
@@ -4793,7 +4799,7 @@ abstract class CommonObject
* @param User $user Object user
* @return int Result of run_triggers
*/
function call_trigger($trigger_name, $user)
public function call_trigger($trigger_name, $user)
{
// phpcs:enable
global $langs,$conf;
@@ -4820,7 +4826,7 @@ abstract class CommonObject
/* Functions for extrafields */
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to get extra fields of an object into $this->array_options
* This method is in most cases called by method fetch of objects but you can call it separately.
@@ -4829,7 +4835,7 @@ abstract class CommonObject
* @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters.
* @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded
*/
function fetch_optionals($rowid = null, $optionsArray = null)
public function fetch_optionals($rowid = null, $optionsArray = null)
{
// phpcs:enable
if (empty($rowid)) $rowid=$this->id;
@@ -4940,7 +4946,7 @@ abstract class CommonObject
*
* @return int <0 if KO, >0 if OK
*/
function deleteExtraFields()
public function deleteExtraFields()
{
$this->db->begin();
@@ -4973,7 +4979,7 @@ abstract class CommonObject
* @return int -1=error, O=did nothing, 1=OK
* @see updateExtraField(), setValueFrom()
*/
function insertExtraFields($trigger = '', $userused = null)
public function insertExtraFields($trigger = '', $userused = null)
{
global $conf,$langs,$user;
@@ -5219,7 +5225,7 @@ abstract class CommonObject
* @return int -1=error, O=did nothing, 1=OK
* @see setValueFrom(), insertExtraFields()
*/
function updateExtraField($key, $trigger = null, $userused = null)
public function updateExtraField($key, $trigger = null, $userused = null)
{
global $conf,$langs,$user;
@@ -5353,7 +5359,7 @@ abstract class CommonObject
* @param string|int $morecss Value for css to define style/length of field. May also be a numeric.
* @return string
*/
function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0)
public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0)
{
global $conf,$langs,$form;
@@ -5963,7 +5969,7 @@ abstract class CommonObject
* @param mixed $showsize Value for css to define size. May also be a numeric.
* @return string
*/
function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0)
public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0)
{
global $conf,$langs,$form;
@@ -6334,7 +6340,7 @@ abstract class CommonObject
* @param string $onetrtd All fields in same tr td
* @return string
*/
function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0)
public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0)
{
global $db, $conf, $langs, $action, $form;
@@ -6642,7 +6648,7 @@ abstract class CommonObject
return $buyPrice;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show photos of an object (nbmax maximum), into several columns
*
@@ -6660,7 +6666,7 @@ abstract class CommonObject
* @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead)
* @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
*/
function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0)
public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0)
{
// phpcs:enable
global $conf,$user,$langs;
@@ -7474,15 +7480,15 @@ abstract class CommonObject
return count($this->comments);
}
/**
* Return nb comments already posted
*
* @return int
*/
public function getNbComments()
{
return count($this->comments);
}
/**
* Return nb comments already posted
*
* @return int
*/
public function getNbComments()
{
return count($this->comments);
}
/**
* Trim object parameters