diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 32c7b638a46..9d3da39e5c3 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -73,10 +73,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', llxHeader('',$langs->trans("WithdrawalsReceipts")); -$sql = "SELECT p.rowid, p.ref, p.amount, p.statut"; -$sql.= ", p.datec"; +$sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " WHERE p.entity IN (".getEntity('facture').")"; if ($search_ref) $sql.=natural_search("p.ref", $search_ref); if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index aaec7696bec..d0aa788fe48 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -284,7 +284,7 @@ class BonPrelevement extends CommonObject $sql.= ", p.fk_user_credit"; $sql.= ", p.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('facture').")"; if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid; else $sql.= " AND p.ref = '".$this->db->escape($ref)."'"; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 5177e8681b7..cd3aebf62f4 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -279,7 +279,7 @@ print load_fiche_titre($langs->trans("LastWithdrawalReceipts",$limit),'',''); $sql = "SELECT p.rowid, p.ref, p.amount, p.statut"; $sql.= ", p.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " WHERE p.entity IN (".getEntity('facture').")"; $sql.= " ORDER BY datec DESC"; $sql.=$db->plimit($limit); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 89f70dfb4f0..fe7d927b6df 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -740,7 +740,7 @@ else $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; @@ -813,7 +813,7 @@ else $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; - $sql.= " WHERE p.entity = ".getEntity('expensereport'); + $sql.= " WHERE p.entity IN (".getEntity('expensereport').")"; $sql.= " AND p.fk_statut>=5"; $column='p.date_valid'; @@ -823,7 +823,7 @@ else $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")"; - $sql.= " WHERE p.entity = ".getEntity('expensereport'); + $sql.= " WHERE p.entity IN (".getEntity('expensereport').")"; $sql.= " AND p.fk_statut>=5"; $column='pe.datep'; @@ -898,7 +898,7 @@ else { $sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('donation').")"; $sql.= " AND fk_statut in (1,2)"; } else diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 86e0b950a47..156576fa4bc 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -638,7 +638,7 @@ if (! empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $m $subtotal_ttc = 0; $sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM " . MAIN_DB_PREFIX . "payment_salary as p"; - $sql .= " WHERE p.entity = " . $conf->entity; + $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'"; $sql .= " GROUP BY p.label, dm"; @@ -686,7 +686,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' $sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; - $sql.= " WHERE p.entity = ".getEntity('expensereport'); + $sql.= " WHERE p.entity IN (".getEntity('expensereport').")"; $sql.= " AND p.fk_statut>=5"; $column='p.date_valid'; @@ -699,7 +699,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")"; - $sql.= " WHERE p.entity = ".getEntity('expensereport'); + $sql.= " WHERE p.entity IN (".getEntity('expensereport').")"; $sql.= " AND p.fk_statut>=5"; $column='pe.datep'; @@ -752,7 +752,7 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('donation').")"; $sql.= " AND fk_statut in (1,2)"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index cbb866d6f20..4fb8cc19c82 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -111,7 +111,7 @@ class box_activity extends ModeleBoxes $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('propal').")"; $sql.= " AND p.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index f4a6d98c671..f1d407d3bba 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -330,7 +330,7 @@ class FormProjets $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t'; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND t.fk_projet = p.rowid"; if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 92e44f63f02..7106657d417 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1421,7 +1421,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks= { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; } - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($mytasks) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 6c4ecf8098e..edf5a1ab050 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -264,7 +264,7 @@ class modProjet extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity = '.$conf->entity; + $this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")"; // Import list of tasks diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 9d0f2c1ed13..a2bf0b106ed 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -132,7 +132,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } -$sql.= " WHERE p.entity = ".getEntity('survey'); +$sql.= " WHERE p.entity IN (".getEntity('survey').")"; if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; if ($search_expired == 'opened') $sql.=" AND p.date_fin >= '".$db->idate($now)."'"; diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 8418561aa30..fb23eed80b0 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -451,7 +451,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S { $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect"; } - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on if ($mine) // this may duplicate record if we are contact twice { diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 8c919b5d213..e29bd4555a8 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -3,7 +3,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."c_lead_status as cls"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND p.fk_opp_status = cls.rowid"; $sql.= " AND p.fk_statut = 1"; // Opend projects only if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ae2c73d8752..e43404777b6 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1833,7 +1833,7 @@ class SupplierProposal 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."supplier_proposal 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('supplier_proposal').")"; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; if (! $user->rights->societe->client->voir && ! $socid) //restriction