Skip to content

Commit

Permalink
Fix: uniformize code
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Mar 13, 2012
1 parent 150f3ec commit deb30b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 3 additions & 7 deletions htdocs/comm/fiche.php
Expand Up @@ -89,13 +89,9 @@
if ($action == 'setconditions' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->cond_reglement=$_POST['cond_reglement_id'];

// TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id'];
$sql.= "' WHERE rowid='".$id."'";
$result = $db->query($sql);
if (! $result) dol_print_error($result);
$object->cond_reglement=GETPOST('cond_reglement_id','int');
$result=$object->setPaymentTerms($object->cond_reglement);
if ($result < 0) dol_print_error($db,$object->error);
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer)
Expand Down
8 changes: 6 additions & 2 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -871,8 +871,12 @@ function setProject($projectid)
function setPaymentTerms($id)
{
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
if ($this->statut >= 0)
{
if ($this->statut >= 0 || $this->element == 'societe')
{
// TODO uniformize field name
$fieldname = 'fk_cond_reglement';
if ($this->element == 'societe') $fieldname = 'cond_reglement';

$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET fk_cond_reglement = '.$id;
$sql .= ' WHERE rowid='.$this->id;
Expand Down

0 comments on commit deb30b6

Please sign in to comment.