Skip to content

Commit

Permalink
Fix: use getEntity if no rowid to compare
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Mar 8, 2018
1 parent 93a9430 commit fd9c79f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 1 addition & 3 deletions htdocs/compta/bank/class/account.class.php
Expand Up @@ -399,8 +399,6 @@ function get_url($fk_bank='', $url_id='', $type='')
*/
function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='')
{
global $conf;

// Deprecatîon warning
if (is_numeric($oper)) {
dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING);
Expand All @@ -416,7 +414,7 @@ function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user
{
$sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE id=".$oper;
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity IN (".getEntity('c_paiement').")";
$resql=$this->db->query($sql);
if ($resql)
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/compta/facture/class/paymentterm.class.php
Expand Up @@ -102,7 +102,7 @@ function create($user, $notrigger=0)
$sql.= "decalage";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").",";
$sql.= " ".(! isset($this->entity)?$conf->entity:"'".$this->db->escape($this->entity)."'").",";
$sql.= " ".(! isset($this->entity)?getEntity('c_payment_term'):"'".$this->db->escape($this->entity)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->sortorder)?'NULL':"'".$this->db->escape($this->sortorder)."'").",";
$sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").",";
Expand Down Expand Up @@ -222,15 +222,15 @@ function fetch($id)
*/
function getDefaultId()
{
global $conf, $langs;
global $langs;

$ret=0;

$sql = "SELECT";
$sql.= " t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.code = 'RECEP'";
$sql.= " AND t.entity = " . $conf->entity;
$sql.= " AND t.entity IN (".getEntity('c_payment_term').")";

dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG);
$resql=$this->db->query($sql);
Expand Down
4 changes: 1 addition & 3 deletions htdocs/core/class/commoninvoice.class.php
Expand Up @@ -595,8 +595,6 @@ function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0)
*/
function calculate_date_lim_reglement($cond_reglement=0)
{
global $conf;

if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code;
if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id;

Expand All @@ -606,7 +604,7 @@ function calculate_date_lim_reglement($cond_reglement=0)
$sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement;
else {
$sqltemp.= " WHERE c.entity = ".$conf->entity;
$sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")";
$sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'";
}

Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -2784,7 +2784,7 @@ function select_address($selected, $socid, $htmlname='address_id',$showempty=0)
*/
function load_cache_conditions_paiements()
{
global $conf, $langs;
global $langs;

$num = count($this->cache_conditions_paiements);
if ($num > 0) return 0; // Cache already loaded
Expand All @@ -2793,7 +2793,7 @@ function load_cache_conditions_paiements()

$sql = "SELECT rowid, code, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term';
$sql.= " WHERE entity = " . $conf->entity;
$sql.= " WHERE entity IN (".getEntity('c_payment_term').")";
$sql.= " AND active > 0";
$sql.= " ORDER BY sortorder";

Expand Down Expand Up @@ -2997,7 +2997,7 @@ function selectInputReason($selected='',$htmlname='demandreasonid',$exclude='',$
*/
function load_cache_types_paiements()
{
global $conf, $langs;
global $langs;

$num=count($this->cache_types_paiements);
if ($num > 0) return $num; // Cache already loaded
Expand All @@ -3008,7 +3008,7 @@ function load_cache_types_paiements()

$sql = "SELECT id, code, libelle as label, type, active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " WHERE entity IN (".getEntity('c_paiement').")";
//if ($active >= 0) $sql.= " AND active = ".$active;

$resql = $this->db->query($sql);
Expand Down

0 comments on commit fd9c79f

Please sign in to comment.