From 565040e1bc7c561cd7797202036a4547ddda4107 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 26 Dec 2015 08:19:43 +0100 Subject: [PATCH 1/2] Accountancy Add a list to select accounting account on dict --- htdocs/admin/dict.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 899aba82057..bf0c69096cc 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -586,6 +587,9 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 + if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null + if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null + if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd')) @@ -1461,6 +1465,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); + $formaccountancy = New FormVentilation($db); foreach ($fieldlist as $field => $value) { @@ -1589,6 +1594,20 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print ''; } + elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') + { + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountancy_account = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); + print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1); + } + else + { + print ''; + } + print ''; + } else { print ''; @@ -1597,9 +1616,6 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field]=='position') $size='size="4" '; if ($fieldlist[$field]=='libelle') $size='size="32" '; if ($fieldlist[$field]=='tracking') $size='size="92" '; - if ($fieldlist[$field]=='accountancy_code') $size='size="10" '; - if ($fieldlist[$field]=='accountancy_code_sell') $size='size="10" '; - if ($fieldlist[$field]=='accountancy_code_buy') $size='size="10" '; if ($fieldlist[$field]=='sortorder') $size='size="2" '; print ''; print ''; From d6b96ec03a4f437d42a48e29553c23c53893c888 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 26 Dec 2015 08:38:18 +0100 Subject: [PATCH 2/2] Add function length_accountg to dictionary --- htdocs/admin/dict.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index bf0c69096cc..feb8646442a 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; $langs->load("errors"); @@ -1312,6 +1313,9 @@ if ($id) { $align="center"; } + else if ($fieldlist[$field]=='accountancy_code' || $fieldlist[$field]=='accountancy_code_sell' || $fieldlist[$field]=='accountancy_code_buy') { + $valuetoshow = length_accountg($valuetoshow); + } // Show value for field if ($showfield) print ''.$valuetoshow.'';