Skip to content

Commit

Permalink
Fix: move method in common class
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Mar 13, 2012
1 parent dcf7220 commit 150f3ec
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 7 deletions.
2 changes: 1 addition & 1 deletion htdocs/comm/propal.php
Expand Up @@ -989,7 +989,7 @@
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)
Expand Down
1 change: 1 addition & 0 deletions htdocs/comm/propal/class/propal.class.php
Expand Up @@ -1886,6 +1886,7 @@ function delete($user, $notrigger=0)
*
* @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)
{
Expand Down
1 change: 1 addition & 0 deletions htdocs/commande/class/commande.class.php
Expand Up @@ -1980,6 +1980,7 @@ function liste_array($brouillon=0, $user='')
*
* @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)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/fiche.php
Expand Up @@ -470,7 +470,7 @@
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);
}

Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/facture.php
Expand Up @@ -267,6 +267,7 @@
if ($result < 0) dol_print_error($db,$object->error);
}

// TODO obsolete ? not used
if ($action == 'setpaymentterm')
{
$object->fetch($id);
Expand All @@ -278,7 +279,7 @@
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);
}

Expand Down
1 change: 1 addition & 0 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -2692,6 +2692,7 @@ function info($id)
* @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='')
{
Expand Down
38 changes: 36 additions & 2 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -861,8 +861,42 @@ function setProject($projectid)
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
*
Expand Down
2 changes: 1 addition & 1 deletion htdocs/expedition/shipment.php
Expand Up @@ -115,7 +115,7 @@
{
$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);
}

Expand Down
1 change: 1 addition & 0 deletions htdocs/fourn/class/fournisseur.commande.class.php
Expand Up @@ -1305,6 +1305,7 @@ function get_methodes_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)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/commande/fiche.php
Expand Up @@ -77,7 +77,7 @@
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
Expand Down

0 comments on commit 150f3ec

Please sign in to comment.