Fix: move method in common class
This commit is contained in:
parent
dcf72206f0
commit
150f3ecfe3
@ -989,7 +989,7 @@ else if ($action == 'setdemandreason')
|
||||
else if ($action == 'setconditions')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->cond_reglement($_POST['cond_reglement_id']);
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
}
|
||||
|
||||
else if ($action == 'setremisepercent' && $user->rights->propale->creer)
|
||||
|
||||
@ -1886,6 +1886,7 @@ class Propal extends CommonObject
|
||||
*
|
||||
* @param int $cond_reglement_id Id of new payment condition
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* TODO deprecated
|
||||
*/
|
||||
function cond_reglement($cond_reglement_id)
|
||||
{
|
||||
|
||||
@ -1980,6 +1980,7 @@ class Commande extends CommonObject
|
||||
*
|
||||
* @param int $cond_reglement_id Id de la nouvelle condition de reglement
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* TODO deprecated
|
||||
*/
|
||||
function cond_reglement($cond_reglement_id)
|
||||
{
|
||||
|
||||
@ -470,7 +470,7 @@ if ($action == 'setdemandreason' && $user->rights->commande->creer)
|
||||
if ($action == 'setconditions' && $user->rights->commande->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->cond_reglement($_POST['cond_reglement_id']);
|
||||
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
|
||||
@ -267,6 +267,7 @@ if ($action == 'setinvoicedate')
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
// TODO obsolete ? not used
|
||||
if ($action == 'setpaymentterm')
|
||||
{
|
||||
$object->fetch($id);
|
||||
@ -278,7 +279,7 @@ if ($action == 'setpaymentterm')
|
||||
if ($action == 'setconditions')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->cond_reglement($_POST['cond_reglement_id']);
|
||||
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
|
||||
@ -2692,6 +2692,7 @@ class Facture extends CommonObject
|
||||
* @param int $cond_reglement_id Id de la nouvelle condition de reglement
|
||||
* @param date $date Date to force payment term
|
||||
* @return int >0 si ok, <0 si ko
|
||||
* TODO deprecated, not used
|
||||
*/
|
||||
function cond_reglement($cond_reglement_id,$date='')
|
||||
{
|
||||
|
||||
@ -861,8 +861,42 @@ abstract class CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Change the payments terms
|
||||
*
|
||||
* @param int $id Id of new payment terms
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function setPaymentTerms($id)
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
|
||||
if ($this->statut >= 0)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET fk_cond_reglement = '.$id;
|
||||
$sql .= ' WHERE rowid='.$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->cond_reglement_id = $id;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
|
||||
$this->error='Status of the object is incompatible '.$this->statut;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set last model used by doc generator
|
||||
*
|
||||
|
||||
@ -115,7 +115,7 @@ if ($action == 'setconditions' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($id);
|
||||
$result=$commande->cond_reglement(GETPOST('mode_reglement_id','int'));
|
||||
$result=$commande->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$commande->error);
|
||||
}
|
||||
|
||||
|
||||
@ -1305,6 +1305,7 @@ class CommandeFournisseur extends Commande
|
||||
*
|
||||
* @param int $cond_reglement_id Id de la nouvelle condition de reglement
|
||||
* @return int >0 si ok, <0 si ko
|
||||
* TODO deprecated
|
||||
*/
|
||||
function cond_reglement($cond_reglement_id)
|
||||
{
|
||||
|
||||
@ -77,7 +77,7 @@ $object = new CommandeFournisseur($db);
|
||||
if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->cond_reglement($_POST['cond_reglement_id']);
|
||||
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
}
|
||||
|
||||
// mode de reglement
|
||||
|
||||
Loading…
Reference in New Issue
Block a user