Fix: move method in common class

This commit is contained in:
Regis Houssin
2012-03-13 20:01:10 +01:00
parent 9831a2028c
commit f8bf7ade83
11 changed files with 54 additions and 15 deletions

View File

@@ -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