From 8e51204dfff455f1a80a144ab63733e39c2cbbc5 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 7 Nov 2018 12:11:19 +0100 Subject: [PATCH 01/10] manage invoice with multicompany --- htdocs/compta/facture/class/facture.class.php | 14 ++++++- .../core/modules/facture/mod_facture_mars.php | 6 ++- .../modules/facture/mod_facture_mercure.php | 37 +++++++++++++++++-- .../modules/facture/mod_facture_terre.php | 5 ++- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 227ae42b266..7c8a02ba693 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -947,7 +947,7 @@ class Facture extends CommonInvoice */ function createFromClone($socid=0) { - global $user,$hookmanager; + global $user,$hookmanager, $conf; $error=0; @@ -996,6 +996,7 @@ class Facture extends CommonInvoice $this->close_code = ''; $this->close_note = ''; $this->products = $this->lines; // Tant que products encore utilise + $this->entity = $conf->entity; // Loop on each line of new invoice foreach($this->lines as $i => $line) @@ -3348,7 +3349,16 @@ class Facture extends CommonInvoice $mybool=false; $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; + + $constant = 'FACTURE_ADDON_'.$this->entity; + + if (! empty($conf->global->$constant)) { + $classname = $conf->global->$constant; // for multicompany proposal sharing + } else { + $classname = $conf->global->FACTURE_ADDON; + } + + // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 19161ae1325..d9ff514d42d 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -151,7 +151,7 @@ class mod_facture_mars extends ModeleNumRefFactures */ function getNextValue($objsoc, $invoice, $mode='next') { - global $db; + global $db, $conf; $prefix=$this->prefixinvoice; @@ -160,12 +160,14 @@ class mod_facture_mars extends ModeleNumRefFactures else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; + $entity = ((isset($$invoice->entity) && is_numeric($$invoice->entity)) ? $$invoice->entity : $conf->entity); + // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + $sql.= " AND entity = $entity"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 88217172c76..032112af70d 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -145,15 +145,46 @@ class mod_facture_mercure extends ModeleNumRefFactures $mask = ''; if (is_object($invoice) && $invoice->type == 1) { + $constant = 'FACTURE_MERCURE_MASK_REPLACEMENT_'.$invoice->entity; + if (! empty($conf->global->$constant)) { + $mask = $conf->global->$constant; // for multicompany proposal sharing + } else { $mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; + } if (! $mask) { + $constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity; + if (! empty($conf->global->$constant)) { + $mask = $conf->global->$constant; // for multicompany proposal sharing + } else { $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; } } - else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; - else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; - else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; + } + else if (is_object($invoice) && $invoice->type == 2){ + $constant = 'FACTURE_MERCURE_MASK_CREDIT_'.$invoice->entity; + if (! empty($conf->global->$constant)) { + $mask = $conf->global->$constant; // for multicompany proposal sharing + } else { + $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; + } + } + else if (is_object($invoice) && $invoice->type == 3){ + $constant = 'FACTURE_MERCURE_MASK_DEPOSIT_'.$invoice->entity; + if (! empty($conf->global->$constant)) { + $mask = $conf->global->$constant; // for multicompany proposal sharing + } else { + $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; + } + } + else { + $constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity; + if (! empty($conf->global->$constant)) { + $mask = $conf->global->$constant; // for multicompany proposal sharing + } else { + $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; + } + } if (! $mask) { $this->error='NotConfigured'; diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 1c19d564486..697827ceb6f 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -175,12 +175,15 @@ class mod_facture_terre extends ModeleNumRefFactures else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; + // D'abord on recupere la valeur max + $entity = ((isset($invoice->entity) && is_numeric($invoice->entity)) ? $invoice->entity : $conf->entity); + // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + $sql.= " AND entity = $entity"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); From a8ab666d6273b8133cfa0ae119134d69c2aab412 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 7 Nov 2018 16:45:04 +0100 Subject: [PATCH 02/10] 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"; From e004fc2f5b7706dfa1a7444d1152b29c2fe93d3a Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 13 Nov 2018 10:13:52 +0100 Subject: [PATCH 03/10] FIX block page if cant fetch --- htdocs/compta/bank/bankentries_list.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 94885ab118b..e53e66c51f6 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -122,6 +122,12 @@ if ($id > 0 || ! empty($ref)) $search_account = $object->id; // Force the search field on id of account } +if (! ($object->id > 0) ) +{ + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('banktransactionlist', $contextpage)); From c18f4861792125be5539036e9e0ebae69409be00 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 13 Nov 2018 12:11:21 +0100 Subject: [PATCH 04/10] set facture to invoice AND check invoicenumber conf --- htdocs/accountancy/class/lettering.class.php | 4 ++-- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 8 ++++---- htdocs/accountancy/customer/lines.php | 4 ++-- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- htdocs/admin/prelevement.php | 2 +- htdocs/comm/card.php | 2 +- htdocs/compta/bank/treso.php | 2 +- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/compta/facture/class/facture-rec.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 14 +++++++------- htdocs/compta/facture/class/facturestats.class.php | 2 +- htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/index.php | 8 ++++---- htdocs/compta/journal/purchasesjournal.php | 2 +- htdocs/compta/journal/sellsjournal.php | 2 +- htdocs/compta/paiement.php | 4 ++-- htdocs/compta/paiement/card.php | 2 +- htdocs/compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/paiement/list.php | 4 ++-- htdocs/compta/paiement/tovalidate.php | 2 +- htdocs/compta/prelevement/bons.php | 2 +- .../prelevement/class/bonprelevement.class.php | 8 ++++---- .../prelevement/class/rejetprelevement.class.php | 2 +- htdocs/compta/prelevement/create.php | 4 ++-- 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_activity.php | 4 ++-- htdocs/core/boxes/box_factures.php | 2 +- htdocs/core/boxes/box_factures_imp.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/modules/facture/mod_facture_mars.php | 6 ++++-- htdocs/core/modules/facture/mod_facture_terre.php | 6 ++++-- htdocs/core/modules/modFacture.class.php | 4 ++-- htdocs/core/modules/rapport/pdf_paiement.class.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/margin/agentMargins.php | 2 +- htdocs/margin/checkMargins.php | 2 +- htdocs/margin/productMargins.php | 2 +- htdocs/margin/tabs/thirdpartyMargins.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/index.php | 2 +- htdocs/product/stats/facture.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/consumption.php | 2 +- htdocs/stripe/payment.php | 4 ++-- htdocs/webservices/server_invoice.php | 2 +- scripts/accountancy/export-thirdpartyaccount.php | 2 +- 61 files changed, 96 insertions(+), 92 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index e0dc0f093bd..9dc3214e6c6 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 IN (".getEntity('facture').")"; + $sql .= " AND fac.entity IN (".getEntity('invoice').")"; $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 IN (".getEntity('facture').")"; + $sql .= " AND fac.entity IN (".getEntity('invoice').")"; $sql .= " AND ( "; if (! empty($object->code_compta)) { $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 677bc627c80..6b60296a5f4 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -102,7 +102,7 @@ if (! empty($id)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 4f4932fe08f..ca75aaac15e 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -180,7 +180,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; $sql .= " AND f.fk_statut > 0"; -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; 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 . ")"; @@ -255,7 +255,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $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 . ")"; @@ -332,7 +332,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $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 . ")"; @@ -384,7 +384,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $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/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 7d8599b683c..f4ed9bad1f5 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -184,7 +184,7 @@ $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factur $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " WHERE fd.fk_code_ventilation > 0"; -$sql.= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql.= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $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 . ")"; @@ -245,7 +245,7 @@ if (strlen(trim($search_country))) { if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); } -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); // Count total nb of records diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 74944b8f823..64a11fccc2a 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -288,7 +288,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } else { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy // Add where from hooks $parameters=array(); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 21736195073..f4729e6243d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -107,7 +107,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $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 .= " WHERE fd.fk_code_ventilation > 0"; -$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy, we use source object sharing +$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing $sql .= " AND f.fk_statut > 0"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 9fc4f46e54f..6d67cab60f9 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -432,7 +432,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) $sql = "SELECT u.rowid, u.lastname, u.firstname, u.fk_soc, u.email"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE entity IN (".getEntity('facture').")"; + $sql.= " WHERE entity IN (".getEntity('invoice').")"; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 37eea35725b..8650837da52 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 5756cbf6c61..94efe101661 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -143,7 +143,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $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 IN (".getEntity('facture').")"; + $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $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"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3d3625ba777..acbc145de53 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -739,7 +739,7 @@ if (empty($reshook)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql.= ' WHERE pf.fk_facture = '.$object->id; $sql.= ' AND pf.fk_paiement = p.rowid'; - $sql.= ' AND p.entity IN (' . getEntity('facture').')'; + $sql.= ' AND p.entity IN (' . getEntity('invoice').')'; $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -4284,7 +4284,7 @@ else if ($id > 0 || ! empty($ref)) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND pf.fk_paiement = p.rowid'; - $sql .= ' AND p.entity IN (' . getEntity('facture').')'; + $sql .= ' AND p.entity IN (' . getEntity('invoice').')'; $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 5075d9d8cb7..1e6b1d35a8e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -123,7 +123,7 @@ class Invoices extends DolibarrApi if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('facture').')'; + $sql.= ' WHERE t.entity IN ('.getEntity('invoice').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 56f87d2eac3..f302f4191f8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -340,7 +340,7 @@ class FactureRec extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; - $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; + $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; if ($rowid) $sql.= ' AND f.rowid='.$rowid; elseif ($ref) $sql.= " AND f.titre='".$this->db->escape($ref)."'"; /* This field are not used for template invoice diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4dc0adea029..97417bd8b9d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1335,7 +1335,7 @@ class Facture extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; if ($rowid) $sql.= " WHERE f.rowid=".$rowid; - else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid + else $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; @@ -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 IN (".getEntity('facture').")"; + $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 IN (".getEntity('facture').")"; + $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 IN (".getEntity('facture').")"; + $sql.= " ".$clause." f.entity IN (".getEntity('invoice').")"; $resql=$this->db->query($sql); if ($resql) @@ -4152,7 +4152,7 @@ class Facture extends CommonInvoice function newCycle() { $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql.= " WHERE f.entity in (".getEntity('facture', 0).")"; + $sql.= " WHERE f.entity in (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 4aa50167842..4cf9477613e 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 IN (".getEntity('facture').")"; + $this->where.= " AND f.entity IN (".getEntity('invoice').")"; 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/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index c0a80c86b74..c28b0917e1e 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -222,7 +222,7 @@ if (! $user->rights->societe->client->voir && ! $socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= ' AND f.entity IN ('.getEntity('facture').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; if (! $user->rights->societe->client->voir && ! $socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 83925a38b08..2b289b9475a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -399,7 +399,7 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE f.fk_soc = s.rowid'; -$sql.= ' AND f.entity IN ('.getEntity('facture').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index df2688298fd..740eb4c8c17 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 IN (".getEntity('facture').')'; + $sql.= " AND f.entity IN (".getEntity('invoice').')'; 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 IN (".getEntity('facture').')'; + $sql.= " AND f.entity IN (".getEntity('invoice').')'; 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 5a73f3a4b41..2ab17905715 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 IN (".getEntity('facture').")"; +$sql.= " WHERE f.fk_statut > 0 AND f.entity IN (".getEntity('invoice').")"; 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 bb0145ff227..dbd11a554f6 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 IN (".getEntity('facture').")"; +$sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $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.php b/htdocs/compta/paiement.php index 32e042c5731..965141da766 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -528,7 +528,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; $sql.= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' WHERE f.entity IN ('.getEntity('facture', $conf->entity).')'; + $sql.= ' WHERE f.entity IN ('.getEntity('invoice', $conf->entity).')'; $sql.= ' AND (f.fk_soc = '.$facture->socid; // Can pay invoices of all child of parent company if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { @@ -846,7 +846,7 @@ if (! GETPOST('action','aZ09')) $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql.= ', '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE p.fk_facture = f.rowid'; - $sql.= ' AND f.entity IN (' . getEntity('facture').')'; + $sql.= ' AND f.entity IN (' . getEntity('invoice').')'; if ($socid) { $sql.= ' AND f.fk_soc = '.$socid; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 63631ca660a..773547bcf4f 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -324,7 +324,7 @@ $sql = 'SELECT f.rowid as facid, f.facnumber,f.entity, f.type, f.total_ttc, f.pa $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 IN ('.getEntity('facture').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; $sql.= ' AND pf.fk_paiement = '.$object->id; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 18dabbcf980..cab87e4ff7b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -165,7 +165,7 @@ class Paiement extends CommonObject $sql.= ' b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' WHERE p.entity IN (' . getEntity('facture').')'; + $sql.= ' WHERE p.entity IN (' . getEntity('invoice').')'; if ($id > 0) $sql.= ' AND p.rowid = '.$id; else if ($ref) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 768792c978c..6bd70e0aacc 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -118,7 +118,7 @@ if (GETPOST("orphelins")) $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql.= " WHERE p.entity IN (" . getEntity('facture').")"; + $sql.= " WHERE p.entity IN (" . getEntity('invoice').")"; $sql.= " AND pf.fk_facture IS NULL"; // Add where from hooks $parameters=array(); @@ -149,7 +149,7 @@ else { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } - $sql.= " WHERE p.entity IN (" . getEntity('facture') . ")"; + $sql.= " WHERE p.entity IN (" . getEntity('invoice') . ")"; if (! $user->rights->societe->client->voir && ! $socid) { $sql.= " AND sc.fk_user = " .$user->id; diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 9fea9afa5df..a037326d9b1 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -71,7 +71,7 @@ if ($socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; } -$sql.= " WHERE p.entity IN (" . getEntity('facture') . ')'; +$sql.= " WHERE p.entity IN (" . getEntity('invoice') . ')'; if ($socid) { $sql.= " AND f.fk_soc = ".$socid; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index e4fb8bc0757..cfe2e2a942c 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -74,7 +74,7 @@ llxHeader('',$langs->trans("WithdrawalsReceipts")); $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 IN (".getEntity('facture').")"; +$sql.= " WHERE p.entity IN (".getEntity('invoice').")"; 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 3ea75d771db..5fc95b90a8f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -288,7 +288,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 IN (".getEntity('facture').")"; + $sql.= " WHERE p.entity IN (".getEntity('invoice').")"; if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid; else $sql.= " AND p.ref = '".$this->db->escape($ref)."'"; @@ -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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.rowid = pfd.fk_facture"; $sql.= " AND f.paye = 0"; $sql.= " AND pfd.traite = 0"; @@ -820,7 +820,7 @@ class BonPrelevement extends CommonObject $sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE f.rowid = pfd.fk_facture"; - $sql.= " AND f.entity IN (".getEntity('facture').')'; + $sql.= " AND f.entity IN (".getEntity('invoice').')'; $sql.= " AND s.rowid = f.fk_soc"; //if ($banque || $agence) $sql.= " AND s.rowid = sr.fk_soc"; $sql.= " AND f.fk_statut = 1"; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index e7d7259333c..4797121a24c 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 91df1750627..dd1be4c2c09 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND pfd.traite = 0"; $sql.= " AND pfd.fk_facture = f.rowid"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; @@ -303,7 +303,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 IN (".getEntity('facture').")"; +$sql.= " WHERE p.entity IN (".getEntity('invoice').")"; $sql.= " ORDER BY datec DESC"; $sql.=$db->plimit($limit); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 1a6c8bf0d84..b75e0d7b191 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 99884eb640a..905a4687812 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 5174a85879e..5c32a10992c 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 0ea6fd36b1e..12b92992053 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 4a22faa1b55..56dff05720f 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 061b2d5347a..d33f0c47aca 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 43e3b85f2a5..fc6bd855d3e 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 b04e9169518..3a3ba57cb18 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 abcf46611d1..701fe86f10e 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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 5824f64a8a2..ba9556dd2ac 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 a7d25cd5c13..eec3bbcfbac 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 IN (".getEntity('facture').")"; +$sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 8ccd4e5349b..e4f53951c58 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; } else if ($modecompta=="BOOKKEEPING") diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index bd3163268ac..413dc43d8b2 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -289,7 +289,7 @@ class box_activity extends ModeleBoxes $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " WHERE f.entity IN (".getEntity('facture').')'; + $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; 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; $sql.= " AND f.fk_soc = s.rowid"; @@ -371,7 +371,7 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity IN (".getEntity('facture').')'; + $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0"; $sql.= " GROUP BY f.fk_statut"; diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 17a2da3a72f..3641e9cc8d0 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; 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 11476e8fa93..2a2c62daa82 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9a1ac5cb834..2b47459c04a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6414,8 +6414,8 @@ class Form $possiblelinks=array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), - 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.facnumber as ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'), - 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'), + 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.facnumber as ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), + 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), 'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index d9ff514d42d..222b3342d6f 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -167,7 +167,8 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity = $entity"; + if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + else $sql.= " AND entity = $entity"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -191,7 +192,8 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + else $sql.= " AND entity = $entity"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 697827ceb6f..e24205cb2d6 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -183,7 +183,8 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity = $entity"; + if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + else $sql.= " AND entity = $entity"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -207,7 +208,8 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + else $sql.= " AND entity = $entity"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index f8982ae2893..c187725e181 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -265,7 +265,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; - $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('facture').')'; + $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; $r++; @@ -320,7 +320,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture').')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('invoice').')'; if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; $r++; } diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 191e68c777b..90f57c6ca0c 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b6ff1d36551..3749489e290 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -516,7 +516,7 @@ if (empty($reshook)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (' . getEntity('c_paiement') . ')'; $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $sql.= ' AND pf.fk_paiementfourn = p.rowid'; - $sql.= ' AND p.entity IN (' . getEntity('facture').')'; + $sql.= ' AND p.entity IN (' . getEntity('invoice').')'; $resql = $db->query($sql); if (! $resql) dol_print_error($db); diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 5c808051a06..71922b77aa2 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -139,7 +139,7 @@ $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= ' AND f.entity IN ('.getEntity('facture').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; $sql.= " AND sc.fk_soc = f.fk_soc"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if (! empty($conf->global->AGENT_CONTACT_TYPE)) diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 06527f42b91..2f7b534fbba 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -191,7 +191,7 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d ON d.fk_facture = f.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid"; $sql .= " WHERE f.fk_statut > 0"; -$sql .= " AND f.entity IN (" . getEntity('facture') . ") "; +$sql .= " AND f.entity IN (" . getEntity('invoice') . ") "; if (! empty($startdate)) $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'"; if (! empty($enddate)) $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'"; if ($search_ref) $sql.=natural_search('f.facnumber', $search_ref); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 23c9de6c321..8a741c3712e 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -189,7 +189,7 @@ if (! empty($TSelectedCats)) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=p.rowid'; } $sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= ' AND f.entity IN ('.getEntity('facture').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; $sql.= " AND f.fk_statut > 0"; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index e30135ef16e..b41888267d3 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 IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $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/class/product.class.php b/htdocs/product/class/product.class.php index 6d3a0724006..df1b0d20eae 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2622,7 +2622,7 @@ class Product extends CommonObject } $sql.= " WHERE f.rowid = fd.fk_facture"; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND fd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; } @@ -2788,7 +2788,7 @@ class Product extends CommonObject if ($filteronproducttype >= 0) { $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$socid) { $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; } if ($socid > 0) { $sql.= " AND f.fk_soc = $socid"; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 9a2a1d992ca..56519e6f46b 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 IN (".getEntity('facture').")"; + $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $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/product/stats/facture.php b/htdocs/product/stats/facture.php index cd2dc221bb9..8b3cd4d9856 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -155,7 +155,7 @@ if ($id > 0 || ! empty($ref)) $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture').")"; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND d.fk_product =".$product->id; if (! empty($search_month)) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2411623e4aa..e69a7886d1e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3804,7 +3804,7 @@ class Societe extends CommonObject if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('facture_fourn').")"; } else { - $sql .= " AND entity IN (".getEntity('facture').")"; + $sql .= " AND entity IN (".getEntity('invoice').")"; } dol_syslog("getOutstandingBills", LOG_DEBUG); diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 7ad96019639..693a09cee44 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 IN (".getEntity('facture').")"; + $where.= " AND f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; $doc_number='f.facnumber'; $thirdTypeSelect='customer'; diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 03252da6cfa..6739d4ccf34 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 IN ('.getEntity('facture').")"; + $sql.= ' WHERE f.entity IN ('.getEntity('invoice').")"; $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 IN ('.getEntity('facture').")"; + $sql.= ' AND f.entity IN ('.getEntity('invoice').")"; if ($socid) { $sql.= ' AND f.fk_soc = '.$socid; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 161f4fd7cb3..de829990d53 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 IN (".getEntity('facture').")"; + $sql.=" WHERE f.entity IN (".getEntity('invoice').")"; 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 d90315af72f..6774c2af275 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 IN (".getEntity('facture').")"; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) $sql .= " AND f.fk_soc = " . $socid; $sql .= " GROUP BY name"; From 70fdff5c27fd20a6f4ec8ef8db051edecf0253c0 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 13 Nov 2018 12:32:24 +0100 Subject: [PATCH 05/10] revert getNextValue function + createfromclone entity --- htdocs/compta/facture/class/facture.class.php | 1 - htdocs/core/modules/facture/mod_facture_mars.php | 13 +++---------- htdocs/core/modules/facture/mod_facture_terre.php | 12 ++---------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 97417bd8b9d..69816eb1660 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -996,7 +996,6 @@ class Facture extends CommonInvoice $this->close_code = ''; $this->close_note = ''; $this->products = $this->lines; // Tant que products encore utilise - $this->entity = $conf->entity; // Loop on each line of new invoice foreach($this->lines as $i => $line) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 222b3342d6f..5dbc1dd2b7a 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -151,8 +151,7 @@ class mod_facture_mars extends ModeleNumRefFactures */ function getNextValue($objsoc, $invoice, $mode='next') { - global $db, $conf; - + global $db; $prefix=$this->prefixinvoice; if ($invoice->type == 1) $prefix=$this->prefixreplacement; @@ -160,16 +159,12 @@ class mod_facture_mars extends ModeleNumRefFactures else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; - $entity = ((isset($$invoice->entity) && is_numeric($$invoice->entity)) ? $$invoice->entity : $conf->entity); - // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); if ($resql) @@ -192,9 +187,7 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index e24205cb2d6..3d323ba2c6b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -174,18 +174,12 @@ class mod_facture_terre extends ModeleNumRefFactures if ($invoice->type == 2) $prefix=$this->prefixcreditnote; else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; - - // D'abord on recupere la valeur max - $entity = ((isset($invoice->entity) && is_numeric($invoice->entity)) ? $invoice->entity : $conf->entity); - // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); if ($resql) @@ -208,9 +202,7 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); if ($resql) From 4cc3fa1006ea5e5e07c7eff0fad141ecdd192210 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 16 Nov 2018 11:03:05 +0100 Subject: [PATCH 06/10] FIX we dont share object for accountancy --- htdocs/accountancy/class/lettering.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 9dc3214e6c6..4ffd6cbe426 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 IN (".getEntity('invoice').")"; + $sql .= " AND fac.entity IN (".getEntity('invoice',0).")";// We don't share object for accountancy $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 IN (".getEntity('invoice').")"; + $sql .= " AND fac.entity IN (".getEntity('invoice',0).")";// We don't share object for accountancy $sql .= " AND ( "; if (! empty($object->code_compta)) { $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; From 7571760fddab9c368de808e29291537a2db0ddd2 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 16 Nov 2018 11:31:23 +0100 Subject: [PATCH 07/10] fix errors during cherry picking --- htdocs/core/modules/facture/mod_facture_mars.php | 6 ++++-- htdocs/core/modules/facture/mod_facture_mercure.php | 3 +++ htdocs/core/modules/facture/mod_facture_terre.php | 6 ++++-- htdocs/product/card.php | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 5dbc1dd2b7a..a9ae6a0e1e8 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -164,7 +164,8 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); if ($resql) @@ -187,7 +188,8 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index d1ad13affa7..73c8984d336 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -194,6 +194,9 @@ class mod_facture_mercure extends ModeleNumRefFactures $where=''; //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); if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal; diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 3d323ba2c6b..474c4c20ac2 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -179,7 +179,8 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); if ($resql) @@ -202,7 +203,8 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f4e4bb90937..f94c34d1804 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 ( $object->id && ($action == '' || $action == 'view') && $object->status) +if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) { //Variable used to check if any text is going to be printed $html = ''; From 56d4a8a73759e0b5d7928908c9ed07c047bf38f1 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 16 Nov 2018 15:16:48 +0100 Subject: [PATCH 08/10] revert some code --- htdocs/compta/facture/class/facture.class.php | 11 +---- htdocs/compta/paiement.php | 2 +- .../modules/facture/mod_facture_mercure.php | 47 ++----------------- 3 files changed, 8 insertions(+), 52 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 69816eb1660..36dc78d4e0f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3348,15 +3348,8 @@ class Facture extends CommonInvoice $mybool=false; - - $constant = 'FACTURE_ADDON_'.$this->entity; - - if (! empty($conf->global->$constant)) { - $classname = $conf->global->$constant; // for multicompany proposal sharing - } else { - $classname = $conf->global->FACTURE_ADDON; - } - $file = $classname.".php"; + $file = $conf->global->FACTURE_ADDON.".php"; + $classname = $conf->global->FACTURE_ADDON; // Include file with class diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 965141da766..c8146691b55 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -528,7 +528,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; $sql.= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' WHERE f.entity IN ('.getEntity('invoice', $conf->entity).')'; + $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; $sql.= ' AND (f.fk_soc = '.$facture->socid; // Can pay invoices of all child of parent company if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 73c8984d336..1225fbd5964 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -138,69 +138,32 @@ class mod_facture_mercure extends ModeleNumRefFactures function getNextValue($objsoc, $invoice, $mode='next') { global $db,$conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; - // Get Mask value $mask = ''; if (is_object($invoice) && $invoice->type == 1) { - $constant = 'FACTURE_MERCURE_MASK_REPLACEMENT_'.$invoice->entity; - if (! empty($conf->global->$constant)) { - $mask = $conf->global->$constant; // for multicompany proposal sharing - } else { $mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; - } if (! $mask) { - $constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity; - if (! empty($conf->global->$constant)) { - $mask = $conf->global->$constant; // for multicompany proposal sharing - } else { $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; } } - } - else if (is_object($invoice) && $invoice->type == 2){ - $constant = 'FACTURE_MERCURE_MASK_CREDIT_'.$invoice->entity; - if (! empty($conf->global->$constant)) { - $mask = $conf->global->$constant; // for multicompany proposal sharing - } else { - $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; - } - } - else if (is_object($invoice) && $invoice->type == 3){ - $constant = 'FACTURE_MERCURE_MASK_DEPOSIT_'.$invoice->entity; - if (! empty($conf->global->$constant)) { - $mask = $conf->global->$constant; // for multicompany proposal sharing - } else { - $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; - } - } - else { - $constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity; - if (! empty($conf->global->$constant)) { - $mask = $conf->global->$constant; // for multicompany proposal sharing - } else { - $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; - } - } + else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; + else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; + else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; if (! $mask) { $this->error='NotConfigured'; return 0; } - $where=''; //if ($facture->type == 2) $where.= " AND type = 2"; //else $where.=" AND type != 2"; - - // Get entities + // 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; } From a0d5607ba5f9ddd7bb9b684e3e19a32babcff88e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 16 Nov 2018 15:29:05 +0100 Subject: [PATCH 09/10] FIX error travis --- htdocs/compta/bank/treso.php | 3 +-- htdocs/core/lib/tax.lib.php | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 94efe101661..2495ac89d51 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -291,8 +291,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) if($obj->family == 'invoice'){ $mc->getInfo($obj->entity); print "".$mc->label.""; - }else print ""; - + }else print ""; } print "".$refcomp.""; if ($obj->total_ttc < 0) { print "".price(abs($total_ttc))." "; }; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 105a8e7e215..d6930281e8b 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -110,7 +110,6 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $paymenttable='paiement'; $paymentfacturetable='paiement_facture'; $invoicefieldref='facnumber'; - } if ($direction == 'buy') { From 6d088e45ee89333b2eb24a0b011a6eb465f58107 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 14 Dec 2018 16:29:47 +0100 Subject: [PATCH 10/10] FIX missing getEntity 0 in scripts directory --- scripts/accountancy/export-thirdpartyaccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 6774c2af275..c135e33016c 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 IN (".getEntity('invoice').")"; +$sql .= " AND f.entity IN (".getEntity('invoice',0).")"; if ($socid) $sql .= " AND f.fk_soc = " . $socid; $sql .= " GROUP BY name";