diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php index f3539e672cd..34ee081b5b3 100644 --- a/htdocs/asterisk/cidlookup.php +++ b/htdocs/asterisk/cidlookup.php @@ -42,7 +42,7 @@ if (empty($phone)) $sql = "SELECT nom as name FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid"; -$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; +$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; $sql.= " AND (s.tel='".$db->escape($phone)."'"; $sql.= " OR sp.phone='".$db->escape($phone)."'"; $sql.= " OR sp.phone_perso='".$db->escape($phone)."'"; diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 9ec4af4df21..310ee0af9da 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -33,7 +33,8 @@ if ( $_GET['filtre'] ) { if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; - $sql.= " WHERE p.tosell = 1"; + $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " AND (p.ref LIKE '%".$_GET['filtre']."%' OR p.label LIKE '%".$_GET['filtre']."%' "; if ($conf->barcode->enabled) $sql.= " OR p.barcode LIKE '%".$_GET['filtre']."%')"; @@ -69,7 +70,8 @@ if ( $_GET['filtre'] ) { if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; - $sql.= " WHERE p.tosell = 1"; + $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " ORDER BY p.label"; diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index 775d9948e77..335925cf764 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -47,7 +47,8 @@ if (dol_strlen($_GET["code"]) >= 0) // If search criteria is on char length at l if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; - $sql.= " WHERE p.tosell = 1"; + $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " AND p.tosell = 1"; $sql.= " AND p.fk_product_type = 0"; // Add criteria on ref/label if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 2944d86b622..556f895e1df 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -19,11 +19,8 @@ require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); require_once(DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'); - -/** add Ditto */ require_once(DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); -/** end add Ditto */ $obj_facturation = unserialize($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']); @@ -38,15 +35,16 @@ switch ( $_GET['action'] ) if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; - + $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + // Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ... if ( $_POST['hdnSource'] == 'LISTE' ) { - $sql.= " WHERE p.rowid = ".$_POST['selProduit']; + $sql.= " AND p.rowid = ".$_POST['selProduit']; } else if ( $_POST['hdnSource'] == 'REF' ) { - $sql.= " WHERE p.ref = '".$_POST['txtRef']."'"; + $sql.= " AND p.ref = '".$_POST['txtRef']."'"; } $result = $db->query($sql); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9320ad50c2c..d163e84828f 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -452,7 +452,7 @@ if ($showbirthday) $sql = 'SELECT sp.rowid, sp.name, sp.firstname, sp.birthday'; $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= ' AND sp.entity = '.$conf->entity; + $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; if ($action == 'show_day') { $sql.= ' AND MONTH(birthday) = '.$month; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 76a15422aa1..1c352367159 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -153,7 +153,7 @@ $sql.= " ut.login as logintodo, ut.rowid as useridtodo,"; $sql.= " ud.login as logindone, ud.rowid as useriddone,"; $sql.= " sp.name, sp.firstname"; $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c,"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; +if (! $user->rights->societe->client->voir && ! $socid) $sql.= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; $sql.= " ".MAIN_DB_PREFIX.'user as u,'; $sql.= " ".MAIN_DB_PREFIX."actioncomm as a)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; @@ -166,7 +166,7 @@ $sql.= ' AND a.fk_user_author = u.rowid'; $sql.= ' AND a.entity = '.$conf->entity; // To limit to entity if ($actioncode) $sql.=" AND c.code='".$db->escape($actioncode)."'"; if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->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; if ($_GET["type"]) $sql.= " AND c.id = ".$_GET["type"]; if ($status == 'done') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1de7725e6b6..123c3207818 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2203,7 +2203,7 @@ class Propal extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity = ".$conf->entity; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6c0aa45fe3c..547314759ac 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1595,13 +1595,13 @@ class Commande extends CommonObject // Tableau des id de produit de la commande $array_of_product=array(); - // Recherche total en stock pour chaque produit + // TODO $array_of_product est défini vide juste au dessus !! if (count($array_of_product)) { $sql = "SELECT fk_product, sum(ps.reel) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= " WHERE ps.fk_product in (".join(',',$array_of_product).")"; + $sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")"; $sql.= ' GROUP BY fk_product '; $result = $this->db->query($sql); if ($result) @@ -2635,7 +2635,7 @@ class Commande extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity = ".$conf->entity; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ad1bc5ff7a8..2abfaeb9cd8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3084,7 +3084,7 @@ class Facture extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity = ".$conf->entity; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index a8b6747b2a6..ba29a357df5 100755 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -85,14 +85,14 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS); $idpays = $p[0]; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.libelle,"; -$sql .= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; -$sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code"; -$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd "; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product "; -$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn "; -$sql .= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ; -$sql .= " WHERE f.fk_statut > 0 AND f.entity IN (0,".$conf->entity.")"; +$sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; +$sql.= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code"; +$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product"; +$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn"; +$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ; +$sql.= " WHERE f.fk_statut > 0 AND f.entity = ".$conf->entity; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $result = $db->query($sql); @@ -205,6 +205,6 @@ print ""; // End of page -$db->close(); llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index ab8c41aff5a..1a0e273776a 100755 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -87,13 +87,13 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS); $idpays = $p[0]; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client , fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; -$sql .= " p.accountancy_code_sell, s.code_compta , ct.accountancy_code"; -$sql .= " FROM ".MAIN_DB_PREFIX."facturedet fd "; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product "; -$sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture "; -$sql .= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'"; -$sql .= " WHERE f.fk_statut > 0 AND f.entity IN (0,".$conf->entity.")"; +$sql.= " p.accountancy_code_sell, s.code_compta , ct.accountancy_code"; +$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product"; +$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture"; +$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'"; +$sql.= " WHERE f.fk_statut > 0 AND f.entity = ".$conf->entity; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " order by f.rowid"; diff --git a/htdocs/compta/ventilation/lignes.php b/htdocs/compta/ventilation/lignes.php index fb868e4ead4..c9949e9c352 100644 --- a/htdocs/compta/ventilation/lignes.php +++ b/htdocs/compta/ventilation/lignes.php @@ -55,10 +55,11 @@ $sql.= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c"; $sql.= " , ".MAIN_DB_PREFIX."facturedet as l"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql.= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND l.fk_code_ventilation <> 0 "; +$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND c.rowid = l.fk_code_ventilation"; if (dol_strlen(trim($_GET["search_facture"]))) { - $sql .= " AND f.facnumber like '%".$_GET["search_facture"]."%'"; + $sql .= " AND f.facnumber LIKE '%".$_GET["search_facture"]."%'"; } $sql .= " ORDER BY l.rowid DESC"; diff --git a/htdocs/compta/ventilation/liste.php b/htdocs/compta/ventilation/liste.php index d00dea0197b..e7bc07844c7 100644 --- a/htdocs/compta/ventilation/liste.php +++ b/htdocs/compta/ventilation/liste.php @@ -60,6 +60,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."facturedet as l"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql.= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND fk_code_ventilation = 0"; +$sql.= " AND f.entity = ".$conf->entity; $sql.= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset); $result = $db->query($sql); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 76c8dda3775..a1c9418ef8a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -397,11 +397,11 @@ class Contact extends CommonObject $result=false; // Mis a jour contact - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET rowid=".$id; - $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; + $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); if ($user) $sql .= ", fk_user_modif=".$user->id; - $sql .= " WHERE rowid=".$id; - //print "update_perso: ".$this->birthday.'-'.$this->db->idate($this->birthday); + $sql.= " WHERE rowid=".$id; + dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." - sql=".$sql); $resql = $this->db->query($sql); if (! $resql) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c7d79e564a6..96060d6f3fb 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1450,8 +1450,8 @@ class Contrat extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE tosell = 1"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " AND tosell = 1"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 9ca6a240e50..e4f888b5c4a 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -372,9 +372,9 @@ $sql.= ", ".MAIN_DB_PREFIX."contrat 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.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE cd.fk_contrat = c.rowid"; +$sql.= " WHERE c.entity = ".$conf->entity; +$sql.= " AND cd.fk_contrat = c.rowid"; $sql.= " AND c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; 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 cd.tms DESC"; @@ -450,11 +450,11 @@ $sql.= ", ".MAIN_DB_PREFIX."contrat 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.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE c.statut=1"; +$sql.= " WHERE c.entity = ".$conf->entity; +$sql.= " AND c.statut = 1"; $sql.= " AND cd.statut = 0"; $sql.= " AND cd.fk_contrat = c.rowid"; $sql.= " AND c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; 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 cd.tms DESC"; @@ -529,12 +529,12 @@ $sql.= ", ".MAIN_DB_PREFIX."contrat 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.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE c.statut=1"; +$sql.= " WHERE c.entity = ".$conf->entity; +$sql.= " AND c.statut = 1"; $sql.= " AND cd.statut = 4"; $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; $sql.= " AND cd.fk_contrat = c.rowid"; $sql.= " AND c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; 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 cd.tms DESC"; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 0d53b117d2d..fdcf83dba1f 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -84,10 +84,9 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; $sql.= " ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE"; -$sql.= " c.rowid = cd.fk_contrat"; +$sql.= " WHERE c.entity = ".$conf->entity; +$sql.= " AND c.rowid = cd.fk_contrat"; $sql.= " AND c.fk_soc = s.rowid"; -$sql.= " AND c.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($mode == "0") $sql.= " AND cd.statut = 0"; if ($mode == "4") $sql.= " AND cd.statut = 4"; diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 277d62191c3..ac2f244969a 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -47,7 +47,7 @@ print '