Merge pull request #2673 from aternatik/fix_getentity

Fix : missing getEntity calls
This commit is contained in:
Laurent Destailleur 2015-05-07 00:48:19 +02:00
commit b71e5a1025
53 changed files with 110 additions and 110 deletions

View File

@ -87,7 +87,7 @@ if (! empty($id)) {
$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);

View File

@ -159,7 +159,7 @@ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'
$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";
@ -234,7 +234,7 @@ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'
$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);
@ -307,7 +307,7 @@ if (! empty($conf->margin->enabled)) {
$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);

View File

@ -136,7 +136,7 @@ if (strlen(trim($search_account))) {
}
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
$sql .= " ORDER BY l.rowid";

View File

@ -132,7 +132,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.
$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";

View File

@ -96,7 +96,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_factu
$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)";

View File

@ -99,7 +99,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$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))

View File

@ -88,7 +88,7 @@ if ($_GET["id"]) {
$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);

View File

@ -144,7 +144,7 @@ $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'
$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";
@ -221,7 +221,7 @@ $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'
$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);

View File

@ -136,7 +136,7 @@ if (strlen(trim($search_account))) {
$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";

View File

@ -135,7 +135,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_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";

View File

@ -1703,7 +1703,7 @@ class Adherent extends CommonObject
$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)
@ -1741,7 +1741,7 @@ class Adherent extends CommonObject
$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);

View File

@ -65,7 +65,7 @@ class AdherentStats extends Stats
$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)
{

View File

@ -99,7 +99,7 @@ if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
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

View File

@ -123,7 +123,7 @@ $sql.= " e.fk_user, e.description,";
$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)."%'"; }

View File

@ -746,7 +746,7 @@ class ActionComm extends CommonObject
$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))
{
@ -797,7 +797,7 @@ class ActionComm extends CommonObject
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 . ")";
@ -1094,7 +1094,7 @@ class ActionComm extends CommonObject
// 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))."'";

View File

@ -685,7 +685,7 @@ if ($id > 0)
$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';

View File

@ -164,7 +164,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
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;
@ -235,7 +235,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
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;
@ -440,7 +440,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO
$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;
@ -496,7 +496,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
$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;
@ -592,7 +592,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
$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;

View File

@ -1565,7 +1565,7 @@ if ($action == 'create')
$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";

View File

@ -1202,7 +1202,7 @@ class Propal extends CommonObject
$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;
@ -2021,7 +2021,7 @@ class Propal extends CommonObject
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
@ -2476,7 +2476,7 @@ class Propal extends CommonObject
$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;
@ -2639,7 +2639,7 @@ class Propal extends CommonObject
$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)

View File

@ -69,7 +69,7 @@ class PropaleStats extends Stats
$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)
{

View File

@ -83,7 +83,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$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)";
@ -159,7 +159,7 @@ if (! empty($conf->propal->enabled))
$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;
@ -217,7 +217,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
$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;
@ -296,7 +296,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
$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;

View File

@ -162,7 +162,7 @@ if ($search_user > 0)
$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;

View File

@ -120,7 +120,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
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);
@ -183,7 +183,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
$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";

View File

@ -1473,7 +1473,7 @@ class Commande extends CommonOrder
$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)."'";
@ -2194,7 +2194,7 @@ class Commande extends CommonOrder
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
{
@ -2836,7 +2836,7 @@ class Commande extends CommonOrder
$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;
@ -3173,7 +3173,7 @@ class Commande extends CommonOrder
$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)

View File

@ -73,7 +73,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (dol_strlen($stcomm))
{

View File

@ -82,7 +82,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$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('societe', 1).")";
if ($user->societe_id) $sql.=' AND c.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.= " GROUP BY c.fk_statut, c.facture";
@ -171,7 +171,7 @@ if (! empty($conf->commande->enabled))
$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('commande', 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;
@ -220,7 +220,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
$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('commande', 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;
@ -290,7 +290,7 @@ if (! empty($conf->commande->enabled))
$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('commande', 1).")";
$sql.= " AND c.fk_statut = 1";
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;
@ -361,7 +361,7 @@ if (! empty($conf->commande->enabled))
$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('commande', 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;

View File

@ -127,7 +127,7 @@ if ($search_user > 0)
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
}
$sql.= ' WHERE c.fk_soc = s.rowid';
$sql.= ' AND c.entity = '.$conf->entity;
$sql.= ' AND c.entity IN ('.getEntity('commande', 1).')';
if ($socid) $sql.= ' AND s.rowid = '.$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_ref) {

View File

@ -526,7 +526,7 @@ if (($action != 'create' && $action != 'add') || !$error)
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$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.entity = '.$conf->entity;
$sql.= ' WHERE c.entity IN ('.getEntity('commande', 1).')';
$sql.= ' AND c.fk_soc = s.rowid';
// Show orders with status validated, shipping started and delivered (well any order we can bill)

View File

@ -264,7 +264,7 @@ if ($id > 0 || ! empty($ref))
}
$sql.= " WHERE b.fk_account = ".$object->id;
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= $sql_rech;
dol_syslog("account.php count transactions -", LOG_DEBUG);
@ -512,7 +512,7 @@ if ($id > 0 || ! empty($ref))
}
$sql.= " WHERE b.fk_account=".$object->id;
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= $sql_rech;
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
$sql.= $db->plimit($limitsql, 0);

View File

@ -80,7 +80,7 @@ $sql.= ", date_format(b.dateo,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.amount >= 0";
if (! empty($id))
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
@ -108,7 +108,7 @@ $sql.= ", date_format(b.dateo,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.amount <= 0";
if (! empty($id))
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
@ -261,7 +261,7 @@ $sql = "SELECT SUM(b.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if (! empty($id))
$sql.= " AND b.fk_account IN (".$db->escape($id).")";
@ -302,7 +302,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")";
$resql = $db->query($sql);
@ -333,7 +333,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
$sql.= " AND b.amount > 0";
@ -422,7 +422,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
$sql.= " AND b.amount < 0";

View File

@ -930,7 +930,7 @@ class Account extends CommonObject
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.rappro=0";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
@ -1191,7 +1191,7 @@ class AccountLine extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'";
else if ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'";
else $sql.= " AND b.rowid=".$rowid;

View File

@ -90,7 +90,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
$resql = $db->query($sql);
@ -129,7 +129,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
@ -160,7 +160,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev < '".$year."-".sprintf("%02s",$month)."-01'";
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
@ -272,7 +272,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
@ -303,7 +303,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev < '".$year."-01-01'";
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
@ -411,7 +411,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
$sql.= " GROUP BY date_format(b.datev,'%Y%m%d')";
@ -534,7 +534,7 @@ else
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
$sql.= " AND b.amount > 0";
@ -572,7 +572,7 @@ else
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
$sql.= " AND b.amount < 0";
@ -652,7 +652,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
$sql.= " AND b.amount > 0";
@ -681,7 +681,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
$sql.= " AND b.amount < 0";

View File

@ -110,7 +110,7 @@ $sql.= " ".MAIN_DB_PREFIX."bank as b";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if (GETPOST("req_nb"))
{
$sql.= " AND b.num_chq LIKE '%".$db->escape(GETPOST("req_nb"))."%'";

View File

@ -376,7 +376,7 @@ if ($action == 'new')
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_type = 'CHQ'";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.fk_bordereau = 0";
$sql.= " AND b.amount > 0";
if ($filterdate) $sql.=" AND b.dateo = '".$db->idate($filterdate)."'";
@ -599,7 +599,7 @@ else
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql.= " WHERE ba.rowid = b.fk_account";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.fk_type= 'CHQ'";
$sql.= " AND b.fk_bordereau = ".$object->id;
$sql.= " ORDER BY $sortfield $sortorder";

View File

@ -445,7 +445,7 @@ class RemiseCheque extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND b.fk_type = 'CHQ'";
$sql.= " AND b.fk_bordereau = 0";
$sql.= " AND b.amount > 0";

View File

@ -235,7 +235,7 @@ if ($modecompta != 'CREANCES-DETTES')
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY name, idp";

View File

@ -155,7 +155,7 @@ if ($modecompta != 'CREANCES-DETTES')
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";

View File

@ -232,7 +232,7 @@ if ($modecompta != 'CREANCES-DETTES') {
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($date_start && $date_end) {
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}

View File

@ -279,7 +279,7 @@ if ($modecompta != 'CREANCES-DETTES') {
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY socid, name";
$sql.= " ORDER BY name";

View File

@ -146,7 +146,7 @@ if ($modecompta != 'CREANCES-DETTES')
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";

View File

@ -167,7 +167,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
$sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj";
//if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
$sql.= " WHERE e.entity = ".$conf->entity;
$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")";
$sql.= " AND obj.fk_".$origin." = ".$origin_id;
$sql.= " AND obj.rowid = ed.fk_origin_line";
$sql.= " AND ed.fk_expedition = e.rowid";

View File

@ -436,7 +436,7 @@ class Expedition extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->element."'";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid';
$sql.= " WHERE e.entity = ".$conf->entity;
$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")";
if ($id) $sql.= " AND e.rowid=".$id;
if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'";

View File

@ -75,7 +75,7 @@ if (!$user->rights->societe->client->voir && !$socid)
$clause = " AND ";
}
$sql.= $clause." e.fk_statut = 0";
$sql.= " AND e.entity = ".$conf->entity;
$sql.= " AND e.entity IN (".getEntity('expedition', 1).")";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$resql=$db->query($sql);
@ -235,7 +235,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_ta
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= " WHERE e.entity = ".$conf->entity;
$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id;
$sql.= " AND e.fk_statut = 1";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;

View File

@ -82,7 +82,7 @@ $sql.= ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
$sql.= " WHERE e.entity = ".$conf->entity;
$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")";
if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
{
$sql.= " AND e.fk_soc = sc.fk_soc";

View File

@ -72,7 +72,7 @@ class FormProduct
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid";
$sql.= " AND ps.fk_product = '".$fk_product."'";
}
$sql.= " WHERE e.entity = ".$conf->entity;
$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")";
$sql.= " AND e.statut = 1";
$sql.= " ORDER BY e.label";

View File

@ -1793,7 +1793,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.rowid = pd.fk_propal";
$sql.= " AND p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
$sql.= " AND pd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
//$sql.= " AND pr.fk_statut != 0";
@ -1836,7 +1836,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = cd.fk_commande";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
@ -1878,7 +1878,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = cd.fk_commande";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('commande_fourniseur', 1).")";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
@ -1923,7 +1923,7 @@ class Product extends CommonObject
$sql.= " WHERE e.rowid = ed.fk_expedition";
$sql.= " AND c.rowid = cd.fk_commande";
$sql.= " AND e.fk_soc = s.rowid";
$sql.= " AND e.entity = ".$conf->entity;
$sql.= " AND e.entity IN (".getEntity('expedition', 1).")";
$sql.= " AND ed.fk_origin_line = cd.rowid";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -1966,7 +1966,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.rowid = fd.fk_commande";
$sql.= " AND cf.fk_soc = s.rowid";
$sql.= " AND cf.entity = ".$conf->entity;
$sql.= " AND cf.entity IN (".getEntity('commande_fournisseur', 1).")";
$sql.= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid;
@ -2008,7 +2008,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = cd.fk_contrat";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('contrat', 1).")";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
//$sql.= " AND c.statut != 0";
@ -2050,7 +2050,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.rowid = fd.fk_facture";
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity IN (".getEntity('facture', 1).")";
$sql.= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
//$sql.= " AND f.fk_statut != 0";
@ -2092,7 +2092,7 @@ class Product extends CommonObject
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.rowid = fd.fk_facture_fourn";
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")";
$sql.= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
//$sql.= " AND f.fk_statut != 0";
@ -2190,7 +2190,7 @@ class Product extends CommonObject
$sql.= " WHERE f.rowid = d.fk_facture";
$sql.= " AND d.fk_product =".$this->id;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity IN (".getEntity('facture', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND f.fk_soc = $socid";
$sql.= " GROUP BY date_format(f.datef,'%Y%m')";
@ -2219,7 +2219,7 @@ class Product extends CommonObject
$sql.= " WHERE f.rowid = d.fk_facture_fourn";
$sql.= " AND d.fk_product =".$this->id;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND f.fk_soc = $socid";
$sql.= " GROUP BY date_format(f.datef,'%Y%m')";
@ -2248,7 +2248,7 @@ class Product extends CommonObject
$sql.= " WHERE p.rowid = d.fk_propal";
$sql.= " AND d.fk_product =".$this->id;
$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 p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid;
$sql.= " GROUP BY date_format(p.datep,'%Y%m')";
@ -2275,7 +2275,7 @@ class Product extends CommonObject
$sql.= " WHERE c.rowid = d.fk_commande";
$sql.= " AND d.fk_product =".$this->id;
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " GROUP BY date_format(c.date_commande,'%Y%m')";
@ -2302,7 +2302,7 @@ class Product extends CommonObject
$sql.= " WHERE c.rowid = d.fk_commande";
$sql.= " AND d.fk_product =".$this->id;
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " GROUP BY date_format(c.date_commande,'%Y%m')";

View File

@ -377,7 +377,7 @@ function activitytrim($product_type)
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND pf.fk_paiement= p.rowid";
$sql.= " AND fd.product_type=".$product_type;
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate),1)."'";
$sql.= " GROUP BY annee, mois ";
$sql.= " ORDER BY annee, mois ";

View File

@ -137,7 +137,7 @@ if ($id > 0 || ! empty($ref))
$sql.= ", ".MAIN_DB_PREFIX."commandedet as d";
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 d.fk_commande = c.rowid";
$sql.= " AND d.fk_product =".$product->id;
if (! empty($search_month))

View File

@ -131,7 +131,7 @@ if ($id > 0 || ! empty($ref))
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " WHERE c.rowid = cd.fk_contrat";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('contrat', 1).")";
$sql.= " AND cd.fk_product =".$product->id;
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;

View File

@ -138,7 +138,7 @@ if ($id > 0 || ! empty($ref))
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity IN (".getEntity('facture', 1).")";
$sql.= " AND d.fk_facture = f.rowid";
$sql.= " AND d.fk_product =".$product->id;
if (! empty($search_month))

View File

@ -139,7 +139,7 @@ if ($id > 0 || ! empty($ref))
$sql .= ", " . MAIN_DB_PREFIX . "facture_fourn_det as d";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = " . $conf->entity;
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 1).")";
$sql .= " AND d.fk_facture_fourn = f.rowid";
$sql .= " AND d.fk_product =" . $product->id;
if (! empty($search_month))

View File

@ -138,7 +138,7 @@ if ($id > 0 || ! empty($ref))
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 d.fk_propal = p.rowid";
$sql .= " AND d.fk_product =" . $product->id;
if (! empty($search_month))

View File

@ -295,7 +295,7 @@ if ($usevirtualstock)
$sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty";
$sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)";
$sqlCommandesCli.= " WHERE c.entity = ".$conf->entity;
$sqlCommandesCli.= " WHERE c.entity IN (".getEntity('order', 1).")";
$sqlCommandesCli.= " AND cd.fk_product = p.rowid";
$sqlCommandesCli.= " AND c.fk_statut IN (1,2))";
@ -304,7 +304,7 @@ if ($usevirtualstock)
$sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)";
$sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)";
$sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)";
$sqlExpeditionsCli.= " WHERE e.entity = ".$conf->entity;
$sqlExpeditionsCli.= " WHERE e.entity IN (".getEntity('expedition', 1).")";
$sqlExpeditionsCli.= " AND cd.fk_product = p.rowid";
$sqlExpeditionsCli.= " AND c.fk_statut IN (1,2))";
@ -312,14 +312,14 @@ if ($usevirtualstock)
$sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd";
$sqlCommandesFourn.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande";
$sqlCommandesFourn.= " AND c.entity = ".$conf->entity;
$sqlCommandesFourn.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")";
$sqlCommandesFourn.= " AND cd.fk_product = p.rowid";
$sqlCommandesFourn.= " AND c.fk_statut IN (3,4))";
$sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty";
$sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)";
$sqlReceptionFourn.= " WHERE cf.entity = ".$conf->entity;
$sqlReceptionFourn.= " WHERE cf.entity IN (".getEntity('commande_fournisseur', 1).")";
$sqlReceptionFourn.= " AND fd.fk_product = p.rowid";
$sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))";