New: getEntity function use true $shared value by default

This commit is contained in:
Regis Houssin 2017-05-30 18:50:54 +02:00
parent d9cdad6a77
commit 5c5663c5ae
237 changed files with 456 additions and 454 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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 {

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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";

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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;

View File

@ -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)

View File

@ -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

View File

@ -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."%'";

View File

@ -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";

View File

@ -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)

View File

@ -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();

View File

@ -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); }

View File

@ -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)."'";

View File

@ -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)."'";

View File

@ -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) )
{

View File

@ -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";

View File

@ -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

View File

@ -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' )

View File

@ -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;

View File

@ -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;

View File

@ -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)."'";

View File

@ -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))."'";

View File

@ -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

View File

@ -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;

View File

@ -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))
{

View File

@ -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))
{

View File

@ -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);

View File

@ -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";

View File

@ -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';

View File

@ -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)";

View File

@ -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;

View File

@ -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) {

View File

@ -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";

View File

@ -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

View File

@ -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)

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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))
{

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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";

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -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";

View File

@ -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);

View File

@ -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)
{

View File

@ -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))
{

View File

@ -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;

View File

@ -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

View File

@ -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.")";

View File

@ -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)
{

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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";

View File

@ -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";

View File

@ -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))

View File

@ -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";

View File

@ -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)
{

View File

@ -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)."'";
}

View File

@ -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";

View File

@ -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";

View File

@ -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)";

View File

@ -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)

View File

@ -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)."'";

View File

@ -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;

View File

@ -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";

View File

@ -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";

View File

@ -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 ";

View File

@ -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");

View File

@ -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) {

View File

@ -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";

View File

@ -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."'";

View File

@ -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').')')
);
}

View File

@ -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);

View File

@ -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))
{

View File

@ -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 = '')";

Some files were not shown because too many files have changed in this diff Show More