diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 18e144c363c..65f9de24496 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1097,7 +1097,7 @@ class Adherent extends CommonObject $sql.= " WHERE d.fk_adherent_type = t.rowid"; if ($rowid) $sql.= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { - $sql.= " AND d.entity IN (".getEntity().")"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'"; elseif ($fk_soc > 0) $sql.= " AND d.fk_soc=".$fk_soc; } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 76368fc5673..2614a27d509 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -64,8 +64,8 @@ $sql.= " d.statut, count(d.rowid) as somme"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " ON t.rowid = d.fk_adherent_type"; -$sql.= " AND d.entity IN (".getEntity().")"; -$sql.= " WHERE t.entity IN (".getEntity().")"; +$sql.= " AND d.entity IN (".getEntity('adherent').")"; +$sql.= " WHERE t.entity IN (".getEntity('adherent').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members by type", LOG_DEBUG); @@ -100,7 +100,7 @@ $now=dol_now(); // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) $sql = "SELECT count(*) as somme , d.fk_adherent_type"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql.= " WHERE d.entity IN (".getEntity().")"; +$sql.= " WHERE d.entity IN (".getEntity('adherent').")"; //$sql.= " AND d.statut = 1 AND ((t.subscription = 0 AND d.datefin IS NULL) OR d.datefin >= '".$db->idate($now)."')"; $sql.= " AND d.statut = 1 AND d.datefin >= '".$db->idate($now)."'"; $sql.= " AND t.rowid = d.fk_adherent_type"; @@ -133,7 +133,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_member']=array('text'=>'Member'); } - + if (count($listofsearchfields)) { print '
'; @@ -149,7 +149,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; $i++; } - print ''; + print ''; print '
'; print '
'; } @@ -211,7 +211,7 @@ $numb=0; $sql = "SELECT c.subscription, c.dateadh as dateh"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; -$sql.= " WHERE d.entity IN (".getEntity().")"; +$sql.= " WHERE d.entity IN (".getEntity('adherent').")"; $sql.= " AND d.rowid = c.fk_adherent"; if(isset($date_select) && $date_select != '') { @@ -275,7 +275,7 @@ $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, $sql.= " a.tms as datem, datefin as date_end_subscription,"; $sql.= " ta.rowid as typeid, ta.libelle, ta.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; -$sql.= " WHERE a.entity IN (".getEntity().")"; +$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; $sql.= " AND a.fk_adherent_type = ta.rowid"; $sql.= $db->order("a.tms","DESC"); $sql.= $db->plimit($max, 0); @@ -336,7 +336,7 @@ $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, $sql.= " datefin as date_end_subscription,"; $sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; -$sql.= " WHERE a.entity IN (".getEntity().")"; +$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; $sql.= " AND c.fk_adherent = a.rowid"; $sql.= $db->order("c.tms","DESC"); $sql.= $db->plimit($max, 0); diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 6f896e186bb..f067b27b3d4 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -67,7 +67,7 @@ $tab='byproperties'; $data = array(); $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; -$sql.=" WHERE d.entity IN (".getEntity().")"; +$sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY d.morphy"; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 8e3d0862490..1f9ff189068 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -79,7 +79,7 @@ if ($mode) $data = array(); $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code"; //print $sql; @@ -96,7 +96,7 @@ if ($mode) $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, c.nom"; //print $sql; @@ -112,7 +112,7 @@ if ($mode) $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, r.nom"; //+ //print $sql; @@ -127,7 +127,7 @@ if ($mode) $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code, d.town"; //print $sql; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f0be2ee9fae..50c464596fd 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -173,7 +173,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity().")"; + $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; $result = $db->query($sql); if ($result) @@ -380,7 +380,7 @@ if ($rowid > 0) $sql.= " t.libelle as type, t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_adherent_type = t.rowid "; - $sql.= " AND d.entity IN (".getEntity().")"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; $sql.= " AND t.rowid = ".$object->id; if ($sall) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3157348062a..8a9bd1e88b6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -113,7 +113,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * @param int $shared 1=Return id of current entity + shared entities (default), 0=Return id of current entity only * @return mixed Entity id(s) to use */ -function getEntity($element=false, $shared=1) +function getEntity($element, $shared=1) { global $conf, $mc;