diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 5a47ce17089..8d10d55b3bd 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -107,7 +107,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - + if ($ret < 0) $error++; if (! $error) { @@ -456,7 +456,7 @@ if ($object->id > 0) /* - * Last supplier proposal + * Latest supplier proposal */ $proposalstatic = new SupplierProposal($db); @@ -465,7 +465,7 @@ if ($object->id > 0) $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p "; $sql.= " WHERE p.fk_soc =".$object->id; - $sql.= " AND p.entity =".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql.= " ORDER BY p.date_valid DESC"; $sql.= " ".$db->plimit($MAXLIST); @@ -528,7 +528,7 @@ if ($object->id > 0) } /* - * Last supplier orders + * Latest supplier orders */ $orderstatic = new CommandeFournisseur($db); @@ -541,6 +541,7 @@ if ($object->id > 0) $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql2.= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c'; $sql2.= ' WHERE c.fk_soc = s.rowid'; + $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= ' AND s.rowid = '.$object->id; // Show orders with status validated, shipping started and delivered (well any order we can bill) $sql2.= " AND c.fk_statut IN (5)"; @@ -558,9 +559,9 @@ if ($object->id > 0) // TODO move to DAO class $sql = "SELECT count(p.rowid) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p"; $sql.= " WHERE p.fk_soc =".$object->id; - $sql.= " AND p.entity =".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('commande_fournisseur').")"; $resql=$db->query($sql); if ($resql) { @@ -569,9 +570,9 @@ if ($object->id > 0) } $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p"; $sql.= " WHERE p.fk_soc =".$object->id; - $sql.= " AND p.entity =".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('commande_fournisseur').")"; $sql.= " ORDER BY p.date_commande DESC"; $sql.= " ".$db->plimit($MAXLIST); $resql=$db->query($sql); @@ -632,7 +633,7 @@ if ($object->id > 0) } /* - * Last supplier invoices + * Latest supplier invoices */ $langs->load('bills'); @@ -646,7 +647,7 @@ if ($object->id > 0) $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn'; $sql.= ' WHERE f.fk_soc = '.$object->id; - $sql.= " AND f.entity =".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; $sql.= ' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye'; $sql.= ' ORDER BY f.datef DESC'; $resql=$db->query($sql); @@ -674,15 +675,15 @@ if ($object->id > 0) print '