Skip to content

Commit

Permalink
Merge pull request #2673 from aternatik/fix_getentity
Browse files Browse the repository at this point in the history
Fix : missing getEntity calls
  • Loading branch information
eldy committed May 6, 2015
2 parents 2707dcd + e1665be commit b71e5a1
Show file tree
Hide file tree
Showing 53 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/card.php
Expand Up @@ -87,7 +87,7 @@
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}

dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/accountancy/customer/index.php
Expand Up @@ -159,7 +159,7 @@
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}

$sql .= " GROUP BY fd.fk_code_ventilation";
Expand Down Expand Up @@ -234,7 +234,7 @@
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}

dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
Expand Down Expand Up @@ -307,7 +307,7 @@
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}

dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/lines.php
Expand Up @@ -136,7 +136,7 @@
}

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}

$sql .= " ORDER BY l.rowid";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/list.php
Expand Up @@ -132,7 +132,7 @@
$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation <= 0";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}

$sql .= " ORDER BY l.rowid";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/journal/purchasesjournal.php
Expand Up @@ -96,7 +96,7 @@
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " WHERE f.fk_statut > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = " . $conf->entity;
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/journal/sellsjournal.php
Expand Up @@ -99,7 +99,7 @@
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$sql .= " WHERE fd.fk_code_ventilation > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = " . $conf->entity;
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/card.php
Expand Up @@ -88,7 +88,7 @@
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}

$result = $db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/accountancy/supplier/index.php
Expand Up @@ -144,7 +144,7 @@
$sql .= " AND ff.fk_statut > 0 ";

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ff.entity = '" . $conf->entity . "'";
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 1) . ")";
}

$sql .= " GROUP BY ffd.fk_code_ventilation";
Expand Down Expand Up @@ -221,7 +221,7 @@
$sql .= " AND ff.fk_statut > 0 ";

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ff.entity = '" . $conf->entity . "'";
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 1) . ")";
}

dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/lines.php
Expand Up @@ -136,7 +136,7 @@
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
}
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}

$sql .= " ORDER BY l.rowid";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/list.php
Expand Up @@ -135,7 +135,7 @@
$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='')";

if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}

$sql .= " ORDER BY l.rowid";
Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/class/adherent.class.php
Expand Up @@ -1703,7 +1703,7 @@ function load_state_board()
$sql = "SELECT count(a.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.statut > 0";
$sql.= " AND a.entity = ".$conf->entity;
$sql.= " AND a.entity IN (".getEntity('adherent', 1).")";

$resql=$this->db->query($sql);
if ($resql)
Expand Down Expand Up @@ -1741,7 +1741,7 @@ function load_board($user)
$sql = "SELECT a.rowid, a.datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.statut = 1";
$sql.= " AND a.entity = ".$conf->entity;
$sql.= " AND a.entity IN (".getEntity('adherent', 1).")";
$sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";

$resql=$this->db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/class/adherentstats.class.php
Expand Up @@ -65,7 +65,7 @@ function __construct($db, $socid=0, $userid=0)
$this->field='cotisation';

$this->where.= " m.statut != 0";
$this->where.= " AND p.fk_adherent = m.rowid AND m.entity = ".$conf->entity;
$this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent', 1).")";
//if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($this->memberid)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/list.php
Expand Up @@ -99,7 +99,7 @@
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
$sql.= " AND d.entity = ".$conf->entity;
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")";
if ($sall)
{
// For natural search
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/tools/listevents.php
Expand Up @@ -123,7 +123,7 @@
$sql.= " u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."events as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
$sql.= " WHERE e.entity = ".$conf->entity;
$sql.= " WHERE e.entity IN (".getEntity('actioncomm', 1).")";
if ($search_code) { $usefilter++; $sql.=" AND e.type LIKE '%".$db->escape($search_code)."%'"; }
if ($search_ip) { $usefilter++; $sql.=" AND e.ip LIKE '%".$db->escape($search_ip)."%'"; }
if ($search_user) { $usefilter++; $sql.=" AND u.login LIKE '%".$db->escape($search_user)."%'"; }
Expand Down
6 changes: 3 additions & 3 deletions htdocs/comm/action/class/actioncomm.class.php
Expand Up @@ -746,7 +746,7 @@ static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filte

$sql = "SELECT a.id";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " WHERE a.entity = ".$conf->entity;
$sql.= " WHERE a.entity IN (".getEntity('actioncomm', 1).")";
if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid;
if (! empty($elementtype))
{
Expand Down Expand Up @@ -797,7 +797,7 @@ function load_board($user)
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql.= " WHERE a.percent >= 0 AND a.percent < 100";
$sql.= " AND a.entity = ".$conf->entity;
$sql.= " AND a.entity IN (".getEntity('actioncomm', 1).")";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
Expand Down Expand Up @@ -1094,7 +1094,7 @@ function build_exportfile($format,$type,$cachedelay,$filename,$filters)
// We must filter on assignement table
if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
$sql.= " WHERE a.fk_action=c.id";
$sql.= " AND a.entity = ".$conf->entity;
$sql.= " AND a.entity IN (".getEntity('actioncomm', 1).")";
foreach ($filters as $key => $value)
{
if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/card.php
Expand Up @@ -685,7 +685,7 @@
$sql.= ', s.rowid as socid';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
$sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql.= " AND e.entity = ".$conf->entity;
$sql.= " AND e.entity IN (".getEntity('expedition', 1).")";
$sql.= ' GROUP BY e.rowid';
$sql.= ', e.ref';
$sql.= ', e.date_creation';
Expand Down
10 changes: 5 additions & 5 deletions htdocs/comm/index.php
Expand Up @@ -164,7 +164,7 @@
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_statut = 0";
$sql.= " AND p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;

Expand Down Expand Up @@ -235,7 +235,7 @@
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.fk_statut = 0";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND c.fk_soc = ".$socid;

Expand Down Expand Up @@ -440,7 +440,7 @@
$sql.= ", ".MAIN_DB_PREFIX."product as p";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('contrat', 1).")";
$sql.= " AND c.fk_product = p.rowid";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
Expand Down Expand Up @@ -496,7 +496,7 @@
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
$sql.= " AND p.fk_statut = 1";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
Expand Down Expand Up @@ -592,7 +592,7 @@
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
$sql.= " AND c.fk_statut = 1";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal.php
Expand Up @@ -1565,7 +1565,7 @@
$sql .= " FROM " . MAIN_DB_PREFIX . "propal p";
$sql .= ", " . MAIN_DB_PREFIX . "societe s";
$sql .= " WHERE s.rowid = p.fk_soc";
$sql .= " AND p.entity = " . $conf->entity;
$sql .= " AND p.entity IN (".getEntity('propal', 1).")";
$sql .= " AND p.fk_statut <> 0";
$sql .= " ORDER BY Id";

Expand Down
8 changes: 4 additions & 4 deletions htdocs/comm/propal/class/propal.class.php
Expand Up @@ -1202,7 +1202,7 @@ 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 = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
if ($ref) $sql.= " AND p.ref='".$ref."'";
else $sql.= " AND p.rowid=".$rowid;

Expand Down Expand Up @@ -2021,7 +2021,7 @@ function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " WHERE p.entity IN (".getEntity('propal', 1).")";
$sql.= " AND p.fk_soc = s.rowid";
$sql.= " AND p.fk_statut = c.id";
if (! $user->rights->societe->client->voir && ! $socid) //restriction
Expand Down Expand Up @@ -2476,7 +2476,7 @@ function load_board($user,$mode)
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = " AND";
}
$sql.= $clause." p.entity = ".$conf->entity;
$sql.= $clause." p.entity IN (".getEntity('propal', 1).")";
if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED;
if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED;
if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id;
Expand Down Expand Up @@ -2639,7 +2639,7 @@ function load_state_board()
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= " ".$clause." p.entity = ".$conf->entity;
$sql.= " ".$clause." p.entity IN (".getEntity('propal', 1).")";

$resql=$this->db->query($sql);
if ($resql)
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/class/propalestats.class.php
Expand Up @@ -69,7 +69,7 @@ function __construct($db, $socid=0, $userid=0)

$this->where.= " p.fk_statut > 0";
//$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
$this->where.= " AND p.entity = ".$conf->entity;
$this->where.= " AND p.entity IN (".getEntity('propal', 1).")";
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($this->socid)
{
Expand Down
8 changes: 4 additions & 4 deletions htdocs/comm/propal/index.php
Expand Up @@ -83,7 +83,7 @@
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " AND p.fk_statut IN (0,1,2,3,4)";
Expand Down Expand Up @@ -159,7 +159,7 @@
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('propal', 1).")";
$sql.= " AND c.fk_statut = 0";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
Expand Down Expand Up @@ -217,7 +217,7 @@
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('propal', 1).")";
//$sql.= " AND c.fk_statut > 2";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
Expand Down Expand Up @@ -296,7 +296,7 @@
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
$sql.= " AND p.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/list.php
Expand Up @@ -162,7 +162,7 @@
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
}
$sql.= ' WHERE p.fk_soc = s.rowid';
$sql.= ' AND p.entity = '.$conf->entity;
$sql.= ' AND p.entity IN ('.getEntity('propal', 1).')';
if (! $user->rights->societe->client->voir && ! $socid) //restriction
{
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/comm/prospect/index.php
Expand Up @@ -120,7 +120,7 @@
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_statut = 0";
$sql.= " AND p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;

$resql=$db->query($sql);
Expand Down Expand Up @@ -183,7 +183,7 @@
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.fk_statut = c.id";
$sql.= " AND p.fk_statut = 1";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY p.rowid DESC";
Expand Down
8 changes: 4 additions & 4 deletions htdocs/commande/class/commande.class.php
Expand Up @@ -1473,7 +1473,7 @@ 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 = ".$conf->entity;
$sql.= " WHERE c.entity IN (".getEntity('commande', 1).")";
if ($id) $sql.= " AND c.rowid=".$id;
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
Expand Down Expand Up @@ -2194,7 +2194,7 @@ function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " WHERE c.entity IN (".getEntity('commande', 1).")";
$sql.= " AND c.fk_soc = s.rowid";
if (! $user->rights->societe->client->voir && ! $socid) //restriction
{
Expand Down Expand Up @@ -2836,7 +2836,7 @@ function load_board($user)
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = " AND";
}
$sql.= $clause." c.entity = ".$conf->entity;
$sql.= $clause." c.entity IN (".getEntity('commande', 1).")";
//$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
Expand Down Expand Up @@ -3173,7 +3173,7 @@ function load_state_board()
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= " ".$clause." co.entity = ".$conf->entity;
$sql.= " ".$clause." co.entity IN (".getEntity('commande', 1).")";

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

0 comments on commit b71e5a1

Please sign in to comment.