From ae11ab12f6a689550b4dfd6784941130b422f555 Mon Sep 17 00:00:00 2001
From: aspangaro <alexandre.spangaro@gmail.com>
Date: Sun, 25 Jan 2015 06:54:17 +0100
Subject: [PATCH] FIXED Accounting module - Align core & module 3.6

---
 htdocs/accountancy/admin/export.php           | 19 +++--
 htdocs/core/modules/modAccounting.class.php   | 73 +++++++++++++------
 .../install/mysql/migration/3.6.0-3.7.0.sql   | 11 ++-
 3 files changed, 69 insertions(+), 34 deletions(-)

diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php
index d0eef1dc2f4..8fd0795c262 100644
--- a/htdocs/accountancy/admin/export.php
+++ b/htdocs/accountancy/admin/export.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2013-2014 Olivier Geffroy		<jeff@jeffinfo.com>
- * Copyright (C) 2013-2014 Alexandre Spangaro	<alexandre.spangaro@gmail.com>
+ * Copyright (C) 2013-2015 Alexandre Spangaro	<alexandre.spangaro@gmail.com>
  * Copyright (C) 2014	   Florian Henry		<florian.henry@open-concept.pro>
  * Copyright (C) 2014      Marcos GarcĂ­a        <marcosgdf@gmail.com>
  * Copyright (C) 2014	   Juanjo Menent		<jmenent@2byte.es>
@@ -44,7 +44,13 @@ $action = GETPOST('action', 'alpha');
 
 // Other parameters ACCOUNTING_*
 $list = array (
-		'ACCOUNTING_SEPARATORCSV'
+		'ACCOUNTING_EXPORT_SEPARATORCSV',
+		'ACCOUNTING_EXPORT_DATE',
+		'ACCOUNTING_EXPORT_PIECE',
+		'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT',
+		'ACCOUNTING_EXPORT_LABEL',
+		'ACCOUNTING_EXPORT_AMOUNT',
+		'ACCOUNTING_EXPORT_DEVISE'
 );
 
 /*
@@ -57,7 +63,7 @@ if ($action == 'update') {
 
 	if (! empty($modelcsv)) {
 
-		if (! dolibarr_set_const($db, 'ACCOUNTING_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
+		if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
 			$error ++;
 		}
 	} else {
@@ -112,12 +118,12 @@ print "<td>" . $langs->trans("Selectmodelcsv") . "</td>";
 print "<td>";
 print '<select class="flat" name="modelcsv" id="modelcsv">';
 print '<option value="0"';
-if ($conf->global->ACCOUNTING_MODELCSV == 0) {
+if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 0) {
 	print ' selected="selected"';
 }
 print '>' . $langs->trans("Modelcsv_normal") . '</option>';
 print '<option value="1"';
-if ($conf->global->ACCOUNTING_MODELCSV == 1) {
+if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
 	print ' selected="selected"';
 }
 print '>' . $langs->trans("Modelcsv_CEGID") . '</option>';
@@ -128,8 +134,7 @@ print "</table>";
 print "<br>\n";
 
 /*
- *  Params
- *
+ *  Parameters
  */
 
 $num = count($list);
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index e074bfe82f1..d683d4bb271 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2013-2014 Olivier Geffroy		<jeff@jeffinfo.com>
- * Copyright (C) 2013-2014 Alexandre Spangaro	<alexandre.spangaro@gmail.com>
+ * Copyright (C) 2013-2015 Alexandre Spangaro	<alexandre.spangaro@gmail.com>
  * Copyright (C) 2014      Ari Elbaz (elarifr)	<github@accedinfo.com>
  * Copyright (C) 2014 	   Florian Henry        <florian.henry@open-concept.pro>
  *
@@ -19,14 +19,14 @@
  */
 
 /**
- * \file		accountingex/core/modules/modAccounting.class.php
+ * \file		htdocs/core/modules/modAccounting.class.php
  * \ingroup		Accounting Expert
  * \brief		Module to activate Accounting Expert module
  */
 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
 
 /**
- * \class	modAccountingExpert
+ * \class	modAccounting
  * \brief	Description and activation class for module accounting expert
  */
 class modAccounting extends DolibarrModules
@@ -68,7 +68,7 @@ class modAccounting extends DolibarrModules
 		$this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled
 		$this->requiredby = array(); // List of modules id to disable if this one is disabled
 		$this->conflictwith = array("modComptabilite"); // List of modules are in conflict with this module
-		$this->phpmin = array(5, 2); // Minimum version of PHP required by module
+		$this->phpmin = array(5, 3); // Minimum version of PHP required by module
 		$this->need_dolibarr_version = array(3, 6); // Minimum version of Dolibarr required by module
 		$this->langfiles = array("accountancy");
 
@@ -87,7 +87,7 @@ class modAccounting extends DolibarrModules
 				"With this constants on, bank account number is always required"
 		);
 		$this->const[1] = array(
-				"ACCOUNTING_SEPARATORCSV",
+				"ACCOUNTING_EXPORT_SEPARATORCSV",
 				"string",
 				","
 		);
@@ -112,60 +112,85 @@ class modAccounting extends DolibarrModules
 				"SOC"
 		);
 		$this->const[6] = array(
-				"ACCOUNTING_CASH_JOURNAL",
-				"chaine",
-				"CAI"
-		);
-		$this->const[7] = array(
 				"ACCOUNTING_MISCELLANEOUS_JOURNAL",
 				"chaine",
 				"OD"
 		);
-		$this->const[8] = array(
-				"ACCOUNTING_BANK_JOURNAL",
-				"chaine",
-				"BQ"
-		); // Deprecated Move into llx_bank_account
-		$this->const[9] = array(
+		$this->const[7] = array(
 				"ACCOUNTING_ACCOUNT_TRANSFER_CASH",
 				"chaine",
 				"58"
 		);
-		$this->const[10] = array(
+		$this->const[8] = array(
 				"CHARTOFACCOUNTS",
 				"chaine",
 				"2"
 		);
-		$this->const[11] = array(
-				"ACCOUNTING_MODELCSV",
+		$this->const[9] = array(
+				"ACCOUNTING_EXPORT_MODELCSV",
 				"chaine",
 				"0"
 		);
-		$this->const[12] = array(
+		$this->const[10] = array(
 				"ACCOUNTING_LENGTH_GACCOUNT",
 				"chaine",
 				""
 		);
-		$this->const[13] = array(
+		$this->const[11] = array(
 				"ACCOUNTING_LENGTH_AACCOUNT",
 				"chaine",
 				""
 		);
-		$this->const[14] = array(
+		$this->const[12] = array(
 				"ACCOUNTING_LIMIT_LIST_VENTILATION",
 				"chaine",
 				"50"
 		);
-		$this->const[15] = array(
+		$this->const[13] = array(
 				"ACCOUNTING_LIST_SORT_VENTILATION_TODO",
 				"yesno",
 				"1"
 		);
-		$this->const[16] = array(
+		$this->const[14] = array(
 				"ACCOUNTING_LIST_SORT_VENTILATION_DONE",
 				"yesno",
 				"1"
 		);
+		$this->const[15] = array (
+				"ACCOUNTING_GROUPBYACCOUNT",
+				"yesno",
+				"1"
+		);
+		$this->const[16] = array (
+				"ACCOUNTING_EXPORT_DATE",
+				"chaine",
+				"%d%m%Y"
+		);
+		$this->const[17] = array (
+				"ACCOUNTING_EXPORT_PIECE",
+				"yesno",
+				"1"
+		);
+		$this->const[18] = array (
+				"ACCOUNTING_EXPORT_GLOBAL_ACCOUNT",
+				"yesno",
+				"1" 
+		);
+		$this->const[19] = array (
+				"ACCOUNTING_EXPORT_LABEL",
+				"yesno",
+				"1"
+		);
+		$this->const[20] = array (
+				"ACCOUNTING_EXPORT_AMOUNT",
+				"yesno",
+				"1" 
+		);
+		$this->const[21] = array (
+				"ACCOUNTING_EXPORT_DEVISE",
+				"yesno",
+				"1" 
+		);
 
 		// Tabs
 		$this->tabs = array();
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index 7dbdb7eb7dc..1b99d993ac3 100755
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -106,15 +106,20 @@ UPDATE llx_const SET name = 'ACCOUNTING_VAT_ACCOUNT' WHERE name = 'COMPTA_VAT_AC
 UPDATE llx_const SET name = 'ACCOUNTING_VAT_BUY_ACCOUNT' WHERE name = 'COMPTA_VAT_BUY_ACCOUNT';
 
 -- Compatibility with module Accounting Expert
-UPDATE llx_const SET name = 'ACCOUNTING_SEPARATORCSV' WHERE name = 'ACCOUNTINGEX_SEPARATORCSV';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_MODELCSV' WHERE name = 'ACCOUNTINGEX_MODELCSV';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_SEPARATORCSV' WHERE name = 'ACCOUNTINGEX_SEPARATORCSV';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_DATE' WHERE name = 'ACCOUNTINGEX_EXP_DATE';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_PIECE' WHERE name = 'ACCOUNTINGEX_EXP_PIECE';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT' WHERE name = 'ACCOUNTINGEX_EXP_GLOBAL_ACCOUNT';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_LABEL' WHERE name = 'ACCOUNTINGEX_EXP_LABEL';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_AMOUNT' WHERE name = 'ACCOUNTINGEX_EXP_AMOUNT';
+UPDATE llx_const SET name = 'ACCOUNTING_EXPORT_DEVISE' WHERE name = 'ACCOUNTINGEX_EXP_DEVISE';
 UPDATE llx_const SET name = 'ACCOUNTING_ACCOUNT_SUSPENSE' WHERE name = 'ACCOUNTINGEX_ACCOUNT_SUSPENSE';
 UPDATE llx_const SET name = 'ACCOUNTING_SELL_JOURNAL' WHERE name = 'ACCOUNTINGEX_SELL_JOURNAL';
 UPDATE llx_const SET name = 'ACCOUNTING_PURCHASE_JOURNAL' WHERE name = 'ACCOUNTINGEX_PURCHASE_JOURNAL';
 UPDATE llx_const SET name = 'ACCOUNTING_SOCIAL_JOURNAL' WHERE name = 'ACCOUNTINGEX_SOCIAL_JOURNAL';
-UPDATE llx_const SET name = 'ACCOUNTING_CASH_JOURNAL' WHERE name = 'ACCOUNTINGEX_CASH_JOURNAL';
 UPDATE llx_const SET name = 'ACCOUNTING_MISCELLANEOUS_JOURNAL' WHERE name = 'ACCOUNTINGEX_MISCELLANEOUS_JOURNAL';
 UPDATE llx_const SET name = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH' WHERE name = 'ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH';
-UPDATE llx_const SET name = 'ACCOUNTING_MODELCSV' WHERE name = 'ACCOUNTINGEX_MODELCSV';
 UPDATE llx_const SET name = 'ACCOUNTING_LENGTH_GACCOUNT' WHERE name = 'ACCOUNTINGEX_LENGTH_GACCOUNT';
 UPDATE llx_const SET name = 'ACCOUNTING_LENGTH_AACCOUNT' WHERE name = 'ACCOUNTINGEX_LENGTH_AACCOUNT';
 UPDATE llx_const SET name = 'ACCOUNTING_LIMIT_LIST_VENTILATION' WHERE name = 'ACCOUNTINGEX_LIMIT_LIST_VENTILATION';
-- 
GitLab