diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index 3f251e0090b..70f191f3679 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -161,11 +161,11 @@ if ($result) {
print '';
print '
';
- print ' | ';
- print ' | ';
- print ' | ';
- print ' | ';
- print ' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
print ' | ';
print '';
print '';
@@ -190,7 +190,7 @@ if ($result) {
print ' | ' . $accountstatic->getNomUrl(1) . ' | ';
print '' . $obj->label . ' | ';
- if ($obj->account_parent)
+ if (! empty($obj->account_parent))
{
$accountparent->id = $obj->rowid2;
$accountparent->label = $obj->label2;
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index eeb94bddf60..04d538b1b31 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -59,12 +59,17 @@ if ($action == 'add') {
// Clean code
$account_number = clean_account(GETPOST('account_number')); // Accounting account without zero on the right
+ if (GETPOST('account_category') <= 0) {
+ $account_parent = '';
+ } else {
+ $account_parent = GETPOST('account_category','int');
+ }
$object->fk_pcg_version = $obj->pcg_version;
$object->pcg_type = GETPOST('pcg_type');
$object->pcg_subtype = GETPOST('pcg_subtype');
$object->account_number = $account_number;
- $object->account_parent = GETPOST('account_parent', 'int');
+ $object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category');
$object->label = GETPOST('label', 'alpha');
$object->active = 1;
@@ -96,12 +101,17 @@ if ($action == 'add') {
// Clean code
$account_number = clean_account(GETPOST('account_number')); // Accounting account without zero on the right
-
+ if (GETPOST('account_category') <= 0) {
+ $account_parent = '';
+ } else {
+ $account_parent = GETPOST('account_category','int');
+ }
+
$object->fk_pcg_version = $obj->pcg_version;
$object->pcg_type = GETPOST('pcg_type');
$object->pcg_subtype = GETPOST('pcg_subtype');
$object->account_number = $account_number;
- $object->account_parent = GETPOST('account_parent', 'int');
+ $object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category');
$object->label = GETPOST('label', 'alpha');
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index bedb2a78bae..8671638ce0c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3423,26 +3423,26 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
* @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit
* @return string String to show dimensions
*/
-function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitouput='no')
+function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
- if (($forceunitouput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitouput) && $forceunitouput == -6))
+ if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
{
$dimension = $dimension * 1000000;
$unit = $unit - 6;
}
- elseif (($forceunitouput == 'no' && $dimension < 1/10) || (is_numeric($forceunitouput) && $forceunitouput == -3))
+ elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
{
$dimension = $dimension * 1000;
$unit = $unit - 3;
}
- elseif (($forceunitouput == 'no' && $dimension > 100000000) || (is_numeric($forceunitouput) && $forceunitouput == 6))
+ elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
{
$dimension = $dimension / 1000000;
$unit = $unit + 6;
}
- elseif (($forceunitouput == 'no' && $dimension > 100000) || (is_numeric($forceunitouput) && $forceunitouput == 3))
+ elseif (($forceunitoutput == 'no' && $dimension > 100000) || (is_numeric($forceunitoutput) && $forceunitoutput == 3))
{
$dimension = $dimension / 1000;
$unit = $unit + 3;
diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
index bad6d4fd51e..b3399ae5ca1 100644
--- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
+++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
@@ -343,6 +343,8 @@ CREATE TABLE llx_c_accounting_category (
ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code);
+ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer;
+
DROP INDEX uk_bordereau_cheque ON llx_bordereau_cheque;
ALTER TABLE llx_bordereau_cheque CHANGE number ref VARCHAR(30) NOT NULL;
diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql
index e8927cdfda5..d74c1b75105 100644
--- a/htdocs/install/mysql/tables/llx_accounting_account.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_account.sql
@@ -29,7 +29,7 @@ create table llx_accounting_account
pcg_type varchar(20) NOT NULL,
pcg_subtype varchar(20) NOT NULL,
account_number varchar(32) NOT NULL,
- account_parent varchar(32),
+ account_parent integer, -- Hierarchic parent
label varchar(255) NOT NULL,
fk_accounting_category integer DEFAULT 0,
fk_user_author integer DEFAULT NULL,