Fix management of multientity
This commit is contained in:
parent
5539415354
commit
206970b82c
@ -184,9 +184,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
||||
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -200,9 +198,7 @@ class BookKeeping extends CommonObject
|
||||
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
|
||||
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
||||
$resqlnum = $this->db->query($sqlnum);
|
||||
@ -214,9 +210,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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
||||
$resqlnum = $this->db->query($sqlnum);
|
||||
@ -503,9 +497,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " t.piece_num";
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
$sql .= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
if (null !== $ref) {
|
||||
$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
|
||||
} else {
|
||||
@ -609,9 +601,7 @@ class BookKeeping extends CommonObject
|
||||
}
|
||||
}
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||
}
|
||||
@ -721,9 +711,7 @@ class BookKeeping extends CommonObject
|
||||
}
|
||||
}
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||
}
|
||||
@ -817,9 +805,7 @@ class BookKeeping extends CommonObject
|
||||
}
|
||||
}
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||
}
|
||||
@ -1073,9 +1059,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."'";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if (! $resql) {
|
||||
@ -1107,9 +1091,7 @@ class BookKeeping extends CommonObject
|
||||
$sql = "DELETE";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$sql .= " WHERE piece_num = " . $piecenum;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -1212,9 +1194,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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -1245,9 +1225,7 @@ class BookKeeping extends CommonObject
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -1279,9 +1257,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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -1333,9 +1309,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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
|
||||
|
||||
@ -1404,9 +1378,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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
$sql .= " ORDER BY account_number ASC";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
||||
@ -1472,9 +1444,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " WHERE aa.account_number = '" . $account . "'";
|
||||
$sql .= " AND parent.active = 1";
|
||||
$sql .= " AND root.active = 1";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -1513,9 +1483,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";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -41,9 +41,7 @@ class FormVentilation extends Form
|
||||
$options = array();
|
||||
|
||||
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
$sql .= ' ORDER BY import_key DESC';
|
||||
|
||||
dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG);
|
||||
@ -232,9 +230,7 @@ class FormVentilation extends Form
|
||||
// Auxiliary customer account
|
||||
$sql = "SELECT DISTINCT code_compta, nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
|
||||
$sql .= " ORDER BY code_compta";
|
||||
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -254,9 +250,7 @@ class FormVentilation extends Form
|
||||
// Auxiliary supplier account
|
||||
$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
|
||||
$sql .= " ORDER BY code_compta_fournisseur";
|
||||
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -297,9 +291,7 @@ class FormVentilation extends Form
|
||||
|
||||
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
$sql .= " ORDER BY date_format(doc_date,'%Y')";
|
||||
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -338,9 +330,7 @@ class FormVentilation extends Form
|
||||
|
||||
$sql = "SELECT DISTINCT code_journal";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
$sql .= " ORDER BY code_journal";
|
||||
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -140,7 +140,8 @@ 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) . ")";
|
||||
|
||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||
|
||||
$resql1 = $db->query($sql1);
|
||||
|
||||
@ -133,8 +133,9 @@ if ($action == 'validatehistory') {
|
||||
$sql1 .= " SET fd.fk_code_ventilation = 0";
|
||||
$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.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')";
|
||||
$sql1 .= " AND f.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||
|
||||
$resql1 = $db->query($sql1);
|
||||
|
||||
@ -133,8 +133,9 @@ if ($action == 'validatehistory') {
|
||||
$sql1 .= " SET fd.fk_code_ventilation = 0";
|
||||
$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.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')";
|
||||
$sql1 .= " AND f.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
|
||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||
|
||||
$resql1 = $db->query($sql1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user