From a8ab666d6273b8133cfa0ae119134d69c2aab412 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 7 Nov 2018 16:45:04 +0100 Subject: [PATCH] remplacement en masse des $conf->entity par des getEntity('facture') --- htdocs/accountancy/class/lettering.class.php | 4 ++-- htdocs/comm/card.php | 2 +- htdocs/compta/bank/treso.php | 18 ++++++++++++++---- htdocs/compta/facture/card.php | 11 +++++++---- htdocs/compta/facture/class/facture.class.php | 16 ++++++++-------- .../facture/class/facturestats.class.php | 2 +- htdocs/compta/index.php | 8 ++++---- htdocs/compta/journal/purchasesjournal.php | 2 +- htdocs/compta/journal/sellsjournal.php | 2 +- htdocs/compta/paiement/card.php | 15 ++++++++++++--- .../prelevement/class/bonprelevement.class.php | 4 ++-- .../class/rejetprelevement.class.php | 2 +- htdocs/compta/prelevement/create.php | 2 +- htdocs/compta/prelevement/demandes.php | 2 +- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/prelevement/index.php | 2 +- htdocs/compta/prelevement/ligne.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/compta/recap-compta.php | 2 +- htdocs/compta/resultat/clientfourn.php | 4 ++-- htdocs/compta/resultat/index.php | 4 ++-- htdocs/compta/stats/cabyprodserv.php | 2 +- htdocs/compta/stats/cabyuser.php | 2 +- htdocs/compta/stats/casoc.php | 2 +- htdocs/compta/stats/index.php | 4 ++-- htdocs/core/boxes/box_factures.php | 2 +- htdocs/core/boxes/box_factures_imp.php | 2 +- htdocs/core/lib/tax.lib.php | 17 +++++++++-------- .../modules/facture/mod_facture_mercure.php | 5 +---- .../modules/rapport/pdf_paiement.class.php | 2 +- htdocs/margin/tabs/thirdpartyMargins.php | 2 +- htdocs/product/card.php | 2 +- htdocs/product/index.php | 2 +- htdocs/societe/consumption.php | 2 +- htdocs/stripe/payment.php | 4 ++-- htdocs/webservices/server_invoice.php | 2 +- .../accountancy/export-thirdpartyaccount.php | 2 +- 37 files changed, 91 insertions(+), 71 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 3122526061b..e0dc0f093bd 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -157,7 +157,7 @@ class Lettering extends BookKeeping $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='" . $obj->code_journal . "')"; $sql .= " WHERE payfac.fk_paiement = '" . $obj->url_id . "' "; $sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; - $sql .= " AND fac.entity = ".$conf->entity; + $sql .= " AND fac.entity IN (".getEntity('facture').")"; $sql .= " AND ( "; if (! empty($object->code_compta)) { $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; @@ -185,7 +185,7 @@ class Lettering extends BookKeeping $sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (" . implode(',', $ids_fact) . "))"; $sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; - $sql .= " AND fac.entity = ".$conf->entity; + $sql .= " AND fac.entity IN (".getEntity('facture').")"; $sql .= " AND ( "; if (! empty($object->code_compta)) { $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 8fa1e9a8f97..37eea35725b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1146,7 +1146,7 @@ if ($object->id > 0) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.tva, f.total_ttc,'; $sql.= ' f.datef, f.datec, f.paye, f.fk_statut,'; $sql.= ' s.nom, s.rowid'; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index ef471aea693..5756cbf6c61 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -103,6 +103,8 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print '
'; $solde = $object->solde(0); + if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)$colspan = 6; + else $colspan = 5; // Show next coming entries print '
'; @@ -112,6 +114,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print ''.$langs->trans("DateDue").''; print ''.$langs->trans("Description").''; + if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED )print ''.$langs->trans("Entity").''; print ''.$langs->trans("ThirdParty").''; print ''.$langs->trans("Debit").''; print ''.$langs->trans("Credit").''; @@ -127,7 +130,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; - print ''.$langs->trans("RemainderToPay").''; + print ''.$langs->trans("RemainderToPay").''; print ' '; print ''; @@ -136,11 +139,11 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sqls = array(); // Customer invoices - $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; + $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr, f.entity,"; $sql.= " s.rowid as socid, s.nom as name, s.fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').")"; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice $sql.= " ORDER BY dlr ASC"; @@ -284,6 +287,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) else print $langs->trans("NotDefined"); print ""; print "".$ref.""; + if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){ + if($obj->family == 'invoice'){ + $mc->getInfo($obj->entity); + print "".$mc->label.""; + }else print ""; + + } print "".$refcomp.""; if ($obj->total_ttc < 0) { print "".price(abs($total_ttc))." "; }; if ($obj->total_ttc >= 0) { print " ".price($total_ttc).""; }; @@ -309,7 +319,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // solde print ''; - print ''.$langs->trans("FutureBalance").' ('.$object->currency_code.')'; + print ''.$langs->trans("FutureBalance").' ('.$object->currency_code.')'; print ''.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cafd59569bb..3d3625ba777 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -830,9 +830,9 @@ if (empty($reshook)) if ($socid > 0) $object->socid = GETPOST('socid', 'int'); $db->begin(); - + $error = 0; - + $originentity = GETPOST('originentity'); // Fill array 'array_options' with data from add form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -911,6 +911,9 @@ if (empty($reshook)) if (! $error) { + if(!empty($originentity)){ + $object->entity = $originentity; + } $object->socid = GETPOST('socid','int'); $object->number = $_POST['facnumber']; $object->date = $dateinvoice; @@ -2601,7 +2604,6 @@ if ($action == 'create') // Load objectsrc $remise_absolue = 0; - if (! empty($origin) && ! empty($originid)) { // Parse element/subelement (ex: project_task) @@ -2723,6 +2725,7 @@ if ($action == 'create') print ''; print ''; print ''; + print ''; if (!empty($currency_tx)) print ''; dol_fiche_head(''); @@ -4803,7 +4806,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext) { - print ''; + print ''; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7c8a02ba693..4dc0adea029 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3348,7 +3348,7 @@ class Facture extends CommonInvoice $mybool=false; - $file = $conf->global->FACTURE_ADDON.".php"; + $constant = 'FACTURE_ADDON_'.$this->entity; @@ -3357,7 +3357,7 @@ class Facture extends CommonInvoice } else { $classname = $conf->global->FACTURE_ADDON; } - + $file = $classname.".php"; // Include file with class @@ -3391,7 +3391,7 @@ class Facture extends CommonInvoice } } } - + if (! $mybool) { dol_print_error('',"Failed to include file ".$file); @@ -3493,7 +3493,7 @@ class Facture extends CommonInvoice 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."facture as f"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').")"; $sql.= " AND f.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $socid) //restriction { @@ -3565,7 +3565,7 @@ class Facture extends CommonInvoice $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND f.paye = 0"; // Pas classee payee completement $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement @@ -3614,7 +3614,7 @@ class Facture extends CommonInvoice $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').")"; $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; // $sql.= " WHERE f.fk_statut >= 1"; // $sql.= " AND (f.paye = 1"; // Classee payee completement @@ -3830,7 +3830,7 @@ class Facture extends CommonInvoice $clause = " AND"; } $sql.= $clause." f.paye=0"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; @@ -4078,7 +4078,7 @@ class Facture extends CommonInvoice $sql.= " WHERE sc.fk_user = " .$user->id; $clause = "AND"; } - $sql.= " ".$clause." f.entity = ".$conf->entity; + $sql.= " ".$clause." f.entity IN (".getEntity('facture').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 7a9a9621a78..4aa50167842 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -80,7 +80,7 @@ class FactureStats extends Stats } $this->where = " f.fk_statut > 0"; - $this->where.= " AND f.entity = ".$conf->entity; + $this->where.= " AND f.entity IN (".getEntity('facture').")"; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if ($this->socid) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index ac6479afc0b..df2688298fd 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -146,7 +146,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) @@ -236,7 +236,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; // Add where from hooks @@ -331,7 +331,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.rowid = f.fk_soc"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; // Add where from hooks @@ -823,7 +823,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; // Add where from hooks diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 8974c1b78e0..5a73f3a4b41 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -110,7 +110,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva as ct ON fd.tva_tx = ct.taux AND fd.i $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; $sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc" ; -$sql.= " WHERE f.fk_statut > 0 AND f.entity = ".$conf->entity; +$sql.= " WHERE f.fk_statut > 0 AND f.entity IN (".getEntity('facture').")"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index f88f5643c40..bb0145ff227 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -110,7 +110,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; $sql.= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'"; -$sql.= " WHERE f.entity = ".$conf->entity; +$sql.= " WHERE f.entity IN (".getEntity('facture').")"; $sql.= " AND f.fk_statut > 0"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 1898a270222..63631ca660a 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -320,11 +320,11 @@ dol_fiche_end(); * List of invoices */ -$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid'; +$sql = 'SELECT f.rowid as facid, f.facnumber,f.entity, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s'; $sql.= ' WHERE pf.fk_facture = f.rowid'; $sql.= ' AND f.fk_soc = s.rowid'; -$sql.= ' AND f.entity = '.$conf->entity; +$sql.= ' AND f.entity IN ('.getEntity('facture').')'; $sql.= ' AND pf.fk_paiement = '.$object->id; $resql=$db->query($sql); if ($resql) @@ -344,10 +344,12 @@ if ($resql) print ''; print ''.$langs->trans('Bill').''; print ''.$langs->trans('Company').''; + if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED )print ''.$langs->trans('Entity').''; print ''.$langs->trans('ExpectedToPay').''; print ''.$langs->trans('PayedByThisPayment').''; print ''.$langs->trans('RemainderToPay').''; print ''.$langs->trans('Status').''; + print "\n"; if ($num > 0) @@ -378,7 +380,14 @@ if ($resql) print ''; print $thirdpartystatic->getNomUrl(1); print ''; - + + // Entity + if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){ + print ''; + $mc->getInfo($objp->entity); + print $mc->label; + print ''; + } // Expected to pay print ''.price($objp->total_ttc).''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4089ffd76e2..3ea75d771db 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -699,7 +699,7 @@ class BonPrelevement extends CommonObject $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; //$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp"; $sql.= " WHERE f.fk_statut = 1"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND f.rowid = pfd.fk_facture"; $sql.= " AND f.paye = 0"; $sql.= " AND pfd.traite = 0"; @@ -740,7 +740,7 @@ class BonPrelevement extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE f.fk_statut = 1"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND f.rowid = pfd.fk_facture"; $sql.= " AND f.paye = 0"; $sql.= " AND pfd.traite = 0"; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 6c99cc5562c..e7d7259333c 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -294,7 +294,7 @@ class RejetPrelevement $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)"; $sql.= " WHERE pf.fk_prelevement_lignes = ".$this->id; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 02ccee567f5..91df1750627 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -194,7 +194,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."facture as f,"; $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE s.rowid = f.fk_soc"; -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND pfd.traite = 0"; $sql.= " AND pfd.fk_facture = f.rowid"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 3129d4af3c8..1a6c8bf0d84 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -75,7 +75,7 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.rowid = f.fk_soc"; -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$statut) $sql.= " AND pfd.traite = 0"; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 1f0309f13f3..99884eb640a 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -155,7 +155,7 @@ $sql.= " WHERE pf.fk_prelevement_lignes = pl.rowid"; $sql.= " AND pl.fk_prelevement_bons = p.rowid"; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND pf.fk_facture = f.rowid"; -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; if ($prev_id) $sql.= " AND p.rowid=".$prev_id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index a73e9d4f835..5174a85879e 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -99,7 +99,7 @@ $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."prelevement_facture_demande as pfd"; $sql.= " WHERE s.rowid = f.fk_soc"; -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.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 f.fk_soc = ".$socid; diff --git a/htdocs/compta/prelevement/ligne.php b/htdocs/compta/prelevement/ligne.php index 38e5f91ec2b..0ea6fd36b1e 100644 --- a/htdocs/compta/prelevement/ligne.php +++ b/htdocs/compta/prelevement/ligne.php @@ -272,7 +272,7 @@ if ($id) $sql.= " AND pl.fk_prelevement_bons = p.rowid"; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND pf.fk_facture = f.rowid"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND pl.rowid=".$id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY $sortfield $sortorder "; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 1313658a5f7..4a22faa1b55 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -94,7 +94,7 @@ $sql.= " WHERE pl.fk_prelevement_bons = p.rowid"; $sql.= " AND pf.fk_prelevement_lignes = pl.rowid"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.fk_soc = s.rowid"; -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'"; if ($search_bon) $sql.= natural_search("p.ref", $search_bon); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 3a22666e2f7..061b2d5347a 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -122,7 +122,7 @@ if ($id > 0) $sql.= " u.login, u.rowid as userid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND f.fk_user_valid = u.rowid"; $sql.= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index e08ebb17ed1..43e3b85f2a5 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -371,7 +371,7 @@ else if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= " GROUP BY name, socid"; $sql.= $db->order($sortfield, $sortorder); @@ -991,7 +991,7 @@ else $sql.= " AND f.type IN (0,1,2,3,5)"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " GROUP BY dm"; $newsortfield = $sortfield; if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm'; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 33c3883f8ef..b04e9169518 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -207,7 +207,7 @@ if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mo $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND f.fk_soc = $socid"; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -370,7 +370,7 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $sql.= " WHERE f.fk_statut IN (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY dm"; diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index e7a3d4da480..abcf46611d1 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -259,7 +259,7 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ")"; $sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; } - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type"; $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index c00c0e52849..5824f64a8a2 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -232,7 +232,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } } -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql .= " GROUP BY u.rowid, u.lastname, u.firstname"; $sql .= " ORDER BY u.rowid"; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index f49f15afa1f..a7d25cd5c13 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -291,7 +291,7 @@ if (!empty($search_societe)) $sql.= natural_search('s.nom', $search_societe); if (!empty($search_zip)) $sql.= natural_search('s.zip', $search_zip); if (!empty($search_town)) $sql.= natural_search('s.town', $search_town); if ($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.''; -$sql.= " AND f.entity = ".$conf->entity; +$sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; $sql.= " ORDER BY s.rowid"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 711c8ec2bb7..8ccd4e5349b 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -171,7 +171,7 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " WHERE f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; } else if ($modecompta=="RECETTES-DEPENSES") @@ -186,7 +186,7 @@ else if ($modecompta=="RECETTES-DEPENSES") $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; $sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " AND pf.fk_facture = f.rowid"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; } else if ($modecompta=="BOOKKEEPING") diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index c76ea8d825b..17a2da3a72f 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -100,7 +100,7 @@ class box_factures extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; 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; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC "; diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 10edddf4667..11476e8fa93 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -102,7 +102,7 @@ class box_factures_imp extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND f.paye = 0"; $sql.= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index a61026fa67d..105a8e7e215 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -110,6 +110,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $paymenttable='paiement'; $paymentfacturetable='paiement_facture'; $invoicefieldref='facnumber'; + } if ($direction == 'buy') { @@ -152,7 +153,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -191,7 +192,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -300,7 +301,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -339,7 +340,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -621,7 +622,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -660,7 +661,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -769,7 +770,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; @@ -808,7 +809,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 032112af70d..d1ad13affa7 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -195,10 +195,7 @@ class mod_facture_mercure extends ModeleNumRefFactures //if ($facture->type == 2) $where.= " AND type = 2"; //else $where.=" AND type != 2"; - // Get entities - $entity = getEntity('invoicenumber', 1, $invoice); - - $numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$invoice->date,$mode,false,null,$entity); + $numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$invoice->date,$mode,false,null,$entity); if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal; return $numFinal; diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 9bd93777df1..191e68c777b 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -201,7 +201,7 @@ class pdf_paiement $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid"; if (! empty($conf->banque->enabled)) $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; if (! $user->rights->societe->client->voir && ! $socid) { diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 55362ac4218..e30135ef16e 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -154,7 +154,7 @@ if ($socid > 0) $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut > 0"; - $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND f.fk_soc = $socid"; $sql.= " AND d.buy_price_ht IS NOT NULL"; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f94c34d1804..f4e4bb90937 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2053,7 +2053,7 @@ if ($action != 'create' && $action != 'edit') * All the "Add to" areas */ -if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) +if ( $object->id && ($action == '' || $action == 'view') && $object->status) { //Variable used to check if any text is going to be printed $html = ''; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 8fb1fe7dd12..9a2a1d992ca 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -418,7 +418,7 @@ function activitytrim($product_type) $sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; $sql.= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf"; - $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').")"; $sql.= " AND f.rowid = fd.fk_facture"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND pf.fk_paiement= p.rowid"; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 3a3fb8507c9..7ad96019639 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -204,7 +204,7 @@ if ($type_element == 'invoice') $tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; $where.= " AND d.fk_facture = f.rowid"; - $where.= " AND f.entity = ".$conf->entity; + $where.= " AND f.entity IN (".getEntity('facture').")"; $dateprint = 'f.datef'; $doc_number='f.facnumber'; $thirdTypeSelect='customer'; diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 7a06da294ab..03252da6cfa 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -770,7 +770,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - $sql.= ' WHERE f.entity = '.$conf->entity; + $sql.= ' WHERE f.entity IN ('.getEntity('facture').")"; $sql.= ' AND (f.fk_soc = '.$facture->socid; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { @@ -1077,7 +1077,7 @@ if (! GETPOST('action')) $sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; - $sql.= ' AND f.entity = '.$conf->entity; + $sql.= ' AND f.entity IN ('.getEntity('facture').")"; if ($socid) { $sql.= ' AND f.fk_soc = '.$socid; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 03931701659..161f4fd7cb3 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -428,7 +428,7 @@ function getInvoicesForThirdParty($authentication,$idthirdparty) $sql ='SELECT f.rowid as facid, facnumber as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva'; $sql.=' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.=" WHERE f.entity = ".$conf->entity; + $sql.=" WHERE f.entity IN (".getEntity('facture').")"; if ($idthirdparty != 'all' ) $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty); $resql=$db->query($sql); diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index ad5d6b72650..d90315af72f 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -128,7 +128,7 @@ $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND s.fk_pays = cp.rowid"; if (! empty($date_start) && ! empty($date_end)) $sql .= " AND f.datec >= '" . $db->idate($date_start) . "' AND f.datec <= '" . $db->idate($date_end) . "'"; -$sql .= " AND f.entity = " . $conf->entity; +$sql .= " AND f.entity IN (".getEntity('facture').")"; if ($socid) $sql .= " AND f.fk_soc = " . $socid; $sql .= " GROUP BY name";