diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index 2d6ee046bbc..ead997a5d8c 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -51,8 +51,8 @@ $action = GETPOST('action', 'alpha');
$list = array (
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT' ,
- 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
- 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
+// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
+// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
);
@@ -65,28 +65,28 @@ $accounting_mode = defined('ACCOUNTING_MODE') ? ACCOUNTING_MODE : 'RECETTES-DEPE
if ($action == 'update') {
$error = 0;
-
+
$accounting_modes = array (
'RECETTES-DEPENSES',
- 'CREANCES-DETTES'
+ 'CREANCES-DETTES'
);
-
+
$accounting_mode = GETPOST('accounting_mode', 'alpha');
-
+
if (in_array($accounting_mode, $accounting_modes)) {
-
+
if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
-
+
if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
- foreach ($list as $constname)
+ foreach ($list as $constname)
{
$constvalue = GETPOST($constname, 'alpha');
@@ -267,10 +267,10 @@ if (! empty($user->admin))
// Param a user $user->rights->accountancy->chartofaccount can access
-foreach ($list as $key)
+foreach ($list as $key)
{
print '
';
-
+
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
// Param
@@ -280,7 +280,7 @@ foreach ($list as $key)
print '| ';
print '';
print ' | ';
-
+
print '
';
}
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index 5b614061dbc..311aab692ff 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -111,16 +111,16 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
if ($action == 'update') {
if (! empty($btn_changetype)) {
$error = 0;
-
+
$accounting_product_modes = array (
'ACCOUNTANCY_SELL',
- 'ACCOUNTANCY_BUY'
+ 'ACCOUNTANCY_BUY'
);
-
+
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
-
+
if (in_array($accounting_product_mode, $accounting_product_modes)) {
-
+
if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
@@ -128,26 +128,26 @@ if ($action == 'update') {
$error ++;
}
}
-
+
if (! empty($btn_changeaccount)) {
//$msg = '' . $langs->trans("Processing") . '...
';
if (! empty($chk_prod)) {
-
+
$accounting = new AccountingAccount($db);
-
+
//$msg .= '' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
';
-
+
$cpt = 0; $ok = 0; $ko = 0;
foreach ( $chk_prod as $productid ) {
-
+
$accounting_account_id = GETPOST('codeventil_' . $productid);
-
+
$result = $accounting->fetch($accounting_account_id, null, 1);
if ($result < 0) {
// setEventMessages(null, $accounting->errors, 'errors');
$msg .= '' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
' . $sql . '
';
} else {
-
+
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " SET accountancy_code_buy = " . $accounting->account_number;
@@ -156,7 +156,7 @@ if ($action == 'update') {
$sql .= " SET accountancy_code_sell = " . $accounting->account_number;
}
$sql .= " WHERE rowid = " . $productid;
-
+
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$ok++;
@@ -166,7 +166,7 @@ if ($action == 'update') {
//$msg .= '' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '
' . $sql . '
';
}
}
-
+
$cpt ++;
}
} else {
@@ -258,11 +258,11 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
-if ($result)
+if ($result)
{
$num = $db->num_rows($result);
$i = 0;
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -271,7 +271,7 @@ if ($result)
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
-
+
print '';
-
+
$db->free($result);
} else {
dol_print_error($db);
diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index b5778ce86f2..d6d006c6556 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -121,7 +121,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
}
-
+
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
@@ -240,7 +240,7 @@ if ($result) {
if ($search_tvaintra)
$param .= "&search_tvaintra=" . $search_tvaintra;
-
+
print '';
} else {
print $db->lasterror();
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 85a97fb3a1e..75c1a59aa30 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -144,10 +144,10 @@ if ($massaction == 'ventil') {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
-
+
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
-
+
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
';
@@ -157,7 +157,7 @@ if ($massaction == 'ventil') {
$ko++;
}
}
-
+
$cpt++;
}
$msg.='';
@@ -375,10 +375,10 @@ if ($result) {
print '';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
- $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
+ $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
print ' | ';
-
+
print '';
print price($objp->total_ht);
print ' | ';
@@ -404,7 +404,7 @@ if ($result) {
print '';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' | ';
-
+
print '';
print 'aarowid ? "checked" : "") . '/>';
print ' | ';
diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php
index 5a386c82522..2237f578069 100644
--- a/htdocs/accountancy/expensereport/lines.php
+++ b/htdocs/accountancy/expensereport/lines.php
@@ -1,10 +1,10 @@
* Copyright (C) 2013-2017 Alexandre Spangaro
- * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
+ * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
* Copyright (C) 2013-2016 Florian Henry
* Copyright (C) 2014 Juanjo Menent
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -94,13 +94,13 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
-
+
$db->begin();
-
+
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')';
-
+
dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
@@ -193,7 +193,7 @@ $result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -210,8 +210,8 @@ if ($result) {
if ($search_country)
$param .= "&search_country=" . $search_country;
if ($search_tvaintra)
- $param .= "&search_tvaintra=" . $search_tvaintra;
-
+ $param .= "&search_tvaintra=" . $search_tvaintra;
+
print '';
} else {
print $db->error();
diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php
index 7fb5f26b28b..8e7b9c60c92 100644
--- a/htdocs/accountancy/expensereport/list.php
+++ b/htdocs/accountancy/expensereport/list.php
@@ -139,10 +139,10 @@ if ($massaction == 'ventil') {
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
-
+
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
-
+
dol_syslog('accountancy/expensereport/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
';
@@ -152,7 +152,7 @@ if ($massaction == 'ventil') {
$ko++;
}
}
-
+
$cpt++;
}
$msg.='';
@@ -224,7 +224,7 @@ if ($result) {
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -237,8 +237,8 @@ if ($result) {
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
-
-
+
+
print '';
} else {
print $db->error();
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index dc6b5e7ec20..9c7a72cb94c 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -1,10 +1,10 @@
* Copyright (C) 2013-2017 Alexandre Spangaro
- * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
+ * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
* Copyright (C) 2013-2016 Florian Henry
* Copyright (C) 2014 Juanjo Menent
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -98,13 +98,13 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
-
+
$db->begin();
-
+
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
-
+
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
@@ -202,7 +202,7 @@ $result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -221,8 +221,8 @@ if ($result) {
if ($search_country)
$param .= "&search_country=" . $search_country;
if ($search_tvaintra)
- $param .= "&search_tvaintra=" . $search_tvaintra;
-
+ $param .= "&search_tvaintra=" . $search_tvaintra;
+
print '';
} else {
print $db->error();
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 93aeb1746f5..ff39aad67f4 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -104,7 +104,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
{
$search_lineid = '';
$search_ref = '';
- $search_invoice = '';
+ $search_invoice = '';
$search_label = '';
$search_desc = '';
$search_amount = '';
@@ -146,10 +146,10 @@ if ($massaction == 'ventil') {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
-
+
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
-
+
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
';
@@ -159,7 +159,7 @@ if ($massaction == 'ventil') {
$ko++;
}
}
-
+
$cpt++;
}
$msg.='';
@@ -332,7 +332,7 @@ if ($result) {
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
$facturefourn_static->type = $objp->type;
-
+
$code_buy_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
@@ -356,7 +356,7 @@ if ($result) {
// $objp->code_buy_p is now code of product/service
// $objp->code_buy_l is now default code of product/service
-
+
print '';
// Line id
@@ -381,7 +381,7 @@ if ($result) {
// Description
print '| ';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
- $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
+ $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
print ' | ';
@@ -422,7 +422,7 @@ if ($result) {
print '';
print "";
-
+
print '';
} else {
print $db->error();
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 8a348dba57a..e3e6e9a4f20 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -266,7 +266,7 @@ class FormAccounting extends Form
}
else
{
- $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
+ $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT;
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";