Fix: move method in common class
This commit is contained in:
parent
9831a2028c
commit
f8bf7ade83
@ -89,21 +89,15 @@ if ($action == 'setcustomeraccountancycode')
|
||||
if ($action == 'setconditions' && $user->rights->societe->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->cond_reglement=GETPOST('cond_reglement_id','int');
|
||||
$result=$object->setPaymentTerms($object->cond_reglement);
|
||||
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
// mode de reglement
|
||||
if ($action == 'setmode' && $user->rights->societe->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->mode_reglement=$_POST['mode_reglement_id'];
|
||||
|
||||
// TODO move to DAO class
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id'];
|
||||
$sql.= "' WHERE rowid='".$id."'";
|
||||
$result = $db->query($sql);
|
||||
if (! $result) dol_print_error($result);
|
||||
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
// assujetissement a la TVA
|
||||
if ($action == 'setassujtva' && $user->rights->societe->creer)
|
||||
|
||||
@ -1008,7 +1008,7 @@ else if ($action == 'setremiseabsolue' && $user->rights->propale->creer)
|
||||
else if ($action == 'setmode')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->mode_reglement($_POST['mode_reglement_id']);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1922,6 +1922,7 @@ class Propal extends CommonObject
|
||||
*
|
||||
* @param int $mode_reglement_id Id of new payment mode
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* TODO deprecated
|
||||
*/
|
||||
function mode_reglement($mode_reglement_id)
|
||||
{
|
||||
|
||||
@ -2016,6 +2016,7 @@ class Commande extends CommonObject
|
||||
*
|
||||
* @param int $mode Id du nouveau mode
|
||||
* @return int >0 si ok, <0 si ko
|
||||
* TODO deprecated
|
||||
*/
|
||||
function mode_reglement($mode_reglement_id)
|
||||
{
|
||||
|
||||
@ -449,7 +449,7 @@ if ($action == 'setaddress' && $user->rights->commande->creer)
|
||||
if ($action == 'setmode' && $user->rights->commande->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->mode_reglement($_POST['mode_reglement_id']);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
|
||||
@ -254,7 +254,7 @@ if ($action == 'classin')
|
||||
if ($action == 'setmode')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->mode_reglement($_POST['mode_reglement_id']);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
|
||||
@ -2742,6 +2742,7 @@ class Facture extends CommonObject
|
||||
*
|
||||
* @param int $mode_reglement_id Id du nouveau mode
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* TODO deprecated
|
||||
*/
|
||||
function mode_reglement($mode_reglement_id)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
@ -107,7 +107,7 @@ if ($action == 'setmode' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($id);
|
||||
$result=$commande->mode_reglement(GETPOST('mode_reglement_id','int'));
|
||||
$result = $commande->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
if ($result < 0) dol_print_error($db,$commande->error);
|
||||
}
|
||||
|
||||
|
||||
@ -1340,6 +1340,7 @@ class CommandeFournisseur extends Commande
|
||||
*
|
||||
* @param int $mode_reglement_id Id du nouveau mode
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* TODO deprecated
|
||||
*/
|
||||
function mode_reglement($mode_reglement_id)
|
||||
{
|
||||
|
||||
@ -84,7 +84,7 @@ if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer)
|
||||
if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->mode_reglement($_POST['mode_reglement_id']);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
}
|
||||
|
||||
// Set project
|
||||
|
||||
Loading…
Reference in New Issue
Block a user