From 5c5663c5ae9a9b02f9a994d10cfaa310ed2bbdfb Mon Sep 17 00:00:00 2001 From: Regis Houssin <regis.houssin@capnetworks.com> Date: Tue, 30 May 2017 18:50:54 +0200 Subject: [PATCH] New: getEntity function use true $shared value by default --- ChangeLog | 2 + htdocs/accountancy/admin/productaccount.php | 2 +- .../accountancy/class/bookkeeping.class.php | 32 ++++++++-------- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 12 +++--- htdocs/accountancy/customer/lines.php | 4 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/card.php | 2 +- htdocs/accountancy/expensereport/index.php | 8 ++-- htdocs/accountancy/expensereport/lines.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- .../journal/expensereportsjournal.php | 2 +- .../accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/supplier/card.php | 2 +- htdocs/accountancy/supplier/index.php | 8 ++-- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/adherents/class/adherent.class.php | 4 +- .../adherents/class/adherentstats.class.php | 2 +- htdocs/adherents/class/api_members.class.php | 2 +- .../class/api_memberstypes.class.php | 2 +- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/admin/dict.php | 2 +- htdocs/admin/facture.php | 4 +- htdocs/admin/mails_templates.php | 2 +- htdocs/admin/tools/listevents.php | 2 +- htdocs/asterisk/cidlookup.php | 2 +- htdocs/asterisk/wrapper.php | 2 +- htdocs/bookmarks/bookmarks.lib.php | 2 +- htdocs/cashdesk/facturation.php | 4 +- htdocs/cashdesk/facturation_dhtml.php | 2 +- htdocs/cashdesk/facturation_verif.php | 2 +- .../categories/class/api_categories.class.php | 4 +- .../class/api_deprecated_category.class.php | 4 +- htdocs/categories/class/categorie.class.php | 10 ++--- htdocs/comm/action/class/actioncomm.class.php | 6 +-- .../action/class/api_agendaevents.class.php | 2 +- htdocs/comm/action/index.php | 4 +- htdocs/comm/action/listactions.php | 2 +- htdocs/comm/action/pertype.php | 2 +- htdocs/comm/action/peruser.php | 4 +- htdocs/comm/action/rapport/index.php | 2 +- htdocs/comm/card.php | 2 +- htdocs/comm/contact.php | 2 +- htdocs/comm/index.php | 14 +++---- .../mailing/class/advtargetemailing.class.php | 4 +- htdocs/comm/propal/card.php | 2 +- .../comm/propal/class/api_proposals.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 10 ++--- .../comm/propal/class/propalestats.class.php | 2 +- htdocs/comm/propal/index.php | 8 ++-- htdocs/comm/propal/list.php | 2 +- htdocs/comm/prospect/index.php | 4 +- .../class/api_deprecated_commande.class.php | 2 +- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/commande/class/commande.class.php | 10 ++--- htdocs/commande/class/commandestats.class.php | 2 +- htdocs/commande/customer.php | 2 +- htdocs/commande/index.php | 10 ++--- htdocs/commande/list.php | 2 +- htdocs/commande/orderstoinvoice.php | 2 +- htdocs/compta/bank/annuel.php | 12 +++--- htdocs/compta/bank/bankentries.php | 4 +- htdocs/compta/bank/class/account.class.php | 6 +-- .../bank/class/api_bankaccounts.class.php | 2 +- htdocs/compta/bank/graph.php | 20 +++++----- htdocs/compta/bank/index.php | 2 +- htdocs/compta/charges/index.php | 2 +- htdocs/compta/clients.php | 2 +- .../deplacement/class/deplacement.class.php | 2 +- .../class/api_deprecated_invoice.class.php | 2 +- .../facture/class/api_invoices.class.php | 2 +- .../facture/class/facture-rec.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 4 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/paiement/cheque/card.php | 4 +- .../cheque/class/remisecheque.class.php | 2 +- htdocs/compta/paiement/cheque/index.php | 2 +- htdocs/compta/resultat/clientfourn.php | 8 ++-- htdocs/compta/resultat/index.php | 8 ++-- htdocs/compta/sociales/payments.php | 2 +- htdocs/compta/stats/cabyuser.php | 2 +- htdocs/compta/stats/casoc.php | 2 +- htdocs/compta/stats/index.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 +- htdocs/contrat/index.php | 14 +++---- htdocs/contrat/list.php | 2 +- htdocs/core/boxes/box_clients.php | 2 +- htdocs/core/boxes/box_contacts.php | 2 +- htdocs/core/boxes/box_fournisseurs.php | 2 +- htdocs/core/boxes/box_goodcustomers.php | 2 +- htdocs/core/boxes/box_project.php | 4 +- htdocs/core/boxes/box_prospect.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/html.form.class.php | 32 ++++++++-------- .../core/class/html.formaccounting.class.php | 8 ++-- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 6 +-- htdocs/core/class/html.formprojet.class.php | 4 +- htdocs/core/class/notify.class.php | 4 +- htdocs/core/lib/company.lib.php | 4 +- htdocs/core/lib/files.lib.php | 8 ++-- htdocs/core/lib/functions.lib.php | 4 +- htdocs/core/lib/sendings.lib.php | 2 +- .../core/modules/facture/mod_facture_mars.php | 4 +- .../modules/facture/mod_facture_terre.php | 4 +- .../mailings/advthirdparties.modules.php | 6 +-- .../modules/mailings/contacts1.modules.php | 6 +-- .../modules/mailings/contacts2.modules.php | 8 ++-- .../modules/mailings/contacts3.modules.php | 10 ++--- .../modules/mailings/contacts4.modules.php | 10 ++--- .../modules/mailings/thirdparties.modules.php | 8 ++-- .../thirdparties_services_expired.modules.php | 6 +-- htdocs/core/modules/modAccounting.class.php | 2 +- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/core/modules/modAgenda.class.php | 2 +- htdocs/core/modules/modBanque.class.php | 4 +- htdocs/core/modules/modCategorie.class.php | 10 ++--- htdocs/core/modules/modCommande.class.php | 2 +- htdocs/core/modules/modContrat.class.php | 2 +- htdocs/core/modules/modDeplacement.class.php | 2 +- htdocs/core/modules/modExpedition.class.php | 2 +- .../core/modules/modExpenseReport.class.php | 2 +- htdocs/core/modules/modFacture.class.php | 4 +- htdocs/core/modules/modFicheinter.class.php | 2 +- htdocs/core/modules/modFournisseur.class.php | 6 +-- htdocs/core/modules/modProduct.class.php | 6 +-- htdocs/core/modules/modProjet.class.php | 2 +- htdocs/core/modules/modPropale.class.php | 2 +- htdocs/core/modules/modResource.class.php | 2 +- htdocs/core/modules/modSalaries.class.php | 2 +- htdocs/core/modules/modService.class.php | 4 +- htdocs/core/modules/modSociete.class.php | 6 +-- htdocs/core/modules/modStock.class.php | 4 +- htdocs/core/modules/modTax.class.php | 2 +- htdocs/core/modules/modUser.class.php | 2 +- .../modules/societe/mod_codeclient_monkey.php | 4 +- htdocs/don/class/don.class.php | 2 +- htdocs/ecm/class/ecmfiles.class.php | 4 +- htdocs/expedition/card.php | 2 +- htdocs/expedition/class/expedition.class.php | 4 +- htdocs/expedition/index.php | 4 +- htdocs/expedition/list.php | 2 +- .../class/api_expensereports.class.php | 2 +- .../class/expensereport.class.php | 4 +- .../class/expensereportstats.class.php | 2 +- htdocs/expensereport/export_csv.php | 2 +- htdocs/expensereport/index.php | 4 +- htdocs/expensereport/list.php | 2 +- htdocs/expensereport/payment/card.php | 2 +- htdocs/expensereport/payment/payment.php | 2 +- htdocs/fichinter/index.php | 8 ++-- htdocs/fourn/card.php | 2 +- .../class/api_supplier_invoices.class.php | 2 +- htdocs/fourn/class/fournisseur.class.php | 4 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 4 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/contact.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/fourn/index.php | 2 +- htdocs/fourn/product/list.php | 2 +- htdocs/holiday/class/holiday.class.php | 4 +- htdocs/livraison/class/livraison.class.php | 2 +- htdocs/margin/agentMargins.php | 4 +- htdocs/margin/checkMargins.php | 2 +- htdocs/margin/customerMargins.php | 2 +- htdocs/margin/productMargins.php | 2 +- .../oldskeletons/skeleton_api_class.class.php | 2 +- .../oldskeletons/skeleton_class.class.php | 4 +- .../oldskeletons/skeleton_list.php | 2 +- .../template/class/myobject.class.php | 4 +- .../class/myobject_api_class.class.php | 2 +- .../modulebuilder/template/myobject_list.php | 2 +- .../class/multicurrency.class.php | 2 +- htdocs/opensurvey/list.php | 2 +- htdocs/product/admin/product_tools.php | 4 +- htdocs/product/ajax/products.php | 2 +- .../product/actions_card_product.class.php | 2 +- .../service/actions_card_service.class.php | 2 +- .../class/api_deprecated_product.class.php | 4 +- htdocs/product/class/api_products.class.php | 2 +- .../product/class/html.formproduct.class.php | 2 +- htdocs/product/class/product.class.php | 38 +++++++++---------- .../class/productcustomerprice.class.php | 6 +-- htdocs/product/composition/card.php | 2 +- htdocs/product/index.php | 2 +- .../inventory/class/inventory.class.php | 2 +- htdocs/product/list-with-listview.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/popuprop.php | 2 +- htdocs/product/price.php | 2 +- htdocs/product/reassort.php | 2 +- htdocs/product/reassortlot.php | 2 +- htdocs/product/stats/commande.php | 2 +- htdocs/product/stats/contrat.php | 2 +- htdocs/product/stats/facture.php | 2 +- htdocs/product/stats/facture_fournisseur.php | 2 +- htdocs/product/stats/propal.php | 2 +- .../stock/class/api_stockmovements.class.php | 2 +- .../stock/class/api_warehouses.class.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/product/stock/index.php | 4 +- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/mouvement.php | 2 +- htdocs/product/stock/product.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/product/stock/replenish.php | 10 ++--- htdocs/product/stock/valo.php | 2 +- htdocs/projet/class/api_projects.class.php | 2 +- htdocs/projet/class/api_tasks.class.php | 2 +- htdocs/projet/class/project.class.php | 8 ++-- htdocs/projet/class/task.class.php | 6 +-- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/resource/class/dolresource.class.php | 6 +-- htdocs/societe/ajaxcompanies.php | 2 +- htdocs/societe/class/api_contacts.class.php | 2 +- .../class/api_deprecated_contact.class.php | 2 +- .../class/api_deprecated_thirdparty.class.php | 2 +- .../societe/class/api_thirdparties.class.php | 2 +- htdocs/societe/class/societe.class.php | 4 +- htdocs/societe/index.php | 6 +-- htdocs/societe/list.php | 2 +- htdocs/societe/notify/index.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/user/class/api_users.class.php | 2 +- htdocs/user/class/user.class.php | 6 +-- htdocs/user/index.php | 2 +- .../variants/class/ProductAttribute.class.php | 6 +-- .../class/ProductAttributeValue.class.php | 2 +- .../class/ProductCombination.class.php | 8 ++-- htdocs/websites/class/websitepage.class.php | 2 +- 237 files changed, 456 insertions(+), 454 deletions(-) diff --git a/ChangeLog b/ChangeLog index c76617b2f8a..a0470fee04a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ English Dolibarr ChangeLog For developers: NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... +NEW: getEntity function use true $shared value by default WARNING: @@ -21,6 +22,7 @@ Following changes may create regression for some external modules, but were nece * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. * Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still exists, but if an external module need action on it, it must provides itself its trigger file. +* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', false) instead getEntity('xxx') or getEntity('xxx', 0) ***** ChangeLog for 5.0.2 compared to 5.0.1 ***** FIX: #6468 + Fix missing translation diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index fcb44c6f858..504d91a8f91 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -218,7 +218,7 @@ else { $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; } -$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; +$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy",$search_current_account); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5d9e7a9910a..8ba8d185ede 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -189,7 +189,7 @@ class BookKeeping extends CommonObject $sql .= " AND fk_doc = " . $this->fk_doc; $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $resql = $this->db->query($sql); @@ -203,7 +203,7 @@ class BookKeeping extends CommonObject $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object - $sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -215,7 +215,7 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + $sqlnum .= " WHERE entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -500,7 +500,7 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; if (null !== $ref) { $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; } else { @@ -605,7 +605,7 @@ class BookKeeping extends CommonObject } $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -715,7 +715,7 @@ class BookKeeping extends CommonObject } } $sql.= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -809,7 +809,7 @@ class BookKeeping extends CommonObject } } $sql.= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -1062,7 +1062,7 @@ class BookKeeping extends CommonObject $sql.= " WHERE 1 = 1"; if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $resql = $this->db->query($sql); if (! $resql) { @@ -1094,7 +1094,7 @@ class BookKeeping extends CommonObject $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $resql = $this->db->query($sql); @@ -1200,7 +1200,7 @@ class BookKeeping extends CommonObject $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -1231,7 +1231,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -1263,7 +1263,7 @@ class BookKeeping extends CommonObject $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -1315,7 +1315,7 @@ class BookKeeping extends CommonObject $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); @@ -1384,7 +1384,7 @@ class BookKeeping extends CommonObject $sql .= " AND aa.active = 1"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $pcgver; - $sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY account_number ASC"; dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); @@ -1449,7 +1449,7 @@ class BookKeeping extends CommonObject $sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; - $sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -1488,7 +1488,7 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND aa.active = 1"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; - $sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " WHERE aa.entity IN (" . getEntity('accountancy') . ")"; dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index eca3be1d477..b32486038af 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -93,7 +93,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('facture', false) . ")"; // 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 82a406d4a0b..ab10efde376 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -141,7 +141,7 @@ if ($action == 'validatehistory') { $sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; - $sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; $sql1.=")"; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); @@ -187,7 +187,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('facture', false) . ")"; // We don't share object for accountancy dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); @@ -228,7 +228,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(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', false) . ")"; // 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 . ")"; @@ -284,7 +284,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(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; -$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', false) . ")"; // We don't share object for accountancy 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 . ")"; } else { @@ -341,7 +341,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(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture', false) . ")"; // We don't share object for accountancy 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 . ")"; } else { @@ -387,7 +387,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(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture', false) . ")"; // We don't share object for accountancy 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 . ")"; } else { diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index f3763dd9ca0..f5e8881e51b 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -164,7 +164,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu $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('facture', false) . ")"; // 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 . ")"; @@ -201,7 +201,7 @@ if (strlen(trim($search_country))) { if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tva_intra); } -$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', false) . ")"; // 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 8af289f2c99..cc2495a0f9e 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -220,7 +220,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } else { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . 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('facture', false) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index e37b35f1003..201e61e97ab 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -96,7 +96,7 @@ if (! empty($id)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id; - $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + $sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index c062d4e09c2..933cd6c3303 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -134,7 +134,7 @@ if ($action == 'validatehistory') { $sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er"; $sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; $sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; - $sql1.= " AND er.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; $sql1.=")"; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); @@ -206,7 +206,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.fk_statut > 0 "; -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; @@ -259,7 +259,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.fk_statut > 0 "; -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; @@ -313,7 +313,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.fk_statut > 0 "; - $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + $sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); $resql = $db->query($sql); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index b3936bbf1a6..c678795bf2d 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -173,7 +173,7 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; } -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index b1a86c96838..4b0a379faf3 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -203,7 +203,7 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("erd.tva_tx",$search_vat,1); } -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f67224e3996..f1f0ac4b0de 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -97,7 +97,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_ex $sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; $sql .= " WHERE er.fk_statut > 0 "; $sql .= " AND erd.fk_code_ventilation > 0 "; -$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', false) . ")"; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; $sql .= " ORDER BY er.date_debut"; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index f9cd162b6a0..e7f887547d3 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -96,7 +96,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_factu $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 "; $sql .= " AND fd.fk_code_ventilation > 0 "; -$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2)"; else diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 47a99c88496..863c68c5746 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -96,7 +96,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_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; - $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 2d36399c9b5..fdaa70e22ca 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -134,7 +134,7 @@ if ($action == 'validatehistory') { $sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; - $sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; $sql1.= ")"; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); @@ -204,7 +204,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.fk_statut > 0 "; -$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; @@ -258,7 +258,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.fk_statut > 0 "; -$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; @@ -312,7 +312,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.fk_statut > 0 "; - $sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy + $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); $resql = $db->query($sql); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 2757b6d8aec..22982a6f087 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -182,7 +182,7 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", $search_vat, 1); } -$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 9c822425a1c..30a42410d8b 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -217,7 +217,7 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx",$search_vat,1); } -$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture_fourn', false) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 92449005d1f..20f5fa671c9 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1780,7 +1780,7 @@ class Adherent extends CommonObject $sql = "SELECT count(a.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " WHERE a.statut > 0"; - $sql.= " AND a.entity IN (".getEntity('adherent', 1).")"; + $sql.= " AND a.entity IN (".getEntity('adherent').")"; $resql=$this->db->query($sql); if ($resql) @@ -1818,7 +1818,7 @@ class Adherent extends CommonObject $sql = "SELECT a.rowid, a.datefin, a.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " WHERE a.statut = 1"; - $sql.= " AND a.entity IN (".getEntity('adherent', 1).")"; + $sql.= " AND a.entity IN (".getEntity('adherent').")"; $sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')"; $resql=$this->db->query($sql); diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 97a4c8201a7..7fabd2c0ddf 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -65,7 +65,7 @@ class AdherentStats extends Stats $this->field='subscription'; $this->where.= " m.statut != 0"; - $this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent', 1).")"; + $this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; //if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if($this->memberid) { diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 3b1bda41250..3defcabd059 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -100,7 +100,7 @@ class Members extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; if (!empty($typeid)) { $sql.= ' AND t.fk_adherent_type='.$typeid; diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 18c828eb9e5..9457b910c5d 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; // Add sql filters if ($sqlfilters) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1b059d8616d..0f2cd40d076 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -210,7 +210,7 @@ if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid); if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ); if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; -$sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; +$sql.= " AND d.entity IN (".getEntity('adherent').")"; if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type); if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 55b832e327c..633c872e607 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -123,7 +123,7 @@ $sql.= " b.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql.= " WHERE d.rowid = c.fk_adherent"; -$sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; +$sql.= " AND d.entity IN (".getEntity('adherent').")"; if (isset($date_select) && $date_select != '') { $sql.= " AND c.dateadh LIKE '".$date_select."%'"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 913fcf75de6..85694a5c88b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -189,7 +189,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")"; +//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 77230dc3f68..8a57a62b144 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -639,7 +639,7 @@ if (! empty($conf->banque->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE clos = 0"; $sql.= " AND courant = 1"; - $sql.= " AND entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND entity IN (".getEntity('bank_account').")"; $resql=$db->query($sql); if ($resql) { @@ -684,7 +684,7 @@ $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE clos = 0"; $sql.= " AND courant = 1"; -$sql.= " AND entity IN (".getEntity('bank_account', 1).")"; +$sql.= " AND entity IN (".getEntity('bank_account').")"; $var=True; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index caea3bef9f7..6f060ca136f 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -80,7 +80,7 @@ $tabname[25]= MAIN_DB_PREFIX."c_email_templates"; // Requests to extract data $tabsql=array(); -$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")"; +$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; // Criteria to sort dictionaries $tabsqlsort=array(); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 47f4af17dcf..40ebcd69dc6 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -165,7 +165,7 @@ $sql.= " e.fk_user, e.description,"; $sql.= " u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; -$sql.= " WHERE e.entity IN (".getEntity('event', 1).")"; +$sql.= " WHERE e.entity IN (".getEntity('event').")"; if ($date_start > 0) $sql.= " AND e.dateevent >= '".$db->idate($date_start)."'"; if ($date_end > 0) $sql.= " AND e.dateevent <= '".$db->idate($date_end)."'"; if ($search_code) { $usefilter++; $sql.=natural_search("e.type", $search_code, 0); } diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php index e50a1a74a1b..e6b4985f6b8 100644 --- a/htdocs/asterisk/cidlookup.php +++ b/htdocs/asterisk/cidlookup.php @@ -48,7 +48,7 @@ if (empty($phone)) $sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid"; -$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; +$sql.= " WHERE s.entity IN (".getEntity('societe').")"; $sql.= " AND (s.phone='".$db->escape($phone)."'"; $sql.= " OR sp.phone='".$db->escape($phone)."'"; $sql.= " OR sp.phone_perso='".$db->escape($phone)."'"; diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 381750546ce..69a9a96f032 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -117,7 +117,7 @@ llxHeader(); $sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid"; -$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; +$sql.= " WHERE s.entity IN (".getEntity('societe').")"; $sql.= " AND (s.phone='".$db->escape($called)."'"; $sql.= " OR sp.phone='".$db->escape($called)."'"; $sql.= " OR sp.phone_perso='".$db->escape($called)."'"; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 4df9b56979d..05bd454eeea 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -63,7 +63,7 @@ function printBookmarksList($aDb, $aLangs) { $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; - $sql.= " AND entity IN (".getEntity('bookmarks',1).")"; + $sql.= " AND entity IN (".getEntity('bookmarks').")"; $sql.= " ORDER BY position"; if ($resql = $db->query($sql) ) { diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index dd722805eb6..5a7a56e333e 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -44,7 +44,7 @@ if ( GETPOST('filtre') ) { if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; @@ -96,7 +96,7 @@ if ( GETPOST('filtre') ) { if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " ORDER BY p.label"; diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index 3046644c35e..72fbd509535 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -50,7 +50,7 @@ if (dol_strlen($search) >= 0) // If search criteria is on char length at least if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; $sql.= " AND p.tosell = 1"; $sql.= " AND p.fk_product_type = 0"; // Add criteria on ref/label diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index d4bf53e01c5..96742ddfebf 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -43,7 +43,7 @@ switch($action) if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; // Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ... if ( $_POST['hdnSource'] == 'LISTE' ) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index fc7aca368f4..ed10e337f7b 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -114,7 +114,7 @@ class Categories extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('category', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('category').')'; if (!empty($type)) { $sql.= ' AND t.type='.array_search($type,Categories::$TYPES); @@ -205,7 +205,7 @@ class Categories extends DolibarrApi $sql = "SELECT s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; - $sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')'; + $sql.= ' WHERE s.entity IN ('.getEntity('category').')'; $sql.= ' AND s.type='.array_search($type,Categories::$TYPES); $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$item; diff --git a/htdocs/categories/class/api_deprecated_category.class.php b/htdocs/categories/class/api_deprecated_category.class.php index efbcac82124..392005b71fe 100644 --- a/htdocs/categories/class/api_deprecated_category.class.php +++ b/htdocs/categories/class/api_deprecated_category.class.php @@ -121,7 +121,7 @@ class CategoryApi extends DolibarrApi $sql = "SELECT s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; - $sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')'; + $sql.= ' WHERE s.entity IN ('.getEntity('category').')'; $sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES); $nbtotalofrecords = ''; @@ -201,7 +201,7 @@ class CategoryApi extends DolibarrApi $sql = "SELECT s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; - $sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')'; + $sql.= ' WHERE s.entity IN ('.getEntity('category').')'; $sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES); $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$item; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 142cc22fe75..cfe4f3ad169 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -195,7 +195,7 @@ class Categorie extends CommonObject } else { - $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category',1).")"; + $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; if ($type) $sql.= " AND type = '".$this->db->escape($type)."'"; } @@ -903,7 +903,7 @@ class Categorie extends CommonObject $sql = "SELECT fk_parent as id_parent, rowid as id_son"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity IN (".getEntity('category',1).")"; + $sql.= " AND entity IN (".getEntity('category').")"; dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1094,7 +1094,7 @@ class Categorie extends CommonObject function get_all_categories($type=null, $parent=false) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE entity IN (".getEntity('category',1).")"; + $sql.= " WHERE entity IN (".getEntity('category').")"; if (! is_null($type)) $sql.= " AND type = ".$type; if ($parent) @@ -1129,7 +1129,7 @@ class Categorie extends CommonObject { $sql = "SELECT count(rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE entity IN (".getEntity('category',1).")"; + $sql.= " WHERE entity IN (".getEntity('category').")"; $res = $this->db->query($sql); if ($res) { @@ -1155,7 +1155,7 @@ class Categorie extends CommonObject */ $sql = "SELECT c.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c "; - $sql.= " WHERE c.entity IN (".getEntity('category',1).")"; + $sql.= " WHERE c.entity IN (".getEntity('category').")"; $sql.= " AND c.type = ".$this->type; $sql.= " AND c.fk_parent = ".$this->fk_parent; $sql.= " AND c.label = '".$this->db->escape($this->label)."'"; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a9695abcb35..8243268574c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -870,7 +870,7 @@ class ActionComm extends CommonObject $sql = "SELECT a.id"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " WHERE a.entity IN (".getEntity('agenda', 1).")"; + $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid; if (! empty($elementtype)) { @@ -921,7 +921,7 @@ class ActionComm extends CommonObject if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; - $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; + $sql.= " AND a.entity IN (".getEntity('agenda').")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; @@ -1281,7 +1281,7 @@ class ActionComm extends CommonObject // We must filter on assignement table if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql.= " WHERE a.fk_action=c.id"; - $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; + $sql.= " AND a.entity IN (".getEntity('agenda').")"; foreach ($filters as $key => $value) { if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'"; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index dccd98ebe96..f32c721a826 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -112,7 +112,7 @@ class AgendaEvents extends DolibarrApi $sql = "SELECT t.id as rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('agenda', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 307d6417285..7c256e95837 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -456,7 +456,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; +$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (! empty($actioncode)) { @@ -648,7 +648,7 @@ if ($showbirthday) $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; if ($action == 'show_day') { $sql.= ' AND MONTH(birthday) = '.$month; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 6ed846c0ebe..400b882d143 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -197,7 +197,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= " WHERE c.id = a.fk_action"; -$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; +$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (! empty($actioncode)) { diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 544da904cdc..01cc4db5303 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -364,7 +364,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; +$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (! empty($actioncode)) { diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 2a707cd2d8f..e6444f26ad3 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -371,7 +371,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; +$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (! empty($actioncode)) { @@ -661,7 +661,7 @@ else $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; - $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user',1).")"; + $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; //print $sql; $resql=$db->query($sql); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 125355a3386..f6d01b18ca1 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -80,7 +80,7 @@ $sql.= " date_format(a.datep, '%Y') as year"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE a.fk_user_author = u.rowid"; -$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; +$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; //$sql.= " AND percent = 100"; $sql.= " GROUP BY year, month, df"; $sql.= " ORDER BY year DESC, month DESC, df DESC"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 7599cce4cfd..921b9eddb2f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -762,7 +762,7 @@ if ($id > 0) $sql.= ', s.rowid as socid'; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; $sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND e.entity IN (".getEntity('expedition', 1).")"; + $sql.= " AND e.entity IN (".getEntity('expedition').")"; $sql.= ' GROUP BY e.rowid'; $sql.= ', e.ref'; $sql.= ', e.date_creation'; diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index fe66e3ac243..a13ffe61c76 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -78,7 +78,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREF $sql.= " ".MAIN_DB_PREFIX."socpeople as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND p.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND p.entity IN (".getEntity('societe').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($type == "c") $sql.= " AND s.client IN (1, 3)"; if ($type == "p") $sql.= " AND s.client IN (2, 3)"; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 24bccbf9c9c..885be0dd37c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_statut = 0"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; @@ -227,7 +227,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_statut = 0"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; @@ -306,7 +306,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.fk_statut = 0"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND c.fk_soc = ".$socid; @@ -387,7 +387,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cf.fk_soc = s.rowid"; $sql.= " AND cf.fk_statut = 0"; - $sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")"; + $sql.= " AND cf.entity IN (".getEntity('supplier_order').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND cf.fk_soc = ".$socid; @@ -611,7 +611,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $sql.= ", ".MAIN_DB_PREFIX."product as p"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract', 1).")"; + $sql.= " AND c.entity IN (".getEntity('contract').")"; $sql.= " AND c.fk_product = p.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 s.rowid = ".$socid; @@ -669,7 +669,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; $sql.= " AND p.fk_statut = 1"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; @@ -766,7 +766,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; $sql.= " AND c.fk_statut = 1"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 453d1f75319..a36077f94db 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -466,7 +466,7 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere=array(); - $sqlwhere[]= 't.entity IN ('.getEntity('societe',1).')'; + $sqlwhere[]= 't.entity IN ('.getEntity('societe').')'; if (count($arrayquery)>0) { @@ -625,7 +625,7 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere=array(); - $sqlwhere[]= 't.entity IN ('.getEntity('socpeople',1).')'; + $sqlwhere[]= 't.entity IN ('.getEntity('socpeople').')'; if (count($arrayquery)>0) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index df86464281a..61fa4ee5789 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1618,7 +1618,7 @@ if ($action == 'create') $sql .= " FROM " . MAIN_DB_PREFIX . "propal p"; $sql .= ", " . MAIN_DB_PREFIX . "societe s"; $sql .= " WHERE s.rowid = p.fk_soc"; - $sql .= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; $sql .= " AND p.fk_statut <> 0"; $sql .= " ORDER BY Id"; diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 190f6cdca87..2f067f46b18 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -112,7 +112,7 @@ class Proposals 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('propal', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; 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.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 224cb77eee1..fb1ac46cd91 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1276,7 +1276,7 @@ class Propal extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid'; $sql.= " WHERE p.fk_statut = c.id"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if ($ref) $sql.= " AND p.ref='".$ref."'"; else $sql.= " AND p.rowid=".$rowid; @@ -2499,7 +2499,7 @@ class Propal extends CommonObject if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.entity IN (".getEntity('propal', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('propal').")"; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; if (! $user->rights->societe->client->voir && ! $socid) //restriction @@ -3025,7 +3025,7 @@ class Propal extends CommonObject $sql.= " WHERE sc.fk_user = " .$user->id; $clause = " AND"; } - $sql.= $clause." p.entity IN (".getEntity('propal', 1).")"; + $sql.= $clause." p.entity IN (".getEntity('propal').")"; if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED; if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED; if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id; @@ -3096,7 +3096,7 @@ class Propal extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -3194,7 +3194,7 @@ class Propal extends CommonObject $sql.= " WHERE sc.fk_user = " .$user->id; $clause = "AND"; } - $sql.= " ".$clause." p.entity IN (".getEntity('propal', 1).")"; + $sql.= " ".$clause." p.entity IN (".getEntity('propal').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index e38297a3377..39ef49991b6 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -86,7 +86,7 @@ class PropaleStats extends Stats $this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; - $this->where.= " AND p.entity IN (".getEntity('propal', 1).")"; + $this->where.= " AND p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if($this->socid) { diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 145d1891be3..a54ceb32f0b 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -81,7 +81,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; -$sql.= " AND p.entity IN (".getEntity('propal', 1).")"; +$sql.= " AND p.entity IN (".getEntity('propal').")"; if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND p.fk_statut IN (0,1,2,3,4)"; @@ -157,7 +157,7 @@ if (! empty($conf->propal->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND c.entity IN (".getEntity('propal').")"; $sql.= " AND c.fk_statut = 0"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -215,7 +215,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('propal', 1).")"; +$sql.= " AND c.entity IN (".getEntity('propal').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -294,7 +294,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; $sql.= " AND p.fk_statut = 1"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d2a6c6e926f..6f14d918f4f 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -269,7 +269,7 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE p.fk_soc = s.rowid'; -$sql.= ' AND p.entity IN ('.getEntity('propal', 1).')'; +$sql.= ' AND p.entity IN ('.getEntity('propal').')'; if (! $user->rights->societe->client->voir && ! $socid) //restriction { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 2364672ccf9..0ec6f20ae46 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -120,7 +120,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_statut = 0"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $resql=$db->query($sql); @@ -183,7 +183,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; $sql.= " AND p.fk_statut = 1"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY p.rowid DESC"; diff --git a/htdocs/commande/class/api_deprecated_commande.class.php b/htdocs/commande/class/api_deprecated_commande.class.php index c0b3a634825..11d3fe7260a 100644 --- a/htdocs/commande/class/api_deprecated_commande.class.php +++ b/htdocs/commande/class/api_deprecated_commande.class.php @@ -128,7 +128,7 @@ class CommandeApi extends DolibarrApi //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $sql.= ' WHERE s.entity IN ('.getEntity('commande', 1).')'; + $sql.= ' WHERE s.entity IN ('.getEntity('commande').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ($socid) $sql.= " AND s.fk_soc = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 1bd4e44a877..a1330a7be04 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -115,7 +115,7 @@ class Orders 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('commande', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('commande').')'; 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.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index fea30eda589..93df2f1aa0b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1564,7 +1564,7 @@ class Commande extends CommonOrder $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; - $sql.= " WHERE c.entity IN (".getEntity('commande', 1).")"; + $sql.= " WHERE c.entity IN (".getEntity('commande').")"; if ($id) $sql.= " AND c.rowid=".$id; if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; @@ -2369,7 +2369,7 @@ class Commande extends CommonOrder 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."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.entity IN (".getEntity('commande', 1).")"; + $sql.= " WHERE c.entity IN (".getEntity('commande').")"; $sql.= " AND c.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $socid) //restriction { @@ -3222,7 +3222,7 @@ class Commande extends CommonOrder $sql.= " WHERE sc.fk_user = " .$user->id; $clause = " AND"; } - $sql.= $clause." c.entity IN (".getEntity('commande', 1).")"; + $sql.= $clause." c.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0"; $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id; @@ -3506,7 +3506,7 @@ class Commande extends CommonOrder $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -3598,7 +3598,7 @@ class Commande extends CommonOrder $sql.= " WHERE sc.fk_user = " .$user->id; $clause = "AND"; } - $sql.= " ".$clause." co.entity IN (".getEntity('commande', 1).")"; + $sql.= " ".$clause." co.entity IN (".getEntity('commande').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 81488bdb1d6..b0c63625bb9 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -81,7 +81,7 @@ class CommandeStats extends Stats $this->where.= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= ' AND c.entity IN ('.getEntity('commande', 1).')'; + $this->where.= ' AND c.entity IN ('.getEntity('commande').')'; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->socid) diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 431a54b9f76..65d92f2a12c 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -75,7 +75,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (dol_strlen($stcomm)) { diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 9f7f36f78ca..fee8e5314d1 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -85,7 +85,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND c.entity IN (".getEntity('societe').")"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY c.fk_statut, c.facture"; @@ -177,7 +177,7 @@ if (! empty($conf->commande->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; $sql.= " AND c.fk_statut = 0"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -247,7 +247,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('commande', 1).")"; +$sql.= " AND c.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -328,7 +328,7 @@ if (! empty($conf->commande->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; $sql.= " AND c.fk_statut = 1"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -410,7 +410,7 @@ if (! empty($conf->commande->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; $sql.= " AND c.fk_statut = 2 "; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b9102e78ddc..daabf6357af 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -468,7 +468,7 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE c.fk_soc = s.rowid'; -$sql.= ' AND c.entity IN ('.getEntity('commande', 1).')'; +$sql.= ' AND c.entity IN ('.getEntity('commande').')'; if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index b05b6658ca7..9c79b030456 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -549,7 +549,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ' WHERE c.entity IN ('.getEntity('commande', 1).')'; + $sql.= ' WHERE c.entity IN ('.getEntity('commande').')'; $sql.= ' AND c.fk_soc = s.rowid'; // Show orders with status validated, shipping started and delivered (well any order we can bill) diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index cb10fd8c3c7..eb14db2d3ac 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -90,7 +90,7 @@ $sql.= ", date_format(b.dateo,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; +$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.amount >= 0"; if (! empty($id)) $sql .= " AND b.fk_account IN (".$db->escape($id).")"; @@ -118,7 +118,7 @@ $sql.= ", date_format(b.dateo,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; +$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.amount <= 0"; if (! empty($id)) $sql .= " AND b.fk_account IN (".$db->escape($id).")"; @@ -250,7 +250,7 @@ $sql = "SELECT SUM(b.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; +$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if (! empty($id)) $sql.= " AND b.fk_account IN (".$db->escape($id).")"; @@ -290,7 +290,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; $resql = $db->query($sql); @@ -321,7 +321,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'"; $sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'"; $sql.= " AND b.amount > 0"; @@ -410,7 +410,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'"; $sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'"; $sql.= " AND b.amount < 0"; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index f98c48b1aba..da89c662438 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -463,7 +463,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; +$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($account > 0) $sql.=" AND b.fk_account = ".$account; // Search period criteria if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; @@ -861,7 +861,7 @@ if ($resql) $sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b"; $sqlforbalance.= " WHERE b.fk_account = ba.rowid"; - $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")"; $sqlforbalance.= " AND b.fk_account = ".$account; $sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'"; $resqlforbalance = $db->query($sqlforbalance); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b77ed4db1a5..b544c99dd4c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1167,7 +1167,7 @@ class Account extends CommonObject $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.rappro=0"; $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable $sql.= " AND clos = 0"; if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; @@ -1224,7 +1224,7 @@ class Account extends CommonObject $sql = "SELECT COUNT(ba.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; $resql=$db->query($sql); if ($resql) @@ -1615,7 +1615,7 @@ class AccountLine extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'"; else if ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'"; else $sql.= " AND b.rowid=".$rowid; diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 98ee2672d3b..869b86238ff 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -70,7 +70,7 @@ class BankAccounts extends DolibarrApi } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('bank_account', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('bank_account').')'; // Add sql filters if ($sqlfilters) { diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 91b6cb38ec2..12cfeda7b15 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -92,7 +92,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); @@ -133,7 +133,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; @@ -164,7 +164,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev < '".$year."-".sprintf("%02s",$month)."-01'"; if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; @@ -276,7 +276,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; @@ -307,7 +307,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev < '".$year."-01-01'"; if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; @@ -415,7 +415,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; $sql.= " GROUP BY date_format(b.datev,'%Y%m%d')"; @@ -538,7 +538,7 @@ else $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; $sql.= " AND b.amount > 0"; @@ -576,7 +576,7 @@ else $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; $sql.= " AND b.amount < 0"; @@ -656,7 +656,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; $sql.= " AND b.amount > 0"; @@ -685,7 +685,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; $sql.= " AND b.amount < 0"; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 8ff5f1964fc..b3e07d81b36 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -152,7 +152,7 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // N $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)"; -$sql.= " WHERE entity IN (".getEntity('bank_account', 1).")"; +$sql.= " WHERE entity IN (".getEntity('bank_account').")"; if ($statut == 'opened') $sql.= " AND clos = 0"; if ($statut == 'closed') $sql.= " AND clos = 1"; if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref); diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index a690478a53e..52864e52627 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -476,7 +476,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE s.entity IN (".getEntity('user',1).")"; + $sql.= " WHERE s.entity IN (".getEntity('user').")"; $sql.= " AND u.rowid = s.fk_user"; if ($year > 0) { diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index 59fb3af2f00..c305603c82c 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -93,7 +93,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (dol_strlen($stcomm)) { diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index fa8911cecf7..2cfed45c9d4 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -223,7 +223,7 @@ class Deplacement extends CommonObject { $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement"; - $sql.= " WHERE entity IN (".getEntity('deplacement').")"; + $sql.= " WHERE entity IN (".getEntity('deplacement', false)")"; if ($ref) $sql.= " AND ref ='".$this->db->escape($ref)."'"; else $sql.= " AND rowid = ".$id; diff --git a/htdocs/compta/facture/class/api_deprecated_invoice.class.php b/htdocs/compta/facture/class/api_deprecated_invoice.class.php index 36aa232de9e..360c065a5f2 100644 --- a/htdocs/compta/facture/class/api_deprecated_invoice.class.php +++ b/htdocs/compta/facture/class/api_deprecated_invoice.class.php @@ -120,7 +120,7 @@ class InvoiceApi extends DolibarrApi if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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 s.entity IN ('.getEntity('facture', 1).')'; + $sql.= ' WHERE s.entity IN ('.getEntity('facture').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ($socid) $sql.= " AND s.fk_soc = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e2842df0530..55304136ed6 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -112,7 +112,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', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('facture').')'; 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 927be3fa25e..6bc88e47490 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -955,7 +955,7 @@ class FactureRec extends CommonInvoice $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e46b5718d22..36d59c36c9a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3756,7 +3756,7 @@ class Facture extends CommonInvoice $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -3964,7 +3964,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').")"; + $sql.= " WHERE f.entity in (".getEntity('facture', false)")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1ab17765d8f..d772d53aba7 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -384,7 +384,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', 1).')'; +$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 ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index eed3a79335c..b5767a6f0bc 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -416,7 +416,7 @@ if ($action == 'new') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)"; $sql.= " WHERE b.fk_type = 'CHQ'"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.fk_bordereau = 0"; $sql.= " AND b.amount > 0"; if ($filterdate) $sql.=" AND b.dateo = '".$db->idate($filterdate)."'"; @@ -656,7 +656,7 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; - $sql.= " WHERE ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " WHERE ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.fk_type= 'CHQ'"; $sql.= " AND b.fk_bordereau = ".$object->id; $sql.= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 4889693857b..20afa14e0ca 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -496,7 +496,7 @@ class RemiseCheque extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.fk_type = 'CHQ'"; $sql.= " AND b.fk_bordereau = 0"; $sql.= " AND b.amount > 0"; diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 97dc3c1674f..e9f887e37f4 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -56,7 +56,7 @@ $sql = "SELECT count(b.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE ba.rowid = b.fk_account"; -$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; +$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND b.fk_type = 'CHQ'"; $sql.= " AND b.fk_bordereau = 0"; $sql.= " AND b.amount > 0"; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 1b5a232b812..4fa13f3e842 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -263,7 +263,7 @@ if ($modecompta != 'CREANCES-DETTES') $sql.= " WHERE pf.rowid IS NULL"; $sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY name, idp"; @@ -654,7 +654,7 @@ if (! empty($conf->expensereport->enabled)) $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; - $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; $column='p.date_valid'; @@ -664,7 +664,7 @@ if (! empty($conf->expensereport->enabled)) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; - $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; $column='pe.datep'; @@ -745,7 +745,7 @@ if (! empty($conf->don->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; - $sql.= " WHERE p.entity = ".getEntity('donation',1); + $sql.= " WHERE p.entity = ".getEntity('donation'); $sql.= " AND fk_statut >= 2"; } if (! empty($date_start) && ! empty($date_end)) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index fe64bb7b999..45cbbfe3a46 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -164,7 +164,7 @@ if ($modecompta != 'CREANCES-DETTES') $sql.= " WHERE pf.rowid IS NULL"; $sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -536,7 +536,7 @@ if (! empty($conf->expensereport->enabled)) $sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; - $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; $column='p.date_valid'; @@ -547,7 +547,7 @@ if (! empty($conf->expensereport->enabled)) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; - $sql.= " WHERE p.entity = ".getEntity('expensereport',1); + $sql.= " WHERE p.entity = ".getEntity('expensereport'); $sql.= " AND p.fk_statut>=5"; $column='pe.datep'; @@ -600,7 +600,7 @@ if (! empty($conf->don->enabled)) $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; - $sql.= " WHERE p.entity = ".getEntity('donation',1); + $sql.= " WHERE p.entity = ".getEntity('donation'); $sql.= " AND fk_statut >= 2"; } $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index ae7240c204a..824185c52aa 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -413,7 +413,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE s.entity IN (".getEntity('user',1).")"; + $sql.= " WHERE s.entity IN (".getEntity('user').")"; $sql.= " AND u.rowid = s.fk_user"; if ($year > 0) { diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index fff94c898c2..ad9a8fbd346 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -237,7 +237,7 @@ if ($modecompta != 'CREANCES-DETTES') { $sql.= " WHERE pf.rowid IS NULL"; $sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($date_start && $date_end) { $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 548809f4317..b9fcf6b7aa3 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -306,7 +306,7 @@ if ($modecompta != 'CREANCES-DETTES') { $sql.= " WHERE pf.rowid IS NULL"; $sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY socid, name"; $sql.= " ORDER BY name"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 2bb9a7d50a0..19c106a44dc 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -151,7 +151,7 @@ if ($modecompta != 'CREANCES-DETTES') $sql.= " WHERE pf.rowid IS NULL"; $sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9bcfee7ccae..2d46b91f922 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -247,7 +247,7 @@ if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= ' WHERE p.entity IN ('.getEntity('societe', 1).')'; +$sql.= ' WHERE p.entity IN ('.getEntity('societe').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index db6464edb6a..762a22889c6 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -504,7 +504,7 @@ class Contrat extends CommonObject if ($ref) { $sql.= " WHERE ref='".$this->db->escape($ref)."'"; - $sql.= " AND entity IN (".getEntity('contract').")"; + $sql.= " AND entity IN (".getEntity('contract', false)")"; } else $sql.= " WHERE rowid=".$id; @@ -2180,7 +2180,7 @@ class Contrat extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $sql.= " AND tosell = 1"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 924958319a4..3cff590bc4b 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -107,7 +107,7 @@ $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; $sql.= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))"; -$sql.= " AND c.entity IN (".getEntity('contract').")"; +$sql.= " AND c.entity IN (".getEntity('contract', false)")"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY cd.statut"; @@ -144,7 +144,7 @@ $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; $sql.= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')"; -$sql.= " AND c.entity IN (".getEntity('contract').")"; +$sql.= " AND c.entity IN (".getEntity('contract', false)")"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY cd.statut"; @@ -230,7 +230,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".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 = c.fk_soc"; - $sql.= " AND c.entity IN (".getEntity('contract').")"; + $sql.= " AND c.entity IN (".getEntity('contract', false)")"; $sql.= " AND c.statut = 0"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND c.fk_soc = ".$socid; @@ -302,7 +302,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= " ".MAIN_DB_PREFIX. $sql.= " ".MAIN_DB_PREFIX."contrat as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('contract').")"; +$sql.= " AND c.entity IN (".getEntity('contract', false)")"; $sql.= " AND c.statut > 0"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; @@ -372,7 +372,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."contratdet as cd"; $sql.= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE c.entity IN (".getEntity('contract').")"; +$sql.= " WHERE c.entity IN (".getEntity('contract', false)")"; $sql.= " AND cd.fk_contrat = c.rowid"; $sql.= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -450,7 +450,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."contratdet as cd"; $sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE c.entity IN (".getEntity('contract').")"; +$sql.= " WHERE c.entity IN (".getEntity('contract', false)")"; $sql.= " AND c.statut = 1"; $sql.= " AND cd.statut = 0"; $sql.= " AND cd.fk_contrat = c.rowid"; @@ -529,7 +529,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."contratdet as cd"; $sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -$sql.= " WHERE c.entity IN (".getEntity('contract').")"; +$sql.= " WHERE c.entity IN (".getEntity('contract', false)")"; $sql.= " AND c.statut = 1"; $sql.= " AND cd.statut = 4"; $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 43cce90bd1c..e0711f63704 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -222,7 +222,7 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= " WHERE c.fk_soc = s.rowid "; -$sql.= ' AND c.entity IN ('.getEntity('contract', 1).')'; +$sql.= ' AND c.entity IN ('.getEntity('contract').')'; if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid); if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 0649d43a049..51e4a22d756 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -90,7 +90,7 @@ class box_clients extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 3)"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; 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.= " ORDER BY s.tms DESC"; diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index d6c38a9fce8..c6aaf1ec24a 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -69,7 +69,7 @@ class box_contacts extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; $sql.= " ORDER BY sp.tms DESC"; diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 432d34897d0..530a99c8224 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -71,7 +71,7 @@ class box_fournisseurs extends ModeleBoxes $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; 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.= " ORDER BY s.tms DESC "; diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 73208b1423a..6c19b46e468 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -86,7 +86,7 @@ class box_goodcustomers extends ModeleBoxes $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1','1','0').") as nbfactpaye"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; + $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql.= ' AND s.rowid = f.fk_soc'; $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; $sql.= $db->order("nbfact","DESC"); diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 4c4e8085592..80c7b24249b 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -90,7 +90,7 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc"; - $sql.= " WHERE p.entity IN (".getEntity('project',1).')'; + $sql.= " WHERE p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts @@ -130,7 +130,7 @@ class box_project extends ModeleBoxes $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project',1).')'; + $sql.= " WHERE p.entity IN (".getEntity('project').')'; $sql.=" AND p.rowid = ".$objp->rowid; $resultTask = $db->query($sql); if ($resultTask) { diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 1acd77addfc..abc99246c4a 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -90,7 +90,7 @@ class box_prospect extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (2, 3)"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; 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.= " ORDER BY s.tms DESC"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fe93387cadb..01ffb706586 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -959,7 +959,7 @@ abstract class CommonObject $sql.= " WHERE ec.element_id = ".$id; $sql.= " AND ec.fk_socpeople = c.rowid"; if ($source == 'internal') $sql.= " AND c.entity IN (0,".$conf->entity.")"; - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe', 1).")"; + if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$element."'"; $sql.= " AND tc.source = '".$source."'"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cf6ae18f568..b72a451a41c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1042,7 +1042,7 @@ class Form $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id; if ($filter) $sql.= " AND (".$filter.")"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -1282,7 +1282,7 @@ class Form if ($showsoc > 0) $sql.= " , s.nom as company"; $sql.= " FROM ".MAIN_DB_PREFIX ."socpeople as sp"; if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid; if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0"; $sql.= " ORDER BY sp.lastname ASC"; @@ -1905,7 +1905,7 @@ class Form $sql .= " LEFT JOIN llx_product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if (count($warehouseStatusArray)) { $sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.implode(',',$warehouseStatusArray).'))'; @@ -2140,7 +2140,7 @@ class Form $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; $sql.= " WHERE fk_product='".$objp->rowid."'"; - $sql.= " AND entity IN (".getEntity('productprice', 1).")"; + $sql.= " AND entity IN (".getEntity('productprice').")"; $sql.= " AND price_level=".$price_level; $sql.= " ORDER BY date_price DESC, rowid DESC"; // Warning DESC must be both on date_price and rowid. $sql.= " LIMIT 1"; @@ -2364,7 +2364,7 @@ class Form $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; $sql.= " AND p.tobuy = 1"; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$this->db->escape($filtertype); if (! empty($filtre)) $sql.=" ".$filtre; @@ -2574,7 +2574,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('productprice', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('productprice').")"; $sql.= " AND p.tobuy = 1"; $sql.= " AND s.fournisseur = 1"; $sql.= " AND p.rowid = ".$productid; @@ -3316,7 +3316,7 @@ class Form $sql = "SELECT rowid, label, bank, clos as status"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity IN (".getEntity('bank_account', 1).")"; + $sql.= " WHERE entity IN (".getEntity('bank_account').")"; if ($statut != 2) $sql.= " AND clos = '".$statut."'"; if ($filtre) $sql.=" AND ".$filtre; $sql.= " ORDER BY label"; @@ -4352,7 +4352,7 @@ class Form $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; - $sql.= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; + $sql.= " WHERE entity IN ('".getEntity('mutlicurrency', false)"')"; $resql = $db->query($sql); if ($resql) { @@ -5596,14 +5596,14 @@ class Form if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent; $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',1).')'), - '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',1).')'), - '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',1).')'), - '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',1).')'), - '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',1).')'), - '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',1).')'), - 'order_supplier'=>array('enabled'=>$conf->fournisseur->commande->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur',1).')'), - 'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn',1).')') + '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').')'), + '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').')'), + 'order_supplier'=>array('enabled'=>$conf->fournisseur->commande->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')') ); } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index f3db5777783..2d444c1aefe 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -221,7 +221,7 @@ class FormAccounting extends Form $options = array(); $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; $sql .= ' ORDER BY import_key DESC'; dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG); @@ -344,7 +344,7 @@ class FormAccounting extends Form // Auxiliary customer account $sql = "SELECT DISTINCT code_compta, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('societe') . ")"; $sql .= " ORDER BY code_compta"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -364,7 +364,7 @@ class FormAccounting extends Form // Auxiliary supplier account $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('societe') . ")"; $sql .= " ORDER BY code_compta_fournisseur"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -405,7 +405,7 @@ class FormAccounting extends Form $sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY date_format(doc_date,'%Y')"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index bcff0981a70..3ab47e1994b 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -629,7 +629,7 @@ class FormCompany // Search to list thirdparties $sql = "SELECT s.rowid, s.nom as name FROM"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; // For ajax search we limit here. For combo list, we limit later if (is_array($limitto) && count($limitto)) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3641ac87cef..feac8b20cec 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -843,7 +843,7 @@ class FormMail extends Form $sql = "SELECT label, topic, content, content_lines, lang"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$db->escape($type_template)."'"; - $sql.= " AND entity IN (".getEntity("c_email_templates").")"; + $sql.= " AND entity IN (".getEntity('c_email_templates', false)")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if ($active >= 0) $sql.=" AND active = ".$active; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; @@ -910,7 +910,7 @@ class FormMail extends Form $sql = "SELECT label, topic, content, lang"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; - $sql.= " AND entity IN (".getEntity("c_email_templates").")"; + $sql.= " AND entity IN (".getEntity('c_email_templates', false)")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; $sql.= $this->db->order("lang,label","ASC"); @@ -947,7 +947,7 @@ class FormMail extends Form $sql = "SELECT rowid, label, topic, content, content_lines, lang, position"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; - $sql.= " AND entity IN (".getEntity("c_email_templates").")"; + $sql.= " AND entity IN (".getEntity('c_email_templates', false)")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if ($active >= 0) $sql.=" AND active = ".$active; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 30481497163..119787874ea 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -153,7 +153,7 @@ class FormProjets // Search all projects $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias'; $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p LEFT JOIN '.MAIN_DB_PREFIX .'societe as s ON s.rowid = p.fk_soc'; - $sql.= " WHERE p.entity IN (".getEntity('project', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid > 0) @@ -526,7 +526,7 @@ class FormProjets if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid; else $sql.= " AND t.fk_soc IN (".$socid.")"; } - if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project',1).')'; + if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project').')'; if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc"; if ($sqlfilter) $sql.= " AND ".$sqlfilter; $sql.= " ORDER BY ref DESC"; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 1205f0c5c63..6f2f9e56d61 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -147,7 +147,7 @@ class Notify if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage else $sql.= " AND a.code = '".$notifcode."'"; // New usage } - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; if ($socid > 0) $sql.= " AND s.rowid = ".$socid; dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); @@ -192,7 +192,7 @@ class Notify if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage else $sql.= " AND a.code = '".$notifcode."'"; // New usage } - $sql.= " AND c.entity IN (".getEntity('user', 1).")"; + $sql.= " AND c.entity IN (".getEntity('user').")"; if ($userid > 0) $sql.= " AND c.rowid = ".$userid; dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3c37a18ab27..0a41969afd3 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1065,7 +1065,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if (get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; $sql.= " WHERE u.rowid = a.fk_user_action"; - $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; + $sql.= " AND a.entity IN (".getEntity('agenda').")"; if (get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; if (get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; if (get_class($filterobj) == 'Adherent') @@ -1478,7 +1478,7 @@ function show_subsidiaries($conf,$langs,$db,$object) $sql = "SELECT s.rowid, s.nom as name, s.address, s.zip, s.town, s.code_client, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE s.parent = ".$object->id; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; $sql.= " ORDER BY s.nom"; $result = $db->query($sql); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index ad800708522..82f399417ba 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1946,7 +1946,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed=1; } $original_file=$conf->societe->multidir_output[$entity].'/'.$original_file; - $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$db->escape($refname)."' AND entity IN (".getEntity('societe', 1).")"; + $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$db->escape($refname)."' AND entity IN (".getEntity('societe').")"; } // Wrapping for contact @@ -2087,7 +2087,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed=1; } $original_file=$conf->projet->dir_output.'/'.$original_file; - $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project', 1).")"; + $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; } else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output)) { @@ -2096,7 +2096,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed=1; } $original_file=$conf->projet->dir_output.'/'.$original_file; - $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project', 1).")"; + $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; } // Wrapping pour les commandes fournisseurs @@ -2210,7 +2210,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed=1; } $original_file=$conf->contrat->dir_output.'/'.$original_file; - $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract', 1).")"; + $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")"; } // Wrapping pour les dons diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 041235f40f6..97070483aaf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -110,10 +110,10 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', * 'email_template', 'event', - * @param int $shared 0=Return id of entity, 1=Return id entity + shared entities + * @param int $shared true=Return id entity + shared entities (by default), false=Return id of current entity or referent entity if current element is "societe" * @return mixed Entity id(s) to use */ -function getEntity($element=false, $shared=0) +function getEntity($element=false, $shared=true) { global $conf, $mc; diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 3455979afbe..78de61a729f 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -184,7 +184,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='') //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; //TODO Add link to expeditiondet_batch - $sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; + $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; $sql.= " AND obj.fk_".$origin." = ".$origin_id; $sql.= " AND obj.rowid = ed.fk_origin_line"; $sql.= " AND ed.fk_expedition = e.rowid"; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 578ed1a16ff..15d3ce53fa8 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -153,7 +153,7 @@ 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('facture', 1).")"; + $sql.= " AND entity IN (".getEntity('facture').")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -177,7 +177,7 @@ 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('facture', 1).")"; + $sql.= " AND entity IN (".getEntity('facture').")"; 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 c0497f5fb5c..b2a2f22cd12 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -169,7 +169,7 @@ 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('facture', 1).")"; + $sql.= " AND entity IN (".getEntity('facture').")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -193,7 +193,7 @@ 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('facture', 1).")"; + $sql.= " AND entity IN (".getEntity('facture').")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 737b239498f..497d3c54f54 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -71,7 +71,7 @@ class mailing_advthirdparties extends MailingTargets { $sql= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; $sql.= " AND s.rowid IN (".implode(',',$socid).")"; $sql.= " ORDER BY email"; @@ -122,7 +122,7 @@ class mailing_advthirdparties extends MailingTargets { $sql= "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as socp"; - $sql.= " WHERE socp.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE socp.entity IN (".getEntity('societe').")"; if (count($contactid)>0) { $sql.= " AND socp.rowid IN (".implode(',',$contactid).")"; } @@ -211,7 +211,7 @@ class mailing_advthirdparties extends MailingTargets $sql = "SELECT count(distinct(s.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE s.email != ''"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 02bcc17ec30..0e4966a5ada 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -72,7 +72,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0] = "SELECT '".$langs->trans("NbOfCompaniesContacts")."' as label,"; $statssql[0].= " count(distinct(c.email)) as nb"; $statssql[0].= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $statssql[0].= " WHERE c.entity IN (".getEntity('societe', 1).")"; + $statssql[0].= " WHERE c.entity IN (".getEntity('societe').")"; $statssql[0].= " AND c.email != ''"; // Note that null != '' is false $statssql[0].= " AND c.no_email = 0"; $statssql[0].= " AND c.statut = 1"; @@ -96,7 +96,7 @@ class mailing_contacts1 extends MailingTargets $sql = "SELECT count(distinct(c.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - $sql.= " WHERE c.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE c.entity IN (".getEntity('societe').")"; $sql.= " AND c.email != ''"; // Note that null != '' is false $sql.= " AND c.no_email = 0"; $sql.= " AND c.statut = 1"; @@ -203,7 +203,7 @@ class mailing_contacts1 extends MailingTargets $sql.= " s.nom as companyname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - $sql.= " WHERE c.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE c.entity IN (".getEntity('societe').")"; $sql.= " AND c.email <> ''"; $sql.= " AND c.no_email = 0"; $sql.= " AND c.statut = 1"; diff --git a/htdocs/core/modules/mailings/contacts2.modules.php b/htdocs/core/modules/mailings/contacts2.modules.php index 778b2182e1a..a9c05434cd3 100644 --- a/htdocs/core/modules/mailings/contacts2.modules.php +++ b/htdocs/core/modules/mailings/contacts2.modules.php @@ -83,7 +83,7 @@ class mailing_contacts2 extends MailingTargets $sql.= " s.nom as companyname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; $sql.= " AND sp.email <> ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; @@ -140,7 +140,7 @@ class mailing_contacts2 extends MailingTargets $statssql[$i].= " WHERE s.rowid = sp.fk_soc"; $statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false $statssql[$i].= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; - $statssql[$i].= " AND sp.entity IN (".getEntity('societe', 1).")"; + $statssql[$i].= " AND sp.entity IN (".getEntity('societe').")"; $statssql[$i].= " GROUP BY label"; $statssql[$i].= " ORDER BY nb DESC"; $statssql[$i].= " LIMIT $i,1"; @@ -166,7 +166,7 @@ class mailing_contacts2 extends MailingTargets $sql = "SELECT count(distinct(sp.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; @@ -190,7 +190,7 @@ class mailing_contacts2 extends MailingTargets $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; diff --git a/htdocs/core/modules/mailings/contacts3.modules.php b/htdocs/core/modules/mailings/contacts3.modules.php index 2c142541023..c16f6869668 100644 --- a/htdocs/core/modules/mailings/contacts3.modules.php +++ b/htdocs/core/modules/mailings/contacts3.modules.php @@ -86,7 +86,7 @@ class mailing_contacts3 extends MailingTargets $sql.= " WHERE sp.email <> ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; $sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_categorie = c.rowid"; if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_soc = sp.fk_soc"; @@ -143,7 +143,7 @@ class mailing_contacts3 extends MailingTargets $statssql[$i].= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $statssql[$i].= " WHERE s.rowid = sp.fk_soc"; $statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false - $statssql[$i].= " AND sp.entity IN (".getEntity('societe', 1).")"; + $statssql[$i].= " AND sp.entity IN (".getEntity('societe').")"; $statssql[$i].= " AND cs.fk_categorie = c.rowid"; $statssql[$i].= " AND cs.fk_soc = sp.fk_soc"; $statssql[$i].= " GROUP BY c.label"; @@ -171,7 +171,7 @@ class mailing_contacts3 extends MailingTargets $sql = "SELECT count(distinct(c.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - $sql.= " WHERE c.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE c.entity IN (".getEntity('societe').")"; $sql.= " AND c.email != ''"; // Note that null != '' is false $sql.= " AND c.no_email = 0"; $sql.= " AND c.statut = 1"; @@ -182,7 +182,7 @@ class mailing_contacts3 extends MailingTargets $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " WHERE s.rowid = sp.fk_soc"; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_soc = sp.fk_soc"; @@ -211,7 +211,7 @@ class mailing_contacts3 extends MailingTargets $sql.= " WHERE sp.email != ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_soc = sp.fk_soc"; $sql.= " GROUP BY c.label"; diff --git a/htdocs/core/modules/mailings/contacts4.modules.php b/htdocs/core/modules/mailings/contacts4.modules.php index a79d48a03e4..f4c67874bfb 100644 --- a/htdocs/core/modules/mailings/contacts4.modules.php +++ b/htdocs/core/modules/mailings/contacts4.modules.php @@ -86,7 +86,7 @@ class mailing_contacts4 extends MailingTargets $sql.= " WHERE sp.email != ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; if ($filtersarray[0] <> 'all') $sql.= " AND c.label = '".$this->db->escape($filtersarray[0])."'"; $sql.= " ORDER BY sp.lastname, sp.firstname"; @@ -144,7 +144,7 @@ class mailing_contacts4 extends MailingTargets $statssql[$i].= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $statssql[$i].= " WHERE s.rowid = sp.fk_soc"; $statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false - $statssql[$i].= " AND sp.entity IN (".getEntity('societe', 1).")"; + $statssql[$i].= " AND sp.entity IN (".getEntity('societe').")"; $statssql[$i].= " AND cs.fk_categorie = c.rowid"; $statssql[$i].= " AND cs.fk_soc = sp.fk_soc"; $statssql[$i].= " GROUP BY c.label"; @@ -171,7 +171,7 @@ class mailing_contacts4 extends MailingTargets // If we want a filter "is inside at least one category", we must add it into formFilter $sql = "SELECT count(distinct(c.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql.= " WHERE c.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE c.entity IN (".getEntity('societe').")"; $sql.= " AND c.email != ''"; // Note that null != '' is false $sql.= " AND c.no_email = 0"; $sql.= " AND c.statut = 1"; @@ -182,7 +182,7 @@ class mailing_contacts4 extends MailingTargets $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " WHERE s.rowid = sp.fk_soc"; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_soc = sp.fk_soc"; @@ -211,7 +211,7 @@ class mailing_contacts4 extends MailingTargets $sql.= " WHERE sp.email != ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND sp.entity IN (".getEntity('societe').")"; $sql.= " GROUP BY c.label"; $sql.= " ORDER BY c.label"; diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 2f9be84aab4..e1d3cd5861c 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -65,7 +65,7 @@ class mailing_thirdparties extends MailingTargets $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, null as label"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE s.email <> ''"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; } else @@ -73,7 +73,7 @@ class mailing_thirdparties extends MailingTargets $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c"; $sql.= " WHERE s.email <> ''"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; $sql.= " AND cs.fk_soc = s.rowid"; $sql.= " AND c.rowid = cs.fk_categorie"; @@ -82,7 +82,7 @@ class mailing_thirdparties extends MailingTargets $sql.= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_fournisseur as cs, ".MAIN_DB_PREFIX."categorie as c"; $sql.= " WHERE s.email <> ''"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; $sql.= " AND cs.fk_soc = s.rowid"; $sql.= " AND c.rowid = cs.fk_categorie"; @@ -167,7 +167,7 @@ class mailing_thirdparties extends MailingTargets $sql = "SELECT count(distinct(s.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE s.email != ''"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 21a37301e38..786cfa1f756 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -48,7 +48,7 @@ class mailing_thirdparties_services_expired extends MailingTargets // List of services $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $sql.= " AND fk_product_type = 1"; // By default, only services $sql.= " ORDER BY ref"; $result=$this->db->query($sql); @@ -102,7 +102,7 @@ class mailing_thirdparties_services_expired extends MailingTargets $sql = "SELECT s.rowid as id, s.email, s.nom as name, cd.rowid as cdid, cd.date_ouverture, cd.date_fin_validite, cd.fk_contrat"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; $sql.= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; $sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid AND p.ref = '".$product."'"; @@ -192,7 +192,7 @@ class mailing_thirdparties_services_expired extends MailingTargets $sql = "SELECT count(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; $sql.= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; $sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid"; $sql.= " AND p.ref IN ('".join("','",$this->arrayofproducts)."')"; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 9204cd02aa0..1780da06456 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -295,7 +295,7 @@ class modAccounting extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'accounting_account as aa, '.MAIN_DB_PREFIX.'accounting_system as ac'; - $this->export_sql_end[$r] .=' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting', 1).') '; + $this->export_sql_end[$r] .=' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').') '; } } diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index b75d674b41f..041892c35ee 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -290,7 +290,7 @@ class modAdherent extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; - $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('adherent', 1).') '; + $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('adherent').') '; $this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them // Imports diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 339a208fc31..7513b489195 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -401,7 +401,7 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid'; if (! empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid'; - $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')'; + $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); $this->export_sql_end[$r] .=' ORDER BY ac.datep'; diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index a868bfd2f08..c9fde5f0087 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -162,7 +162,7 @@ class modBanque extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account'; - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account',1).')'; + $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; $r++; @@ -189,7 +189,7 @@ class modBanque extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'"; $this->export_sql_end[$r] .=' AND p.fk_paiement = 7'; - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account',1).')'; + $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account').')'; $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index edda1043d71..b56d405c354 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -129,7 +129,7 @@ class modCategorie extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_fournisseur as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')'; + $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .=' AND u.type = 1'; // Supplier categories $r++; @@ -144,7 +144,7 @@ class modCategorie extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object '; $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')'; + $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories // Add extra fields @@ -201,7 +201,7 @@ class modCategorie extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')'; + $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .=' AND u.type = 0'; // Supplier categories $r++; @@ -216,7 +216,7 @@ class modCategorie extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')'; + $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .=' AND u.type = 3'; // Member categories $r++; @@ -352,7 +352,7 @@ class modCategorie extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; - $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories // Imports diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 1806bfdea71..e80833ae7c4 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -217,7 +217,7 @@ class modCommande extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.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 c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande',1).')'; + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.(empty($user)?0:$user->id); } diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 52127c4e6f4..1b17b773c77 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -200,7 +200,7 @@ class modContrat extends DolibarrModules $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contratdet as cod'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat'; - $this->export_sql_end[$r] .=' AND co.entity IN ('.getEntity('contract',1).')'; + $this->export_sql_end[$r] .=' AND co.entity IN ('.getEntity('contract').')'; } diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index 9563e11aaa2..ec8d665b1e0 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -132,7 +132,7 @@ class modDeplacement extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; - $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement',1).')'; + $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; if (! empty($user)) // Not defined during migration process diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 7320eba6736..94c86e6e3b1 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -277,7 +277,7 @@ class modExpedition extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition',1).')'; + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; } diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 0d9b808fb6a..cbaf141809f 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -186,7 +186,7 @@ class modExpenseReport extends DolibarrModules $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid'; $this->export_sql_end[$r] .=' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid'; - $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('expensereport',1).')'; + $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('expensereport').')'; } /** diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index b16c7749e40..3af85a1944d 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -241,7 +241,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',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture').')'; if(isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; $r++; @@ -271,7 +271,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',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture').')'; 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/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 55deaf2403f..0d9f73b76e4 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -172,7 +172,7 @@ class modFicheinter extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention').')'; $r++; } diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index fc2572d3669..233b1601842 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -380,7 +380,7 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; $r++; @@ -443,7 +443,7 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; // Order @@ -552,7 +552,7 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; } diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 30e64b5de2c..dae39fc00d4 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -187,7 +187,7 @@ class modProduct extends DolibarrModules if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity("product", 1).')'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -215,7 +215,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity("product", 1).')'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; } if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) @@ -244,7 +244,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity("product", 1).')'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 96e5a96b384..071912e1c00 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -231,7 +231,7 @@ class modProjet extends DolibarrModules // Add multicompany field if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { - $nbofallowedentities=count(explode(',',getEntity('project',1))); // If project are shared, nb will be > 1 + $nbofallowedentities=count(explode(',',getEntity('project'))); // If project are shared, nb will be > 1 if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity'); } if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 3dd39b336bc..43ba37aa26e 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -209,7 +209,7 @@ class modPropale extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.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 c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal',1).')'; + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal').')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; } diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 020fa92e9f3..7ab7afc1e4b 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -271,7 +271,7 @@ class modResource extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; - $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource',1).')'; + $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource').')'; // Imports diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index d5e982bcccc..bf37a7e73d8 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -158,7 +158,7 @@ class modSalaries extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user',1).')'; + $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')'; } diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index c385ece4b26..f9c6a608085 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -194,7 +194,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity("product", 1).')'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) @@ -222,7 +222,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity("product", 1).')'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; } } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index a2239514898..c4c93537444 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -263,7 +263,7 @@ class modSociete extends DolibarrModules // Add multicompany field if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { - $nbofallowedentities=count(explode(',',getEntity('societe',1))); // If project are shared, nb will be > 1 + $nbofallowedentities=count(explode(',',getEntity('societe'))); // If project are shared, nb will be > 1 if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); } $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra'; @@ -286,7 +286,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; - $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; + $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { @@ -323,7 +323,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; - $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; + $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('societe').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index be6817062b6..8362343f8cb 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -176,7 +176,7 @@ class modStock extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e'; $this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid'; - $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock',1).')'; + $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')'; if ($conf->productbatch->enabled) { @@ -196,7 +196,7 @@ class modStock extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e, '.MAIN_DB_PREFIX.'product_batch as pb'; $this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock'; - $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock',1).')'; + $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock').')'; } // Imports diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index bb8f31e466d..8dfc7283b90 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -139,7 +139,7 @@ class modTax extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax',1).')'; + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax').')'; // Import social contributions $r++; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 55d4d45d28e..1bd4281b507 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -229,7 +229,7 @@ class modUser extends DolibarrModules } $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; - $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user',1).')'; + $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')'; // Imports //-------- diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 88ec1a6e8db..e942e747794 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -123,7 +123,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; - $sql.= " AND entity IN (".getEntity('societe', 1).")"; + $sql.= " AND entity IN (".getEntity('societe').")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -224,7 +224,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE code_client = '".$code."'"; - $sql.= " AND entity IN (".getEntity('societe', 1).")"; + $sql.= " AND entity IN (".getEntity('societe').")"; if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index bfcbd6b7059..695314bb526 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -818,7 +818,7 @@ class Don extends CommonObject $sql = "SELECT count(d.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " WHERE d.fk_statut > 0"; - $sql.= " AND d.entity IN (".getEntity('don', 1).")"; + $sql.= " AND d.entity IN (".getEntity('don').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index a48d3171020..9a8c503ac2e 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -263,7 +263,7 @@ class EcmFiles //extends CommonObject $sql.= ' WHERE 1 = 1'; /* Fetching this table depends on filepath+filename, it must not depends on entity if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; }*/ if ($fullpath) { $sql .= " AND t.filepath = '" . $this->db->escape(dirname($fullpath)) . "' AND t.filename = '".$this->db->escape(basename($fullpath))."'"; @@ -371,7 +371,7 @@ class EcmFiles //extends CommonObject $sql.= ' WHERE 1 = 1'; /* Fetching this table depends on filepath+filename, it must not depends on entity if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; }*/ if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8a5811a790a..b4345c72878 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1780,7 +1780,7 @@ else if ($id || $ref) $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; - $sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; + $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; $sql.= " AND obj.fk_".$origin." = ".$origin_id; $sql.= " AND obj.rowid = ed.fk_origin_line"; $sql.= " AND ed.fk_expedition = e.rowid"; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 2b7ada7a0c2..06cddeace91 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -491,7 +491,7 @@ class Expedition extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; - $sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; + $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; if ($id) $sql.= " AND e.rowid=".$id; if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; @@ -1583,7 +1583,7 @@ class Expedition extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 039a038f18a..7eaba0b29ad 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -77,7 +77,7 @@ if (!$user->rights->societe->client->voir && !$socid) $clause = " AND "; } $sql.= $clause." e.fk_statut = 0"; -$sql.= " AND e.entity IN (".getEntity('expedition', 1).")"; +$sql.= " AND e.entity IN (".getEntity('expedition').")"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $resql=$db->query($sql); @@ -242,7 +242,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_ta $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; -$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; +$sql.= " WHERE e.entity IN (".getEntity('expedition').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id; $sql.= " AND e.fk_statut = 1"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index c838c002cc9..c46a8b6bcde 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -197,7 +197,7 @@ if (!$user->rights->societe->client->voir && !$socid) // Internal user with no p { $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; +$sql.= " WHERE e.entity IN (".getEntity('expedition').")"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { $sql.= " AND e.fk_soc = sc.fk_soc"; diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 763b550d34e..58783ba69b3 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -104,7 +104,7 @@ class ExpenseReports extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('expensereport', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('expensereport').')'; if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; // Add sql filters diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index d62de0596e1..ffef31cad8b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1859,7 +1859,7 @@ class ExpenseReport extends CommonObject $sql = "SELECT count(ex.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; $sql.= " WHERE ex.fk_statut > 0"; - $sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")"; + $sql.= " AND ex.entity IN (".getEntity('expensereport').")"; $resql=$this->db->query($sql); if ($resql) @@ -1900,7 +1900,7 @@ class ExpenseReport extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2"; else $sql.= " WHERE ex.fk_statut = 5"; - $sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")"; + $sql.= " AND ex.entity IN (".getEntity('expensereport').")"; $sql.= " AND (ex.fk_user_author IN (".join(',',$userchildids).")"; $sql.= " OR ex.fk_user_validator IN (".join(',',$userchildids)."))"; diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index d68483cb32b..d29e1202bf4 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -61,7 +61,7 @@ class ExpenseReportStats extends Stats //$this->where = " e.fk_statut > 0"; //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. - $this->where.= ' e.entity IN ('.getEntity('expensereport', 1).')'; + $this->where.= ' e.entity IN ('.getEntity('expensereport').')'; //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php index d55e262e2e4..26df07cbcfb 100644 --- a/htdocs/expensereport/export_csv.php +++ b/htdocs/expensereport/export_csv.php @@ -128,7 +128,7 @@ if (isset($_POST['action'])) $sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; - $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; + $sql.= ' AND d.entity IN ('.getEntity('expensereport').')'; $sql.= " ORDER BY d.rowid"; $result = $db->query($sql); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 724fb234798..e08c5563de4 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -70,7 +70,7 @@ $label=$somme=$nb=array(); $totalnb=$totalsum=0; $sql = "SELECT tf.code, tf.label, count(de.rowid) as nb, sum(de.total_ht) as km"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."expensereport_det as de, ".MAIN_DB_PREFIX."c_type_fees as tf"; -$sql.= " WHERE de.fk_expensereport = d.rowid AND d.entity IN (".getEntity('expensereport', 1).") AND de.fk_c_type_fees = tf.id"; +$sql.= " WHERE de.fk_expensereport = d.rowid AND d.entity IN (".getEntity('expensereport').") AND de.fk_c_type_fees = tf.id"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) @@ -158,7 +158,7 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense $childids[]=$user->id; $sql.= " AND d.fk_user_author IN (".join(',',$childids).")\n"; } -$sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; +$sql.= ' AND d.entity IN ('.getEntity('expensereport').')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND d.fk_user_author = ".$socid; $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index f95952db482..e1039ca304d 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -194,7 +194,7 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields as ef on (d.rowid = ef.fk_object)"; $sql.= ", ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport', 1).")"; +$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; // Search all if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); // Ref diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index ce6e0da8c5a..d2f3a4c3567 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -214,7 +214,7 @@ dol_fiche_end(); $sql = 'SELECT er.rowid as eid, er.paid, er.total_ttc, per.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' WHERE per.fk_expensereport = er.rowid'; -$sql.= ' AND er.entity IN ('.getEntity('expensereport', 1).')'; +$sql.= ' AND er.entity IN ('.getEntity('expensereport').')'; $sql.= ' AND per.rowid = '.$id; dol_syslog("expensereport/payment/card.php", LOG_DEBUG); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index fdac304ffcb..29e6b2174e3 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -209,7 +209,7 @@ if ($action == 'create' || empty($action)) $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; $sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$chid; - $sql.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; + $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index fe00c046117..53116dae843 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -82,7 +82,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; 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('societe', 1).")"; +$sql.= " AND f.entity IN (".getEntity('societe').")"; if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY f.fk_statut"; @@ -171,7 +171,7 @@ if (! empty($conf->ficheinter->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; 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('intervention', 1).")"; + $sql.= " AND f.entity IN (".getEntity('intervention').")"; $sql.= " AND f.fk_statut = 0"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -219,7 +219,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f,"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; 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('commande', 1).")"; +$sql.= " AND f.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -290,7 +290,7 @@ if (! empty($conf->ficheinter->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; 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('intervention', 1).")"; + $sql.= " AND f.entity IN (".getEntity('intervention').")"; $sql.= " AND f.fk_statut = 1"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index cfa88b187f0..0c1f3e56c5b 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -391,7 +391,7 @@ if ($object->id > 0) $sql.= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; $sql.= ' AND pfp.fk_soc = '.$object->id; $sql .= $db->order('pfp.tms', 'desc'); $sql.= $db->plimit($MAXLIST); diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 1eb1872126c..6f3291518ca 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -113,7 +113,7 @@ class SupplierInvoices extends DolibarrApi if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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('supplier_invoice', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index c8d1ccb846a..7364199fca5 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -124,7 +124,7 @@ class Fournisseur extends Societe $clause = "AND"; } $sql.= " ".$clause." s.fournisseur = 1"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; $resql=$this->db->query($sql); if ($resql) @@ -189,7 +189,7 @@ class Fournisseur extends Societe $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + $sql.= " AND s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $resql=$this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index cb47a2d99df..159f76249df 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2455,7 +2455,7 @@ class CommandeFournisseur extends CommonOrder $product=new ProductFournisseur($this->db); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $sql.=$this->db->order("rowid","ASC"); $sql.=$this->db->plimit(1); $resql = $this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f9df07e96cc..5c8a41a0466 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1966,7 +1966,7 @@ class FactureFournisseur extends CommonInvoice $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 4f576148099..ae34f543c22 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -448,7 +448,7 @@ class ProductFournisseur extends Product $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pfp.entity IN (".getEntity('productprice', 1).")"; + $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status=1"; // only enabled company selected $sql.= " AND pfp.fk_product = ".$prodid; @@ -557,7 +557,7 @@ class ProductFournisseur extends Product $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, "; $sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; $sql.= " AND pfp.fk_product = ".$prodid; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status = 1"; // only enabled society diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 544d882cda3..2375168fca3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -524,7 +524,7 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE cf.fk_soc = s.rowid'; -$sql.= ' AND cf.entity IN ('.getEntity('supplier_order', 1).')'; +$sql.= ' AND cf.entity IN ('.getEntity('supplier_order').')'; if ($socid > 0) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index b1db17f3754..1c345478ef7 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -64,7 +64,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PRE $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.fournisseur = 1"; $sql.= " AND s.rowid = p.fk_soc"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (dol_strlen($stcomm)) { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 0918423908e..782a78981ed 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -292,7 +292,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_fourn', 1).')'; +$sql.= ' AND f.entity IN ('.getEntity('facture_fourn').')'; 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 = ".$search_product_category; if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 32f785460ba..690835a5e99 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -240,7 +240,7 @@ $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.fournisseur = 1"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; $sql.= " ORDER BY s.tms DESC"; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index ca874511c94..9d62747a1cb 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -94,7 +94,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if ($catid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; +$sql.= " WHERE p.entity IN (".getEntity('product').")"; if ($sRefSupplier) { $sql .= natural_search('ppf.ref_fourn', $sRefSupplier); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index ba36d911971..03d3c23f5cc 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -320,7 +320,7 @@ class Holiday extends CommonObject $sql.= " ua.photo as validator_photo"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday', 1).")"; + $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau $sql.= " AND cp.fk_user = '".$user_id."'"; @@ -445,7 +445,7 @@ class Holiday extends CommonObject $sql.= " ua.photo as validator_photo"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday', 1).")"; + $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau // Filtrage de séléction diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 383b2276d6c..56ffa78f429 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -844,7 +844,7 @@ class Livraison extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $sql.= " AND tosell = 1"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 846daad7806..ee0a068251b 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -130,7 +130,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', 1).')'; +$sql.= ' AND f.entity IN ('.getEntity('facture').')'; $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)) @@ -138,7 +138,7 @@ if (! empty($conf->global->AGENT_CONTACT_TYPE)) else $sql .= " AND sc.fk_user = u.rowid"; $sql.= " AND f.fk_statut > 0"; -$sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; +$sql.= ' AND s.entity IN ('.getEntity('societe').')'; $sql.= " AND d.fk_facture = f.rowid"; if ($agentid > 0) { if (! empty($conf->global->AGENT_CONTACT_TYPE)) diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 9656fa99fd9..c576b3ce4a6 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -193,7 +193,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 = " . getEntity('facture', 1); +$sql .= " AND f.entity = " . getEntity('facture'); 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/customerMargins.php b/htdocs/margin/customerMargins.php index bcb3cc65699..f7ccf637676 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -181,7 +181,7 @@ $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut > 0"; -$sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; +$sql.= ' AND s.entity IN ('.getEntity('societe').')'; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if ($client) diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f5e84dd5c04..d52bcf1b3b0 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -177,7 +177,7 @@ $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product"; $sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= ' AND f.entity IN ('.getEntity('facture', 1).')'; +$sql.= ' AND f.entity IN ('.getEntity('facture').')'; $sql.= " AND f.fk_statut > 0"; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php b/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php index a40b00af72c..97224b64da9 100644 --- a/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php +++ b/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php @@ -120,7 +120,7 @@ class SkeletonApi extends DolibarrApi //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $sql.= ' AND s.entity IN ('.getEntity('skeleton', 1).')'; + $sql.= ' AND s.entity IN ('.getEntity('skeleton').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ($socid) $sql.= " AND s.fk_soc = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php b/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php index 6805a697043..ea552ad85f9 100644 --- a/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php +++ b/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php @@ -179,7 +179,7 @@ class Skeleton_Class extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql.= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('skeleton') . ")"; } if (null !== $ref) { $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; @@ -257,7 +257,7 @@ class Skeleton_Class extends CommonObject } $sql.= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('skeleton') . ")"; } if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_list.php b/htdocs/modulebuilder/oldskeletons/skeleton_list.php index 47aeda79fdc..842fdf32457 100644 --- a/htdocs/modulebuilder/oldskeletons/skeleton_list.php +++ b/htdocs/modulebuilder/oldskeletons/skeleton_list.php @@ -216,7 +216,7 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= " WHERE 1 = 1"; -//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")"; +//$sql.= " WHERE u.entity IN (".getEntity('mytable').")"; if ($search_field1) $sql.= natural_search("field1",$search_field1); if ($search_field2) $sql.= natural_search("field2",$search_field2); if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 292c6a139a4..b35519826d3 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -180,7 +180,7 @@ class MyModuleObject extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql.= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("mymoduleobject", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('mymoduleobject') . ")"; } if (null !== $ref) { $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; @@ -258,7 +258,7 @@ class MyModuleObject extends CommonObject } $sql.= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("mymoduleobject", 1) . ")"; + $sql .= " AND entity IN (" . getEntity('mymoduleobject') . ")"; } if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); diff --git a/htdocs/modulebuilder/template/class/myobject_api_class.class.php b/htdocs/modulebuilder/template/class/myobject_api_class.class.php index 8f0dbee2e38..7f5ee413892 100644 --- a/htdocs/modulebuilder/template/class/myobject_api_class.class.php +++ b/htdocs/modulebuilder/template/class/myobject_api_class.class.php @@ -123,7 +123,7 @@ class MyObjectApi extends DolibarrApi //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $sql.= ' AND s.entity IN ('.getEntity('myobject', 1).')'; + $sql.= ' AND s.entity IN ('.getEntity('myobject').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ($socid) $sql.= " AND s.fk_soc = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index a935b87bd58..fc8bdcc9200 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -215,7 +215,7 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= " WHERE 1 = 1"; -//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")"; +//$sql.= " WHERE u.entity IN (".getEntity('mytable').")"; if ($search_field1) $sql.= natural_search("field1",$search_field1); if ($search_field2) $sql.= natural_search("field2",$search_field2); if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index b8ce1995b5a..67725bad586 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -520,7 +520,7 @@ class MultiCurrency extends CommonObject $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; $sql1.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; $sql1.= ' WHERE m.code = \''.$db->escape($code).'\''; - $sql1.= " AND m.entity IN (".getEntity('multicurrency', 1).")"; + $sql1.= " AND m.entity IN (".getEntity('multicurrency').")"; $sql2= ''; if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) $sql2.= ' AND DATE_FORMAT(mc.date_sync, "%Y-%m-%d") = "'.date('Y-m-d', $date_document).'"'; $sql3.= ' ORDER BY mc.date_sync DESC LIMIT 1'; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 510a0545372..861d9fa3300 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -133,7 +133,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } -$sql.= " WHERE p.entity = ".getEntity('survey',1); +$sql.= " WHERE p.entity = ".getEntity('survey'); if ($status == 'expired') $sql.=" AND date_fin < '".$db->idate($now)."'"; if ($status == 'opened') $sql.=" AND date_fin >= '".$db->idate($now)."'"; if ($search_ref) $sql.=natural_search("p.id_sondage", $search_ref); diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 58d66f3a2c5..85351a0fb2a 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -72,7 +72,7 @@ if ($action == 'convert') { $sql = 'SELECT rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product'; - $sql.= ' WHERE entity IN ('.getEntity('product',1).')'; + $sql.= ' WHERE entity IN ('.getEntity('product').')'; $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; $resql=$db->query($sql); @@ -162,7 +162,7 @@ if ($action == 'convert') // Change supplier prices $sql = 'SELECT pfp.rowid, pfp.fk_soc, pfp.price as price, pfp.quantity as qty, pfp.fk_availability, pfp.ref_fourn'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'societe as s'; - $sql.= ' WHERE pfp.fk_soc = s.rowid AND pfp.entity IN ('.getEntity('product',1).')'; + $sql.= ' WHERE pfp.fk_soc = s.rowid AND pfp.entity IN ('.getEntity('product').')'; $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; $sql.= " AND s.fk_pays = '".$country_id."'"; //print $sql; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 8867011101b..8e4892678e5 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -110,7 +110,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price "; $sql .= " WHERE fk_product='" . $id . "'"; - $sql .= " AND entity IN (" . getEntity('productprice', 1) . ")"; + $sql .= " AND entity IN (" . getEntity('productprice') . ")"; $sql .= " AND price_level=" . $price_level; $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1"; diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index a60694ca7cb..53442d94d39 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -352,7 +352,7 @@ class ActionsCardProduct } $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; if ($sall) { diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 970ac535273..f053e6f8d0b 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -313,7 +313,7 @@ class ActionsCardService $fourn_id = GETPOST("fourn_id",'int'); $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; } - $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE p.entity IN (".getEntity('product').")"; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ if ($sall) { diff --git a/htdocs/product/class/api_deprecated_product.class.php b/htdocs/product/class/api_deprecated_product.class.php index e33c7dd3e32..a1d475f53ab 100644 --- a/htdocs/product/class/api_deprecated_product.class.php +++ b/htdocs/product/class/api_deprecated_product.class.php @@ -115,7 +115,7 @@ class ProductApi extends DolibarrApi $sql ="SELECT rowid, ref, ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; // Show products if ($mode == 1) $sql.= " AND p.fk_product_type = 0"; @@ -198,7 +198,7 @@ class ProductApi extends DolibarrApi $sql = "SELECT rowid, ref, ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p, "; $sql.= MAIN_DB_PREFIX."categorie_product as c"; - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; // Select products of given category $sql.= " AND c.fk_categorie = ".$db->escape($category); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index a733a554fd5..0d6694ac569 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -109,7 +109,7 @@ class Products extends DolibarrApi { $sql.= ", ".MAIN_DB_PREFIX."categorie_product as c"; } - $sql.= ' WHERE t.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('product').')'; // Select products of given category if ($category > 0) { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index dda92ea0c0f..01064c8ffa3 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -112,7 +112,7 @@ class FormProduct $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; } } - $sql.= " WHERE e.entity IN (".getEntity('stock', 1).")"; + $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { $sql.= " AND e.statut IN (".implode(',',$warehouseStatus).")"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d866e3ec2ae..606274cd30e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -493,7 +493,7 @@ class Product extends CommonObject { $sql = "SELECT count(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $sql.= " AND ref = '" .$this->db->escape($this->ref)."'"; $result = $this->db->query($sql); @@ -1942,7 +1942,7 @@ class Product extends CommonObject $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql.= " WHERE entity IN (".getEntity('productprice', 1).")"; + $sql.= " WHERE entity IN (".getEntity('productprice').")"; $sql.= " AND price_level=".$i; $sql.= " AND fk_product = ".$this->id; $sql.= " ORDER BY date_price DESC, rowid DESC"; @@ -2108,7 +2108,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = pd.fk_propal"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; $sql.= " AND pd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; //$sql.= " AND pr.fk_statut != 0"; @@ -2151,7 +2151,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = cd.fk_commande"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; @@ -2217,7 +2217,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = cd.fk_commande"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('supplier_order', 1).")"; + $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; @@ -2262,7 +2262,7 @@ class Product extends CommonObject $sql.= " WHERE e.rowid = ed.fk_expedition"; $sql.= " AND c.rowid = cd.fk_commande"; $sql.= " AND e.fk_soc = s.rowid"; - $sql.= " AND e.entity IN (".getEntity('expedition', 1).")"; + $sql.= " AND e.entity IN (".getEntity('expedition').")"; $sql.= " AND ed.fk_origin_line = cd.rowid"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2305,7 +2305,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cf.rowid = fd.fk_commande"; $sql.= " AND cf.fk_soc = s.rowid"; - $sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")"; + $sql.= " AND cf.entity IN (".getEntity('supplier_order').")"; $sql.= " AND fd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid; @@ -2347,7 +2347,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = cd.fk_contrat"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract', 1).")"; + $sql.= " AND c.entity IN (".getEntity('contract').")"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; //$sql.= " AND c.statut != 0"; @@ -2389,7 +2389,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = fd.fk_facture"; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture', 1).")"; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $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; //$sql.= " AND f.fk_statut != 0"; @@ -2431,7 +2431,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = fd.fk_facture_fourn"; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")"; + $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; $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; //$sql.= " AND f.fk_statut != 0"; @@ -2543,7 +2543,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; 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', 1).")"; + $sql.= " AND f.entity IN (".getEntity('facture').")"; 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"; $sql.=$morefilter; @@ -2579,7 +2579,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; 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_fourn', 1).")"; + $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; 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"; $sql.=$morefilter; @@ -2614,7 +2614,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; $sql.=$morefilter; @@ -2649,7 +2649,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql.= " AND p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; $sql.=$morefilter; @@ -2683,7 +2683,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; $sql.=$morefilter; @@ -2717,7 +2717,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('supplier_order', 1).")"; + $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; $sql.=$morefilter; @@ -2908,7 +2908,7 @@ class Product extends CommonObject $sql.= " WHERE fk_soc = ".$id_fourn; $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; $sql.= " AND fk_product != ".$this->id; - $sql.= " AND entity IN (".getEntity('productprice', 1).")"; + $sql.= " AND entity IN (".getEntity('productprice').")"; $resql=$this->db->query($sql); if ($resql) @@ -2931,7 +2931,7 @@ class Product extends CommonObject else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; $sql.= " AND quantity = '".$quantity."'"; $sql.= " AND fk_product = ".$this->id; - $sql.= " AND entity IN (".getEntity('productprice', 1).")"; + $sql.= " AND entity IN (".getEntity('productprice').")"; $resql=$this->db->query($sql); if ($resql) @@ -3742,7 +3742,7 @@ class Product extends CommonObject $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; - $sql.= " WHERE w.entity IN (".getEntity('stock', 1).")"; + $sql.= " WHERE w.entity IN (".getEntity('stock').")"; $sql.= " AND w.rowid = ps.fk_entrepot"; $sql.= " AND ps.fk_product = ".$this->id; if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql.= " AND w.statut IN (".implode(',',$warehouseStatus).")"; diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 5b9050077c9..6a488c87e2b 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -338,7 +338,7 @@ class Productcustomerprice extends CommonObject $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product', 1) . ")"; + $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; // Manage filter if (count($filter) > 0) { @@ -445,7 +445,7 @@ class Productcustomerprice extends CommonObject $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product', 1) . ")"; + $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; // Manage filter if (count($filter) > 0) { @@ -724,7 +724,7 @@ class Productcustomerprice extends CommonObject $sql = "SELECT s.rowid"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= " WHERE s.parent = " . $this->fk_soc; - $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; + $sql .= " AND s.entity IN (" . getEntity('societe') . ")"; dol_syslog(get_class($this) . "::setPriceOnAffiliateThirdparty", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index aa1cf4137e9..07d83fc8d3a 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -148,7 +148,7 @@ if ($action == 'search') $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if ($key != "") { // For natural search diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 34da4f857b9..49a80859bd9 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -186,7 +186,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS $sql.= " FROM ".MAIN_DB_PREFIX."categorie_product as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; $sql.= " WHERE c.type = 0"; - $sql.= " AND c.entity IN (".getEntity('category',1).")"; + $sql.= " AND c.entity IN (".getEntity('category').")"; $sql.= " GROUP BY c.label"; $total=0; $result = $db->query($sql); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 8cb1f56eb9d..dc79dac28e5 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -519,7 +519,7 @@ class Inventory extends CoreObject $sql = 'SELECT i.rowid,i.title, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status'; $sql.= ' FROM '.MAIN_DB_PREFIX.'inventory i'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot e ON (e.rowid = i.fk_warehouse)'; - $sql.= ' WHERE i.entity IN ('.getEntity('inventory', 1).')'; + $sql.= ' WHERE i.entity IN ('.getEntity('inventory').')'; } return $sql; diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 1ebbf256c9c..0a40858cab9 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -286,7 +286,7 @@ else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 74f9c59cff3..e84aeb53681 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -288,7 +288,7 @@ else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($search_type) && $search_type != '-1') diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 5320e637316..07a19c4af5e 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -114,7 +114,7 @@ $infoprod=array(); $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, SUM(pd.qty) as c"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; -$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; +$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; $sql.= " AND p.rowid = pd.fk_product"; if ($type !== '') { $sql.= " AND fk_product_type = ".$type; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 99184b89e72..41f5cda1eb7 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1319,7 +1319,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ $sql .= " FROM " . MAIN_DB_PREFIX . "product_price as p,"; $sql .= " " . MAIN_DB_PREFIX . "user as u"; $sql .= " WHERE fk_product = " . $object->id; - $sql .= " AND p.entity IN (" . getEntity('productprice', 1) . ")"; + $sql .= " AND p.entity IN (" . getEntity('productprice') . ")"; $sql .= " AND p.fk_user_author = u.rowid"; if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = " . $soc->price_level; $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index e460bbec7c5..ffa0544976b 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -119,7 +119,7 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -$sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; +$sql.= " WHERE p.entity IN (".getEntity('product').")"; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ if ($sall) $sql.=natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $all); // if the type is not 1, we show all products (type = 0,2,3) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 6ab18ac87cb..1d45e93590c 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -124,7 +124,7 @@ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -$sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; +$sql.= " WHERE p.entity IN (".getEntity('product').")"; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ if ($sall) $sql.=natural_search(array('p.ref','p.label','p.description','p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 1c72d5f6615..221e76d7ac9 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -129,7 +129,7 @@ if ($id > 0 || ! empty($ref)) $sql.= ", ".MAIN_DB_PREFIX."commandedet as d"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; $sql.= " AND d.fk_commande = c.rowid"; $sql.= " AND d.fk_product =".$product->id; if (! empty($search_month)) diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index e2f5bccc430..eec53697a91 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -123,7 +123,7 @@ if ($id > 0 || ! empty($ref)) $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " WHERE c.rowid = cd.fk_contrat"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract', 1).")"; + $sql.= " AND c.entity IN (".getEntity('contract').")"; $sql.= " AND cd.fk_product =".$product->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 506689a6001..0aa1ca90c98 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -149,7 +149,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', 1).")"; + $sql.= " AND f.entity IN (".getEntity('facture').")"; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND d.fk_product =".$product->id; if (! empty($search_month)) diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index ac2849fefcf..db957ae6532 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -131,7 +131,7 @@ if ($id > 0 || ! empty($ref)) $sql .= ", " . MAIN_DB_PREFIX . "facture_fourn_det 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_fourn', 1).")"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; $sql .= " AND d.fk_facture_fourn = f.rowid"; $sql .= " AND d.fk_product =" . $product->id; if (! empty($search_month)) diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 06d43838bce..ec796422f0b 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -131,7 +131,7 @@ if ($id > 0 || ! empty($ref)) if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal', 1).")"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; $sql .= " AND d.fk_propal = p.rowid"; $sql .= " AND d.fk_product =" . $product->id; if (! empty($search_month)) diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 79e17749991..5465c04d9a9 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -104,7 +104,7 @@ class StockMovements extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as t"; - //$sql.= ' WHERE t.entity IN ('.getEntity('stock', 1).')'; + //$sql.= ' WHERE t.entity IN ('.getEntity('stock').')'; $sql.= ' WHERE 1 = 1'; // Add sql filters if ($sqlfilters) diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index d50f590c30c..6eccf805b41 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -103,7 +103,7 @@ class Warehouses extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('stock', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('stock').')'; // Add sql filters if ($sqlfilters) { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 1b650a4e7bb..9263fe4ba10 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -411,7 +411,7 @@ class Entrepot extends CommonObject $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; - $sql.= " WHERE entity IN (".getEntity('stock', 1).")"; + $sql.= " WHERE entity IN (".getEntity('stock').")"; $sql.= " AND statut = ".$status; $result = $this->db->query($sql); diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index a6e20aabcab..22a9e95410c 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -64,7 +64,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $sql = "SELECT e.label, e.rowid, e.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " WHERE e.statut in (0,1)"; -$sql.= " AND e.entity IN (".getEntity('stock', 1).")"; +$sql.= " AND e.entity IN (".getEntity('stock').")"; $sql.= $db->order('e.statut','DESC'); $sql.= $db->plimit(15, 0); @@ -119,7 +119,7 @@ $sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE m.fk_product = p.rowid"; $sql.= " AND m.fk_entrepot = e.rowid"; -$sql.= " AND e.entity IN (".getEntity('stock', 1).")"; +$sql.= " AND e.entity IN (".getEntity('stock').")"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; $sql.= $db->order("datem","DESC"); $sql.= $db->plimit($max,0); diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index eefbe3deee9..d3de2b6b6e5 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -87,7 +87,7 @@ $sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellv $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")"; +$sql.= " WHERE e.entity IN (".getEntity('stock').")"; if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 5f0f9c213dc..7a8010117a2 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -434,7 +434,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND $sql.= " WHERE m.fk_product = p.rowid"; if ($msid > 0) $sql .= " AND m.rowid = ".$msid; $sql.= " AND m.fk_entrepot = e.rowid"; -$sql.= " AND e.entity IN (".getEntity('stock', 1).")"; +$sql.= " AND e.entity IN (".getEntity('stock').")"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; if ($month > 0) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index e894368beaf..3ad426eda8c 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -810,7 +810,7 @@ $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; -$sql.= " AND e.entity IN (".getEntity('stock', 1).")"; +$sql.= " AND e.entity IN (".getEntity('stock').")"; $sql.= " AND ps.fk_product = ".$object->id; $sql.= " ORDER BY e.label"; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 78d3c470cb1..6233d8a3583 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -227,7 +227,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product_lot as t"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.rowid = t.fk_product"; -//$sql.= " WHERE u.entity IN (".getEntity('productlot',1).")"; +//$sql.= " WHERE u.entity IN (".getEntity('productlot').")"; if ($search_entity) $sql.= natural_search("entity",$search_entity); if ($search_product) $sql.= natural_search("p.ref",$search_product); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 1a3d7c9edb2..405fe098bb2 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -292,7 +292,7 @@ if($fk_supplier > 0) { if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; } -$sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')'; +$sql.= ' WHERE p.entity IN (' . getEntity('product') . ')'; if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { @@ -322,7 +322,7 @@ if ($usevirtualstock) $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; $sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlCommandesCli.= " WHERE c.entity IN (".getEntity('commande', 1).")"; + $sqlCommandesCli.= " WHERE c.entity IN (".getEntity('commande').")"; $sqlCommandesCli.= " AND cd.fk_product = p.rowid"; $sqlCommandesCli.= " AND c.fk_statut IN (1,2))"; @@ -331,7 +331,7 @@ if ($usevirtualstock) $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlExpeditionsCli.= " WHERE e.entity IN (".getEntity('expedition', 1).")"; + $sqlExpeditionsCli.= " WHERE e.entity IN (".getEntity('expedition').")"; $sqlExpeditionsCli.= " AND cd.fk_product = p.rowid"; $sqlExpeditionsCli.= " AND c.fk_statut IN (1,2))"; @@ -339,14 +339,14 @@ if ($usevirtualstock) $sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; $sqlCommandesFourn.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande"; - $sqlCommandesFourn.= " AND c.entity IN (".getEntity('supplier_order', 1).")"; + $sqlCommandesFourn.= " AND c.entity IN (".getEntity('supplier_order').")"; $sqlCommandesFourn.= " AND cd.fk_product = p.rowid"; $sqlCommandesFourn.= " AND c.fk_statut IN (3,4))"; $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty"; $sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; - $sqlReceptionFourn.= " WHERE cf.entity IN (".getEntity('supplier_order', 1).")"; + $sqlReceptionFourn.= " WHERE cf.entity IN (".getEntity('supplier_order').")"; $sqlReceptionFourn.= " AND fd.fk_product = p.rowid"; $sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))"; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 0c71eb6ad18..40e3060cfee 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -56,7 +56,7 @@ $sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sell $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")"; +$sql.= " WHERE e.entity IN (".getEntity('stock').")"; if ($sref) { $sql.= " AND e.label LIKE '%".$db->escape($sref)."%'"; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 0f4f85c05af..e2a60578e9e 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -116,7 +116,7 @@ class Projects 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('project', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('project').')'; 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.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index d2d7b81d865..d6303c18a16 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -123,7 +123,7 @@ class Tasks 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('project', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('project').')'; 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.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6a7b130ac0d..7cb6c29de1a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -385,7 +385,7 @@ class Project extends CommonObject else if (! empty($ref)) { $sql.= " WHERE ref='".$this->db->escape($ref)."'"; - $sql.= " AND entity IN (".getEntity('project',1).")"; + $sql.= " AND entity IN (".getEntity('project').")"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -1108,7 +1108,7 @@ class Project extends CommonObject { $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; } - $sql.= " WHERE p.entity IN (".getEntity('project',1).")"; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Internal users must see project he is contact to even if project linked to a third party he can't see. //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; @@ -1681,7 +1681,7 @@ class Project extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql.= " WHERE p.fk_statut = 1"; - $sql.= " AND p.entity IN (".getEntity('project').')'; + $sql.= " AND p.entity IN (".getEntity('project', false)')'; if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; @@ -1756,7 +1756,7 @@ class Project extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE"; - $sql.= " p.entity IN (".getEntity('projet', 1).")"; + $sql.= " p.entity IN (".getEntity('projet').")"; if (! $user->rights->projet->all->lire) { $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index e1025241115..c21669daf3b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -690,7 +690,7 @@ class Task extends CommonObject $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } - $sql.= " WHERE p.entity IN (".getEntity('project',1).")"; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND t.fk_projet = p.rowid"; } elseif ($mode == 1) @@ -710,7 +710,7 @@ class Task extends CommonObject { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; } - $sql.= " WHERE p.entity IN (".getEntity('project',1).")"; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; } else return 'BadValueForParameterMode'; @@ -1704,7 +1704,7 @@ class Task extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; + $sql.= " WHERE p.entity IN (".getEntity('project', false)')'; $sql.= " AND p.fk_statut = 1"; $sql.= " AND t.fk_projet = p.rowid"; $sql.= " AND t.progress < 100"; // tasks to do diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b327573e3db..851956f816b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -259,7 +259,7 @@ if ($search_project_user > 0) { $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; } -$sql.= " WHERE p.entity IN (".getEntity('project',1).')'; +$sql.= " WHERE p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 4e31434dbc4..19e64826110 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -268,7 +268,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab if ($search_project_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; if ($search_task_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ect"; $sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity IN (".getEntity('project',1).')'; +$sql.= " AND p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.=" AND p.rowid IN (".($projectsListId?$projectsListId:'0').")"; // public and assigned to projects, or restricted to company for external users // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 51024cfe7ee..4fbb8dde70d 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -470,7 +470,7 @@ class Dolresource extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid"; - $sql.= " WHERE t.entity IN (".getEntity('resource',1).")"; + $sql.= " WHERE t.entity IN (".getEntity('resource').")"; //Manage filter if (!empty($filter)){ @@ -555,7 +555,7 @@ class Dolresource extends CommonObject $sql.= " t.fk_user_create,"; $sql.= " t.tms"; $sql.= ' FROM '.MAIN_DB_PREFIX .'element_resources as t '; - $sql.= " WHERE t.entity IN (".getEntity('resource',1).")"; + $sql.= " WHERE t.entity IN (".getEntity('resource').")"; //Manage filter if (!empty($filter)){ @@ -637,7 +637,7 @@ class Dolresource extends CommonObject $sql.= " t.fk_user_create,"; $sql.= " t.tms"; $sql.= ' FROM '.MAIN_DB_PREFIX .'element_resources as t '; - $sql.= " WHERE t.entity IN (".getEntity('resource',1).")"; + $sql.= " WHERE t.entity IN (".getEntity('resource').")"; //Manage filter if (!empty($filter)){ diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index b3565a2ca26..f81d9092fd2 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -61,7 +61,7 @@ if (GETPOST('newcompany') || GETPOST('socid','int') || GETPOST('id_fourn')) $sql = "SELECT rowid, nom"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; if ($socid) { $sql.=" AND ("; diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 02c1410fcbf..ad82db3e008 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -114,7 +114,7 @@ class Contacts extends DolibarrApi $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid"; - $sql.= ' WHERE t.entity IN (' . getEntity('socpeople', 1) . ')'; + $sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')'; if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) diff --git a/htdocs/societe/class/api_deprecated_contact.class.php b/htdocs/societe/class/api_deprecated_contact.class.php index 8cb61fa3eb0..bfa032f13c4 100644 --- a/htdocs/societe/class/api_deprecated_contact.class.php +++ b/htdocs/societe/class/api_deprecated_contact.class.php @@ -126,7 +126,7 @@ class ContactApi extends DolibarrApi $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON c.fk_soc = s.rowid"; - $sql.= ' WHERE c.entity IN (' . getEntity('socpeople', 1) . ')'; + $sql.= ' WHERE c.entity IN (' . getEntity('socpeople') . ')'; if ($socid) $sql.= " AND c.fk_soc = " . $socid; diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php index a8146f4cca6..bca74ba8ae2 100644 --- a/htdocs/societe/class/api_deprecated_thirdparty.class.php +++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php @@ -178,7 +178,7 @@ class ThirdpartyApi extends DolibarrApi if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; if ($mode == 3) $sql.= " AND s.client IN (0)"; - $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; + $sql.= ' AND s.entity IN ('.getEntity('societe').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 507fd62ec48..24cf991da52 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -119,7 +119,7 @@ class Thirdparties extends DolibarrApi if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; if ($mode == 3) $sql.= " AND t.client IN (0)"; - $sql.= ' AND t.entity IN ('.getEntity('societe', 1).')'; + $sql.= ' AND t.entity IN ('.getEntity('societe').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; if ($socid) $sql.= " AND t.rowid IN (".$socids.")"; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ebd06dbd5c4..2610ea7071f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1248,7 +1248,7 @@ class Societe extends CommonObject // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE entity IN (".getEntity('category',1).")"; + $sql.= " WHERE entity IN (".getEntity('category').")"; if (! empty($type)) { if ($type == 1 || $type == 2) @@ -2640,7 +2640,7 @@ class Societe extends CommonObject } //Verify duplicate entries - $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe',1).")"; + $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; if($socid) $sql .= " AND rowid <> ".$socid; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index c3508bd0cef..0973de848b5 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -107,7 +107,7 @@ $total=0; $sql = "SELECT s.rowid, s.client, s.fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; +$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible @@ -184,7 +184,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; $sql.= " WHERE c.type = 2"; if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; - $sql.= " AND c.entity IN (".getEntity('category',1).")"; + $sql.= " AND c.entity IN (".getEntity('category').")"; $sql.= " GROUP BY c.label"; $total=0; $result = $db->query($sql); @@ -248,7 +248,7 @@ $sql.= ", s.logo"; $sql.= ", s.canvas, s.tms as datem, s.status as status"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; +$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 51d4b41e6bb..3ab173e958b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -396,7 +396,7 @@ $sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st"; // We'll need this table joined to the select in order to filter by sale if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/societe/notify/index.php b/htdocs/societe/notify/index.php index 02125e8fad8..ebebb23494c 100644 --- a/htdocs/societe/notify/index.php +++ b/htdocs/societe/notify/index.php @@ -64,7 +64,7 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE n.fk_contact = c.rowid"; $sql.= " AND a.rowid = n.fk_action"; $sql.= " AND n.fk_soc = s.rowid"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; if ($socid > 0) $sql.= " AND s.rowid = " . $user->societe_id; $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 7019933fb9c..35914750ddc 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2185,7 +2185,7 @@ class SupplierProposal extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $sql.= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 2c10e2451a6..a5d1d6cdc0f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -266,7 +266,7 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE sp.fk_soc = s.rowid'; -$sql.= ' AND sp.entity IN ('.getEntity('supplier_proposal', 1).')'; +$sql.= ' AND sp.entity IN ('.getEntity('supplier_proposal').')'; if (! $user->rights->societe->client->voir && ! $socid) //restriction { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index af1b8441293..f119fa36ffa 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -77,7 +77,7 @@ class Users extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('user', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('user').')'; if ($user_ids) $sql.=" AND t.rowid IN (".$user_ids.")"; // Add sql filters if ($sqlfilters) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index e09e52c1882..869059d359b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2529,7 +2529,7 @@ class User extends CommonObject $sql = "SELECT fk_user as id_parent, rowid as id_son"; $sql.= " FROM ".MAIN_DB_PREFIX."user"; $sql.= " WHERE fk_user <> 0"; - $sql.= " AND entity IN (".getEntity('user',1).")"; + $sql.= " AND entity IN (".getEntity('user').")"; dol_syslog(get_class($this)."::load_parentof", LOG_DEBUG); $resql = $this->db->query($sql); @@ -2579,7 +2579,7 @@ class User extends CommonObject } else { - $sql.= " WHERE u.entity IN (".getEntity('user',1).")"; + $sql.= " WHERE u.entity IN (".getEntity('user').")"; } if ($filter) $sql.=" AND ".$filter; @@ -2764,7 +2764,7 @@ class User extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.statut > 0"; //$sql.= " AND employee != 0"; - $sql.= " AND u.entity IN (".getEntity('user', 1).")"; + $sql.= " AND u.entity IN (".getEntity('user').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 8333acbbb79..898851d2108 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -200,7 +200,7 @@ if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf } else { - $sql.= " WHERE u.entity IN (".getEntity('user',1).")"; + $sql.= " WHERE u.entity IN (".getEntity('user').")"; } if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index bbfc655a0bd..792a0f67e93 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -73,7 +73,7 @@ class ProductAttribute return -1; } - $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product', 1).")"; + $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -100,7 +100,7 @@ class ProductAttribute { $return = array(); - $sql = 'SELECT rowid, ref, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product', 1).')'; + $sql = 'SELECT rowid, ref, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')'; $sql .= $this->db->order('rang', 'asc'); $query = $this->db->query($sql); if ($query) @@ -202,7 +202,7 @@ class ProductAttribute public function countChildProducts() { $sql = "SELECT COUNT(*) count FROM ".MAIN_DB_PREFIX."product_attribute_combination2val pac2v - LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac2v.fk_prod_combination = pac.rowid WHERE pac2v.fk_prod_attr = ".(int) $this->id." AND pac.entity IN (".getEntity('product', 1).")"; + LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac2v.fk_prod_combination = pac.rowid WHERE pac2v.fk_prod_attr = ".(int) $this->id." AND pac.entity IN (".getEntity('product').")"; $query = $this->db->query($sql); diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index 399137dca18..02ef86a9222 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -68,7 +68,7 @@ class ProductAttributeValue */ public function fetch($valueid) { - $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $valueid." AND entity IN (".getEntity('product', 1).")"; + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $valueid." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 155d92af532..f6eb4c58935 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -86,7 +86,7 @@ class ProductCombination */ public function fetch($rowid) { - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE rowid = ".(int) $rowid." AND entity IN (".getEntity('product', 1).")"; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE rowid = ".(int) $rowid." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -118,7 +118,7 @@ class ProductCombination */ public function fetchByFkProductChild($fk_child) { - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product', 1).")"; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -150,7 +150,7 @@ class ProductCombination */ public function fetchAllByFkProductParent($fk_product_parent) { - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product', 1).")"; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -185,7 +185,7 @@ class ProductCombination public function countNbOfCombinationForFkProductParent($fk_product_parent) { $nb = 0; - $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product', 1).")"; + $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index c80d20fe44b..c454a7d3502 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -205,7 +205,7 @@ class WebsitePage extends CommonObject $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - //$sql .= ' WHERE entity IN ('.getEntity('website', 1).')'; // entity is on website level + //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level $sql .= ' WHERE 1 = 1'; if (null !== $website_id) { $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; -- GitLab