diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a6f487c1211..b94675b1896 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -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); diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index fab9e81031d..e479b5931be 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -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); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 08677974a6d..be03f372b0a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -136,11 +136,13 @@ if ($action == 'validatehistory') { // Now clean $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1 .= " SET fd.fk_code_ventilation = 0"; - $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.= " SET fd.fk_code_ventilation = 0"; + $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.=")"; + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index b18923a1e1d..326170c6f4e 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -256,7 +256,7 @@ if ($result) { print ''; print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "fd.rowid", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("ProductRef"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); @@ -293,7 +293,7 @@ if ($result) { print ''; - print '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; // Ref Invoice $facture_static->ref = $objp->facnumber; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 84d5e3ffdee..8ddb34e5082 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -240,7 +240,7 @@ if ($result) { print ''; print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("ProductRef"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); @@ -309,7 +309,7 @@ if ($result) { print ''; // Line id - print '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; // Ref Invoice $facture_static->ref = $objp->facnumber; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index affb3971c08..2f378fa2e11 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -130,11 +130,13 @@ if ($action == 'validatehistory') { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $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.= " 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.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql1.=")"; + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 14a3d69a4ea..38327cb718c 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -266,7 +266,7 @@ if ($result) { print ''; - print '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; // Ref Invoice $expensereport_static->ref = $objp->ref; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index b9e929cab04..aeca9498f15 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -223,7 +223,7 @@ if ($result) { $center='
'; - print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, 0, 'title_accountancy', 0, '', '', $limit); + print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); if ($msg) print $msg.'
'; @@ -273,7 +273,7 @@ if ($result) { print ''; // Line id - print '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; // Ref Expense report $expensereport_static->ref = $objp->ref; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index f9a5100adbc..5c60627ebb2 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -130,11 +130,13 @@ if ($action == 'validatehistory') { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $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.= " 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.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql1.= ")"; + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 09422eb5b93..bcb2ed6b1ec 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -146,14 +146,15 @@ print '