Skip to content

Commit

Permalink
Fix: !!!! Dont't use entity if you use rowid in fetch or others !!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Jul 1, 2018
1 parent f13dd9c commit 26495fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions htdocs/comm/propal/class/propal.class.php
Expand Up @@ -1335,8 +1335,11 @@ function fetch($rowid,$ref='')
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
$sql.= " WHERE p.fk_statut = c.id";
$sql.= " AND p.entity IN (".getEntity('propal').")";
if ($ref) $sql.= " AND p.ref='".$ref."'";

if ($ref) {
$sql.= " AND p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid
$sql.= " AND p.ref='".$ref."'";
}
else $sql.= " AND p.rowid=".$rowid;

dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
Expand Down
6 changes: 4 additions & 2 deletions htdocs/commande/class/commande.class.php
Expand Up @@ -1591,8 +1591,10 @@ function fetch($id, $ref='', $ref_ext='', $ref_int='')
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
$sql.= " WHERE c.entity IN (".getEntity('commande').")";
if ($id) $sql.= " AND c.rowid=".$id;

if ($id) $sql.= " WHERE c.rowid=".$id;
else $sql.= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid

if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
Expand Down
6 changes: 4 additions & 2 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -1274,8 +1274,10 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
$sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
if ($rowid) $sql.= " AND f.rowid=".$rowid;

if ($rowid) $sql.= " WHERE f.rowid=".$rowid;
else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid

if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'";
Expand Down

0 comments on commit 26495fb

Please sign in to comment.