From 5c5663c5ae9a9b02f9a994d10cfaa310ed2bbdfb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 30 May 2017 18:50:54 +0200 Subject: [PATCH 1/7] 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) . "'"; From aa780ea33b3164656c71aa3231e53f76ef14bcba Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 30 May 2017 19:15:37 +0200 Subject: [PATCH 2/7] Fix: missing dot --- .../compta/deplacement/class/deplacement.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/contrat/index.php | 14 +++++++------- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 6 +++--- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/class/task.class.php | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 2cfed45c9d4..6fb146c205b 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', false)")"; + $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/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 36d59c36c9a..50ccf788bf5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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', false)")"; + $sql.= " WHERE f.entity in (".getEntity('facture', false).")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 762a22889c6..9632d1766e6 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', false)")"; + $sql.= " AND entity IN (".getEntity('contract', false).")"; } else $sql.= " WHERE rowid=".$id; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 3cff590bc4b..608a1167fba 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', false)")"; +$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', false)")"; +$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', false)")"; + $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', false)")"; +$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', false)")"; +$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', false)")"; +$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', false)")"; +$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/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b72a451a41c..1244001da57 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4352,7 +4352,7 @@ class Form $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; - $sql.= " WHERE entity IN ('".getEntity('mutlicurrency', false)"')"; + $sql.= " WHERE entity IN ('".getEntity('mutlicurrency', false)."')"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index feac8b20cec..fce080bdcf4 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', false)")"; + $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', false)")"; + $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', false)")"; + $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/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7cb6c29de1a..ba394f1b8e6 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -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', false)')'; + $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.")"; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index c21669daf3b..b751f8f0478 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -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', false)')'; + $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 From 0eadef9a7ad540e81bc03edaf1e81795043d7b0e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 3 Jun 2017 11:46:18 +0200 Subject: [PATCH 3/7] Fix: merge correction --- htdocs/modulebuilder/oldskeletons/.gitignore | 2 - htdocs/modulebuilder/oldskeletons/README | 34 - .../oldskeletons/build_api_class.php | 123 ---- .../oldskeletons/build_class_from_table.php | 677 ------------------ .../build_webservice_from_class.php | 179 ----- .../oldskeletons/modMyModule.class.php | 291 -------- .../oldskeletons/skeleton_api_class.class.php | 289 -------- .../oldskeletons/skeleton_card.php | 604 ---------------- .../oldskeletons/skeleton_class.class.php | 606 ---------------- .../oldskeletons/skeleton_list.php | 570 --------------- .../oldskeletons/skeleton_script.php | 166 ----- .../skeleton_webservice_server.php | 272 ------- 12 files changed, 3813 deletions(-) delete mode 100644 htdocs/modulebuilder/oldskeletons/.gitignore delete mode 100644 htdocs/modulebuilder/oldskeletons/README delete mode 100755 htdocs/modulebuilder/oldskeletons/build_api_class.php delete mode 100755 htdocs/modulebuilder/oldskeletons/build_class_from_table.php delete mode 100755 htdocs/modulebuilder/oldskeletons/build_webservice_from_class.php delete mode 100644 htdocs/modulebuilder/oldskeletons/modMyModule.class.php delete mode 100644 htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php delete mode 100644 htdocs/modulebuilder/oldskeletons/skeleton_card.php delete mode 100644 htdocs/modulebuilder/oldskeletons/skeleton_class.class.php delete mode 100644 htdocs/modulebuilder/oldskeletons/skeleton_list.php delete mode 100644 htdocs/modulebuilder/oldskeletons/skeleton_script.php delete mode 100644 htdocs/modulebuilder/oldskeletons/skeleton_webservice_server.php diff --git a/htdocs/modulebuilder/oldskeletons/.gitignore b/htdocs/modulebuilder/oldskeletons/.gitignore deleted file mode 100644 index 2dda6229d24..00000000000 --- a/htdocs/modulebuilder/oldskeletons/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -out.* -socpeople* diff --git a/htdocs/modulebuilder/oldskeletons/README b/htdocs/modulebuilder/oldskeletons/README deleted file mode 100644 index 5b5b992d91e..00000000000 --- a/htdocs/modulebuilder/oldskeletons/README +++ /dev/null @@ -1,34 +0,0 @@ -README (English) --------------------------------- -This directory contains PHP script samples that can be used to start a development on Dolibarr. - - -*** build_class_from_table.php: - -This is the script to use to generate PHP code of a PHP POJO class -object, a PHP script that use this POJO. This script use the files -skeleton_*.php to build its generated code. - - -*** modMyModule.class.php: - -Is a sample of module descriptor that you can use if you want to build a new module/plugin for -Dolibarr. - - -*** skeleton_script.php: - -Is a sample you can use as an example if you need to build a script to run on command line - - -*** skeleton_page.php: - -Is a sample you can use as an example if you need to build an HTML page to include in Dolibarr GUI. - - -*** skeleton_class.class.php: - -Is a sample you can use as an example if you need to build a class file to access a new table required by a Dolibarr development. -However it is better to run the build_class_from_table.php script that accepts a table name as a parameter and will uses the description table within database and the skeleton_class.class.php file to generate full code for your class file. -After running this script, the class to access your table (insert a record, update, delete and select) is directly finished and can be used by your module's code. -No more coding is needed to get access to table with this script because the file is completely generated once. diff --git a/htdocs/modulebuilder/oldskeletons/build_api_class.php b/htdocs/modulebuilder/oldskeletons/build_api_class.php deleted file mode 100755 index 6263eabcd6e..00000000000 --- a/htdocs/modulebuilder/oldskeletons/build_api_class.php +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env php - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file dev/skeletons/build_api_class.php - * \ingroup core - * \brief Create a complete API class file from existant class file - */ - -$sapi_type = php_sapi_name(); -$script_file = basename(__FILE__); -$path=dirname(__FILE__).'/'; - -// Test if batch mode -if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; -} - -// Include Dolibarr environment -require_once($path."../../htdocs/master.inc.php"); -// After this $db is a defined handler to database. - -// Main -$version='1'; -@set_time_limit(0); -$error=0; - -$langs->load("main"); - - -print "***** $script_file ($version) *****\n"; - - -// -------------------- START OF BUILD_API_FROM_CLASS -------------------- - -// Check parameters -if (! isset($argv[1]) && ! isset($argv[2])) -{ - print "Usage: $script_file phpClassFile phpClassName\n"; - exit; -} -// Show parameters -print 'Classfile='.$argv[1]."\n"; -print 'Classname='.$argv[2]."\n"; - -$classfile=$argv[1]; -$classname=$argv[2]; -$classmin=strtolower($classname); -$classnameApi = $classname.'Api'; -$property=array(); -$targetcontent=''; - -// Load the class and read properties -require_once($classfile); - -$property=array(); -$class = new $classname($db); -$values=get_class_vars($classname); - -unset($values['db']); -unset($values['error']); -unset($values['errors']); -unset($values['element']); -unset($values['table_element']); -unset($values['table_element_line']); -unset($values['fk_element']); -unset($values['ismultientitymanaged']); - -// Read skeleton_api_class.class.php file -$skeletonfile=$path.'skeleton_api_class.class.php'; -$sourcecontent=file_get_contents($skeletonfile); -if (! $sourcecontent) -{ - print "\n"; - print "Error: Failed to read skeleton sample '".$skeletonfile."'\n"; - print "Try to run script from skeletons directory.\n"; - exit; -} - -// Define output variables -$outfile='out.api_'.$classmin.'.class.php'; -$targetcontent=$sourcecontent; - -// Substitute class name -$targetcontent=preg_replace('/skeleton_api_class\.class\.php/', 'api_'.$classmin.'.class.php', $targetcontent); -$targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent); -//$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$tablenoprefix.'\'', $targetcontent); -$targetcontent=preg_replace('/SkeletonApi/', $classnameApi, $targetcontent); -$targetcontent=preg_replace('/Skeleton/', $classname, $targetcontent); - -// Build file -$fp=fopen($outfile,"w"); -if ($fp) -{ - fputs($fp, $targetcontent); - fclose($fp); - print "\n"; - print "File '".$outfile."' has been built in current directory.\n"; -} -else $error++; - - - -// -------------------- END OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- - -print "You can now rename generated files by removing the 'out.' prefix in their name and store them into directory /module/class.\n"; -return $error; diff --git a/htdocs/modulebuilder/oldskeletons/build_class_from_table.php b/htdocs/modulebuilder/oldskeletons/build_class_from_table.php deleted file mode 100755 index 0e5a6d82a82..00000000000 --- a/htdocs/modulebuilder/oldskeletons/build_class_from_table.php +++ /dev/null @@ -1,677 +0,0 @@ -#!/usr/bin/env php - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file dev/skeletons/build_class_from_table.php - * \ingroup core - * \brief Create a complete class file from a table in database - */ - -$sapi_type = php_sapi_name(); -$script_file = basename(__FILE__); -$path=dirname(__FILE__).'/'; - -// Test if batch mode -if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; -} - -// Include Dolibarr environment -require_once($path."../../htdocs/master.inc.php"); -// After this $db is a defined handler to database. - -// Main -$version='3.2'; -@set_time_limit(0); -$error=0; - -$langs->load("main"); - - -print "***** $script_file ($version) *****\n"; - - -// -------------------- START OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- - -// Check parameters -if (! isset($argv[1]) || ! isset($argv[2]) || (isset($argv[3]) && ! isset($argv[7]))) -{ - print "Usage: $script_file tablename modulename [server port databasename user pass]\n"; - exit; -} - -if (isset($argv[3]) && isset($argv[4]) && isset($argv[5]) && isset($argv[6]) && isset($argv[7])) -{ - print 'Use specific database ids'."\n"; - $db=getDoliDBInstance('mysqli',$argv[3],$argv[6],$argv[7],$argv[5],$argv[4]); -} - -if ($db->type != 'mysql' && $db->type != 'mysqli') -{ - print "Error: This script works with mysql or mysqli driver only\n"; - exit; -} - -$table=$argv[1]; -$module=$argv[2]; - -// Show parameters -print 'Tablename: '.$table."\n"; -print 'Modulename: '.$module."\n"; -print "Current dir: ".getcwd()."\n"; -print "Database name: ".$db->database_name."\n"; - - -// Define array with list of properties -$property=array(); -$foundprimary=0; -$resql=$db->DDLDescTable($table); -if ($resql) -{ - $i=0; - while($obj=$db->fetch_object($resql)) - { - //var_dump($obj); - $i++; - $property[$i]['field']=$obj->Field; - if ($obj->Key == 'PRI') - { - $property[$i]['primary']=1; - $foundprimary=1; - } - else - { - $property[$i]['primary']=1; - } - $property[$i]['type'] =$obj->Type; - $property[$i]['null'] =$obj->Null; - $property[$i]['extra']=$obj->Extra; - if ($property[$i]['type'] == 'date' - || $property[$i]['type'] == 'datetime' - || $property[$i]['type'] == 'timestamp') - { - $property[$i]['istime']=true; - } - else - { - $property[$i]['istime']=false; - } - if (preg_match('/varchar/i',$property[$i]['type']) - || preg_match('/text/i',$property[$i]['type'])) - { - $property[$i]['ischar']=true; - } - else - { - $property[$i]['ischar']=false; - } - if (preg_match('/int/i',$property[$i]['type'])) - { - $property[$i]['isint']=true; - } - else - { - $property[$i]['isint']=false; - } - } -} -else -{ - print "Error: Failed to get description for table '".$table."'.\n"; - return false; -} -//var_dump($property); - -// Define substitute fetch/select parameters -$varpropselect="\n"; -$cleanparam=''; -$i=0; -foreach($property as $key => $prop) -{ - $i++; - if ($prop['field'] != 'rowid') - { - $varpropselect.="\t\t\$sql .= \" "; - $varpropselect.="t.".$prop['field']; - if ($i < count($property)) $varpropselect.=","; - $varpropselect.="\";"; - $varpropselect.="\n"; - } -} - - - -//-------------------------------- -// Build skeleton_class.class.php -//-------------------------------- - -// Define working variables -$table=strtolower($table); -$tablenoprefix=preg_replace('/'.preg_quote(MAIN_DB_PREFIX,'/').'/i','',$table); -$classname=preg_replace('/_/','',ucfirst($tablenoprefix)); -$classmin=preg_replace('/_/','',strtolower($classname)); - - -// Read skeleton_class.class.php file -$skeletonfile=$path.'skeleton_class.class.php'; -$sourcecontent=file_get_contents($skeletonfile); -if (! $sourcecontent) -{ - print "\n"; - print "Error: Failed to read skeleton sample '".$skeletonfile."'\n"; - print "Try to run script from skeletons directory.\n"; - exit; -} - -// Define output variables -$outfile=$classmin.'.class.php'; -$targetcontent=$sourcecontent; - -// Substitute module name -$targetcontent=preg_replace('/dev\/skeletons/', $module, $targetcontent); -$targetcontent=preg_replace('/mymodule othermodule1 othermodule2/', $module, $targetcontent); -$targetcontent=preg_replace('/mymodule/', $module, $targetcontent); - -// Substitute class name -$targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent); -$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element = \''.$classmin.'\'', $targetcontent); -$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element = \''.$tablenoprefix.'\'', $targetcontent); -$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent); -$targetcontent=preg_replace('/skeletons/', $classmin, $targetcontent); -$targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent); - -// Substitute comments -$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent); -$targetcontent=preg_replace('/\s*\/\/\.\.\./', '', $targetcontent); -$targetcontent=preg_replace('/Put here some comments/','Initialy built by build_class_from_table on '.strftime('%Y-%m-%d %H:%M',mktime()), $targetcontent); - -// Substitute table name -$targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent); - -// Substitute declaration parameters -$varprop="\n"; -$cleanparam=''; -foreach($property as $key => $prop) -{ - if ($prop['field'] != 'rowid' && $prop['field'] != 'id') - { - $varprop.="\tpublic \$".$prop['field']; - if ($prop['istime']) $varprop.=" = ''"; - $varprop.=";"; - if ($prop['comment']) $varprop.="\t// ".$prop['extra']; - $varprop.="\n"; - } -} -$targetcontent=preg_replace('/'.preg_quote('public $prop1;','/').'/', $varprop, $targetcontent); -$targetcontent=preg_replace('/'.preg_quote('public $prop2;','/').'/', '', $targetcontent); - -$targetcontent=preg_replace('/\*((\s|\n|\r|\t)*)\@var mixed Sample property 1((\s|\n|\r|\t)*)/', '', $targetcontent); -$targetcontent=preg_replace('/\*((\s|\n|\r|\t)*)\@var mixed Sample property 2((\s|\n|\r|\t)*)/', '', $targetcontent); - -// Substitute clean parameters -$varprop="\n"; -$cleanparam=''; -foreach($property as $key => $prop) -{ - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="\t\tif (isset(\$this->".$prop['field'].")) {\n\t\t\t \$this->".$prop['field']." = trim(\$this->".$prop['field'].");\n\t\t}"; - $varprop.="\n"; - } -} -$targetcontent=preg_replace('/if \(isset\(\$this->prop1\)\) {((\n|\r|\t)*)\$this->prop1 = trim\(\$this->prop1\);((\n|\r|\t)*)}/', $varprop, $targetcontent); -$targetcontent=preg_replace('/if \(isset\(\$this->prop2\)\) {((\n|\r|\t)*)\$this->prop2 = trim\(\$this->prop2\);((\n|\r|\t)*)}/', '', $targetcontent); - - -$no_output_field=0; -foreach($property as $key => $prop) -{ - if ($prop['field'] == 'tms') $no_output_field++; // This is a field of type timestamp edited automatically - if ($prop['extra'] == 'auto_increment') $no_output_field++; -} -// Substitute insert into parameters -$varprop="\n"; -$cleanparam=''; -$i=0; -foreach($property as $key => $prop) -{ - $i++; - $addfield=1; - if ($prop['field'] == 'tms') $addfield=0; // This is a field of type timestamp edited automatically - if ($prop['extra'] == 'auto_increment') $addfield=0; - - if ($addfield) - { - $varprop.="\t\t\$sql.= '".$prop['field']; - if ($i < (count($property)-$no_output_field)) $varprop.=","; - $varprop.="';"; - $varprop.="\n"; - } -} -$targetcontent=preg_replace('/\$sql \.= \' field1,\';/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$sql \.= \' field2\';/', '', $targetcontent); - -// Substitute insert values parameters -$varprop="\n"; -$cleanparam=''; -$i=0; - -//Count nb field to output to manage commat at end SQL instruction - - -foreach($property as $key => $prop) -{ - - $addfield=1; - if ($prop['field'] == 'tms') $addfield=0; // This is a field of type timestamp edited automatically - if ($prop['extra'] == 'auto_increment') $addfield=0; - - if ($addfield) - { - $i++; - - $varprop.="\t\t\$sql .= ' "; - if ($prop['field']=='datec') - { - $varprop.='\'."\'".$this->db->idate(dol_now())."\'"'; - } - elseif ($prop['istime']) - { - $varprop.='\'.(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':"\'".$this->db->idate('; - $varprop.="\$this->".$prop['field']; - $varprop.=").\"'\")"; - } - elseif ($prop['ischar']) - { - $varprop.="'.(! isset(\$this->".$prop['field'].")?'NULL':\"'\"."; - $varprop.="\$this->db->escape(\$this->".$prop['field'].")"; - $varprop.=".\"'\")"; - } - elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_m' || $prop['field']=='fk_user_author') - { - $varprop.="'.\$user->id"; - } - elseif ($prop['isint']) - { - $varprop.='\'.(! isset($this->'.$prop['field'].')?\'NULL\':'; - $varprop.="\$this->".$prop['field']; - $varprop.=')'; - } - else - { - $varprop.='\'.(! isset($this->'.$prop['field'].')?\'NULL\':"\'".'; - $varprop.="\$this->".$prop['field']; - $varprop.='."\'")'; - } - - if ($i < (count($property)-$no_output_field)) $varprop.=".','"; - $varprop.=';'; - $varprop.="\n"; - } -} - -$patern1='/\$sql \.= \' (.*)\' \. \$this->prop1 \. \'(.*),\';/'; -$patern2='/\$sql \.= \' (.*)\' \. \$this->prop2 \. \'(.*)\';/'; -$targetcontent=preg_replace($patern1, $varprop, $targetcontent); -$targetcontent=preg_replace($patern2, '', $targetcontent); - -// Substitute update values parameters - -//Count nb field to output to manage commat at end SQL instruction -$no_output_field=0; -foreach($property as $key => $prop) -{ - if ($prop['extra'] == 'auto_increment') $no_output_field++; -} - -$varprop="\n"; -$cleanparam=''; -$i=0; -foreach($property as $key => $prop) -{ - - $addfield=1; - if ($prop['extra'] == 'auto_increment') $addfield=0; - - if ($addfield) - { - $i++; - - $varprop.="\t\t\$sql .= ' "; - $varprop.=$prop['field'].' = '; - if ($prop['field']=='tms') { - $varprop.='\'.(dol_strlen($this->'.$prop['field'].') != 0 ? "\'".$this->db->idate('; - $varprop.='$this->'.$prop['field']; - $varprop.=')."\'" : "\'".$this->db->idate(dol_now())."\'")'; - } - elseif ($prop['istime']) - { - $varprop.='\'.(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].') != 0 ? "\'".$this->db->idate('; - $varprop.='$this->'.$prop['field']; - $varprop.=')."\'" : \'null\')'; - } - - elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_m') { - $varprop.="'.\$user->id"; - } - else - { - $varprop.="'."; - if ($prop['ischar']) $varprop.='(isset($this->'.$prop['field'].')?"\'".$this->db->escape($this->'.$prop['field'].')."\'":"null")'; - elseif ($prop['isint']) $varprop.='(isset($this->'.$prop['field'].')?$this->'.$prop['field'].':"null")'; - else $varprop.='(isset($this->'.$prop['field'].')?$this->'.$prop['field'].':"null")'; - } - - if ($i < (count($property)-$no_output_field)) $varprop.=".','"; - $varprop.=';'; - $varprop.="\n"; - } -} -$targetcontent=preg_replace('/\$sql \.= " field1=".\(isset\(\$this->field1\)\?"\'".\$this->db->escape\(\$this->field1\)."\'":"null"\).",";/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$sql \.= " field2=".\(isset\(\$this->field2\)\?"\'".\$this->db->escape\(\$this->field2\)."\'":"null"\)."";/', '', $targetcontent); - -// Substitute fetch/select parameters -$targetcontent=preg_replace('/\$sql \.= \' t\.field1,\';/', $varpropselect, $targetcontent); -$targetcontent=preg_replace('/\$sql \.= \' t\.field2\';/', '', $targetcontent); - -// Substitute select set parameters -$varprop="\n"; -$varpropline="\n"; -$cleanparam=''; -$i=0; -foreach($property as $key => $prop) -{ - $i++; - if ($prop['field'] != 'rowid' && $prop['field'] != 'id') - { - $varprop.="\t\t\t\t\$this->".$prop['field']." = "; - if ($prop['istime']) $varprop.='$this->db->jdate('; - $varprop.='$obj->'.$prop['field']; - if ($prop['istime']) $varprop.=')'; - $varprop.=";"; - $varprop.="\n"; - - $varpropline.="\t\t\t\t\$line->".$prop['field']." = "; - if ($prop['istime']) $varpropline.='$this->db->jdate('; - $varpropline.='$obj->'.$prop['field']; - if ($prop['istime']) $varpropline.=')'; - $varpropline.=";"; - $varpropline.="\n"; - } -} -$targetcontent=preg_replace('/\$this->prop1 = \$obj->field1;/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$this->prop2 = \$obj->field2;/', '', $targetcontent); - -//Substirute fetchAll -$targetcontent=preg_replace('/\$line->prop1 = \$obj->field1;/', $varpropline, $targetcontent); -$targetcontent=preg_replace('/\$line->prop2 = \$obj->field2;/', '', $targetcontent); - - -// Substitute initasspecimen parameters -$varprop="\n"; -$cleanparam=''; -foreach($property as $key => $prop) -{ - if ($prop['field'] != 'rowid' && $prop['field'] != 'id') - { - $varprop.="\t\t\$this->".$prop['field']." = '';"; - $varprop.="\n"; - } -} -$targetcontent=preg_replace('/\$this->prop1 = \'prop1\';/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$this->prop2 = \'prop2\';/', '', $targetcontent); - -// Build file -$fp=fopen($outfile,"w"); -if ($fp) -{ - fputs($fp, $targetcontent); - fclose($fp); - print "\n"; - print "File '".$outfile."' has been built in current directory.\n"; -} -else $error++; - - - -//-------------------------------------------------------------------- -// Build skeleton_script.php, skeleton_list.php and skeleton_card.php -//-------------------------------------------------------------------- - -$skeletonfiles=array( - $path.'skeleton_script.php' => $classmin.'_script.php', - $path.'skeleton_list.php' => $classmin.'_list.php', - $path.'skeleton_card.php' => $classmin.'_card.php' - ); - -foreach ($skeletonfiles as $skeletonfile => $outfile) -{ - $sourcecontent=file_get_contents($skeletonfile); - if (! $sourcecontent) - { - print "\n"; - print "Error: Failed to read skeleton sample '".$skeletonfile."'\n"; - print "Try to run script from skeletons directory.\n"; - exit; - } - - // Define output variables - $targetcontent=$sourcecontent; - - // Substitute module name - $targetcontent=preg_replace('/dev\/skeletons/', $module, $targetcontent); - $targetcontent=preg_replace('/mymodule othermodule1 othermodule2/', $module, $targetcontent); - $targetcontent=preg_replace('/mymodule/', $module, $targetcontent); - - // Substitute class name - $targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent); - $targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent); - $targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent); - $targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent); - $targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent); - $targetcontent=preg_replace('/skeletons/', $classmin, $targetcontent); - $targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent); - - // Substitute comments - $targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent); - $targetcontent=preg_replace('/\s*\/\/\.\.\./', '', $targetcontent); - $targetcontent=preg_replace('/Put here some comments/','Initialy built by build_class_from_table on '.strftime('%Y-%m-%d %H:%M',mktime()), $targetcontent); - - // Substitute table name - $targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent); - - // Substitute GETPOST search_fieldx - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - if ($prop['isint']) $varprop.='$search_'.$prop['field']."=GETPOST('search_".$prop['field']."','int');\n"; - else $varprop.='$search_'.$prop['field']."=GETPOST('search_".$prop['field']."','alpha');\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote('$search_field1=GETPOST("search_field1");','/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote('$search_field2=GETPOST("search_field2");','/').'/', '', $targetcontent); - - // Substitute GETPOST fieldx - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - if ($prop['isint']) $varprop.="\t\$object->".$prop['field']."=GETPOST('".$prop['field']."','int');\n"; - else $varprop.="\t\$object->".$prop['field']."=GETPOST('".$prop['field']."','alpha');\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote('$object->prop1=GETPOST("field1");','/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote('$object->prop2=GETPOST("field2");','/').'/', '', $targetcontent); - - // Substitute reset search_field = ''; - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.='$search_'.$prop['field']."='';\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote('$search_field1=\'\';','/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote('$search_field2=\'\';','/').'/', '', $targetcontent); - - // Substitute fetch/select parameters - $targetcontent=preg_replace('/\$sql\s*\.= " t\.field1,";/', $varpropselect, $targetcontent); - $targetcontent=preg_replace('/\$sql\s*\.= " t\.field2";/', '', $targetcontent); - - // Substitute where for search - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.='if ($search_'.$prop['field'].') $sql.= natural_search("'.$prop['field'].'",$search_'.$prop['field'].');'."\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote('if ($search_field1) $sql.= natural_search("field1",$search_field1);','/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote('if ($search_field2) $sql.= natural_search("field2",$search_field2);','/').'/', '', $targetcontent); - - // substitute $params.= - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="if (\$search_".$prop['field']." != '') \$params.= '&search_".$prop['field']."='.urlencode(\$search_".$prop['field'].");\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote("if (\$search_field1 != '') \$params.= '&search_field1='.urlencode(\$search_field1);",'/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote("if (\$search_field2 != '') \$params.= '&search_field2='.urlencode(\$search_field2);",'/').'/', '', $targetcontent); - - // Substitute arrayfields - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="'t.".$prop['field']."'=>array('label'=>\$langs->trans(\"Field".$prop['field']."\"), 'checked'=>1),\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote("'t.field1'=>array('label'=>\$langs->trans(\"Field1\"), 'checked'=>1),",'/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote("'t.field2'=>array('label'=>\$langs->trans(\"Field2\"), 'checked'=>1),",'/').'/', '', $targetcontent); - - // Substitute print_liste_field_titre - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="if (! empty(\$arrayfields['t.".$prop['field']."']['checked'])) print_liste_field_titre(\$arrayfields['t.".$prop['field']."']['label'],\$_SERVER['PHP_SELF'],'t.".$prop['field']."','',\$params,'',\$sortfield,\$sortorder);\n"; - } - } - $targetcontent=preg_replace('/LIST_OF_TD_TITLE_FIELDS/', $varprop, $targetcontent); - - // Substitute fields title search - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="if (! empty(\$arrayfields['t.".$prop['field']."']['checked'])) print '';\n"; - } - } - $targetcontent=preg_replace('/LIST_OF_TD_TITLE_SEARCH/', $varprop, $targetcontent); - - // Substitute where for .fieldx. - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="if (! empty(\$arrayfields['t.".$prop['field']."']['checked'])) print ''.\$obj->".$prop['field'].".'';\n"; - } - } - $targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print ''.\$obj->field1.'';",'/').'/', $varprop, $targetcontent); - $targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print ''.\$obj->field2.'';",'/').'/', '', $targetcontent); - - // LIST_OF_TD_LABEL_FIELDS_CREATE - List of td for card view - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.="print ''.\$langs->trans(\"Field".$prop['field']."\").'';\n"; - } - } - $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_CREATE/', $varprop, $targetcontent); - - // LIST_OF_TD_LABEL_FIELDS_EDIT - List of td for card view - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $baseString = 'print "".\$langs->trans("Field%s")."%s."\">";'; - $varprop.= sprintf("\t ".$baseString." \n", $prop['field'], $prop['field'], $prop['field']); - } - } - $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_EDIT/', $varprop, $targetcontent); - - // LIST_OF_TD_LABEL_FIELDS_VIEW - List of td for card view - $varprop="\n"; - $cleanparam=''; - foreach($property as $key => $prop) - { - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) - { - $varprop.=sprintf("\t print ''.\$langs->trans(\"Field%s\").''.\$object->%s.'';\n",$prop['field'],$prop['field']); - } - } - $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_VIEW/', $varprop, $targetcontent); - - - // LIST_OF_TD_FIELDS_LIST - - - - // Build file - $fp=fopen($outfile,"w"); - if ($fp) - { - fputs($fp, $targetcontent); - fclose($fp); - print "File '".$outfile."' has been built in current directory.\n"; - } - else $error++; -} - - -// -------------------- END OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- - -print "You can now move generated files to store them into directory /yourmodule/class (for .class.php file) or /yourmodule.\n"; -return $error; diff --git a/htdocs/modulebuilder/oldskeletons/build_webservice_from_class.php b/htdocs/modulebuilder/oldskeletons/build_webservice_from_class.php deleted file mode 100755 index c91347a424d..00000000000 --- a/htdocs/modulebuilder/oldskeletons/build_webservice_from_class.php +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env php - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file dev/skeletons/build_webservice_from_class.php - * \ingroup core - * \brief Create a complete webservice file from CRUD functions of a PHP class - */ - -$sapi_type = php_sapi_name(); -$script_file = basename(__FILE__); -$path=dirname(__FILE__).'/'; - -// Test if batch mode -if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; -} - -// Include Dolibarr environment -require_once($path."../../htdocs/master.inc.php"); -// After this $db is a defined handler to database. - -// Main -$version='1.8'; -@set_time_limit(0); -$error=0; - -$langs->load("main"); - - -print "***** $script_file ($version) *****\n"; - - -// -------------------- START OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- - -// Check parameters -if (! isset($argv[1]) && ! isset($argv[2])) -{ - print "Usage: $script_file phpClassFile phpClassName\n"; - exit; -} - -// Show parameters -print 'Classfile='.$argv[1]."\n"; -print 'Classname='.$argv[2]."\n"; - -$classfile=$argv[1]; -$classname=$argv[2]; -$classmin=strtolower($classname); -$property=array(); -$targetcontent=''; - -// Load the class and read properties -require_once($classfile); - -$property=array(); -$class = new $classname($db); -$values=get_class_vars($classname); - -unset($values['db']); -unset($values['error']); -unset($values['errors']); -unset($values['element']); -unset($values['table_element']); -unset($values['table_element_line']); -unset($values['fk_element']); -unset($values['ismultientitymanaged']); - -$properties=array_keys($values); - -// Read skeleton_class.class.php file -$skeletonfile='skeleton_webservice_server.php'; -$sourcecontent=file_get_contents($skeletonfile); -if (! $sourcecontent) -{ - print "\n"; - print "Error: Failed to read skeleton sample '".$skeletonfile."'\n"; - print "Try to run script from skeletons directory.\n"; - exit; -} - -// Define output variables -$outfile='out.server_'.$classmin.'.php'; -$targetcontent=$sourcecontent; - - - -// Substitute class name -$targetcontent=preg_replace('/Skeleton/', $classname, $targetcontent); -$targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent); - -// Substitute declaration parameters -$varprop="\n"; -$cleanparam=''; -$i=0; - -while($i array('name'=>'".$properties[$i]."','type'=>'xsd:string')"; - $i++; - - if ($i == count($properties)) - $varprop.="\n"; - else - $varprop.=",\n"; -} - -$targetcontent=preg_replace('/\'prop1\'=>\'xxx\',/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\'prop2\'=>\'xxx\',/', '', $targetcontent); -// Substitute get method parameters -$varprop="\n"; -$cleanparam=''; -$i=0; - -while($i $".$classmin."->".$properties[$i]; - - $i++; - if ($i == count($properties)) - $varprop.="\n"; - else - $varprop.=",\n"; -} - -$targetcontent=preg_replace('/\'prop1\'=>\$'.$classmin.'->prop1,/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\'prop2\'=>\$'.$classmin.'->prop2,/', '', $targetcontent); - -// Substitute get method parameters -$varprop="\n\t\t"; -$cleanparam=''; -$i=0; - -while($i'.$properties[$i].';'; - - $i++; - if ($i == count($properties)) - $varprop.="\n"; - else - $varprop.="\n\t\t"; -} -$targetcontent=preg_replace('/\$newobject->prop1=\$'.$classmin.'->prop1;/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$newobject->prop2=\$'.$classmin.'->prop2;/', '', $targetcontent); - - - -// Build file -$fp=fopen($outfile,"w"); -if ($fp) -{ - fputs($fp, $targetcontent); - fclose($fp); - print "File '".$outfile."' has been built in current directory.\n"; -} -else $error++; - -// -------------------- END OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- - -print "You must rename files by removing the 'out.' prefix in their name.\n"; -return $error; diff --git a/htdocs/modulebuilder/oldskeletons/modMyModule.class.php b/htdocs/modulebuilder/oldskeletons/modMyModule.class.php deleted file mode 100644 index 4f994c7c654..00000000000 --- a/htdocs/modulebuilder/oldskeletons/modMyModule.class.php +++ /dev/null @@ -1,291 +0,0 @@ - - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2016 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \defgroup mymodule Module MyModule - * \brief Example of a module descriptor. - * Such a file must be copied into htdocs/mymodule/core/modules directory. - * \file htdocs/mymodule/core/modules/modMyModule.class.php - * \ingroup mymodule - * \brief Description and activation file for module MyModule - */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; - - -/** - * Description and activation class for module MyModule - */ -class modMyModule extends DolibarrModules -{ - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs,$conf; - - $this->db = $db; - - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'mymodule'; - - // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' - // It is used to group modules by family in module setup page - $this->family = "other"; - // Module position in the family - $this->module_position = 500; - // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '001', 'label' => $langs->trans("MyOwnFamily"))); - - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Description of module MyModule"; - $this->descriptionlong = "A very long description. Can be a full HTML content"; - $this->editor_name = 'Editor name'; - $this->editor_url = 'https://www.dolibarr.org'; - - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '1.0'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='generic'; - - // Defined all module parts (triggers, login, substitutions, menus, css, etc...) - // for default path (eg: /mymodule/core/xxxxx) (0=disable, 1=enable) - // for specific path of parts (eg: /mymodule/core/modules/barcode) - // for specific css file (eg: /mymodule/css/mymodule.css.php) - //$this->module_parts = array( - // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) - // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - // 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file - // 'js' => array('/mymodule/js/mymodule.js'), // Set this to relative path of js file if module must load a js on all pages - // 'hooks' => array('hookcontext1','hookcontext2',...) // Set here all hooks context managed by module. You can also set hook context 'all' - // 'dir' => array('output' => 'othermodulename'), // To force the default directories names - // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule')) // Set here all workflow context managed by module - // ); - $this->module_parts = array(); - - // Data directories to create when module is enabled. - // Example: this->dirs = array("/mymodule/temp"); - $this->dirs = array(); - - // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. - $this->config_page_url = array("mysetuppage.php@mymodule"); - - // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,0); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module - $this->langfiles = array("mylangfile@mymodule"); - - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) - // ); - $this->const = array(); - - // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname - // where objecttype can be - // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view - $this->tabs = array(); - - if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) - { - $conf->mymodule=new stdClass(); - $conf->mymodule->enabled=0; - } - - // Dictionaries - $this->dictionaries=array(); - /* Example: - $this->dictionaries=array( - 'langs'=>'mylangfile@mymodule', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) // Condition to show each dictionary - ); - */ - - // Boxes - // Add here list of php file(s) stored in core/boxes that contains class to show a box. - $this->boxes = array(); // List of boxes - // Example: - //$this->boxes=array( - // 0=>array('file'=>'myboxa.php@mymodule','note'=>'','enabledbydefaulton'=>'Home'), - // 1=>array('file'=>'myboxb.php@mymodule','note'=>''), - // 2=>array('file'=>'myboxc.php@mymodule','note'=>'') - //); - - // Cronjobs - $this->cronjobs = array(); // List of cron jobs entries to add - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'test'=>true), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'test'=>true) - // ); - - // Permissions - $this->rights = array(); // Permission array used by this module - $r=0; - - // Add here list of permission defined by an id, a label, a boolean and two constant strings. - // Example: - // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $r++; - - // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; - - // Add here entries to declare new menus - // - // Example to declare a new Top Menu entry and its Left menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - // 'type'=>'top', // This is a Top menu entry - // 'titre'=>'MyModule top menu', - // 'mainmenu'=>'mymodule', - // 'leftmenu'=>'mymodule', - // 'url'=>'/mymodule/pagetop.php', - // 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; - // - // Example to declare a Left Menu entry into an existing Top menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - // 'type'=>'left', // This is a Left menu entry - // 'titre'=>'MyModule left menu', - // 'mainmenu'=>'xxx', - // 'leftmenu'=>'mymodule', - // 'url'=>'/mymodule/pagelevel2.php', - // 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - // 'position'=>100, - // 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - // 'target'=>'', - // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; - - - // Exports - $r=1; - - // Example: - // $this->export_code[$r]=$this->rights_class.'_'.$r; - // $this->export_label[$r]='MyModule'; // Translation key (used only if key ExportDataset_xxx_z not found) - // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. - // $this->export_icon[$r]='generic:MyModule'; // Put here code of icon then string for translation key of module name - // $this->export_permission[$r]=array(array("mymodule","level1","level2")); - // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); - // $this->export_TypeFields_array[$r]=array('t.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric', 't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','p.accountancy_code_sell'=>'Text'); - // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); - // $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - // $this->export_sql_start[$r]='SELECT DISTINCT '; - // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; - // $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'; - // $this->export_sql_order[$r] .=' ORDER BY s.nom'; - // $r++; - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options='') - { - $sql = array(); - - //$this->_load_tables('/mymodule/sql/'); - - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); - - return $this->_remove($sql, $options); - } - -} - diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php b/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php deleted file mode 100644 index 97224b64da9..00000000000 --- a/htdocs/modulebuilder/oldskeletons/skeleton_api_class.class.php +++ /dev/null @@ -1,289 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - use Luracast\Restler\RestException; - - -/** - * API class for skeleton object - * - * @smart-auto-routing false - * @access protected - * @class DolibarrApiAccess {@requires user,external} - * - * - */ -class SkeletonApi extends DolibarrApi -{ - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'name' - ); - - /** - * @var Skeleton $skeleton {@type Skeleton} - */ - public $skeleton; - - /** - * Constructor - * - * @url GET skeleton/ - * - */ - function __construct() - { - global $db, $conf; - $this->db = $db; - $this->skeleton = new Skeleton($this->db); - } - - /** - * Get properties of a skeleton object - * - * Return an array with skeleton informations - * - * @param int $id ID of skeleton - * @return array|mixed data without useless information - * - * @url GET skeleton/{id} - * @throws RestException - */ - function get($id) - { - if(! DolibarrApiAccess::$user->rights->skeleton->read) { - throw new RestException(401); - } - - $result = $this->skeleton->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Skeleton not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('skeleton',$this->skeleton->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - return $this->_cleanObjectDatas($this->skeleton); - } - - /** - * List skeletons - * - * Get a list of skeletons - * - * @param int $mode Use this param to filter list - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') or (t.import_key:=:'20160101')" - * @return array Array of skeleton objects - * - * @url GET /skeletons/ - */ - function index($mode, $sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') { - global $db, $conf; - - $obj_ret = array(); - - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; - - // If the internal user must only see his customers, force searching by him - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - - $sql = "SELECT s.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."skeleton as s"; - - 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.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE s.fk_stcomm = st.id"; - - // Example of use $mode - //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').')'; - 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 - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; - - $sql.= $db->plimit($limit + 1, $offset); - } - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - while ($i < $num) - { - $obj = $db->fetch_object($result); - $skeleton_static = new Skeleton($db); - if($skeleton_static->fetch($obj->rowid)) { - $obj_ret[] = parent::_cleanObjectDatas($skeleton_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieve skeleton list'); - } - if( ! count($obj_ret)) { - throw new RestException(404, 'No skeleton found'); - } - return $obj_ret; - } - - /** - * Create skeleton object - * - * @param array $request_data Request datas - * @return int ID of skeleton - * - * @url POST skeleton/ - */ - function post($request_data = NULL) - { - if(! DolibarrApiAccess::$user->rights->skeleton->create) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); - - foreach($request_data as $field => $value) { - $this->skeleton->$field = $value; - } - if( ! $this->skeleton->create(DolibarrApiAccess::$user)) { - throw new RestException(500); - } - return $this->skeleton->id; - } - - /** - * Update skeleton - * - * @param int $id Id of skeleton to update - * @param array $request_data Datas - * @return int - * - * @url PUT skeleton/{id} - */ - function put($id, $request_data = NULL) - { - if(! DolibarrApiAccess::$user->rights->skeleton->create) { - throw new RestException(401); - } - - $result = $this->skeleton->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Skeleton not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('skeleton',$this->skeleton->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - foreach($request_data as $field => $value) { - $this->skeleton->$field = $value; - } - - if($this->skeleton->update($id, DolibarrApiAccess::$user)) - return $this->get ($id); - - return false; - } - - /** - * Delete skeleton - * - * @param int $id Skeleton ID - * @return array - * - * @url DELETE skeleton/{id} - */ - function delete($id) - { - if(! DolibarrApiAccess::$user->rights->skeleton->supprimer) { - throw new RestException(401); - } - $result = $this->skeleton->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Skeleton not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('skeleton',$this->skeleton->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - if( !$this->skeleton->delete($id)) - { - throw new RestException(500); - } - - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Skeleton deleted' - ) - ); - - } - - /** - * Validate fields before create or update object - * - * @param array $data Data to validate - * @return array - * - * @throws RestException - */ - function _validate($data) - { - $skeleton = array(); - foreach (SkeletonApi::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $skeleton[$field] = $data[$field]; - } - return $skeleton; - } -} diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_card.php b/htdocs/modulebuilder/oldskeletons/skeleton_card.php deleted file mode 100644 index 49683af79c8..00000000000 --- a/htdocs/modulebuilder/oldskeletons/skeleton_card.php +++ /dev/null @@ -1,604 +0,0 @@ - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file dev/skeletons/skeleton_card.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example of a php page - * Put here some comments - */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs -include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -dol_include_once('/mymodule/class/skeleton_class.class.php'); - -// Load traductions files requiredby by page -$langs->load("mymodule"); -$langs->load("other"); - -// Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$cancel = GETPOST('cancel'); -$backtopage = GETPOST('backtopage'); -$myparam = GETPOST('myparam','alpha'); - -$search_field1=GETPOST("search_field1"); -$search_field2=GETPOST("search_field2"); - -if (empty($action) && empty($id) && empty($ref)) $action='view'; - -// Protection if external user -if ($user->societe_id > 0) -{ - //accessforbidden(); -} -//$result = restrictedArea($user, 'mymodule', $id); - - -$object = new Skeleton_Class($db); -$extrafields = new ExtraFields($db); - -// fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('skeleton')); - - - -/* - * ACTIONS - * - * Put here all code to do according to value of "action" parameter - */ - -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - -if (empty($reshook)) -{ - if ($cancel) - { - if ($action != 'addlink') - { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); - header("Location: ".$urltogo); - exit; - } - if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); - $action=''; - } - - // Action to add record - if ($action == 'add' && ! empty($user->rights->mymodule->create)) - { - if ($cancel) - { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); - header("Location: ".$urltogo); - exit; - } - - $error=0; - - /* object_prop_getpost_prop */ - $object->prop1=GETPOST("field1"); - $object->prop2=GETPOST("field2"); - - if (empty($object->ref)) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors'); - } - - if (! $error) - { - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); - header("Location: ".$urltogo); - exit; - } - { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='create'; - } - } - else - { - $action='create'; - } - } - - // Action to update record - if ($action == 'update' && ! empty($user->rights->mymodule->create)) - { - $error=0; - - $object->prop1=GETPOST("field1"); - $object->prop2=GETPOST("field2"); - - if (empty($object->ref)) - { - $error++; - setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors'); - } - - if (! $error) - { - $result=$object->update($user); - if ($result > 0) - { - $action='view'; - } - else - { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='edit'; - } - } - else - { - $action='edit'; - } - } - - // Action to delete - if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete)) - { - $result=$object->delete($user); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".dol_buildpath('/mymodule/list.php',1)); - exit; - } - else - { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } -} - - - - -/* - * VIEW - * - * Put here all code to build page - */ - -$form=new Form($db); - -llxHeader('','MyPageName',''); - - -// Put here content of your page - -// Example : Adding jquery code -print ''; - - -// Part to create -if ($action == 'create') -{ - print load_fiche_titre($langs->trans("NewMyModule")); - - print '
'; - print ''; - print ''; - - dol_fiche_head(); - - print ''."\n"; - // print ''; - // LIST_OF_TD_LABEL_FIELDS_CREATE - print '
'.$langs->trans("Label").'
'."\n"; - - dol_fiche_end(); - - print '
 
'; - - print '
'; -} - - - -// Part to edit record -if (($id || $ref) && $action == 'edit') -{ - print load_fiche_titre($langs->trans("MyModule")); - - print '
'; - print ''; - print ''; - print ''; - - dol_fiche_head(); - - print ''."\n"; - // print ''; - // LIST_OF_TD_LABEL_FIELDS_EDIT - print '
'.$langs->trans("Label").'
'; - - dol_fiche_end(); - - print '
'; - print '   '; - print '
'; - - print '
'; -} - - - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ - $res = $object->fetch_optionals($object->id, $extralabels); - - $head = mymodule_prepare_head($object); - dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - } - - // Confirmation of action xxxx - if ($action == 'xxx') - { - $formquestion=array(); - /* - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); - }*/ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - - if (! $formconfirm) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - - - // Object card - // ------------------------------------------------------------ - - $linkback = '' . $langs->trans("BackToList") . ''; - - - $morehtmlref='
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->creer) - { - if ($action != 'classify') - { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } - } - */ - $morehtmlref.='
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - print '
'; - print ''."\n"; - // print ''; - // LIST_OF_TD_LABEL_FIELDS_VIEW - - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'.$langs->trans("Label").''.$object->label.'
'; - print '
'; - print '
'; - print '
'; - print '
'; - print ''; - - - - print '
'; - print '
'; - print '
'; - print '
'; - - print '

'; - - dol_fiche_end(); - - - // Buttons for actions - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook)) - { - if ($user->rights->mymodule->write) - { - print ''."\n"; - } - - if ($user->rights->mymodule->delete) - { - print ''."\n"; - } - } - print '
'."\n"; - } - - - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - if ($action != 'presend') - { - print '
'; - print ''; // ancre - // Documents - $comref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->mymodule->dir_output . '/' . $comref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->mymodule->creer; - $delallowed = $user->rights->mymodule->supprimer; - print $formfile->showdocuments('mymodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - - print '
'; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'order', $socid); - - print '
'; - } - - - /* - * Action presend - */ - /* - if ($action == 'presend') - { - $object->fetch_projet(); - - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - - if (!empty($newlang)) - { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->load('commercial'); - } - - // Build document if it not exists - if (! $file || ! is_readable($file)) { - $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) { - dol_print_error($db, $object->error, $object->errors); - exit(); - } - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans('SendOrderByMail')); - - dol_fiche_head(''); - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - $formmail->trackid='ord'.$object->id; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom = 1; - $liste = array(); - foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) - $liste [$key] = $value; - $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; - $formmail->withtocc = $liste; - $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); - } - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - // Tableau des substitutions - $formmail->setSubstitFromObject($object); - $formmail->substit ['__ORDERREF__'] = $object->ref; - - $custcontact = ''; - $contactarr = array(); - $contactarr = $object->liste_contact(- 1, 'external'); - - if (is_array($contactarr) && count($contactarr) > 0) - { - foreach ($contactarr as $contact) - { - if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label - $contactstatic = new Contact($db); - $contactstatic->fetch($contact ['id']); - $custcontact = $contactstatic->getFullName($langs, 1); - } - } - - if (! empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; - } - } - - // Tableau des parametres complementaires - $formmail->param['action'] = 'send'; - $formmail->param['models'] = 'order_send'; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['orderid'] = $object->id; - $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; - - // Init list of files - if (GETPOST("mode") == 'init') { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); - } - - // Show form - print $formmail->get_form(); - - dol_fiche_end(); - }*/ -} - - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php b/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php deleted file mode 100644 index ea552ad85f9..00000000000 --- a/htdocs/modulebuilder/oldskeletons/skeleton_class.class.php +++ /dev/null @@ -1,606 +0,0 @@ - - * Copyright (C) 2014-2016 Juanjo Menent - * Copyright (C) 2015 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file modulebuilder/skeletons/skeleton_class.class.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) - */ - -// Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - -/** - * Class Skeleton_Class - * - * Put here description of your class. - */ -class Skeleton_Class extends CommonObject -{ - /** - * @var string Id to identify managed object - */ - public $element = 'skeleton'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'skeleton'; - /** - * @var array Array with all fields and their property - */ - public $picto = 'generic'; - /** - * @var array Array with all fields and their property - */ - public $fields; - - /** - * @var mixed Sample property 1 - */ - public $prop1; - /** - * @var mixed Sample property 2 - */ - public $prop2; - - //... - - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - - public $table_element_line = 'skeletondet'; - public $class_element_line = 'SkeletonLine'; - public $fk_element = 'fk_skeleton'; - /** - * @var Skeleton_ClassLine[] Lines - */ - public $lines = array(); - - - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } - - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - // Clean parameters - if (isset($this->prop1)) { - $this->prop1 = trim($this->prop1); - } - if (isset($this->prop2)) { - $this->prop2 = trim($this->prop2); - } - //... - - // Check parameters - // Put here code to add control on parameters values - - // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql .= ' field1,'; - $sql .= ' field2'; - //... - $sql .= ') VALUES ('; - $sql .= ' \'' . $this->prop1 . '\','; - $sql .= ' \'' . $this->prop2 . '\''; - //... - $sql .= ')'; - - $this->db->begin(); - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return $this->id; - } - } - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= ' t.field1,'; - $sql .= ' t.field2'; - //... - $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') . ")"; - } - if (null !== $ref) { - $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; - } else { - $sql .= ' AND t.rowid = ' . $id; - } - - $resql = $this->db->query($sql); - if ($resql) { - $numrows = $this->db->num_rows($resql); - if ($numrows) { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->prop1 = $obj->field1; - $this->prop2 = $obj->field2; - //... - } - - // Retrieve all extrafields for invoice - // fetch optionals attributes and labels - /* - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); - */ - - // $this->fetch_lines(); - - $this->db->free($resql); - - if ($numrows) { - return 1; - } else { - return 0; - } - } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - - return - 1; - } - } - - /** - * Load object in memory from the database - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int <0 if KO, >0 if OK - */ - public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= ' t.field1,'; - $sql .= ' t.field2'; - //... - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; - } - } - $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity('skeleton') . ")"; - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); - } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield,$sortorder); - } - if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - - while ($obj = $this->db->fetch_object($resql)) { - $line = new self($this->db); - - $line->id = $obj->rowid; - $line->prop1 = $obj->field1; - $line->prop2 = $obj->field2; - //... - } - $this->db->free($resql); - - return $num; - } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - - return - 1; - } - } - - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - // Clean parameters - if (isset($this->prop1)) { - $this->prop1 = trim($this->prop1); - } - if (isset($this->prop2)) { - $this->prop2 = trim($this->prop2); - } - //... - - // Check parameters - // Put here code to add a control on parameters values - - // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").","; - $sql .= " field2=".(isset($this->field2)?"'".$this->db->escape($this->field2)."'":"null").""; - //... - $sql .= ' WHERE rowid=' . $this->id; - - $this->db->begin(); - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - if (!$error && !$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return 1; - } - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - $this->db->begin(); - - if (!$error) { - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_DELETE',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - } - - // If you need to delete child tables to, you can insert them here - - if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return 1; - } - } - - /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * - * @return int New id of clone - */ - public function createFromClone($fromid) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - global $user; - $error = 0; - $object = new Skeleton_Class($this->db); - - $this->db->begin(); - - // Load source object - $object->fetch($fromid); - // Reset object - $object->id = 0; - - // Clear fields - // ... - - // Create clone - $result = $object->create($user); - - // Other options - if ($result < 0) { - $error ++; - $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - // End - if (!$error) { - $this->db->commit(); - - return $object->id; - } else { - $this->db->rollback(); - - return - 1; - } - } - - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to - * @param int $notooltip 1=Disable tooltip - * @param int $maxlen Max length of visible user name - * @param string $morecss Add more css on link - * @return string String with URL - */ - function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') - { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; - - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - - $result = ''; - $companylink = ''; - - $label = '' . $langs->trans("MyModule") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - - $url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id; - - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowProject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); - - $linkstart = ''; - $linkend=''; - - if ($withpicto) - { - $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result.=' '; - } - $result.= $linkstart . $this->ref . $linkend; - return $result; - } - - /** - * Retourne le libelle du status d'un user (actif, inactif) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->status,$mode); - } - - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto - * @return string Label of status - */ - static function LibStatut($status,$mode=0) - { - global $langs; - - if ($mode == 0) - { - $prefix=''; - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); - } - if ($mode == 1) - { - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); - } - if ($mode == 2) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 3) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); - } - if ($mode == 4) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); - } - if ($mode == 6) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); - } - } - - - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - $this->id = 0; - $this->prop1 = 'prop1'; - $this->prop2 = 'prop2'; - } - -} - -/** - * Class Skeleton_ClassLine - */ -class Skeleton_ClassLine -{ - /** - * @var int ID - */ - public $id; - /** - * @var mixed Sample line property 1 - */ - public $prop1; - /** - * @var mixed Sample line property 2 - */ - public $prop2; -} diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_list.php b/htdocs/modulebuilder/oldskeletons/skeleton_list.php deleted file mode 100644 index 842fdf32457..00000000000 --- a/htdocs/modulebuilder/oldskeletons/skeleton_list.php +++ /dev/null @@ -1,570 +0,0 @@ - - * Copyright (C) 2014-2016 Juanjo Menent - * Copyright (C) 2016 Jean-François Ferry - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file dev/skeletons/skeleton_list.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example of a php page - * Put here some comments - */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs -require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/mymodule/class/skeleton_class.class.php'); - -// Load traductions files requiredby by page -$langs->load("mymodule"); -$langs->load("other"); - -$action=GETPOST('action','alpha'); -$massaction=GETPOST('massaction','alpha'); -$show_files=GETPOST('show_files','int'); -$confirm=GETPOST('confirm','alpha'); -$toselect = GETPOST('toselect', 'array'); - -$id = GETPOST('id','int'); -$backtopage = GETPOST('backtopage'); -$myparam = GETPOST('myparam','alpha'); - -$search_all=trim(GETPOST("sall")); -$search_field1=GETPOST("search_field1"); -$search_field2=GETPOST("search_field2"); -$search_myfield=GETPOST('search_myfield'); -$optioncss = GETPOST('optioncss','alpha'); - -// Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortfield) $sortfield="t.rowid"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; - -// Protection if external user -$socid=0; -if ($user->societe_id > 0) -{ - $socid = $user->societe_id; - //accessforbidden(); -} - -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymodulelist'; - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('mymodulelist')); -$extrafields = new ExtraFields($db); - -// fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('mymodule'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); - -// List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 't.ref'=>'Ref', - 't.note_public'=>'NotePublic', -); -if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate"; - -// Definition of fields for list -$arrayfields=array( - 't.field1'=>array('label'=>"Field1", 'checked'=>1), - 't.field2'=>array('label'=>"Field2", 'checked'=>1), - //'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), - 't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - //'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), -); -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) -{ - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } -} - - -$object=new Skeleton_Class($db); - - - - -/* - * ACTIONS - * - * Put here all code to do according to value of "action" parameter - */ - -if (GETPOST('cancel')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } - -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - -if (empty($reshook)) -{ - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers - { - $search_field1=''; - $search_field2=''; - $search_date_creation=''; - $search_date_update=''; - $toselect=''; - $search_array_options=array(); - } - - // Mass actions - $objectclass='Skeleton'; - $objectlabel='Skeleton'; - $permtoread = $user->rights->skeleton->read; - $permtodelete = $user->rights->skeleton->delete; - $uploaddir = $conf->skeleton->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; -} - - - -/* - * VIEW - * - * Put here all code to build page - */ - -$now=dol_now(); - -$form=new Form($db); - -//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; -$help_url=''; -$title = $langs->trans('MyModuleListTitle'); - -// Put here content of your page - -// Example : Adding jquery code -print ''; - - -$sql = "SELECT"; -$sql.= " t.rowid,"; -$sql.= " t.field1,"; -$sql.= " t.field2"; -// Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); -// Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook -$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').")"; -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); -// Add where from extra fields -foreach ($search_array_options as $key => $val) -{ - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } -} -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.=$db->order($sortfield,$sortorder); - -// Count total nb of records -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); -} - -$sql.= $db->plimit($limit+1, $offset); - -dol_syslog($script_file, LOG_DEBUG); -$resql=$db->query($sql); -if (! $resql) -{ - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); - -// Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/skeleton/card.php?id='.$id); - exit; -} - -llxHeader('', $title, $help_url); - -$arrayofselected=is_array($toselect)?$toselect:array(); - -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); -if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); -if ($optioncss != '') $param.='&optioncss='.$optioncss; -// Add $param from extra fields -foreach ($search_array_options as $key => $val) -{ - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); -} - -$arrayofmassactions = array( - 'presend'=>$langs->trans("SendByMail"), - 'builddoc'=>$langs->trans("PDFMerge"), -); -if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); -if ($massaction == 'presend') $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); - -print '
'; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); - -if ($sall) -{ - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); -} - -$moreforfilter = ''; -$moreforfilter.='
'; -$moreforfilter.= $langs->trans('MyFilter') . ': '; -$moreforfilter.= '
'; - -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; - -if (! empty($moreforfilter)) -{ - print '
'; - print $moreforfilter; - print '
'; -} - -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - -print '
'; -print ''."\n"; - -// Fields title -print ''; -// LIST_OF_TD_TITLE_FIELDS -//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); -//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) -{ - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } -} -// Hook fields -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); -print ''."\n"; - -// Fields title search -print ''; -// LIST_OF_TD_TITLE_SEARCH -//if (! empty($arrayfields['t.field1']['checked'])) print ''; -//if (! empty($arrayfields['t.field2']['checked'])) print ''; -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) -{ - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } -} -// Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) -{ - // Date creation - print ''; -} -if (! empty($arrayfields['t.tms']['checked'])) -{ - // Date modification - print ''; -} -/*if (! empty($arrayfields['u.statut']['checked'])) -{ - // Status - print ''; -}*/ -// Action column -print ''; -print ''."\n"; - - -// Detect if we need a fetch on each output line -$needToFetchEachLine=0; -foreach ($extrafields->attribute_computed as $key => $val) -{ - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object -} - - -$i=0; -$totalarray=array(); -while ($i < min($num, $limit)) -{ - $obj = $db->fetch_object($resql); - if ($obj) - { - // Show here line of result - print ''; - // LIST_OF_TD_FIELDS_LIST - /* - if (! empty($arrayfields['t.field1']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.field2']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - }*/ - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['t.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - /* - if (! empty($arrayfields['u.statut']['checked'])) - { - $userstatic->statut=$obj->statut; - print ''; - }*/ - - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; - - print ''; - } - $i++; -} - -// Show total line -if (isset($totalarray['totalhtfield'])) -{ - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit) print ''; - else print ''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; - else print ''; - } - print ''; -} - -$db->free($resql); - -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print '
'; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - print ''; - print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; -$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); -print $searchpicto; -print '
'.$obj->field1.''.$obj->field2.''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$userstatic->getLibStatut(3).''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
'."\n"; -print '
'."\n"; - -print '
'."\n"; - - -if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) -{ - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); - - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->lire; - - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); -} -else -{ - print '
'.$langs->trans("ShowTempMassFilesArea").''; -} - - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_script.php b/htdocs/modulebuilder/oldskeletons/skeleton_script.php deleted file mode 100644 index 5eb1565d4a3..00000000000 --- a/htdocs/modulebuilder/oldskeletons/skeleton_script.php +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env php - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file dev/skeletons/skeleton_script.php - * \ingroup mymodule - * \brief This file is an example for a command line script - * Put here some comments - */ - -$sapi_type = php_sapi_name(); -$script_file = basename(__FILE__); -$path=dirname(__FILE__).'/'; - -// Test if batch mode -if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit(-1); -} - -// Global variables -$version='1.0'; -$error=0; - - -// -------------------- START OF YOUR CODE HERE -------------------- -@set_time_limit(0); // No timeout for this script -define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". - -// Include and load Dolibarr environment variables -require_once($path."../../htdocs/master.inc.php"); -// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). -// $user is created but empty. - -//$langs->setDefaultLang('en_US'); // To change default language of $langs -$langs->load("main"); // To load language file for default language - -// Load user and its permissions -$result=$user->fetch('','admin'); // Load user for login 'admin'. Comment line to run as anonymous user. -if (! $result > 0) { dol_print_error('',$user->error); exit; } -$user->getrights(); - - -print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -if (! isset($argv[1])) { // Check parameters - print "Usage: ".$script_file." param1 param2 ...\n"; - exit(-1); -} -print '--- start'."\n"; -print 'Argument 1='.$argv[1]."\n"; -print 'Argument 2='.$argv[2]."\n"; - - -// Start of transaction -$db->begin(); - - -// Examples for manipulating class skeleton_class -require_once(DOL_DOCUMENT_ROOT."/../dev/skeletons/skeleton_class.class.php"); -$myobject=new Skeleton_Class($db); - -// Example for inserting creating object in database -/* -dol_syslog($script_file." CREATE", LOG_DEBUG); -$myobject->prop1='value_prop1'; -$myobject->prop2='value_prop2'; -$id=$myobject->create($user); -if ($id < 0) { $error++; dol_print_error($db,$myobject->error); } -else print "Object created with id=".$id."\n"; -*/ - -// Example for reading object from database -/* -dol_syslog($script_file." FETCH", LOG_DEBUG); -$result=$myobject->fetch($id); -if ($result < 0) { $error; dol_print_error($db,$myobject->error); } -else print "Object with id=".$id." loaded\n"; -*/ - -// Example for updating object in database ($myobject must have been loaded by a fetch before) -/* -dol_syslog($script_file." UPDATE", LOG_DEBUG); -$myobject->prop1='newvalue_prop1'; -$myobject->prop2='newvalue_prop2'; -$result=$myobject->update($user); -if ($result < 0) { $error++; dol_print_error($db,$myobject->error); } -else print "Object with id ".$myobject->id." updated\n"; -*/ - -// Example for deleting object in database ($myobject must have been loaded by a fetch before) -/* -dol_syslog($script_file." DELETE", LOG_DEBUG); -$result=$myobject->delete($user); -if ($result < 0) { $error++; dol_print_error($db,$myobject->error); } -else print "Object with id ".$myobject->id." deleted\n"; -*/ - - -// An example of a direct SQL read without using the fetch method -/* -$sql = "SELECT field1, field2"; -$sql.= " FROM ".MAIN_DB_PREFIX."skeleton"; -$sql.= " WHERE field3 = 'xxx'"; -$sql.= " ORDER BY field1 ASC"; - -dol_syslog($script_file, LOG_DEBUG); -$resql=$db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - // You can use here results - print $obj->field1; - print $obj->field2; - } - $i++; - } - } -} -else -{ - $error++; - dol_print_error($db); -} -*/ - - -// -------------------- END OF YOUR CODE -------------------- - -if (! $error) -{ - $db->commit(); - print '--- end ok'."\n"; -} -else -{ - print '--- end error code='.$error."\n"; - $db->rollback(); -} - -$db->close(); // Close $db database opened handler - -exit($error); diff --git a/htdocs/modulebuilder/oldskeletons/skeleton_webservice_server.php b/htdocs/modulebuilder/oldskeletons/skeleton_webservice_server.php deleted file mode 100644 index 54a050ff9da..00000000000 --- a/htdocs/modulebuilder/oldskeletons/skeleton_webservice_server.php +++ /dev/null @@ -1,272 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/webservices/server_skeleton.php - * \brief File that is entry point to call Dolibarr WebServices - * \version $Id: server_skeleton.php,v 1.7 2010/12/19 11:49:37 eldy Exp $ - */ - -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); - -require_once("../master.inc.php"); -require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP -require_once(DOL_DOCUMENT_ROOT."/core/lib/ws.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/skeleton/class/skeleton.class.php"); - - -dol_syslog("Call Skeleton webservices interfaces"); - -// Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive",'WebServices').'.

'; - print $langs->trans("ToActivateModule"); - exit; -} - -// Create the soap Object -$server = new nusoap_server(); -$server->soap_defencoding='UTF-8'; -$server->decode_utf8=false; -$ns='http://www.dolibarr.org/ns/'; -$server->configureWSDL('WebServicesDolibarrSkeleton',$ns); -$server->wsdl->schemaTargetNamespace=$ns; - - -// Define WSDL Authentication object -$server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), - 'login' => array('name'=>'login','type'=>'xsd:string'), - 'password' => array('name'=>'password','type'=>'xsd:string'), - 'entity' => array('name'=>'entity','type'=>'xsd:string'), - ) -); - -// Define WSDL Return object -$server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), - ) -); - -// Define other specific objects -$server->wsdl->addComplexType( - 'skeleton', - 'complexType', - 'struct', - 'all', - '', - array( - 'prop1'=>'xxx', - 'prop2'=>'xxx', - //... - ) -); - - - -// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped -// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model. -// http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ -$styledoc='rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages) -$styleuse='encoded'; // encoded/literal/literal wrapped -// Better choice is document/literal wrapped but literal wrapped not supported by nusoap. - - -// Register WSDL -$server->register( - 'getSkeleton', - // Entry values - array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), - // Exit values - array('result'=>'tns:result','skeleton'=>'tns:skeleton'), - $ns, - $ns.'#getSkeleton', - $styledoc, - $styleuse, - 'WS to get skeleton' -); - -// Register WSDL -$server->register( - 'createSkeleton', - // Entry values - array('authentication'=>'tns:authentication','skeleton'=>'tns:skeleton'), - // Exit values - array('result'=>'tns:result','id'=>'xsd:string'), - $ns, - $ns.'#createSkeleton', - $styledoc, - $styleuse, - 'WS to create a skeleton' -); - - - - -/** - * Get Skeleton - * - * @param array $authentication Array of authentication information - * @param int $id Id of object - * @param string $ref Ref of object - * @param string $ref_ext Ref external of object - * @return mixed - */ -function getSkeleton($authentication,$id,$ref='',$ref_ext='') -{ - global $db,$conf,$langs; - - dol_syslog("Function: getSkeleton login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - - if ($authentication['entity']) $conf->entity=$authentication['entity']; - - // Init and check authentication - $objectresp=array(); - $errorcode='';$errorlabel=''; - $error=0; - $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); - // Check parameters - if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { - $error++; - $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; - } - - if (! $error) - { - $fuser->getrights(); - - if ($fuser->rights->skeleton->read) - { - $skeleton=new Skeleton($db); - $result=$skeleton->fetch($id,$ref,$ref_ext); - if ($result > 0) - { - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'skeleton'=>array( - 'prop1'=>$skeleton->prop1, - 'prop2'=>$skeleton->prop2, - //... - ) - ); - } - else - { - $error++; - $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; - } - } - else - { - $error++; - $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request'; - } - } - - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } - - return $objectresp; -} - - -/** - * Create Skeleton - * - * @param array $authentication Array of authentication information - * @param Skeleton $skeleton $skeleton - * @return array Array result - */ -function createSkeleton($authentication,$skeleton) -{ - global $db,$conf,$langs; - - $now=dol_now(); - - dol_syslog("Function: createSkeleton login=".$authentication['login']); - - if ($authentication['entity']) $conf->entity=$authentication['entity']; - - // Init and check authentication - $objectresp=array(); - $errorcode='';$errorlabel=''; - $error=0; - $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); - // Check parameters - - - if (! $error) - { - $newobject=new Skeleton($db); - $newobject->prop1=$skeleton->prop1; - $newobject->prop2=$skeleton->prop2; - //... - - $db->begin(); - - $result=$newobject->create($fuser); - if ($result <= 0) - { - $error++; - } - - if (! $error) - { - $db->commit(); - $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref); - } - else - { - $db->rollback(); - $error++; - $errorcode='KO'; - $errorlabel=$newobject->error; - } - } - - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } - - return $objectresp; -} - -// Return the results. -$server->service(file_get_contents("php://input")); From a25facef7ce7c6aeae7f1116439a278bd60494da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 3 Jun 2017 11:49:59 +0200 Subject: [PATCH 4/7] Fix: use 0 instead false --- ChangeLog | 2 +- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 10 +++++----- htdocs/accountancy/customer/lines.php | 4 ++-- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/card.php | 2 +- htdocs/accountancy/expensereport/index.php | 6 +++--- htdocs/accountancy/expensereport/lines.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- .../accountancy/journal/expensereportsjournal.php | 2 +- htdocs/accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/supplier/card.php | 2 +- htdocs/accountancy/supplier/index.php | 6 +++--- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- .../compta/deplacement/class/deplacement.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/contrat/index.php | 14 +++++++------- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 6 +++--- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/class/task.class.php | 2 +- 23 files changed, 40 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06650828623..fd431b407d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,7 +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) +* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') ***** ChangeLog for 5.0.3 compared to 5.0.2 ***** FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index b32486038af..c436fdfd088 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index ab10efde376..deca83b6f12 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; @@ -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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // 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 f5e8881e51b..9c88a417bac 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; @@ -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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); // Count total nb of records diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index cc2495a0f9e..9e534d55af7 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // 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 201e61e97ab..1c94b0b649a 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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 933cd6c3303..e9ce1b2e729 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -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', false) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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 c678795bf2d..ca2369a11e4 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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 4b0a379faf3..01acf759260 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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 f1f0ac4b0de..9ed0435f298 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // 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 e7f887547d3..a8dd976ba9e 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // 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 863c68c5746..69a7855dfd2 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // 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 fdaa70e22ca..805c5e40420 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -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', false) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // 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', false) . ")"; // We don't share object for accountancy + $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // 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 22982a6f087..06308a67fa1 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // 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 30a42410d8b..7ed1453982e 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', false) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 6fb146c205b..ea8b85c55af 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', false).")"; + $sql.= " WHERE entity IN (".getEntity('deplacement', 0).")"; if ($ref) $sql.= " AND ref ='".$this->db->escape($ref)."'"; else $sql.= " AND rowid = ".$id; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 86e8dd893f5..880832f80e1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3965,7 +3965,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', false).")"; + $sql.= " WHERE f.entity in (".getEntity('facture', 0).")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d40e41013dd..2b0dd2f2924 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', false).")"; + $sql.= " AND entity IN (".getEntity('contract', 0).")"; } else $sql.= " WHERE rowid=".$id; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 608a1167fba..509467cc822 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', false).")"; +$sql.= " AND c.entity IN (".getEntity('contract', 0).")"; 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', false).")"; +$sql.= " AND c.entity IN (".getEntity('contract', 0).")"; 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', false).")"; + $sql.= " AND c.entity IN (".getEntity('contract', 0).")"; $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', false).")"; +$sql.= " AND c.entity IN (".getEntity('contract', 0).")"; $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', false).")"; +$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")"; $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', false).")"; +$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")"; $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', false).")"; +$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")"; $sql.= " AND c.statut = 1"; $sql.= " AND cd.statut = 4"; $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b2f831a1cbb..7b112a2d333 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4361,7 +4361,7 @@ class Form $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; - $sql.= " WHERE entity IN ('".getEntity('mutlicurrency', false)."')"; + $sql.= " WHERE entity IN ('".getEntity('mutlicurrency', 0)."')"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0d953a22be6..860d3fcfb1c 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', false).")"; + $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; $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', false).")"; + $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; $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', false).")"; + $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; $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/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ba394f1b8e6..ca3a1157e74 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -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', false).')'; + $sql.= " AND p.entity IN (".getEntity('project', 0).')'; 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.")"; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index b751f8f0478..227ea68d41b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -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', false).')'; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; $sql.= " AND p.fk_statut = 1"; $sql.= " AND t.fk_projet = p.rowid"; $sql.= " AND t.progress < 100"; // tasks to do From 707a9e40c0e28ab48a9d48c362d40ce76894d0bb Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 6 Jun 2017 12:00:47 +0200 Subject: [PATCH 5/7] Fix can't use search on all extrafields on list --- htdocs/product/inventory/listview.class.php | 8 ++++++++ htdocs/product/list-with-listview.php | 2 +- htdocs/societe/list.php | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/listview.class.php b/htdocs/product/inventory/listview.class.php index 1c03d0b524f..ac5ec68f51a 100644 --- a/htdocs/product/inventory/listview.class.php +++ b/htdocs/product/inventory/listview.class.php @@ -41,6 +41,11 @@ class Listview $this->totalRow=0; $this->TField=array(); + + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $this->extrafields = new ExtraFields($this->db); + $this->extralabels = $this->extrafields->fetch_name_optionals_label('product'); + $this->search_array_options=$this->extrafields->getOptionalsFromPost($this->extralabels,'','search_'); } /** @@ -808,6 +813,9 @@ class Listview } else { + // Overrive search from extrafields + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + if (isset($this->extralabels[$field])) $TParam['search'][$field] = $this->extrafields->showInputField($field, $this->search_array_options['search_options_'.$field], '', '', 'search_'); $visible = 1; } diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 1ebbf256c9c..6cd8533778e 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -611,7 +611,7 @@ else } //var_dump($arraytitle,$arrayhide); - $list=new Listview($db, 'products'); + $list=new Listview($db, 'product'); $listHTML = $list->render($sql,array( 'list'=>array( 'title'=>$texte diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 51d4b41e6bb..29c1ab3bd4c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -840,6 +840,11 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } From c041fe21650458783bcee40b7f04ef7a95468df1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 7 Jun 2017 06:03:52 +0200 Subject: [PATCH 6/7] Fix : Missing ref of getNomUrl in AccountLine (Bank) --- htdocs/compta/bank/class/account.class.php | 3 ++- htdocs/compta/salaries/card.php | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b77ed4db1a5..f4067a63a9c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -2028,6 +2028,7 @@ class AccountLine extends CommonObject $result.=$langs->trans("BankAccount").': '; $accountstatic=new Account($this->db); $accountstatic->id=$this->fk_account; + $accountstatic->ref=$this->bank_account_ref; $accountstatic->label=$this->bank_account_label; $result.=$accountstatic->getNomUrl(0).', '; } diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 68f59d03cfa..b7cc64927a9 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2017 Alexandre Spangaro * Copyright (C) 2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Charlie BENKE @@ -19,9 +19,9 @@ */ /** - * \file htdocs/compta/salaries/card.php - * \ingroup salaries - * \brief Page of salaries payments + * \file htdocs/compta/salaries/card.php + * \ingroup salaries + * \brief Page of salaries payments */ require '../../main.inc.php'; @@ -72,7 +72,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); if (empty($datev)) $datev=$datep; - + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0; $object->datev=$datev; @@ -228,8 +228,8 @@ if ($action == 'create') print load_fiche_titre($langs->trans("NewSalaryPayment"),'', 'title_accountancy.png'); - dol_fiche_head('', ''); - + dol_fiche_head(''); + print ''; // Date payment @@ -340,12 +340,12 @@ if ($id) $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); $morehtmlref.=''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); - print '
'; + print '
'; print '
'; - print '
'; + print '
'; // Label print ''; @@ -405,7 +405,7 @@ if ($id) { if (! empty($user->rights->salaries->delete)) { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } else { From a96049d0e6dd74697f8407158a45e24ab6cc41f1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 7 Jun 2017 06:06:53 +0200 Subject: [PATCH 7/7] Spaces!!! --- htdocs/compta/bank/class/account.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index f4067a63a9c..92f2cfc584c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -2028,7 +2028,7 @@ class AccountLine extends CommonObject $result.=$langs->trans("BankAccount").': '; $accountstatic=new Account($this->db); $accountstatic->id=$this->fk_account; - $accountstatic->ref=$this->bank_account_ref; + $accountstatic->ref=$this->bank_account_ref; $accountstatic->label=$this->bank_account_label; $result.=$accountstatic->getNomUrl(0).', '; }
'.$langs->trans("Label").''.$object->label.'