mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Fix: move method in common class
This commit is contained in:
@@ -862,6 +862,46 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the payments methods
|
||||
*
|
||||
* @param int $id Id of new payment method
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function setPaymentMethods($id)
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
|
||||
if ($this->statut >= 0 || $this->element == 'societe')
|
||||
{
|
||||
// TODO uniformize field name
|
||||
$fieldname = 'fk_mode_reglement';
|
||||
if ($this->element == 'societe') $fieldname = 'mode_reglement';
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.$id;
|
||||
$sql .= ' WHERE rowid='.$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->mode_reglement_id = $id;
|
||||
$this->mode_reglement = $id; // for compatibility
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
|
||||
$this->error='Status of the object is incompatible '.$this->statut;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the payments terms
|
||||
*
|
||||
@@ -883,7 +923,8 @@ abstract class CommonObject
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->cond_reglement_id = $id;
|
||||
$this->cond_reglement_id = $id;
|
||||
$this->cond_reglement = $id; // for compatibility
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user