From 1f079fac9d92bd8baabad8a947f849c6acc36c4e Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO <alexandre.spangaro@gmail.com>
Date: Thu, 25 May 2017 06:57:28 +0200
Subject: [PATCH] Move html.formventilation.class.php to
 html.formaccounting.class.php

---
 htdocs/accountancy/admin/account.php          |   1 -
 htdocs/accountancy/admin/accountmodel.php     |   8 +-
 htdocs/accountancy/admin/card.php             |   6 +-
 htdocs/accountancy/admin/categories_list.php  |   6 +-
 htdocs/accountancy/admin/defaultaccounts.php  |   6 +-
 htdocs/accountancy/admin/importaccounts.php   |  33 +-
 htdocs/accountancy/admin/index.php            |  15 +-
 htdocs/accountancy/admin/productaccount.php   |   4 +-
 htdocs/accountancy/bookkeeping/balance.php    |   8 +-
 htdocs/accountancy/bookkeeping/card.php       |  12 +-
 htdocs/accountancy/bookkeeping/list.php       |  18 +-
 .../accountancy/bookkeeping/listbyaccount.php |   6 +-
 htdocs/accountancy/bookkeeping/listbyyear.php |  12 +-
 .../class/html.formventilation.class.php      | 292 ------------------
 htdocs/accountancy/customer/card.php          |  38 ++-
 htdocs/accountancy/customer/lines.php         |  34 +-
 htdocs/accountancy/customer/list.php          |  43 ++-
 htdocs/accountancy/expensereport/card.php     |   6 +-
 htdocs/accountancy/expensereport/lines.php    |   6 +-
 htdocs/accountancy/expensereport/list.php     |   6 +-
 htdocs/accountancy/supplier/card.php          |  36 +--
 htdocs/accountancy/supplier/lines.php         |  10 +-
 htdocs/accountancy/supplier/list.php          |  39 ++-
 htdocs/admin/dict.php                         |   6 +-
 htdocs/admin/loan.php                         |   8 +-
 htdocs/admin/mails_templates.php              |   4 +-
 htdocs/admin/salaries.php                     |   6 +-
 htdocs/admin/taxes.php                        |   6 +-
 htdocs/compta/bank/card.php                   |  31 +-
 htdocs/compta/bank/various_payment/card.php   |   8 +-
 .../core/class/html.formaccounting.class.php  | 264 +++++++++++++++-
 htdocs/don/admin/donation.php                 |  18 +-
 htdocs/loan/card.php                          |  18 +-
 htdocs/product/card.php                       |  14 +-
 34 files changed, 490 insertions(+), 538 deletions(-)
 delete mode 100644 htdocs/accountancy/class/html.formventilation.class.php

diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index d3556135972..62e35fa0f57 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -27,7 +27,6 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 
 // Langs
 $langs->load("compta");
diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php
index 55c194cd416..ca26c35c442 100644
--- a/htdocs/accountancy/admin/accountmodel.php
+++ b/htdocs/accountancy/admin/accountmodel.php
@@ -39,7 +39,7 @@ 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';
 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';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("errors");
 $langs->load("admin");
@@ -1258,8 +1258,8 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
 
 	$formadmin = new FormAdmin($db);
 	$formcompany = new FormCompany($db);
-	$formaccountancy = new FormVentilation($db);
-	
+	$formaccounting = new FormAccounting($db);
+
 	foreach ($fieldlist as $field => $value)
 	{
 		if ($fieldlist[$field] == 'country')
@@ -1400,7 +1400,7 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
 			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, 'maxwidth200 maxwidthonsmartphone');
+				print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
 			}
 			else
 			{
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index b23f5cb5421..73e3fdf6dd9 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -27,7 +27,6 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $error = 0;
@@ -196,7 +195,6 @@ $helpurl = '';
 llxheader('', $title, $helpurl);
 
 $form = new Form($db);
-$htmlacc = new FormVentilation($db);
 $formaccounting = new FormAccounting($db);
 
 $accountsystem = new AccountancySystem($db);
@@ -231,7 +229,7 @@ if ($action == 'create') {
 	// Account parent
 	print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
 	print '<td>';
-	print $htmlacc->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
+	print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
 	print '</td></tr>';
 
 	// Category
@@ -295,7 +293,7 @@ if ($action == 'create') {
 			// Account parent
 			print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
 			print '<td>';
-			print $htmlacc->select_account($object->account_parent, 'account_parent', 1);
+			print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
 			print '</td></tr>';
 
 			// Category
diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php
index c0fa895ae4c..f3a35350084 100644
--- a/htdocs/accountancy/admin/categories_list.php
+++ b/htdocs/accountancy/admin/categories_list.php
@@ -39,7 +39,7 @@ 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';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 $langs->load("errors");
 $langs->load("admin");
@@ -982,7 +982,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex
 
 	$formadmin = new FormAdmin($db);
 	$formcompany = new FormCompany($db);
-	if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
+	if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
 	foreach ($fieldlist as $field => $value)
 	{
@@ -1125,7 +1125,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex
 			{
 			    $fieldname = $fieldlist[$field];
 				$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
-				print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
+				print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
 			}
 			else
 			{
diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php
index 4b733bee5a6..c2a6453ffee 100644
--- a/htdocs/accountancy/admin/defaultaccounts.php
+++ b/htdocs/accountancy/admin/defaultaccounts.php
@@ -32,7 +32,7 @@ require '../../main.inc.php';
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("compta");
 $langs->load("bills");
@@ -117,7 +117,7 @@ if ($action == 'update') {
 llxHeader();
 
 $form = new Form($db);
-$formaccountancy = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 $linkback = '';
 print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
@@ -142,7 +142,7 @@ foreach ( $list_account as $key ) {
 	print '<td>' . $label . '</td>';
 	// Value
 	print '<td>';  // Do not force align=right, or it align also the content of the select box 
-	print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
+	print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
 	print '</td>';
 	print '</tr>';
 }
diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php
index f4f155c0b59..1bb1bf178b3 100644
--- a/htdocs/accountancy/admin/importaccounts.php
+++ b/htdocs/accountancy/admin/importaccounts.php
@@ -1,8 +1,7 @@
 <?php
-/* 
- * Copyright (C) 2013-2014 Olivier Geffroy      <jeff@jeffinfo.com>
- * Copyright (C) 2013-2014 Alexandre Spangaro   <aspangaro.dolibarr@gmail.com> 
- * Copyright (C) 2014	   Florian Henry		<florian.henry@open-concept.pro>
+/* Copyright (C) 2013-2014 Olivier Geffroy      <jeff@jeffinfo.com>
+ * Copyright (C) 2013-2017 Alexandre Spangaro   <aspangaro.dolibarr@gmail.com> 
+ * Copyright (C) 2014      Florian Henry        <florian.henry@open-concept.pro>
  *
  * 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
@@ -28,7 +27,7 @@ require '../../main.inc.php';
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // langs
 $langs->load("compta");
@@ -65,22 +64,22 @@ if ($_POST["action"] == 'import') {
 	if (is_array($to_import) && count($to_import) > 0) {
 		print '<div><font color="red">' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
 		$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
-		
+
 		$result = $db->query($sql);
 		if ($result && ($db->num_rows($result) > 0)) {
-			
+
 			$obj = $db->fetch_object($result);
-			
+
 			$cpt = 0;
 			foreach ( $to_import as $maLigneCochee ) {
-				
+
 				$accounting = new AccountingAccount($db);
-				
+
 				$monLabel = GETPOST('label' . $maLigneCochee);
 				$monParentAccount = GETPOST('AccountParent' . $maLigneCochee);
 				$monType = GETPOST('pcgType' . $maLigneCochee);
 				$monSubType = GETPOST('pcgSubType' . $maLigneCochee);
-				
+
 				$accounting->fk_pcg_version = $obj->pcg_version;
 				$accounting->account_number = $maLigneCochee;
 				$accounting->label = $monLabel;
@@ -126,10 +125,10 @@ if ($result) {
 	$num_lines = $db->num_rows($result);
 	$i = 0;
 	print_barre_liste($langs->trans("ImportAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
-	
+
 	print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
 	print '<input type="hidden" name="action" value="import">';
-	
+
 	print '<table class="noborder" width="100%">';
 	print '<tr class="liste_titre"><td>' . $langs->trans("AccountAccouting") . '</td>';
 	print '<td>' . $langs->trans("label") . '</td>';
@@ -138,10 +137,10 @@ if ($result) {
 	print '<td>' . $langs->trans("Pcgsubtype") . '</td>';
 	print '<td align="center">' . $langs->trans("Import") . '</td>';
 	print '</tr>';
-	
+
 	$form = new Form($db);
-	$htmlacc = new FormVentilation($db);
-	
+	$formaccounting = new FormAccounting($db);
+
 	$var = true;
 	while ( $i < min($num_lines, $limit) ) {
 		$objp = $db->fetch_object($result);
@@ -157,7 +156,7 @@ if ($result) {
 
 		// Colonne choix du compte
 		print '<td>';
-		print $htmlacc->select_account($accounting->account_parent, 'AccountParent');
+		print $formaccounting->select_account($accounting->account_parent, 'AccountParent');
 		print '</td>';
 
 		print '<td>';
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index 899aaa1a3d2..0e1f67a0e61 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -1,11 +1,11 @@
 <?php
-/* Copyright (C) 2013-2014 Olivier Geffroy		<jeff@jeffinfo.com>
- * Copyright (C) 2013-2014 Florian Henry		<florian.henry@open-concept.pro>
- * Copyright (C) 2013-2017 Alexandre Spangaro	<aspangaro@zendsi.com>
- * Copyright (C) 2014-2015 Ari Elbaz (elarifr)	<github@accedinfo.com>
+/* Copyright (C) 2013-2014 Olivier Geffroy      <jeff@jeffinfo.com>
+ * Copyright (C) 2013-2014 Florian Henry        <florian.henry@open-concept.pro>
+ * Copyright (C) 2013-2017 Alexandre Spangaro   <aspangaro@zendsi.com>
+ * Copyright (C) 2014-2015 Ari Elbaz (elarifr)  <github@accedinfo.com>
  * Copyright (C) 2014      Marcos García        <marcosgdf@gmail.com>
- * Copyright (C) 2014	   Juanjo Menent		<jmenent@2byte.es>
- * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
+ * Copyright (C) 2014      Juanjo Menent        <jmenent@2byte.es>
+ * Copyright (C) 2015      Jean-François Ferry  <jfefe@aternatik.fr>
  *
  * 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
@@ -31,8 +31,6 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 
 $langs->load("compta");
 $langs->load("bills");
@@ -160,7 +158,6 @@ if ($action == 'setdisabledirectinput') {
 llxHeader();
 
 $form = new Form($db);
-$formaccountancy = new FormVentilation($db);
 
 $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
 print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index 359a8b40c12..fcb44c6f858 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 
@@ -184,7 +184,7 @@ if ($action == 'update') {
  * View
  */
 
-$form = new FormVentilation($db);
+$form = new FormAccounting($db);
 
 // Defaut AccountingAccount RowId Product / Service
 // at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index 9e5be25eb73..3111707cff6 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -28,8 +28,8 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 
 // Langs
@@ -61,7 +61,7 @@ $offset = $limit * $page;
 
 $object = new BookKeeping($db);
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 $formother = new FormOther($db);
 $form = new Form($db);
 
@@ -186,10 +186,10 @@ else {
     print '<tr class="liste_titre_filter">';
     print '<td class="liste_titre" colspan="5">';
     print $langs->trans('From');
-    print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
+    print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
     print ' ';
     print $langs->trans('to');
-    print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
+    print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
     print '</td>';
     print '<td align="right" class="liste_titre">';
 	$searchpicto=$form->showFilterAndCheckAddButtons(0);
diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 7ee3e6bb4fe..4443fb959b2 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -27,9 +27,8 @@ require '../../main.inc.php';
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Langs
 $langs->load("accountancy");
@@ -215,7 +214,6 @@ else if ($action == "confirm_create") {
 llxHeader();
 
 $html = new Form($db);
-$formventilation = new FormVentilation($db);
 $formaccountancy = new FormAccounting($db);
 
 /*
@@ -389,10 +387,10 @@ if ($action == 'create') {
 					if ($action == 'update' && $line->id == $id) {
 
 						print '<td>';
-						print $formventilation->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
+						print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
 						print '</td>';
 						print '<td>';
-						print $formventilation->select_auxaccount($line->code_tiers, 'code_tiers', 1);
+						print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1);
 						print '</td>';
 						print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
 						print '<td align="right"><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
@@ -433,10 +431,10 @@ if ($action == 'create') {
 				if ($action == "" || $action == 'add') {
 					print '<tr class="oddeven">';
 					print '<td>';
-					print $formventilation->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
+					print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
 					print '</td>';
 					print '<td>';
-					print $formventilation->select_auxaccount($code_tiers, 'code_tiers', 1);
+					print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1);
 					print '</td>';
 					print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>';
 					print '<td align="right"><input type="text" class="right maxwidth50" name="debit" value="' . price($debit) . '"/></td>';
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 72385bab746..a955d671475 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -28,10 +28,10 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Langs
 $langs->load("accountancy");
@@ -94,7 +94,7 @@ if ($sortfield == "") $sortfield = "t.rowid";
 
 $object = new BookKeeping($db);
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 $formother = new FormOther($db);
 $form = new Form($db);
 
@@ -321,8 +321,8 @@ if ($action == 'delbookkeepingyear') {
 	if (empty($delyear)) {
 		$delyear = dol_print_date(dol_now(), '%Y');
 	}
-	$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
-	$journal_array = $formventilation->selectjournal_accountancy_bookkepping($deljournal, 'deljournal', 0, 'array');
+	$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
+	$journal_array = $formaccounting->selectjournal_accountancy_bookkepping($deljournal, 'deljournal', 0, 'array');
 
 	$form_question['delyear'] = array (
 			'name' => 'delyear',
@@ -385,17 +385,17 @@ print '</td>';
 print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
 print '<td class="liste_titre">';
 print $langs->trans('From');
-print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
+print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
 print '<br>';
 print $langs->trans('to');
-print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
+print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
 print '</td>';
 print '<td class="liste_titre">';
 print $langs->trans('From');
-print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
+print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
 print '<br>';
 print $langs->trans('to');
-print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
+print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
 print '</td>';
 print '<td class="liste_titre">';
 print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index eb8a53561d2..6b329e421ad 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -29,8 +29,8 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 
 // Langs
@@ -75,7 +75,7 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_
 
 $object = new BookKeeping($db);
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 $formother = new FormOther($db);
 $form = new Form($db);
 
@@ -188,7 +188,7 @@ if ($action == 'delbookkeepingyear') {
 	if (empty($delyear)) {
 		$delyear = dol_print_date(dol_now(), '%Y');
 	}
-	$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
+	$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
 
 	$form_question['delyear'] = array (
 			'name' => 'delyear',
diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php
index 263f293043a..5fba55f2eba 100644
--- a/htdocs/accountancy/bookkeeping/listbyyear.php
+++ b/htdocs/accountancy/bookkeeping/listbyyear.php
@@ -29,7 +29,7 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Langs
 $langs->load("accountancy");
@@ -67,7 +67,7 @@ $search_code_journal = GETPOST('search_code_journal', 'alpha');
 
 $object = new BookKeeping($db);
 $form = new Form($db);
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 // Filter
 if (empty($search_date_start)) {
@@ -182,15 +182,15 @@ print $form->select_date($search_date_end, 'date_end');
 print '</div>';
 print '<div class="liste_titre">';
 print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': ';
-print $formventilation->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, '');
+print $formaccounting->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, '');
 print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': ';
-print $formventilation->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, '');
+print $formaccounting->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, '');
 print '</div>';
 print '<div class="liste_titre">';
 print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
-print $formventilation->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1);
+print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1);
 print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
-print $formventilation->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1);
+print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1);
 print '</div>';
 print "<table class=\"noborder\" width=\"100%\">";
 
diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php
deleted file mode 100644
index d7a827f2480..00000000000
--- a/htdocs/accountancy/class/html.formventilation.class.php
+++ /dev/null
@@ -1,292 +0,0 @@
-<?php
-/* Copyright (C) 2013-2016 Florian Henry        <florian.henry@open-concept.pro>
- * Copyright (C) 2013-2014 Olivier Geffroy      <jeff@jeffinfo.com>
- * Copyright (C) 2013-2016 Alexandre Spangaro   <aspangaro.dolibarr@gmail.com>
- * Copyright (C) 2015      Ari Elbaz (elarifr)  <github@accedinfo.com>
- * Copyright (C) 2016      Marcos García        <marcosgdf@gmail.com>
- *
- * 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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * \file		htdocs/accountancy/class/html.formventilation.class.php
- * \ingroup		Advanced accountancy
- * \brief		File of class with all html predefined components
- */
-
-/**
- * Class to manage generation of HTML components for bank module
- */
-class FormVentilation extends Form
-{
-
-    private $options_cache = array();
-
-
-	/**
-	 * Return select filter with date of transaction
-	 *
-	 * @param string $htmlname Name of select field
-	 * @param string $selectedkey Value
-	 * @return string HTML edit field
-	 */
-	function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') {
-		$options = array();
-
-		$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
-	    $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
-		$sql .= ' ORDER BY import_key DESC';
-
-		dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG);
-		$resql = $this->db->query($sql);
-
-		if (!$resql) {
-			$this->error = "Error " . $this->db->lasterror();
-			dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
-			return - 1;
-		}
-
-		while ($obj = $this->db->fetch_object($resql)) {
-			$options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext');
-		}
-
-		return Form::selectarray($htmlname, $options, $selectedkey);
-	}
-
-	/**
-	 * Return list of accounts with label by chart of accounts
-	 *
-	 * @param string   $selectid           Preselected id or code of accounting accounts (depends on $select_in)
-	 * @param string   $htmlname           Name of field in html form
-	 * @param int      $showempty          Add an empty field
-	 * @param array    $event              Event options
-	 * @param int      $select_in          0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
-	 * @param int      $select_out         Set value returned by select. 0=rowid (default), 1=account_number
-	 * @param string   $morecss            More css non HTML object
-	 * @param string   $usecache           Key to use to store result into a cache. Next call with same key will reuse the cache.
-	 * @return string                      String with HTML select
-	 */
-	function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='')
-	{
-		global $conf;
-
-		require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-
-		$out = '';
-		
-    	$options = array();
-		if ($usecache && ! empty($this->options_cache[$usecache]))
-		{
-		    $options = $this->options_cache[$usecache];
-		    $selected=$selectid;
-		}
-		else
-		{
-    		$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
-
-    		$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
-    		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
-    		$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
-    		$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
-    		$sql .= " AND aa.active = 1";
-    		$sql .= " ORDER BY aa.account_number";
-
-    		dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
-    		$resql = $this->db->query($sql);
-
-    		if (!$resql) {
-    			$this->error = "Error " . $this->db->lasterror();
-    			dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
-    			return -1;
-    		}
-
-    		$out .= ajax_combobox($htmlname, $event);
-
-    		$selected = 0;
-    		while ($obj = $this->db->fetch_object($resql))
-    		{
-    			$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
-    			$label = dol_trunc($label, $trunclength);
-
-    			$select_value_in = $obj->rowid;
-    			$select_value_out = $obj->rowid;
-
-    			// Try to guess if we have found default value
-    			if ($select_in == 1) {
-    				$select_value_in = $obj->account_number;
-    			}
-    			if ($select_out == 1) {
-    				$select_value_out = $obj->account_number;
-    			}
-    			// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
-    			// Because same account_number can be share between different accounting_system and do have the same meaning
-    			if ($selectid != '' && $selectid == $select_value_in) {
-    			    //var_dump("Found ".$selectid." ".$select_value_in);
-    				$selected = $select_value_out;
-    			}
-
-    			$options[$select_value_out] = $label;
-    		}
-    		$this->db->free($resql);
-
-    		if ($usecache)
-    		{
-                $this->options_cache[$usecache] = $options;
-    		}
-		}
-
-		$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
-
-		return $out;
-	}
-
-	/**
-	 * Return list of auxilary thirdparty accounts
-	 *
-	 * @param string $selectid Preselected pcg_type
-	 * @param string $htmlname Name of field in html form
-	 * @param int $showempty Add an empty field
-	 * @param array $event Event options
-	 *
-	 * @return string String with HTML select
-	 */
-	function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) {
-
-		$aux_account = array();
-
-		// Auxiliary customer account
-		$sql = "SELECT DISTINCT code_compta, nom ";
-		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
-	    $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);
-		if ($resql) {
-			while ($obj = $this->db->fetch_object($resql)) {
-				if (!empty($obj->code_compta)) {
-					$aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')';
-				}
-			}
-		} else {
-			$this->error = "Error ".$this->db->lasterror();
-			dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
-			return -1;
-		}
-		$this->db->free($resql);
-
-		// Auxiliary supplier account
-		$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
-		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
-	    $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);
-		if ($resql) {
-			while ($obj = $this->db->fetch_object($resql)) {
-				if (!empty($obj->code_compta_fournisseur)) {
-					$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
-				}
-			}
-		} else {
-			$this->error = "Error ".$this->db->lasterror();
-			dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
-			return -1;
-		}
-		$this->db->free($resql);
-
-		// Build select
-		$out = ajax_combobox($htmlname, $event);
-		$out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
-
-		return $out;
-	}
-
-	/**
-	 * Return HTML combo list of years existing into book keepping
-	 *
-	 * @param string $selected Preselected value
-	 * @param string $htmlname Name of HTML select object
-	 * @param int $useempty Affiche valeur vide dans liste
-	 * @param string $output_format (html/opton (for option html only)/array (to return options arrays
-	 * @return string/array
-	 */
-	function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
-	{
-	    global $conf;
-
-		$out_array = array();
-
-		$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
-		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
-	    $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);
-
-		if (!$resql) {
-			$this->error = "Error ".$this->db->lasterror();
-			dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
-			return -1;
-		}
-		while ($obj = $this->db->fetch_object($resql)) {
-			$out_array[$obj->dtyear] = $obj->dtyear;
-		}
-		$this->db->free($resql);
-
-		if ($output_format == 'html') {
-			return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
-		} else {
-			return $out_array;
-		}
-	}
-
-	/**
-	 * Return HTML combo list of years existing into book keepping
-	 *
-	 * @param  string          $selected       Preselected value
-	 * @param  string          $htmlname       Name of HTML select object
-	 * @param  int             $useempty       Affiche valeur vide dans liste
-	 * @param  string          $output_format  Html/option (for option html only)/array (to return options arrays
-	 * @return string/array
-	 */
-	function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
-	{
-	    global $conf,$langs;
-
-		$out_array = array();
-
-		$sql = "SELECT DISTINCT code_journal";
-		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
-	    $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);
-
-		if (!$resql) {
-			$this->error = "Error ".$this->db->lasterror();
-			dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
-			return -1;
-		}
-		while ($obj = $this->db->fetch_object($resql)) {
-			$out_array[$obj->code_journal] = $obj->code_journal?$obj->code_journal:$langs->trans("NotDefined");  // TODO Not defined is accepted ? We should avoid this, shouldn't we ?
-		}
-		$this->db->free($resql);
-
-		if ($output_format == 'html') {
-			return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
-		} else {
-			return $out_array;
-		}
-	}
-}
diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php
index baa70bf51e8..eca3be1d477 100644
--- a/htdocs/accountancy/customer/card.php
+++ b/htdocs/accountancy/customer/card.php
@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2013-2014 Olivier Geffroy		<jeff@jeffinfo.com>
  * Copyright (C) 2013-2014 Florian Henry		<florian.henry@open-concept.pro>
- * Copyright (C) 2013-2015 Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2013-2017 Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
  *
  * 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
@@ -26,7 +26,7 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Langs
 $langs->load("bills");
@@ -39,9 +39,7 @@ $id = GETPOST('id');
 // Security check
 if ($user->societe_id > 0)
 	accessforbidden();
-	
-	
-	
+
 /*
  * Actions
  */
@@ -84,7 +82,7 @@ if ($cancel == $langs->trans("Cancel")) {
  */
 $form = new Form($db);
 $facture_static = new Facture($db);
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 if (! empty($id)) {
 	$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,";
@@ -96,50 +94,50 @@ if (! empty($id)) {
 	$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
 	$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
 	$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
-	
+
 	dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
 	$result = $db->query($sql);
-	
+
 	if ($result) {
 		$num_lines = $db->num_rows($result);
 		$i = 0;
-		
+
 		if ($num_lines) {
-			
+
 			$objp = $db->fetch_object($result);
-			
+
 			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
 			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
 			print '<input type="hidden" name="action" value="ventil">';
-			
+
 			print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup');
-			
+
 			dol_fiche_head();
-			
+
 			print '<table class="border" width="100%">';
-			
+
 			// Ref facture
 			print '<tr><td>' . $langs->trans("Invoice") . '</td>';
 			$facture_static->ref = $objp->facnumber;
 			$facture_static->id = $objp->facid;
 			print '<td>' . $facture_static->getNomUrl(1) . '</td>';
 			print '</tr>';
-			
+
 			print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
 			print '<td>' . nl2br($objp->description) . '</td></tr>';
 			print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
-			print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
+			print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
 			print '</td></tr>';
 			print '</table>';
-			
+
 			dol_fiche_end();
-			
+
 			print '<div class="center">';
 			print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 			print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
 			print '</div>';
-			
+
 			print '</form>';
 		} else {
 			print "Error";
diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index 52b3a31d6f0..f3763dd9ca0 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -28,7 +28,7 @@
 require '../../main.inc.php';
 
 // Class
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@@ -77,7 +77,7 @@ if ($user->societe_id > 0)
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 
 /*
@@ -254,14 +254,14 @@ if ($result) {
 	print $langs->trans("DescVentilDoneCustomer") . '<br>';
 
 	print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
-	print $formventilation->select_account($account_parent, 'account_parent', 1);
+	print $formaccounting->select_account($account_parent, 'account_parent', 1);
 	print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
 
 	$moreforfilter = '';
-	
-    print '<div class="div-table-responsive">';
+
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
-	
+
 	print '<tr class="liste_titre_filter">';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
@@ -278,7 +278,7 @@ if ($result) {
 	$searchpicto=$form->showFilterButtons();
 	print $searchpicto;
 	print "</td></tr>\n";
-	
+
 	print '<tr class="liste_titre">';
 	print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "fd.rowid", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
@@ -303,16 +303,16 @@ if ($result) {
 
 		$facture_static->ref = $objp->facnumber;
 		$facture_static->id = $objp->rowid;
-		
+
 		$product_static->ref = $objp->product_ref;
 		$product_static->id = $objp->product_id;
 		$product_static->type = $objp->product_type;
 		$product_static->label = $objp->product_label;
-		
+
 		print '<tr class="oddeven">';
 
 		print '<td>' . $objp->rowid . '</td>';
-		
+
 		// Ref Invoice
 		print '<td>' . $facture_static->getNomUrl(1) . '</td>';
 
@@ -324,13 +324,13 @@ if ($result) {
 			print $product_static->getNomUrl(1);
 		if ($objp->product_label) print '<br>'.$objp->product_label;
 		print '</td>';
-		
+
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
 		$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
 		print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
 		print '</td>';
-		
+
 		print '<td align="right">' . price($objp->total_ht) . '</td>';
 		print '<td align="center">' . price($objp->tva_tx) . '</td>';
 		print '<td>';
@@ -338,20 +338,20 @@ if ($result) {
 		print img_edit();
 		print '</a>';
 		print '</td>';
-		
+
 		print '<td>' . $objp->country .'</td>';
-		
+
 		print '<td>' . $objp->tva_intra . '</td>';
-		
+
 		print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
 
 		print "</tr>";
 		$i ++;
 	}
-	
+
 	print "</table>";
 	print "</div>";
-	
+
     if ($nbtotalofrecords > $limit) {
         print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
     }
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index bbd875e0dbf..8af289f2c99 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -30,7 +30,7 @@ require '../../main.inc.php';
 // Class
 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 
@@ -85,7 +85,7 @@ if ($user->societe_id > 0)
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 $accounting = new AccountingAccount($db);
 $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
 $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
@@ -101,7 +101,7 @@ if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction !=
 // Purge search criteria
 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
 {
-    $search_lineid = '';
+	$search_lineid = '';
 	$search_ref = '';
 	$search_invoice = '';
 	$search_label = '';
@@ -241,7 +241,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;
@@ -254,8 +254,7 @@ if ($result) {
 	//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
 	//if ($massaction == 'presend') $arrayofmassactions=array();
 	$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
-	
-	
+
 	print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
 	print '<input type="hidden" name="action" value="ventil">';
 	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -264,16 +263,16 @@ if ($result) {
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 	print '<input type="hidden" name="page" value="'.$page.'">';
-	
+
 	print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
 
 	print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
 
 	if ($msg) print $msg.'<br>';
-	
+
 	$moreforfilter = '';
-	
-    print '<div class="div-table-responsive">';
+
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
 
 	// We add search filter
@@ -309,7 +308,7 @@ if ($result) {
 	if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
 	print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
 	print "</tr>\n";
-	
+
 	$facture_static = new Facture($db);
 	$product_static = new Product($db);
 	$form = new Form($db);
@@ -330,7 +329,7 @@ if ($result) {
 		$facture_static->ref = $objp->facnumber;
 		$facture_static->id = $objp->facid;
 		$facture_static->type = $objp->ftype;
-		
+
 		$code_sell_p_notset = '';
 		$objp->aarowid_suggest = $objp->aarowid;
 
@@ -350,30 +349,30 @@ if ($result) {
 		if (! empty($objp->code_sell)) {
 			$objp->code_sell_p = $objp->code_sell;       // Code on product
 		} else {
-    	    $code_sell_p_notset = 'color:orange';
+			$code_sell_p_notset = 'color:orange';
 		}
 		if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
-		
+
 		// $objp->code_sell_p is now code of product/service
 		// $objp->code_sell_l is now default code of product/service
-					
+
 		print '<tr class="oddeven">';
 
 		// Line id
 		print '<td>' . $objp->rowid . '</td>';
-		
+
 		// Ref Invoice
 		print '<td>' . $facture_static->getNomUrl(1) . '</td>';
 
 		print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
-		
+
 		// Ref Product
 		print '<td>';
 		if ($product_static->id)
 			print $product_static->getNomUrl(1);
 		if ($objp->product_label) print '<br>'.$objp->product_label;
 		print '</td>';
-		
+
 		print '<td class="tdoverflowonsmartphone">';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
 		$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
@@ -383,14 +382,14 @@ if ($result) {
 		print '<td align="right">';
 		print price($objp->total_ht);
 		print '</td>';
-		
+
 		// Vat rate
 		if ($objp->vat_tx_l != $objp->vat_tx_p)
 			$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
 		print '<td style="' . $code_vat_differ . '" align="right">';
 		print price($objp->tva_tx_line);
 		print '</td>';
-		
+
 		// Current account
 		print '<td align="center" style="' . $code_sell_p_notset . '">';
 	    print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));
@@ -403,7 +402,7 @@ if ($result) {
 
 		// Suggested accounting account
 		print '<td align="center">';
-		print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
+		print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
 		print '</td>';
 		
 		print '<td align="center">';
@@ -414,7 +413,7 @@ if ($result) {
 	}
 	print '</table>';
 	print "</div>";
-	
+
 	print '</form>';
 } else {
 	print $db->error();
diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php
index 52440385e50..e37b35f1003 100644
--- a/htdocs/accountancy/expensereport/card.php
+++ b/htdocs/accountancy/expensereport/card.php
@@ -30,7 +30,7 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Langs
 $langs->load("bills");
@@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) {
 // Create
 $form = new Form($db);
 $expensereport_static = new ExpenseReport($db);
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 if (! empty($id)) {
 	$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
@@ -135,7 +135,7 @@ if (! empty($id)) {
 			print '<td>' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
 
 			print '<tr><td>' . $langs->trans("Account") . '</td><td>';
-			print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
+			print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
 			print '</td></tr>';
 			print '</table>';
 
diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php
index 6d0ffbd4476..b3936bbf1a6 100644
--- a/htdocs/accountancy/expensereport/lines.php
+++ b/htdocs/accountancy/expensereport/lines.php
@@ -27,7 +27,7 @@
 require '../../main.inc.php';
 
 // Class
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@@ -74,7 +74,7 @@ if ($user->societe_id > 0)
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 
 /*
@@ -226,7 +226,7 @@ if ($result) {
 	print $langs->trans("DescVentilDoneExpenseReport") . '<br>';
 
 	print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
-	print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
+	print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1);
 	print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
 
 	$moreforfilter = '';
diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php
index 72316e4c4d6..b1a86c96838 100644
--- a/htdocs/accountancy/expensereport/list.php
+++ b/htdocs/accountancy/expensereport/list.php
@@ -29,7 +29,7 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 
@@ -83,7 +83,7 @@ if ($user->societe_id > 0)
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 $accounting = new AccountingAccount($db);
 
 
@@ -343,7 +343,7 @@ if ($result) {
 
 		// Suggested accounting account
 		print '<td align="center">';
-		print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
+		print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
 		print '</td>';
 
 		print '<td align="center">';
diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php
index b7c5979aa7a..47a99c88496 100644
--- a/htdocs/accountancy/supplier/card.php
+++ b/htdocs/accountancy/supplier/card.php
@@ -1,11 +1,11 @@
 <?php
 /* Copyright (C) 2004       Rodolphe Quiedeville  <rodolphe@quiedeville.org>
  * Copyright (C) 2005       Simon TOSSER          <simon@kornog-computing.com>
- * Copyright (C) 2013-2015  Alexandre Spangaro    <aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2013-2017  Alexandre Spangaro    <aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2013-2014  Olivier Geffroy       <jeff@jeffinfo.com>
- * Copyright (C) 2013-2014	Florian Henry	      <florian.henry@open-concept.pro>
- * Copyright (C) 2014	    Juanjo Menent		  <jmenent@2byte.es>
- * Copyright (C) 2015       Jean-François Ferry	  <jfefe@aternatik.fr>
+ * Copyright (C) 2013-2014  Florian Henry         <florian.henry@open-concept.pro>
+ * Copyright (C) 2014       Juanjo Menent         <jmenent@2byte.es>
+ * Copyright (C) 2015       Jean-François Ferry   <jfefe@aternatik.fr>
  *
  * 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
@@ -30,7 +30,7 @@ require '../../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Langs
 $langs->load("bills");
@@ -52,11 +52,11 @@ if ($user->societe_id > 0)
 if ($action == 'ventil' && $user->rights->accounting->bind->write) {
 	if (! GETPOST('cancel', 'alpha')) {
 	    if ($codeventil < 0) $codeventil = 0;
-	    
+
 		$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
 		$sql .= " SET fk_code_ventilation = " . $codeventil;
 		$sql .= " WHERE rowid = " . $id;
-		
+
 		$resql = $db->query($sql);
 		if (! $resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
@@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) {
 // Create
 $form = new Form($db);
 $facturefournisseur_static = new FactureFournisseur($db);
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 if (! empty($id)) {
 	$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
@@ -107,41 +107,41 @@ if (! empty($id)) {
 		
 		if ($num_lines) {
 			$objp = $db->fetch_object($result);
-			
+
 			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
 			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
 			print '<input type="hidden" name="action" value="ventil">';
-			
+
 			print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup');
-			
+
 			dol_fiche_head();
-			
+
 			print '<table class="border" width="100%">';
-			
+
 			// ref invoice
 			print '<tr><td>' . $langs->trans("BillsSuppliers") . '</td>';
 			$facturefournisseur_static->ref = $objp->facnumber;
 			$facturefournisseur_static->id = $objp->facid;
 			print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
 			print '</tr>';
-			
+
 			print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
 			print '<td>' . stripslashes(nl2br($objp->description)) . '</td></tr>';
 			print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
 			print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
 			print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
-			print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
+			print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
 			print '</td></tr>';
 			print '</table>';
-			
+
 			dol_fiche_end();
-			
+
 			print '<div class="center">';
 			print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 			print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
 			print '</div>';
-			
+
 			print '</form>';
 		} else {
 			print "Error";
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index 1a95262f861..2757b6d8aec 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -1,9 +1,9 @@
 <?php
 /* Copyright (C) 2013-2016 Olivier Geffroy		<jeff@jeffinfo.com>
- * Copyright (C) 2013-2016 Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2013-2017 Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2014-2015 Ari Elbaz (elarifr)	<github@accedinfo.com>  
  * Copyright (C) 2013-2016 Florian Henry		<florian.henry@open-concept.pro>
- * Copyright (C) 2014	   Juanjo Menent		<jmenent@2byte.es>
+ * Copyright (C) 2014      Juanjo Menent		<jmenent@2byte.es>
  *   
  * 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
@@ -27,7 +27,7 @@
 require '../../main.inc.php';
 
 // Class
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
@@ -76,7 +76,7 @@ if ($user->societe_id > 0)
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 
 
 /*
@@ -237,7 +237,7 @@ if ($result) {
 	print $langs->trans("DescVentilDoneSupplier") . '<br>';
 	
 	print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
-	print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
+	print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1);
 	print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
 	
 	$moreforfilter = '';
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 061e465b1e7..9c822425a1c 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -1,10 +1,10 @@
 <?php
 /* Copyright (C) 2013-2014	Olivier Geffroy			<jeff@jeffinfo.com>
- * Copyright (C) 2013-2016	Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2013-2017	Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2014-2015	Ari Elbaz (elarifr)		<github@accedinfo.com>
  * Copyright (C) 2013-2014	Florian Henry			<florian.henry@open-concept.pro>
  * Copyright (C) 2014		Juanjo Menent			<jmenent@2byte.es>s
- * Copyright (C) 2016	  	Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2016		Laurent Destailleur		<eldy@users.sourceforge.net>
  *
  * 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
@@ -30,7 +30,7 @@ require '../../main.inc.php';
 // Class
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 
@@ -85,7 +85,7 @@ if ($user->societe_id > 0)
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();
 
-$formventilation = new FormVentilation($db);
+$formaccounting = new FormAccounting($db);
 $accounting = new AccountingAccount($db);
 // TODO: we should need to check if result is a really exist accountaccount rowid.....
 $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
@@ -238,11 +238,11 @@ 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;
-	
+
 	$arrayofmassactions =  array(
 	    'ventil'=>$langs->trans("Ventilate")
 	    //'presend'=>$langs->trans("SendByMail"),
@@ -251,8 +251,7 @@ if ($result) {
 	//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
 	//if ($massaction == 'presend') $arrayofmassactions=array();
 	$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
-	
-	
+
 	print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
 	print '<input type="hidden" name="action" value="ventil">';
 	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -261,15 +260,15 @@ if ($result) {
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 	print '<input type="hidden" name="page" value="'.$page.'">';
-	
+
 	print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
 
 	print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
 
 	if ($msg) print $msg.'<br>';
-	
+
 	$moreforfilter = '';
-	
+
     print '<div class="div-table-responsive">';
 
     print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@@ -329,7 +328,7 @@ if ($result) {
 		$productfourn_static->id = $objp->product_id;
 		$productfourn_static->type = $objp->type;
 		$productfourn_static->label = $objp->product_label;
-		
+
 		$facturefourn_static->ref = $objp->ref;
 		$facturefourn_static->id = $objp->facid;
 		$facturefourn_static->type = $objp->type;
@@ -347,14 +346,14 @@ if ($result) {
 				$objp->aarowid_suggest = $aarowid_p;
 		}
 		if ($objp->code_buy_l == -1) $objp->code_buy_l='';
-		
+
 		if (! empty($objp->code_buy)) {
 			$objp->code_buy_p = $objp->code_buy;       // Code on product
 		} else {
 			$code_buy_p_notset = 'color:orange';
 		}
 		if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red';
-		
+
 		// $objp->code_buy_p is now code of product/service
 		// $objp->code_buy_l is now default code of product/service
 					
@@ -362,23 +361,23 @@ if ($result) {
 
 		// Line id
 		print '<td>' . $objp->rowid . '</td>';
-		
+
 		// Ref Invoice
 		print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
 
 		print '<td class="tdoverflowonsmartphone">';
 		print $objp->invoice_label;
 		print '</td>';
-		
+
 		print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
-		
+
 		// Ref product
 		print '<td>';
 		if ($productfourn_static->id)
 			print $productfourn_static->getNomUrl(1);
 		if ($objp->product_label) print '<br>'.$objp->product_label;
         print '</td>';
-        
+
         // Description
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
@@ -409,9 +408,9 @@ if ($result) {
 
 		// Suggested accounting account
 		print '<td align="center">';
-		print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
+		print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
 		print '</td>';
-		
+
 		// Colonne choix ligne a ventiler
 		print '<td align="center">';
 		print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 28db9ef8b49..913fcf75de6 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -39,7 +39,7 @@ 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';
 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';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("errors");
 $langs->load("admin");
@@ -1662,7 +1662,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
 
 	$formadmin = new FormAdmin($db);
 	$formcompany = new FormCompany($db);
-	if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
+	if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
 	foreach ($fieldlist as $field => $value)
 	{
@@ -1811,7 +1811,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
 			{
 			    $fieldname = $fieldlist[$field];
 				$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
-				print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
+				print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
 			}
 			else
 			{
diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php
index 86d963ed54f..c3e8bad9f6d 100644
--- a/htdocs/admin/loan.php
+++ b/htdocs/admin/loan.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2014-2016	Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
+/* Copyright (C) 2014-2017  Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
  *
  * 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
@@ -26,7 +26,7 @@ require '../main.inc.php';
 	
 // Class
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("admin");
 $langs->load("loan");
@@ -77,7 +77,7 @@ if ($action == 'update')
 llxHeader();
 
 $form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup');
@@ -106,7 +106,7 @@ foreach ($list as $key)
 	print '<td>';
 	if (! empty($conf->accounting->enabled))
 	{
-		print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
+		print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
 	}
 	else
 	{
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index b9e5df738ad..caea3bef9f7 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -39,7 +39,7 @@ 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';
 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';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("errors");
 $langs->load("admin");
@@ -841,7 +841,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
 
 	$formadmin = new FormAdmin($db);
 	$formcompany = new FormCompany($db);
-	if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
+	if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
 	foreach ($fieldlist as $field => $value)
 	{
diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php
index 8f115d3963b..85603de2ae5 100644
--- a/htdocs/admin/salaries.php
+++ b/htdocs/admin/salaries.php
@@ -26,7 +26,7 @@ require '../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("admin");
 $langs->load("salaries");
@@ -76,7 +76,7 @@ if ($action == 'update')
 llxHeader('',$langs->trans('SalariesSetup'));
 
 $form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup');
@@ -109,7 +109,7 @@ foreach ($list as $key)
 	print '<td>';
 	if (! empty($conf->accounting->enabled))
 	{
-		print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
+		print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
 	}
 	else
 	{
diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php
index dbdce59c3c5..59796919a8b 100644
--- a/htdocs/admin/taxes.php
+++ b/htdocs/admin/taxes.php
@@ -27,7 +27,7 @@
 
 require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load('admin');
 
@@ -113,7 +113,7 @@ if ($action == 'update') {
 
 llxHeader();
 $form=new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
@@ -216,7 +216,7 @@ foreach ($list as $key)
 	print '<td>';
 	if (! empty($conf->accounting->enabled))
 	{
-		print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
+		print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
 	}
 	else
 	{
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index a8263a74916..2cb90b6a44a 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php';
 require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
 if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
@@ -281,8 +280,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
 $form = new Form($db);
 $formbank = new FormBank($db);
 $formcompany = new FormCompany($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy2 = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
 
@@ -511,7 +509,7 @@ if ($action == 'create')
 	{
 		print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
 		print '<td>';
-		print $formaccountancy->select_account($object->account_number, 'account_number', 1, '', 1, 1);
+		print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
 		print '</td></tr>';
 	}
 	else
@@ -525,7 +523,7 @@ if ($action == 'create')
 	{
 		print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
 	    print '<td>';
-		print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
+		print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
 		print '</td></tr>';
 	}
 
@@ -957,43 +955,42 @@ else
 
 
 		//print '<div class="underbanner clearboth"></div>';
-		
+
 		print '<table class="border" width="100%">';
-		
+
 		// Accountancy code
 		$tdextra = ' class="titlefieldcreate"';
-		
+
 		if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
 		    $tdextra = ' class="fieldrequired titlefieldcreate"';
 		}
-		
+
 		print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
 		print '<td>';
 		if (!empty($conf->accounting->enabled)) {
-		    print $formaccountancy->select_account($object->account_number, 'account_number', 1, '', 1, 1);
+		    print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
 		} else {
 		    print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
 		}
 		print '</td></tr>';
-		
+
 		// Accountancy journal
 		if (! empty($conf->accounting->enabled))
 		{
 			print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
 			print '<td>';
-			print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
+			print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
 			print '</td></tr>';
 		}
-		
+
 		print '</table>';
-		
-		
+
 		if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
 		{
 		    print '<br>';
-		    
+
 		    //print '<div class="underbanner clearboth"></div>';
-		    
+
 			print '<table class="border" width="100%">';
 
 			// If bank account
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 4875ac593c6..20c49c71468 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
 
 $langs->load("compta");
@@ -180,7 +180,7 @@ if ($action == 'delete')
 llxHeader("",$langs->trans("VariousPayment"));
 
 $form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 if ($id)
 {
@@ -271,9 +271,9 @@ if ($action == 'create')
 	{
 		print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
         print '<td>';
-		print $formaccountancy->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
+		print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
         print '</td></tr>';
-	}			
+	}
 	else // For external software 
 	{
 		print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 97f31f05e99..3ad3721c9d4 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -1,5 +1,9 @@
 <?php
-/* Copyright (C) 2016-2017	Alexandre Spangaro	<aspangaro@zendsi.com>
+/* Copyright (C) 2013-2016 Florian Henry        <florian.henry@open-concept.pro>
+ * Copyright (C) 2013-2014 Olivier Geffroy      <jeff@jeffinfo.com>
+ * Copyright (C) 2015      Ari Elbaz (elarifr)  <github@accedinfo.com>
+ * Copyright (C) 2016      Marcos García        <marcosgdf@gmail.com>
+ * Copyright (C) 2016-2017 Alexandre Spangaro   <aspangaro@zendsi.com>
  *
  * 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
@@ -28,7 +32,7 @@
 class FormAccounting extends Form
 {
 
-    private $options_cache = array();
+	private $options_cache = array();
 
 	var $db;
 	var $error;
@@ -205,5 +209,261 @@ class FormAccounting extends Form
         
         print $out;
     }
+
+	/**
+	 * Return select filter with date of transaction
+	 *
+	 * @param string $htmlname Name of select field
+	 * @param string $selectedkey Value
+	 * @return string HTML edit field
+	 */
+	function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') {
+		$options = array();
+
+		$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
+	    $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
+		$sql .= ' ORDER BY import_key DESC';
+
+		dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG);
+		$resql = $this->db->query($sql);
+
+		if (!$resql) {
+			$this->error = "Error " . $this->db->lasterror();
+			dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
+			return - 1;
+		}
+
+		while ($obj = $this->db->fetch_object($resql)) {
+			$options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext');
+		}
+
+		return Form::selectarray($htmlname, $options, $selectedkey);
+	}
+
+	/**
+	 * Return list of accounts with label by chart of accounts
+	 *
+	 * @param string   $selectid           Preselected id or code of accounting accounts (depends on $select_in)
+	 * @param string   $htmlname           Name of field in html form
+	 * @param int      $showempty          Add an empty field
+	 * @param array    $event              Event options
+	 * @param int      $select_in          0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
+	 * @param int      $select_out         Set value returned by select. 0=rowid (default), 1=account_number
+	 * @param string   $morecss            More css non HTML object
+	 * @param string   $usecache           Key to use to store result into a cache. Next call with same key will reuse the cache.
+	 * @return string                      String with HTML select
+	 */
+	function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='')
+	{
+		global $conf;
+
+		require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
+
+		$out = '';
+		
+    	$options = array();
+		if ($usecache && ! empty($this->options_cache[$usecache]))
+		{
+		    $options = $this->options_cache[$usecache];
+		    $selected=$selectid;
+		}
+		else
+		{
+    		$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
+
+    		$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
+    		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
+    		$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
+    		$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
+    		$sql .= " AND aa.active = 1";
+    		$sql .= " ORDER BY aa.account_number";
+
+    		dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
+    		$resql = $this->db->query($sql);
+
+    		if (!$resql) {
+    			$this->error = "Error " . $this->db->lasterror();
+    			dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
+    			return -1;
+    		}
+
+    		$out .= ajax_combobox($htmlname, $event);
+
+    		$selected = 0;
+    		while ($obj = $this->db->fetch_object($resql))
+    		{
+    			$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
+    			$label = dol_trunc($label, $trunclength);
+
+    			$select_value_in = $obj->rowid;
+    			$select_value_out = $obj->rowid;
+
+    			// Try to guess if we have found default value
+    			if ($select_in == 1) {
+    				$select_value_in = $obj->account_number;
+    			}
+    			if ($select_out == 1) {
+    				$select_value_out = $obj->account_number;
+    			}
+    			// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
+    			// Because same account_number can be share between different accounting_system and do have the same meaning
+    			if ($selectid != '' && $selectid == $select_value_in) {
+    			    //var_dump("Found ".$selectid." ".$select_value_in);
+    				$selected = $select_value_out;
+    			}
+
+    			$options[$select_value_out] = $label;
+    		}
+    		$this->db->free($resql);
+
+    		if ($usecache)
+    		{
+                $this->options_cache[$usecache] = $options;
+    		}
+		}
+
+		$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
+
+		return $out;
+	}
+
+	/**
+	 * Return list of auxilary thirdparty accounts
+	 *
+	 * @param string $selectid Preselected pcg_type
+	 * @param string $htmlname Name of field in html form
+	 * @param int $showempty Add an empty field
+	 * @param array $event Event options
+	 *
+	 * @return string String with HTML select
+	 */
+	function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) {
+
+		$aux_account = array();
+
+		// Auxiliary customer account
+		$sql = "SELECT DISTINCT code_compta, nom ";
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
+	    $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);
+		if ($resql) {
+			while ($obj = $this->db->fetch_object($resql)) {
+				if (!empty($obj->code_compta)) {
+					$aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')';
+				}
+			}
+		} else {
+			$this->error = "Error ".$this->db->lasterror();
+			dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
+			return -1;
+		}
+		$this->db->free($resql);
+
+		// Auxiliary supplier account
+		$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
+		$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);
+		if ($resql) {
+			while ($obj = $this->db->fetch_object($resql)) {
+				if (!empty($obj->code_compta_fournisseur)) {
+					$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
+				}
+			}
+		} else {
+			$this->error = "Error ".$this->db->lasterror();
+			dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
+			return -1;
+		}
+		$this->db->free($resql);
+
+		// Build select
+		$out = ajax_combobox($htmlname, $event);
+		$out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
+
+		return $out;
+	}
+
+	/**
+	 * Return HTML combo list of years existing into book keepping
+	 *
+	 * @param string $selected Preselected value
+	 * @param string $htmlname Name of HTML select object
+	 * @param int $useempty Affiche valeur vide dans liste
+	 * @param string $output_format (html/opton (for option html only)/array (to return options arrays
+	 * @return string/array
+	 */
+	function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
+	{
+	    global $conf;
+
+		$out_array = array();
+
+		$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
+	    $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);
+
+		if (!$resql) {
+			$this->error = "Error ".$this->db->lasterror();
+			dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
+			return -1;
+		}
+		while ($obj = $this->db->fetch_object($resql)) {
+			$out_array[$obj->dtyear] = $obj->dtyear;
+		}
+		$this->db->free($resql);
+
+		if ($output_format == 'html') {
+			return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
+		} else {
+			return $out_array;
+		}
+	}
+
+	/**
+	 * Return HTML combo list of years existing into book keepping
+	 *
+	 * @param  string          $selected       Preselected value
+	 * @param  string          $htmlname       Name of HTML select object
+	 * @param  int             $useempty       Affiche valeur vide dans liste
+	 * @param  string          $output_format  Html/option (for option html only)/array (to return options arrays
+	 * @return string/array
+	 */
+	function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
+	{
+	    global $conf,$langs;
+
+		$out_array = array();
+
+		$sql = "SELECT DISTINCT code_journal";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
+	    $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);
+
+		if (!$resql) {
+			$this->error = "Error ".$this->db->lasterror();
+			dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
+			return -1;
+		}
+		while ($obj = $this->db->fetch_object($resql)) {
+			$out_array[$obj->code_journal] = $obj->code_journal?$obj->code_journal:$langs->trans("NotDefined");  // TODO Not defined is accepted ? We should avoid this, shouldn't we ?
+		}
+		$this->db->free($resql);
+
+		if ($output_format == 'html') {
+			return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
+		} else {
+			return $out_array;
+		}
+	}
 }
 
diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php
index 2888b911700..c8d8be2461d 100644
--- a/htdocs/don/admin/donation.php
+++ b/htdocs/don/admin/donation.php
@@ -1,9 +1,9 @@
 <?php
 /* Copyright (C) 2005-2010  Laurent Destailleur  	<eldy@users.sourceforge.net>
- * Copyright (C) 2012-2015	Juanjo Menent			<jmenent@2byte.es>
+ * Copyright (C) 2012-2015  Juanjo Menent			<jmenent@2byte.es>
  * Copyright (C) 2013-2017  Philippe Grand			<philippe.grand@atoo-net.com>
- * Copyright (C) 2015       Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
- * Copyright (C) 2015  		Benoit Bruchard			<benoitb21@gmail.com>
+ * Copyright (C) 2015-2017  Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2015       Benoit Bruchard			<benoitb21@gmail.com>
  *
  * 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
@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.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';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $langs->load("admin");
 $langs->load("donations");
@@ -199,7 +199,7 @@ else if ($action == 'setart885') {
 
 $dir = "../../core/modules/dons/";
 $form=new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@@ -364,7 +364,7 @@ print '<label for="DONATION_ACCOUNTINGACCOUNT">' . $label . '</label></td>';
 print '<td>';
 if (! empty($conf->accounting->enabled))
 {
-	print $formaccountancy->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
+	print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
 }
 else
 {
@@ -401,7 +401,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
 	print '<tr class="liste_titre">';
 	print '<td colspan="3">' . $langs->trans('Parameters') . '</td>';
 	print "</tr>\n";
-	
+
 	print '<tr class="oddeven">';
 	print '<td width="80%">' . $langs->trans("DONATION_ART200") . '</td>';
 	if (! empty($conf->global->DONATION_ART200)) {
@@ -414,7 +414,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
 		print '</a></td>';
 	}
 	print '</tr>';
-	
+
 	print '<tr class="oddeven">';
 	print '<td width="80%">' . $langs->trans("DONATION_ART238") . '</td>';
 	if (! empty($conf->global->DONATION_ART238)) {
@@ -427,7 +427,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
 		print '</a></td>';
 	}
 	print '</tr>';
-	
+
 	print '<tr class="oddeven">';
 	print '<td width="80%">' . $langs->trans("DONATION_ART885") . '</td>';
 	if (! empty($conf->global->DONATION_ART885)) {
diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php
index b58bfb929d9..81d43e46ab0 100644
--- a/htdocs/loan/card.php
+++ b/htdocs/loan/card.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2014-2016	Alexandre Spangaro   <aspangaro@zendsi.com>
+/* Copyright (C) 2014-2017	Alexandre Spangaro   <aspangaro@zendsi.com>
  * Copyright (C) 2015       Frederic France      <frederic.france@free.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
 
@@ -235,7 +235,7 @@ if (empty($reshook))
 
 $form = new Form($db);
 $formproject = new FormProjets($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 $title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
 $help_url = 'EN:Module_Loan|FR:Module_Emprunt';
@@ -337,19 +337,19 @@ if ($action == 'create')
 		// Accountancy_account_capital
         print '<tr><td class="titlefieldcreate">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
         print '<td>';
-		print $formaccountancy->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1);
+		print $formaccounting->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1);
         print '</td></tr>';
 
 		// Accountancy_account_insurance
         print '<tr><td>'.$langs->trans("LoanAccountancyInsuranceCode").'</td>';
         print '<td>';
-		print $formaccountancy->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
+		print $formaccounting->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
         print '</td></tr>';
 
 		// Accountancy_account_interest
         print '<tr><td>'.$langs->trans("LoanAccountancyInterestCode").'</td>';
         print '<td>';
-		print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
+		print $formaccounting->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
         print '</td></tr>';
 	}
 	else // For external software 
@@ -541,7 +541,7 @@ if ($id > 0)
 		{
 			if (! empty($conf->accounting->enabled))
 			{
-				print $formaccountancy->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1);
+				print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1);
 			}
 			else
 			{
@@ -566,7 +566,7 @@ if ($id > 0)
 		{
 			if (! empty($conf->accounting->enabled))
 			{
-				print $formaccountancy->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
+				print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
 			}
 			else
 			{
@@ -591,7 +591,7 @@ if ($id > 0)
 		{
 			if (! empty($conf->accounting->enabled))
 			{
-				print $formaccountancy->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1);
+				print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1);
 			}
 			else
 			{
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 7cd86404afa..2869e0f557c 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -52,7 +52,7 @@ if (! empty($conf->propal->enabled))     require_once DOL_DOCUMENT_ROOT.'/comm/p
 if (! empty($conf->facture->enabled))    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 if (! empty($conf->commande->enabled))   require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.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';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 $langs->load("products");
 $langs->load("other");
@@ -808,7 +808,7 @@ llxHeader('', $title, $helpurl);
 $form = new Form($db);
 $formfile = new FormFile($db);
 $formproduct = new FormProduct($db);
-if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
 
 // Load object modBarCodeProduct
 $res=0;
@@ -1113,13 +1113,13 @@ else
             // Accountancy_code_sell
             print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
             print '<td>';
-		    print $formaccountancy->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, '');
+		    print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, '');
             print '</td></tr>';
 
             // Accountancy_code_buy
             print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
             print '<td>';
-			print $formaccountancy->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, '');
+			print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, '');
             print '</td></tr>';
 		}			
 		else // For external software 
@@ -1406,15 +1406,15 @@ else
                 // Accountancy_code_sell
                 print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
                 print '<td>';
-				print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
+				print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
                 print '</td></tr>';
 
                 // Accountancy_code_buy
                 print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
                 print '<td>';
-				print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
+				print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
                 print '</td></tr>';
-			}			
+			}
 			else // For external software 
 			{
                 // Accountancy_code_sell
-- 
GitLab