Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into franck_develop
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-florian committed Nov 16, 2016
2 parents a251f0d + b928bbe commit afd17fe
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 126 deletions.
64 changes: 16 additions & 48 deletions htdocs/accountancy/class/bookkeeping.class.php
Expand Up @@ -184,9 +184,7 @@ public function create(User $user, $notrigger = false) {
$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);

Expand All @@ -200,9 +198,7 @@ public function create(User $user, $notrigger = false) {
$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);
Expand All @@ -214,9 +210,7 @@ public function create(User $user, $notrigger = false) {
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);
Expand Down Expand Up @@ -503,9 +497,7 @@ public function fetch($id, $ref = null) {
$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 {
Expand Down Expand Up @@ -609,9 +601,7 @@ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0,
}
}
$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);
}
Expand Down Expand Up @@ -721,9 +711,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =
}
}
$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);
}
Expand Down Expand Up @@ -817,9 +805,7 @@ public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $o
}
}
$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);
}
Expand Down Expand Up @@ -1073,9 +1059,7 @@ function deleteByYearAndJournal($delyear='', $journal='') {
$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) {
Expand Down Expand Up @@ -1107,9 +1091,7 @@ function deleteMvtNum($piecenum) {
$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);

Expand Down Expand Up @@ -1212,9 +1194,7 @@ public function fetchPerMvt($piecenum) {
$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);
Expand Down Expand Up @@ -1245,9 +1225,7 @@ public function getNextNumMvt()
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);
Expand Down Expand Up @@ -1279,9 +1257,7 @@ function fetch_all_per_mvt($piecenum) {
$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);
Expand Down Expand Up @@ -1333,9 +1309,7 @@ function export_bookkeping($model = 'ebp') {
$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);

Expand Down Expand Up @@ -1404,9 +1378,7 @@ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event
$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);
Expand Down Expand Up @@ -1472,9 +1444,7 @@ function get_compte_racine($account = null)
$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);
Expand Down Expand Up @@ -1513,9 +1483,7 @@ function get_compte_desc($account = null)
$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);
Expand Down
20 changes: 5 additions & 15 deletions htdocs/accountancy/class/html.formventilation.class.php
Expand Up @@ -41,9 +41,7 @@ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = ''
$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);
Expand Down Expand Up @@ -232,9 +230,7 @@ function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty
// 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);
Expand All @@ -254,9 +250,7 @@ function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty
// 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);
Expand Down Expand Up @@ -297,9 +291,7 @@ function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid'

$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);
Expand Down Expand Up @@ -338,9 +330,7 @@ function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'jour

$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);
Expand Down
12 changes: 7 additions & 5 deletions htdocs/accountancy/customer/index.php
Expand Up @@ -136,11 +136,13 @@

// 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);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/accountancy/customer/lines.php
Expand Up @@ -256,7 +256,7 @@
print '<tr class="liste_titre">';
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);
Expand Down Expand Up @@ -293,7 +293,7 @@

print '<tr '. $bc[$var].'>';

print '<td align="right">' . $objp->rowid . '</td>';
print '<td>' . $objp->rowid . '</td>';

// Ref Invoice
$facture_static->ref = $objp->facnumber;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/accountancy/customer/list.php
Expand Up @@ -240,7 +240,7 @@
print '<tr class="liste_titre">';
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);
Expand Down Expand Up @@ -309,7 +309,7 @@
print '<tr '. $bc[$var].'>';

// Line id
print '<td align="center">' . $objp->rowid . '</td>';
print '<td>' . $objp->rowid . '</td>';

// Ref Invoice
$facture_static->ref = $objp->facnumber;
Expand Down
12 changes: 7 additions & 5 deletions htdocs/accountancy/expensereport/index.php
Expand Up @@ -130,11 +130,13 @@
$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);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/expensereport/lines.php
Expand Up @@ -266,7 +266,7 @@

print '<tr '. $bc[$var].'>';

print '<td align="right">' . $objp->rowid . '</td>';
print '<td>' . $objp->rowid . '</td>';

// Ref Invoice
$expensereport_static->ref = $objp->ref;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/accountancy/expensereport/list.php
Expand Up @@ -223,7 +223,7 @@

$center='<div class="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';

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.'<br>';

Expand Down Expand Up @@ -273,7 +273,7 @@
print '<tr '. $bc[$var].'>';

// Line id
print '<td align="center">' . $objp->rowid . '</td>';
print '<td>' . $objp->rowid . '</td>';

// Ref Expense report
$expensereport_static->ref = $objp->ref;
Expand Down
12 changes: 7 additions & 5 deletions htdocs/accountancy/supplier/index.php
Expand Up @@ -130,11 +130,13 @@
$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);
Expand Down

0 comments on commit afd17fe

Please sign in to comment.